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

// copied
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
typedef long long ll;
ll ans,a[60];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        cin>>a[i];
    }
    ll* p;
    while(*(p=max_element(a+1,a+n+1)) >= (ll)n){
        for(int i=1;i<=n;++i){
            if(a+i!=p){
                a[i]+=(*p)/(ll)n;
            }
        }
        ans+=(*p)/(ll)n;
        (*p)%=(ll)n;
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
Main.java:2: error: illegal character: '#'
#include<cstdio>
^
Main.java:3: error: illegal character: '#'
#include<iostream>
^
Main.java:4: error: illegal character: '#'
#include<algorithm>
^
Main.java:6: error: unnamed classes are a preview feature and are disabled by default.
int n;
^
  (use --enable-preview to enable unnamed classes)
Main.java:7: error: class, interface, enum, or record expected
typedef long long ll;
^
Main.java:8: error: class, interface, enum, or record expected
ll ans,a[60];
^
Main.java:12: error: not a statement
        cin>>a[i];
           ^
Main.java:14: error: not a statement
    ll* p;
      ^
Main.java:24: error: not a statement
    cout<<ans<<endl;
             ^
Main.java:10: error: illegal start of expression
    scanf("%d",&n);
               ^
Main.java:15: error: illegal start of expression
    while(*(p=max_element(a+1,a+n+1)) >= (ll)n){
          ^
Main.java:18: error: illegal start of expression
                a[i]+=(*p)/(ll)n;
                       ^
Main.java:21: error: illegal start of expression
        ans+=(*p)/(ll)n;
              ^
Main.java:22: error: illegal start of expression
        (*p)%=(ll)n;
         ^
14 errors
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 7;

int N;
ll A[51];

void solve() {
	cin>>N;
	rep(i,N) cin>>A[i];
	
	ll ret=0;
	rep(x,1000000) {
		rep(i,N) if(A[i]>=N) {
			ll del=A[i]/N;
			ret += del;
			A[i] -= del*N;
			rep(j,N) if(i!=j) A[j] += del;
		}
	}
	
	cout<<ret<<endl;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int N=55;

int n;
long long arr[N],cur[N];

bool can(long long x)
{
	for(int i=0;i<n;i++)
	{
		cur[i]=arr[i]+x;
	}
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		long long dif=cur[i]-(n-1);
		ans+=(dif+n)/(n+1);
	}
	return ans<=x;
}

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	long long st=0,en=(1LL<<60),ans=(1LL<<60);
	while(st<=en)
	{
		long long mid=st+(en-st)/2;
		if(can(mid))
		{
			ans=mid; en=mid-1;
		}
		else st=mid+1;
	}
	for(long long curr=max(ans-1e5,0LL);curr<=ans;curr++)
	{
		if(can(curr))
		{
			ans=curr;
			break;
		}
	}
	cout << ans << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
long long INF = 100000000000000000;
int main(){
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  long long tv = -100;
  long long fv = INF;
  while (fv - tv > 1){
    long long mid = (tv + fv) / 2;
    vector<long long> b(N);
    for (int i = 0; i < N; i++){
      b[i] = a[i] + mid;
    }
    long long cnt = 0;
    for (int i = 0; i < N; i++){
      cnt += b[i] / (N + 1) - 1;
    }
    if (cnt >= mid){
      tv = mid;
    } else {
      fv = mid;
    }
  }
  long long ans = tv;
  long long curr = tv;
  while (1){
    vector<long long> b(N);
    for (int i = 0; i < N; i++){
      b[i] = a[i] + curr;
    }
    long long cnt = 0;
    for (int i = 0; i < N; i++){
      cnt += b[i] / (N + 1);
    }
    ans = curr - 1;
    if (cnt < curr && currr > 0 || curr == tv + 1000000){
      break;
    }
    curr++;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:23: error: 'currr' was not declared in this scope; did you mean 'curr'?
   41 |     if (cnt < curr && currr > 0 || curr == tv + 1000000){
      |                       ^~~~~
      |                       curr
Language: C++

#include <iostream>
#include <array>
using namespace std;
typedef long long ll;
#define FOR(i,n) for (int i = 0; i < n; i++)

int N;
array<ll, 51> A;

void solve() {
    int i,j,k,l,r,x,y; string s;
    
    cin>>N;
    FOR(i,N) cin>>A[i];
    
    ll ret=0;
    FOR(x,1000000) {
        FOR(i,N) if(A[i]>=N) {
            ll del=A[i]/N;
            ret += del;
            A[i] -= del*N;
            FOR(j,N) if(i!=j) A[j] += del;
        }
    }    
    cout<<ret<<endl;
}


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;
#define FOR(i,n) for (int i = 0; i < n; i++)
int N;
ll A[51];

void solve() {
    int i,j,k,l,r,x,y; string s;
    
    cin>>N;
    FOR(i,N) cin>>A[i];
    
    ll ret=0;
    FOR(x,1000000) {
        FOR(i,N) if(A[i]>=N) {
            ll del=A[i]/N;
            ret += del;
            A[i] -= del*N;
            FOR(j,N) if(i!=j) A[j] += del;
        }
    }    
    cout<<ret<<endl;
}


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;
int N;
ll A[51];

void solve() {
    int i,j,k,l,r,x,y; string s;
    
    cin>>N;
    FOR(i,N) cin>>A[i];
    
    ll ret=0;
    FOR(x,1000000) {
        FOR(i,N) if(A[i]>=N) {
            ll del=A[i]/N;
            ret += del;
            A[i] -= del*N;
            FOR(j,N) if(i!=j) A[j] += del;
        }
    }    
    cout<<ret<<endl;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:11:5: error: 'FOR' was not declared in this scope
   11 |     FOR(i,N) cin>>A[i];
      |     ^~~
Language: C++

#include <iostream>
typedef long long ll;
int N;
ll A[51];

void solve() {
    int i,j,k,l,r,x,y; string s;
    
    cin>>N;
    FOR(i,N) cin>>A[i];
    
    ll ret=0;
    FOR(x,1000000) {
        FOR(i,N) if(A[i]>=N) {
            ll del=A[i]/N;
            ret += del;
            A[i] -= del*N;
            FOR(j,N) if(i!=j) A[j] += del;
        }
    }    
    cout<<ret<<endl;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:7:24: error: 'string' was not declared in this scope
    7 |     int i,j,k,l,r,x,y; string s;
      |                        ^~~~~~
a.cc:7:24: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:9:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    9 |     cin>>N;
      |     ^~~
      |     std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:10:5: error: 'FOR' was not declared in this scope
   10 |     FOR(i,N) cin>>A[i];
      |     ^~~
a.cc:21:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   21 |     cout<<ret<<endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:21:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   21 |     cout<<ret<<endl;
      |                ^~~~
      |                std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> a;
int n;

bool isok(ll m) {
  ll cnt = 0;
  for (int i = 0; i < n && cnt <= m; i++) {
    ll t = a[i] + m - (n - 1);
    ll d = n+1;
    cnt += (t+d-1) / d;
  }
  return cnt <= m;
}

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  ll ng = -1;
  ll ok = 1e18;
  while (ok - ng > 1) {
    ll mid = (ok+ng) / 2;
    (isok(mid) ? ok : ng) = mid;
  }
  for (int i = 0; i <= n; i++) {
    if (isok(i)) {
      ok = i; break;
    }
  }
  else cout << ok << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:3: error: 'else' without a previous 'if'
   32 |   else cout << ok << endl;
      |   ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
usibg ll = long long;
vector<ll> a;
int n;

bool isok(ll m) {
  ll cnt = 0;
  for (int i = 0; i < n && cnt <= m; i++) {
    ll t = a[i] + m - (n - 1);
    ll d = n+1;
    cnt += (t+d-1) / d;
  }
  return cnt <= m;
}

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  ll ng = -1;
  ll ok = 1e18;
  while (ok - ng > 1) {
    ll mid = (ok+ng) / 2;
    (isok(mid) ? ok : ng) = mid;
  }
  cout << ok << endl;
}

Compiler output:
a.cc:3:1: error: 'usibg' does not name a type
    3 | usibg ll = long long;
      | ^~~~~
a.cc:4:8: error: 'll' was not declared in this scope
    4 | vector<ll> a;
      |        ^~
a.cc:4:10: error: template argument 1 is invalid
    4 | vector<ll> a;
      |          ^
a.cc:4:10: error: template argument 2 is invalid
a.cc:7:11: error: 'll' was not declared in this scope
    7 | bool isok(ll m) {
      |           ^~
a.cc: In function 'int main()':
a.cc:19:5: error: request for member 'resize' in 'a', which is of non-class type 'int'
   19 |   a.resize(n);
      |     ^~~~~~
a.cc:20:39: error: invalid types 'int[int]' for array subscript
   20 |   for (int i = 0; i < n; i++) cin >> a[i];
      |                                       ^
a.cc:21:3: error: 'll' was not declared in this scope
   21 |   ll ng = -1;
      |   ^~
a.cc:22:5: error: expected ';' before 'ok'
   22 |   ll ok = 1e18;
      |     ^~~
      |     ;
a.cc:23:10: error: 'ok' was not declared in this scope
   23 |   while (ok - ng > 1) {
      |          ^~
a.cc:23:15: error: 'ng' was not declared in this scope; did you mean 'n'?
   23 |   while (ok - ng > 1) {
      |               ^~
      |               n
a.cc:24:7: error: expected ';' before 'mid'
   24 |     ll mid = (ok+ng) / 2;
      |       ^~~~
      |       ;
a.cc:25:11: error: 'mid' was not declared in this scope
   25 |     (isok(mid) ? ok : ng) = mid;
      |           ^~~
a.cc:25:14: error: 'isok' cannot be used as a function
   25 |     (isok(mid) ? ok : ng) = mid;
      |              ^
a.cc:27:11: error: 'ok' was not declared in this scope
   27 |   cout << ok << endl;
      |           ^~
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long

signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  int ans=0;
  while(v[N-1]>N-1){
    int k=0;
    for(int i=0;i<N;i++){
      int a=max((v[i]-(N-1)-1)/N+1,0);
      k+=a;v[i]-=a*(N+1);
    }
    for(int i=0;i<N;i++)v[i]+=k;
    ans+=k;
    sort(v.begin(),v.end());
  }
  cout<<ans<<endl;
}


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

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

const int MAX = 50;
const int64_t INF = 4611686018427387903; // 10^62-1、使わない辺とかに用いる

bool check(int64_t x, int64_t *a, int N) {
	for (int i = 0;i < N;i ++) {
		int64_t operate = 0;
		for (int j = 0;j < N;j ++) {
			operate += (a[j] + x - i + 1) / (N + 1);
		}
		if (operate <= x - i) return false;
	}
	return true;
}

int64_t binarySearch(int64_t l, int64_t r, int64_t *a, int N) {
	int64_t mid;
	for (mid = r >> 1;r - l > 1;mid = l + (r - l >> 1)) {
		if (check(mid, a, N)) l = mid;
		else r = mid;
	}
	return mid;
}
int main() {
	int N;
	int64_t a[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> a[i];
	
	int64_t ans = binarySearch(0, INF, a, N);
	if (check(ans, a, N)) ans ++;
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

操作回数をX回と決め打ちます
この時、ある数aに対して行わなければならない操作回数は(a+X-N+1)/(N+1)の端数切り上げです
ということは、O(N^2)でX回以内にできるか分かります
よって後はXを二分探索すれば良いです、O(N^2log(max(a)))
*/

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

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

int main(){
  long long int N;
  cin >> N;
  vector<long long int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  if(*max_element(A.begin(), A.end()) < N){
    cout << 0 << endl;
    return 0;
  }
  long long int ng = 0, ok = 1e18;
  while(ok - ng > 1){
    long long int m = (ok + ng)/2, t = 0;
    for(int i = 0; i < N; ++i){
      t += (A[i] + m)/(N+1);
      //if((A[i] + m)%(N+1) == N) --t;
    }
    if(t < m) ok = m;
    else ng = m;
  }
  cout << ng << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'max_element' was not declared in this scope
   10 |   if(*max_element(A.begin(), A.end()) < N){
      |       ^~~~~~~~~~~
Language: C

#include<cstdio>
#include<algorithm>
using namespace std;
using LL = long long;
LL N, M, S;
LL A[50];
inline LL ceil(LL d, LL n) {return (d+n-1)/n;}
inline bool ok(LL x) {
  if(M < S-x) return false;
  LL s = 0;
  for(auto i=0; i<N; ++i) s += max(0ll, ceil(A[i]+x+1-N, N+1));
  return s <= x;
}
int main() {
  scanf("%lld", &N);
  M=N*(N-1);
  for(auto i=0; i<N; ++i) scanf("%lld", A+i), S+=A[i];
  LL l = -1, h = 1e18;
  while(l+1 < h) {
    LL m = (l+h)>>1;
    if(ok(m)) h = m;
    else      l = m;
  }
  for(auto x=max(0ll,h-N*N); x<=h; ++x) if(ok(x)) {
    printf("%lld\n",x);
    break;
  }
}

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

#include<iostream>
#include<vector>
#include<math.h>
#include<map>
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define INF int(1e9)
#define N 50
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
typedef pair<int, int> P;
typedef pair<pair<P, P>, P>PP;
typedef long long LL;
LL n, sum;
LL a[N];
vector<LL> sm, bi;
bool judge()
{
	REP(i, n)
		if (a[i] > n - 1)
			return false;
	return true;
}
void solve(LL ans)
{
	LL sum = 0, s;
	REP(i, n)
	{
		s = a[i] / n;
		sum += s;
		a[i] %= n;
		a[i] -= s;
	}
	REP(i, n)
	{
		a[i] += sum;
	}
	judge() ? printf("%lld\n", ans + sum) : solve(ans + sum);
}
int main()
{
	cin >> n;
	REP(i, n)
		cin >> a[i];
	sort(a, a + n);
	judge() ? printf("0\n") : solve(0);
	return 0;
}

Compiler output:
a.cc: In function 'void solve(LL)':
a.cc:42:25: error: third operand to the conditional operator is of type 'void', but the second operand is neither a throw-expression nor of type 'void'
   42 |         judge() ? printf("%lld\n", ans + sum) : solve(ans + sum);
      |                   ~~~~~~^~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:50:25: error: third operand to the conditional operator is of type 'void', but the second operand is neither a throw-expression nor of type 'void'
   50 |         judge() ? printf("0\n") : solve(0);
      |                   ~~~~~~^~~~~~~
Language: C++

#include <iostream>
using namespace sdt;

int main() {
    long long n, tmp,  res = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
	cin >> tmp;
	res += tmp / n;
    }
    cout << res << endl;
}


Compiler output:
a.cc:2:17: error: 'sdt' is not a namespace-name
    2 | using namespace sdt;
      |                 ^~~
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |     cin >> n;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   11 |     cout << res << endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:11:20: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   11 |     cout << res << endl;
      |                    ^~~~
      |                    std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++


use std::io;
use std::collections::VecDeque;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let n:usize = buf.trim().parse().unwrap();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let mut a: Vec<i64> = buf.split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();

    let mut ans = 0i64;
    let mut flag = true;

    while flag {
        flag = false;
        for i in 0..n {
            let x  = a[i] / (n as i64);
            if x > 0 {
                for j in 0..n {
                    if j!=i {
                        a[j] += x;
                    }
                }
                ans += x;
                a[i] = a[i] % (n as i64);
                flag = true;
            }
        }
    }
    println!("{}", ans);

}


Compiler output:
a.cc:25:18: error: too many decimal points in number
   25 |         for i in 0..n {
      |                  ^~~~
a.cc:28:26: error: too many decimal points in number
   28 |                 for j in 0..n {
      |                          ^~~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::io;
      | ^~~
a.cc:3:1: error: 'use' does not name a type
    3 | use std::collections::VecDeque;
      | ^~~
a.cc:5:1: error: 'fn' does not name a type
    5 | fn main() {
      | ^~
Language: C++

#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<utility>
#ifdef XS
	#include<De>
#endif
using namespace std;
#define MS(m) memset(m,0,sizeof(m))

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//while(1)
	//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
	inp();
	return 0;
}
const int N = 51;
void inp(){
	ll n,sum,A[N];cin>>n;
	for(int i = 1;i<=n;i++)cin>>A[i];
	ll k = 0;
	while(1){
		sum = 0;
		for(int i = 1;i<=n;i++)sum += A[i]/n;
		if(!sum)break;
		k += sum;
		for(int i = 1;i<=n;i++){
			A[i] = sum - A[i]/n + A[i]%n;
		}
	}
	cout<<k<<endl;
}
/

Compiler output:
a.cc:41:1: error: expected unqualified-id before '/' token
   41 | /
      | ^
Language: C++

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<utility>
#ifdef XS
	#include<De>
#endif
using namespace std;
#define MS(m) memset(m,0,sizeof(m))

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//while(1)
	//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
	inp();
	return 0;
}
const int N = 51;
void inp(){
	ll n,sum,A[N];cin>>n;
	for(int i = 1;i<=n;i++)cin>>A[i];
	ll k = 0;
	while(1){
		sum = 0;
		for(int i = 1;i<=n;i++)sum += A[i]/n;
		if(!sum)break;
		k += sum;
		for(int i = 1;i<=n;i++){
			A[i] += sum - A[i]/n;
		}
	}
	cout<<sum<<endl;
}
//at79E.cc by xsthunder at Sun Jul 30 16:12:38 2017


Compiler output:
a.cc: In function 'void inp()':
a.cc:26:23: error: 'cin' was not declared in this scope
   26 |         ll n,sum,A[N];cin>>n;
      |                       ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include<utility>
  +++ |+#include <iostream>
    5 | #ifdef XS
a.cc:38:9: error: 'cout' was not declared in this scope
   38 |         cout<<sum<<endl;
      |         ^~~~
a.cc:38:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:38:20: error: 'endl' was not declared in this scope
   38 |         cout<<sum<<endl;
      |                    ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    4 | #include<utility>
  +++ |+#include <ostream>
    5 | #ifdef XS
Language: C++

//
//  main.cpp
//  D
//
//  Created by Vadim Zakharenko on 29/07/2017.
//  Copyright © 2017 Vadim Zakharenko. All rights reserved.
//

#include <iostream>
#include <memory.h>

using namespace std;

long long a[111];
int n;

int main(int argc, const char * argv[]) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for(;;) {
        long long iter = 0;
        for (int i = 1; i <= n; i++) {
            iter += a[i] / n;
        }
        ans += iter;
        for (int i = 1; i <= n; i++) {
            long long old_a = a[i];
            a[i] %= n;
            a[i] += iter - old_a / n;
        }
        if (*max_element(a + 1, a + n + 1) < n) {
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:34:14: error: 'max_element' was not declared in this scope
   34 |         if (*max_element(a + 1, a + n + 1) < n) {
      |              ^~~~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
using namespace std;

int main(){
  long long int n;
  cin>>n;
  long long int bsum=0;
  long long int ssum=0;
  vector<long long int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  sort(a.begin(),a.end());

  while(a[n-1]>n-1){
    //cout<<a[n-1]<<endl;
    for(int i=0;i<n;i++){
      if(a[i]>(n-1)){
        long long int wl=a[i]/(n-1);
        bsum+=wl;
        a[i]=wl;
      }
    }
    for(int i=0;i<n;i++){
      a[i]+=a[i];
      a[i]-=bsum;
    }
    sort(a.begin(),a.end());
    ssum=bsum;
    bsum=0;
  }

  cout<<ssum<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   18 |   sort(a.begin(),a.end());
      |   ^~~~
      |   sqrt
Language: C++

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
  int n;
  std::cin >> n;
  std::vector<long long> a(n);
  rep(i,n){
    std::cin >> a[i];
  }
  sort(all(a));
  reverse(all(a));
  ans=0;
  bool b=false;
  while(!b){
    long long tmp =0,tmp2;
    rep(i,a.size()){
      ans+=a[i]/n;
      tmp+=a[i]/n;
    }
    rep(i,a.size()){
      tmp2=a[i]
      a[i]=tmp2%n;
      a[i]+=tmp-tmp2/n;
    }
    b=true;
    rep(i,a.size()){
      if(a[i]>n-1) b=false;
    }
  }
  
  std::cout << ans << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |   ans=0;
      |   ^~~
      |   abs
a.cc:46:16: error: expected ';' before 'a'
   46 |       tmp2=a[i]
      |                ^
      |                ;
   47 |       a[i]=tmp2%n;
      |       ~
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long[] a = new long[N];
    long max = 0;
    long sum = 0;
    for(int i = 0; i < (int)N; i++) {
      a[i] = sc.nextLong();
      max = Math.max(max, a[i]);
      sum += a[i];
    }
    if(max < N) {
      System.out.println(0);
    } else {
      System.out.println(sum / N);
    }
  }
}

Compiler output:
Main.java:7: error: incompatible types: possible lossy conversion from long to int
    long[] a = new long[N];
                        ^
1 error
Language: C++

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int MaxN = 50;
LL a[MaxN + 5];
LL cnt[MaxN + 5];
int n;
 
int main(){
	while(~scanf("%d", &n)){
		for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
		LL tot = 0, ans = 0;
		bool ok = true;
		while(ok){
			ok = false;
			tot = 0;
			for(int i = 1; i <= n; i++){
				cnt[i] = a[i] / n;
				a[i] = a[i] % n;
				tot += cnt[i];
			}
			ans += tot;
			for(int i= 1; i <= n; i++){
				a[i] += tot - cnt[i];
				if(a[i] >= n) flag = true;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:47: error: 'flag' was not declared in this scope
   29 |                                 if(a[i] >= n) flag = true;
      |                                               ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <climits>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main() {
    ll n;
    cin >> n;
    
    vector<ull> arr(n);
    for(ll i = 0; i < n; ++i)
        cin >> arr[i];
  
    sort(arr.begin(), arr.end());
    ull k = 0;
    
    while(arr.back() > (n - 1)) {
        ld Z = arr.back() - (n - 1);
        ld N = n;
        ull temp = ceil(Z / N);
        
        k += temp;
        
        for(ll i = 0; i < n - 1; ++i)
            arr[i] += temp;
        arr[n - 1] = arr[n - 1] - (temp * N);
        
        sort(arr.begin(), arr.end());
    }
    
    cout << k << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:20: error: 'ceil' was not declared in this scope
   27 |         ull temp = ceil(Z / N);
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;


const int MAX_n = 50;
int n,a[MAX_n];

bool solve(int mid){

    int need=0;
    for(int i = 0;i < n;i++){
        if(a[i]>=n){
            need+=a[i]/n;
            for(int j = 0;j < n;j++){
                if(i!=j)
                    a[j]+=a[i]/n;
            }
            a[i]-=a[i]/n *n
        }
    }
    for(int i = 0;i < n;i++){
        if(a[i]>=n){
            need+=a[i]/n;
            for(int j = 0;j < n;j++){
                if(i!=j)
                    a[j]+=a[i]/n;
            }
            a[i]-=a[i]/n *n
        }
    }
    for(int i = 0;i < n;i++){
        if(a[i]>=n){
            need+=a[i]/n;
            for(int j = 0;j < n;j++){
                if(i!=j)
                    a[j]+=a[i]/n;
            }
            a[i]-=a[i]/n *n
        }
    }
    if(need<=mid)
        return 1;
    else {
        return 0;
    }

}

signed main(){

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

    int ok=INF;   // 解が存在する値
    int ng=-1;    // 解が存在しない値

    while (abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        if(solve(mid)){
            ok=mid;
        }else{
            ng = mid;
        }
    }

    cout<< ok<< endl;


    return 0;
}

Compiler output:
a.cc: In function 'bool solve(long long int)':
a.cc:42:28: error: expected ';' before '}' token
   42 |             a[i]-=a[i]/n *n
      |                            ^
      |                            ;
   43 |         }
      |         ~                   
a.cc:52:28: error: expected ';' before '}' token
   52 |             a[i]-=a[i]/n *n
      |                            ^
      |                            ;
   53 |         }
      |         ~                   
a.cc:62:28: error: expected ';' before '}' token
   62 |             a[i]-=a[i]/n *n
      |                            ^
      |                            ;
   63 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;


const int MAX_n = 50;
int n,a[MAX_n];

bool solve(int mid){

    int need=0;
    for(int i = 0;i < n;i++){
        if(a[i]>=n){
            need+=a[i]/n;
            a[i]-=a[i]/n *n
            for(int j = 0;j < n;j++){
                if(i!=j)
                    a[j]+=a[i]/n;
            }
        }
    }
    for(int i = 0;i < n;i++){
        if(a[i]>=n){
            need+=a[i]/n;
            a[i]-=a[i]/n *n
            for(int j = 0;j < n;j++){
                if(i!=j)
                    a[j]+=a[i]/n;
            }
        }
    }
    for(int i = 0;i < n;i++){
        if(a[i]>=n){
            need+=a[i]/n;
            a[i]-=a[i]/n *n
            for(int j = 0;j < n;j++){
                if(i!=j)
                    a[j]+=a[i]/n;
            }
        }
    }
    if(need<=mid)
        return 1;
    else {
        return 0;
    }

}

signed main(){

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

    int ok=INF;   // 解が存在する値
    int ng=-1;    // 解が存在しない値

    while (abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        if(solve(mid)){
            ok=mid;
        }else{
            ng = mid;
        }
    }

    cout<< ok<< endl;


    return 0;
}

Compiler output:
a.cc: In function 'bool solve(long long int)':
a.cc:38:28: error: expected ';' before 'for'
   38 |             a[i]-=a[i]/n *n
      |                            ^
      |                            ;
   39 |             for(int j = 0;j < n;j++){
      |             ~~~             
a.cc:39:27: error: 'j' was not declared in this scope
   39 |             for(int j = 0;j < n;j++){
      |                           ^
a.cc:48:28: error: expected ';' before 'for'
   48 |             a[i]-=a[i]/n *n
      |                            ^
      |                            ;
   49 |             for(int j = 0;j < n;j++){
      |             ~~~             
a.cc:49:27: error: 'j' was not declared in this scope
   49 |             for(int j = 0;j < n;j++){
      |                           ^
a.cc:58:28: error: expected ';' before 'for'
   58 |             a[i]-=a[i]/n *n
      |                            ^
      |                            ;
   59 |             for(int j = 0;j < n;j++){
      |             ~~~             
a.cc:59:27: error: 'j' was not declared in this scope
   59 |             for(int j = 0;j < n;j++){
      |                           ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n;
int p[maxn] , cur;
int ans[maxn];
int cyc[maxn];
int order[maxn];
vector < int > adj[maxn];
bool mark[maxn];
set < int > st;

void dfs1(int v = 1){
    if(mark[v]){
        cyc[v] = 1;
        while(order[cur]!=v)
            cyc[order[cur--]] = 1;
        return;
    }
    mark[v] = 1;
    order[++cur] = v;
    dfs1(p[v]);
}

void dfs(int v){
    set < int > st;
    for(auto u : adj[v]){
        if(ans[u] == -1)
            dfs(u);
        st.insert(ans[u]);
    }
    int mn = 0;
    for(;;mn++)
        if(!st.count(mn)){
            ans[v] = mn;
            break;
        }
}

bool chk(int v , int val){
    ans[v] = val;
    int pos = p[v];
    set < int > st;
    while(pos!=v){
        st.clear();
        for(auto u : adj[pos])
            st.insert(ans[u]);
        int mn = 0;
        for(;;mn++)
            if(!st.count(mn)){
                ans[pos] = mn;
                break;
            }
        pos = p[pos];
    }
    st.clear();
    for(auto u : adj[pos])
            st.insert(ans[u]);
    int mn = 0;
        for(;;mn++)
            if(!st.count(mn))
                return(mn == val);4
2 3 1 1

}

int main(){
    migmig
    cin >> n;
    for(int i = 1; i <= n ; i ++)
        cin >> p[i] , adj[p[i]].pb(i);
    ms(ans , -1);
    dfs1();
    cur = 0;
    for(int i = 1 ; i <= n ; i ++)
        if(!cyc[i])dfs(i);
        else cur = i;
    for(auto u : adj[cur])
        if(!cyc[u])
            st.insert(ans[u]);
    int a = -1;
    int b = -1;
    int cnt = 0;
    for(;;cnt++){
        if(st.count(cnt))continue;
        if(a==-1)a = cnt;
        else{
            b = cnt;
            break;
        }
    }
    bool oke = 0;
    oke |= chk(cur , a);
    oke |= chk(cur , b);
    cout << ((oke)?"POSSIBLE" : "IMPOSSIBLE");
    return(0);
}

Compiler output:
a.cc: In function 'bool chk(int, int)':
a.cc:81:36: error: expected ';' before numeric constant
   81 |                 return(mn == val);4
      |                                    ^
      |                                    ;
   82 | 2 3 1 1
      | ~
Language: C++

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

const int MAXN = 2.1e5;
int N;
int P[MAXN];
int inDeg[MAXN];
set<int> ch[MAXN];
int V[MAXN];
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> P[i];
  for (int i = 1; i <= N; i++) inDeg[P[i]] ++;
  vector<int> q;
  for (int i = 1; i <= N; i++) if (inDeg[i] == 0) q.push_back(i);
  for (int z = 0; z < int(q.size()); z++) {
    int i = q[z];
    V[i] = 0;
    while (ch[i].count(V[i])) V[i]++;
    ch[P[i]].insert(V[i]);
    if (!(--inDeg[P[i]])) q.push_back(P[i]);
  }
  
  int st = 1;
  while (!deg[st]) st++;
  vector<int> vals;
  int cur = 0;
  for (int z = 0; z < 2; z++) {
    for (int i = P[i]; true; i = P[i]) {
      int nxt = 0;
      while (nxt == cur || ch[i].count(nxt)) nxt++;
      cur = nxt;
      if (i == st) break;
    }
    vals.push_back(cur);
  }
  cout << (vals[0] == vals[1] ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:11: error: 'deg' was not declared in this scope
   25 |   while (!deg[st]) st++;
      |           ^~~
Language: C++

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

const int MAXN = 2.1e5;
int N;
int P[MAXN];
int inDeg[MAXN];
set<int> ch[MAXN];
int V[MAXN];
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> P[i];
  for (int i = 1; i <= N; i++) inDeg[P[i]] ++;
  vector<int> q;
  for (int i = 1; i <= N; i++) if (inDeg[i] == 0) q.push_back(i);
  for (int z = 0; z < int(q.size()); z++) {
    int i = q[z];
    V[i] = 0;
    while (ch[i].count(V[i])) V[i]++;
    ch[P[i]].insert(V[i]);
    if (!(--deg[P[i]])) q.push_back(P[i]);
  }
  
  int st = 1;
  while (!deg[st]) st++;
  vector<int> vals;
  int cur = 0;
  for (int z = 0; z < 2; z++) {
    for (int i = P[i]; true; i = P[i]) {
      int nxt = 0;
      while (nxt == cur || ch[i].count(nxt)) nxt++;
      cur = nxt;
      if (i == st) break;
    }
    vals.push_back(cur);
  }
  cout << (vals[0] == vals[1] ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:13: error: 'deg' was not declared in this scope
   21 |     if (!(--deg[P[i]])) q.push_back(P[i]);
      |             ^~~
a.cc:25:11: error: 'deg' was not declared in this scope
   25 |   while (!deg[st]) st++;
      |           ^~~
Language: C++

#include <bits/stdc++.h>
int main() {
return puts("IMPOSSIBLE), 0;
}

Compiler output:
a.cc:3:13: warning: missing terminating " character
    3 | return puts("IMPOSSIBLE), 0;
      |             ^
a.cc:3:13: error: missing terminating " character
    3 | return puts("IMPOSSIBLE), 0;
      |             ^~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:4:1: error: expected primary-expression before '}' token
    4 | }
      | ^
a.cc:3:13: error: expected ';' before '}' token
    3 | return puts("IMPOSSIBLE), 0;
      |             ^
      |             ;
    4 | }
      | ~
Language: C++

#include<algorithm>
#include<iostream>
#include<queue>
#include<set>
using namespace std;
const int N=2e5+5;
set<int>se[N];
typedef set<int>::iterator it;
int n,now,v[N],c[N],b[N],nex[N],head[N];
struct each{
	int a,id;
}a[N];
queue<int>que;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
int get(int x){
	int last=-1;
	it i=se[x].begin();
	for(;i!=se[x].end();++i)
		if(last+1==*i)	++last;
		else	break;
	return ++last;
}
int vis[N],tm[N],p[N];
int main(){
	//freopen("graph.out","w",stdout);
	//freopen("graph.in","r",stdin);

	n=read();
	for(register int i=1;i<=n;i++)
		++b[p[i]=read()];
	for(register int i=1;i<=n;i++)
		if(!b[i])	que.push(i);
	while(!que.empty()){
		int x=que.front(),k=get(x);
		que.pop(),se[p[x]].insert(k);
		if(!(--b[p[x]]))	que.push(p[x]);
	}
	int st;
	for(int i=1;i<=n;i++)
		if(b[i]){
			st=i,que.push(i);
			break;
		}
	while(!que.empty()){
		int x=que.front();
		que.pop(),tm[x]=get(x);
		if(se[p[x]].count(tm[x]))	vis[x]=1;
		se[p[x]].insert(tm[x]);
		if(p[x]==st){
			if(tm[x]==tm[st])	break;
			else{
				puts("POSSIBLE");
				return 0;
			}
		}
		que.push(p[x]);
	}
	for(int i=1;i<=n;i++)
		if(b[i]&&!vis[x])	se[p[i]].erase(tm[i]);
	int end=tm[st];
	que.push(st),se[st].insert(end);
	while(!que.empty()){
		int x=que.front();
		que.pop(),tm[x]=get(x);
		se[p[x]].insert(tm[x]);
		if(p[x]==st){
			if(tm[x]!=end)	break;
			else{
				puts("POSSIBLE");
				return 0;
			}
		}
		que.push(p[x]);
	}
	puts("IMPOSSIBLE");
	return 0;
}

Compiler output:
a.cc: In function 'int read()':
a.cc:15:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |         register int x=0;
      |                      ^
a.cc:16:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   16 |         register char ch=getchar();
      |                       ^~
a.cc: In function 'int main()':
a.cc:35:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   35 |         for(register int i=1;i<=n;i++)
      |                          ^
a.cc:37:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |         for(register int i=1;i<=n;i++)
      |                          ^
a.cc:65:31: error: 'x' was not declared in this scope
   65 |                 if(b[i]&&!vis[x])       se[p[i]].erase(tm[i]);
      |                               ^
Language: C++

#include<algorithm>
#include<iostream>
#include<queue>
#include<set>
using namespace std;
const int N=2e5+5;
set<int>se[N];
typedef set<int>::iterator it;
int n,now,v[N],c[N],b[N],nex[N],head[N];
struct each{
	int a,id;
}a[N];
queue<int>que;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
int get(int x){
	int last=-1;
	it i=se[x].begin();
	for(;i!=se[x].end();++i)
		if(last+1==*i)	++last;
		else	break;
	return ++last;
}
int vis[N],tm[N],p[N];
int main(){
	//freopen("graph.out","w",stdout);
	//freopen("graph.in","r",stdin);

	n=read();
	for(register int i=1;i<=n;i++)
		++b[p[i]=read()];
	for(register int i=1;i<=n;i++)
		if(!b[i])	que.push(i);
	while(!que.empty()){
		int x=que.front(),k=get(x);
		que.pop(),se[p[x]].insert(k);
		if(!(--b[p[x]]))	que.push(p[x]);
	}
	int st;
	for(int i=1;i<=n;i++)
		if(b[i]){
			st=i,que.push(i);
			break;
		}
	while(!que.empty()){
		int x=que.front();
		que.pop(),tm[x]=get(x);
		if(se[p[x]].count(tm[x]))	vis[x]=1;
		se[p[x]].insert(tm[x]);
		if(p[x]==st){
			if(tm[x]==tm[st])	break;
			else{
				puts("POSSIBLE");
				return 0;
			}
		}
		que.push(p[x]);
	}
	for(int i=1;i<=n;i++)
		if(b[i]&&!vis[x])	se[p[i]].erase(tm[i]);
	int end=tm[st];
	que.push(st),se[st].insert(end);
	while(!que.empty()){
		int x=que.front();
		que.pop(),tm[x]=get(x);
		se[p[x]].insert(tm[x]);
		if(p[x]==st){
			if(tm[x]!=end)	break;
			else{
				puts("POSSIBLE");
				return 0;
			}
		}
		que.push(p[x]);
	}
	puts("IMPOSSIBLE");
	return 0;
}


Compiler output:
a.cc: In function 'int read()':
a.cc:15:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |         register int x=0;
      |                      ^
a.cc:16:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   16 |         register char ch=getchar();
      |                       ^~
a.cc: In function 'int main()':
a.cc:35:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   35 |         for(register int i=1;i<=n;i++)
      |                          ^
a.cc:37:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |         for(register int i=1;i<=n;i++)
      |                          ^
a.cc:65:31: error: 'x' was not declared in this scope
   65 |                 if(b[i]&&!vis[x])       se[p[i]].erase(tm[i]);
      |                               ^