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

#include<iostream>
#include<algorithm>

using namespace std;

int x[100'000];
int v[100'000];
bool eaten[100'000];

int distance(int nowX, targetX, int halfC){
	int distance = abs(targetX - nowX) % halfC;
	return distance;
}

int main(){
	int n, c;
	cin >> n >> c;
	int ans = 0;
	int halfC = c/2;

	for(int i = 0; i < n; ++i){
		cin >> x[i] >> v[i];
		eaten[i] = false;
	}

	// if(distance >= cal) eat
	int nowX = 0;
	int eatIndex, maxCal;
	bool shallContinue = true;

	while(shallContinue){
		shallContinue = false;
		eatIndex = maxCal = -1;
		for(int i = 0; i < n; ++i){
			if(eaten[i]) continue;
			int d = distance(nowX, x[i], halfC);
			int cal = v[i] - d;
			if(cal < 0) continue;
			if(cal > maxCal){
				eatIndex = i;
				maxCal = cal;
			}
		}
		if(eatIndex != -1){
			ans += maxCal;
			shallContinue = true;
			eaten[eatIndex] = true;
		}
	}

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

Compiler output:
a.cc:10:24: error: 'targetX' has not been declared
   10 | int distance(int nowX, targetX, int halfC){
      |                        ^~~~~~~
a.cc: In function 'int distance(int, int, int)':
a.cc:11:28: error: 'targetX' was not declared in this scope
   11 |         int distance = abs(targetX - nowX) % halfC;
      |                            ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const int N=2e5+5; 
ll n,C,x[N],v[N],pv[N],sv[N];
priority_queue<ii> q,q2;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>C;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>v[i],pv[i]=pv[i-1]+v[i];
	ll val=0;
	for(int i=n;i>=1;i--)
	{
		val+=v[i],sv[i]=val;
		q.push(ii(val-(C-x[i]),n-i+1));
	}
	ll res=0,p=1,mx=0;
	for(int i=0;i<=n;i++)
	{
		ll c1=2ll*x[i];
		if(i==0)
			c1=0;
		//case 1
		while(!q.empty()&&(q.top().second>n-i||C-x[n-q.top().second+1]<=x[i]))
			q.pop();
		if(!q.empty())
			res=max(res,pv[i]-c1+max(0ll,q.top().first));	
		//case 2
		while(p<=n-i&&C-x[n-p+1]<=x[i])
			q2.push(ii(sv[n-p+1]-2ll*(C-x[n-p+1]),p)),p++;
		while(!q2.empy()&&(q.top().second>n-i))
			q.pop();			
		if(!q2.empty())
			res=max(res,pv[i]-x[i]+max(0ll,q2.top().first));		
	//	cout<<i<<' '<<res<<'\n';
	}
	cout<<res<<'\n';
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:27: error: 'class std::priority_queue<std::pair<long long int, long long int> >' has no member named 'empy'; did you mean 'empty'?
   35 |                 while(!q2.empy()&&(q.top().second>n-i))
      |                           ^~~~
      |                           empty
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct sushi
{
  unsigned long long x, v;
};

int main()
{
  unsigned long long n, c;
  cin >> n >> c;
  
  vector<sushi> s(n);
  
  for(int i = 0; i < n; i++)
  {
    sushi tmp;
    cin >> tmp.x >> tmp.v;
    s.push_back(tmp);
  }
  
  sort(s.begin(), s.end(), [](sushi& a, sushi& b)->bool{return a.x<b.x;});
  unsigned long long l_nut=0, r_nut=0, lpos=0, rpos=c;
  int i;
  for(i = 0; i < n; i++)
  {
    if(s[i].x > c/2)
    {
      break;
    }
    l_nut -= s[i].x - lpos;
    l_nut += s[i].v;
    lpos = s[i].x;
  }
  
  for(int j = n - 1; j >= i; j--)
  {
    r_nut -= rpos - s[j].x;
    r_nut += s[j].v;
    rpos = s[j].x;
  }
  
  maxnut = l_nut - (rpos - lpos) + r_nut - (c-s[n-1].x);
  maxnut = maxnut < (l_nut + r_nut - lpos) ? l_nut + r_nut - lpos : maxnut;
  maxnut = maxnut < l_nut ? l_nut : maxnut;
  maxnut = maxnut < r_nut ? r_nut : maxnut;
  
    
  cout << maxnut << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:3: error: 'maxnut' was not declared in this scope
   46 |   maxnut = l_nut - (rpos - lpos) + r_nut - (c-s[n-1].x);
      |   ^~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct sushi
{
  unsigned long long x, v;
};

int main()
{
  unsigned long long n, c;
  cin >> n >> c;
  
  vector<sushi> s(n);
  
  for(int i = 0; i < n; i++)
  {
    sushi tmp;
    cin >> tmp.x >> tmp.v;
    s.push_back(tmp);
  }
  
  sort(s.begin(), s.end(), [](sushi& a, sushi& b)->bool{return a.x<b.x;});
  unsigned long long l_nut=0, r_nut=0, lpos=0, rpos=c;
  int i;
  for(i = 0; i < n; i++)
  {
    if(s[i].x > c/2)
    {
      break;
    }
    l_nut -= s[i].x - lpos;
    l_nut += s[i].v;
    lpos = s[i].x;
  }
  
  for(int j = n - 1; j >= i; j--)
  {
    r_nut -= rpos - s[j].x;
    r_nut += s[j].v;
    rpos = s[j].x;
  }
  
  maxnut = l_nut - (r_pos - l_pos) + r_nut - (c-s[n-1].x);
  maxnut = maxnut < (l_nut + r_nut - lpos) ? l_nut + r_nut - lpos : maxnut;
  maxnut = maxnut < l_nut ? l_nut : maxnut;
  maxnut = maxnut < r_nut ? r_nut : maxnut;
  
    
  cout << maxnut << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:3: error: 'maxnut' was not declared in this scope
   46 |   maxnut = l_nut - (r_pos - l_pos) + r_nut - (c-s[n-1].x);
      |   ^~~~~~
a.cc:46:21: error: 'r_pos' was not declared in this scope; did you mean 'rpos'?
   46 |   maxnut = l_nut - (r_pos - l_pos) + r_nut - (c-s[n-1].x);
      |                     ^~~~~
      |                     rpos
a.cc:46:29: error: 'l_pos' was not declared in this scope; did you mean 'lpos'?
   46 |   maxnut = l_nut - (r_pos - l_pos) + r_nut - (c-s[n-1].x);
      |                             ^~~~~
      |                             lpos
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct sushi
{
  unsigned long long x, v;
}

int main()
{
  unsigned long long n, c;
  cin >> n >> c;
  
  vector<sushi> s(n);
  
  for(int i = 0; i < n; i++)
  {
    sushi tmp;
    cin >> tmp.x >> tmp.v;
    s.push_back(tmp);
  }
  
  sort(s.begin(), s.end(), [](sushi& a, sushi& b)->bool{return a.x<b.x;})
  unsigned long long l_nut=0, r_nut=0, lpos=0, rpos=c;
  int i;
  for(i = 0; i < n; i++)
  {
    if(s[i].x > c/2)
    {
      break;
    }
    l_nut -= s[i].x - lpos;
    l_nut += s[i].v;
    lpos = s[i].x;
  }
  
  for(int j = n - 1; j >= i; j--)
  {
    r_nut -= rpos - s[j].x;
    r_nut += s[j].v;
    rpos = s[j].x;
  }
  
  maxnut = l_nut - (r_pos - l_pos) + r_nut - (c-s[n-1].x);
  maxnut = maxnut < (l_nut + r_nut - lpos) ? l_nut + r_nut - lpos : maxnut;
  maxnut = maxnut < l_nut ? l_nut : maxnut;
  maxnut = maxnut < r_nut ? r_nut : maxnut;
  
    
  cout << maxnut << endl;
}

Compiler output:
a.cc:9:2: error: expected ';' after struct definition
    9 | }
      |  ^
      |  ;
a.cc: In function 'int main()':
a.cc:25:74: error: expected ';' before 'unsigned'
   25 |   sort(s.begin(), s.end(), [](sushi& a, sushi& b)->bool{return a.x<b.x;})
      |                                                                          ^
      |                                                                          ;
   26 |   unsigned long long l_nut=0, r_nut=0, lpos=0, rpos=c;
      |   ~~~~~~~~                                                                
a.cc:34:5: error: 'l_nut' was not declared in this scope
   34 |     l_nut -= s[i].x - lpos;
      |     ^~~~~
a.cc:34:23: error: 'lpos' was not declared in this scope
   34 |     l_nut -= s[i].x - lpos;
      |                       ^~~~
a.cc:41:5: error: 'r_nut' was not declared in this scope
   41 |     r_nut -= rpos - s[j].x;
      |     ^~~~~
a.cc:41:14: error: 'rpos' was not declared in this scope
   41 |     r_nut -= rpos - s[j].x;
      |              ^~~~
a.cc:46:3: error: 'maxnut' was not declared in this scope
   46 |   maxnut = l_nut - (r_pos - l_pos) + r_nut - (c-s[n-1].x);
      |   ^~~~~~
a.cc:46:12: error: 'l_nut' was not declared in this scope
   46 |   maxnut = l_nut - (r_pos - l_pos) + r_nut - (c-s[n-1].x);
      |            ^~~~~
a.cc:46:21: error: 'r_pos' was not declared in this scope
   46 |   maxnut = l_nut - (r_pos - l_pos) + r_nut - (c-s[n-1].x);
      |                     ^~~~~
a.cc:46:29: error: 'l_pos' was not declared in this scope
   46 |   maxnut = l_nut - (r_pos - l_pos) + r_nut - (c-s[n-1].x);
      |                             ^~~~~
a.cc:46:38: error: 'r_nut' was not declared in this scope
   46 |   maxnut = l_nut - (r_pos - l_pos) + r_nut - (c-s[n-1].x);
      |                                      ^~~~~
a.cc:47:38: error: 'lpos' was not declared in this scope
   47 |   maxnut = maxnut < (l_nut + r_nut - lpos) ? l_nut + r_nut - lpos : maxnut;
      |                                      ^~~~
Language: C++

#include<cstdio>  
#include<cmath>  
#include<iostream>  
#include<cstring>  
#include<iostream>  
#include<cstdlib>  
#include<string>  
using namespace std;  
#define LL long long   
const int MaxN = 1e5 + 7;  
LL a[MaxN], b[MaxN];    
LL x[MaxN], v[MaxN];  
  
int main()  
{  
    LL n, c;  
    scanf("%lld %lld", &n, &c);  
    for(int i = 1; i <= n; i++)   
        scanf("%lld %lld", &x[i], &v[i]);  
      
    for(LL i = 1; i <= n; i++)   
        a[i] = a[i - 1] + v[i] - (x[i] - x[i - 1]);  // 顺时针走到i点时的能量  
    x[n + 1] = c;  
    for(LL i = n; i >= 1; i--)   
        b[i] = b[i + 1] + v[i] - (x[i+1] - x[i]);  // 逆时针走到i点时的能量  
  
    for(LL i = 2; i <= n; i++)   
        a[i] = max(a[i-1], a[i]);  //走或者不走（和走之前的值进行比较）  
    for(LL i = n-1; i >= 1; i--)   
        b[i] = max(b[i], b[i + 1]);  
  
    LL ans = max(0,max(a[n],b[1]));  
    for(LL i = 1; i <= n; i++) {  
        ans = max(ans, a[i] - x[i] + b[i + 1]);  // 顺时针走后并返回一次的值  
        ans = max(ans, b[i] - (c - x[i]) + a[i - 1]);  // 逆时针走后返回一次的值  
        //ans = max(ans, a[i]);  // 顺时针的最大值  
        //ans = max(ans, b[i]); //逆时针的最大值  
    }  
  
    printf("%lld\n", ans);  
}  

Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: no matching function for call to 'max(int, const long long int&)'
   32 |     LL ans = max(0,max(a[n],b[1]));
      |              ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:2:
/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:32:17: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   32 |     LL ans = max(0,max(a[n],b[1]));
      |              ~~~^~~~~~~~~~~~~~~~~~
/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
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath> 
using namespace std;
const int maxn=1e5+5;
//int a[maxn];
long long dp[2][maxn];
long long cp[2][maxn];  
long long x[maxn], v[maxn];
int main()
{
	long long n,c,sum,ans;
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++) 
	scanf("%lld%lld",&x[i],&v[i]); 
	for (int i=0;i<=n+1;i++)
	dp[0][i]=dp[1][i]=-0x3f3f3f3f;
	for(int i=1;i<=n;i++) 
	{ 
        sum+=v[i];    
        dp[0][i]=max(dp[0][i-1],sum-x[i]);  
        cp[0][i]=sum-2*x[i];  
    }  
    sum=0;  
    for(int i=n;i>=1;i--) 
	{ 
        sum+=v[i];  
        dp[1][i]=max(dp[1][i+1],sum-(c-x[i]));  
        cp[1][i]=sum-2*(c-x[i]);  
    }  
    long long ans=max(dp[0][n],dp[1][1]);  
    for(int i=1;i<=n;i++) 
	{  
        ans=max(ans,cp[0][i]+dp[1][i + 1]);  
        ans=max(ans,cp[1][i]+dp[0][i - 1]);  
    }  
    printf("%lld\n", ans > 0 ? ans : 0);   
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:31:15: error: redeclaration of 'long long int ans'
   31 |     long long ans=max(dp[0][n],dp[1][1]);
      |               ^~~
a.cc:12:27: note: 'long long int ans' previously declared here
   12 |         long long n,c,sum,ans;
      |                           ^~~
Language: C++

15 10000000000
400000000 1000000000
800000000 1000000000
1900000000 1000000000
2400000000 1000000000
2900000000 1000000000
3300000000 1000000000
3700000000 1000000000
3800000000 1000000000
4000000000 1000000000
4100000000 1000000000
5200000000 1000000000
6600000000 1000000000
8000000000 1000000000
9300000000 1000000000
9700000000 1000000000

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 15 10000000000
      | ^~
Language: C++

#include<iostream>
using namespace std;

int main(){
    unsigned long int N,C;
    //max1 = 0,max2=0,max3=0,max4=0,res1=0,res2=0,res3=0,res4=0;
    long int maxr=-1,maxl=-1,maxl1[N+1],maxr1[N+1];
    cin >> N >> C;
    unsigned long int x[N+2],v[N],sumr[N+1],suml[N+1];
    //3=N 20=C
    x[0]=0;
    x[N+1]=C;
    for (int i =0; i < N; i++){
        cin >>x[i+1]>>v[i];
    } 
    //sum of right rotation
    sumr[0] = 0;
    for(int i = 1;i<=N;i++){
        sumr[i]=sumr[i-1]+v[i-1];
    }
    
    //sum of left rotation
    suml[0] = 0;
     for(int i = 1;i<=N;i++){
        suml[i]=suml[i-1]+v[N-i];
    }   
 
    maxl1[0]=0;
    for(int J = 1;J<=N;J++){
       //long int maxl0 = suml[J] - C + x[N+1-J]; 
        maxl1[J] = max(maxl1[J-1],(long int)suml[J] - C + x[N+1-J]);
    }
    
/*
    for(int I= 0;I<=N;I++){
        //J=0
        long int res=sumr[I]+suml[0];
        res -= x[I];
        if(maxr<res) maxr =res;
        res = sumr[I]-x[I]*2;
        res += maxl1[N-I];
        if(maxr<res)             maxr =res;
//        cout << "maxr: "<< res <<endl;
        
    }
    
    maxr1[0]=0;
    for(int I = 1;I<=N;I++){
       //
        long int maxr0 = sumr[I] - x[I]; 
        maxr1[I] = max(maxr1[I-1],maxr0);
    }
    

    for(int J = 0;J<=N;J++){
        //I=0
        long int res=sumr[J]+suml[0];
        res -= C - x[N+1-J];
        if(maxl<res) maxl = res;
        res = suml[J]-2*C+2*x[N+1-J];
        res += maxr1[N-J];
        if(maxl<res) maxl =res;
//        cout << "maxl: " << res << endl;
    }
 
    cout << max(maxr,maxl) << endl;
*/
    cout << "0" << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:23: error: no matching function for call to 'max(long int&, long unsigned int)'
   31 |         maxl1[J] = max(maxl1[J-1],(long int)suml[J] - C + x[N+1-J]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:31:23: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long unsigned int')
   31 |         maxl1[J] = max(maxl1[J-1],(long int)suml[J] - C + x[N+1-J]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>

using namespace std;
const int INF = (1<<30);
typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair



//出力チェック用
int qqq;

ll x[100001],v[100001];

int main() 
{
	ll n, c;
	cin >> n >> c;
	rep(i, n) cin >> x[i] >> v[i];
	ll a = 0, b = 0,d=0,e=0;

	ll vc[100001] = { 0 }, vac[100001] = { 0 };
	
	//PatternA
	ll walk = 0;
	ll aMax＝0;
	rep(i, n) {
		walk += x[i];
		a += v[i] - (x[i]-walk);
		aMax= max(aMax, a);
	}
	cout << max(a, b) << endl;
	cin >> qqq;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:17: error: 'aMax' was not declared in this scope
   52 |                 aMax= max(aMax, a);
      |                 ^~~~
Language: C++

#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long long n, c;
    cin>>n>>c;
    vector<pair<long long, long long> > ss;
    for(int i=0; i<n; i++){
        long long x,v;
        cin>>x>>v;
        ss.push_back(make_pair(x, v));
    }
    sort(ss.begin(), ss.end());
    long long mmru[100000], mmri[100000];
    for(int i=0; i<100000; i++) mmru[i]=mmri[i]=0;
    long long tv=0;
    long long mxri=0, mxru=0;
    for(int i=0; i<ss.size(); i++){
        tv+=ss[i].second;
        long long x=ss[i].first;
        mxri=max(mxri, tv-x);
        mxru=max(mxru, tv-x*2);
        mmru[i]=mxru;
        mmri[i]=mxri;
    }
    long long mx=0;
    tv=0;
    long long mxli=0, mxlu=0;
    mx=mxri;
    for(int i=ss.size()-1; i>=0; i--){
        tv+=ss[i].second;
        long long x=c-ss[i].first;
        mxli=max(mxli, tv-x);
        mxlu=max(mxlu, tv-x*2);
        long long ru;
        if(i>=1) ru=mmru[i-1];
        else ru=0;
        mx=max(mx, mxli+ru);
        long long ri;
        if(i>=1) ri=mmri[i-1];
        else ri=0;
        mx=max(mx, mxlu+ri);
    }
    cout<<mx<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin>>n>>c;
      |     ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <algorithm>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:45:5: error: 'cout' was not declared in this scope
   45 |     cout<<mx<<endl;
      |     ^~~~
a.cc:45:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:45:15: error: 'endl' was not declared in this scope
   45 |     cout<<mx<<endl;
      |               ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <algorithm>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

typedef long long ll;

const int MAX_N=1e5;
const ll INF=1e18;

int N;
ll C;
ll X[MAX_N+2],V[MAX_N+2];
ll vsum[MAX_N+2];

int main(){
	cin>>N>>C;
	vsum[0]=0;
	X[0]=0;
	V[0]=0;
	REP(i,N){
		cin>>X[i+1]>>V[i+1];
		vsum[i+1]=vsum[i]+V[i+1];
	}
	ll ans=-INF;
	int mx1,mx2;
	mx1=0;
	mx2=0;
	int y=0;
	REP(i,N){
		y++;
		ll ans2;
		if (vsum[mx1]-X[mx1]<vsum[i]-X[i]){
			mx1=i;
		}
		if (vsum[mx2]-2*X[mx2]<vsum[i]-2*X[i]){
			mx2=i;
		}
		if (X[mx1]>=C-X[y]){
			ans2=vsum[mx1]+(vsum[N]-vsum[y-1])-X[mx1]-(C-X[y])-min<ll>(X[mx1],C-X[y]);
		}else{
			ans2=vsum[mx2]+(vsum[N]-vsum[y-1])-X[mx2]-(C-X[y])-min<ll>(X[mx2],C-X[y]);
		}
		ans=max<ll>(ans,ans2);
	}
	if (vsum[mx1]-X[mx1]<vsum[N]-X[N]){
		mx1=N;
	}
	ans=max<ll>(ans,vsum[mx1]-X[mx1]);
	mx1=0;
	mx2=0;
	int y=0;
	REP(i,N){
		y++;
		ll ans2;
		if (vsum[mx1]-X[mx1]<=vsum[i]-X[i]){
			mx1=i;
		}
		if (vsum[mx2]-2*X[mx2]<=vsum[i]-2*X[i]){
			mx2=i;
		}
		if (X[mx1]>=C-X[y]){
			ans2=vsum[mx1]+(vsum[N]-vsum[y-1])-X[mx1]-(C-X[y])-min<ll>(X[mx1],C-X[y]);
		}else{
			ans2=vsum[mx2]+(vsum[N]-vsum[y-1])-X[mx2]-(C-X[y])-min<ll>(X[mx2],C-X[y]);
		}
		ans=max<ll>(ans,ans2);
	}
	if (vsum[mx1]-X[mx1]<vsum[N]-X[N]){
		mx1=N;
	}
	ans=max<ll>(ans,vsum[mx1]-X[mx1]);
	cout<<ans<<endl;
	return 0;
}

/*
int main(){
	cin>>N>>C;
	vsum[0]=0;
	X[0]=0;
	V[0]=0;
	REP(i,N){
		cin>>X[i+1]>>V[i+1];
		vsum[i+1]=vsum[i]+V[i+1];
	}
	X[N+1]=C;
	V[N+1]=0;
	vsum[N+1]=vsum[N];
	ll ans=0;
	REP(i,N+1){
		FOR(j,i+1,N+2){
			ans=max(ans,vsum[i]+(vsum[N]-vsum[j-1])-X[i]-(C-X[j])-min(X[i],C-X[j]));
		}
	}
	cout<<ans<<endl;
	return 0;
}
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:54:13: error: redeclaration of 'int y'
   54 |         int y=0;
      |             ^
a.cc:31:13: note: 'int y' previously declared here
   31 |         int y=0;
      |             ^
Language: C++

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll f[N][N][2],x[N*2];
int main()
{
    ll n,c,i,j,k,v[N];
    cin>>n>>c;
    for(i=1;i<=n;i++){
        scanf("%lld%lld",&x[n+1+i],&v[i]);
    }
    ll l=c-x[n+2];
    for(i=2;i<=n;i++){
        x[i]=x[n+1+i]-x[n+1+i-1];v[i]=v[n+1+i];
    }
    x[n+1]=c-x[n+2];v[1]=v[n+2];v[n+1]=0;
    for(i=1;i<=n;i++)
        x[n+1+i]+=x[n+1];
    for(j=n+1;j<=2*n+1;j++)
        for(i=j-1;i>=j-n;i--){
        f[i][j][0]=max(f[i][j][0],f[i+1][j][0]+v[i]-(x[i+1]-x[i]));
        f[i][j][0]=max(f[i][j][0],f[i+1][j][1]+v[i]-(x[j]-x[i]));
        f[i][j][1]=max(f[i][j][1],f[i][j-1][0]+v[j]-(x[j]-x[i]));
        f[i][j][1]=max(f[i][j][1],f[i][j-1][1]+v[j]-(x[j]-x[j-1]));
    }
    ll ans=0;
    for(i=1;i<=n+1;i++){
        ans=max(ans,f[i][i+n][0]);
        ans=max(ans,f[i][i+n][1]);
    }
    cout<<ans<<endl;

    return 0;
}

Compiler output:
/tmp/cch4CcHK.o: in function `main':
a.cc:(.text+0x69): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cch4CcHK.o
a.cc:(.text+0xad): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cch4CcHK.o
a.cc:(.text+0xe3): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cch4CcHK.o
a.cc:(.text+0x109): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cch4CcHK.o
a.cc:(.text+0x126): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cch4CcHK.o
a.cc:(.text+0x17b): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cch4CcHK.o
a.cc:(.text+0x19c): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cch4CcHK.o
a.cc:(.text+0x1f3): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cch4CcHK.o
a.cc:(.text+0x20e): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cch4CcHK.o
a.cc:(.text+0x234): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cch4CcHK.o
a.cc:(.text+0x2b8): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

int main(){
  long long int N, C;
  cin >> N >> C;
  vector< pair<long long int, long long int> > V;
  long long int x, v;
  for(int i = 0; i < N; ++i){
    cin >> x >> v;
    V.emplace_back(x, v);
  }
  long long int ans = 0, t = 0;
  //右回り
  vector<long long int> R(N), L(N);
  for(int i = 0; i < N; ++i){
    t += V[i].second - V[i].first;
    if(i > 0) t += V[i-1].first;
    ans = max(ans, t);
    R[i] = ans;
  }
  t = 0, ans = 0;
  for(int i = N-1; i >= 0; --i){
    t += V[i].second + V[i].first - C;
    if(i < N-1) t += C - V[i+1].first;
    ans = max(ans, t);
    L[i] = ans;
  }
  t = 0;
  for(int i = 0; i < N-1; ++i){
    t += V[i].second;
    ans = max(ans, t - 2*V[i].first + L[i+1]);
  }
  t = 0;
  for(int i = N-1; i > 0; --i){
    t += V[i].second;
    ans = max(ans, t + 2*(V[i].first - C) + R[i-1]);
  }
  ans = max({ans, R[N-1], L[0]});
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:12: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   40 |   ans = max({ans, R[N-1], L[0]});
      |         ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
Language: C

//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<ctime>
#include<cctype>
#include<queue>
#include<deque>
#include<stack>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 10000000000000000ll
#define inf 1000000000
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define rep(p,n,i) for(RE int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE int i=n;i>=p;--i)
#define vep(p,n,i) for(RE int i=p;i<n;++i)
#define pii pair<int,int>
#define mk make_pair
#define RE register
#define P 1000000007ll
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define EPS 1e-4
#define sq sqrt
#define S second
#define F first
using namespace std;
char *fs,*ft,buf[1<<15];
inline char gc()
{
	return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
	RE int x=0,f=1;RE char ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
	return x*f;

}
const int MAXN=3010;
int n,mod;
int fac[MAXN],inv[MAXN];
int s[MAXN][MAXN];
inline int ksm(int b,int p,int M)
{
	int cnt=1;
	while(p)
	{
		if(p&1)cnt=(ll)cnt*b%M;
		b=(ll)b*b%M;p=p>>1;
	}
	return cnt;
}
inline int C(int a,int b){return (ll)fac[a]*inv[b]%mod*inv[a-b]%mod;}
int main()
{
	//freopen("1.in","r",stdin);
	get(n);get(mod);
	fac[0]=1;
	rep(1,n,i)fac[i]=fac[i-1]*(ll)i%mod;
	inv[n]=ksm(fac[n],mod-2,mod);
	fep(n-1,0,i)inv[i]=(ll)inv[i+1]*(i+1)%mod;
	s[0][0]=1;
	rep(1,n+1,i)rep(1,i,j)s[i][j]=(s[i-1][j-1]+(ll)s[i-1][j]*j)%mod;
	int op=-1,ans=0;
	rep(0,n,i)
	{
		op=-op;
		int cnt=ksm(2,n-i,mod-1);
		cnt=ksm(2,cnt,mod)*(ll)C(n,i)%mod;
		int sum=0;
		int c1=ksm(2,n-i,mod),c2=1;
		rep(0,i,k)
		{
			sum=(sum+(ll)c2*s[i+1][k+1])%mod;
			c2=(ll)c1*c2%mod;
		}
		ans=(ans+op*(ll)cnt*sum)%mod;
	}
	put((ans+mod)%mod);
	return 0;
}


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

/*---Author:HenryHuang---*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e3+5;
typedef long long int;
int n,p;
int ksm(int a,int b,int p){
	int ans=1;
	while(b){
		if(b&1) ans=ans*a%p;
		b>>=1,a=a*a%p;
	}
	return ans;
}
int C[maxn][maxn],S[maxn][maxn];
void init(){
	C[0][0]=S[0][0]=1;
	for(int i=1;i<=n+1;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j){
			S[i][j]=(S[i-1][j-1]+1ll*j*S[i-1][j]%p)%p;
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%p;
		}
	}
}
int a[32769],b[32769];
int c[32769],d[32769];
int p1(int x){
	return 1ll*a[x&0x00007fff]*b[x>>15]%p;
}
int p2(int x){
	return 1ll*c[x&0x00007fff]*d[x>>15]%(p-1);
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>p;init();
	a[0]=1;
	for(int i=1;i<=32768;++i){
		a[i]=1ll*a[i-1]*2%p;
	}
	b[0]=1,b[1]=a[32768];
	for(int i=2;i<=32768;++i){
		b[i]=1ll*b[i-1]*b[1]%p;
	}
	c[0]=1;
	for(int i=1;i<=32768;++i){
		c[i]=1ll*c[i-1]*2%(p-1);
	}
	d[0]=1,d[1]=c[32768];
	for(int i=2;i<=32768;++i){
		d[i]=1ll*d[i-1]*d[1]%(p-1);
	}
	int ans=0;
	for(int i=0;i<=n;++i){
		int tmp=1ll*p1(p2(n-i))*C[n][i]%p,owo=0;
		if(i&1) tmp=p-tmp;
		for(int j=0;j<=i;++j){
			owo=(owo+1ll*S[i+1][j+1]*p1(1ll*(n-i)*j%(p-1))%p)%p;
		}
		(ans+=1ll*tmp*owo)%=p;
	}
	cout<<ans<<'\n';
	return 0;
}


Compiler output:
a.cc:5:19: error: declaration does not declare anything [-fpermissive]
    5 | typedef long long int;
      |                   ^~~
Language: C++

#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=3e3+2;
ll mod,g[N][N],C[N][N],f[N];

ll modpow(ll x,ll y,ll p,ll res=1) {
    for(;y;y>>=1,x=x*x%p) if(y&1) res=res*x%p;
    return res;
}

int main() {
    int n;scanf("%d%lld",&n,&mod);
    for(int i=0;i<=n;++i) {
        C[i][0]=g[i][0]=1;
        for(int j=1;j<=i;++j) 
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod,
            g[i][j]=(g[i-1][j-1]+1ll*(j+1)*g[i-1][j]%mod)%mod;
    }
    ll ans=0;
    for(int i=0;i<=n;++i) {
        ll k=C[n][i];
        if(i&1) k=mod-k;
        ll x=pow(2,n-i,mod-1);x=pow(2,x,mod);
        ll num=pow(2,n-i,mod),y=1,res=0;
        for(int j=0;j<=i;++j)
            res=(res+1ll*g[i][j]*y%mod)%mod,y=num*y%mod;
        ans=(ans+k*res%mod*x%mod)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:14: error: 'pow' was not declared in this scope
   29 |         ll x=pow(2,n-i,mod-1);x=pow(2,x,mod);
      |              ^~~
a.cc:32:13: error: 'res' was not declared in this scope
   32 |             res=(res+1ll*g[i][j]*y%mod)%mod,y=num*y%mod;
      |             ^~~
a.cc:32:34: error: 'y' was not declared in this scope
   32 |             res=(res+1ll*g[i][j]*y%mod)%mod,y=num*y%mod;
      |                                  ^
a.cc:33:20: error: 'res' was not declared in this scope
   33 |         ans=(ans+k*res%mod*x%mod)%mod;
      |                    ^~~
Language: C++

#include <iostream>
#include <cmath>

#define ll long long
#define MAX 3010
#define y 9000010
using namespace std;
ll m,mod,dp[3010][3010],f[3010]={0},bek1[y] = {0},bek[y]={0},cnk[3010][3010];
ll beki(ll x, ll a){
	if(a<y && bek[a]!=0){
		return bek[a];
	}
	if(a==0){
		bek[a] = 1;
		return 1;
	}else if(a%2==0){
		if(a<y){
			bek[a] = beki(x,a/2)*beki(x,a/2)%mod;
		}
		return beki(x,a/2)*beki(x,a/2)%mod;
	}else{
		if(a<y){
			bek[a] = beki(x,a/2)*beki(x,a/2)%mod*x%mod;
		}
		return beki(x,a/2)*beki(x,a/2)%mod*x%mod;
	}
}

ll beki1(ll x, ll a){
	if(bek1[a]!=0){
		return bek1[a];
	}
	if(a==0){
		bek1[a] = 1;
	}else if(a%2==0){
		bek1[a] = beki1(x,a/2)*beki1(x,a/2)%m;
	}else{
		bek1[a] = beki1(x,a/2)*beki1(x,a/2)%m*x%m;
	}
	return bek1[a];
}

ll pw(ll a, ll b) {
	ll ans = 1; 
	while (b) {
		while (b%2==0){
			b /= 2;
			a = (a * a) % mod;
		}
		ans = (ans * a) % mod;
		--b;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll i,j,n;
	cin >> n >> mod;
	m = mod - 1;
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			dp[i][j] = 0;
		}
	}
	
	dp[0][0] = 1;
	for(i=1;i<=n;i++){
		for(j=0;j<=i;j++){
			if(j==0){
				dp[i][j] = 1;
			}else{
				dp[i][j] = (dp[i-1][j-1] + (j+1)*dp[i-1][j]%mod)%mod;
			}
		}
	}
	
	for(i=0;i<=n;i++){
		mod -= 1;
		ll x = pw(2,(n-i));
		mod += 1;
		ll y = pw(2,x);
		ll z = pw(2,(n-i));
		for(j=0;j<=i;j++){
			f[i] += y*pw(z,j)%mod*dp[i][j]%mod;
			f[i] = f[i]%mod;
		}
	}

	for (int i = 0; i <= n; ++i){
		for (int j = 0; j <= n; ++j) {
			if (i == j || j == 0)
				cnk[i][j] = 1;
			else if (j > i)
				cnk[i][j] = 0;
			else
				cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % mod;
		}
	}
	
	ll ans = 0;
	for(i=0;i<=n;i++){
		ll k = cnk[n][i]*f[i]%mod;
		ans += pow(-1,i)*k;
		ans = (ans+mod)%mod;
	}
	
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:11: error: expected unqualified-id before numeric constant
    6 | #define y 9000010
      |           ^~~~~~~
a.cc:82:20: note: in expansion of macro 'y'
   82 |                 ll y = pw(2,x);
      |                    ^
Language: C++

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

typedef long long ll;

int N;
ll mod;
ll dp[2][3010];
ll P[10000000] = {1};
ll F[3010] = {1},R[3010],D[10000000] = {2};
ll ans = 0;

ll pow_mod(ll a,ll b)
{
    if(b == 0)return 1;
    ll res = pow_mod(a * a % mod,b / 2);
    if(b & 1)res = res * a % mod;
    return res;
}

ll con(int a,int b)
{
    return F[a] * R[b] % mod * R[a - b] % mod;
}

int main()
{
    scanf("%d%lld",&N,&mod);

    for(int i = 1; i < 3010; i++)F[i] = F[i - 1] * i % mod;
    for(int i = 1; i < 10000000; i++)P[i] = P[i - 1] * 2 % mod;
    for(int i = 1; i < 10000000; i++)D[i] = D[i - 1] * D[i - 1] % mod;
    for(int i = 0; i < 3010; i++)R[i] = pow_mod(F[i],mod - 2);
    dp[0][0] = 1;
    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= N; j++)
        {
            //if(dp[i][j] == 0)continue;
            dp[1][j] += dp[0][j];
            dp[1][j] += dp[0][j] * j;
            dp[1][j + 1] += dp[0][j];
            dp[1][j] %= mod;
            dp[1][j + 1] %= mod;
            ll tmp = ((dp[0][j] * P[(N - i) * j] % mod * D[N - i] % mod * con(N,i) % mod)) % mod;
            if(i % 2)ans -= tmp;
            else ans += tmp;
            ans = (ans + mod) % mod;
        }
        for(int j = 0; j <= N; j++)
        {
            dp[0][j] = dp[1][j];
            dp[1][j] = 0;
        }
    }

    printf("%lld\n",ans);
    return 0;
}


Compiler output:
/tmp/cc7ktcmV.s: Assembler messages:
/tmp/cc7ktcmV.s: Fatal error: can't fill 256 bytes in section .data of /tmp/ccsm0CSW.o: 'No space left on device'
Language: C++

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

typedef long long ll;

int N;
ll mod;
ll dp[3010][3010];
ll P[10000000] = {1};
ll F[3010] = {1},R[3010],D[10000000] = {2};
ll ans = 0;

ll pow_mod(ll a,ll b)
{
    if(b == 0)return 1;
    ll res = pow_mod(a * a % mod,b / 2);
    if(b & 1)res = res * a % mod;
    return res;
}

ll con(int a,int b)
{
    return F[a] * R[b] % mod * R[a - b] % mod;
}

int main()
{
    scanf("%d%lld",&N,&mod);

    for(int i = 1; i < 3010; i++)F[i] = F[i - 1] * i % mod;
    for(int i = 1; i < 10000000; i++)P[i] = P[i - 1] * 2 % mod;
    for(int i = 1; i < 10000000; i++)D[i] = D[i - 1] * D[i - 1] % mod;
    for(int i = 0; i < 3010; i++)R[i] = pow_mod(F[i],mod - 2);
    dp[0][0] = 1;
    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= N; j++)
        {
            //if(dp[i][j] == 0)continue;
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] += dp[i][j] * j;
            dp[i + 1][j + 1] += dp[i][j];
            dp[i + 1][j] %= mod;
            dp[i + 1][j + 1] %= mod;
            ll tmp = ((dp[i][j] * P[(N - i) * j] % mod * D[N - i] % mod * con(N,i) % mod)) % mod;
            if(i % 2)ans -= tmp;
            else ans += tmp;
            ans = (ans + mod) % mod;
        }
    }

    printf("%lld\n",ans);
    return 0;
}


Compiler output:
/tmp/ccPyWzHa.s: Assembler messages:
/tmp/ccPyWzHa.s: Fatal error: can't fill 256 bytes in section .data of /tmp/cc1RpSEs.o: 'No space left on device'
/tmp/ccPyWzHa.s: Fatal error: /tmp/cc1RpSEs.o: No such file or directory
Language: C++

#include <bits/stdc++.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 3e3 + 5;
int comb[MAX][MAX], memo[MAX][MAX];

inline int add(int a, int b, int mod) {
	a += b;
	if(a >= mod) {
		a -= mod;
	}
	return a;
}

inline int sub(int a, int b, int mod) {
	a -= b;
	if(0 > a) {
		a += mod;
	}
	return a;
}

inline int mult(int a, int b, int mod) {
	return (1LL * a * b) % mod;
}

inline int f_exp(int x, int exp, int mod) {
	if(exp == 0) {
		return 1;
	}
	else if(exp & 1) {
		return mult(x, f_exp(x, exp - 1, mod), mod);
	}
	return f_exp(mult(x, x, mod), exp / 2, mod);
}

inline int phi(int x) {
	return x - 1;
}

int S(int n, int k, const int &mod) {
	if(k > n) {
		return 0;
	}
	else if(n == 0 && k == 0) {
		return 1;
	}
	else if(k == 0) {
		return 0;
	}

	int &ans = memo[n][k];
	if(~ans) {
		return ans;
	}

	ans = add(mult(k, S(n - 1, k, mod), mod), S(n - 1, k - 1, mod), mod);
	return ans;
}

inline int kernel(int n, int k, int mod) {
	return add(mult(k + 1, S(n, k + 1, mod), mod), S(n, k, mod), mod);
}

int n;
int ways(int x, int mod) {
	int total = 1;
	fori(i, 1, x + 1) {
		int cur = mult(kernel(x, i, mod), f_exp(2, (n - x) * i, mod), mod);

		total = add(total, cur, mod);
	}

	total = mult(total, f_exp(2, f_exp(2, n - x, phi(mod)), mod), mod);

	return total;
}

int main() {
	memset(memo, -1, sizeof memo);

	int mod;
	scanf("%d %d", &n, &mod);

	fori(i, 0, MAX) {
		fori(j, 0, i + 1) {
			if(i == j || j == 0) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = add(comb[i - 1][j], comb[i - 1][j - 1], mod);
			}
			S(i, j);
		}
	}

	int ans = 0;

	fori(i, 0, n + 1) {
		int cur = mult(comb[n][i], ways(i, mod), mod);

		if(i % 2 == 0) {
			ans = add(ans, cur, mod);
		}
		else {
			ans = sub(ans, cur, mod);
		}
	}

	printf("%d\n", ans);

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:102:26: error: too few arguments to function 'int S(int, int, const int&)'
  102 |                         S(i, j);
      |                         ~^~~~~~
a.cc:50:5: note: declared here
   50 | int S(int n, int k, const int &mod) {
      |     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=55;
int n,x,d,fa[N],c[n*m];
struct node
{
	int v,id;
	long long w;
	bool operator<(const node k)
	{
		return v*k.w>w*k.v;
	}
}a[N];
long long dp[n*m],ans;
int main()
{
	ios::sync_with_stdio();
	cin>>n>>x>>d;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].w;
		if(i>1)
			cin>>fa[i];
		a[i].id=i;
		a[i].v=1;
	}
	for(int i=n;i>=1;i--)
	{
		a[fa[i]].w+=a[i].w;
		a[fa[i]].v+=a[i].v;
	}
	sort(a+1,a+n+1);
	int m=min(n,d);
	for(int j=1;j<=n*m;j++)
		dp[j]=9e18;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=n*m;j++)
			c[j]=0;
		for(int j=0;j<=n*m;j++)
		{
			if(j+a[i].v>n*m)
				continue;
			if(c[j]==m)
				continue;
			if(dp[j+a[i].v]>dp[j]+a[i].w)
			{
				dp[j+a[i].v]=dp[j]+a[i].w;
				c[j+a[i].v]=c[j]+1;
			}
			else if(dp[j+a[i].v]==dp[j]+a[i].w&&c[j+a[i].v]>c[j]+1)
				c[j+a[i].v]=c[j]+1;
		}
	}
	for(int i=0;i<=n*m;i++)
	{
		long long w=dp[i],v=i;
		for(int j=1;j<=n;j++)
		{
			if(a[j].id==1)
			{
				long long zh=(x-w)/a[j].w;
				w+=zh*a[j].w,v+=zh*a[j].v;
			}
			long long zh=min((long long)d-m,(x-w)/a[j].w);
			w+=zh*a[j].w,v+=zh*a[j].v;
		}
		ans=max(ans,v);
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc:4:21: error: 'm' was not declared in this scope
    4 | int n,x,d,fa[N],c[n*m];
      |                     ^
a.cc:14:16: error: 'm' was not declared in this scope
   14 | long long dp[n*m],ans;
      |                ^
a.cc: In function 'int main()':
a.cc:35:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   35 |                 dp[j]=9e18;
      |                 ^~
      |                 dup
a.cc:39:25: error: 'c' was not declared in this scope
   39 |                         c[j]=0;
      |                         ^
a.cc:44:28: error: 'c' was not declared in this scope
   44 |                         if(c[j]==m)
      |                            ^
a.cc:46:28: error: 'dp' was not declared in this scope; did you mean 'dup'?
   46 |                         if(dp[j+a[i].v]>dp[j]+a[i].w)
      |                            ^~
      |                            dup
a.cc:49:33: error: 'c' was not declared in this scope
   49 |                                 c[j+a[i].v]=c[j]+1;
      |                                 ^
a.cc:51:61: error: 'c' was not declared in this scope
   51 |                         else if(dp[j+a[i].v]==dp[j]+a[i].w&&c[j+a[i].v]>c[j]+1)
      |                                                             ^
a.cc:57:29: error: 'dp' was not declared in this scope; did you mean 'dup'?
   57 |                 long long w=dp[i],v=i;
      |                             ^~
      |                             dup
a.cc:63:46: error: 'v' was not declared in this scope
   63 |                                 w+=zh*a[j].w,v+=zh*a[j].v;
      |                                              ^
a.cc:66:38: error: 'v' was not declared in this scope
   66 |                         w+=zh*a[j].w,v+=zh*a[j].v;
      |                                      ^
a.cc:68:29: error: 'v' was not declared in this scope
   68 |                 ans=max(ans,v);
      |                             ^
Language: C

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll inf=1E16;
ll ans,n,have,d,m[55],sum[55],sumW[55];
ll f[55*55];
int fa[55];
inline void chmin(ll&x,ll y)
{
	x=min(x,y);
}
struct pt
{
	ll v,w,id;
	bool operator<(const pt&A)const
	{
		return v*A.w>A.v*w;
	}
}a[55];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>have>>d>>m[1];
	++sum[1],sumW[1]+=m[1];
	for(int i=2;i<=n;++i)
	{
		cin>>m[i]>>fa[i];
		for(int j=i;j;j=fa[j])
			++sum[j],sumW[j]+=m[i];
	}
	for(int i=1;i<=n;++i)
		a[i]=(pt){sum[i],sumW[i],i};
	sort(a+1,a+n+1);
	for(int i=1;i<=n*n;++i)
		f[i]=inf;
	int l=min(d,n);
	for(int i=1;i<=n;++i)
	{
		ll v=a[i].v,w=a[i].w;
		for(int j=1;j<=l;++j)
			for(int k=n*n;k>=v;--k)
				chmin(f[k],f[k-v]+w);
	}
	for(int j=0;j<=n*n;++j)
	{
		if(f[j]>have)
			continue;
		ll left=have-f[j],now=j;
		for(int i=1;i<=n;++i)
		{
			ll g=left/a[i].w;
			if(a[i].id!=1)
				g=min(g,d-l);
			left-=g*a[i].w,now+=g*a[i].v;
		}
		ans=max(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}



Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int n,t,z,d,tot,head[55000];
long long ans,f[1000010];
struct point{
	int v,w,num;
	friend bool operator <(point a,point b){
		return a.w*b.v>b.w*a.v;
	}
}a[55000];
struct node{
	int fr,to,nxt;	
}e[55000];
void add(int x,int y)
{
	e[++tot].fr=x;
	e[tot].to=y; e[tot].nxt=head[x];
	head[x]=tot;
}
void dfs(int x)
{
	a[x].w=1; 
	for(int i=head[x];i;i=e[i].nxt)
		dfs(e[i].to),a[x].v+=a[e[i].to].v,a[x].w+=a[e[i].to].w;
}
int main()
{
	scanf("%lld%lld%lld",&n,&t,&d);
	scanf("%lld",&a[1].v); a[1].num=1;
	for(int i=2,x;i<=n;i++)
		scanf("%lld%lld",&a[i].v,&x),a[i].num=i,add(x,i);
	dfs(1);
	memset(f,0x3f,sizeof(f)); f[0]=0;
	for(int i=1;i<=n;i++)
	{
		int tmp=min(d,n);
		for(int j=0;(1<<j)<=tmp;j++) {
			for(int k=n*n*n;k>=0;k--)
				f[k+(1<<j)*a[i].w]=min(f[k+(1<<j)*a[i].w],f[k]+1ll*(1<<j)*a[i].v);
			tmp-=(1<<j);
		}
		if(tmp) for(int k=n*n*n;k>=0;k--)
			f[k+tmp*a[i].w]=min(f[k+tmp*a[i].w],f[k]+1ll*tmp*a[i].v);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) 
		if(a[i].num==1) {z=i;break;}
	for(int i=0;i<=n*n*n;i++)
	{
		if(f[i]>t) continue;
		long long rst=t-f[i],ret=i;
		for(int j=1;j<z;j++)
		{
			int now=min(0ll+d-min(d,n),rst/a[j].v);
			ret+=1ll*now*a[j].w; rst-=1ll*now*a[j].v;
		}
		long long now=rst/a[z].v;
		ret+=1ll*now*a[z].w; ans=max(ans,ret);
	} 
	printf("%lld\n",ans);
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define cri const int
#define ll long long
using namespace std;
vector<int>to[52];
int is[52];
ll w[52],v[52],dp[125010];
void dfs(cri x){
	w[x]=1;
	for(int i=0;i<to[x].size();i++) dfs(to[x][i]),w[x]+=w[to[x][i]],v[x]+=v[to[x][i]];
}
inline int as(cri x,cri y){
	return w[x]*v[y]>w[y]*v[x];
}
int main(){
	int n,X,d,sum=0;
	cin>>n>>X>>d>>v[1];is[1]=1;
	for(int i=2,x;i<=n;i++){
		cin>>v[i]>>x;is[i]=i;
		to[x].push_back(i);
	}
	dfs(1);
	sort(is+1,is+n+1,as);
	memset(dp,0x3f,sizeof dp);dp[0]=0;
	cri mn=min(d,n);
	for(int i=1;i<=n;i++){
		int lst=mn;
		for(int j=1;j<=lst;j<<=1){
			sum+=j*w[i];
			for(int k=sum;k>=j*w[i];k--) dp[k]=min(dp[k],dp[k-j*w[i]]+j*v[i]);
		}
		if(lst){
			cri j=lst;
			sum+=j*w[i];
			for(int k=sum;k>=j*w[i];k--) dp[k]=min(dp[k],dp[k-j*w[i]]+j*v[i]);
		}
	}//cout<<1<<endl;
	ll ans=0;
	for(int s=0;s<=sum;s++) if(dp[s]<=X){
		int lst=X-dp[s];ll tmp=s;
		//cout<<s<<" "<<lst<<" "<<tmp<<endl;
		for(int i=1;i<=n;i++){
			cri x=is[i],num=x==1?lst/v[x]:min((ll)d-mn,lst/v[x]);
			tmp+=num*w[x];lst-=num*v[x];
		}
		//cout<<tmp<<endl;
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc:9:1: error: 'vector' does not name a type
    9 | vector<int>to[52];
      | ^~~~~~
a.cc: In function 'void dfs(int)':
a.cc:14:23: error: 'to' was not declared in this scope; did you mean 'tm'?
   14 |         for(int i=0;i<to[x].size();i++) dfs(to[x][i]),w[x]+=w[to[x][i]],v[x]+=v[to[x][i]];
      |                       ^~
      |                       tm
a.cc: In function 'int main()':
a.cc:24:17: error: 'to' was not declared in this scope; did you mean 'tm'?
   24 |                 to[x].push_back(i);
      |                 ^~
      |                 tm
Language: C++

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define cri const int
#define ll long long
using namespace std;
vector<int>to[52];
int is[52];
ll w[52],v[52],dp[125010];
void dfs(cri x){
	w[x]=1;
	for(int y:to[x]) dfs(y),w[x]+=w[y],v[x]+=v[y];
}
inline int as(cri x,cri y){
	return w[x]*v[y]>w[y]*v[x];
}
int main(){
	int n,X,d,sum=0;
	cin>>n>>X>>d>>v[1];is[1]=1;
	for(int i=2,x;i<=n;i++){
		cin>>v[i]>>x;is[i]=i;
		to[x].push_back(i);
	}
	dfs(1);
	sort(is+1,is+n+1,as);
	memset(dp,0x3f,sizeof dp);dp[0]=0;
	cri mn=min(d,n);
	for(int i=1;i<=n;i++){
		int lst=mn;
		for(int j=1;j<=lst;j<<=1){
			sum+=j*w[i];
			for(int k=sum;k>=j*w[i];k--) dp[k]=min(dp[k],dp[k-j*w[i]]+j*v[i]);
		}
		if(lst){
			cri j=lst;
			sum+=j*w[i];
			for(int k=sum;k>=j*w[i];k--) dp[k]=min(dp[k],dp[k-j*w[i]]+j*v[i]);
		}
	}//cout<<1<<endl;
	ll ans=0;
	for(int s=0;s<=sum;s++) if(dp[s]<=X){
		int lst=X-dp[s];ll tmp=s;
		//cout<<s<<" "<<lst<<" "<<tmp<<endl;
		for(int i=1;i<=n;i++){
			cri x=is[i],num=x==1?lst/v[x]:min((ll)d-mn,lst/v[x]);
			tmp+=num*w[x];lst-=num*v[x];
		}
		//cout<<tmp<<endl;
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc:9:1: error: 'vector' does not name a type
    9 | vector<int>to[52];
      | ^~~~~~
a.cc: In function 'void dfs(int)':
a.cc:14:19: error: 'to' was not declared in this scope; did you mean 'tm'?
   14 |         for(int y:to[x]) dfs(y),w[x]+=w[y],v[x]+=v[y];
      |                   ^~
      |                   tm
a.cc: In function 'int main()':
a.cc:24:17: error: 'to' was not declared in this scope; did you mean 'tm'?
   24 |                 to[x].push_back(i);
      |                 ^~
      |                 tm