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

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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int n;
vector<int> graph[1001*1001];
vector<bool> used(1001*1001, false);
map<int, int> depth_map;

bool dfs(int node, int par) {
    // cerr << par/(n+1) << " " << par%(n+1) << "->" << node/(n+1) << " " << node%(n+1) << endl;
    used[node] = true;
    for(int child: graph[node]) {
        if(used[child]) return false;
        if(!dfs(child, node)) return false;
    }
    used[node] = false;
    return true;
}

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n;
    int a[n+1][n-1];
    for(int i=1;i<=n;++i) {
        for(int j=0;j<n-1;++j) {
            cin >> a[i][j];
            if(j) {
                graph[min(i, a[i][j-1])*(n+1)+max(i, a[i][j-1])].push_back(
                    min(i, a[i][j])*(n+1)+max(i, a[i][j])
                );
            } else {
                graph[0].push_back(
                    min(i, a[i][j])*(n+1)+max(i, a[i][j])
                );
            }
        }
    }

    if(!dfs(0, -1)) {
        cout << -1 << endl;
        return 0;
    }

    cassert(false);

}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:5: error: 'cassert' was not declared in this scope; did you mean 'assert'?
   71 |     cassert(false);
      |     ^~~~~~~
      |     assert
Language: C++

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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int n;
vector<int> graph[1001*1001];
vector<bool> used(1001*1001, false);
map<int, int> depth_map;

bool dfs(int node, int par) {
    // cerr << par/(n+1) << " " << par%(n+1) << "->" << node/(n+1) << " " << node%(n+1) << endl;
    used[node] = true;
    for(int child: graph[node]) {
        if(used[child]) return false;
        if(!dfs(child, node)) return false;
    }
    used[node] = false;
    return true;
}

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n;
    int a[n+1][n-1];
    for(int i=1;i<=n;++i) {
        for(int j=0;j<n-1;++j) {
            cin >> a[i][j];
            if(j) {
                graph[min(i, a[i][j-1])*(n+1)+max(i, a[i][j-1])].push_back(
                    min(i, a[i][j])*(n+1)+max(i, a[i][j])
                );
            } else {
                graph[0].push_back(
                    min(i, a[i][j])*(n+1)+max(i, a[i][j])
                );
            }
        }
    }

    if(!dfs(0, -1)) {
        cout << -1 << endl;
        return 0;
    }

    cassert(false);

    cout << bfs() << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:5: error: 'cassert' was not declared in this scope; did you mean 'assert'?
   71 |     cassert(false);
      |     ^~~~~~~
      |     assert
a.cc:73:13: error: 'bfs' was not declared in this scope; did you mean 'dfs'?
   73 |     cout << bfs() << endl;
      |             ^~~
      |             dfs
Language: C++

#include <bits/stdc++.h>

#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define N 1003

using namespace std;

struct Edge {
    int to, nxt;
} e[N * N * 3];

int n, cnt;
int ins[N * N], mp[N][N], fir[N * N], t[N * N];

queue<int> Q;

int id(int, int);
void add(int, int);

int main() {
    scanf("%d", &n);
    int ans = 0;
    rep (i, 1, n)
        rep (j, 1, n - 1)
            scanf("%d", mp[i] + j);
    rep (i, 1, n)
        rep (j, 2, n - 1)
            add(id(i, mp[i][j - 1]), id(i, mp[i][j]));
    rep (i, 1, n * n) {
        if (!ins[i])
            Q.push(i);
        t[i] = 1;
    }
    while (!Q.empty()) {
        int u = Q.front();
        Q.pop();
        ans = max(ans, t[u]);
        for (int i = fir[u]; i; i = e[i].nxt) {
            int v = e[i].to;
            --ins[v];
            if (!ins[v])
                Q.push(v), t[v] = t[u] + 1;
        }
    }
    reo (i, 1, n) 
        if (ins[i])
            ans = -1;
    cout << ans << endl;
    return 0;
}

int id(int x, int y) {
    if (x > y)
        swap(x, y);
    return (x - 1) * n + y;
}

void add(int u, int v) {
    e[++cnt] = (Edge){v, fir[u]};
    fir[u] = cnt;
    ++ins[v];
    return;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:10: error: 'i' was not declared in this scope
   45 |     reo (i, 1, n)
      |          ^
a.cc:45:5: error: 'reo' was not declared in this scope; did you mean 'rep'?
   45 |     reo (i, 1, n)
      |     ^~~
      |     rep
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

int main()
{
    int n;
    scanf("%d", &n);
    vector<vector<int>> a;
    for (int i=0; i<n; i++)
    {
        vector<int> vs;
        for (int j=0; j<n-1; j++)
        {
            int v;
            scanf("%d", &v);
            vs.push_back(vs);
        }
        a.push_back(vs);
    }

    ll day = 0;
    vector<int> vsed_player;
    while(true)
    {
        bool nonVS = true;
        int num_empty = 0;
        for (int i=0; i<n; i++)
        {
            if (a[i].empty())
            {
                num_empty++;
                continue;
            }
            int vs = a[i][0] - 1;
            if (vs < i) continue;
            auto itr_i = find(vsed_player.begin(), vsed_player.end(), i);
            if (itr_i != vsed_player.end()) continue;
            auto itr_vs = find(vsed_player.begin(), vsed_player.end(), vs);
            if (itr_vs != vsed_player.end()) continue;
            if (a[vs][0] - 1 == i)
            {
                a[i].erase(a[i].begin());
                a[vs].erase(a[vs].begin());
                vsed_player.push_back(vs);
                nonVS = false;
            }
        }
        if (num_empty == n) break;
        if (nonVS)
        {
            day = -1;
            break;
        }
        day++;
        vsed_player.clear();
    }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:18:25: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)'
   18 |             vs.push_back(vs);
      |             ~~~~~~~~~~~~^~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<int>::value_type&' {aka 'const int&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Language: C++

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define pii pair<long long,long long>
#define pll pair<long long, long long>
#define rep(i,l,r) for(long long i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const long long INF = (long long)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

mt19937 mt('O' + '4' + 'K' + 'O');

void kekek()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    mt();
    #ifdef EB_UG
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
}

int main() {
	kekek();
	auto time = clock();
	long long n;
	cin >> n;
	vector<deque<int>> dq(n + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n - 1; j++) {
			int t;
			cin >> t;
			dq[i].push_back(t);
		}
	}
	int cnt = 1;
	bitset<1000> used;
	bool fast = false;
	int sz = n * (n - 1) / 2;
	while(true) {
		if (!fast) {
			double nt = clock  - time();
			nt /= CLOCKS_PER_SEC;
			if (nt >= 1.8) {
				fast = true;
			}
		}
		used.reset();
		for (int i = 1; i < n + 1; i++) {
			if (!used[i]) {
				int t = dq[i].front();
				if (!used[t] && dq[t].front() == i) {
					dq[i].pop_front();
					dq[t].pop_front();
					used[i] = true;
					used[t] = true;
					sz-=1;
					if (fast)
						break;
					// cout << "match: " << i << ' ' << t << endl;
				}
			}
		}
		// cout << sz << endl;
		int ts = 0;
		if (!used.any() && sz != 0) {
			cout << -1;
			return 0;
		}
		if (sz == 0) {
			break;
		}
		cnt++;
	}
	cout << cnt;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:50: error: 'time' cannot be used as a function
   54 |                         double nt = clock  - time();
      |                                              ~~~~^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
#define fi first
#define se second
int n,f[N],a[N][N];
typedef pair<int,int>P;
priority_queue<P,vector<P>,greater<P> >que;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<n;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
		if(i==a[a[i][1]][1])
			que.push(P(1,i)),f[i]=1;
	int ans=0,res=0;
	while(!que.empty()){
		P x=que.top();	que.pop();
		++res,ans=max(ans,f[x.se]);
		x.fi=max(x.fi,f[x.se]);
		int k=a[x.se][b[x.se]];
		if(x.se==a[k][b[k]]){
			++b[k],++b[x.se];
			x.fi=max(x.fi,f[k])+1;
			f[k]=x.fi,que.push(P(f[k],k));
			f[x.se]=x.fi,que.push(P(f[k],x.se));
		}
	}
	if(res!=n*(n-1))	cout<<-1<<endl;
	else	cout<<ans<<endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:22:31: error: 'b' was not declared in this scope
   22 |                 int k=a[x.se][b[x.se]];
      |                               ^
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,A,cnt,now,sum=0;
bool flag=true,te[1000]={};

int main(){
    cin>>N;
    queue<int> opp[N];
    rep(i,N){
        rep(j,N-1){
            cin>>A;
            A--;
            opp[i].push(A);
        }
    }
    while(flag){
        // out(cnt);
        flag=false;
        bool lo[N];
        // rep(i,N){
        //     lo[i]=false;
        // }
        memcpy(&lo,&te,sizeof(lo));
        rep(i,N){
            if(lo[i]||opp[i].size()==0)continue;
            now=opp[i].front();
            if(opp[now].front()==i&&!lo[now]){
                flag=true;
                opp[i].pop();
                opp[now].pop();
                lo[i]=lo[now]=true;
                sum+=2;
            }
            lo[i]=true;
        }
        cnt++;
        if(sum==N*(N-1)){
            out(cnt);
            return 0;
        }
    }
    out(-1);
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:9: error: 'memcpy' was not declared in this scope
   46 |         memcpy(&lo,&te,sizeof(lo));
      |         ^~~~~~
a.cc:14:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include<queue>
  +++ |+#include <cstring>
   14 | using namespace std;
Language: C++

int main() {
	cout << -1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:9: error: 'cout' was not declared in this scope
    2 |         cout << -1 << endl;
      |         ^~~~
a.cc:2:23: error: 'endl' was not declared in this scope
    2 |         cout << -1 << endl;
      |                       ^~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int a[1000][1000];
int cnt[1000];
int us[1000];
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void){
  int n,c=0,ans;
  scanf("%d",&n);
  FOR(n)FORJ(n-1)scanf("%d",&a[i][j]);
  for(ans=0;c*2<n*(n-1);ans++){
    int flg=1;
    FOR(n){
      int j=a[i][cnt[i]]-1;
      if(cnt[i]==n-1||us[i][ans])continue;
      if(us[j][ans])continue;
      if(i+1==a[j][cnt[j]]){
        us[i][ans]++;
        us[a[i][cnt[i]]-1][ans]++;
        cnt[a[i][cnt[i]]-1]++;
        cnt[i]++;
        c++;
        flg=0;
      }
    }
    if(flg){
      ans=-1;
      break;
    }
    FOR(n)us[i]=0;
  }
  PRN(ans);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:47:28: error: subscripted value is neither array nor pointer nor vector
   47 |       if(cnt[i]==n-1||us[i][ans])continue;
      |                            ^
main.c:48:15: error: subscripted value is neither array nor pointer nor vector
   48 |       if(us[j][ans])continue;
      |               ^
main.c:50:14: error: subscripted value is neither array nor pointer nor vector
   50 |         us[i][ans]++;
      |              ^
main.c:51:27: error: subscripted value is neither array nor pointer nor vector
   51 |         us[a[i][cnt[i]]-1][ans]++;
      |                           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
const int M=1e6+5;
int n,f[N],b[N],a[N][N];
#define fi first
#define se second
typedef pair<int,int>P;
priority_queue<P,vector<P>,greater<P> >que;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<n;j++)
			scanf("%d",&a[i][j]),b[i]=1;
	for(int i=1;i<=n;i++)
		if(i==a[a[i][1]][1])
			que.push(P(1,i)),++b[i];
	int ans=0,res=0;
	while(!que.empty()){
		P x=que.top();	que.pop();
		++res,ans=max(ans,f[x.se]);
		int k=a[x.se][b[x.se]];
		if(x.se==a[k][b[k]]){
			++b[k],++b[x.se];
			x.fi=max(x.fi,f[k])+1;
			fw[k]=x.fi,que.push(P(f[k],k));
			f[x.se]=x.fi,que.push(P(f[k],x.se));
		}
	}
	if(res!=n*(n-1))	cout<<-1<<endl;
	else	cout<<ans<<endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: 'fw' was not declared in this scope; did you mean 'f'?
   26 |                         fw[k]=x.fi,que.push(P(f[k],k));
      |                         ^~
      |                         f
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,A,cnt,now,sum=0;
bool flag=true,te[1000]={};

int main(){
    cin>>N;
    queue<int> opp[N];
    rep(i,N){
        rep(j,N-1){
            cin>>A;
            A--;
            opp[i].push(A);
        }
    }
    while(flag){
        // out(cnt);
        flag=false;
        bool lo[N];
        // rep(i,N){
        //     lo[i]=false;
        // }
        memcpy(lo,te,sizeof(lo));
        rep(i,N){
            if(lo[i]||opp[i].size()==0)continue;
            now=opp[i].front();
            if(opp[now].front()==i&&!lo[now]){
                flag=true;
                opp[i].pop();
                opp[now].pop();
                lo[i]=lo[now]=true;
                sum+=2;
            }
            lo[i]=true;
        }
        cnt++;
        if(sum==N*(N-1)){
            out(cnt);
            return 0;
        }
    }
    out(-1);
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:9: error: 'memcpy' was not declared in this scope
   46 |         memcpy(lo,te,sizeof(lo));
      |         ^~~~~~
a.cc:14:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include<queue>
  +++ |+#include <cstring>
   14 | using namespace std;
Language: C++

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

int n,a[1005][1005],now[1005],ans=0,tmp[1005],ok;

int read(){
	int s=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')
	s=s*10+c-'0',c=getchar();
	return s;
}

int main(void){
	n=read();
	for(int i=1;i<=n;i++){
		now[i]=1;
		tmp[i]=-1;
		for(int j=1;j<n;j++)
		a[i][j]=read();
	}
	ok=n*(n-1)/2;
	while(1){
		bool check=0;
		int p=0;
		for(int i=1;i<=n;i++){
			if(tmp[u]==ans||tmp[i]==ans)continue;
			if(a[u][now[u]]!=i)continue;
			int u=a[i][now[i]];
			check=1;
			tmp[i]=ans;
			tmp[u]=ans;
			now[u]++;
			now[i]++;
			p+=2;
			ok--;
			if(n-p<2)break;
		}
		ans++;
		if(ok==0)break;
		if(check==0&&ok!=0){
			printf("-1\n");
			return 0;
		}
	}
	printf("%d",ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:32: error: 'u' was not declared in this scope
   30 |                         if(tmp[u]==ans||tmp[i]==ans)continue;
      |                                ^
a.cc:31:30: error: 'u' was not declared in this scope
   31 |                         if(a[u][now[u]]!=i)continue;
      |                              ^
Language: C++

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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in();
    queue<int> a[n];
    for (int i=0;i<n;i++){
        for (int i2=0;i2<n-1;i2++){
            a[i].push(in());
        }
    }
    set<int> emp;
    for (int day=1;true;day++){
        set<int> num;
        int out=0;
        for (int i=0;n<out;i=(i+1)%n){
            if (a[i].empty()) {
                emp.push(i);
                out++;
                continue;
            }
            if (num.count(i)) {
                out++;
                continue;
            }
            if (i==a[a[i].front()].front()){
                num.insert(a[a[i].front()].front());
                num.insert(a[i].front());
                a[a[i].front].pop();
                a[i].pop();
                out=0;
            }
        }
        if (num.empty()){
            cout << "-1" << endl;
            return 0;
        }
        if (emp.size()==n){
            cout << day << endl;
            return 0;
        }
    }
}

Compiler output:
a.cc:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:64:21: error: 'class std::set<int>' has no member named 'push'
   64 |                 emp.push(i);
      |                     ^~~~
a.cc:75:18: error: invalid types 'std::queue<int> [n][<unresolved overloaded function type>]' for array subscript
   75 |                 a[a[i].front].pop();
      |                  ^
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,A,cnt,now,sum=0;
bool flag=true,te[1000]={};

int main(){
    cin>>N;
    queue<int> opp[N];
    rep(i,N){
        rep(j,N-1){
            cin>>A;
            A--;
            opp[i].push(A);
        }
    }
    while(flag){
        // out(cnt);
        flag=false;
        bool lo[N];
        // rep(i,N){
        //     lo[i]=false;
        // }
        memcpy(lo,te,sizeof(bool)*N);
        rep(i,N){
            if(lo[i]||opp[i].size()==0)continue;
            now=opp[i].front();
            if(opp[now].front()==i&&!lo[now]){
                flag=true;
                opp[i].pop();
                opp[now].pop();
                lo[i]=lo[now]=true;
                sum+=2;
            }
            lo[i]=true;
        }
        cnt++;
        if(sum==N*(N-1)){
            out(cnt);
            return 0;
        }
    }
    out(-1);
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:9: error: 'memcpy' was not declared in this scope
   46 |         memcpy(lo,te,sizeof(bool)*N);
      |         ^~~~~~
a.cc:14:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include<queue>
  +++ |+#include <cstring>
   14 | using namespace std;
Language: C++

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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in();
    queue<int> a[n];
    for (int i=0;i<n;i++){
        for (int i2=0;i2<n-1;i2++){
            a[i].push(in());
        }
    }
    set<int> emp;
    for (int day=1;true;day++){
        set<int> num;
        int out=0
        for (int i=0;n<out;i=(i+1)%n){
            if (a[i].empty()) {
                emp.push(i);
                out++;
                continue;
            }
            if (num.count(i)) {
                out++;
                continue;
            }
            if (i==a[a[i].front()].front()){
                num.insert(a[a[i].front()].front());
                num.insert(a[i].front());
                a[a[i].front].pop();
                a[i].pop();
                out=0;
            }
        }
        if (num.empty()){
            cout << "-1" << endl;
            return 0;
        }
        if (emp.size()==n){
            cout << day << endl;
            return 0;
        }
    }
}

Compiler output:
a.cc:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:62:9: error: expected ',' or ';' before 'for'
   62 |         for (int i=0;n<out;i=(i+1)%n){
      |         ^~~
a.cc:62:28: error: 'i' was not declared in this scope
   62 |         for (int i=0;n<out;i=(i+1)%n){
      |                            ^
Language: C++

#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;

int N;
int ans;
bool f[1000];
int A[1000][1000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1; j++) {
			cin >> A[i][j];
		}
	}

	int game = N*(N - 1) / 2;
	vector<int> now(N, 0);
	int e;
	while (game > 0) {
		bool flag = false;
		memset(f, false, sizeof(f));
		for (int i = 0; i < N; i++) {
			if (f[i] || now[i] >= N - 1)continue;
			e = A[i][now[i]] - 1;
			if (A[e][now[e]] == i + 1 && !f[e]) {
				flag = true;
				game--;
				now[e]++;
				now[i]++;
				f[e] = f[i] = true;
			}
		}
		if (!flag) {
			cout << -1 << endl; return 0;
		}
		ans++;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: 'memset' was not declared in this scope
   25 |                 memset(f, false, sizeof(f));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<vector>
  +++ |+#include <cstring>
    4 |
Language: C

#include<stdio.h>
int main()
{
  int n,ans=0;
  int dayMax,temp = 0;
  int all[1000][1000] //N，N-1　
  scanf("%d",&n);
  dayMax = n/2;
  for(int i = 0;i<n;i++)
    for(int j = 0;i<n-1;j++)
  		scanf("%d",&all[i][j]);
  for(int j = 0;j<n-1;i++)
    for(int i = 0;i<n;i++)
    {
      if(all[i][j]!=-1)
      {
        	if(all[(all[i][j]-1)][j]!=i&&all[(all[i][j]-1)][j]!=-1)
            {
              ans = -1;
              goto end;
            }
        else
        {
          	temp++;
        	all[i][j]=-1;
          	all[(all[i][j]-1)][j]=-1;
        }
        	
      }
      
    }
  
  end:;
  printf("%d\n",ans);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'scanf'
    7 |   scanf("%d",&n);
      |   ^~~~~
main.c:11:29: error: 'all' undeclared (first use in this function)
   11 |                 scanf("%d",&all[i][j]);
      |                             ^~~
main.c:11:29: note: each undeclared identifier is reported only once for each function it appears in
main.c:12:23: error: 'i' undeclared (first use in this function)
   12 |   for(int j = 0;j<n-1;i++)
      |                       ^
Language: C++

#include<iostream>
#include<vector>
#include<set>

using namespace std;

int N;
int ans;
bool f[1000];
int A[1000][1000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1; j++) {
			cin >> A[i][j];
		}
	}

	int game = N*(N - 1) / 2;
	vector<int> now(N, 0);
	int e;
	while (game > 0) {
		bool flag = false;
		memset(f, false, sizeof(f));
		for (int i = 0; i < N; i++) {
			if (f[i] || now[i] >= N - 1)continue;
			e = A[i][now[i]] - 1;
			if (A[e][now[e]] == i + 1 && !f[e]) {
				flag = true;
				game--;
				now[e]++;
				now[i]++;
				f[e] = f[i] = true;
			}
		}
		if (!flag) {
			cout << -1 << endl; return 0;
		}
		ans++;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: 'memset' was not declared in this scope
   25 |                 memset(f, false, sizeof(f));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<set>
  +++ |+#include <cstring>
    4 |
Language: C

#include<stdio.h>
int main()
{
  int n,ans=0;
  int dayMax,temp = 0;
  all[1000][1000] //N，N-1　
  scanf("%d",&n);
  dayMax = n/2;
  for(int i = 0;i<n;i++)
    for(int j = 0;i<n-1;j++)
  		scanf("%d",&all[i][j]);
  for(int j = 0;j<n-1;i++)
    for(int i = 0;i<n;i++)
    {
      if(all[i][j]!=-1)
      {
        	if(all[(all[i][j]-1)][j]!=i&&all[(all[i][j]-1)][j]!=-1)
            {
              ans = -1;
              goto end;
            }
        else
        {
          	temp++;
        	all[i][j]=-1;
          	all[(all[i][j]-1)][j]=-1;
        }
        	
      }
      
    }
  
  end:;
  printf("%d\n",ans);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:3: error: 'all' undeclared (first use in this function)
    6 |   all[1000][1000] //N，N-1　
      |   ^~~
main.c:6:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:6:18: error: expected ';' before 'scanf'
    6 |   all[1000][1000] //N，N-1　
      |                  ^
      |                  ;
    7 |   scanf("%d",&n);
      |   ~~~~~           
main.c:12:23: error: 'i' undeclared (first use in this function)
   12 |   for(int j = 0;j<n-1;i++)
      |                       ^
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int a[1000][1000];
int cnt[1000];
int us[1000][499500];
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void){
  int n,c=0,ans;
  scanf("%d",&n);
  FOR(n)FORJ(n-1)scanf("%d",&a[i][j]);
  for(ans=0;c*2<n*(n-1);ans++){
    int flg=1;
    FOR(n){
      int j=a[i][cnt[i]]-1;
      if(cnt[i]==n-1||us[i][ans])continue;
      if(us[j][ans])continue;
      if(i+1==a[j][cnt[j]]){
        us[i][ans]++;
        us[a[i][cnt[i]]-1][ans]++;
        cnt[a[i][cnt[i]]-1]++;
        cnt[i]++;
        c++;
        flg=0;
      }
    }
    if(fld){
      ans=-1;
      break;
    }
  }
  PRN(ans);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:58:8: error: 'fld' undeclared (first use in this function); did you mean 'flg'?
   58 |     if(fld){
      |        ^~~
      |        flg
main.c:58:8: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int a[1005][1005];
int pos[1005];
bool vis[1005];
set<int> st;
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		pos[i] = 1; st.insert(i);
		for (int j = 1; j < n; j++)
			cin >> a[i][j];
	}
	int cnt = 0;
	while (!st.empty())
	{
		memset(vis, false, sizeof(vis));
		for (int i = 1; i <= n; i++)
		{
			if (vis[i] || vis[a[i][pos[i]]] || pos[i] >= n)continue;
			if (i == a[a[i][pos[i]]][pos[a[i][pos[i]]]])
			{
				vis[i] = true, vis[a[i][pos[i]]] = true;
				pos[a[i][pos[i]]]++; if (pos[a[i][pos[i]]] >= n)st.erase(a[i][pos[i]]);
				pos[i]++; if (pos[i] >= n)st.erase(i);
			}
		}
		cnt++;
		if (cnt > n * (n - 1) / 2)
		{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

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

typedef pair<int,int> pii;
const int N=1010;
inline int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}
int n;
vector<int>e[N*N];
int Tot;

map<pii,int>mp;
inline int hash(int i,int j){
	if(i>j)swap(i,j);
	if(!mp[make_pair(i,j)]){
		mp[make_pair(i,j)]=++Tot;
	}
	return (mp[make_pair(i,j)]);
}
stack<int>s;
int dfn[N*N],low[N*N],insta[N*N],tot,cnt;
void tarjan(int x){
    dfn[x]=low[x]=++tot;
    s.push(x);insta[x]=1;
    for(int i=0;i<e[x].size();i++){
		int y=e[x][i];
		if(dfn[y]==0){
			tarjan(y);
			low[x]=min(low[x],low[y]);
		}
		else if(insta[y])low[x]=min(low[x],dfn[y]);
	}
	int k;
    if(low[x]==dfn[x]){
        cnt++;
        do{
            k=s.top();s.pop();
            insta[k]=0;
        }while(x!=k);
    }
}
int ans=0;
void dfs(int x,int di){
	ans=max(ans,di);
	for(int i=0;i<e[x].size();i++){
		int y=e[x][i];
		dfs(y,di+1);
	}
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		int lst=read();
		for(int j=2;j<n;j++){
			int a=read();
			int id1=hash(i,lst),id2=hash(i,a);
			e[id1].push_back(id2);
			lst=a;
		}
	}
	for(register int i=1;i<=Tot;i++)if(!dfn[i])tarjan(i);
	if(cnt!=Tot){puts("-1");return 0;}
	
	for(register int i=1;i<=n;i++)dfs(i,1);
	printf("%d\n",ans);
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:33: error: reference to 'hash' is ambiguous
   60 |                         int id1=hash(i,lst),id2=hash(i,a);
      |                                 ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:17:12: note:                 'int hash(int, int)'
   17 | inline int hash(int i,int j){
      |            ^~~~
a.cc:61:42: error: 'id2' was not declared in this scope; did you mean 'id1'?
   61 |                         e[id1].push_back(id2);
      |                                          ^~~
      |                                          id1
a.cc:65:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   65 |         for(register int i=1;i<=Tot;i++)if(!dfn[i])tarjan(i);
      |                          ^
a.cc:68:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   68 |         for(register int i=1;i<=n;i++)dfs(i,1);
      |                          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<"### "<<x<<endl;
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
const int N=1010;
inline int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}
int n;
vector<int>e[N*N];
int hashcnt;

map<pair<int,int> ,int>mp;
inline int hash(int i,int j){
	if(i>j)swap(i,j);
	if(!mp[make_pair(i,j)]){
		mp[make_pair(i,j)]=++hashcnt;
	}
	return mp[make_pair(i,j)];
}
stack<int>s;
int dfn[N*N],low[N*N],insta[N*N],tot,cnt;
void tarjan(int x){
    dfn[x]=low[x]=++tot;
    s.push(x);insta[x]=1;
    for(int i=0;i<e[x].size();i++){
		int y=e[x][i];
		if(dfn[y]==0){
			tarjan(y);
			low[x]=min(low[x],low[y]);
		}
		else if(insta[y])low[x]=min(low[x],dfn[y]);
	}
	int k;
    if(low[x]==dfn[x]){
        cnt++;
        do{
            k=s.top();s.pop();
            insta[k]=0;
        }while(x!=k);
    }
}
int ans=0;
void dfs(int x,int di){
	ans=max(ans,di);
	for(int i=0;i<e[x].size();i++){
		int y=e[x][i];
		dfs(y,di+1);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int lst;scanf("%d",&lst);
		for(int j=2;j<n;j++){
			int a;scanf("%d",&a);
			int id1=hash(i,lst),id2=hash(i,a);
			e[id1].push_back(id2);
			lst=a;
		}
	}
	for(int i=1;i<=hashcnt;i++)if(!dfn[i])tarjan(i);
	if(cnt!=hashcnt){puts("-1");return 0;}
	
	for(int i=1;i<=n;i++){
		dfs(i,1);
	}
	printf("%d\n",ans);
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:33: error: reference to 'hash' is ambiguous
   61 |                         int id1=hash(i,lst),id2=hash(i,a);
      |                                 ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:18:12: note:                 'int hash(int, int)'
   18 | inline int hash(int i,int j){
      |            ^~~~
a.cc:62:42: error: 'id2' was not declared in this scope; did you mean 'id1'?
   62 |                         e[id1].push_back(id2);
      |                                          ^~~
      |                                          id1
Language: C++

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vector<queue<int> > a(n);
	REP(i,n)REP(j,n-1){
		int aa;
		cin>>aa;
		a[i].push(aa-1);
	}
	
	llong day=0;
	vector<bool> jud(n,true);//empty.
	while(1){
		vector<bool> jud2(n,true);//day.
		bool jud3=true;
		
		day++;
		REP(i,n){
			if(jud[i]&&jud2[i]){
				int b=a[i].push();
				if(jud[b]&&jud2[i]){
					int tmp=a[b].push();
					if(tmp==i){
						a[i].pop();
						a[b].pop();
						jud2[i]=false;
						jud2[b]=false;
						if(a[i].empty()) jud[i]=false;
						if(a[b].empty()) jud[b]=false;
						jud3=false;
					}
				}
			}
		}
		
		if(jud3){
			cout<<-1<<endl;
			return 0;
		}
	}
	
	cout<<day<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:48: error: no matching function for call to 'std::queue<int>::push()'
   34 |                                 int b=a[i].push();
      |                                       ~~~~~~~~~^~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]'
  283 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]'
  288 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note:   candidate expects 1 argument, 0 provided
a.cc:36:58: error: no matching function for call to 'std::queue<int>::push()'
   36 |                                         int tmp=a[b].push();
      |                                                 ~~~~~~~~~^~
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]'
  283 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]'
  288 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note:   candidate expects 1 argument, 0 provided
Language: Java

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

class CP {
	public static void main(String[] args) throws Exception {
		Scanner io = new Scanner(System.in);
		int i, j, k;
		
		Comparator<int[]> com = new Comparator<int[]>() {
			@Override
			public int compare(int[] a, int[] b) {
				for (int i = a.length - 1; i >= 0; --i) if (a[i] != b[i]) 
					return Integer.compare(a[i], b[i]);
				return 0;
			}
		};
		
	
		int N = io.nextInt();
		TreeSet<int[]>[] graph = new TreeSet[N];
		for (i = 0; i < N; ++i) graph[i] = new TreeSet<>(com);
		
		for (i = 0; i < N; ++i) for (j = 0; j < N - 1; ++j) {
			int[] edge = new int[] {i, io.nextInt() - 1, j};
			graph[i].add(edge);
		}
		
		int match = 0;
		HashSet<Integer> exc = new HashSet<>();
		for (i = 1; ; ++i) {
			exc.clear();
			boolean ok = false;
			
			for (j = 0; j < N; ++j) if (!graph[j].isEmpty() && !exc.contains(j)) {
				int oth = graph[j].first() [1];
				if (graph[oth].first() [1] == j) {
					ok = true;
					graph[j].pollFirst();
					graph[oth].pollFirst();
					exc.add(oth);
					++match;
					
					//System.err.println("PPP: " + j + " " + oth);
				}
			}
			
			if (!ok) {
				if (match == N * (N - 1) >> 1) {
					System.out.println(i);
				} else {
					System.out.println(-1);
				}
				return;
			}
		}
 	}
}

Compiler output:
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e6+10;
int n,m=1003;
int b[1005],c[1005];
int ct[1010],bit[1005];
vector<int> a[maxn];
vector<int> topo;
vector<int> all;

bool vis[maxn],d[maxn],ok;
void topsort(int nod){
    vis[nod]=true;
    d[nod]=true;
    for(int i:a[nod]){
        if(!vis[i]){
            topsort(i);
        }
        else if(d[i]){
            ok=false;
        }
    }
    d[nod]=false;
    topo.push_back(nod);
}
int get(int idx){
    int sum=0;
    while(idx>0){
        sum+=(bit[idx]);
        idx-=(idx&(-idx));
    }
    return sum;
}
void update(int idx,int val){
    while(idx<=m){
        bit[idx]+=val;
        idx+=(idx&(-idx));
    }
    return;
}
int getat(int x){
    return get(x)-get(x-1);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            scanf("%d",&b[j]);
            int x=i,y=b[j];
            if(x>y)swap(x,y);
            c[j]=(n+1)*x+y;
            all.push_back(c[j]);
           /// cout<<c[j]<<' ';
        }
       /// cout<<'\n';
        for(int j=1;j+1<n;j++){
            a[c[j]].push_back(c[j+1]);
        }

    }
    ok=true;
    topsort(n+3);
    if(!ok)return !printf("-1");
    printf("%d\n",ans);
}
/*
    Good Luck
        -Lucina
*/


Compiler output:
a.cc: In function 'int main()':
a.cc:64:19: error: 'ans' was not declared in this scope; did you mean 'abs'?
   64 |     printf("%d\n",ans);
      |                   ^~~
      |                   abs
Language: C++

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

int main()
{
    int N;
    cin >> N;
    int Aij;
    vector<vector<int>> A(N, vector<int>(N-1));
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin >> Aij;
            A[i][j] = Aij-1;
        }
    }
    vector<int> i_cur(N-1, 0);
    set<int> s;
    ll res = 0;
    while(true){
        for(int i=0; i<N; i++){
            if(i_cur[i]==N-1) continue;
            if(s.count(i)) continue;
            auto i_next = A[i][i_cur[i]];
            if(i_cur[i_next]==N-1) continue;
            if(A[i_next][i_cur[i_next]] == i){
                s.insert(i);
                s.insert(i_next);
            }
        }
        if(s.empty()){
            for(int i=0; i<N; i++){
                if(i_cur[i]!=N-1){
                    cout<<"-1"<<endl;
                    return 0;
                }
            }
            cout<<res<<endl;
            return 0;
        }

        for(auto v : s){
            i_cur[v]++;
        }

        res++;
        s.clear();
    }

}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'll' was not declared in this scope
   18 |     ll res = 0;
      |     ^~
a.cc:37:19: error: 'res' was not declared in this scope
   37 |             cout<<res<<endl;
      |                   ^~~
a.cc:45:9: error: 'res' was not declared in this scope
   45 |         res++;
      |         ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define show(x) #x " = " << x
#define mp make_pair
#define quit(x) { cout << (x) << endl; return 0; }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }

template <class T> typename conditional<true, ostream&, decltype(declval<T>().begin())>::type operator<<(ostream& os, T const& v) { for (auto const& x : v) os << x << " "; return os; }
template <class T> typename conditional<true, istream&, decltype(declval<T>().begin())>::type operator>>(istream& is, T& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.fst << ", " << p.snd << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.fst >> p.snd; }
struct _Init { _Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init;

int main() {
    int n; cin >> n;
    int N = n*(n-1)/2;
    vector<vector<int> > g(N);
    vector<int> cnt(N);
    map<pair<int,int>, int> m;
    int c = 0;
    rep (i,n) rep (j,n) if (i < j) m[mp(i,j)] = c++;
    rep (i,n) rep (j,n) if (i > j) m[mp(i,j)] = m[mp(j,i)];

    rep (i,n) {
        vector<int> a(n-1);
        rep (j,n-1) cin >> a[j], a[j]--;
        rep (j,n-2) {
            int x = m[mp(i,a[j])];
            int y = m[mp(i,a[j+1])];
            g[x].push_back(y);
            cnt[y]++;
        }
    }

    deque<int> q;
    rep (i,N) if (cnt[i] == 0) q.push_back(i);
    vector<int> a;
    while (!q.empty()) {
        int x = q.front(); q.pop_front();
        a.push_back(x);
        for (int y : g[x]) if (--cnt[y] == 0) q.push_back(y);
    }

    if (a.size() != N) quit(-1);

    vector<int> d(N,1);
    rep (i,N) {
        int x = a[i];
        for (int y : g[x]) chmax(d[y],d[x]+1);
    }

    rep (i,N) for (int j : g[i]) if (d[i] >= d[j]) quit(-1);
    cout << *max_element(all(d)) << endl;
}


Compiler output:
/usr/bin/ld: /tmp/ccTKow85.o:(.bss+0x0): multiple definition of `_init'; /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here
collect2: error: ld returned 1 exit status