Source Code
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define fast ios::sync_with_stdio(false);cin.tie(0);
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<int, null_type, less<int>,
        rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int mod = 1e9 + 7;
ll fac[1001];

ll power(ll x,ll p){
			if(!p)return 1;
			ll v=power(x,p/2);
			if(p%2) return ((x*v)%mod *v)%mod;
			return (v*v)%mod;
			}
ll nCk(ll n,ll k){
	if(n<k)return 0;
	if(k==1)return n;
	return ((fac[n]*power(fac[k],mod-2)) %mod * power(fac[n-k],mod-2))%mod;
	}


int main(){
	fast
	fac[1] = fac[0] = 1;
	for(int i=2;i<=1000;i++)
		fac[i] = (i * fac[i-1])%mod;
	
	int n;
	cin>>n;
	if(n%2==1 || n<6){
		cout<<0;
		return 0;
		}
	
	int N = n/2;
	
	
	if(n==6)
		cout<<1<<endl;
	else if(n==8)
		cout<<4<<endl;
	else
		cout<<nCk(n-3,N);
	
	
return 0;
}
Copy
Bracket Sequence Bahaa
GNU G++17
13 ms
1.0 MB
Wrong Answer