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

#include<bits/stdc++.h>
using namespace std;
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
#define rept(i,L,R) for(int i=(L);i<(R);i++)
#define isc(n) scanf("%d",&n)
#define llsc(n) scanf("%lld",&n)
#define dsc(n) scanf("%lf",&n)
#define enl cout<<endl
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define xx first
#define yy second
typedef unsigned long long ll;
typedef pair<int,int>PI;
typedef pair<int,pair<int,int>>PII;
const int mx=4e6+10;
bitset<mx> dp;
int main()
{
    int k,in,sum=0;
    cin>>k;
    dp[0] = 1;
    for (int i=0;i<k;i++)
    {
        cin>>in;
        dp = dp|(dp<<in);
        sum+=in;
    }
    sum=(sum+1)/2;
    for (int i=s;i<mx;i++)
    {
        if (dp[i])
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: 's' was not declared in this scope
   30 |     for (int i=s;i<mx;i++)
      |                ^
Language: C++

/*input
*/
#include <bits/stdc++>
using namespace std;
bitset<4000001>bit; 
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 1; i<=n; i++)
	{
		int num;
		cin >> num;
		bit = bit | (bit << num);
		sum += (num);
	}
	sum/=2;
	for(int i = sum/2; i<=4000000; i++)
	{
		if(bit[i])
		{
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Compiler output:
a.cc:3:10: fatal error: bits/stdc++: No such file or directory
    3 | #include <bits/stdc++>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 日  1/14 22:02:31 2018
 * Ended  Time*  : 四  1/18 13:11:34 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

const int MaxN = 2000;
int n;

int main()
{
	while(~scanf("%d", &n)){
		bitset<MaxN * MaxN> dp;
		dp[0] = 1;
		int sum = 0;
		for(int i = 1; i <= n; i++){
			int x;
			scanf("%d", &x);
			sum += x;
			dp |= dp << x;
		}
		for(int i = (sum+1)/2; ; i++){
			if(dp[i]) { printf("%d\n", i); break;}
		}
	}
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:17: error: 'bitset' was not declared in this scope
   31 |                 bitset<MaxN * MaxN> dp;
      |                 ^~~~~~
a.cc:20:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   19 | #include <stack>
  +++ |+#include <bitset>
   20 | using namespace std;
a.cc:31:37: error: 'dp' was not declared in this scope
   31 |                 bitset<MaxN * MaxN> dp;
      |                                     ^~
Language: C++

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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int A[2000];
bitset<4000001> dp;

signed main() {
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    dp = bitset<4000001>(0);
    for (int i = 1; i <= N; i++) {
        dp | = (dp << A[i]) | (bitset<4000001>(1) << A[i - 1]);
    }
    int ans;
    for (int i = (sum + 1) / 2; i < 4000001; i++) {
        if (dp[i] == 1) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:14: error: expected primary-expression before '=' token
   23 |         dp | = (dp << A[i]) | (bitset<4000001>(1) << A[i - 1]);
      |              ^
Language: C++

/* 2018-01-15-11.35.00 */

#include<bits/stdc++.h>
#define ll long long int
#define N 2010
using namespace std;

int main()
{
    int n,A[N],i,bit=0,ans=1e9+7;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]),bit+=A[i];
    bitset<N*N> dp;
    for(i=0;i<n;i++) dp|=(dp<<v[i]);
    for(i=(bit+1)/2;i<=bit;i++)
    {
        if(dp[i])
        {
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:31: error: 'v' was not declared in this scope
   14 |     for(i=0;i<n;i++) dp|=(dp<<v[i]);
      |                               ^
Language: C++

#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 2000 * 2001;
// const int N = 20;
bitset<N> b;

int main() {
  int n;
  S(n);
  int sm = 0;
  b.set(0,1);
  rep(i,0,n) {
    int x;
    S(x);
    b = b | (b << x);
    sm += x;
  }
  sm++; sm /= 2;
  rep(i,sm,N+1) if(b[i]) {
    P(i);
    return 0;
  }
  return 0;
}


Compiler output:
a.cc:31:1: error: 'bitset' does not name a type
   31 | bitset<N> b;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:37:3: error: 'b' was not declared in this scope
   37 |   b.set(0,1);
      |   ^
Language: C++

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, s;
    cin >> n;
    vector<int> a(n);
    rep(n) cin >> a[i];
    s = accumulate(all(a), 0);
    bitset<4000001> bs(0LL);

    bs.set(0);
    rep(n){
        bitset<4000001> bs2(bs);
        bs2 <<= a[i];
        bs |= bs2;
    }
    reppp(i, (s+1)/2, s+1){
        if(bs[i]){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: 'bitset' was not declared in this scope
   37 |     bitset<4000001> bs(0LL);
      |     ^~~~~~
a.cc:14:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   13 | #include<numeric>
  +++ |+#include <bitset>
   14 | 
a.cc:37:21: error: 'bs' was not declared in this scope; did you mean 's'?
   37 |     bitset<4000001> bs(0LL);
      |                     ^~
      |                     s
a.cc:41:25: error: 'bs2' was not declared in this scope
   41 |         bitset<4000001> bs2(bs);
      |                         ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
bitset< 8000001> dp;
int main()
{
    int arr[2000];
    int n;
    cin>>n;
    int i;
    for(i=0;i<n;i++)
        cin>>arr[i];
    
    if(n==1){cout<<arr[0];return 0;}
    
    int pre=arr[0];
    
    for(i=1;i<n;i++)pre=pre+arr[i];
    dp[arr[0]]=1;
    int sum=pre/2;
    int ans=1e9;
    
    for(i=1;i<n;i++)
    {
        for(int j=1;j<=pre[n-1];j++)
        {
            long long addr1= 1LL*pre[n-1]*i + j;
            long long addr2= j>=arr[i] ? 1LL* pre[n-1]*(i-1)+j-arr[i] : 0;
            long long addr3= 1LL* pre[n-1]*(i-1)+j;
            
            dp[addr1]= dp[addr2] | dp[addr3];
            if(dp[addr1]==1 && j>=sum){ans= min(ans,j);}
        }
    }
   
    cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:27: error: invalid types 'int[int]' for array subscript
   24 |         for(int j=1;j<=pre[n-1];j++)
      |                           ^
a.cc:26:37: error: invalid types 'int[int]' for array subscript
   26 |             long long addr1= 1LL*pre[n-1]*i + j;
      |                                     ^
a.cc:27:50: error: invalid types 'int[int]' for array subscript
   27 |             long long addr2= j>=arr[i] ? 1LL* pre[n-1]*(i-1)+j-arr[i] : 0;
      |                                                  ^
a.cc:28:38: error: invalid types 'int[int]' for array subscript
   28 |             long long addr3= 1LL* pre[n-1]*(i-1)+j;
      |                                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
bitset< 80000001> dp;
int main()
{
    int arr[2000];
    int n;
    cin>>n;
    int i;
    for(i=0;i<n;i++)
        cin>>arr[i];
    
    if(n==1){cout<<arr[0];return 0;}
    
    int pre=arr[0];
    
    for(i=1;i<n;i++)pre=pre+arr[i];
    dp[arr[0]]=1;
    int sum=pre/2;
    int ans=1e9;
    
    for(i=1;i<n;i++)
    {
        for(int j=1;j<=pre[n-1];j++)
        {
            long long addr1= 1LL*pre[n-1]*i + j;
            long long addr2= j>=arr[i] ? 1LL* pre[n-1]*(i-1)+j-arr[i] : 0;
            long long addr3= 1LL* pre[n-1]*(i-1)+j;
            
            dp[addr1]= dp[addr2] | dp[addr3];
            if(dp[addr1]==1 && j>=sum){ans= min(ans,j);}
        }
    }
   
    cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:27: error: invalid types 'int[int]' for array subscript
   24 |         for(int j=1;j<=pre[n-1];j++)
      |                           ^
a.cc:26:37: error: invalid types 'int[int]' for array subscript
   26 |             long long addr1= 1LL*pre[n-1]*i + j;
      |                                     ^
a.cc:27:50: error: invalid types 'int[int]' for array subscript
   27 |             long long addr2= j>=arr[i] ? 1LL* pre[n-1]*(i-1)+j-arr[i] : 0;
      |                                                  ^
a.cc:28:38: error: invalid types 'int[int]' for array subscript
   28 |             long long addr3= 1LL* pre[n-1]*(i-1)+j;
      |                                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
bitset< 8000000001> dp;
int arr[2000];
int main()
{
    
    int n;
    cin>>n;
    int i;
    for(i=0;i<n;i++)
        cin>>arr[i];
    
    if(n==1){cout<<arr[0];return 0;}
    
    int pre=arr[0];
    
    for(i=1;i<n;i++)pre=pre+arr[i];
    dp[arr[0]]=1;
    int sum=pre/2;
    int ans=1e9;
    
    for(i=1;i<n;i++)
    {
        for(int j=1;j<=pre[n-1];j++)
        {
            long long addr1= 1LL*pre[n-1]*i + j;
            long long addr2= j>=arr[i] ? 1LL* pre[n-1]*(i-1)+j-arr[i] : 0;
            long long addr3= 1LL* pre[n-1]*(i-1)+j;
            
            dp[addr1]= dp[addr2] | dp[addr3];
            if(dp[addr1]==1 && j>=sum){ans= min(ans,j);}
        }
    }
   
    cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:27: error: invalid types 'int[int]' for array subscript
   25 |         for(int j=1;j<=pre[n-1];j++)
      |                           ^
a.cc:27:37: error: invalid types 'int[int]' for array subscript
   27 |             long long addr1= 1LL*pre[n-1]*i + j;
      |                                     ^
a.cc:28:50: error: invalid types 'int[int]' for array subscript
   28 |             long long addr2= j>=arr[i] ? 1LL* pre[n-1]*(i-1)+j-arr[i] : 0;
      |                                                  ^
a.cc:29:38: error: invalid types 'int[int]' for array subscript
   29 |             long long addr3= 1LL* pre[n-1]*(i-1)+j;
      |                                      ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
typedef long long ll;

int main() {
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	ll sum=accumulate(ALL(a),0);
	bitset<4000001> dp;
	dp[0]=1;
	REP(i,n) dp=dp|(dp<<a[i]);
	FOR(i,(sum-1)/2+1, 4000001) if(dp[i]==1) {
		cout<<i<<endl;
		return 0;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: 'accumulate' was not declared in this scope
   16 |         ll sum=accumulate(ALL(a),0);
      |                ^~~~~~~~~~
Language: C++

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

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    
    constexpr int maxn = 2000 * 2000 + 1;
    
    bitset<maxn> g;
    
    g[0] = 1;
    
    int sums = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        sums += x;
        g = g | (g << x);
    }
    
    sums = (sums + 1) / 2;
    while (!g[sums]) {
        sums++;
    }
    
    cout << sums << endl;
    
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: 'bitset' was not declared in this scope
   16 |     bitset<maxn> g;
      |     ^~~~~~
a.cc:5:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
    4 | #include <map>
  +++ |+#include <bitset>
    5 | 
a.cc:16:18: error: 'g' was not declared in this scope
   16 |     bitset<maxn> g;
      |                  ^
Language: C++

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int N = 2000010;

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) cin >> a[i];
    int sum = 0;
    REP(i,n) sum += a[i];

    bitset<N> dp;
    dp = 1;
    REP(i,n){
        dp |= dp << a[i];
    }

    FOR(x,sum/2,sum){
        if (dp[x]){
            cout << x << endl;
            return 0;
        }
    }


    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:5: error: 'bitset' was not declared in this scope
   39 |     bitset<N> dp;
      |     ^~~~~~
a.cc:14:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   13 | #include <algorithm>
  +++ |+#include <bitset>
   14 | using namespace std;
a.cc:39:15: error: 'dp' was not declared in this scope
   39 |     bitset<N> dp;
      |               ^~
Language: C++

//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=1e6+1000;
const int SIZE2=5010;
const int SIZE3=400;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string s;
ut N,M,K,X,L,Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;

////////////////////////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////////////////////////
void init(){
 
}
LL solve(){
 	cin >> N;
 	VI A;
 	REP(i,N){
 		cin >> vals[i];
 		A.PB(vals[i]);
 	}
 	sort(ALL(A),greater<LL>);
 	deque<int> c;
 	c.PB(0);
 	c.PB(A[0]);
 	FOR(i,1,A.size()){
 		int t=SI(c);
 		REP(j,t) c.PB(c[j]+A[i]);
 		sort(ALL(c));
 		while(SI(c)>4000){
	 		c.pop_front();
	 		c.pop_back(); 			
 		}
 	}
 	int ans=c[SI(c)/2];

	return ans;
}
signed main(){
	OUT(solve());
	return 0;
}

Compiler output:
a.cc: In function 'LL solve()':
a.cc:73:32: error: expected primary-expression before ')' token
   73 |         sort(ALL(A),greater<LL>);
      |                                ^
Language: C++

N = int(input().strip())
A = list(map(int, input().strip().split(' ')))

sum_a = sum(A)
cnt = [0 for _ in range(sum_a + 1)]
cnt[0] = 1

for a in A:
    for j in range(a, len(cnt))[::-1]:
        cnt[j] += cnt[j - a]

print(A)
print(cnt)

target = 2 ** (N - 1)
s = 0
for i, c in enumerate(cnt):
    s += c
    if target <= s:
        print(i)
        break


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input().strip())
      | ^
Language: Java

#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;

ll dp[2001*2001+100];
ll x[2002*2002];
int main()  {
    int n,k=0;
    cin>>n;
    for(int i=0 ;i <n; i ++){
        scanf("%I64d",&x[i]);
    }

    for(int i=0 ;i <n; i ++){
        if(i)dp[i]= dp[i-1];
        dp[i] += x[i];
    }
    for(int i=n ;i <2*n ;i ++)
        dp[i] = x[i-n];
    sort(dp,dp+2*n);
    cout<<dp[n]<<endl;
    return 0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:2: error: illegal character: '#'
#define pii pair<int,int>
^
Main.java:3: error: illegal character: '#'
#define pll pair<ll,ll>
^
Main.java:4: error: illegal character: '#'
#define fr first
^
Main.java:5: error: illegal character: '#'
#define sc second
^
Main.java:6: error: illegal character: '#'
#define ll  long long
^
Main.java:7: error: illegal character: '#'
#define mp make_pair
^
Main.java:8: error: illegal character: '#'
#define mod 1000000007
^
Main.java:12: error: class, interface, enum, or record expected
ll dp[2001*2001+100];
^
Main.java:13: error: class, interface, enum, or record expected
ll x[2002*2002];
^
Main.java:16: error: not a statement
    cin>>n;
       ^
Main.java:28: error: not a statement
    cout<<dp[n]<<endl;
               ^
Main.java:14: error: unnamed classes are a preview feature and are disabled by default.
int main()  {
^
  (use --enable-preview to enable unnamed classes)
Main.java:18: error: illegal start of expression
        scanf("%I64d",&x[i]);
                      ^
15 errors
Language: C++

#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}


int N,sm;
int A[2005];
int rsm[2005];
int tmpBest = inf;

int dfs(int pos, int sum) {
	if(pos==N) return sum;
	if(sum > tmpBest) return inf;
	if(rsm[pos]+sum < (sm+1)/2) return inf;
	int sm1 = dfs(pos+1, sum+A[i]);
	int sm2 = dfs(pos+1, sum);
	int res  = min(sm1,sm2);
	Min(tmpBest, res);
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> N;
	for(int i=1;i<=N;++i) {cin >> A[i];sm += A[i];}
	for(int i=N;i>=1;--i) {rsm[i]=rsm[i+1]+A[i];}
	cout << dfs(0,0) << endl;

}










Compiler output:
a.cc: In function 'int dfs(int, int)':
a.cc:37:36: error: 'i' was not declared in this scope
   37 |         int sm1 = dfs(pos+1, sum+A[i]);
      |                                    ^
Language: Java


import java.math.BigInteger;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

/**
 *
 * @author I Love Eslam
 */
public class JavaApplication21 {

    /**
     * @param args the command line arguments
     */
    public static boolean ch(int m) {
        int st = m;
        int en = m - 1;
        BigInteger rst = BigInteger.valueOf(0);
        BigInteger ren = BigInteger.valueOf(1);
        while (true) {
            if (rst.compareTo(ren) <= 0 && st >= 0) {
                rst = rst.add(dp[st--]);
            } else if (en < dp.length) {
                ren = ren.add(dp[en++]);
            } else {
                break;
            }
        }
        return rst.compareTo(ren) <=0;

    }

    static BigInteger dp[];
    static int x[];
    static int add[];

    public static void main(String[] args) {
        TreeSet<Integer> st = new TreeSet<>();
        dp = new BigInteger[2002 * 2002];
        add = new int[2002 * 2002];
        for (int i = 0; i < dp.length; i++) {
            dp[i] = BigInteger.valueOf(0);
        }
        int n, k = 0;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        dp[0] = BigInteger.valueOf(1);
        st.add(0);
        Iterator it;
        int t;
        for (int i = 0; i < n; i++) {
            it = st.iterator();
            while (it.hasNext()) {
                t = (Integer) it.next();
                t *= -1;
                if (dp[t + x[i]].equals(BigInteger.valueOf(0))) {
                    add[k++] = (-(t + x[i]));
                }
                dp[t + x[i]] = dp[t + x[i]].add(dp[t]);
            }
            for (int j = 0; j < k; j++) {
                st.add(add[j]);
            }
        }
        int l = 1, r = dp.length-1;
        int res = 1;
        while (l <= r) {
            int m = (l + r) / 2;
            if (ch(m)) {
                res = m;
                l = m + 1;
            } else {
                r = m - 1;
            }
        }
        while(dp[res].equals(BigInteger.valueOf(0)))res--;
        System.out.println("" + res);
    }

}


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

#include <iostream>
#include <algorithm>
using namespace std;
int N;
int V[2005];
vector<long long> tmp;
int main()
{
    cin >> N;
    long long rez = 0;
    for(int i = 1;i <= N;i++){
        cin >> V[i];
    }
    sort(V + 1,V + 1 + N);
    for(int i = 1;i <= N;i++){
        long long sum = 0;
        for(int j = i;j <= N;j++){
            sum += V[j];
            tmp.push_back(sum);
        }
    }
    sort(tmp.begin(),tmp.end());
    cout << tmp[(tmp.size() - 1) / 2];
    return 0;
}


Compiler output:
a.cc:6:1: error: 'vector' does not name a type
    6 | vector<long long> tmp;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:19:13: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   19 |             tmp.push_back(sum);
      |             ^~~
      |             tm
a.cc:22:10: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   22 |     sort(tmp.begin(),tmp.end());
      |          ^~~
      |          tm
Language: C++

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

int main() {
  int N;
  scanf("%d",&N);
  int A[N];
  for (int i=0; i<N; i++) {
    scanf("%d",&A[i]);
  }
  printf("%d\n",A[i/2]);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:19: error: 'i' was not declared in this scope
   12 |   printf("%d\n",A[i/2]);
      |                   ^
Language: C++

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

using f80 = long double;
using f64 = double;
using i64 = unsigned long long;
using pii = pair<int, int>;

const int N = 1024;

set<int> a, b;
vector<int> v;

int main() {
#ifdef HOME
	freopen("agc.in", "r", stdin);
	freopen("agc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, t, s(0);

	a.insert(0);

	cin >> n;
	v.resize(n);
	for (auto &i: v)
		cin >> i, s+= i;

	for (int i = 0; i < n && a.size() <= s; ++i) {
		b.clear();
		for (auto j: a) {
			b.insert(j + v[i]);
			b.insert(j); }
		 swap(a, b); }

	v.clear();
	for (auto i: a)
		l.push_back(i);

	cout << v[(v.size() + 1) / 2] << endl;


	return 0; }


Compiler output:
a.cc: In function 'int main()':
a.cc:41:17: error: 'l' was not declared in this scope
   41 |                 l.push_back(i);
      |                 ^
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#define N 210000
#define M 210000
using namespace std;
int ans,n;
int sum;
int a[2100];
bitset<4100000> f;
int main()
{
	scanf("%d",&n);
	ans=-2147483647;
	f.reset();
	f|=1;
	sum=0;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		ans=max(a[i],ans);
		sum+=a[i];
		f=(f<<a[i])|f;
	}
	if(ans<sum-ans)
	{
		for(int i=(sum+1)/2;;i++)
			if(f.test(i)){ ans=i; break; }
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc:17:1: error: 'bitset' does not name a type
   17 | bitset<4100000> f;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:22:9: error: 'f' was not declared in this scope
   22 |         f.reset();
      |         ^
Language: Java

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] A = IntStream.range(0,N).map(i -> scan.nextInt()).toArray();
        Arrays.sort(A);
        int sumA = 0;
        for(int i=0;i<N;++i)sumA+=A[i];
        int k = (sumA)/2;
        //k以下の最大値
        int dp[]= new int[k+1];
        for(int i=0;i<N;++i){
            int newdp[]=new int[k+1];
            for(int j=0;j<=k;++j){
                if(j-A[i]>=0){
                    newdp[j]=dp[j-A[i]]+A[i];
                }else{
                    newdp[j]=dp[j];
                }
            }
        }
        System.out.println(sumA - dp[N][k]);


    }
}

Compiler output:
Main.java:26: error: array required, but int found
        System.out.println(sumA - dp[N][k]);
                                       ^
1 error
Language: C++

#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int W = 2000100;
typedef bitset<W> bs;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int tot = 0;
  REP(i, 0, n) {
    tot += a[i];
  }
  if (tot - a[n - 1] <= a[n - 1]) {
    cout << a[n - 1] << endl;
    return 0;
  }
  int margin = tot - 2 * a[n - 1];
  int lim = margin / 2;
  bs dp;
  dp[0] = true;
  REP(i, 0, n - 1) {
    dp |= dp << a[i];
  }
  int ma = 0;
  for(int j=lim;j>=0;--j){
    if (dp[j]) {
      ma = j;
      break;
    }
  }
  cout << tot - a[n - 1] - ma << endl;
}


Compiler output:
a.cc:33:9: error: 'bitset' does not name a type
   33 | typedef bitset<W> bs;
      |         ^~~~~~
a.cc: In function 'int main()':
a.cc:55:3: error: 'bs' was not declared in this scope; did you mean 'abs'?
   55 |   bs dp;
      |   ^~
      |   abs
a.cc:56:3: error: 'dp' was not declared in this scope
   56 |   dp[0] = true;
      |   ^~
Language: C++

#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = 2005;
int a[N];
int BASE = N;

bitset <N * N> cb;

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n;
    scanf("%d", &n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i] );
        sum += a[i];
    }
    cb[0] = 1;
    for (int i = 0; i < n; i++)
        cb |= (cb << a[i] );
    sum = (sum + 1) / 2;
    while (!cb[sum])
        sum++;
    printf("%d\n", sum);


	return 0;
}



Compiler output:
a.cc:27:1: error: 'bitset' does not name a type
   27 | bitset <N * N> cb;
      | ^~~~~~
a.cc: In function 'int main(int, char**)':
a.cc:44:5: error: 'cb' was not declared in this scope
   44 |     cb[0] = 1;
      |     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
bitset<4000005>mask(1);
int main(){
	int n,sum=0;cin>>n;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		mask|=mask<<x,sum+=x;
	}
	for(int i=sum+1>>1;;i++){
		if(mask.test(i))
			cout<<i,break;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:33: error: expected primary-expression before 'break'
   12 |                         cout<<i,break;
      |                                 ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2001;
int n, arr[MAXN];
int main() {
	scanf("%d", &n);
	int s = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", arr + i);
		s += arr[i];
	}
	int maxv = sa / 2 + 1;
	bitset<maxv> dp;
	dp.set(0);
	for(int i = 0; i < n; i++)
	    dp |= dp << arr[i];
	for (int i = maxv-1; i >= 0; i--) {
		if (dp.get(i)) {
			printf("%d\n", sa - i);
			return 0;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:20: error: 'sa' was not declared in this scope; did you mean 's'?
   12 |         int maxv = sa / 2 + 1;
      |                    ^~
      |                    s
a.cc:13:20: error: the value of 'maxv' is not usable in a constant expression
   13 |         bitset<maxv> dp;
      |                    ^
a.cc:13:20: note: in template argument for type 'long unsigned int'
a.cc:14:12: error: request for member 'set' in 'dp', which is of non-class type 'int'
   14 |         dp.set(0);
      |            ^~~
a.cc:18:24: error: request for member 'get' in 'dp', which is of non-class type 'int'
   18 |                 if (dp.get(i)) {
      |                        ^~~
Language: Java

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

public class C {

	void solve() {
		int n = in.nextInt();
		int max = 2000;
		int sum = 0;
		boolean[][] dp = new boolean[n + 1][2 * max + 1];
		dp[0][max] = true;
		for (int i = 0; i < n; i++) {
			int val = in.nextInt();
			sum += val;
			
			for (int j = 0; j < dp[i].length; j++) {
				if (dp[i][j]) {
					if (j - val >= 0) {
						dp[i + 1][j - val] = true;
					}
					if (j + val < dp[i].length) {
						dp[i + 1][j + val] = true;
					}
				}
			}
		}
		
		for (int j = 0; j <= max; j++) {
			if (dp[n][j + max]) {
				out.println((sum + j) / 2);
				return;
			}
		}
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new C().run();
	}
}


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



#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
using namespace std;

#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979
#define x0 ikjnrmthklmnt
#define y0 lkrjhkltr
#define y1 ewrgrg

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<Int, Int> PLL;
typedef pair<double, double> PDD;
typedef complex<double> base;

const int INF = 1000000000;
const int BASE = 1000000007;
const int MAX = 4000000 + 1;
const int MAXX = 1000000;
const int ADD = 1000000;
const int MOD = 1000000007;
const int CNT = 800;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("distance.in",  "r", stdin);
    //freopen("distance.out", "w", stdout);
    //freopen("out.txt" , "w" , stdout);
    
    
    int n;
    cin >> n;
    
    bitset<MAX> B;
    
    B[0] = 1;
    
    int s = 0;
    
    FOR(i,0,n)
    {
        int x;
        cin >> x;
        s += x;
        B = B | (B << x);
    }
    
    FOR(i,(s + 1) / 2 , MAX)
        if (B[i] == 1)
        {
            cout << i << endl;
            return 0;
        }
    
    
    
    
    
    
    return 0;
}













Compiler output:
a.cc: In function 'int main()':
a.cc:68:5: error: 'bitset' was not declared in this scope
   68 |     bitset<MAX> B;
      |     ^~~~~~
a.cc:26:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   25 | #include <complex>
  +++ |+#include <bitset>
   26 | using namespace std;
a.cc:68:17: error: 'B' was not declared in this scope
   68 |     bitset<MAX> B;
      |                 ^
Language: C

#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
int a,b,A,B,C,D,re,tag;
void get(int mid){
	a=A-mid/(re+1)*re-mid%(re+1);
	b=B-mid/(re+1);
}
signed main(){
	for(int T=read();T--;){
		A=read(),B=read(),C=read(),D=read();
		re=max(ceil((double)A/(B+1)),ceil((double)B/(A+1)));
		int l=0,r=A+B,pos=0;
		while(l<=r){
			int mid=l+r>>1;get(mid);
			if(b<=a*re)l=mid+1,pos=mid;
			else r=mid-1;
		}get(pos);tag=pos+1+b-a*re;
		for(int i=C;i<=D;i++){
			if(i<=pos){if(i%(re+1))cout<<'A';else cout<<'B';}
			else{if((i-tag)%(re+1))cout<<'B';else cout<<'A';}
		}cout<<'\n';
	}return signed();
}

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<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const char s[2]={'A','B'};
int a,b,c,d,q,k,nb;ll lim;
int calc(int x)
{
	return (a-(b-x+k-1)/k)/k;
}
inline int find(){
    R int l=0,r=b,mid,ans=0;
    while(l<=r){
        mid=(l+r)>>1;
        mid<=calc(mid)?(ans=mid,l=mid+1):r=mid-1;
    }
    return ans;
}
int main(){
//  freopen("testdata.in","r",stdin);
    for(scanf("%d",&q);q;--q){
        scanf("%d%d%d%d",&a,&b,&c,&d),--c;
		k=(max(a,b)+min(a,b))/(min(a,b)+1);
		if(k==1)
		{
			c++;
			for(i=c;i<=d;i++)
			{
				putchar('A'+((i&1)^(a>b)));
			}
			puts("");
			continue;
		}
        else{
            nb=find();
//          printf("qwq %d %d %d %d\n",a,b,k,nb);
            lim=nb+a-(b-nb+k-1)/k+1;
            fp(i,c,d-1)putchar(i<lim?s[i%(k+1)==k]:s[(a+b-i)%(k+1)>0]);
        }
        putchar('\n');
    }
    return 0;
}

Compiler output:
a.cc: In function 'int find()':
a.cc:17:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |     R int l=0,r=b,mid,ans=0;
      |           ^
a.cc:17:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |     R int l=0,r=b,mid,ans=0;
      |               ^
a.cc:17:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |     R int l=0,r=b,mid,ans=0;
      |                   ^~~
a.cc:17:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |     R int l=0,r=b,mid,ans=0;
      |                       ^~~
a.cc: In function 'int main()':
a.cc:32:29: error: 'i' was not declared in this scope
   32 |                         for(i=c;i<=d;i++)
      |                             ^
a.cc:43:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |             fp(i,c,d-1)putchar(i<lim?s[i%(k+1)==k]:s[(a+b-i)%(k+1)>0]);
      |                ^
a.cc:3:29: note: in definition of macro 'fp'
    3 | #define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
      |                             ^
a.cc:3:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    3 | #define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
      |                                   ^
a.cc:43:13: note: in expansion of macro 'fp'
   43 |             fp(i,c,d-1)putchar(i<lim?s[i%(k+1)==k]:s[(a+b-i)%(k+1)>0]);
      |             ^~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int T,n,m,l,r;
int work(int a,int b){
	if(a%b==0) return a/b;
	return a/b+1;
}
bool check(int A,int B,int pos,int k){
	int tmp=pos/(k+1);
	A-=tmp*k;B-=tmp;A-=pos-tmp*(k+1);
	return B<=(ll)A*k;
}
int cal(int a,int k){
	if(a%(k+1)==0) return 1;
	return 0;
}
int main()
{
	scanf("%d",&T);
	while(T--){
		scanf("%d%d%d%d",&n,&m,&l,&r);
		int k=work(max(n,m),min(n,m)+1),pos=-1;
		int li=0,ri=n+m+1;
		while(li<ri){
			int mid=(li+ri)>>1;
			if(check(n,m,mid,k)) li=mid+1;
			else ri=mid;
		}
		pos=li;
		for(int i=l;i<=r;i++){
			int op=0;
			if(i<=pos) op=cal(i,k);
			else op=cal(n+m-i+1,k)^1;
			if(op==0) printf("A");
			else printf("B");
		}
		puts("");
	}
	return 0;
} 

Compiler output:
a.cc: In function 'bool check(int, int, int, int)':
a.cc:17:20: error: 'll' was not declared in this scope; did you mean 'l'?
   17 |         return B<=(ll)A*k;
      |                    ^~
      |                    l
a.cc:17:23: error: expected ';' before 'A'
   17 |         return B<=(ll)A*k;
      |                       ^
      |                       ;
Language: C++


#include <cstdio>
#include <algorithm>

using namespace std;

namespace io
{
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush (){fwrite (obuf, 1, oS - obuf, stdout);oS = obuf;}
	inline void putc (char x){*oS ++ = x;if (oS == oT) flush ();}
	template <class I>
	inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
	template <class I>
	inline void print (I x){
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while(x) qu[++ qr] = x % 10 + '0',  x /= 10;while (qr) putc (qu[qr--]);}
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io::gi;
using io::putc;
using io::print;

int Q, A, B, C, D, K, L;

inline bool check(int a)
{
	int b = a / (K + 1);
	if (b > B)
		return false;
	if ((a -= b) > A)
		return false;
	return K * ((A - a) + 1) >= B - b;
}

inline char query(int p)
{
	if (p <= L)
		if (p % (K + 1))
			return 'A';
		else
			return 'B';
	p -= L;
	int b = L / (K + 1), a = L - b;
	A -= a, B -= b;
	if (p <= B - K * A)
		return 'B';
	p -= B - K * A;
	if ((p - 1) % (K + 1))
		return 'B';
	else
		return 'A';
}

int main()
	gi(Q);
	for (int l, r, mid;Q--;)
	{
		gi(A), gi(B), gi(C), gi(D);
		K = max(A, B) / (min(A, B) + 1);
		while ((min(A, B) + 1) * K < max(A, B))
			++K;
		l = 0, r = A + B + 1;
		while (l < r)
		{
			mid = l + ((r - l) >> 1);
			if (check(mid))
				l = mid + 1;
			else
				r = mid;
		}
		L = l - 1;
		for (int i = C;i <= D;++i)
			putc(query(i));
		putc('\n');
	}
	return 0;
}

Compiler output:
a.cc:58:9: error: expected initializer before 'gi'
   58 |         gi(Q);
      |         ^~
a.cc:59:9: error: expected unqualified-id before 'for'
   59 |         for (int l, r, mid;Q--;)
      |         ^~~
a.cc:59:28: error: 'Q' does not name a type
   59 |         for (int l, r, mid;Q--;)
      |                            ^
a.cc:59:32: error: expected unqualified-id before ')' token
   59 |         for (int l, r, mid;Q--;)
      |                                ^
a.cc:79:9: error: expected unqualified-id before 'return'
   79 |         return 0;
      |         ^~~~~~
a.cc:80:1: error: expected declaration before '}' token
   80 | }
      | ^
Language: C++

#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const ll INF = 1e9;
inline ll read(){
	ll X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}
int main()
{
	ll T;
	cin>>T;
	while(T--)
	{
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		ll x=floor(1.0*(max(a,b))/(min(a,b)+1);
		ll l=0;
		ll r=a+b;
		ll pos=a+b+1;
		while(r>=l)
		{
			ll mid=(l+r)/2;
			ll tmp1=mid/(x+1);
			ll tmp2=mid-tmp1;
			if(b-tmp1>(a-tmp2)*(x-1))
			{
				pos=mid;
				r=mid-1;
			}
			else
			{
				l=mid+1; 
			}
		}
		cout<<pos<<endl;
		for(ll i=c;i<=min(pos,d);i++)
		{
			cout<<((i%(x+1))?'A':'B');
		}
		for(ll i=max(c,pos+1);i<=d;i++)
		{
			cout<<(((a+b-i+1)%(x+1))?'B':'A');
		}
		cout<<endl;
	}
	return 0;
}
/*
5
2 3 1 5
6 4 1 10
2 3 4 4
6 4 3 7
8 10 5 8
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:39:55: error: expected ')' before ';' token
   39 |                 ll x=floor(1.0*(max(a,b))/(min(a,b)+1);
      |                           ~                           ^
      |                                                       )
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int Q;

int cdiv(int a, int b) { return (a+b-1)/b; }

int eval(int a, int b, int i, int L) {
	return i-i/(L+1)+(a+b-i)/(L+1);
}

bool ok(int a, int b, int i, int L) {
	if (i < 0 || i > a+b) return 0;
	if (eval(a,b,i,L) != a) return 0;
	if (i && a+b-i) if ((i % (L+1) == 0) ^ ((a+b-i) % (L+1) == 0)) return 0;
	return 1;
}

vi get(int a, int b) {
	int L = cdiv(max(a,b),min(a,b)+1);
	if (a > (ll)b*L) return {a,b,L,a+b};
	if (b > (ll)a*L) return {a,b,L,0};

	int lo = 0, hi = a+b;
	while (lo < hi) {
		int mid = (lo+hi)/2;
		if (eval(a,b,mid,L) < a) lo = mid+1;
		else hi = mid;
	}
return lo;
	// cout << eval(a,b,lo,L) << " " << a << "\n";
	while (1) {
		if (ok(a,b,lo,L)) return {a,b,L,lo};
		lo --;
		if (ok(a,b,hi,L)) return {a,b,L,hi};
		hi ++;
	}
}

string get(int L, int x, int c, int d) {
	d = min(d,x-1);
	if (c > d) return "";
	string res;
	FOR(i,c,d+1) {
		if ((i+1) % (L+1) == 0) res += 'B';
		else res += 'A';
	}
	return res;
}

string extract(vi x, int c, int d) {
	string s1 = get(x[2],x[3],c,d);
	string s2 = get(x[2],x[0]+x[1]-x[3],x[0]+x[1]-1-d,x[0]+x[1]-1-c);
	reverse(all(s2));
	for (char& c: s2) c = char('A'+(1-(c-'A')));
	return s1+s2;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> Q;
	F0R(i,Q) {
		int a,b,c,d; cin >> a >> b >> c >> d;
		vi x = get(a,b);
		cout << extract(x,c-1,d-1) << "\n";
	}
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS


Compiler output:
a.cc: In function 'vi get(int, int)':
a.cc:69:8: error: could not convert 'lo' from 'int' to 'vi' {aka 'std::vector<int>'}
   69 | return lo;
      |        ^~
      |        |
      |        int