Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>

#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

int  MOD = 1e9 + 7;
uint64_t inverseModp(uint64_t a, uint64_t p) {
    assert(p < (1ull << 63));
    assert(a < p);
    assert(a != 0);
    uint64_t ex = p-2, result = 1;
    while (ex > 0) {
        if (ex % 2 == 1) {
            result = (result*a) % p;
        }
        a = (a*a) % p;
        ex /= 2;
    }
    return result;
}

// p MUST be prime
uint32_t nCrModp(uint32_t n, uint32_t r, uint32_t p)
{
    assert(r <= n);
    if (r > n-r) r = n-r;
    if (r == 0) return 1;
    if(n/p - (n-r)/p > r/p) return 0;
    
    uint64_t result = 1; //intermediary results may overflow 32 bits
    
    for (uint32_t i = n, x = 1; i > r; --i, ++x) {
        if( i % p != 0) {
            result *= i % p;
            result %= p;
        }
        if( x % p != 0) {
            result *= inverseModp(x % p, p);
            result %= p;
        }
    }
    return result;
}

int main(){
    int x,y;
    cin >> x >> y;
    if ( (2*y-x)%3 != 0 || (2*x-y)%3!= 0 || (2*y-x)/3 < 0 || (2*x-y)/3 < 0 ){
        cout << 0 ;rn 0;
    }
    int q = (2*y-x)/3;
    int p = (2*x-y)/3;
    
    cout << nCrModp((uint32_t) p + q, (uint32_t) q, (uint32_t) MOD);
    rn 0;
}


Compiler output:
a.cc:34:1: error: 'uint64_t' does not name a type
   34 | uint64_t inverseModp(uint64_t a, uint64_t p) {
      | ^~~~~~~~
a.cc:13:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   12 | #include <sstream>
  +++ |+#include <cstdint>
   13 | #include <string>
a.cc:50:1: error: 'uint32_t' does not name a type
   50 | uint32_t nCrModp(uint32_t n, uint32_t r, uint32_t p)
      | ^~~~~~~~
a.cc:50:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc: In function 'int main()':
a.cc:81:22: error: 'uint32_t' was not declared in this scope
   81 |     cout << nCrModp((uint32_t) p + q, (uint32_t) q, (uint32_t) MOD);
      |                      ^~~~~~~~
a.cc:81:22: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:81:49: error: expected ')' before 'q'
   81 |     cout << nCrModp((uint32_t) p + q, (uint32_t) q, (uint32_t) MOD);
      |                    ~                            ^~
      |                                                 )
a.cc:81:63: error: expected ')' before 'MOD'
   81 |     cout << nCrModp((uint32_t) p + q, (uint32_t) q, (uint32_t) MOD);
      |                    ~                                          ^~~~
      |                                                               )
a.cc:81:13: error: 'nCrModp' was not declared in this scope
   81 |     cout << nCrModp((uint32_t) p + q, (uint32_t) q, (uint32_t) MOD);
      |             ^~~~~~~