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

#include<bits/stdc++.h>

//コピペここから

namespace MMNMM {

// extended Euclidean Algorithm
// ax + by = gcd(a, b)
// return : gcd(a, b)
    template<typename Integer = int_fast64_t>
    constexpr Integer extgcd(Integer a, Integer b, Integer &x, Integer &y) {
        Integer u = 0, v = 1, q = 0, tmp = 0;
        x = v = 1;
        y = u = 0;

        while (b) {
            q = a / b;
            x ^= u ^= x ^= u;
            u = u - q * x;
            y ^= v ^= y ^= v;
            v = v - q * y;
            a ^= b ^= a ^= b;
            b = b - q * a;
        }

        return a;
    }

// mod inverse(設計が変わるかもしれません)
// return : val^(-1) mod MOD
    template<uint_fast64_t MOD, typename Integer = int_fast64_t>
    constexpr Integer modinv(Integer val) {
        int_fast64_t ret = 0, tmp = 0;

        extgcd<int_fast64_t>(static_cast<int_fast64_t>(val), static_cast<int_fast64_t>(MOD), ret, tmp);

        return static_cast<Integer>(ret > 0 ? ret % MOD : (MOD - (-ret % MOD)));
    }

// const expression factorial mod MOD
    template<std::size_t N, std::uint_fast64_t MOD>
    struct Fact {
        std::uint_fast64_t val[N + 1];

        constexpr Fact() : val() {
            val[0] = 1;
            for (std::size_t i = 1; i <= N; ++i) val[i] = val[i - 1] * i % MOD;
        }
    };

// const expression factorial inverse mod MOD
    template<std::size_t N, std::uint_fast64_t MOD, std::uint_fast64_t F>
    struct IFact {
        std::uint_fast64_t val[N + 1];

        constexpr IFact() : val() {
            val[N] = F;
            for (std::size_t i = N; i; --i) val[i - 1] = val[i] * i % MOD;
        }
    };
}

constexpr std::uint_fast64_t MOD = 998244353, maxN = 3000000;

constexpr auto fact = MMNMM::Fact<maxN, MOD>();
constexpr auto ifact = MMNMM::IFact<maxN, MOD, MMNMM::modinv<MOD>(fact.val[maxN])>();

// const expression binomial mod MOD
inline constexpr std::uint_fast64_t binommod(std::uint_fast64_t n, std::uint_fast64_t r){
    if(r < 0 || r > n)return 0;
    return fact.val[n] * (ifact.val[r] * ifact.val[n - r] % MOD) % MOD;
}

inline constexpr std::uint_fast64_t C(std::uint_fast64_t n, std::uint_fast64_t r){
    return binommod(n, r);
}

//コピペここまで(ある部分を使うためにはそれより上を全てコピーしてください)

//verified : AtCoder Grand Contest 025 B - RGB Coloring

long long int N, M, A, B, K, ans;

int main(){
    using namespace std;
    scanf("%lld%lld%lld%lld", &N, &A, &B, &K);
    M = min(N, K / A);
    for(int i = 0; i <= M; ++i){
        if((K - i * A) % B == 0){
            ans += C(N, i) * C(N, (K - i * A) / B);
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc:65:46:   in 'constexpr' expansion of 'MMNMM::Fact<3000000, 998244353>()'
a.cc:47:13: error: 'constexpr' loop iteration count exceeds limit of 262144 (use '-fconstexpr-loop-limit=' to increase the limit)
   47 |             for (std::size_t i = 1; i <= N; ++i) val[i] = val[i - 1] * i % MOD;
      |             ^~~
Language: C++

// ConsoleApplication2.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <string.h>

long long ta[99999];

int main()
{
	int n;
	int a;
	int b;
	long long k;
	std::cin >> n >> a >> b >> k;
//	n = 4; a = 2; b = 1; k = 5;
//	printf("%d\t%d\t%d\t%lld\n", n, a, b, k);
//	system("pause");
	ta[0] = 1;
	long long q = 1;
	int m = (n + 1) / 2;
	long long answer = 0;

	for (int i = 1; i < m + 1; i++) {
		q = (q * (n - i + 1)) % 998244353;
		long long j = 998244353 - 2;
		long long ii = i;
		while (j > 0) {
			if (j % 2 == 1) {
				q = (q*ii) % 998244353;
			}
			ii = (ii*ii) % 998244353;
			j = j / 2;
		}
		ta[i] = q;
	}
	for (int i = m + 1; i < n + 1; i++) {
		ta[i] = ta[n - i];
	}
	for (int i = 0; i < n + 1; i++) {
//		printf("%d\t%lld\n", i, ta[i]);
	}
	for (int i = 0; i < n + 1; i++) {
		if ((k - i*a) % b == 0) {
			int j = (k - i*a) / b;
			if (j <= n && j >= 0) {
				long long pp = (ta[i])*(ta[j]);
//				printf("%d %d %lld %lld %lld\n", i, j, ta[i],ta[j],pp);
				answer += pp;
				answer = answer % 998244353;
			}
			else {
				continue;
			}
		}
	}




//	printf("%d\t%d\t%d\t%d\n", n, a, b, k);
	printf("%lld\n", answer);

	system("pause");
}


Compiler output:
a.cc:4:10: fatal error: stdafx.h: No such file or directory
    4 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

def combo(m,n):
    ans=1
    for i in range(n+1,m+1):
        ans*=i
    for i in range(1,(m-n+1)):
        ans=ans//i
    return ans

num=input().split()
N=int(num[0])
A=int(num[1])
B=int(num[2])
K=int(num[3])
res=0
tim=min(K//A,N)

for i in range(0,tim+1):
    if (K-i*A)%B==0:
        m=i
        n=(K-i*A)//B
        if m+n>2*N:
            break
        res+=combo(N,m)*combo(N,n)
        res=res%998244353
print(res)


Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def combo(m,n):
      | ^~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

ll c(ll n, ll m)
{
    if (n - m < m)
        m = n - m;

    ll r = 1;
    for (ll i = 0; i < m; i++)
    {
        r *= n - i;
      r/=i+1
        r %= 998244353;
    }
    return r;
}

int main()
{

    ll n, a, b, k;
    vector<ll> an, bn;
    cin >> n >> a >> b >> k;

    if (k == 0)
    {
        cout << 1 << endl;
        return 0;
    }

    if (a > b)
    {
        int i = 0;
        while ((k - a * i) / b > n)
            i++;
        while ((k - a * i) / b > 0)
        {
            if ((k - a * i) % b == 0)
            {
                an.push_back(i);
                bn.push_back((k - a * i) / b);
            }

            i++;
        }
    }
    else
    {
        int i = 0;
        while ((k - b * i) / a > n)
            i++;
        while ((k - b * i) / a > 0)
        {
            if ((k - b * i) % a == 0)
            {
                bn.push_back(i);
                an.push_back((k - b * i) / a);
            }

            i++;
        }
    }

    ll ans = 0;
    for (int i = 0; i < an.size(); i++)
    {
        ans += c(n, an[i]) * c(n, bn[i]);
        ans %= 998244353;

        cout << an[i] << " " << bn[i] << endl;
        cout << c(n, an[i]) << endl;
        cout << c(n, bn[i]) << endl;
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'll c(ll, ll)':
a.cc:17:13: error: expected ';' before 'r'
   17 |       r/=i+1
      |             ^
      |             ;
   18 |         r %= 998244353;
      |         ~
Language: C++

#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 300000
#define LL long long
#define MO 998244353
LL fac[MAXN+5],inv[MAXN+5];
LL powmod(LL a,LL b)
{
	LL ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%MO;
		a=a*a%MO;
		b>>=1;
	}
	return ret;
}
void gcd(LL a,LL b,LL &x,LL &y,LL &d)
{
	if(b==0)
	{
		x=1;y=0;d=a;
		return;
	}
	gcd(b,a%b,y,x,d);
	y-=(a/b)*x;
}
void Init()
{
	fac[0]=inv[0]=1;
	for(int i=1;i<=MAXN;i++)
		fac[i]=i*fac[i-1]%MO;
	inv[n]=powmod(fac[n],MO-2);
	for(int i=MAXN-1;i>=1;i--)
		inv[i]=(i+1)*inv[i+1]%MO;
}
LL n,A,B,k,x,y,d,tot;
LL Solve(int i,int j)
{
	return inv[i]*inv[j]%MO*inv[n-i]%MO*inv[n-j]%MO;
}
int main()
{
	scanf("%lld%lld%lld%lld",&n,&A,&B,&k);
	Init();
	gcd(A,B,x,y,d);
	if(k%d)
	{
		printf("0\n");
		return 0;
	}
	A/=d,B/=d,k/=d;
	x*=k,y*=k;
	LL ad1=B,ad2=A;
	LL ans=0;
	LL j=x/ad1*ad2+y;
	LL i=x%ad1;
	int s=0;
	for(;i<=n&&j>=0;i+=ad1,j-=ad2)
	{
		if(j>n) continue;
		ans=ans+Solve(i,j);
		if(ans>=MO) ans-=MO;
	}
	printf("%lld\n",ans*fac[n]%MO*fac[n]%MO);
}

Compiler output:
a.cc: In function 'void Init()':
a.cc:34:13: error: 'n' was not declared in this scope
   34 |         inv[n]=powmod(fac[n],MO-2);
      |             ^
Language: Java

//package ldm;
import java.math.BigInteger;
import java.util.Scanner;
public class main {

	public static void main(String[] args) {
		 
       Scanner sc = new Scanner(System.in);
	   long n=sc.nextLong();
	   long a=sc.nextLong();
	   long b=sc.nextLong();
	   long k=sc.nextLong();
	   if(k==0) System.out.println(1);
	   else
	   {
		   long re=a,gr=a+b,bl=b;
		   BigInteger ans=BigInteger.ONE;
		   BigInteger sum=BigInteger.ZERO;
		   for(long i=2;i<=n;i++) ans=ans.multiply(BigInteger.valueOf(i));
		   for(long i=0;i<=n;i++)
		   {
			   if(i*re<=k&&(k-i*re)%gr==0)
			   {
				   long j=(k-i*re)/gr;
				   if(j<=n&&(i+j)<=n)
				   {
					   long h=n-i-j;
					   BigInteger t=BigInteger.ZERO;
					   t=t.add(ans);
					   BigInteger an=BigInteger.ONE;
					   for(long w=2;w<=i;w++) an=an.multiply(BigInteger.valueOf(w));
					   BigInteger anss=BigInteger.ONE;
					   for(long w=2;w<=j;w++) anss=anss.multiply(BigInteger.valueOf(w));
					   BigInteger ansss=BigInteger.ONE;
					   for(long w=2;w<=h;w++) ansss=ansss.multiply(BigInteger.valueOf(w));
					   t=t.divide(ansss);
					   t=t.divide(an);
					   t=t.divide(anss);
					   sum=sum.add(t);
				   }
			   }
		   }
		   for(long i=0;i<=n;i++)
		   {
			   if(i*gr<=k&&(k-i*gr)%bl==0)
			   {
				   long j=(k-i*gr)/bl;
				   if(j<=n&&(i+j)<=n)
				   {
					   long h=n-i-j;
					   BigInteger t=BigInteger.ZERO;
					   t=t.add(ans);
					   BigInteger an=BigInteger.ONE;
					   for(long w=2;w<=i;w++) an=an.multiply(BigInteger.valueOf(w));
					   BigInteger anss=BigInteger.ONE;
					   for(long w=2;w<=j;w++) anss=anss.multiply(BigInteger.valueOf(w));
					   BigInteger ansss=BigInteger.ONE;
					   for(long w=2;w<=h;w++) ansss=ansss.multiply(BigInteger.valueOf(w));
					   t=t.divide(ansss);
					   t=t.divide(an);
					   t=t.divide(anss);
					   sum=sum.add(t);
				   }
			   }
		   }
		   for(long i=0;i<=n;i++)
		   {
			   if(i*re<=k&&(k-i*re)%bl==0)
			   {
				   long j=(k-i*re)/bl;
				   if(j<=n&&(i+j)<=n)
				   {
					   long h=n-i-j;
					   BigInteger t=BigInteger.ZERO;
					   t=t.add(ans);
					   BigInteger an=BigInteger.ONE;
					   for(long w=2;w<=i;w++) an=an.multiply(BigInteger.valueOf(w));
					   BigInteger anss=BigInteger.ONE;
					   for(long w=2;w<=j;w++) anss=anss.multiply(BigInteger.valueOf(w));
					   BigInteger ansss=BigInteger.ONE;
					   for(long w=2;w<=h;w++) ansss=ansss.multiply(BigInteger.valueOf(w));
					   t=t.divide(ansss);
					   t=t.divide(an);
					   t=t.divide(anss);
					   sum=sum.add(t);
				   }
			   }
		   }
		   BigInteger m=new BigInteger("998244353");
		   sum=sum.mod(m);
		   System.out.println(sum);
	   }
	}
}


Compiler output:
Main.java:4: error: class main is public, should be declared in a file named main.java
public class main {
       ^
1 error
Language: C++

# -*- coding: utf-8 -*-
def fac(n)
  (1..n).inject(1,:*)
end

def solve(n, a, b, k)
  sum = 0
  nfac = fac(n)
  (k / a + 1).times{|i|
    if (k - i * a) % b == 0
      t = (k - i * a) / b
      ([i, n].min + 1).times{|x|
        y = i - x
        z = t - y
        if 0 <= y and 0 <= z and x + y + z <= n
          w = n - (x + y + z)
          sum += nfac / (fac(x) * fac(y) * fac(z) * fac(w))
          sum = sum.modulo(998244353)
        end
      }
    end
  }
  sum
end

n, a, b, k = gets.split(" ").map{|t| t.to_i }
puts solve(n, a, b, k)

Compiler output:
a.cc:1:3: error: invalid preprocessing directive #-
    1 | # -*- coding: utf-8 -*-
      |   ^
a.cc:3:4: error: too many decimal points in number
    3 |   (1..n).inject(1,:*)
      |    ^~~~
a.cc:2:1: error: 'def' does not name a type
    2 | def fac(n)
      | ^~~
a.cc:23:3: error: 'sum' does not name a type
   23 |   sum
      |   ^~~
a.cc:27:1: error: 'puts' does not name a type
   27 | puts solve(n, a, b, k)
      | ^~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII; 
const double eps = 1e-12;
const double PI = acos(-1);
const LL INFF = (LL)1e18;
const int INF = (int)1e9;
const int mod = 998244353;
const int MAX = (int)6e5+7;
LL val[MAX], re_val[MAX];
bitset<MAX>ck;
LL mypow(LL v, LL t, int p){
	if(ck[p]) return re_val[p];
	LL res = 1;
	while(t){
		if(t & 1) res = res*v%mod;
		t >>= 1;
		v = v*v%mod;
	}
	ck[p] = 1;
	return re_val[p] = res;
}	
void build(){
	val[0] = 1;
	rep1(i, 1, MAX) val[i] = val[i-1]*i%mod;
	return ;
}
int main(void){
	build();
	int n;
	LL a, b, k;
	scanf("%d %lld %lld %lld", &n, &a, &b, &k);
	LL ans = 0;
	rep(i, n+1){
		LL v = a*i;
		if(v > k) break;
		LL v2 = k - v;
		if(v2 % b) continue;
		LL t = v2 / b;
		if(t > n) continue;
		int t1 = 0, t2 = i;
		if(t + i > n){
			t1 = t + i - n;
			t -= t1;
			t2 = i - t1;
		}
		while(t >= 0 && t2 >= 0){
			int t3 = n - t1 - t - t2;
			LL res = val[n]*re_val(val[t], mod - 2, t)%mod;
			res = res*re_val(val[t1], mod - 2, t1)%mod;
			res = res*re_val(val[t2], mod - 2, t2)%mod;
			res = res*re_val(val[t3], mod - 2, t3)%mod;
			ans = (ans + res)%mod;
			t--; t2--;
			t1++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:81:47: error: 're_val' cannot be used as a function
   81 |                         LL res = val[n]*re_val(val[t], mod - 2, t)%mod;
      |                                         ~~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:82:41: error: 're_val' cannot be used as a function
   82 |                         res = res*re_val(val[t1], mod - 2, t1)%mod;
      |                                   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:83:41: error: 're_val' cannot be used as a function
   83 |                         res = res*re_val(val[t2], mod - 2, t2)%mod;
      |                                   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:84:41: error: 're_val' cannot be used as a function
   84 |                         res = res*re_val(val[t3], mod - 2, t3)%mod;
      |                                   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)




ll mod = 998244353;
ll n,a,b,k;


/*
使い方
Nとmodをセットする
はじめにinitを呼ぶ
*/

ll N;
ll fact[1000002];
ll invf[1000002];

ll f(ll a, ll x){
  ll res = 1;
  a %= mod;
  while(x > 0){
    if(x&1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}

ll inv(ll x){
  return f(x, mod-2);
}

void init(){
  fact[0] = invf[0] = 1;
  FOR(i,1,N){
    fact[i] = i * fact[i-1] % mod;
    invf[i] = inv(fact[i]);
  }
}

ll P(ll n, ll r){
  return fact[n] * invf[n-r] % mod;
}

ll C(ll n, ll r){
  return P(n, r) * invf[r] % mod;
}

ll x,y;

ll cnt = 0;

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


int main(){
  cin >> n>>a>>b>>k;

  N = n +2;
  init();
  ll start = 0;
  REP(i,2*n){
    if((k-a*i)%b==0){
      start = i;
      break;
    }
  }
  int gcd_ab = gcd(a,b)
  int d = b/gcd_ab;
  for(ll x = start; x <= 2*n; x += d){
    if((k-a*x) % b != 0) continue;
    y = (k-a*x)/b;
    if(y<0) break;
    ll p = min(x,y);
    if(x+y-p>n) continue;
    for(ll i=p;i>=0;i--){
      ll tx = x - i;
      ll ty = y - i;
      if(tx+ty+i>n) break;
      ll tmp = C(n,tx);
      tmp = (tmp*C(n-tx,ty)) % mod;
      tmp = (tmp*C(n-tx-ty,i)) % mod;
      cnt = (cnt+tmp) % mod;
    }
  }
  cout << cnt << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:3: error: expected ',' or ';' before 'int'
   82 |   int d = b/gcd_ab;
      |   ^~~
a.cc:83:36: error: 'd' was not declared in this scope
   83 |   for(ll x = start; x <= 2*n; x += d){
      |                                    ^
Language: C++

#include<iostream>
using namespace std;

typedef long long LL;
#define p 998244353
LL n,m,p;

LL quick_mod(LL a, LL b)
{
    LL ans = 1;
    a %= p;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * a % p;
            b--;
        }
        b >>= 1;
        a = a * a % p;
    }
    return ans;
}

LL C(LL n, LL m)
{
    if(m > n) return 0;
    LL ans = 1;
    for(int i=1; i<=m; i++)
    {
        LL a = (n + i - m) % p;
        LL b = i % p;
        ans = ans * (a * quick_mod(b, p-2) % p) % p;
    }
    return ans;
}

LL Lucas(LL n, LL m)
{
    if(m == 0) return 1;
    return C(n % p, m % p) * Lucas(n / p, m / p) % p;
}



int main()
{
	long long n,a,b,k;
	calJc();
	cin>>n>>a>>b>>k;
//	init(); 
//	pre(1000);
	long long cnta,cntb,cntc;
	cnta=k/a;
	cntb=k/b;
	cntc=k/(a+b);
	long long sum=0;
	for(long long x=0;x<=cntc&&x<=n;++x)
	{
		for(long long y=0;y<=cntb&&y<=n;++y)
		{
			long long left=k-x*(a+b)-y*b;
			if(left<0)
				break;
			if(left%a==0)
			{
				long long z=left/a;
				if(x+y+z>n)
					continue;
				sum=sum+Lucas(n,x)%p*Lucas(n-x,y)%p*Lucas(n-x-y,z)%mod;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
	
}

Compiler output:
a.cc:5:11: error: expected unqualified-id before numeric constant
    5 | #define p 998244353
      |           ^~~~~~~~~
a.cc:6:8: note: in expansion of macro 'p'
    6 | LL n,m,p;
      |        ^
a.cc: In function 'int main()':
a.cc:49:9: error: 'calJc' was not declared in this scope; did you mean 'calloc'?
   49 |         calJc();
      |         ^~~~~
      |         calloc
a.cc:70:84: error: 'mod' was not declared in this scope
   70 |                                 sum=sum+Lucas(n,x)%p*Lucas(n-x,y)%p*Lucas(n-x-y,z)%mod;
      |                                                                                    ^~~
Language: C++

#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
using namespace std;

const int N = 3e5 + 5;
ll n,a,b,k;
ll fakt[N];
const ll mod = 998244353;

ll modexp(ll b,ll e,ll m){
	ll r = 1;
	while(e > 0){
		if((e & 1) == 1){
			r = (r * b) % m;
		}
		e = e / 2;
		b = (b * b) % m;
	}
	return r;
}

ll kombin(ll atas,ll bawah){
	if(bawah > atas){
		return 0;
	}
	if(bawah == atas){
		return 1;
	}

	ll c = (fakt[atas] * modexp(fakt[bawah], mod - 2, mod)) % mod;
	c = (c * modexp(fakt[atas - bawah], mod - 2, mod)) % mod;
	return c;
}

int main()
{
	cin.sync_with_stdio(0);		cin.tie(0);		cout.tie(0);

	cin >> n >> a >> b >> k;
	fakt[0] = 1;
	pang2[1] = 1;
	fakt[1] = 1;
	for(ll x = 2; x <= 300000; x++){
		pang2[x] = (pang2[x - 1] * (ll)2) % mod;
		fakt[x] = (fakt[x - 1] * (ll)x) % mod;
	}
	ll ans = 0;

	for(ll x = 0 ; x <= 300000; x++){
		if(x > n) break;
		ll rem = k - a * x;
		if(rem % b != 0 || rem < 0) continue;

		ll tk = rem / b;
		if(tk <= n){
			ans = (ans + (kombin(n, x) * kombin(n, tk)) % mod) % mod;
		}
	}
	cout << ans << "\n";
}	

Compiler output:
a.cc: In function 'int main()':
a.cc:45:9: error: 'pang2' was not declared in this scope
   45 |         pang2[1] = 1;
      |         ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n, r, b;
	long long u;
	cin >> n >> r >> b >> u;
	long long g = r + b;
	long long rans=0;
	if (u == 0) {
		cout << 1 << endl; return 0;
	}
	for (long long i = 0; i < u / r; i++) {
		for (long long j = 0; j < g / r; j++) {
			if ((u - r * i - g * j) % b == 0) {
				if (a / b < 0)continue;
				long long ans = 1;
				for (long long k = 1; k <= i; k++) {
					ans *= n - k + 1;
					ans /= k;
					ans %= 998244353;
				}
				for (long long k = 1; k <= j; k++){
					ans *= n - i - k + 1;
					ans /= k;
					ans %= 998244353;
				}
				for (long long k = 1; k <= (u - r * i - g * j) / b; k++) {
					ans *= n - i - j - k + 1;
					ans /= k;
					ans %= 998244353;
				}
				rans += ans;
				rans %= 998244353;
			}
		}
	}
	cout << rans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:37: error: 'a' was not declared in this scope
   15 |                                 if (a / b < 0)continue;
      |                                     ^
Language: C++

#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=998244353;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
ll mod_pow(ll x,ll n,ll mod){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret=ret*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return ret;
}
ll f[300010],fr[300010];
ll ncr(ll n,ll r){
	if(r==0){
		return 1;
	}else{
		return f[n]*fr[r]%MOD*fr[n-r]%MOD;
	}
}
int main(){
	f[0]=1;
	ll n,a,b,k;cin>>n>>a>>b>>k;
	for(ll i=1;i<=n;i++){
		f[i]=f[i-1]*i%MOD;
	}
	fr[n]=mod_pow(f[n],MOD-2,MOD);
	for(ll i=n-1;i>=0;i--){
		fr[i]=fr[i+1]*(i+1)%MOD;
	}
	ll ans=0;
	if(k==0){
		cout<<1<<endl;
		return 0;
	}
	if(k/c>n){
		cout<<0<<endl;
		return 0;
	}
	ll c=a+b;
	for(ll i=0;i<=k/c;i++){
		for(ll j=0;j<=(k-c*i)/a;j++){
			if(i+j>n)continue;
			if(i*c+j*a>k)continue;
			if((k-i*c-j*a)%b)continue;
			ans+=ncr(n,i)*ncr(n-i,j)*ncr(n-i-j,(k-i*c-j*a)/b)%MOD;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:14: error: 'c' was not declared in this scope
   47 |         if(k/c>n){
      |              ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mod 998244353
#define maxn 400010
using namespace std;
typedef long long ll;
ll n,a,b,k;
ll x,y;
ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(b==0)
    {
        x=1;y=0;
        return a;
    }
    ll res=exgcd(b,a%b,x,y);
    ll tmp=x;
    x=y;
    y=tmp-(a/b)*y;
    return res;
}
ll ans;
ll quick_pow(ll x,ll p)
{-
    ll an=1;
    ll po=x;
    while(p)
    {
        if(p%2)  an=(an*po)%mod;
        po=(po*po)%mod;
        p/=2;
    }
    return an;
}
ll C[maxn],fac[maxn],ine[maxn];
int main()
{
    scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
    C[0]=1;
    for(ll i=1;i<=n;i++)  C[i]=C[i-1]*(n-i+1)%mod*quick_pow(i,mod-2)%mod;
    fac[0]=1;
    for(ll i=1;i<=n;i++)  fac[i]=(fac[i-1]*i)%mod;
    for(int i=0;i<=n;i++)  ine[i]=quick_pow(fac[i],mod-2);
    ll g=exgcd(a,b,x,y);
    if(k%g!=0)
    {
        puts("0");
        return 0;
    }
    x*=k/g;y*=k/g;
    ll mi1=b/g;
    ll mi2=a/g;
    if(x<0)
    {
        ll p=(-x-1)/mi1+1;
        x+=p*mi1;
        y-=p*mi2;
    }
    else{
        ll p=x/mi1;
        x-=p*mi1;
        y+=p*mi2;
    }
    //cout<<x<<" "<<y<<endl;
    while(x>=0&&y>=0&&x<=n)
    {
        //cout<<x<<" "<<y<<endl;
        for(ll i=max((ll)0,x+y-n);i<=min(x,y);i++)
        {
            if(n-x-y+i<0)  continue;
            if(i>n)  continue;
            if(x-i>n-i)  continue;
            if(y-i>n-x)  continue;
            ll op=fac[n]*fac[n-i]%mod*fac[n-x]%mod;
            //cout<<op<<endl;
            //op=op*quick_pow(fac[i],mod-2)%mod*quick_pow(fac[n-i],mod-2)%mod;
            op=op*ine[i]%mod*ine[n-i]%mod;
            //cout<<op<<endl;
            //op=op*quick_pow(fac[n-x],mod-2)%mod*quick_pow(fac[x-i],mod-2)%mod;
            //op=op*quick_pow(fac[n-x-y+i],mod-2)%mod*quick_pow(fac[y-i],mod-2)%mod;
            //cout<<op<<endl;
            op=op*ine[n-x]%mod*ine[x-i]%mod;
            op=op*ine[n-x-y+i]%mod*ine[y-i]%mod;
            ans=(ans+op)%mod;
        }
        x+=mi1;
        y-=mi2;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'll quick_pow(ll, ll)':
a.cc:28:8: error: expected primary-expression before 'an'
   28 |     ll an=1;
      |        ^~
a.cc:32:18: error: 'an' was not declared in this scope; did you mean 'yn'?
   32 |         if(p%2)  an=(an*po)%mod;
      |                  ^~
      |                  yn
a.cc:36:12: error: 'an' was not declared in this scope; did you mean 'yn'?
   36 |     return an;
      |            ^~
      |            yn
Language: C++

#include <iostream>
using namespace std;

int cnoyatu(int a, int b) {
	int aa = a, bb = b;
	for (int i = 1; i < b; i++) {
		aa *= a - i;
		bb *= b - i;
	}

	return aa / bb;
}

int main() {
	int n, a, b, k, cnt=0;

	cin >> n >> a >> b >> k;
	
	int c = a + b;

	if (a*n <= k && k%a == 0) cnt += cnoyatu(n, k / a);
	if (b*n <= k && k%b == 0) cnt += cnoyatu(n, k / b);
	if (c*n <= k && k%c == 0) cnt += cnoyatu(n, k / c);

	if((k%a) % b == 0)
	if ((k%a) % c == 0)
	if ((k%b) % a == 0)
	if ((k%b) % c == 0)
	if ((k%c) % a == 0)
	if ((k%c) % b == 0)

	cout << cnoyatu(4, 3) << cnoyatu(5, 2) << cnoyatu(6, 4);


	muri
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'muri' was not declared in this scope
   35 |         muri
      |         ^~~~
Language: C++

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
const ll MOD = 998244353LL;
ll add(ll &a, ll b) {return a=(a+b)%MOD;}
ll mul(ll &a, ll b) {return a=(a*b)%MOD;}

const int SIZE = 300000+10;

ll fact[SIZE];

ll inv(ll a, ll p) {
  return ( a == 1LL ? 1LL : (1LL - p*inv(p%a, a)) / a + p );
}

ll solve(ll N, ll A, ll B, ll K) {
  ll ans = 0;
  ll start = max(0LL, K-N*B);
  for(ll a = 0; a <= N; a++) {
    if(a*A > K) break;
    ll b = (K-(a*A))/B;
    if(a*A+b*B != K) continue;
    //    cout << a << " " << b << endl;                                                
    ll g = min(a, b);
    for( ; g >= 0; g--) {
      ll red = a-g;
      ll blue = b-g;
      ll rem = N-(red+blue+g);
      if(rem < 0LL) break;
      ll tmp = 1LL;
      ll tmp1 = 1LL;
      mul(tmp, fact[red]);
      mul(tmp, fact[blue]);
      mul(tmp, fact[g]);
      mul(tmp, fact[rem]);
      ll tmp2 = inv(tmp, MOD);
      mul(tmp1, fact[N]);
      mul(tmp1, tmp2);
      //    cout << red << "," << blue << "," << g << "," << rem << "=" ;               
      //    cout << tmp1 << "," << tmp2 << " " << tmp << endl;                          
      add(ans, tmp1);
    }
  }
  return ans;
}

int main() {
  fact[0] = 1; fact[1] = 1;
  ifact[0] = 1; ifact[1] = 1;
  for(int i = 2; i < SIZE; i++) {
    fact[i] = (ll)i;
    mul(fact[i],fact[i-1]);
    //    cout << i << " " << fact[i] << endl;                                          
  }
  ll N;
  ll A, B;
  ll K;
  cin>>N>>A>>B>>K;
  if(A>B) swap(A,B);
  ll ans = solve(N, A, B, K);
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:3: error: 'ifact' was not declared in this scope; did you mean 'fact'?
   57 |   ifact[0] = 1; ifact[1] = 1;
      |   ^~~~~
      |   fact
Language: C++

#include<iostream>
using namespace std;

int main(){
	int N,A,B,K;
	cin>>N>>A>>B>>K;
	int d;
	int e;
	int f;
	int g;
	int h;
	int kh[h][3];
	if(N==d+e+f+g){
		if{K==A*d+(A+B)*e+B*f+0*g}{
			kh[h][0]=d;
			kh[h][1]=e;
			kh[h][2]=f;
			kh[h][3]=g;
			cout<<h%998244353<<endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: expected '(' before '{' token
   14 |                 if{K==A*d+(A+B)*e+B*f+0*g}{
      |                   ^
      |                   (
Language: C++

/*
Problem:B - RGB Coloring
Algorithm:Maths
Status:
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <utility>
#include <list>
#include <ctime>
#include <memory.h>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <windows.h>

using namespace std;

const long long INF=998244353ll;
const long long mod=998244353ll;

typedef long long ll;

long long c[300005];
long long a,b,n;
long long k;

long long fpower(long long x,long long y){
	if(y=0)return 1l;
	if(y=1)return x;
	if(y&1){
		long long tmp=fpower(x,y/2);
		return (((tmp*tmp)%INF)*x)%INF;
	}
	long long tmp=fpower(x,y/2);
	return (tmp*tmp)%INF;
}

ll mpow(ll a,ll b,ll mod){
 if(b==0) return 1;
 ll ans=mpow(a,b/2,mod);
 if(b%2==1){
  return ans*ans%mod*a%mod;
 }else{
  return ans*ans%mod;
 }
}


ll inv(ll a,ll mod){
 return mpow(a,mod-2,mod);
}

/*
void pre(){
	C[0]=1;
	for(long long i=1;i<=n;i++){
		C[i]=(C[i-1]*(n-i+1));
		C[i]=(C[i]%(INF*i))/i;
		//cout<<C[i]<<endl;
	}
	
}
*/

int main()
{
	long long ans=0;

	cin>>n>>a>>b>>k;
	
	c[0]=1;
	for(ll i=1,j=n; i<=n; i++,j--)  {
 		ll ooo=j*inv(i,mod)%mod;
 		c[i]=c[i-1]*ooo%mod; 
	}
	
	for(long long an=0;an<=n;an++){
		if((k-an*a)%b==0){
			int bn=(k-an*a)/b;
			ans+=(c[an]*c[bn])%INF;
		}
	}
	cout<<ans%INF<<endl;
	
	return 0;
}


Compiler output:
a.cc:25:10: fatal error: windows.h: No such file or directory
   25 | #include <windows.h>
      |          ^~~~~~~~~~~
compilation terminated.
Language: C++

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

Int gcd(Int a, Int b) {
  return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
  return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
Int extgcd(Int a, Int b, Int &x, Int &y) {
  Int g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

Int invMod(Int a, Int m) {
  Int x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;
  else                         return 0; // unsolvable
}

ll mod = 998244353;
#define SIZE 300000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}

signed main(){
  Int n,a,b,k,x,y;
  cin >> n >> a >> b >> k;

  invinit();
  extgcd(a,b,x,y);
  if(x < 0) {
    x += b; y-= a;
  }

  Int X,Y;
  X= (k%b)*x; Y=(k%b)*y + k/b;
  Int c = X/b;
  X -= c*b; Y+= c*a;
  x=X;y=Y;

  ll ans = 0;
  while (x <= N && y >= 0) {
/*    cout << x << endl;
    cout << y << endl;
    cout << com(n,x) << endl;
    cout << com(n,y) << endl;
*/    ans = (ans + com(n,x)*com(n,y)%mod) % mod;

    x += b;
    y -= a;

  }

  cout << ans << endl;



}











Compiler output:
a.cc: In function 'int main()':
a.cc:68:15: error: 'N' was not declared in this scope
   68 |   while (x <= N && y >= 0) {
      |               ^
Language: C++

#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

typedef struct {
  int r;
  int g;
  int b;
}RGB;

using namespace std;

long comb(long n,long c){
  long up=1,down=1;
  long ii;

  for(ii=1;ii<=n-c;ii++){
	up *= (n-ii+1);
	down *= ii;
  }
  return up/down;
}

int main(){
  int n,a,b,k;
  int rr,gg,bb;
  int ii,jj,kk;
  long ret=0;
  vector<RGB> vec;
  long retn,patr,patg,patb;
  cin >> n >> a >> b >> k;

  for(rr=0;rr<=k/a+1;rr++){
	gg = 0;
	bb = 0;

	while((rr*a + gg*(a+b) + bb*b <= k) &&
		  gg <= k/(a+b) + 
		  ){
	  bb=0;
	  while(rr*a + gg*(a+b) + bb*b <= k &&
			bb <= k/b +1){

		if((rr*a + gg*(a+b) + bb*b) == k &&
		   rr + gg + bb <= n){
		  RGB rgb;
		  rgb.r = rr;
		  rgb.g = gg;
		  rgb.b = bb;
		  retn = n;
		  patr = comb(retn,rgb.r);
		  retn -= rgb.r;
		  patg = comb(retn,rgb.g);
		  retn -= rgb.g;
		  patb = comb(retn,rgb.b);
		  ret += patr*patg*patb;		  
		}
		bb++;
	  }
	  gg++;
	}
  }

  cout << ret << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:19: error: expected primary-expression before ')' token
   46 |                   ){
      |                   ^
Language: C++

#include<iostream>
using namespace std;
int main(){
  unsigned int N,A,B,K,ans;
  ans = 0;
  cin >> N >> A >> B >> K;
  if(k==0)
    ans = 1;
  else{
    ans += (N*A)%998244353;
    ans = (ans*B)%998244353;
    K = K%998244353;
    ans = (ans*K)%998244353;
  }
  cout << ans << "\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:6: error: 'k' was not declared in this scope
    7 |   if(k==0)
      |      ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
#define long long long
inline int inv(int n, int p) {
	int i = 1;
	for (int r = n; r > 1; r = p % r)
		i = p / r * long(p - i) % p;
	return i;
}
long c[333333];
int main()
{
	int n, a, b;
	long k;
	cin >> n >> a >> b >> k;
	int p = 998244353;
	c[0] = 1;
	for (int i = 0; i < n; i++)
		c[i + 1] = long(n - i)*inv(i + 1, p) % p*c[i] % p;
	long r = 0;
	for (int i = 0; i <= n; i++) {
		long x = k - long(i)*a;
		if (x%b || x<0 || x / b>n) continue;
		r += c[i] * c[x / b];
		r %= p;
	}
	cout << r << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int inv(int, int)':
a.cc:4:14: error: expected primary-expression before 'long'
    4 | #define long long long
      |              ^~~~
a.cc:8:29: note: in expansion of macro 'long'
    8 |                 i = p / r * long(p - i) % p;
      |                             ^~~~
a.cc: In function 'int main()':
a.cc:4:14: error: expected primary-expression before 'long'
    4 | #define long long long
      |              ^~~~
a.cc:20:28: note: in expansion of macro 'long'
   20 |                 c[i + 1] = long(n - i)*inv(i + 1, p) % p*c[i] % p;
      |                            ^~~~
a.cc:4:14: error: expected primary-expression before 'long'
    4 | #define long long long
      |              ^~~~
a.cc:23:30: note: in expansion of macro 'long'
   23 |                 long x = k - long(i)*a;
      |                              ^~~~
Language: C++

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

int main(){
    ll n; cin >> n; ll ans = 0;
    vector<ll> l(n); vector<ll> r(n);
    REP(i,n) cin >> l[i] >> r[i];
    l.pb(0); r.pb(0);
    sort(l.rbegin(),l.rend()); sort(r.begin(),r.end());
    REP(i,n) if (l[i]>r[i]) ans += l[i]-r[i];
    cout << ans*2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'class std::vector<long long int>' has no member named 'pb'
   10 |     l.pb(0); r.pb(0);
      |       ^~
a.cc:10:16: error: 'class std::vector<long long int>' has no member named 'pb'
   10 |     l.pb(0); r.pb(0);
      |                ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

int main(){
	int N; cin >> N;
	vector<int> L(N), R(N);
	rep(i, N) cin >> L[i] >> R[i];
	sort(all(L), greater<int>());
	sort(all(R));
	ll K = 0, s = 0;
	rep(i, N){
		chmax(K, s+max{L[i], -R[i], L[i]-R[i]});
		s += L[i] - R[i];
	}
	cout << 2*K << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:27: error: invalid operands of types 'll' {aka 'long long int'} and '<unresolved overloaded function type>' to binary 'operator+'
   28 |                 chmax(K, s+max{L[i], -R[i], L[i]-R[i]});
      |                          ~^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}

int main(){
	int N; cin >> N;
	vector<int> L(N), R(N);
	rep(i, N) cin >> L[i] >> R[i];
	sort(all(L), greater<P>());
	sort(all(R));
	ll K = 0, s = 0;
	rep(i, N){
		chmax(K, s+max{L[i], -R[i], L[i]-R[i]});
		s += L[i] - R[i];
	}
	cout << 2*K << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:30: error: 'P' was not declared in this scope
   12 |         sort(all(L), greater<P>());
      |                              ^
a.cc:12:31: error: template argument 1 is invalid
   12 |         sort(all(L), greater<P>());
      |                               ^
a.cc:16:27: error: invalid operands of types 'll' {aka 'long long int'} and '<unresolved overloaded function type>' to binary 'operator+'
   16 |                 chmax(K, s+max{L[i], -R[i], L[i]-R[i]});
      |                          ~^~~~
Language: C++

#include <stdio.h>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;
#define mod 998244353

int main(void) {
  ll i, j, k, n, ans = 0, now = 0, be, a = 1e18;
  scanf("%lld", &n);
  set< pair<ll, ll> > s1, s2;
  set< pair<ll, ll> >::iterator it1, it2;
  pair<ll, ll> t[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld", &t[i].first, &t[i].second);
  for(be = 0; be < 2; ++be) {
    for(i = 0; i < n; ++i) {
      s1.insert(t[i]);
      ll tmp;
      tmp = t[i].first, t[i].first = t[i].second, t[i].second = tmp;
      s2.insert(t[i]);
    }
  while(s1.size()) {
    it1 = s1.end(), it2 = s2.begin();
    it1--;
    be = (be + 1) % 2;
    if(be) {
      if((*it1).first <= now && now <= (*it1).second) {
        break;
      }
      ans += abs((*it1).first - now);
      now = (*it1).first;
      //printf("%lld\n", (*it1).first);
      pair<ll, ll> tt = (*it1);
      ll tmp;
      tmp = tt.first, tt.first = tt.second, tt.second = tmp;
      s2.erase(s2.find(tt));
      s1.erase(it1);
    } else {
      if((*it2).first <= now && now <= (*it2).second) {
        break;
      }
      ans += abs((*it2).first - now);
      now = (*it2).first;
      //printf("%lld\n", (*it2).first);
      pair<ll, ll> tt = (*it2);
      ll tmp;
      tmp = tt.first, tt.first = tt.second, tt.second = tmp;
      s1.erase(s1.find(tt));
      s2.erase(it2);
    }
  }
  ans += abs(now);
  if(a > ans) a = ans;
  }
  printf("%lld", a);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:14: error: 'abs' was not declared in this scope; did you mean 'ans'?
   30 |       ans += abs((*it1).first - now);
      |              ^~~
      |              ans
a.cc:42:14: error: 'abs' was not declared in this scope; did you mean 'ans'?
   42 |       ans += abs((*it2).first - now);
      |              ^~~
      |              ans
a.cc:52:10: error: 'abs' was not declared in this scope; did you mean 'ans'?
   52 |   ans += abs(now);
      |          ^~~
      |          ans
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.begin()

void chmin(int &a, int b) {if(a > b) a = b;}

main() {
 int n; cin >> n;
 int lmin = 10000000, rmin = 10000000;
 vector<int> l(n), r(n);
 rep (i, n) {
  cin >> l[i] >> r[i];
  if (l[i] > 0) chmin(rmin, l[i] + r[i]);
  if (r[i] < 0) chmin(lmin, -l[i]-r[i]));
 }
 sort(all(l)); sort(all(r));
 vector<int> L, R;
 int ans = 0;
 rep (i, n) {
  if (r[i] < 0) L.push_back(r[i]), ans -= r[i];
  if (l[i] > 0) R.push_back(l[i]), ans += l[i];
 }
 if (L.size() + 1 < R.size()) {
  ans -= rmin;
 }
 if (R.size() + 1 < L.size()) {
  ans -= lmin;
 }
 cout << ans * 2 << endl;
}

Compiler output:
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:16:40: error: expected ';' before ')' token
   16 |   if (r[i] < 0) chmin(lmin, -l[i]-r[i]));
      |                                        ^
      |                                        ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.begin()

void chmin(int &a, int b) if(a > b) a = b;

main() {
 int n; cin >> n;
 int lmin = 10000000, rmin = 10000000;
 vector<int> l(n), r(n);
 rep (i, n) {
  cin >> l[i] >> r[i];
  if (l[i] > 0) chmin(rmin, l[i] + r[i]);
  if (r[i] < 0) chmin(lmin, -l[i]-r[i]));
 }
 sort(all(l)); sort(all(r));
 vector<int> L, R;
 int ans = 0;
 rep (i, n) {
  if (r[i] < 0) L.push_back(r[i]), ans -= r[i];
  if (l[i] > 0) R.push_back(l[i]), ans += l[i];
 }
 if (L.size() + 1 < R.size()) {
  ans -= rmin;
 }
 if (R.size() + 1 < L.size()) {
  ans -= lmin;
 }
 cout << ans * 2 << endl;
}

Compiler output:
a.cc:7:27: error: expected initializer before 'if'
    7 | void chmin(int &a, int b) if(a > b) a = b;
      |                           ^~
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:15:17: error: 'chmin' was not declared in this scope
   15 |   if (l[i] > 0) chmin(rmin, l[i] + r[i]);
      |                 ^~~~~
a.cc:16:17: error: 'chmin' was not declared in this scope
   16 |   if (r[i] < 0) chmin(lmin, -l[i]-r[i]));
      |                 ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.begin()

main() {
 int n; cin >> n;
 int lmin = 10000000, rmin = 10000000;
 vector<int> l(n), r(n);
 rep (i, n) {
  cin >> l[i] >> r[i];
  if (l[i] > 0) chmin(rmin, l[i] + r[i]);
  if (r[i] < 0) chmin(lmin, -l[i]-r[i]));
 }
 sort(all(l)); sort(all(r));
 vector<int> L, R;
 int ans = 0;
 rep (i, n) {
  if (r[i] < 0) L.push_back(r[i]), ans -= r[i];
  if (l[i] > 0) R.push_back(l[i]), ans += l[i];
 }
 if (L.size() + 1 < R.size()) {
  ans -= rmin;
 }
 if (R.size() + 1 < L.size()) {
  ans -= lmin;
 }
 cout << ans * 2 << endl;
}

Compiler output:
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:13:17: error: 'chmin' was not declared in this scope
   13 |   if (l[i] > 0) chmin(rmin, l[i] + r[i]);
      |                 ^~~~~
a.cc:14:17: error: 'chmin' was not declared in this scope
   14 |   if (r[i] < 0) chmin(lmin, -l[i]-r[i]));
      |                 ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin >> n;
    int l[n],r[n];
    for(int i=0;i<n;i++){
        cin >> l[i] >>r[i];

    }
    sort(l,l+n,greater<int>());
    sort(r,r+n);
    int ans=0;
    for(int i=0;i<n;i++){
        if(l[i]>r[i]){
            ans+=2*(l[i]-r[i]);
        }else{
            int k=max(l[i],-r[i]);
            ans+=2*max(k,0);
            break;
        }
    }
    cout << ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:23: error: no matching function for call to 'max(long long int&, int)'
   20 |             ans+=2*max(k,0);
      |                    ~~~^~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:20:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   20 |             ans+=2*max(k,0);
      |                    ~~~^~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:20:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |             ans+=2*max(k,0);
      |                    ~~~^~~~~
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(ll i = f; i < t; i++)

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
    vector<P> lsc, rsc;
    ll n;
    cin >> n;
    forin(i, 0, n) {
        ll l, r;
        cin >> l >> r;
        lsc.push_back(P{i, l});
        rsc.push_back(P{i, r});
    }
    sort(lsc.begin(), lsc.end(), [](P lhs, P rhs) {
        return lhs.second < rhs.second;
    });
    sort(rsc.begin(), rsc.end(), [](P lhs, P rhs) {
        return lhs.second > rhs.second;
    });
    
    vector<bool> used(n, false);
    
    ll lenU = 0;
    ll count = 0;
    ll pos = 0;
    auto ls = lsc, rs = rsc;
    bool vec = true;
    while (count++ < n) {
        auto& cvec = vec ? ls : rs;
        auto &cp = cvec.back();
        while (used[cp.first]) {
            cvec.pop_back();
            cp = cvec.back();
        }
        if ((vec && pos < cp.second) || (!vec && cp.second < pos)) {
            lenU += abs(cp.second - pos);
            pos = cp.second;
        }
        used[cp.first] = true;
        vec = !vec;
    }
    lenU += abs(pos);
    
    ll lenV = 0;
    ls = lsc; rs = rsc;
    ll count = 0;
    ll pos = 0;
    vec = false;
    while (count++ < n) {
        auto& cvec = vec ? ls : rs;
        auto &cp = cvec.back();
        while (used[cp.first]) {
            cvec.pop_back();
            cp = cvec.back();
        }
        if ((vec && pos < cp.second) || (!vec && cp.second < pos)) {
            lenV += abs(cp.second - pos);
            pos = cp.second;
        }
        used[cp.first] = true;
        vec = !vec;
    }
    lenV += abs(pos);
    
    
    cout << max(lenU, lenV) << endl;
    
}



Compiler output:
a.cc: In function 'int main()':
a.cc:61:8: error: redeclaration of 'll count'
   61 |     ll count = 0;
      |        ^~~~~
a.cc:39:8: note: 'll count' previously declared here
   39 |     ll count = 0;
      |        ^~~~~
a.cc:62:8: error: redeclaration of 'll pos'
   62 |     ll pos = 0;
      |        ^~~
a.cc:40:8: note: 'll pos' previously declared here
   40 |     ll pos = 0;
      |        ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

long long ans;
int l[100002], r[100002], n;

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> l[i] >> r[i];
  sort (l, l + n + 1, cmp);
  reverse(l, l + n + 1);
  sort (r, r + n + 1);
  for (int i = 0; i <= n; i++) {
    if (l[i] <= r[i]) break;
    ans += l[i] - r[i];
  }
  cout << ans * 2;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:23: error: 'cmp' was not declared in this scope; did you mean 'bcmp'?
   12 |   sort (l, l + n + 1, cmp);
      |                       ^~~
      |                       bcmp