This is my code for the problem MARBELS,
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ncr(ll n, ll k){
if(k > n)
return 0;
if(k==n)
return 1;
ll C[k+1];
memset(C, 0, sizeof(C));
C[0] = 1; // nC0 is 1
for (ll i = 1; i <= n; i++)
{
// Compute next row of pascal triangle using
// the previous row
for (ll j = min(i, k); j > 0; j--)
C[j] = ((C[j]%LONG_MAX) + (C[j-1]%LONG_MAX) )%LONG_MAX;
}
return C[k];
}
int main() {
ll t;
cin>>t;
while(t--) {
ll n,k;
cin>>n>>k;
cout<<ncr(n-1, k-1)<<endl;
}
return 0;
}
Also, the code provided in solution is only passing one test case!