Language: C++

#include <bits/stdc++.h>
// #include<atcoder/all>
// using namespace #include <bits/stdc++.h>
// #include<atcoder/all>
// using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1e9 + 7;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1LL;
    else if (P % 2 == 1) return (N * RepeatSquaring(N,P-1,M)) % M;
    else {
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
}
int main(void){
    // Your code here!
    ll x,y; cin >> x >> y;
    if ((x+y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    if ((2*y - x) % 3 != 0 || (2*x-y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll a = (2*y-x)/3;
    ll b = (2*x-y)/3;
    if (a == 0 || b == 0) {
        cout << a + b << endl;
        return 0;
    }
    ll ans = 1;
    for (ll i = a + b; i > max(a,b); i--) {
        ans *= i;
        ans %= MOD;
    }
    for (ll i = 2; i <= min(a,b); i++) {
        ans *= RepeatSquaring(i,MOD-2,MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}
;
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1e9 + 7;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1LL;
    else if (P % 2 == 1) return (N * RepeatSquaring(N,P-1,M)) % M;
    else {
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
}
int main(void){
    // Your code here!
    ll x,y; cin >> x >> y;
    if ((x+y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    if ((2*y - x) % 3 != 0 || (2*x-y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll a = (2*y-x)/3;
    ll b = (2*x-y)/3;
    ll ans = 1;
    for (ll i = a + b; i > max(a,b); i--) {
        ans *= i;
        ans %= MOD;
    }
    for (ll i = 2; i <= min(a,b); i++) {
        ans *= RepeatSquaring(i,MOD-2,MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}


Compiler output:
a.cc:84:11: error: redefinition of 'const int INF'
   84 | const int INF = 1001001001;
      |           ^~~
a.cc:8:11: note: 'const int INF' previously defined here
    8 | const int INF = 1001001001;
      |           ^~~
a.cc:90:10: error: redefinition of 'const ll MOD'
   90 | const ll MOD=1e9 + 7;
      |          ^~~
a.cc:14:10: note: 'const ll MOD' previously defined here
   14 | const ll MOD=1e9 + 7;
      |          ^~~
a.cc:92:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
   92 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:16:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
   16 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:93:31: error: redefinition of 'template<class T> bool chmin(T&, T)'
   93 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:17:31: note: 'template<class T> bool chmin(T&, T)' previously declared here
   17 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:94:23: error: redefinition of 'template<class T> auto MAX(const T&)'
   94 | template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
      |                       ^~~
a.cc:18:23: note: 'template<class T> auto MAX(const T&)' previously declared here
   18 | template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
      |                       ^~~
a.cc:95:23: error: redefinition of 'template<class T> auto MIN(const T&)'
   95 | template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
      |                       ^~~
a.cc:19:23: note: 'template<class T> auto MIN(const T&)' previously declared here
   19 | template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
      |                       ^~~
a.cc:96:29: error: redefinition of 'template<class T, class U> U SUM(const T&, const U&)'
   96 | template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
      |                             ^~~
a.cc:20:29: note: 'template<class T, class U> U SUM(const T&, const U&)' previously declared here
   20 | template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
      |                             ^~~
a.cc:97:29: error: redefinition of 'template<class T, class U> U COUNT(const T&, const U&)'
   97 | template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
      |                             ^~~~~
a.cc:21:29: note: 'template<class T, class U> U COUNT(const T&, const U&)' previously declared here
   21 | template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
      |                             ^~~~~
a.cc:98:31: error: redefinition of 'template<class T, class U> int LOWER(const T&, const U&)'
   98 | template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
      |                               ^~~~~
a.cc:22:31: note: 'template<class T, class U> int LOWER(const T&, const U&)' previously declared here
   22 | template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
      |                               ^~~~~
a.cc:99:31: error: redefinition of 'template<class T, class U> int UPPER(const T&, const U&)'
   99 | template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
      |                               ^~~~~
a.cc:23:31: note: 'template<class T, class U> int UPPER(const T&, const U&)' previously declared here
   23 | template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
      |                               ^~~~~
a.cc:100:5: error: redefinition of 'int GCD(int, int)'
  100 | int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
      |     ^~~
a.cc:24:5: note: 'int GCD(int, int)' previously defined here
   24 | int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
      |     ^~~
a.cc:101:5: error: redefinition of 'int LCM(int, int)'
  101 | int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
      |     ^~~
a.cc:25:5: note: 'int LCM(int, int)' previously defined here
   25 | int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
      |     ^~~
a.cc:121:4: error: redefinition of 'll RepeatSquaring(ll, ll, ll)'
  121 | ll RepeatSquaring(ll N, ll P, ll M){
      |    ^~~~~~~~~~~~~~
a.cc:45:4: note: 'll RepeatSquaring(ll, ll, ll)' previously defined here
   45 | ll RepeatSquaring(ll N, ll P, ll M){
      |    ^~~~~~~~~~~~~~
a.cc:129:5: error: redefinition of 'int main()'
  129 | int main(void){
      |     ^~~~
a.cc:53:5: note: 'int main()' previously defined here
   53 | int main(void){
      |     ^~~~