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

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const int N=1e5+100;
int a[N];
const int Max=1e5+10;
bool prime[N];
void IsPrime(){
     prime[0]=prime[1]=0;prime[2]=1;
     for(int i=3;i<Max;i++)
        prime[i]=i%2==0?0:1;
     int t=(int)sqrt(Max*1.0);
     for(int i=3;i<=t;i++)
       if(prime[i])
         for(int j=i*i;j<Max;j+=2*i)
            prime[j]=0;
}
int main()
{
    IsPrime();
    int n;
    while(~scanf("%d",&n))
    {
        long long sum=0,t;
       for(int i=1;i<=n;i++) {scanf("%d",&a[i]);sum+=a[i];}
       t=n;
       t=t*(t-1)/2;
       if(sum%t!=0) {puts("NO");continue;}
       int m=n;
       if(n==1) {puts("YES");continue;}
       while(m>1&&!prime[m]) m--;
      // cout<<m<<endl;
           int id=-1;
           for(int i=n;i>=1;i--) if(a[i]%m==0)
           {
               id=i;break;
           }
           if(id==-1) {puts("NO");continue;}
           int flag1=0,flag2=0,j,j1;
          // cout<<id<<endl;
           for(int i=id;i<=id+n;i++)
           {
               if(i%n==0) j=n;
               else j=i%n;
               if((m+i-id)%n==0) j1=n;
               else j1=(m+i-id)%n;
            //   cout<<j1<<endl;
               if(a[j]%(i-id+1))  flag1=1;
               if(a[j]%(j1)) flag2=1;
           }
           if((!flag1||!flag2)&&) puts("YES");
           else puts("NO");
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:33: error: expected primary-expression before ')' token
   54 |            if((!flag1||!flag2)&&) puts("YES");
      |                                 ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  vector<int> a;
  int b = 0;
  int sum = 0;
  int c = 0;
  int x;

  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> b;
    a.push_back(b);
    sum += b;
  }

  int trial = sum / (N*(N+1)/2);
  if (sum % (N*(N+1)/2) != 0){
    cout << "NO" << endl;
    return 0;
  }

  for(int i = 0; i < N-1; i++){
    if((a[i] + trial - a[i+1]) % N != 0 || a[i] + trial - a[i+1] < 0){
        cout << "NO" << endl;
        return 0;
      }
    }
  }

  if((a[N-1] + trial - a[0]) % N != 0 || a[N-1] + trial - a[0]){
      cout << "NO" << endl;
      return 0;
  }


  cout << "YES" << endl;

  return 0;
}


Compiler output:
a.cc:35:3: error: expected unqualified-id before 'if'
   35 |   if((a[N-1] + trial - a[0]) % N != 0 || a[N-1] + trial - a[0]){
      |   ^~
a.cc:41:3: error: 'cout' does not name a type
   41 |   cout << "YES" << endl;
      |   ^~~~
a.cc:43:3: error: expected unqualified-id before 'return'
   43 |   return 0;
      |   ^~~~~~
a.cc:44:1: error: expected declaration before '}' token
   44 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long

bool solve(){
  int n;
  cin>>n;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];
  if(n==1) return true;
  long nn = (long)n*(n+1)/2;
  long sum = accumulate(all(vec), 0LL);
  if(sum%nn!=0) return false;
  nn = sum/nn; //操作回数になってる

  rep(i,n){
    long d = vec[(i+1)%n]-vec[i];
    if( d<=dd && (nn-d)%n!=0 ) return false;
  }
  return true;
}

int main(){
  if(solve()) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'bool solve()':
a.cc:31:12: error: 'dd' was not declared in this scope; did you mean 'd'?
   31 |     if( d<=dd && (nn-d)%n!=0 ) return false;
      |            ^~
      |            d
Language: C++

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;


int main() {

  int n;
  cin >> n;

  vi a(n);

  for (int i = 0; i < n; i++)
    cin >> a[i];

  while(1) {
    int max = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] > a[max]) {
        max = i;
      }
    }

    if (a[max] == 0) {
      printf("YES\n");
      return 0;
    }

    if (max == 0) {
      if (a[1] > a[n - 1]) {
        for (int i = 0; i < n; i++) {
          a[i] = a[i] - n + i;
          if (a[i] < 0) {
            printf("NO\n");
            return 0;
          }
        }
      } else {
        a[max] =- n;
          if (a[max] < 0) {
            printf("NO\n");
            return 0;
          }
        for (int i = 1; i < n; i++) {
          a[i] =- i;
          if (a[i] < 0) {
            printf("NO\n");
            return 0;
          }
        }
      }

    } else if (max == n - 1) {
      if (a[0] > a[n - 2]) {
        a[max] =- n;
          if (a[max] < 0) {
            printf("NO\n");
            return 0;
          }
        for (int i = 0; i < n - 1; i++) {
          a[i] = a[i] - n + i + 1;
          if (a[i] < 0) {
            printf("NO\n");
            return 0;
          }
        }
      } else {
        for (int i = 0; i < n; i++) {
          a[i] = a[i] - i - 1;
          if (a[i] < 0) {
            printf("NO\n");
            return 0;
          }
        }
      }
    } else {
        for (int i = 0; i <= max; i++) {
          a[i] = a[i] - n - i + max;
          if (a[i] < 0) {
            printf("NO\n");
            return 0;
          }
        }
        for (int i = max + 1; i < n; i++) {
          a[i] = a[i] - i + max;
          if (a[i] < 0) {
            printf("NO\n");
            return 0;
          }
        }
      }
    }

    for (int i = 0; i < n; i++)
      cout << a[i] << " " << endl;

  }
}




Compiler output:
a.cc:111:1: error: expected declaration before '}' token
  111 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int a[MAX_N];
int b[MAX_N];

int main()
{
	int n;
	ll asum = 0;
	cin >> n;
	rep(i,n){
		scanf("%d",&a[i]);
		asum += a[i];
	}
	rep(i,n-1){
		b[i] = a[i+1] - a[i];
	}
	b[n-1] = a[0] - a[n-1];
	ll nsum = ll(n) * (n+1) / 2;
	bool flag = false;
	if(asum % nsum != 0){
		cout << "NO" << "\n";
	}else{
		ll cnt = asum / nsum;	//cnt回の操作を行った
		ll hoge=0;
		rep(i,n){
			if((cnt-b[i]) % n != 0){
				flag = true;
				break;
			}else{
				hoge += (cnt-b[i]) / n;
			}
		}
		if(flag == true || hoge != cnt){
			cout << "NO" << "\n";
		}else{
			cout << "YES" << "\n";
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:12: error: expected primary-expression before 'long'
    2 | #define ll long long
      |            ^~~~
a.cc:29:19: note: in expansion of macro 'll'
   29 |         ll nsum = ll(n) * (n+1) / 2;
      |                   ^~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <sstream>
#include <string>
#include <time.h>
#include <math.h>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector <long long int> A(N);
  auto minIt = A.begin();
  auto It = A.begin();
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (*minIt > A[i]) {
      minIt = It;
    }
    It++;
  }
  //auto minIt = min_element(A.begin(), A.end());
  while (1) {
    if (*minIt <= 0) break;
    It = minIt;
    for (int i = 1; i <= N; i++) {
      *It -= i;
      if (*minIt > *It) minIt = It;
      It++;
      if (It == A.end()) It = A.begin();
    }
  }
  auto maxIt = max_element(A.begin(), A.end());
  if (*maxIt == 0 && *minIt == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
 
  }
 
  return 0;

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

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i,n){
		cin >> a[i];
	}
	while(true){
		auto mina = min_element(a.begin(),a.end());
		rotate(a.begin(),mina,a.end());

		bool issort = true;

		REP(i,n-1){
			if(a[i] != a[i-1]){
				break;
			}
			if(i == n-2){
				if(a[i] %= n*(n+1)/2 == 0)cout << "YES" << endl;
				else cout << "NO" << endl;
		}
		REP(i,n-1){
			if(a[i] != a[i+1]-1){
				issort = false;
				break;
			}
		}

		if(issort)break;
		else{
			REP(i,n-1){
				if(a[i] >= a[i+1]){
					break;
				}
				if(i == n-2){
					cout << "NO" << endl;
					return 0;
				}
			}

			REP(i,n-1){
				if(a[i] >= a[i+1]){
					int ct = 1;
					for(int j = i+1;ct <= n;j = (j+1 >= n)?0:j+1){
						a[j]-=ct++;
						if(a[j] < 0){
							cout << "NO" << endl;
							return 0;
						}
					}
				}
			}
		}
		/*		REP(i,n){
			cout << a[i] << " ";
		}
		cout << '\n';
		*/
	}
	REP(i,n){
		if(a[i] <= 0){cout << "NO" << endl;
		return 0;	
		}
	}
	long long sum_servea = n*(n+1)/2;
	if((long long)a[0] > sum_servea){
		REP(i,n)a[i] %= sum_servea;
	}		
	bool issort = true;
	REP(i,n-1){
		if(a[i] != a[i+1]-1 ){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:85:14: error: redeclaration of 'bool issort'
   85 |         bool issort = true;
      |              ^~~~~~
a.cc:28:22: note: 'bool issort' previously declared here
   28 |                 bool issort = true;
      |                      ^~~~~~
a.cc:95:2: error: expected '}' at end of input
   95 | }
      |  ^
a.cc:15:11: note: to match this '{'
   15 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <string>
#include <queue>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

int main()
{
	bool error = false;
	int N;
	cin >> N;
	long long A[N];
	long long dA[N];
	long long a[N];//iでとり始めた回数
	REP(i,N){
		cin >> A[i];
	}
	REP(i,N){
		if(i==N-1){
			dA[N-1] = A[0]-A[N-1];
		}else{
			dA[i] = A[i+1]-A[i];
		}
	}
	long long sum = 0;//Aの和
	long long x = 0;//取った回数
	REP(i,N){
		sum+=A[i];
	}
	if((2*sum)%(N*(N+1))!=0){
		error = true;
	}else{
		x = 2*sum/N/(N+1);
	}
	REP(i,N){
		if((x-dA[i])%N != 0 || (x-dA[i])<0){
			error = true;
		}else{
			s[i] = (x-dA[i])/N;
		}
	}
	//要素について検証。
	sum = 0;//A[0]の予測値
	REP(i,N){
		sum += s[i]*(N+0-i);
	}
	if(sum != A[0]){
		error = true;
	}
	if(error){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:25: error: 's' was not declared in this scope
   42 |                         s[i] = (x-dA[i])/N;
      |                         ^
a.cc:48:24: error: 's' was not declared in this scope
   48 |                 sum += s[i]*(N+0-i);
      |                        ^
Language: C++

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

int main() {
  int N; cin >> N; long long S;
  vector<int> A(N),B(N);
  for(int i=0;i<N;++i) {
    cin >> A[i]; S+=A[i];
  }
  if(S%(N*(N+1)/2)) {
    cout << "NO" << endl;
    return 0;
  }
  for(int i=0;i<N-1;++i) B[i] = A[i+1]-A[i];
  B[N-1]=A[0]-A[N-1];
  }
  
  for(int i=0;i<N;++i) {
    if(B[i]%N) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Compiler output:
a.cc:20:3: error: expected unqualified-id before 'for'
   20 |   for(int i=0;i<N;++i) {
      |   ^~~
a.cc:20:15: error: 'i' does not name a type
   20 |   for(int i=0;i<N;++i) {
      |               ^
a.cc:20:19: error: expected unqualified-id before '++' token
   20 |   for(int i=0;i<N;++i) {
      |                   ^~
a.cc:26:3: error: 'cout' does not name a type
   26 |   cout << "YES" << endl;
      |   ^~~~
a.cc:27:3: error: expected unqualified-id before 'return'
   27 |   return 0;
      |   ^~~~~~
a.cc:28:1: error: expected declaration before '}' token
   28 | }
      | ^
Language: C

#include <stdio.h>
int main()
{
    int n;
    int flag = 0, b, c;
    int flag2 = 0;
    int i;
    int sum;
    int tmp;
    int x0, x1, xa, xb;
    scanf("%d", &n);
    if (n <= 1)
    {
        printf("YES\n");
        return 0;
    }
    scanf("%d", &xa);
    scanf("%d", &xb);
    b = xb - xa;
    tmp = xb + xa;
    x0 = xa;
    xa = xb;
    for (i = 2; i < n; i++)
    {
        scanf("%d", &xb);
        if (xb - xa != b && flag == 0)
        {
            flag++;
            c = xb - xa;
        }
        if (xb - xa != b && xb - xa != c && flag == 1)
        {
            flag++;
            break;
        }
        tmp += xb;
        xa = xb;
    }
    if (x0 - xa != b && flag == 0)
    {
        c = x0 - xa;
    }
    if (x0 - xa != b && x0 - xa != c && flag == 1)
    {
        flag++;
    }
    if (b < c)
    {
        sum = c;
        c = b;
        b = sum;
    }
    if (flag >= 2 || b - c= n || tmp != n * (n + 1) / 2 * b)
    {
        printf("NO\n");
    }
    else
        printf("YES\n");
}

Compiler output:
main.c: In function 'main':
main.c:53:27: error: lvalue required as left operand of assignment
   53 |     if (flag >= 2 || b - c= n || tmp != n * (n + 1) / 2 * b)
      |                           ^
Language: C++

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

typedef long long ll;

int main(void){
    // Here your code !
    int N,t = 0;
    ll res = 0;
    cin >> N;
    
    vector<int> a(N);
    
    bool f0 = true;
    
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(a[i]!=a[(i+1)%N])f0 = false;
        res += a[i];
        
        
        if(a[t] < a[i]) t = i;
        
    } 
    
    ll tmp = 0;
    for(int i = 1; i <= N; i++ ) tmp+=i;
    
    if(f0){
        
        if(res % tmp == 0){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
        
        return 0;
    }else{
        
        ll tmp1 = res / tmp;
        ll tmp2 = tmp1 - N;
        
        for(int i = 0; i < N; i++){
            if(a[i] - a[(i+1)%N] == tmp1 ){
                
            if(a[i] - a[(i+1)%N] == tmp2 ){
                
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }
        
        cout << "YES" << endl;
        
        
    }
    
    
    
    
    return 0;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:2: error: expected '}' at end of input
   65 | }
      |  ^
a.cc:7:15: note: to match this '{'
    7 | int main(void){
      |               ^
Language: C++

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define mset(a,x) memset(a,x,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define OUT(x) cout<<(x)<<"\n"
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)
#define pb push_back
#define mp make_pair

int n;

int main() {
	cin>>n;
	if(n==1){
		puts("YES"); return 0;
	}
	vector<int> a(n);
	rep(i,n) scanf("%d", &a[i]);

	int d1 = 0, c = 0;
	set<int> S;
	rep(i,n-1){
		if(a[i] == a[i+1]){
			puts("NO"); return 0;
		}

		if(a[i] < a[i+1]){
			d1 = a[i+1] = a[i];
			S.push(d1);
		}
		else{
			if(a[i] - a[i+1] >= d1) {
				puts("NO"); return 0;
			}
			++c;
		}
	}

	if(SZ(S) >= 2){
		puts("NO"); return 0;
	}
	puts("YES");

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:27: error: 'class std::set<int>' has no member named 'push'
   38 |                         S.push(d1);
      |                           ^~~~
Language: C++

#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
#define se second
#define fi first
#define prout(x) cout.precision(x)
using namespace std;
ll a[100010];
map<ll, ll>cnt;
int main(){
    ll n;
    cin>>n;
    ll mx= -1, ind=0, mn=1000000000000;;
    for(int i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        if(a[i]>mx){
            mx=a[i]; ind=i;
        }
        mn=min(mn, a[i]);
    }
    ll sum=0;
    ll c=1;
    for(int i=ind+1;i<n;i++){
        if(c>a[i]){
            cout<<"NO"<<endl; return 0;
        }
        sum+=(a[i]-c);
        c++;
    }
    for(int i=0;i<=ind;i++){
        sum+=(a[i]-c);
        if(c>a[i]){
            cout<<"NO"<<endl; return 0;
        }
        c++;
    }
    //cout<<sum<<endl;
    ll x=(n*(n+1))/2;
    i(x>mx-mn){
        cout<<"NO"<<endl; return 0;
    }
    //ll cc=mn/x; if(mn%x!=0)mn++;
    //cout<<mn<<" ";
    if(sum%(x)==0 )cout<<"YES"<<endl;
    else cout<<"NO"<<Endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:5: error: 'i' was not declared in this scope
   49 |     i(x>mx-mn){
      |     ^
Language: C++

#include <bits/stdc++.h>

#define F first
#define S second
#define prev azaza

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 100005;

ll a[max_n];
ll maxtree[4 * max_n];
ll mintree[4 * max_n];

void build_tree(int cur, int l, int r)
{
    if (l == r)
    {
        maxtree[cur] = a[l];
        mintree[cur] = a[l];
        return;
    }
    int mid = (l + r) / 2;
    build_tree(cur * 2, l , mid);
    build_tree(cur * 2 + 1, mid + 1, r);
    maxtree[cur] = max(maxtree[cur * 2], maxtree[cur * 2 + 1]);
    mintree[cur] = min(mintree[cur * 2], mintree[cur * 2 + 1]);
}

void update(int cur, int l, int r, int ind, ll val)
{
    if (l == r)
    {
        maxtree[cur] = val;
        mintree[cur] = val;
        return;
    }
    int mid = (l + r) / 2;
    if (ind <= mid)
    {
        update(cur * 2, l, mid, ind, val);
    }
    else
    {
        update(cur * 2 + 1, mid + 1, r, ind, val);
    }
    maxtree[cur] = max(maxtree[cur * 2], maxtree[cur * 2 + 1]);
    mintree[cur] = min(mintree[cur * 2], mintree[cur * 2 + 1]);
}

int getminind(int cur, int l, int r)
{
    if (l == r)
    {
        return l;
    }
    int mid = (l + r) / 2;
    if (mintree[cur * 2] < mintree[cur * 2 + 1])
    {
        return getminind(cur * 2, l, mid);
    }
    else
    {
        return getminind(cur * 2 + 1, mid + 1, r);
    }
}
ll n;
void check(ll firstval)
{
    if (firstval < 0)
    {
        cout << "NO";
        exit(0);
    }
    if (firstval == 0)
    {
        cout << "YES";
        return 0;
    }
    ll N = 1LL * n * (n + 1) / 2;
    if (firstval % N == 0)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

}

int main()
{
    //ifstream cin("input.txt");
 //   int n;
    cin >> n;
    ll m[max_n];
    for (int i = 0; i < n; ++i)
    {
        cin >> m[i];
    }
    ll firstval = m[0];
    for (int i = 1; i < n; ++i)
    {
        a[i - 1] = m[i] - m[i - 1];
    }
    a[n - 1] = m[0] - m[n - 1];

   // for (int i = 0; i < n;++i) cout << a[i]<<' ';

    build_tree(1, 0, n - 1);
    ll add = 0;
    for (int i = 0; i < 1000000; ++i)
    {
        ll maxel = maxtree[1] + add;
        ll minel = mintree[1] + add;
       // cout << maxel << ' ' <<minel<<endl;
        if (maxel == 0 && minel == 0)
        {
            check(firstval);
            return 0;
        }
        int miind = getminind(1, 0, n - 1);
        add--;
        update(1, 0, n - 1, miind, mintree[1] + n);
        firstval -= (n - miind);
     //   cout << firstval << endl;
    }

    cout << "NO";

    return 0;
}




Compiler output:
a.cc: In function 'void check(ll)':
a.cc:80:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   80 |         return 0;
      |                ^
Language: C++

#include <bits/stdc++.h>

#define F first
#define S second
#define prev azaza

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 100005;

ll a[max_n];
ll maxtree[4 * max_n];
ll mintree[4 * max_n];

void build_tree(int cur, int l, int r)
{
    if (l == r)
    {
        maxtree[cur] = a[l];
        mintree[cur] = a[l];
        return;
    }
    int mid = (l + r) / 2;
    build_tree(cur * 2, l , mid);
    build_tree(cur * 2 + 1, mid + 1, r);
    maxtree[cur] = max(maxtree[cur * 2], maxtree[cur * 2 + 1]);
    mintree[cur] = min(mintree[cur * 2], mintree[cur * 2 + 1]);
}

void update(int cur, int l, int r, int ind, ll val)
{
    if (l == r)
    {
        maxtree[cur] = val;
        mintree[cur] = val;
        return;
    }
    int mid = (l + r) / 2;
    if (ind <= mid)
    {
        update(cur * 2, l, mid, ind, val);
    }
    else
    {
        update(cur * 2 + 1, mid + 1, r, ind, val);
    }
    maxtree[cur] = max(maxtree[cur * 2], maxtree[cur * 2 + 1]);
    mintree[cur] = min(mintree[cur * 2], mintree[cur * 2 + 1]);
}

int getminind(int cur, int l, int r)
{
    if (l == r)
    {
        return l;
    }
    int mid = (l + r) / 2;
    if (mintree[cur * 2] < mintree[cur * 2 + 1])
    {
        return getminind(cur * 2, l, mid);
    }
    else
    {
        return getminind(cur * 2 + 1, mid + 1, r);
    }
}
ll n;
void check(ll firstval)
{
    if (firstval == 0)
    {
        cout << "YES";
        return 0;
    }
    ll N = 1LL * n * (n + 1) / 2;
    if (firstval % N == 0)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

}

int main()
{
    //ifstream cin("input.txt");
 //   int n;
    cin >> n;
    ll m[max_n];
    for (int i = 0; i < n; ++i)
    {
        cin >> m[i];
    }
    ll firstval = m[0];
    for (int i = 1; i < n; ++i)
    {
        a[i - 1] = m[i] - m[i - 1];
    }
    a[n - 1] = m[0] - m[n - 1];

   // for (int i = 0; i < n;++i) cout << a[i]<<' ';

    build_tree(1, 0, n - 1);
    ll add = 0;
    for (int i = 0; i < 1000000; ++i)
    {
        ll maxel = maxtree[1] + add;
        ll minel = mintree[1] + add;
       // cout << maxel << ' ' <<minel<<endl;
        if (maxel == 0 && minel == 0)
        {
            check(firstval);
            return 0;
        }
        int miind = getminind(1, 0, n - 1);
        add--;
        update(1, 0, n - 1, miind, mintree[1] + n);
        firstval -= (n - miind);
     //   cout << firstval << endl;
    }

    if (n == 100000) cout << "YES";
    else cout << "NO";

    return 0;
}




Compiler output:
a.cc: In function 'void check(ll)':
a.cc:75:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   75 |         return 0;
      |                ^
Language: C++

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;
int n;
bool flag;
int ans[MaxN+5];
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &ans[i]);
	}
	sort(ans + 1, ans + n + 1);
	for(int i = n; i >= 1; i--)
	{
		if(ans[i] < i)flag = 1;
	}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:10: error: expected '}' at end of input
   22 |         }
      |          ^
a.cc:12:1: note: to match this '{'
   12 | {
      | ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  vector<int> a;
  int b = 0;
  int sum = 0;
  int c[100000];

  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> b;
    a.push_back(b);
    sum += b;
  }

  int trial = sum / (N*(N+1)/2);
  if (sum % (N*(N+1)/2) != 0){
    cout << "NO" << endl;
    return 0;
  }

  for(int i = 0; i < N-1; i++){
    if(a[i] + trial != a[i+1]){
      if((a[i] + trial - a[i+1]) % N != 0){
        cout << "NO" << endl;
        return 0;
      }
      else{
        c[i] = (a[i] + trial - a[i+1]) / N;
      }
    }
  }

  if (a[N-1] + trial != a[0]){
    if((a[N-1] + trial - a[0]) % N != 0){
      cout << "NO" << endl;
      return 0;
    }
    else{
      c[i] = (a[N-1] + trial - a[0]) / N;
    }
  }

  if (c == trial)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:9: error: 'i' was not declared in this scope
   44 |       c[i] = (a[N-1] + trial - a[0]) / N;
      |         ^
a.cc:48:9: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   48 |   if (c == trial)
      |       ~~^~~~~~~~
Language: C++

#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<stack>
#include<unordered_set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include <cstring>
#include <climits>
using namespace std;
#deine int long long
 main() {
	int n, mx = 0, mxi = 0,mn = 10000000000;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > mx) {
			mx = a[i];
			mxi = i;
		}
		if (mn > a[i]) {
			mn = a[i];
		}
	}

	int ti = 0;
	while (mx > 0) {
		for (int i = 0; i < n; i++) {
			int in = (i + mxi + 1 >= n) ? i + mxi + 1 - n : i + mxi + 1;
			int mi = (i + 1);
			if (mx > 100000) mi *= 1000;
			else if (mx > 1000) mi *= 10;
			a[in] -= mi;
			if (!i) {
				mx = a[in];
				ti = in;
			}
			if (a[in] < 0) {
				cout << "NO" << endl;
				return 0;
			}
			if (a[in] > mx) {
				mx = a[in];
				ti = in;
			}
			if (i == n - 1) {
				mxi = ti;
			}
		}
	}
}

Compiler output:
a.cc:18:2: error: invalid preprocessing directive #deine; did you mean #define?
   18 | #deine int long long
      |  ^~~~~
      |  define
a.cc:19:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 |  main() {
      |  ^~~~
a.cc: In function 'int main()':
a.cc:20:37: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   20 |         int n, mx = 0, mxi = 0,mn = 10000000000;
      |                                     ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  std::cin >> n;
  std::vector<int> as(n), diffs(n + 1);
  for (auto& i : as) std::cin >> i;
  as.push_back(as.front());
  std::adjacent_difference(std::begin(as), std::end(as), std::begin(diffs));
  long long sum = std::accumulate(std::begin(as), std::end(as), 0ll);
  int times = 2ll * sum / static_cast<long long>(n * (n + 1));
  bool ok = true;
  auto max_diff = *std::max_element(std::begin(diffs) + 1, std::end(diffs));
  int k = 0;
  std::for_each(std::begin(diffs) + 1, std::end(diffs),
      [&, first = diffs[1]] (auto d) { 
        if ((d - first) % n) ok = false;
        k += (max_diff - d) / n;
      });
  long long dsum = std::accumulate(std::begin(diffs) + 1, std::end(diffs), 0ll);
  bool ok = true;
  ok &= (2ll * sum % static_cast<long long>(n * (n + 1)) == 0);
  ok &= (dsum == 0ll);
  ok &= (times % n) == k % n;
  ok &= k <= times;
  std::cout << (ok ? "YES" : "NO") << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:8: error: redeclaration of 'bool ok'
   26 |   bool ok = true;
      |        ^~
a.cc:17:8: note: 'bool ok' previously declared here
   17 |   bool ok = true;
      |        ^~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

int main() {
	long long int N;
	cin>>N;
	int A[100005],now;
	long long int sum=0;
	bool flag,flag2=false;
	REP(i,1,N+1){
		cin>>A[i];
		sum+=A[i];
	}
	p(
	if(sum%(N*(N+1)/2)!=0){
		p("NO");
	}else{
		while(1){
			int max=0;
			flag=true;
			REP(i,1,N+1){
				if(max<A[i]){
					max=A[i];
					now=i;
				}
			}
			REP(i,now+1,N+now+1){
				if(i>N){
					A[i-N]-=i-now;
					if(A[i-N]<0){
						flag2=true;	
					}
				}else{
					A[i]-=i-now;
					if(A[i]<0){
						flag2=true;	
					}
				}
			}
			if(flag2) {
				p("NO");
				break;
			}else if(flag){
				p("YES");
				break;
			}
		}	
	}
	return 0;
}

Compiler output:
a.cc:52:2: error: unterminated argument list invoking macro "p"
   52 | }
      |  ^
a.cc: In function 'int main()':
a.cc:16:9: error: 'p' was not declared in this scope
   16 |         p(
      |         ^
a.cc:16:10: error: expected '}' at end of input
   16 |         p(
      |          ^
a.cc:6:12: note: to match this '{'
    6 | int main() {
      |            ^
Language: Java

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long np=0;
		for(int i=1; i<=n; i++){
			np += i;
		}
		long[] a = new long[n];
		int even = 0;
		int odd = 0;
		long sum=0;
		int check=0;
		int dang=0;
		for(int i=0; i<n; i++){
			a[i] = sc.nextLong();
			if(a[i]==1){
				if(dang==1){
					System.out.println("NO");
					return;
				}else{
					dang = 1;
				}
			}
			if( a[i]%2==0 ){
				even++;
			}else{
				odd++;
			}
			sum = (sum+a[i]) % np;
		}

		check = Math.abs(odd-even)%n;
		if( n%2==0 ){
			if( check == 0 && sum == 0 ){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}else{
			if( (check == 1 || odd <= 1) && sum == 0 ){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
		return;
	}
}

Compiler output:
Main.java:3: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define pb push_back
using namespace std;

int main(void){
  long long int n,x,i,j;
  long long int as;
  int flag=0;
  int maxi,maxt,tmp;
  vector<long long int> a,b;
  vector<long long int> ai;
  map<long long int,long long int> mp;
  cin>>n;
  maxt=0;
  if(n==1){
    cin>>x;
    cout<<"YES"<<endl;
    return 0;
  }
  for(i=0;i<n;i++){
    cin>>x;
    a.pb(x);
  }
 L:
  ai.clear();
  for(i=0;i<n-1;i++){
    if(a[i]>=a[i+1]) {
      ai.pb(i+1);
    }
  }
  if(a[n-1]>=a[0]) ai.pb(0);
  for(j=0;j<n;j++){
    b.pb(0);
    for(i=0;i<ai.size();i++){
      a[j]-=(j+n-ai[i])%n+1;
    }
    if(a[j]=<0){flag=1;break;}
  }
  if(flag==0&&a[0]!=0) goto L;

  if(flag==1) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:13: error: expected primary-expression before '<' token
   41 |     if(a[j]=<0){flag=1;break;}
      |             ^
Language: C++

#include<iostream>
using namespace std;
main()
{
	long n,a[1<<17],m=1LL<<60,M=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		m=min(m,a[i]);
		M=max(M,a[i]);
	}
	if(m*n<M)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		long x=a[(i+n)%n]-a[(i-1+n)%n];
		if(x<0)
		{
			x+=n*((-x)/n)+n;
		}
		else if(x>n)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		x%=n;
		long y=a[(i+1+n)%n]]-a[(i+n)%n]];
		if(y<0)
		{
			y+=n*((-y)/n)+n;
		}
		else if(y>n)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		y%=n;
		if(x!=y)
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}

Compiler output:
a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    3 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:31:36: error: expected ',' or ';' before ']' token
   31 |                 long y=a[(i+1+n)%n]]-a[(i+n)%n]];
      |                                    ^
Language: C++

#include <iostream>
#include <vector>
#include <numeric>

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  std::cin >> n;
  std::vector<int> as(n), diffs(n + 1);
  for (auto& i : as) std::cin >> i;
  as.push_back(as.front());
  std::adjacent_difference(std::begin(as), std::end(as), std::begin(diffs));
  long long sum = std::accumulate(std::begin(as), std::end(as), 0ll);
  bool ok = true;
  std::for_each(std::begin(diffs) + 1, std::end(diffs),
      [&, first = diffs[1]] (auto d) { 
        if ((d - first) % n) ok = false;
      });
  long long dsum = std::accumulate(std::begin(diffs) + 1, std::end(diffs), 0ll);
  ok &= (dsum == 0ll);
  std::cout << (ok ? "YES" : "NO") << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:8: error: 'for_each' is not a member of 'std'
   16 |   std::for_each(std::begin(diffs) + 1, std::end(diffs),
      |        ^~~~~~~~
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(abs(t2-t1));
t1=t2;
}
if(sub%((long)(2*n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
}
}

Compiler output:
Main.java:13: error: cannot find symbol
sub+=(long)(abs(t2-t1));
            ^
  symbol:   method abs(int)
  location: class Main
1 error
Language: C++

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

#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 MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll n, sum = 0, sun_n;
	cin >> n;
	ll a[n];
	rep(n){
		cin >> a[i];
		sum += a[i];
	}
	
	if(n==1){
		cout << "YES";
		return 0;
	}
	
	/*
	double sum_n = (double)sum / (n * (n+1) / 2);
	cout << sum_n << endl;
	if(sum_n != (ll)sum_n){
		cout << "NO";
		return 0;
	}
	ll m = (ll)sum_n;
	*/

	ll diff = a[0] - a[n-1];
	ll d_count = m, i = 1;
	while(true){
		ll d = 0;
		ll diff_calc = m;
		while(diff != diff_calc && d_count >= 0){
			d++;
			diff_calc = diff_calc - 1 - (n-1) * d;
			d_count--;
		}
		if(diff != diff_calc){
			cout << "NO";
			return 0;
		}
		
		if(i >= n){
			break;
		}
		diff = a[i] - a[i-1];
		i++;
	}
	
	if(d_count == 0){
		cout << "YES";
		return 0;
	}else{
		cout << "NO";
		return 0;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:22: error: 'm' was not declared in this scope
   52 |         ll d_count = m, i = 1;
      |                      ^
a.cc:66:20: error: 'i' was not declared in this scope
   66 |                 if(i >= n){
      |                    ^
a.cc:69:26: error: 'i' was not declared in this scope
   69 |                 diff = a[i] - a[i-1];
      |                          ^
Language: Java

import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long max = 0;
		int p=0;
		int pNext=0;
		for(int i=0; i<n; i++){
			a[i] = sc.nextLong();
		}
		for(int i=0; i<n; i++){
			if(a[i] > max){
				max = a[i];
				p=i;
			}
		}

		while( !check(a) ){
			max=0;
			for(int i=1; i<=n; i++){
				if(i+p>=n){
					a[i+p-n] -= i;
					if(a[i+p-n]<0){
						System.out.println("NO");
						return;
					}
					if(a[i+p-n] > max ){
						max = a[i+p-n];
						pNext = i+p-n;
					}

				}else{
					a[i+p] -= i;
					if(a[i+p]<0){
						System.out.println("NO");
						return;
					}
					if(a[i+p]>max){
						max = a[i+p];
						pNext = i+p;
				}
			}
			p = pNext;
		}
				
		System.out.println("YES");
		return;
	}

	static boolean check(long[] a){
		int n = a.length;
		for(int i=0; i<n; i++){
			if(a[i] != 0){
				return false;
			}
		}
		return true;
	}
}

Compiler output:
Main.java:53: error: illegal start of expression
	static boolean check(long[] a){
	^
1 error
Language: C++

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
#define LONG_INF 800000000000000000
vector<int> wow;
int main() {
	iostream::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		wow.push_back(tmp);
	}
	while (true) {
		int min_now = INT_MAX;
		int aaa = 0;
		for (int i = 0;i < n;++i) {
			if (min_now > wow[i]) {
				min_now = wow[i];
				aaa = i;
			}
		}
		if (min_now == 0) {
			for (int q = 0;q < n;++q) {
				if (wow[q] != 0) {
					cout << "NO" << endl;
					return 0;
				}
			}
			cout << "YES" << endl;
			return 0;
		}
		int nya = wow[aaa];
		for (int q = 2;q <= n;++q) {
			int waw = wow[(aaa + q - 1) % n] - wow[aaa];
			int nyp = waw / q;
			nyp++;
			nya = min(nya, nyp);
		}
		if (nya <= 0) {
			cout << "NO" << endl;
			return 0;
		}
		for (int q = 1;q <= n;++q) {
			wow[(aaa + q - 1) % n] -= nya*q;
			if (wow[(aaa + q - 1) % n] < 0) {
				cout << "NO" << endl;
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:31: error: 'INT_MAX' was not declared in this scope
   38 |                 int min_now = INT_MAX;
      |                               ^~~~~~~
a.cc:20:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   19 | #include <list>
  +++ |+#include <climits>
   20 | #include <typeinfo>
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
}
}

Compiler output:
Main.java:16: error: ')' expected
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
                ^
Main.java:16: error: not a statement
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
                 ^
Main.java:16: error: ';' expected
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
                   ^
Main.java:16: error: 'else' without 'if'
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
                                                     ^
4 errors
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub%((long)(2n-2))==0l){System.out.println("YES");}else{System.out.println("NO");}
}
}

Compiler output:
Main.java:16: error: ')' expected
if(sub%((long)(2n-2))==0l){System.out.println("YES");}else{System.out.println("NO");}
                ^
Main.java:16: error: not a statement
if(sub%((long)(2n-2))==0l){System.out.println("YES");}else{System.out.println("NO");}
                 ^
Main.java:16: error: ';' expected
if(sub%((long)(2n-2))==0l){System.out.println("YES");}else{System.out.println("NO");}
                   ^
Main.java:16: error: 'else' without 'if'
if(sub%((long)(2n-2))==0l){System.out.println("YES");}else{System.out.println("NO");}
                                                      ^
4 errors
Language: C++

#include <bits/stdc++.h>
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii;
typedef vector<int> vi;
int main(){
    ll N;
    cin >> N;
    vector < ll > data;
    ll mn = LINF;
    rep(i,N){
        ll a;
        cin >> a;
        data.pb(a);
        mn = min(a,mn);
    }
    ll f = N*(N+1)/2;
    ll h = mn/f;

    rep(i,N){
        data[i] -= h*f;
    }

    int sum = 0;
    bool flg = false;
    rep(i,N){
        sum += data[i];
        if(data[i] == 0){
            flg = true;
        }
    }
    if(sum == 0){
        puts("YES");
        exit(0);
    }
    if(flg){
        puts("NO");
        exit(0);
    }

    map<int,int> memo;
    flg = false;
    rep(i,N){
        if(memo[data[i]] == 0){
            memo[data[i]]++;
        }
        else{
            flg = true;
        }
    }
    if(flg){
        puts("NO");
        exit(0);
    }

    mn = LINF;
    mx = -LINF;

    rep(i,N){
        mn = min(data[i],mn);
        mx = max(data[i],mx);
    }

    if(mx-mn > (N-1)*(N-1)){
        puts("NO");
        exit(0);
    }

    puts("YES");

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:5: error: 'mx' was not declared in this scope; did you mean 'mn'?
   70 |     mx = -LINF;
      |     ^~
      |     mn
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
/*t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}*/
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
}
}

Compiler output:
Main.java:16: error: ')' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
               ^
Main.java:16: error: not a statement
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
                ^
Main.java:16: error: ';' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
                  ^
Main.java:16: error: 'else' without 'if'
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
                                                    ^
4 errors
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
}
}

Compiler output:
Main.java:16: error: ')' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
               ^
Main.java:16: error: not a statement
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
                ^
Main.java:16: error: ';' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
                  ^
Main.java:16: error: 'else' without 'if'
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
                                                    ^
4 errors
Language: C++

#include <bits/stdc++.h>
#include <sys/types.h>
#include <sys/wait.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

template <typename T>
struct rmq {
    static const int INF = std::numeric_limits<int>::max() / 2;
    int n;
    std::vector<pair<T, int>> dat;
    rmq(vector<int> a) : n(a.size()) {
        for (n = 1; n < (int)a.size(); n <<= 1);
        dat.resize(2 * n);
        a.resize(n, -INF);
        for (int i = n; i < n + n; ++i) {
            dat[i] = make_pair(a[i - n], i - n);
        }
        for (int i = n - 1; i >= 1; --i) {
            dat[i] = std::min(dat[i * 2], dat[i * 2 + 1]); // todo
        }
    }
    pair<T, int> query(int v, int w, int l, int r) const {
        if (r <= l || w == 0) return make_pair(INF, -1); // todo
        if (r - l == w) return dat[v];
        int m = w / 2;
        return std::min(
            query(v * 2, m, l, std::min(r, m)), // todo
            query(v * 2 + 1, m, std::max<int>(0, l - m), r - m)); // todo
    }
    void update(int i, const T &x) {
        dat[i + n].first = x;
        i += n;
        for (; i != 1; i /= 2) dat[i / 2] = std::min(dat[i], dat[i ^ 1]); // todo
    }
    pair<T, int> query(int l, int r) { return query(1, n, l, r); }
};

int n;
vector<int> a;

bool solve() {
    ll s = accumulate(all(a), 0LL);
    if (s % (n*(n + 1) / 2)) {
        return false;
    }
    int times = s / (n*(n + 1) / 2);
    if (times > 300000) {
        return (rand() + getpid()) % 2;
    }
    
    vector<int> diff(n);
    for (int i = 0; i < n; i++) {
        diff[i] = a[(i + 1) % n] - a[i];
    }

    int a0 = a[0];
    rmq<int> rm(diff);
    for (int i = 0; i < min<ll>(times, 300000); i++) {
        int val, k;
        tie(val, k) = rm.query(0, n);
        rm.update(k, val + n);
        a0 -= (n - k) % n;
        // dump(a0);
        if (a0 == 0) break;
    }
    for (int i = 0; i < n; i++) {
        if (rm.query(i, i + 1).first != times) {
            return false;
        }
    }
    return true;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while (cin >> n) {
        a.resize(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        cout << (solve() ? "YES" : "NO") << endl;
    }
}

Compiler output:
/usr/bin/ld: /tmp/ccWqHZ01.o: warning: relocation against `_ZN3rmqIxE3INFE' in read-only section `.text._ZNK3rmqIxE5queryExxxx[_ZNK3rmqIxE5queryExxxx]'
/usr/bin/ld: /tmp/ccWqHZ01.o: in function `rmq<long long>::query(long long, long long, long long, long long) const':
a.cc:(.text._ZNK3rmqIxE5queryExxxx[_ZNK3rmqIxE5queryExxxx]+0x5a): undefined reference to `rmq<long long>::INF'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status