Language: C++

#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

typedef  ll ll;

const  ll MAX = 300000;
 ll MOD = 998244353;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for ( ll 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;
    }
}

ll COM( ll n,  ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll COM3(ll N, ll R, ll G, ll B) {
   ll ans = 1;
   ll tmp1 = COM(N, R) % MOD;
   ll tmp2 = COM(N - R, G) % MOD;
   ll tmp3 = COM(N - R - G, B) % MOD;
   ans *= tmp1;
   ans *= tmp2;
   ans %= MOD;
   ans *= tmp3;
   ans %= MOD;
   return ans;
}

ll gcd (ll a , ll b) {
   if (b == 0) return a;
   return gcd(b, a % b);
}

 ll extGCD( ll a,  ll b,  ll &x,  ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
     ll d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main() {
   ll A, B, K;
    ll N;

   cin >> N >> A >> B >> K;
   
   COMinit();
   // Ax + By = K = K'g
   ll g = gcd(A, B);
   if (K % g !=0) {
      cout << "1" << endl;
      return 0;
   } 
   ll Kg = K / g;
   ll x, y;
   extGCD(A, B, x, y);
   
   vector<ll> xv, yv;
   if (x >= 0 && y >= 0) {
      xv.push_back(x * Kg);
      yv.push_back(y * Kg);
   }
   ll ag = A / g;
   ll bg = B / g;
   
   ll tmpy = y * Kg;
   ll tmpx = x * Kg;
   for(;;) {
      tmpy -= A;
      tmpx += B;
      // cout << A << " " << B << endl;
      // cout << tmpx << " " << tmpy << endl;
      if (tmpy < 0) break;
      if (tmpx >= 0 && tmpy >= 0) {
         xv.push_back(tmpx);
         yv.push_back(tmpy);
      }
   }
   tmpy = y * Kg;
   tmpx = x * Kg;
   for(;;) {
      tmpy += A;
      tmpx -= B;
      // cout << A << " " << B << endl;
      // cout << tmpx << " " << tmpy << endl;
      if (tmpx < 0) break;
      if (tmpx >= 0 && tmpy >= 0) {
         xv.push_back(tmpx);
         yv.push_back(tmpy);
      }
   }

   ll ans = 0;
   for ( ll i = 0; i < xv.size(); i++) {
      ll X = xv[i];
      ll Y = yv[i];
      ll MIN = X;
      // cout << A << "*" << X << "+" << B << "*" << Y << "=" << K << endl;
      if (MIN > Y) MIN = Y;
      for (ll j = 0; j <= MIN; j++) {
         ll R = X - j;
         ll B = Y - j;
         ll G = j;
         // cout << N << " " << R << " " << G << " " << B << " " << COM3(N, R, G, B) << endl;
         ans += COM3(N, R, G, B);
         ans %= MOD;
      }
   }

   cout << ans << endl;
   return 0;
}


Compiler output:
a.cc:8:10: error: 'll' does not name a type
    8 | typedef  ll ll;
      |          ^~
a.cc:10:8: error: 'll' does not name a type
   10 | const  ll MAX = 300000;
      |        ^~
a.cc:11:2: error: 'll' does not name a type
   11 |  ll MOD = 998244353;
      |  ^~
a.cc:13:1: error: 'll' does not name a type
   13 | ll fac[MAX], finv[MAX], inv[MAX];
      | ^~
a.cc: In function 'void COMinit()':
a.cc:16:5: error: 'fac' was not declared in this scope
   16 |     fac[0] = fac[1] = 1;
      |     ^~~
a.cc:17:5: error: 'finv' was not declared in this scope
   17 |     finv[0] = finv[1] = 1;
      |     ^~~~
a.cc:18:5: error: 'inv' was not declared in this scope; did you mean 'int'?
   18 |     inv[1] = 1;
      |     ^~~
      |     int
a.cc:19:11: error: 'll' was not declared in this scope
   19 |     for ( ll i = 2; i < MAX; i++){
      |           ^~
a.cc:19:21: error: 'i' was not declared in this scope
   19 |     for ( ll i = 2; i < MAX; i++){
      |                     ^
a.cc:19:25: error: 'MAX' was not declared in this scope
   19 |     for ( ll i = 2; i < MAX; i++){
      |                         ^~~
a.cc:20:35: error: 'MOD' was not declared in this scope
   20 |         fac[i] = fac[i - 1] * i % MOD;
      |                                   ^~~
a.cc: At global scope:
a.cc:26:1: error: 'll' does not name a type
   26 | ll COM( ll n,  ll k){
      | ^~
a.cc:32:1: error: 'll' does not name a type
   32 | ll COM3(ll N, ll R, ll G, ll B) {
      | ^~
a.cc:45:1: error: 'll' does not name a type
   45 | ll gcd (ll a , ll b) {
      | ^~
a.cc:50:2: error: 'll' does not name a type
   50 |  ll extGCD( ll a,  ll b,  ll &x,  ll &y) {
      |  ^~
a.cc: In function 'int main()':
a.cc:62:4: error: 'll' was not declared in this scope
   62 |    ll A, B, K;
      |    ^~
a.cc:63:7: error: expected ';' before 'N'
   63 |     ll N;
      |       ^~
      |       ;
a.cc:65:11: error: 'N' was not declared in this scope
   65 |    cin >> N >> A >> B >> K;
      |           ^
a.cc:65:16: error: 'A' was not declared in this scope
   65 |    cin >> N >> A >> B >> K;
      |                ^
a.cc:65:21: error: 'B' was not declared in this scope
   65 |    cin >> N >> A >> B >> K;
      |                     ^
a.cc:65:26: error: 'K' was not declared in this scope
   65 |    cin >> N >> A >> B >> K;
      |                          ^
a.cc:69:6: error: expected ';' before 'g'
   69 |    ll g = gcd(A, B);
      |      ^~
      |      ;
a.cc:70:12: error: 'g' was not declared in this scope
   70 |    if (K % g !=0) {
      |            ^
a.cc:74:6: error: expected ';' before 'Kg'
   74 |    ll Kg = K / g;
      |      ^~~
      |      ;
a.cc:75:6: error: expected ';' before 'x'
   75 |    ll x, y;
      |      ^~
      |      ;
a.cc:76:17: error: 'x' was not declared in this scope
   76 |    extGCD(A, B, x, y);
      |                 ^
a.cc:76:20: error: 'y' was not declared in this scope; did you mean 'yn'?
   76 |    extGCD(A, B, x, y);
      |                    ^
      |                    yn
a.cc:76:4: error: 'extGCD' was not declared in this scope
   76 |    extGCD(A, B, x, y);
      |    ^~~~~~
a.cc:78:13: error: template argument 2 is invalid
   78 |    vector<ll> xv, yv;
      |             ^
a.cc:80:10: error: request for member 'push_back' in 'xv', which is of non-class type 'int'
   80 |       xv.push_back(x * Kg);
      |          ^~~~~~~~~
a.cc:80:24: error: 'Kg' was not declared in this scope
   80 |       xv.push_back(x * Kg);
      |                        ^~
a.cc:81:10: error: request for member 'push_back' in 'yv', which is of non-class type 'int'
   81 |       yv.push_back(y * Kg);
      |          ^~~~~~~~~
a.cc:83:6: error: expected ';' before 'ag'
   83 |    ll ag = A / g;
      |      ^~~
      |      ;
a.cc:84:6: error: expected ';' before 'bg'
   84 |    ll bg = B / g;
      |      ^~~
      |      ;
a.cc:86:6: error: expected ';' before 'tmpy'
   86 |    ll tmpy = y * Kg;
      |      ^~~~~
      |      ;
a.cc:87:6: error: expected ';' before 'tmpx'
   87 |    ll tmpx = x * Kg;
      |      ^~~~~
      |      ;
a.cc:89:7: error: 'tmpy' was not declared in this scope; did you mean 'tm'?
   89 |       tmpy -= A;
      |       ^~~~
      |       tm
a.cc:90:7: error: 'tmpx' was not declared in this scope; did you mean 'tm'?
   90 |       tmpx += B;
      |       ^~~~
      |       tm
a.cc:95:13: error: request for member 'push_back' in 'xv', which is of non-class type 'int'
   95 |          xv.push_back(tmpx);
      |             ^~~~~~~~~
a.cc:96:13: error: request for member 'push_back' in 'yv', which is of non-class type 'int'
   96 |          yv.push_back(tmpy);
      |             ^~~~~~~~~
a.cc:99:4: error: 'tmpy' was not declared in this scope; did you mean 'tm'?
   99 |    tmpy = y * Kg;
      |    ^~~~
      |    tm
a.cc:99:15: error: 'Kg' was not declared in this scope
   99 |    tmpy = y * Kg;
      |               ^~
a.cc:100:4: error: 'tmpx' was not declared in this scope; did you mean 'tm'?
  100 |    tmpx = x * Kg;
      |    ^~~~
      |    tm
a.cc:108:13: error: request for member 'push_back' in 'xv', which is of non-class type 'int'
  108 |          xv.push_back(tmpx);
      |             ^~~~~~~~~
a.cc:109:13: error: request for member 'push_back' in 'yv', which is of non-class type 'int'
  109 |          yv.push_back(tmpy);
      |             ^~~~~~~~~
a.cc:113:6: error: expected ';' before 'ans'
  113 |    ll ans = 0;
      |      ^~~~
      |      ;
a.cc:114:12: error: expected ';' before 'i'
  114 |    for ( ll i = 0; i < xv.size(); i++) {
      |            ^~
      |            ;
a.cc:114:20: error: 'i' was not declared in this scope
  114 |    for ( ll i = 0; i < xv.size(); i++) {
      |                    ^
a.cc:114:27: error: request for member 'size' in 'xv', which is of non-class type 'int'
  114 |    for ( ll i = 0; i < xv.size(); i++) {
      |                           ^~~~
a.cc:115:9: error: expected ';' before 'X'
  115 |       ll X = xv[i];
      |         ^~
      |         ;
a.cc:116:9: error: expected ';' before 'Y'
  116 |       ll Y = yv[i];
      |         ^~
      |         ;
a.cc:117:9: error: expected ';' before 'MIN'
  117 |       ll MIN = X;
      |         ^~~~
      |         ;
a.cc:119:11: error: 'MIN' was not declared in this scope
  119 |       if (MIN > Y) MIN = Y;
      |           ^~~
a.cc:119:17: error: 'Y' was not declared in this scope
  119 |       if (MIN > Y) MIN = Y;
      |                 ^
a.cc:120:14: error: expected ';' before 'j'
  120 |       for (ll j = 0; j <= MIN; j++) {
      |              ^~
      |              ;
a.cc:120:22: error: 'j' was not declared in this scope; did you mean 'jn'?
  120 |       for (ll j = 0; j <= MIN; j++) {
      |                      ^
      |                      jn
a.cc:120:27: error: 'MIN' was not declared in this scope
  120 |       for (ll j = 0; j <= MIN; j++) {
      |                           ^~~
a.cc:121:12: error: expected ';' before 'R'
  121 |          ll R = X - j;
      |            ^~
      |            ;
a.cc:122:12: error: expected ';' before 'B'
  122 |          ll B = Y - j;
      |            ^~
      |            ;
a.cc:123:12: error: expected ';' before 'G'
  123 |          ll G = j;
      |            ^~
      |            ;
a.cc:125:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
  125 |          ans += COM3(N, R, G, B);
      |          ^~~
      |          abs
a.cc:125:25: error: 'R' was not declared in this scope
  125 |          ans += COM3(N, R, G, B);
      |                         ^
a.cc:125:28: error: 'G' was not declared in this scope
  125 |          ans += COM3(N, R, G, B);
      |                            ^
a.cc:125:17: error: 'COM3' was not declared in this scope
  125 |          ans += COM3(N, R, G, B);
      |                 ^~~~
a.cc:126:17: error: 'MOD' was not declared in this scope
  126 |          ans %= MOD;
      |                 ^~~
a.cc:130:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
  130 |    cout << ans << endl;
      |            ^~~
      |            abs