criyle/codenet-compile-errors huggingface dataset:
Language: Java

public class Main {
	public static char[] mv;
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		String str = s.next();
		mv = new char[str.length()];
		for(int i=0;i<str.length();i++) {
			mv[i] = str.charAt(i);
		}

		int [] kids;
		kids = new int[str.length()];
		BigInteger big10_100 = BigInteger.TEN.pow(100);
		for(int i=0;i<str.length();i++) {
			kids[calcPos(i,big10_100 )]++;
		}

		for(int i=0;i<kids.length-1;i++) {
			System.out.print(kids[i]+" ");
		}
		System.out.println(kids[kids.length-1]);
	}

	public static int calcPos(int pos, BigInteger times) {
		int next = pos+move(mv[pos]);
		if(times.equals(BigInteger.ONE)) {
			return next;
		}else {
			if(mv[pos]==mv[next]) {
				return calcPos(next,times.subtract(BigInteger.ONE));
			}else {
				if(times.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO)) {
					return pos;
				}else {
					return next;
				}
			}

		}
	}
	public static int move(char c) {
		return (c=='R')?1:-1;
	}
}

Compiler output:
Main.java:24: error: cannot find symbol
	public static int calcPos(int pos, BigInteger times) {
	                                   ^
  symbol:   class BigInteger
  location: class Main
Main.java:13: error: cannot find symbol
		BigInteger big10_100 = BigInteger.TEN.pow(100);
		^
  symbol:   class BigInteger
  location: class Main
Main.java:13: error: package BigInteger does not exist
		BigInteger big10_100 = BigInteger.TEN.pow(100);
		                                 ^
Main.java:26: error: cannot find symbol
		if(times.equals(BigInteger.ONE)) {
		                ^
  symbol:   variable BigInteger
  location: class Main
Main.java:30: error: cannot find symbol
				return calcPos(next,times.subtract(BigInteger.ONE));
				                                   ^
  symbol:   variable BigInteger
  location: class Main
Main.java:32: error: cannot find symbol
				if(times.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO)) {
				                                           ^
  symbol:   variable BigInteger
  location: class Main
Main.java:32: error: cannot find symbol
				if(times.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO)) {
				             ^
  symbol:   variable BigInteger
  location: class Main
7 errors
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define ll long long

const int maxn = 1e5 + 7;
int a[maxn];
int b[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s; cin >> s;
	int len = s.size();

	for (int i = 0; i <= len; i++) a[i] = 1;
	int t = 10000000;
	while (t--)
	{
		memset(b, 0, sizeof(b));
		for (int i = 0; i < len; i++){
			int num = a[i] - b[i];
			if (num == 0) continue;
			a[i] -= num;
			if (s[i] == 'R'){
				a[i + 1] += num;
				b[i + 1] += num;
			}
			else{
				a[i - 1] += num;
				b[i - 1] += num;
			}
		}
		/*
		cout << a[0];
		for (int i = 1; i < len; i++){
			cout << " " << a[i];
		}
		cout << endl;
		*/
	}
	//cout << "****************" << endl;
	cout << a[0];
	for (int i = 1; i < len; i++){
		cout << " " << a[i];
	}
	cout << endl;

	//system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:17: error: 'memset' was not declared in this scope
   23 |                 memset(b, 0, sizeof(b));
      |                 ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <cmath>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };

int memo[100008];
int num[100008];


int main() {
	char S[100008];	
	scanf("%s", &S);
	int size = strlen(S);


	int dest[100008];//i番目の行き先を入れる
	for (int i = 0; i < size; i++)dest[i] = -1;
	
	for (int i = 0; i < size-1; i++) //10の５乗
		if (S[i] == 'R' && S[i + 1] == 'L')memo[i] = 1;
	

	for (int i = 0; i < size; i++) {//１０の５乗
		if (S[i] == 'R') {
			for (int j = 0; i + j < size; j++) {//絶対ここ！！
				if (memo[i + j] == 1) {
					num[i + j + (j %2)]++;
					dest[i] = i + j + (j % 2);
					break;
				}
				else if (i + j == size - 1) {
					num[i]++;
					dest[i] = i;
				}
			}
		}
		
		else if (dest[i - 2] != -1 && S[i - 1] != 'R') {
			num[i] = dest[i - 2];
			dest[i] = dest[i - 2];
		
		}
		L
		else {//左を見る
			for (int j = 1; i-j >=0; j++) {
				if (memo[i - j] == 1) {
					num[i - j + (j % 2)]++;
					dest[i] = i - j + (j % 2);
					break;
				}
			}
			

		}
		
	}

	for (int i = 0; i < size; i++)printf("%d ", num[i]);

}

/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:53:17: error: 'L' was not declared in this scope
   53 |                 L
      |                 ^
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define ll long long

const int maxn = 1e5 + 7;
int a[maxn];
int b[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s; cin >> s;
	int len = s.size();

	for (int i = 0; i <= len; i++) a[i] = 1;
	int t = 100;
	while (t--)
	{
		memset(b, 0, sizeof(b));
		for (int i = 0; i < len; i++){
			int num = a[i] - b[i];
			if (num == 0) continue;
			a[i] -= num;
			if (s[i] == 'R'){
				a[i + 1] += num;
				b[i + 1] += num;
			}
			else{
				a[i - 1] += num;
				b[i - 1] += num;
			}
		}
		/*
		cout << a[0];
		for (int i = 1; i < len; i++){
			cout << " " << a[i];
		}
		cout << endl;
		*/
	}
	//cout << "****************" << endl;
	cout << a[0];
	for (int i = 1; i < len; i++){
		cout << " " << a[i];
	}
	cout << endl;

	//system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:17: error: 'memset' was not declared in this scope
   23 |                 memset(b, 0, sizeof(b));
      |                 ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <cmath>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

#include <iostream>
#include <string>

using namespace std;

int main(void){
    int childnum[100000] = {0};
    int childnum_bk[100000] = {0};
    int childnum_bkk[100000] = {0};
    string s;
    cin >> s;
    unsigned int tmp;

    for(int i=0; i<s.size(); i++){
        childnum_bk[i] = 1;
    }

    while(1){
        tmp++;
        for(int i=0; i<s.size(); i++){
            if(i==0){
                childnum[1] += childnum_bk[0];
            }else if(i == 99999){
                childnum[99998] += childnum_bk[99999];
            }else{
                if(s[i] == 'L'){
                    childnum[i-1] += childnum_bk[i];
                }else{
                    childnum[i+1] += childnum_bk[i];
                }
            }
        }


        if( (memcmp(childnum, childnum_bkk, s.size())==0) && (tmp%2==0) ){break;}


            memcpy(childnum_bkk ,childnum_bk, 100000); //bk to bkk
            memcpy(childnum_bk ,childnum, 100000); //now to bk
            memset(childnum , 0, 100000); //now to bk
    }

    for(int i=0; i<s.size(); i++){
        cout << childnum[i] << " ";
    }
    

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:14: error: 'memcmp' was not declared in this scope
   35 |         if( (memcmp(childnum, childnum_bkk, s.size())==0) && (tmp%2==0) ){break;}
      |              ^~~~~~
a.cc:2:1: note: 'memcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
a.cc:38:13: error: 'memcpy' was not declared in this scope
   38 |             memcpy(childnum_bkk ,childnum_bk, 100000); //bk to bkk
      |             ^~~~~~
a.cc:38:13: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:40:13: error: 'memset' was not declared in this scope
   40 |             memset(childnum , 0, 100000); //now to bk
      |             ^~~~~~
a.cc:40:13: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <iostream>
#include <string>
#include <vector>

using namespace std;

static inline void FirstChangeDirection(int startIndex, const string &input, int &time, int &index, char &direction)
{
    const auto firstDirection = input[startIndex];
    const auto delta = (input[position] == 'R') ? 1 : -1;
    int t = 0;
    auto position = startIndex;

    while (true)
    {
        position += delta;
        t++;
        const auto newDirection = input[position];
        if (newDirection != firstDirection)
        {
            time = t;
            index = position;
            direction = newDirection;
            return;
        }
    }
}

int main()
{
    string input;
    cin >> input;
    const auto size = input.size();
    auto childCounts = vector<int>(size, 0);
    int time = -1;
    int index = -1;
    char direction = ' ';
    for (int i = 0; i < size; i++)
    {
        if (i > 0 && input[i] == input[i - 1])
        {
            if (time % 2 == 0 && direction == 'L')
            {
                if (index == 0)
                {
                    childCounts[1]++;
                }
                else
                {
                    childCounts[index - 1]++;
                }
            }
            if (time % 2 == 0 && direction == 'R' && index < size - 1)
            {
                if (index == size - 1)
                {
                    childCounts[size - 2]++;
                }
                else
                {
                    childCounts[index + 1]++;
                }
            }
            if (time % 2 == 1 && direction == 'L' && index < size - 1)
            {
                if (index == size - 1)
                {
                    childCounts[size - 2]++;
                }
                else
                {
                    childCounts[index + 0]++;
                }
            }
            if (time % 2 == 1 && direction == 'R' && index > 0)
            {
                if (index == 0)
                {
                    childCounts[1]++;
                }
                else
                {
                    childCounts[index - 0]++;
                }
            }
            time++;
            continue;
        }
        FirstChangeDirection(i, input, time, index, direction);
        int finalIndex = -1;
        if (time % 2 == 0)
        {
            finalIndex = index;
        }
        else
        {
            if (direction == 'L')
            {
                finalIndex = index - 1;
            }
            else
            {
                finalIndex = index + 1;
            }
        }
        childCounts[finalIndex]++;
    }
    for (auto count : childCounts)
    {
        cout << count << " ";
    }
    return 0;
}

Compiler output:
a.cc: In function 'void FirstChangeDirection(int, const std::string&, int&, int&, char&)':
a.cc:10:31: error: 'position' was not declared in this scope
   10 |     const auto delta = (input[position] == 'R') ? 1 : -1;
      |                               ^~~~~~~~
Language: C++

#include"pch.h"
#include<iostream>
#include<string>
#include<vector>
#include<ctime>
#include<iomanip>
#include<fstream>
#include<stack>
#include<queue>
#include<cassert>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<functional>
#include<exception>
#include<utility>
#define fori(i,z,u) for(i=z;i<u;i++)
#define forz(i,m) for(i=0;i<m;i++)
#define forinc(i,z,u,inc) for(i=z;i<u;i+=inc)
using namespace std;
#define fi first
#define se second
#define vi vector<int>
#define vill vector<long long>
#define vd vector<long double>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vb vector<bool>
#define ump unordered_map
#define debug(x) cout<<#x<<" : "<<x
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define Onlaptop

int main()
{
	int i{ 0 }, j{ 0 }, k{ 0 }, l{ 0 }, a{ 0 }, b{ 0 }, c{ 0 }, d{ 0 }, t{ 0 }, n{ 0 };

#ifdef Onlaptop
	fstream cin, cout;

	cin.open("input.txt");
	cout.open("output.txt", ios::trunc);
#endif

	string child;
	cin >> child;

	vi vec(child.size());

	c = 0, d = 0;

	int prev = 0;

	size_t you;

	forz(i, child.size())
	{
		if (i == 0)
			you = child.find("RL");
		else
			you = child.find("RL", prev + 1);

		prev = you;

		if (you == string::npos)
			break;

		a = int(you);
		b = int(you + 1);
		vec[a]++; vec[b]++;

		//cout << a <<" "<< b << endl;

		c = a - 1;
		if (c >= 0)
			while (child[c] == 'R')
			{
				if ((a - (c)) % 2 != 0)
				{
					vec[b]++;
				}
				else vec[a]++;
				c--;
				if (c < 0)break;

				//debug("charim");
			}



		d = b + 1;

		if (d < vec.size())
			while (child[d] == 'L')
			{
				if ((d - b) % 2 == 0)
				{
					vec[b]++;
				}
				else
				{
					vec[a]++;
				}
				d++;
				if (d >= vec.size())break;

				//debug("charmi");
			}
	}
	forz(i, vec.size())
		cout << (i == 0 ? "" : " ") << vec[i];
	return 0;
}

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

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

int check(string s, int a,vector<int> &checked){
    if(checked[a]!=-1) return checked[a];
    if(s.at[a]=='R'&&s.at[a+1]=='L') return checked[a]=a;
    if(s.at[a]=='L'&&s.at[a-1]=='R') return checked[a]=a;
    if(s.at[a]=='R'&&s.at[a+1]=='R') return checked[a]=check(s,a+2,checked);
    if(s.at[a]=='L'&&s.at[a-1]=='L') return checked[a]=check(s,a-2,checked);
}

int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<int> ans(n,0);
    vector<int> checked(n,-1);
    for(int i=0;i<n;i++){
        ans[check(s,i,checked)]++;
        
    }
    for(int i=0;i<n;i++){
            cout<<ans[i]<<' ';
        }
    return 0;
}

Compiler output:
a.cc: In function 'int check(std::string, int, std::vector<int>&)':
a.cc:7:12: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
    7 |     if(s.at[a]=='R'&&s.at[a+1]=='L') return checked[a]=a;
      |            ^
a.cc:7:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
    7 |     if(s.at[a]=='R'&&s.at[a+1]=='L') return checked[a]=a;
      |                          ^
a.cc:8:12: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
    8 |     if(s.at[a]=='L'&&s.at[a-1]=='R') return checked[a]=a;
      |            ^
a.cc:8:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
    8 |     if(s.at[a]=='L'&&s.at[a-1]=='R') return checked[a]=a;
      |                          ^
a.cc:9:12: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
    9 |     if(s.at[a]=='R'&&s.at[a+1]=='R') return checked[a]=check(s,a+2,checked);
      |            ^
a.cc:9:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
    9 |     if(s.at[a]=='R'&&s.at[a+1]=='R') return checked[a]=check(s,a+2,checked);
      |                          ^
a.cc:10:12: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   10 |     if(s.at[a]=='L'&&s.at[a-1]=='L') return checked[a]=check(s,a-2,checked);
      |            ^
a.cc:10:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   10 |     if(s.at[a]=='L'&&s.at[a-1]=='L') return checked[a]=check(s,a-2,checked);
      |                          ^
a.cc:11:1: warning: control reaches end of non-void function [-Wreturn-type]
   11 | }
      | ^
Language: C++

#include<bits/stdc++.h>
#define F(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
using namespace std;
const int N = 1e5+5;
template <class T> inline void read(T &n) {
	n=0;register char ch;while(!isdigit(ch=getchar()));
	for(n=ch^48;isdigit(ch=getchar());n=(n<<3)+(n<<1)+(ch^48));
}
char a[N];
int b[N],len,l,r,k;
int main() {
    gets(a); len=strlen(a);
    while(1) {
    	while(a[r]!='L')++r;
    	//printf("from %d to %d is R\n",l,r);
    	for(register int i=l;i<r;++i)if(r-i&1)++b[r-1];else ++b[r];
    	k=l=r;
		while(a[r]!='R'&&r!=len)++r;
		//printf("from %d to %d is L\n",l,r);
    	for(register int i=l;i<r;++i)if(i-k&1)++b[k-1];else ++b[k];
    	l=r;
		if(r==len)break;
    }
    for(register int i=0;i<len;++i)cout<<b[i]<<' ';
    return 0;
}



Compiler output:
a.cc: In function 'void read(T&)':
a.cc:6:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    6 |         n=0;register char ch;while(!isdigit(ch=getchar()));
      |                           ^~
a.cc: In function 'int main()':
a.cc:12:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
   12 |     gets(a); len=strlen(a);
      |     ^~~~
      |     getw
a.cc:16:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   16 |         for(register int i=l;i<r;++i)if(r-i&1)++b[r-1];else ++b[r];
      |                          ^
a.cc:20:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   20 |         for(register int i=l;i<r;++i)if(i-k&1)++b[k-1];else ++b[k];
      |                          ^
a.cc:24:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |     for(register int i=0;i<len;++i)cout<<b[i]<<' ';
      |                      ^
Language: C++

#include<cstdio>
#include<cstring>

int len,a[100001],i,j,vis[101][100001],sum;
char s[100001];

int main()
{
	gets(s);
	len=strlen(s);
	for(i=0;i<len;i++)
		a[i]=1;
	bool flag=0;
	while(1)
	{
		int temp[100001];
		for(i=0;i<len;i++)
			temp[i]=a[i];
		for(i=0;i<len;i++)
			if(s[i]=='R')
			{
				a[i+1]+=temp[i];
				a[i]-=temp[i];
			}
			else
			{
				a[i-1]+=temp[i];
				a[i]-=temp[i];
			}
		for(i=0;i<sum;i++)
			while(vis[i][j]==a[j])
			{
				if(j==len-1)
					flag=1;
				j++;
			}	
		if(flag)
			break;	
		for(i=0;i<len;i++)
			vis[sum][i]=a[i];
		sum++;
	}
	for(i=0;i<len;i++)
		printf("%d ",vis[sum-1][i]);
	printf("\n");
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
    9 |         gets(s);
      |         ^~~~
      |         getw
Language: C++

#include<iostream>
using namespace std;

int main(){
  string S;
  cin >> S;
  int N=strlen(S);
  int childr[N]={};
  
  int i, j;
  
  int nownum=0;
  int Lnum=0;
  int Rnum=0;
  
  while(nownum<N-1){
    i=0;
    while(S[i]=='R'){
      i+=1;
      Rnum+=1;
    }
    while(S[i]=='L'){
      i+=1;
      Lnum+=1;
    }
    nownum=nownum+Lnum+Rnum;
    childr[Rnum-1]=Rnum/2+(Lnum-Lnum/2);
    childr[Rnum]=Rnum+Lnum-childr[Rnum-1];
  }
  
  cout << childr;
  
  return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'strlen' was not declared in this scope
    7 |   int N=strlen(S);
      |         ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include<cstdio>
#include<cstring>

int len,a[100001],i,j,vis[101][100001],sum;
char s[100001];

int main()
{
	gets(s);
	len=strlen(s);
	for(i=0;i<len;i++)
		a[i]=1;
	bool flag=0;
	while(1)
	{
		int temp[100001];
		for(i=0;i<len;i++)
			temp[i]=a[i];
		for(i=0;i<len;i++)
			if(s[i]=='R')
			{
				a[i+1]+=temp[i];
				a[i]-=temp[i];
			}
			else
			{
				a[i-1]+=temp[i];
				a[i]-=temp[i];
			}
		for(i=0;i<sum;i++)
			while(vis[i][j]==a[j])
			{
				if(j==len-1)
					flag=1;
				j++;
			}	
		if(flag)
			break;	
		for(i=0;i<len;i++)
			vis[sum][i]=a[i];
		sum++;
	}
	for(i=0;i<len;i++)
		printf("%d ",vis[sum-1][i]);
	printf("\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
    9 |         gets(s);
      |         ^~~~
      |         getw
Language: C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
  char s[100001];
  char olds;
  int len;
  int index=0;
  int *line;
  scanf("%s\n",s);
  len=strlen(s);
  line=(int *)malloc(len*sizeof(int));
  for (int i=0;i<len;i++) line[i]=0;
  olds='R';
  for (int i=0;i<len;i++){
    if (olds!=s[i]){
      if (s[i]=='R'){
        line[index]+=(i-index+1)/2;
        line[index-1]+=(i-index)/2
        index=i;
      }
      if (s[i]=='L'){
        line[i]+=(i-index+1)/2;
        line[i-1]+=(i-index)/2
        index=i;
      }
    }
  }
  for (int i=0;i<len;i++){
    if (i<len-1) printf("%d ",line[i]);
    else printf("%d\n",line[i]);
  }
  free(line);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:19:35: error: expected ';' before 'index'
   19 |         line[index-1]+=(i-index)/2
      |                                   ^
      |                                   ;
   20 |         index=i;
      |         ~~~~~                      
main.c:24:31: error: expected ';' before 'index'
   24 |         line[i-1]+=(i-index)/2
      |                               ^
      |                               ;
   25 |         index=i;
      |         ~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int f[100005],p[100005],ans[100005],fp[100005];string s;
inline dfs(int i){
	if(fp[i])return p[i];
	fp[i]=1;
	if(f[i])return p[i]=i;
	if(s[i]=='L'){
		return p[i]=dfs(i-1);
	}else return p[i]=dfs(i+1);
}
int main(){
	cin>>s;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]=='R'&&s[i+1]=='L'){
			f[i]=1;
		}
	}
	for(int i=0;i<s.size();i++){
		dfs(i);
		if(abs(p[i]-i)%2==0)ans[p[i]]++;else ans[p[i]+1]++;
	}
	for(int i=0;i<s.size();i++)cout<<ans[i]<<' ';
	return 0;
}

Compiler output:
a.cc:4:8: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
    4 | inline dfs(int i){
      |        ^~~
Language: C

#include <stdio.h>
#include <string.h>
int main(){
  char s[100001];
  char olds;
  int len;
  int index=0;
  int *line;
  scanf("%s\n",s);
  len=strlen(s);
  line=(int *)malloc(len*sizeof(int));
  for (int i=0;i<len;i++) line[i]=0;
  olds='R';
  for (int i=0;i<len;i++){
    if (olds!=s[i]){
      if (s[i]=='R'){
        line[index]+=(i-index+1)/2;
        line[index-1]+=(i-index)/2
        index=i;
      }
      if (s[i]=='L'){
        line[i]+=(i-index+1)/2;
        line[i-1]+=(i-index)/2
        index=i;
      }
    }
  }
  for (int i=0;i<len;i++){
    if (i<len-1) printf("%d ",line[i]);
    else printf("%d\n",len[i]);
  }
  free(line);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:11:15: error: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
   11 |   line=(int *)malloc(len*sizeof(int));
      |               ^~~~~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
    2 | #include <string.h>
  +++ |+#include <stdlib.h>
    3 | int main(){
main.c:11:15: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   11 |   line=(int *)malloc(len*sizeof(int));
      |               ^~~~~~
main.c:11:15: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:18:35: error: expected ';' before 'index'
   18 |         line[index-1]+=(i-index)/2
      |                                   ^
      |                                   ;
   19 |         index=i;
      |         ~~~~~                      
main.c:23:31: error: expected ';' before 'index'
   23 |         line[i-1]+=(i-index)/2
      |                               ^
      |                               ;
   24 |         index=i;
      |         ~~~~~                  
main.c:30:27: error: subscripted value is neither array nor pointer nor vector
   30 |     else printf("%d\n",len[i]);
      |                           ^
main.c:32:3: error: implicit declaration of function 'free' [-Wimplicit-function-declaration]
   32 |   free(line);
      |   ^~~~
main.c:32:3: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:32:3: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
main.c:32:3: note: include '<stdlib.h>' or provide a declaration of 'free'
Language: C++

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#include "prettyprint.hpp"

string solve(int r, int l) {
  // cout << "solving " << r << " " << l << endl;
  int sum = r + l;
  if (sum % 2 == 0) {
    string ans = "";
    for (int i = 0; i < r - 1; i++) {
      ans += "0 ";
    }

    ans += to_string(sum / 2);
    ans += " ";
    ans += to_string(sum / 2);
    ans += " ";

    for (int i = 0; i < l - 1; i++) {
      ans += "0 ";
    }

    return ans;
  } else {
    string ans = "";
    for (int i = 0; i < r - 1; i++) {
      ans += "0 ";
    }

    string big = to_string(sum / 2 + 1);
    string small = to_string(sum / 2);

    // cout << "big " << big << endl;
    // cout << "small " << small << endl;
    if (r > l) {
      if (r % 2 == 0) {
        ans += small;
        ans += " ";
        ans += big;
        ans += " ";
      } else {
        ans += big;
        ans += " ";
        ans += small;
        ans += " ";
      }
    } else {
      if (l % 2 == 0) {
        ans += big;
        ans += " ";
        ans += small;
        ans += " ";
      } else {
        ans += small;
        ans += " ";
        ans += big;
        ans += " ";
      }
    }

    for (int i = 0; i < l - 1; i++) {
      ans += "0 ";
    }

    return ans;
  }
}

int main() {
  string S;
  cin >> S;
  vector<pair<int, int>> arr;

  string status = "readR";
  int lCount = 0;
  int rCount = 0;
  for (int i = 0; i < S.size(); i++) {
    char curChar = S[i];
    if (status == "readR") {
      if (curChar == 'R') {
        rCount++;
      } else {
        status = "readL";
        lCount++;
      }
    } else {
      if (curChar == 'L') {
        lCount++;
      } else {
        arr.emplace_back(rCount, lCount);
        rCount = 1;
        lCount = 0;
        status = "readR";
      }
    }
  }
  arr.emplace_back(rCount, lCount);

  for (int i = 0; i < arr.size(); i++) {
    cout << solve(arr[i].first, arr[i].second);
  }

  cout << endl;

  return 0;
}

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

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

using namespace std;

int main() {
    string s;
    cin >> s;
    vector<long long> m(s.size(), 1);
    vector<long long> b(s.size(), 0);
    for (size_t i = 0; i < 100; ++i) {
        for (size_t j = 0; j < 10; ++j) {
            b.assign(m.begin(), m.end());
            for (size_t k = 0; k < s.size(); ++k) {
                if (s[k] == 'L') {
                    b[k] -= m[k];
                    b[k - 1] += m[k];
                }  else if (s[k] == 'R') {
                    b[k] -= m[k];
                    b[k + 1] += m[k];
                }
            }
            m.assign(b.begin(), b.end());
        }
    }
    for (size_t i = 0; i < m.size(); ++i) {
        if (i != 0)
            cout << ' ';
        cout << b[i];
    }
    cout << endl;
    return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:34:14: error: expected '}' at end of input
   34 |     return 0;
      |              ^
a.cc:8:12: note: to match this '{'
    8 | int main() {
      |            ^
Language: C++

#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;
string S;

int main()
{
    cin >> S;
    int lastPlace[S.length] = {};

    for(int i = 0; i < S.length(); i++)
    {
        int nowPlace = i; 
        for(int j = 0; j < 100000; j++)
        {
            char nowS = S[nowPlace];
            if(nowS == 'L')
            {
                char leftS = S[nowPlace];
                if(leftS == 'R')
                {
                    if(j % 2 == 1)
                    {
                        nowPlace--;
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    nowPlace--;
                    continue;
                }
            }
            else
            {
                char rightS = S[nowPlace];
                if(rightS == 'L')
                {
                    if(j % 2 == 1)
                    {
                        nowPlace++;
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    nowPlace++;
                    continue;
                }
            }
        }
        lastPlace[nowPlace]++;
    }

    for(int i = 0; i < S.length(); i++)
    {
        cout << lastPlace[i]<< " ";
    }
    cout << endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:27: error: cannot convert 'std::__cxx11::basic_string<char>::length' from type 'std::__cxx11::basic_string<char>::size_type (std::__cxx11::basic_string<char>::)() const noexcept' {aka 'long unsigned int (std::__cxx11::basic_string<char>::)() const noexcept'} to type 'long unsigned int'
   12 |     int lastPlace[S.length] = {};
      |                           ^
a.cc:12:21: error: size of array 'lastPlace' has non-integral type '<unresolved overloaded function type>'
   12 |     int lastPlace[S.length] = {};
      |                   ~~^~~~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  string S;
  cin>>S;
  
  vector<pair<int,int>> A;
  int a=1,b=0;
  FOR(i,1,S.size()){
    if((S.at(i-1)=="L" && S.at(i)=="R") || i==S.size()-1){
      A.push_back(make_pair(a,b));
      a=0;
      b=0;
    }
    else if(S.at(i)=="R") a++;
    else if(S.at(i)=="L") b++;
  }
  
  vector<int> B;
  REP(i,A.size()){
    for(int j=1; j<A[i].first; j++) B.push_back(0);
    int p=(A[i].first+A[i].second+1)/2;
    B.push_back(p);
    B.push_back(A[i].first+A[i].second-p);
    for(int j=1; j<A[i].second; j++) B.push_back(0);
  }
  
  REP(i,B.size()) cout<<B.at(i)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   25 |     if((S.at(i-1)=="L" && S.at(i)=="R") || i==S.size()-1){
      |         ~~~~~~~~~^~~~~
a.cc:25:34: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   25 |     if((S.at(i-1)=="L" && S.at(i)=="R") || i==S.size()-1){
      |                           ~~~~~~~^~~~~
a.cc:30:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   30 |     else if(S.at(i)=="R") a++;
      |             ~~~~~~~^~~~~
a.cc:31:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   31 |     else if(S.at(i)=="L") b++;
      |             ~~~~~~~^~~~~
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

void write (int s) {
	if (s < 10) {
		putchar (s + '0');
		return ;
	}
	write (s / 10);
	putchar (s % 10 + '0');
	return ;
}

const int N = 100003;
char s[N];
int n, next[N], f[N];

int dfs (int x) {
	if (next[x]) return next[x];
	int y;
	if (s[x] == 'L') y = x - 1;
	else y = x + 1;
	if (s[x] != s[y]) return next[x] = x;
	return next[x] = dfs (y);
}

int main () {
	scanf ("%s", s + 1);
	n = strlen (s + 1);
	int i, x;
	for (i = 1; i <= n; ++i) {
		x = dfs (i);
		if (abs (x - i) & 1) {
			if (s[x] == 'L') --x;
			else ++x;
		}
		++f[x];
	}
	for (i = 1; i < n; ++i) write (f[i]), putchar (' ');
	write (f[n]), putchar ('\n');
	return 0;
}


Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:21:13: error: reference to 'next' is ambiguous
   21 |         if (next[x]) return next[x];
      |             ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:18:8: note:                 'int next [100003]'
   18 | int n, next[N], f[N];
      |        ^~~~
a.cc:21:29: error: reference to 'next' is ambiguous
   21 |         if (next[x]) return next[x];
      |                             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:18:8: note:                 'int next [100003]'
   18 | int n, next[N], f[N];
      |        ^~~~
a.cc:25:34: error: reference to 'next' is ambiguous
   25 |         if (s[x] != s[y]) return next[x] = x;
      |                                  ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:18:8: note:                 'int next [100003]'
   18 | int n, next[N], f[N];
      |        ^~~~
a.cc:26:16: error: reference to 'next' is ambiguous
   26 |         return next[x] = dfs (y);
      |                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:18:8: note:                 'int next [100003]'
   18 | int n, next[N], f[N];
      |        ^~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  string S;
  cin>>S;
  
  vector<pair<int,int>> A;
  int a=1,b=0;
  FOR(i,1,S.size()){
    if((S.at(i)=='R' && S.at(i-1)=='L') || i==S.size()-1;){
      A.push_back(make_pair(a,b));
      a=0;
      b=0;
    }
    else if(S.at(i)=='R') a++;
    else if(S.at(i)=='L') b++;
  }
  
  vector<int> B;
  REP(i,A.size()){
    for(int j=1; j<A[i].first; j++) B.push_back(0);
    int p=(A[i].first+A[i].second+1)/2;
    B.push_back(p);
    B.push_back(A[i].first+A[i].second-p);
    for(int j=1; j<A[i].second; j++) B.push_back(0);
  }
  
  REP(i,S.size()) cout<<B.at(i)<<" ";
  cout<<" "<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:58: error: expected primary-expression before ')' token
   25 |     if((S.at(i)=='R' && S.at(i-1)=='L') || i==S.size()-1;){
      |                                                          ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define int				long long
#define pb 				push_back
#define endl 			'\n'
#define F				first
#define S				second
#define mod				(ll)998244353
#define mp              make_pair
#define lb				lower_bound
#define ub				upper_bound
#define ios 			ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inf				1e18
#define mem(a,x)		for(int i=0;i<(int)(sizeof(a)/sizeof(a[0]));i++) a[i] = x;
#define trace(a)		cout<<(#a)<<" --> "<<a<<endl
#define trace2(a,b)		{trace(a);trace(b);}
#define trace3(a,b,c)	{trace(a);trace(b);trace(c);}
#define trace4(a,b,c,d) {trace(a);trace(b);trace(c);trace(d);}
#define M_PI           	3.14159265358979323846

signed main(){
	ios;
	string s;
	cin>>s;
	int n = s.length();
	int ans[n];
	mem(ans,0);
	int cnt1 = 0, cnt2 = 0, cnt;
	for(int i=0;i<n;i++){
		if(s[i] == 'R' && s[i+1] == 'L'){
			int j = i;
			int k = i+1;
			while(j>=0 && s[j] == 'R'){
				cnt1++; j--;
			}
			while(k<n && s[k] == 'L'){
				cnt2++; k++;
			}
			cnt = cnt1+cnt2;
			if(cnt1 == cnt2){
				ans[i] = cnt/2;
				ans[i+1] = cnt/2;
			}
			else if(cnt1>cnt2){
				diff = cnt1-cnt2;
				if(cnt1%2 == 0){
					ans[i+1] = (cnt+1)/2;
					ans[i] = cnt-ans[i+1];
				}
				else{
					ans[i] = (cnt+1)/2;
					ans[i+1] = cnt-ans[i];
				}
			}
			else{
				diff = cnt2-cnt1;
				if(cnt2%2 == 0){
					ans[i] = (cnt+1)/2;
					ans[i+1] = cnt-ans[i];
				}
				else{
					ans[i+1] = (cnt+1)/2;
					ans[i] = cnt-ans[i+1];
				}
			}
			cnt1 = 0; cnt2 = 0;
		}
	}
	for(int i=0;i<n;i++)
		cout<<ans[i]<<" ";
	return 0;
}






Compiler output:
a.cc: In function 'int main()':
a.cc:47:33: error: 'diff' was not declared in this scope
   47 |                                 diff = cnt1-cnt2;
      |                                 ^~~~
a.cc:58:33: error: 'diff' was not declared in this scope
   58 |                                 diff = cnt2-cnt1;
      |                                 ^~~~
Language: C++

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


int main(void){
  std::string s;
  std::cin >> s;

  std::vector<std::pair<int, int> > sections;
  char last = 'R';
  int count_r = 0;
  int count_l = 0;
  for(int i=0; i<s.size(); i++){
    if(last == 'L' && s[i] == 'R'){
      sections.push_back(std::make_pair(count_r, count_l));
      count_r = 1;
      count_l = 0;
    }else if(s[i] == 'R'){
      count_r++;
    }else{
      count_l++;
    }
    last = s[i];
  }
  sections.push_back(std::make_pair(count_r, count_l));

  for(const auto& elem: sections){
    
    for(int i=0; i<elem.first-1; i++){
      std::cout << "0 ";
    }
    std::cout << std::ceil(elem.first/2.0)+std::floor(elem.second/2.0) << " ";
    std::cout << std::floor(elem.first/2.0)+std::ceil(elem.second/2.0) << " ";
    for(int j=1; j<elem.second; j++){
      std::cout << "0 ";
    }
  }
    std::cout << std::endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:23: error: 'ceil' is not a member of 'std'
   34 |     std::cout << std::ceil(elem.first/2.0)+std::floor(elem.second/2.0) << " ";
      |                       ^~~~
a.cc:34:49: error: 'floor' is not a member of 'std'
   34 |     std::cout << std::ceil(elem.first/2.0)+std::floor(elem.second/2.0) << " ";
      |                                                 ^~~~~
a.cc:35:23: error: 'floor' is not a member of 'std'
   35 |     std::cout << std::floor(elem.first/2.0)+std::ceil(elem.second/2.0) << " ";
      |                       ^~~~~
a.cc:35:50: error: 'ceil' is not a member of 'std'
   35 |     std::cout << std::floor(elem.first/2.0)+std::ceil(elem.second/2.0) << " ";
      |                                                  ^~~~
Language: C++

s=input()+"R"
n=len(s)-1
ans=[0]*n
lenr=1
lenl=0
l_sta=-1
for i in range(1,n+1):
  if s[i-1]=="R" and s[i]=="R":
    lenr+=1
  if s[i-1]=="R" and s[i]=="L":
    ans[i-1]+=(lenr+1)//2
    ans[i]+=lenr//2
    l_sta=i
    lenr=0
    lenl=1
  if s[i-1]=="L" and s[i]=="L":
    lenl+=1
  if s[i-1]=="L" and s[i]=="R":
    ans[l_sta]+=(lenl+1)//2
    ans[l_sta-1]+=lenl//2
    lenr=1
ans_=[]    
for i in range(n):
  ans_.append(str(ans[i]))
print(" ".join(ans_))
  

Compiler output:
a.cc:1:1: error: 's' does not name a type
    1 | s=input()+"R"
      | ^
Language: C++

s = input()
n = len(s)

boundary = []
ans = [0] * n

for i in range(n-1):
    if s[i] == "L" and s[i+1] == "R":
        boundary.append(i)

boundary.append(n-1)

l = 0
for r in boundary:
    ## s[l ~~ r]
    middle = 0
    cnt = [0, 0]
    for x in range(l, r+1):
        cnt[x % 2] += 1
        if x < r and s[x] == "R" and s[x+1] == "L":
            middle = x

    ans[middle] = cnt[middle % 2]
    ans[middle + 1] = cnt[1 - (middle % 2)]
    l = r+1

print(" ".join(map(str, ans)))
    

Compiler output:
a.cc:15:5: error: stray '##' in program
   15 |     ## s[l ~~ r]
      |     ^~
a.cc:1:1: error: 's' does not name a type
    1 | s = input()
      | ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    reverse(res.begin(),res.end());
    return res;
}

ll a[550];

int main() {
  ll n,k;cin>>n>>k;
  rep(i,n) cin>>a[i];
  ll sum = 0;
  rep(i,n) sum+=a[i];
  vector<ll> vec = enum_divisors(sum);
  P b[550];
  rep(i,vec.size()) {
    rep(j,n) b[j]=P(a[j]%vec[i],vec[i]-(a[j]%vec[i]));
    ll minus=0;
    sort(b,b+n);
    int id=0;
    while(1) {
      if(minus+b[id].first<=k) {
	minus+=b[id].first;
	id++;
      } else {
	minus=0;
	break;
      }
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:57:6: error: expected '}' at end of input
   57 |     }
      |      ^
a.cc:44:21: note: to match this '{'
   44 |   rep(i,vec.size()) {
      |                     ^
a.cc:57:6: error: expected '}' at end of input
   57 |     }
      |      ^
a.cc:37:12: note: to match this '{'
   37 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(){
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	long long S = 0;
	for (int i = 0; i < N; i++){
		S += A[i];
	}
	vector<long long> f;
	for (int i = 1; (long long) i * i <= S; i++){
		if (S % i == 0){
			f.push_back(i);
			if ((long long) i * i < S){
				f.push_back(S / i);
			}
		}
	}
	long long ans = 0;
	for (long long x : f){
		vector<long long> r(N);
		for (int i = 0; i < N; i++){
			r[i] = A[i] % x;
		}
		sort(r.rbegin(), r.rend());
		long long sum = 0;
		for (int i = 0; i < N; i++){
			sum += r[i];
		}
		long long cnt = 0;
		for (int i = sum / x; i < N; i++){
			cnt += r[i];
		}
		if (cnt <= K){
			ans = max(ans, x);
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   30 |                 sort(r.rbegin(), r.rend());
      |                 ^~~~
      |                 short
Language: C++

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

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

vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll p=1;p*p<=n;++p){
    if(n%p==0){
      res.emplace_back(p);
      if(p*p!=n)res.emplace_back(n/p);
    }
  }
  return res;
}

signed main(){

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for(auto& ai:a)cin>>ai;

  assert(!(n==2&&k==3))

  ll asum = accumulate(begin(a),end(a),0ll);
  auto div = divisor(asum);
  sort(begin(div),end(div));

  auto solve = [&](ll d){
    auto r = a;
    for(auto& ri:r)ri %= d;
    sort(begin(r),end(r));
    auto sum = r;
    rep(i,n-1)sum[i+1]+=sum[i];
    ll op = 1<<28;
    rep(i,n){
      ll rv = (n-1-i)*d-(sum.back()-sum[i]);
      ll lv = sum[i];
      if(rv==lv)op=min(op,lv);
    }
    return op<=k;
  };

  ll ans = 1;
  for(auto d:div)if(solve(d))ans = d;
  cout<<(ans)<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:3: error: expected ';' before 'll'
   27 |   ll asum = accumulate(begin(a),end(a),0ll);
      |   ^~
a.cc:28:22: error: 'asum' was not declared in this scope
   28 |   auto div = divisor(asum);
      |                      ^~~~
Language: C++

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

const int maxn = 505;

int n, k, sum, ans;
int a[maxn];
vector < int > d;

signed main () {
    scanf("%lld %lld", &n, &k);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &a[i]);
        sum += a[i];
    }
    for (int i = 1; i * i <= sum; ++i) {
        if (sum % i == 0) {
            d.push_back(i);
            d.push_back(sum / i);
        }
    }
    for (int x: d) {
        vector < int > b;
        int add = 0, rm = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] % x) {
                b.push_back(a[i] % x);
                add += x - b.back();
            }
        }
        sort(b.begin(), b.end());
        int cur = add;
        for (int i = 0; i < int(b.size()); ++i) {
            rm += b[i];
            add -= x - b[i];
            cur = min(cur, max(rm, add));
        }
        if (cur <= k)
            ans = max(x, ans);
    }
    printf("%lld\n", ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:34:29: note: in expansion of macro 'int'
   34 |         for (int i = 0; i < int(b.size()); ++i) {
      |                             ^~~
a.cc:34:28: error: expected ';' before 'long'
   34 |         for (int i = 0; i < int(b.size()); ++i) {
      |                            ^
      |                            ;
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:34:29: note: in expansion of macro 'int'
   34 |         for (int i = 0; i < int(b.size()); ++i) {
      |                             ^~~
a.cc:34:28: error: expected ')' before 'long'
   34 |         for (int i = 0; i < int(b.size()); ++i) {
      |             ~              ^
      |                            )
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:34:29: note: in expansion of macro 'int'
   34 |         for (int i = 0; i < int(b.size()); ++i) {
      |                             ^~~
a.cc:34:46: error: 'i' was not declared in this scope
   34 |         for (int i = 0; i < int(b.size()); ++i) {
      |                                              ^