criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  long long n, k, a, b, x, y, h, s, t, u; 
  long long w[10000];
  int i = 0;
  w[0] = 1;
  while(w[i] < 1e9ll + 7ll){
    w[i + 1] = k * w[i];
    i++;
  }
  cin >> x >> y;
  n = 1;
  k = 1;
  s = 1;
  t = 1;
  if((x + y) % 3 != 0){
    cout << 0 << endl;
    return 0;
  }
  else{
    a = (2 * y - x) / 3;
    b = (2 * x - y) / 3;
    for(int i = b + 1; i < a + b + 1; i++)
      n = (n * i) % (1e9ll + 7ll);
    for(int i = 1; i < a + 1; i++)
      k = (k * i) % (1e9ll + 7ll);
    h = k;
    u = 1;
    while(w[i] < 1e9ll + 7ll){
      w[i + 1] = k * w[i];
      i++;
    }
    while(s < 1e9ll + 5ll){
      if(s + t < 1e9 + 6ll){
        h = h * w[u] % (1e9ll + 7ll);
        s = s + t;
        t = t * 2;
        u++;
      }
      else{
        t = t / 2;
        u--;
      }
    }
    cout << (n * h) % (1e9ll + 7ll) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:16: error: unable to find numeric literal operator 'operator""ll'
    9 |   while(w[i] < 1e9ll + 7ll){
      |                ^~~~~
a.cc:26:22: error: unable to find numeric literal operator 'operator""ll'
   26 |       n = (n * i) % (1e9ll + 7ll);
      |                      ^~~~~
a.cc:28:22: error: unable to find numeric literal operator 'operator""ll'
   28 |       k = (k * i) % (1e9ll + 7ll);
      |                      ^~~~~
a.cc:31:18: error: unable to find numeric literal operator 'operator""ll'
   31 |     while(w[i] < 1e9ll + 7ll){
      |                  ^~~~~
a.cc:35:15: error: unable to find numeric literal operator 'operator""ll'
   35 |     while(s < 1e9ll + 5ll){
      |               ^~~~~
a.cc:37:25: error: unable to find numeric literal operator 'operator""ll'
   37 |         h = h * w[u] % (1e9ll + 7ll);
      |                         ^~~~~
a.cc:47:24: error: unable to find numeric literal operator 'operator""ll'
   47 |     cout << (n * h) % (1e9ll + 7ll) << endl;
      |                        ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  long long n, k, a, b, x, y, h, s, t; 
  long long w[10000];
  int i = 0;
  w[0] = 1;
  while(w[i] < 1e9 + 7ll){
    w[i + 1] = k * w[i];
    i++;
  }
  cin >> x >> y;
  n = 1;
  k = 1;
  s = 1;
  t = 1;
  if((x + y) % 3 != 0){
    cout << 0 << endl;
    return 0;
  }
  else{
    a = (2 * y - x) / 3;
    b = (2 * x - y) / 3;
    for(int i = b + 1; i < a + b + 1; i++)
      n = (n * i) % (1e9 + 7ll);
    for(int i = 1; i < a + 1; i++)
      k = (k * i) % (1e9 + 7ll);
    h = k;
    w = k;
    u = 1;
    while(w[i] < 1e9 + 7ll){
      w[i + 1] = k * w[i];
      i++;
    }
    while(s < 1e9 + 5ll){
      if(s + t < 1e9 + 6ll){
        h = h * w[u] % (1e9 + 7ll);
        s = s + t;
        t = t * 2;
        u++;
      }
      else{
        t = t / 2;
        u--;
      }
    }
    cout << (n * h) % (1e9 + 7ll) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:19: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   26 |       n = (n * i) % (1e9 + 7ll);
      |           ~~~~~~~ ^ ~~~~~~~~~~~
      |              |           |
      |              |           double
      |              long long int
a.cc:28:19: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   28 |       k = (k * i) % (1e9 + 7ll);
      |           ~~~~~~~ ^ ~~~~~~~~~~~
      |              |           |
      |              |           double
      |              long long int
a.cc:30:7: error: incompatible types in assignment of 'long long int' to 'long long int [10000]'
   30 |     w = k;
      |     ~~^~~
a.cc:31:5: error: 'u' was not declared in this scope
   31 |     u = 1;
      |     ^
a.cc:48:21: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   48 |     cout << (n * h) % (1e9 + 7ll) << endl;
      |             ~~~~~~~ ^ ~~~~~~~~~~~
      |                |           |
      |                |           double
      |                long long int
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  long long n, k, a, b, x, y, h, s, t; 
  long long w[10000];
  int i = 0;
  w[0] = 1;
  while(w[i] < 1e9 + 7){
    w[i + 1] = k * w[i];
    i++;
  }
  cin >> x >> y;
  n = 1;
  k = 1;
  s = 1;
  t = 1;
  if((x + y) % 3 != 0){
    cout << 0 << endl;
    return 0;
  }
  else{
    a = (2 * y - x) / 3;
    b = (2 * x - y) / 3;
    for(int i = b + 1; i < a + b + 1; i++)
      n = (n * i) % (1e9 + 7);
    for(int i = 1; i < a + 1; i++)
      k = (k * i) % (1e9 + 7);
    h = k;
    w = k;
    u = 1;
    while(w[i] < 1e9 + 7){
      w[i + 1] = k * w[i];
      i++;
    }
    while(s < 1e9 + 5){
      if(s + t < 1e9 + 6){
        h = h * w[u] % (1e9 + 7);
        s = s + t;
        t = t * 2;
        u++;
      }
      else{
        t = t / 2;
        u--;
      }
    }
    cout << (n * h) % (1e9 + 7) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:19: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   26 |       n = (n * i) % (1e9 + 7);
      |           ~~~~~~~ ^ ~~~~~~~~~
      |              |           |
      |              |           double
      |              long long int
a.cc:28:19: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   28 |       k = (k * i) % (1e9 + 7);
      |           ~~~~~~~ ^ ~~~~~~~~~
      |              |           |
      |              |           double
      |              long long int
a.cc:30:7: error: incompatible types in assignment of 'long long int' to 'long long int [10000]'
   30 |     w = k;
      |     ~~^~~
a.cc:31:5: error: 'u' was not declared in this scope
   31 |     u = 1;
      |     ^
a.cc:48:21: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   48 |     cout << (n * h) % (1e9 + 7) << endl;
      |             ~~~~~~~ ^ ~~~~~~~~~
      |                |           |
      |                |           double
      |                long long int
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  long long n, k, a, b, x, y, h, s, t;
  long long 
  long long w[10000];
  int i = 0;
  w[0] = 1;
  while(w[i] < 1e9 + 7){
    w[i + 1] = k * w[i];
    i++;
  }
  cin >> x >> y;
  n = 1;
  k = 1;
  s = 1;
  t = 1;
  if((x + y) % 3 != 0){
    cout << 0 << endl;
    return 0;
  }
  else{
    a = (2 * y - x) / 3;
    b = (2 * x - y) / 3;
    for(int i = b + 1; i < a + b + 1; i++)
      n = (n * i) % (1e9 + 7);
    for(int i = 1; i < a + 1; i++)
      k = (k * i) % (1e9 + 7);
    h = k;
    w = k;
    u = 1;
    while(w[i] < 1e9 + 7){
      w[i + 1] = k * w[i];
      i++;
    }
    while(s < 1e9 + 5){
      if(s + t < 1e9 + 6){
        h = h * w[u] % (1e9 + 7);
        s = s + t;
        t = t * 2;
        u++;
      }
      else{
        t = t / 2;
        u--;
      }
    }
    cout << (n * h) % (1e9 + 7) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'long long long' is too long for GCC
    7 |   long long w[10000];
      |   ^~~~
a.cc:7:8: error: 'long long long' is too long for GCC
    7 |   long long w[10000];
      |        ^~~~
a.cc:27:19: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   27 |       n = (n * i) % (1e9 + 7);
      |           ~~~~~~~ ^ ~~~~~~~~~
      |              |           |
      |              |           double
      |              long long int
a.cc:29:19: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   29 |       k = (k * i) % (1e9 + 7);
      |           ~~~~~~~ ^ ~~~~~~~~~
      |              |           |
      |              |           double
      |              long long int
a.cc:31:7: error: incompatible types in assignment of 'long long int' to 'long long int [10000]'
   31 |     w = k;
      |     ~~^~~
a.cc:32:5: error: 'u' was not declared in this scope
   32 |     u = 1;
      |     ^
a.cc:49:21: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   49 |     cout << (n * h) % (1e9 + 7) << endl;
      |             ~~~~~~~ ^ ~~~~~~~~~
      |                |           |
      |                |           double
      |                long long int
Language: C++



a, b = map(int, input().split())
MOD = int(1e9 + 7)

def calc(x, y):
    right = above = 0
    while x>0 and y>0:
        if x>y:
            x -= 2
            y -= 1
            right += 1
        else:
            x -= 1
            y -= 2
            above += 1

    return (True, right, above) if x==0 and y==0 else (False, None, None)


def res(n, k):
    # print(n, k)
    total = 1
    if k < n-k:
        k = n-k
    for i in range(k+1, n+1):
        total = (total * i)% MOD
        total *= pow(i-k, MOD-2, MOD)
    return total

r, right, above = calc(a, b)
if not r:
    print(0)
else:
    print(int(res(above+right, right) % MOD))


Compiler output:
a.cc:22:7: error: invalid preprocessing directive #print
   22 |     # print(n, k)
      |       ^~~~~
a.cc:3:1: error: 'a' does not name a type
    3 | a, b = map(int, input().split())
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int power(long long p,long long q){
  if(q==1)return p;
  else if(q%2==0){
    return (power(p,q/2)*power(p,q/2))%1000000007;
  }
  else return (p*power(p,q-1))%1000000007;
}
int main() {
  long long a,b;
  cin>>a>>b;
  long long big=1000000007;
  if((a+b)%3!=0)cout<<0<<endl;
  else {
    long long k=(a+b)/3;
    a-=k;
    b-=k;
    if(a<0||b<0)cout<<0<<endl;
    else {
      long long m=1,n=1;
      for(int i=k;i>k-a;i--){
        m*=i;
        m%=big;
      }
      for(int i=1;i<a+1;i++){
        n*=i;
        n%=big;
      }
      cout<<(m*power(n,big-2)%big<<endl;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:34: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator<<'
   30 |       cout<<(m*power(n,big-2)%big<<endl;
      |              ~~~~~~~~~~~~~~~~~~~~^~~~~~
a.cc:30:40: error: expected ')' before ';' token
   30 |       cout<<(m*power(n,big-2)%big<<endl;
      |             ~                          ^
      |                                        )
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define p (ll)(1e9+7)

using namespace std;

ll fact(ll n,vector<ll>&F)
{
    // if(n == 0)
    //     return 1;
    //
    // //cout<<"Fact: "<<n<<'\n';
    //
    // if(F[n] == -1)
    //     F[n] = (fact(n-1,F)*n)%p;

    return F[n];
}

ll Pow(ll a,ll m)
{
    if(m == 0)
        return 1;

    ll b,c;
    b = 1;

    if(m%2)
        b = a;

    c = Pow(a,m/2);
    a = (((c*c)%p)*b)%p;

    return a;
}

int main()
{
    ll x,y;

    cin>>x>>y;

    ll n1,n2,m1,m2;

    m1 = y-x;
    m2 = (y+x)/3;

    n1 = (m1+m2)/2;
    n2 = (m2-m1)/2;

    if(n1+2*n2 != x || 2*n1+n2 != y || n1 < 0 || n2 < 0)
    {
        cout<<0;
        exit(0);
    }

    vector<ll>F(2000001);
    ll i;
    F[0] = 1;
    for(i=1;i!=2000001;i++)
        F[i] = (i*F[i-1])%p;

    ll a,b;
    a = fact(n1+n2,F);
    b = (fact(n1,F)*fact(n2,F))%p;
    b = Pow(b,p-2);

    cout<<(a*b)%p;

    // Test code
    // ll i;
    // for(i=0;i!=2000001;i++)
    //     cout<<i<<' '<<fact(i,F)<<'\n';

    return 0;
}#include<bits/stdc++.h>
#define ll long long
#define p (ll)(1e9+7)

using namespace std;

ll fact(ll n,vector<ll>&F)
{
    // if(n == 0)
    //     return 1;
    //
    // //cout<<"Fact: "<<n<<'\n';
    //
    // if(F[n] == -1)
    //     F[n] = (fact(n-1,F)*n)%p;

    return F[n];
}

ll Pow(ll a,ll m)
{
    if(m == 0)
        return 1;

    ll b,c;
    b = 1;

    if(m%2)
        b = a;

    c = Pow(a,m/2);
    a = (((c*c)%p)*b)%p;

    return a;
}

int main()
{
    ll x,y;

    cin>>x>>y;

    ll n1,n2,m1,m2;

    m1 = y-x;
    m2 = (y+x)/3;

    n1 = (m1+m2)/2;
    n2 = (m2-m1)/2;

    if(n1+2*n2 != x || 2*n1+n2 != y || n1 < 0 || n2 < 0)
    {
        cout<<0;
        exit(0);
    }

    vector<ll>F(2000001);
    ll i;
    F[0] = 1;
    for(i=1;i!=2000001;i++)
        F[i] = (i*F[i-1])%p;

    ll a,b;
    a = fact(n1+n2,F);
    b = (fact(n1,F)*fact(n2,F))%p;
    b = Pow(b,p-2);

    cout<<(a*b)%p;

    // Test code
    // ll i;
    // for(i=0;i!=2000001;i++)
    //     cout<<i<<' '<<fact(i,F)<<'\n';

    return 0;
}

Compiler output:
a.cc:76:2: error: stray '#' in program
   76 | }#include<bits/stdc++.h>
      |  ^
a.cc:76:3: error: 'include' does not name a type
   76 | }#include<bits/stdc++.h>
      |   ^~~~~~~
a.cc:82:4: error: redefinition of 'long long int fact(long long int, std::vector<long long int>&)'
   82 | ll fact(ll n,vector<ll>&F)
      |    ^~~~
a.cc:7:4: note: 'long long int fact(long long int, std::vector<long long int>&)' previously defined here
    7 | ll fact(ll n,vector<ll>&F)
      |    ^~~~
a.cc:95:4: error: redefinition of 'long long int Pow(long long int, long long int)'
   95 | ll Pow(ll a,ll m)
      |    ^~~
a.cc:20:4: note: 'long long int Pow(long long int, long long int)' previously defined here
   20 | ll Pow(ll a,ll m)
      |    ^~~
a.cc:112:5: error: redefinition of 'int main()'
  112 | int main()
      |     ^~~~
a.cc:37:5: note: 'int main()' previously defined here
   37 | int main()
      |     ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

ll Pow(ll x,ll p){
  if(!p) return 1;
  if(p%2){
    return (x*Pow(x,p-1))%mod;
  }
  ll t = Pow(x,p>>1);
  return (t*t)%mod;
}

struct combination{
  vector<ll> fact,ifact;
  combination(int n) : fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = (fact[i-1]*i)%mod;
    ifact[n] = Pow(fact[n],mod-2);
    for(int i=n; i>=1; i--) ifact[i-1] = (ifact[i]*i)%mod;
  }
  operator()(int n,int k){
    return (((fact[n]*ifact[k])%mod)*ifact[n-k])%mod;
  }
};

int main(){
  int X,Y;
  cin >> X >> Y;
  if((X+Y)%3 != 0){
    cout << 0 << endl;
    return 0;
  }
  int temp = X+Y;
  X -= temp/3;
  Y -= temp/3;
  combination c(X+Y);
  cout << c(X+Y,Y) << endl;
  return 0;
}


Compiler output:
a.cc:70:3: error: ISO C++ forbids declaration of 'operator()' with no type [-fpermissive]
   70 |   operator()(int n,int k){
      |   ^~~~~~~~
Language: C++

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

x, y = map(int, input().split())
if (x+y)%3 == 0 and x<=2*y and y<=2*x:
	a=int((2*y-x)/3)
	b=int((2*x-y)/3)
	print(cmb(a+b, a, mod))
else:
	print(0)

Compiler output:
a.cc:7:15: error: stray '#' in program
    7 | mod = 10**9+7 #出力の制限
      |               ^
a.cc:9:13: error: stray '#' in program
    9 | g1 = [1, 1] # 元テーブル
      |             ^
a.cc:10:13: error: stray '#' in program
   10 | g2 = [1, 1] #逆元テーブル
      |             ^
a.cc:11:18: error: stray '#' in program
   11 | inverse = [0, 1] #逆元テーブル計算用テーブル
      |                  ^
a.cc:1:1: error: 'def' does not name a type
    1 | def cmb(n, r, mod):
      | ^~~
Language: Java

import java.io.PrintWriter;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    final long mod = 1000000000+7;
    int maxn;
    long[] frac;
    long[] inv;

    public static void main(String[] args) {
        Main main = new Main();
        System.out.println(main.solve());
    }

    long solve() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt(), Y = sc.nextInt();

        if((X+Y)%3!=0) return 0;
        X_p = X - (X+Y)/3;
        Y_p = Y - (X+Y)/3;
        if(X_p<0 || Y_p<0) return 0;

        ans = main.combination(X_p+Y_p, X_p);

        return ans;
    }

    long combination(int n, int k) {
        return kaijo(n)/(kaijo(k)*kaijo(n-k))
    }
    long kaijo(int n) {
        n==0 ? 1 : n * kaijo(n-1)
    }
}



Compiler output:
Main.java:31: error: ';' expected
        return kaijo(n)/(kaijo(k)*kaijo(n-k))
                                             ^
Main.java:34: error: not a statement
        n==0 ? 1 : n * kaijo(n-1)
             ^
Main.java:34: error: ';' expected
        n==0 ? 1 : n * kaijo(n-1)
                                 ^
3 errors
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
using namespace std;


typedef pair<int, int> P;
typedef long long ll;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int mod = pow(10, 9) + 7;



struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){

	int x, y;
	cin >> x >> y;

	if((x + y) % 3){
		cout << 0 << endl;
		return 0;
	}

	int n = (x + y) / 3;
	x -= n; y -= n;

	if(x < 0 || y < 0){
		cout << 0 << endl;
		return 0;
	}

	combination c(x + y);
	mint ans = c(x + y, x);


	cout << ans.x << endl;

}

Compiler output:
a.cc: In constructor 'combination::combination(int)':
a.cc:79:5: error: 'assert' was not declared in this scope
   79 |     assert(n < mod);
      |     ^~~~~~
a.cc:11:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   10 | #include<numeric>
  +++ |+#include <cassert>
   11 | #include<tuple>
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
const int INF = 10000000;
#define mod 1000000007

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
bool palin(int N){//Nが回文数かどうか
    string S = to_string(N);
    int M = (S.size()-1)/2 + 1;
    int n = S.size();
    bool flag = true;

    for(int i = M;i<n;i++){
        if(S[i] != S[n-i-1]) flag = false;
    }
   return flag;
}
/*まずゴールに辿り着けるかを探索　ゴールまでの距離を求める
最初の白マスの個数ー（距離＋１）が答え
たどり着けない場合、-1を出力
*/

ll factorial(ll n){
    ll i = 1;
    ll ans = 1;
    while(i<=n){
        ans = (i*ans)%mod;
        i++;
    }
    return ans;
}
 
ll calc(ll a,ll b ,ll p){
    if(b == 0){
        return 1;
    }
    else if(b %2 == 0){
        ll d = calc(a,b/2,p);
        return ((d%p)*(d%p))%p;
    }
    else{
        return ((a%p)*calc(a,b-1,p))%p;
    }
}
int main() {
    ll X,Y;
    cin >> X >> Y;


    if((2*Y-X)%3 != 0 || (2*X-Y)%3 != 0 || 2*Y-X <0 |
| 2*X-Y <0) cout << 0 << endl;
    else{
        ll n = (2*Y-X)/3;
        ll m = (2*X-Y)/3;
        ll ans = (((factorial(n+m)*calc(factorial(n),mod-2,mod))%mod)*calc(factorial(m),mod-2,mod))%mod;
    cout << ans << endl;
    }
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:1: error: expected primary-expression before '|' token
   58 | | 2*X-Y <0) cout << 0 << endl;
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll mod=1e9+7;
ll MAX=2001005;
vector<ll> fact(MAX),fact_inv(MAX);
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1)res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%mod*fact_inv[n-r]%mod;
}

int main(){
    ll x,y; cin>>x>>y;
    if((x+y)%3!=0)cout<<0<<endl;
    else{
        ll z=(x+y)/3;
        x-=z; y-=z;
        if(min(x,y)<0){cout<<0<<endl; break;}
        fact[0]=1;
      	ll n=x+y+1;
        rep(i,n)fact[i+1]=fact[i]*(i+1)%mod;
        fact_inv[n]=power(fact[n],mod-2);
        rep(i,n)fact_inv[n-1-i]=fact_inv[n-i]*(n-i)%mod;
        ll ans=comb(x+y,x);
        cout<<ans<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:39: error: break statement not within loop or switch
   29 |         if(min(x,y)<0){cout<<0<<endl; break;}
      |                                       ^~~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll x, y;
ll f[1010100], rf[1010100];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}

ll cal_c(int n, int k) {
  f[0] = 1;
  FOR(i, 1, 1010100) f[i] = (f[i - 1] * i) % mod;
  FOR(i, 0, 1010100) rf[i] = inv(f[i]);
  ll a = f[n];
  ll b = rf[n-k];
  ll c = rf[k];

  ll bc = (b * c) % mod;

  return (a * bc) % mod;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x >> y;

  ll ans = 0;
  ll a = (2 * x - y);
  ll b = (2 * y - x);
  if(a % 3 == 0 && b % 3 == 0) {
    ll a /= 3;
    ll b /= 3;

    if(a >= 0 && b >= 0) {
      ll ma = max(a, b);
      ans = cal_c(a + b, ma);
    }
  }

  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:10: error: expected initializer before '/=' token
   71 |     ll a /= 3;
      |          ^~
a.cc:72:10: error: expected initializer before '/=' token
   72 |     ll b /= 3;
      |          ^~
Language: C++

#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);++i)
typedef long long ll;
typedef vector<int> vi;
using namespace std;

// auto mod int

const int mod = 1000000007;

struct mint {

	ll x; // typedef long long ll;

	mint(ll x = 0) :x((x% mod + mod) % mod) {}

	mint& operator+=(const mint a) {

		if ((x += a.x) >= mod) x -= mod;

		return *this;

	}

	mint& operator-=(const mint a) {

		if ((x += mod - a.x) >= mod) x -= mod;

		return *this;

	}

	mint& operator*=(const mint a) {

		(x *= a.x) %= mod;

		return *this;

	}

	mint operator+(const mint a) const {

		mint res(*this);

		return res += a;

	}

	mint operator-(const mint a) const {

		mint res(*this);

		return res -= a;

	}

	mint operator*(const mint a) const {

		mint res(*this);

		return res *= a;

	}

	mint pow(ll t) const {

		if (!t) return 1;

		mint a = pow(t >> 1);

		a *= a;

		if (t & 1) a *= *this;

		return a;

	}



	// for prime mod

	mint inv() const {

		return pow(mod - 2);

	}

	mint& operator/=(const mint a) {

		return (*this) *= a.inv();

	}

	mint operator/(const mint a) const {

		mint res(*this);

		return res /= a;

	}

};

// combination mod prime


struct combination {

	vector<mint> fact, ifact;

	combination(int n) :fact(n + 1), ifact(n + 1) {

		assert(n < mod);

		fact[0] = 1;

		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;

		ifact[n] = fact[n].inv();

		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;

	}

	mint operator()(int n, int k) {

		if (k < 0 || k > n) return 0;

		return fact[n] * ifact[k] * ifact[n - k];

	}

};

int main() {
	int x, y;
	cin >> x >> y;
	if ((x + y) % 3) {
		cout << 0 << endl;
		return 0;
	}
	int n = (x + y) / 3;
	x -= n; y -= n;
	if (x < 0 || y < 0) {
		cout << 0 << endl;
		return 0;
	}
	combination c(x + y);
	mint ans = c(x + y, x);
	cout << ans.x << endl;
	
	return 0;
}

Compiler output:
a.cc:6:9: error: 'vector' does not name a type
    6 | typedef vector<int> vi;
      |         ^~~~~~
Language: C++

#include<iostream>
#include<unordered__map>
#define mod int(10e8+7)
#define factor int(10e7)
typedef long long ll;
using namespace std;

ll ways(ll x,ll y,unordered_map<ll,ll>& dp)
{
  if(x==0 && y==0)
    return 1;
  if(x<0 || y<0)
    return 0;
  if(dp[factor*x+y]!=0)
  	return dp[factor*x+y];
  dp[factor*x+y]=(ways(x-1,y-2,dp)%mod+ways(x-2,y-1,dp)%mod)%mod;
int main()
{
  ll x,y;
  cin>>x>>y;
  unordered_map<ll,ll> dp;
  cout<<ways(x,y,dp)%mod;
}

Compiler output:
a.cc:2:9: fatal error: unordered__map: No such file or directory
    2 | #include<unordered__map>
      |         ^~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){e
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	int  x , y ;
cin >> x>>y;
COMinit();
int a= 2*x-y,b=2*y-x;
if(a%3!=0 || b%3!=0){
cout<<0<<endl;
}else{
a/=3;b/=3;
int k = min(a,b);
cout<<COM(a+b,k)<<endl;

}

} 


Compiler output:
a.cc: In function 'long long int COM(int, int)':
a.cc:22:29: error: 'e' was not declared in this scope
   22 | long long COM(int n, int k){e
      |                             ^
Language: C++

#include<bits/stdc++.h>
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	int  x , y ;
cin >> x>>y;
COMinit();
int a= 2*x-y,b=2*y-x;
if(a%3!=0 || b%3!=0){
cout<<0<<endl;
}else{
a/=3;b/=3;
cout<<COM(a+b,a)<<endln

}

} 


Compiler output:
a.cc: In function 'int main()':
a.cc:37:19: error: 'endln' was not declared in this scope
   37 | cout<<COM(a+b,a)<<endln
      |                   ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	int  x , y ;
cin >> x>>y;
COMinit();
int a= 2x-y,b=2y-x;
if(a%3!=0 || b%3!=0){
cout<<0<<endl;
}else{
a/=3;b/=3;
cout<<COM(a+b,a)<<endln

}

} 


Compiler output:
a.cc: In function 'int main()':
a.cc:32:8: error: unable to find numeric literal operator 'operator""x'
   32 | int a= 2x-y,b=2y-x;
      |        ^~
a.cc:33:14: error: 'b' was not declared in this scope
   33 | if(a%3!=0 || b%3!=0){
      |              ^
a.cc:37:19: error: 'endln' was not declared in this scope
   37 | cout<<COM(a+b,a)<<endln
      |                   ^~~~~
Language: C++

#include <iostream>
using namespace std;

const long long m = 1e9 + 7;

int main(){
  long long a, b;
  cin >> a >> b;
  cout << (((a%m)*(b%m))%m);

Compiler output:
a.cc: In function 'int main()':
a.cc:9:29: error: expected '}' at end of input
    9 |   cout << (((a%m)*(b%m))%m);
      |                             ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1e9+7;
ll binaryExp(ll a, ll b)
{
	ll ans = 1, x = a;
	while(b>0)
	{
		if(b&1)
			ans = (ans*x)%mod;
		x = (x*x)%mod;
		b>>=1;
	}
	return ans;
}
ll invfac(ll n)
{
	return binaryExp(n,mod-2);
}
ll nCr(ll n, ll r)
{
	vector<ll> fact(n+1,1);
	for(ll i = 2; i<=n; i++)
		fact[i] = (i*fact[i-1])%mod;
	return (((fact[n]*invfac(fact[n-r]))%mod)*invfac(fact[r]))%mod;
}

int main()
{
	ll x,y; cin>>x>>y;
	if((x+y)%3!=0)
		cout<<0<<endl;
	else
	{
		if(k>y||y>2*k)
		{
			cout<<0<<endl;
			return 0;
		}
		ll k = (x+y)/3;
		ll m = y - k;
		ll n = 2*k - y;
		cout<<nCr(m+n,min(m,n))<<endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:20: error: 'k' was not declared in this scope
   36 |                 if(k>y||y>2*k)
      |                    ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1e9+7;
ll binaryExp(ll a, ll b)
{
	ll ans = 1, x = a;
	while(b>0)
	{
		if(b&1)
			ans = (ans*x)%mod;
		x = (x*x)%mod;
		b>>=1;
	}
	return ans;
}
ll invfac(ll n)
{
	return binaryExp(n,mod-2);
}
ll nCr(ll n, ll r)
{
	vector<ll> fact(n+1,1);
	for(ll i = 2; i<=n; i++)
		fact[i] = (i*fact[i-1])%mod;
	return (((fact[n]*invfac(fact[n-r]))%mod)*invfac(fact[r]))%mod;
}

int main()
{
	ll x,y; cin>>x>>y;
	if((x+y)%3!=0)
		cout<<0<<endl;
	else
	{
		if(k>y||y>2k)
		{
			cout<<0<<endl;
			return 0;
		}
		ll k = (x+y)/3;
		ll m = y - k;
		ll n = 2*k - y;
		cout<<nCr(m+n,min(m,n))<<endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:20: error: 'k' was not declared in this scope
   36 |                 if(k>y||y>2k)
      |                    ^
a.cc:36:27: error: fixed-point types not supported in C++
   36 |                 if(k>y||y>2k)
      |                           ^~
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>

using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007
ll dp[1000010][1000010] = {};
ll x, y;

int main(){
    cin >> x >> y;
    
    dp[0][0] = 1;
    rep(i, x+1){
        ll dy;
        if(i&1)dy = (i+1)/2+1;
        else dy = i/2;
        rep(j, i/2+1){
            if(dy > y)break;
            // cout << i << ", " << dy << endl;
            if(i-1>=0&&dy-2>=0)dp[i][dy] += dp[i-1][dy-2];
            if(i-2>=0&&dy-1>=0)dp[i][dy] += dp[i-2][dy-1];
            dy+=3;
        }
    }

    cout << dp[x][y] << endl;
}

Compiler output:
/tmp/cc0ZbcXC.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc0ZbcXC.o
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/cc0ZbcXC.o
a.cc:(.text+0x9e): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/cc0ZbcXC.o
a.cc:(.text+0x1f6): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc0ZbcXC.o
a.cc:(.text+0x207): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc0ZbcXC.o
a.cc:(.text+0x20e): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/cc0ZbcXC.o
collect2: error: ld returned 1 exit status
Language: C++

#include <cstdio>

#define int long long

template<class T>void fr(T &a) {
    T w=0,s=1;char c=getchar();
    while(c<'0'||c>'9') {if(c=='-')s=-1;c=getchar();}
    while(c>='0'&&c<='9') w=w*10+c-'0',c=getchar();
    a=w*s;
}
template<class T>T fr() {T a;fr(a);return a;}
#define R() fr<int>()

const int p=1e9+7,N=1e6;
int fac[N+10]={1};

int qpow(int a,int b) {
    int ans=1;
    while(b) {
        if(b%2)ans=ans*a%p;
        a=a*a%p,b/=2;  
    }
    return ans;
}

int C(int n,int m) {
    return fac[n]*qpow(fac[n-m],p-2)%p*qpow(fac[m],p-2)%p;
}

signed main() {
    int x=R(),y=R(),z=(x+y)/3,a=y-z,b=x-z;
    if(z*3!=x+y)return !printf("0\n");
    else {
        for(int i=1;i<=N;i++) fac[i]=fac[i-1]*i%p;
        if(a>=0&&a<=t)return !printf("%lld\n",C(z,a));
        return !printf("0\n");
    }
    return 0;
}
/*
(i,j) to (i+1,j+2) = a
(i,j) to (i+2,j+1) = b

a+2b=x
2a+b=y

3a+3b=x+y

a+b=(x+y)/3

a=y-(x+y)/3
b=x-(x+y)/3
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:35:21: error: 't' was not declared in this scope
   35 |         if(a>=0&&a<=t)return !printf("%lld\n",C(z,a));
      |                     ^
Language: C

#include<stdio.h>
#include<math.h>
int main(void){
  int X,Y,x,y,i,j;
  long long c,n,k;
  scanf("%d %d",&X,&Y);
  if ((2*X-Y)%3==0){
  y=(2*X-Y)/3;
  x=X-2*y;
  /*  printf("%d %d\n",x,y); */
  n=1;
  k=1;
  for(i=x+y;i>y;i--){
    n=n*i;
  }
  /*  printf("%d\n",n); */
  for(i=x;i>0;i--){
    k=k*i;
  }
  /*printf("%d\n",k);*/
    c=n/k;
    printf("%d\n",c%(pow(10,7)+9));
  }
  if((2*X-Y)%3!=0){
    printf("0\n");
  }
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:22:20: error: invalid operands to binary % (have 'long long int' and 'double')
   22 |     printf("%d\n",c%(pow(10,7)+9));
      |                    ^~~~~~~~~~~~~~
      |                               |
      |                               double
Language: C

#include<stdio.h>
#include<math.h>
int main(void){
  int X,Y,x,y,i,j;
  long long c,n,k;
  scanf("%d %d",&X,&Y);
  if ((2*X-Y)%3==0){
  y=(2*X-Y)/3;
  x=X-2*y;
  /*  printf("%d %d\n",x,y); */
  n=1;
  k=1;
  for(i=x+y;i>y;i--){
    n=n*i;
  }
  /*  printf("%d\n",n); */
  for(i=x;i>0;i--){
    k=k*i;
  }
  /*printf("%d\n",k);*/
    c=n/k;
    printf("%d\n",c%(pow(10.0,7.0)+9));
  }
  if((2*X-Y)%3!=0){
    printf("0\n");
  }
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:22:20: error: invalid operands to binary % (have 'long long int' and 'double')
   22 |     printf("%d\n",c%(pow(10.0,7.0)+9));
      |                    ^~~~~~~~~~~~~~~~~~
      |                                   |
      |                                   double
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define MOD 1000000007
#define MAX 2000000

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  int x, y;
  cin >> x >> y;
  int X, Y;
   X =  (2 * b - a) / 3;
   Y = b - 3 * X + a;

  if ( X <= 0 || Y <= 0){
    cout << 0 << endl;
    return 0;
  }


  COMinit();
  cout << COM(X+Y, Y) << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:14: error: 'b' was not declared in this scope
   33 |    X =  (2 * b - a) / 3;
      |              ^
a.cc:33:18: error: 'a' was not declared in this scope
   33 |    X =  (2 * b - a) / 3;
      |                  ^
Language: C++

def factorial_mod(n, mod):
    a = 1
    for i in range(1, n + 1):
        a *= i
        a %= mod
    return a


def comb_mod(n, k, mod):
    if k > n:
        return 0
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod


def main():
    x, y = map(int, input().split())
    MOD = 10 ** 9 + 7
    if (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
        print(0)
        exit()
    i = (2 * x - y) // 3
    j = (2 * y - x) // 3
    print(comb_mod(i + j, i, MOD))


if __name__ == '__main__':
    main()


Compiler output:
a.cc:29:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   29 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def factorial_mod(n, mod):
      | ^~~
Language: C++

#include<iostream>
using namespace std;

template< typename T >
T extgcd(T a, T b, T &x, T &y) {
  T d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}

// mを法としたときのaのモジュラ逆元を求める
template< typename T >
T mod_inverse(T a, T m) {
  T x, y;
  extgcd(a, m, x, y);
  return (m+x%m) % m;
}

// return nCk % mod
template< typename T >
T mod_comb(T n, T k, T mod) {
  T mul = 1, div = 1;
  for (T i = 0; i < k; i++) {
    mul *= (n-i);
    mul %= mod;
    div *= (i+1);
    div %= mod;
  }
  return mul * mod_inverse(div, mod) % mod;
}
const long long MOD=1000000007;
int main(){
  long long x,y;
  cin>>x>>y;
  if((x+y)%3!=0){
    cout<<0<<endl;
    return(0);
  }
  long long times=(x+y)/3;
  long long a=0;
  while(!(a+2*(times-a)==x&&2*a+(times-a)==y)){
    a++;
  }
  if(a<0||b<0){
    cout<<0<<endl;
  }else{
    cout<<mod_comb(times,a,MOD)<<endl;
  }
  return(0);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:11: error: 'b' was not declared in this scope
   49 |   if(a<0||b<0){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)

const int mod = 1e9 + 7;
int fact[(int)1e6 + 10];

void fact0()
{
    fact[0] = 1;
    fact[1] = 1;
    for(int i = 2; i < (int)1e6 + 10; ++i)
    {
        fact[i] = (fact[i - 1]*i)%mod;
    }
}

int binpow(int a,int b)
{
    int res = 1;
    while(b)
    {
        if(b&1)
        {
            res = (res*a)%mod;
        }
        b >>= 1;
        a = (a*a)%mod;
    }
    return res%mod;
}

int nCr(int n,int r)
{
    r = min(r,n - r);
    int ans = 1;
    int num = fact[n];
    int den = (fact[r]*fact[n - r])%mod;
    den = binpow(den,mod - 2);
    ans = (num*den)%mod;
    return ans%mod;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    fact0();
    int x,y;
    cin >> x >> y;
    if((x + y)%3 != 0)
    {
        cout << 0;
        return 0;
    }
    int n = (x + y)/3;
    int r = (2*y - x)/3;
    int x = (2*x  - y)/3;
    if(r < 0 || x < 0)
    {
        cout << 0;
        return 0;
    }
   
    cout << nCr(n,r) << ' ';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:9: error: redeclaration of 'long long int x'
   65 |     int x = (2*x  - y)/3;
      |         ^
a.cc:56:9: note: 'long long int x' previously declared here
   56 |     int x,y;
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;



class DKnight {
public:
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};
    ll x, y;

    ll mod_pow(ll x, ll n) {
        ll a = 1;
        while (n) {
            if (n % 2) a = a * x % INF;
            x = x * x % INF;
            n /= 2;
        }
        return a;
    }

	void solve(std::istream& in, std::ostream& out) {
        in >> x >> y;
        if ((x + y) % 3) {
            out << 0 << endl;
            return;
        }
        ll v = (x + y) / 3;
        if (x < v || y < v) {
            out << 0 << endl;
            return;
        }
        ll bunshi = 1;
        ll bunbo = 1;
        REP(i, min(x, y) - v) {
            bunshi *= v-i;
            bunshi %= INF;
            bunbo *= i+1;
            bunbo %= INF;
        }
        ll ret = bunshi * mod_pow(bunbo, INF-2) % INF;
        out << ret << endl;
	}
};


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sint(a) scanf("%d", &a)
#define sint2(a, b) scanf("%d %d", &a, &b)
#define sll(a) scanf("%lld", &a)
#define sll2(a, b) scanf("%lld %lld", &a, &b)
#define mem(a, i) memset(a, i, sizeof(a))
const double pi = acos(-1);
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;

ll h[maxn];
ll ex_gcd(ll a, ll b, ll &x, ll &y)
{
    if (!b)
    {
        x = 1;
        y = 0;
        return a;
    }
    else
    {
        ll d = ex_gcd(b, a % b, x, y);
        ll k = x;
        x = y;
        y = k - a / b * y;
        return d;
    }
}
void init(int x)
{
    h[0]=0;
    h[1]=1;
    for(int i=2; i<=x; i++)
        h[i]=(h[i-1]*i)%mod;
}
ll iv(ll a)
{
    ll x,y;
    if(ex_gcd(a,mod,x,y))
        return (x+mod)%mod;
}
ll zhs(ll a, ll b)
{
    return h[b]*iv(h[a])%mod*iv(h[b-a])%mod;
}
int main()
{
    ll x, y;
    while (~sll2(x, y))
    {
        if((2*x-y)%3&&(2*y-x)%3)
            cout<<0<<endl;
        else
        {
            ll a,b;
            if(2*x-y>0)
            {
                a=(2*x-y)/3;
                b=x-2*a;
            }
            else
            {
                a=(2*y-x)/3;
                b=y-2*a;
            }
            init(maxn);
            if(a>0&&b>0)
                cout<<zhs(a,a+b)<<endl;;
            else
                cout<<0<<endl;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:13: error: 'else' without a previous 'if'
   71 |             else
      |             ^~~~
a.cc: In function 'll iv(ll)':
a.cc:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  long long x, y, p = 1000000007;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if (x < (x + y) / 3 || y < (x + y) / 3) {
    cout << 0 << endl;
    return 0;
  }
  long long n = (x + y) / 3;
  long long r = min(x - (x + y) / 3, y - (x + y) / 3);
  long long ncr = 1;
  for (long long i = 0; i < r; i++) {
    ncr *= n - i;
    ncr &= p;
  }
  for (long long i = 0; i < r; i++) {
    ncr *= modinv(i + 1, p);
    ncr %= p;
  }
  cout << ncr << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:12: error: 'modinv' was not declared in this scope
   23 |     ncr *= modinv(i + 1, p);
      |            ^~~~~~
Language: C++

#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
int const MOD=1e9+7;
int X, Y;
int const MAXN=35000;
map<pair<int,int>, int> memo;
int power(long long a, long long b, long long c)
{
    long long res = 1;
    a = a % c;
    while (b > 0) {
        if (b % 2 == 1)
            res = (res*a) % c;
        b = b / 2;
        a = (a*a) % c;  
    }
    return res;
}
int main(){
	cin>>X>>Y;
	if((X+Y)%3)
		return cout<<0, 0;
	int moves=(X+Y)/3;
	X-=moves;
	Y-=moves;
	vector<long long> fact(X+Y+1);
	fact[0]=1;
	for(int i=1;i<=X+Y;i++)
		fact[i]=(i*fact[i-1])%MOD;
	//(X+Y)!/X!Y!
	long long num=fact[X+Y];
	long long den=(fact[X]*fact[Y])%MOD;
	//den^(mod-2)mod mod
	if(den%1e9+7==0)
      while(1);
  	den=power(den,1e9+5,1e9+7);
	cout<<(num*den)%MOD;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:15: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   35 |         if(den%1e9+7==0)
      |            ~~~^~~~
      |            |   |
      |            |   double
      |            long long int
Language: C++

#include <iostream>
#include <cmath>
using namespace std;

constexpr int kMod = pow(10, 9) + 7;

// Input: destination coordinate (X, Y)
int main () {
  //int X, Y;
  int X = 0;
  int Y = 0;

  cin >> X;
  cin >> Y;

  if ((X + Y) % 3 != 0) {
    cout << 0 << endl
    return 0;
  }

  int x = (X+1)/2;
  int y = (Y+1)/2;

  int dp[x][y];
  dp[0][0] = 0;
  for (int i =0; i < x; ++i) {
    dp[i][0] = 1;
  }

  for (int j =0; j < y; ++j) {
    dp[0][j] = 1;
  }


  for (int i = 1; i < x; ++i) {
    for (int j = 1; j < y; ++j) {
      if ((2*i + j) > X || ((2*j + i) > Y)) {
        dp[i][j] = -1;
        break;
      }
      dp[i][j] = dp[i][j-1] + dp[i-1][j];
      if ((2*i + j) == X && ((2*j + i) == Y)) {
        cout << dp[i][j] % kMod << endl;
        return 0;
      }
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:22: error: expected ';' before 'return'
   17 |     cout << 0 << endl
      |                      ^
      |                      ;
   18 |     return 0;
      |     ~~~~~~
Language: C

#include <stdio.h>

#define MOD_VAL	1000000007

long long int modpow(long long int a, long long int n, long long int mod) {
    long long int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long int modinv(long long int a) {
    return modpow(a, (long long int)(MOD_VAL - 2), (long long int)MOD_VAL);
}

long long int factorial_mod(long long int a)
{
  long long int ret = 1;
  while( a > 1 ) {
    ret = (ret * a) % (long long int)MOD_VAL;
    a--;
  }
  return ret;
}

long long int combination_mod(long long int n, long long int k)
{
  long long int bunbo, bunshi;
  bunshi = factorial_mod( n );
  bunbo = (factorial_mod( k ) * factorial_mod( n-k )) % (long long int)MOD_VAL;
}

int main()
{
  int ret, X, Y;
  int n, m;
  ret = scanf("%d %d", &X, &Y);
  if ( (X + Y) % 3 != 0 ) {
    printf("0\n");
    return 0;
  }
  n = (2 * X - Y) / 3;
  m = (2 * Y - X) / 3;
  if ( n < 0 || m < 0 ) {
    printf("0\n");
    return 0;
  }
  pritnf("%lld\n", combination_mod( n + m, n ));
}


Compiler output:
main.c: In function 'main':
main.c:51:3: error: implicit declaration of function 'pritnf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   51 |   pritnf("%lld\n", combination_mod( n + m, n ));
      |   ^~~~~~
      |   printf