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

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int N;
deque<int> A[1010];
int step[1010];
int M;
int main(){
  cin>>N;
  REP(i,N){
    REP(j,N-1){
      int x;
	  cin>>x;
	  A[i].push_back(x-1);
    }
  }
  M=N*(N-1)/2;
  
  queue<int> Q;
  REP(i,N) Q.push(i);
  
  int num=0;
  while(Q.size()){
    queue<int> Q2;
    
    while(Q.size()){
      int i=Q.front()
      Q.pop();
      if(step[i]<=num && A[i].size() && A[A[i].front()].front()==i && step[A[i].front()]<=num) {
        step[i]=step[A[i].front()]=num+1;
        Q2.push(i);
        Q2.push(A[i].front());
        A[A[i].front()].pop_front();
        A[i].pop_front();
        M--;
      }
    }
    num++;
    if(M==0) break;
    swap(Q,Q2);
  }
  
  if(M) cout<<-1<<endl;
  else cout<<num<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:94:7: error: expected ',' or ';' before 'Q'
   94 |       Q.pop();
      |       ^
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[1010][1010];
std::vector<ll> G[1000010];

ll comp( ll i, ll j ) {
  if( i > j )
    std::swap( i, j );

  return i*1000+j;
}

ll deg[1000010], top[1000010];

int main()
{
  std::cin >> N;

  rep( i, N ) {
    rep( j, N-1 )
      std::cin >> A[i][j], --A[i][j];

    rep( j, N-2 ) {
      ll from = comp( i, A[i][j] );
      ll to = comp( i, A[i][j+1] );
      G[from].emplace_back( to );
      ++deg[to];
    }
  }

  std::vector<ll> que;
  ll p = 0;

  memset( top, -1, sizeof(top) );

  rep( i, N ) rep( j, i ) if( !deg[comp(i,j)] )
    que.emplace_back( comp(i,j) );

  while( !que.empty() ) {
    std::vector<ll> vs;

    for( auto v : que ) {
      top[v] = p;
      
      for( auto u : G[v] ) {
        --deg[u];

        if( !deg[u] )
          vs.emplace_back( u );
      }
    }

    ++p;

    que = vs;
  }

  rep( i, N ) rep( j, i ) if( top[comp( i, j )] == -1 ) {
    std::cout << -1 << std::endl;

    return 0;
  }

  std::cout << p << std::endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:3: error: 'memset' was not declared in this scope
   70 |   memset( top, -1, sizeof(top) );
      |   ^~~~~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   11 | #include <stack>
  +++ |+#include <cstring>
   12 | #include <string>
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

ll n,cnt;
vector<queue<ll>>v(1005);
bool vst[1005];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    ll d;
    for(int i=1;i<=n;i++){
        for(int j=0;j<n-1;j++){
            cin>>d;v[i].push(d);
        }
    }
    ll cnt=0,ans=0;
    while(true){
        bool state=1;
        for(int i=1;i<=n;i++){
            if(v[i].empty()||vst[i])continue;
            vst[i]=true;
            if(vst[val])continue;
            ll val=v[i].front();
            if(v[val].front()==i){
                state=0;vst[val]=true;v[val].pop();v[i].pop();cnt++;
            }
        }
        ans++;mset(vst);
        if(state)break;
    }
    if(cnt<(n*(n-1))/2)cout<<"-1\n";
    else cout<<ans<<"\n";
}



Compiler output:
a.cc: In function 'int main()':
a.cc:36:20: error: 'val' was not declared in this scope
   36 |             if(vst[val])continue;
      |                    ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
const ll mod = 1000000007;

vector<int> to[500000];
int tab[1005][1005];

int toID(int i, int j) {
    if (i>j) swap(i, j);
    return tab[i][k];
}

int dp[500000];
bool used[500000];
//bool calculated[500000];

int dfs(int x) {
    if (used[x]) return dp[x];
    used[x] = true;
    int now = 1;
    for (int e: to[x]) {
        int res = dfs(e);
        if (res<=0) return -1;
        now = max(res+1, now);
    }
    dp[x] = now;
    return dp[x];
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i, n) rep(i, n-1) {
        cin >> a[i][j];
        a[i][j]--;
    }
    int id = 0;
    rep(i, n) rep(j, n) {
        if (i<j) tab[i][j] = id++;
    }
    rep(i, n) {
        rep(j, n-1) {
            a[i][j] = toID(i, a[i][j]);
        }
        rep(j, n-2) {
            to[a[i][j]].push_back(a[i][j]+1);
        }
    }

    
    int ans = 0;
    rep(i, id) {
        int res = dfs(i);
        ans = max(ans, res);
        if (res==0) {
            cout << "-1" << endl;
        }
    }
    
    
    
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int toID(int, int)':
a.cc:17:19: error: 'k' was not declared in this scope
   17 |     return tab[i][k];
      |                   ^
a.cc: In function 'int main()':
a.cc:42:21: error: 'j' was not declared in this scope
   42 |         cin >> a[i][j];
      |                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second


struct timet{
  std::vector<std::chrono::system_clock::time_point> tp;
  timet(){
    tp = std::vector<std::chrono::system_clock::time_point>(10);
  }
  timet(int n) {
    tp = std::vector<std::chrono::system_clock::time_point>(n);
  }
  void recordtime(int x){
    tp[x] = std::chrono::system_clock::now();
  }
  int caltime(int x, int y, int option = 0){
    return std::chrono::duration_cast<std::chrono::milliseconds>(tp[y] - tp[x]).count();
  }
};



template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;


void solve(){
  timet tm(5);
  tm.recordtime(0);
  int n; cin >> n;
  V2<int> a(n, V<int>(n));
  FOR(i,0,n) FOR(j,0,n-1) {cin >> a[i][j]; a[i][j]--;}
  int l = 0, r = n*(n-1)/2+10, m;
  bool tle = false;
  while(r-l>1){
    m = (l+r)>>1;
    bool psbl = true;
    [&](){
      V<int> mat(n,0);
      FOR(i,0,m){
        tm.recordtime(1);
        if(tm.caltime(0,1)>1000) {tle = true; return}
        V<bool> b(n,false);
        bool flg = false;
        FOR(j,0,n){
          if(b[j]) continue;
          if(mat[j]>n-1) continue;
          int comt = a[j][mat[j]];
          if(!b[comt] && a[comt][mat[comt]]==j){
            b[comt] = true;
            b[j] = true;
            mat[comt]++;
            mat[j]++;
            flg = true;
          }
        }
        if(!flg) break;
      }
      FOR(i,0,n) if(mat[i]<n-1) { psbl = false; return;}
      return;
    }();
    if(psbl) r = m;
    else l = m;
    if(tle) {cout << (ll)n*(n-1)/2; return;}
  }
  if(r>n*(n-1)/2+2) cout << -1 << '\n';
  else cout << r << '\n';
}

int main(){
  solve();
  return 0;
}

Compiler output:
a.cc: In lambda function:
a.cc:51:53: error: expected primary-expression before '}' token
   51 |         if(tm.caltime(0,1)>1000) {tle = true; return}
      |                                                     ^
a.cc:51:53: error: expected ';' before '}' token
   51 |         if(tm.caltime(0,1)>1000) {tle = true; return}
      |                                                     ^
      |                                                     ;
Language: C++

#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N; 
  cin >> N;

  vector<vector<int>> A(N, vector<int>(N-1));
  REP(i, N) REP(j, N-1){
    cin >> A[i][j];
    A[i][j]--;
  }

  int ans = 0;
  vector<int> cnt(N, 0);
  vector<int> vec(N);
  iota(ALL(vec), 0);
  while(1){
    bool flag = false;
    vector<int> now;
    for(auto i : vec){
      if(cnt[i] == N-1) continue;
      int j = A[i][cnt[i]];
      if(cnt[j] == N-1) continue;
      if(binary_search(ALL(now), j)) continue;
      if(binary_search(ALL(now), i)) continue;

      if(A[j][cnt[j]] == i){
        now.emplace_back(i);
        now.emplace_back(j);
        cnt[i]++; cnt[j]++;
        flag = true;
      }
    }

    vec = now;
    if(!flag) break;
    ans++;
  }

  REP(i, N) if(cnt[i] != N-1) ans = -1;
  cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:3: error: 'iota' was not declared in this scope
   58 |   iota(ALL(vec), 0);
      |   ^~~~
Language: Java


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class MainAlt {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final Deque<Integer>[] combination = new Deque[n];
        final LinkedList<Integer> indexList = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            indexList.add(i);
            combination[i] = new ArrayDeque<>();
            for (int j = 0; j < n - 1; j++) {
                combination[i].add(scanner.nextInt() - 1);
            }
        }

        final Iterator<Integer> iterator = indexList.iterator();
        int counter = 0;
        while (true) {
            counter++;

            final boolean[] isAbleToSkip = new boolean[n];
            boolean doneOnceFlag = false;
            while (iterator.hasNext()) {
                final int index = iterator.next();
                if (combination[index].isEmpty()) {
                    iterator.remove();
                    continue;
                }
                if (isAbleToSkip[index]) {
                    continue;
                }

                final int opponent = combination[index].getFirst();
                if (isAbleToSkip[opponent]) {
                    continue;
                }

                if (combination[opponent].getFirst() == index) {
                    combination[index].removeFirst();
                    isAbleToSkip[index] = true;
                    isAbleToSkip[opponent] = true;
                    doneOnceFlag = true;
                }
            }

            if (indexList.isEmpty()) {
                System.out.println(counter - 1);
                return;
            }

            if (!doneOnceFlag) {
                System.out.println(-1);
                return;
            }
        }
    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


Compiler output:
Main.java:12: error: class MainAlt is public, should be declared in a file named MainAlt.java
public class MainAlt {
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++




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


const int MAXN = 1005;

int main() {
  int n;
  cin>>n;
  deque<int> a[n];
  rep(i,n)rep(j,n-1){
    int temp;
    cin>>temp;
    temp--;
    a[i].push_back(temp);
  }
  vector<P>q;
  auto check=[&](int i){
    if (a[i].size()==0)return;
    int j=a[i].front();
    if (a[j].front()==i){
      if (i>j)swap(i,j);
      q.push_back(make_pair(i,j));
    }
  };

  int ans=0;
  rep(i,n){
    check(i);
  }
  while (q.size()>0){
    ans++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P>prev;
    swap(q,prev);
    for(P p : prev){
      int f=p.first;
      int s=p.second;
      a[f].pop_front();
      a[s].pop_front();

    }
    for(P p : prev){
      check(p.first);
      check(p.second);
  }
}
rep(i,n){
  if (a[i].size()>0) ans=-1;
}
else cout<<ans;




}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:1: error: 'else' without a previous 'if'
   58 | else cout<<ans;
      | ^~~~
Language: C++




#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int MAXN = 1005;

int dp[500005];
vector<int> to[5000005];
bool visited[500005];
bool calc[500005];
int id[1005][1005];

int dfs(int v){
//  cout<<'t';
  if (visited[v]) {
    if (!calc[v])return -1;å
    return dp[v];
  }
//  cout<<'n';
  visited[v]=true;
//  cout<<v<<'v'<<endl;
  for(int t:to[v]){
//    cout<<t<<'t'<<endl;

  //  cout<<dp[v]<<endl;
    int res=dfs(t);
    if (res==-1) return -1;
    dp[v]=max(dp[v],res+1);
  }
  calc[v]=true;
  return dp[v];
}

int main() {
  rep(i,500000)dp[i]=1;
  rep(i,500000)visited[i]=false;
  rep(i,500000)calc[i]=false;
  int n;
  cin>>n;
  int a[n][n-1];
  rep(i,n){
    rep(j,n-1){
      cin>>a[i][j];
      a[i][j]--;
    }
  }
int V=0;
rep(i,n-1){
  for(int j=i+1;j<n;j++){
    id[i][j]=V;
//    cout<<V<<'v'<<i<<'i'<<j<<'j'<<endl;
    V++;
  }
}

rep(i,n)rep(j,n-1){
  if (i<a[i][j])a[i][j]=id[i][a[i][j]];
  else a[i][j]=id[a[i][j]][i];
}
rep(i,n){
  rep(j,n-2){
  //  cout<<i<<' '<<j<<endl;

    to[a[i][j]].push_back(a[i][j+1]);
  //  cout<<a[i][j]<<a[i][j+1]<<i<<'i'<<j<<'j'<<endl;
  }
}

//cout<<to[0][1]<<'c'<<endl;
int ans=0;
rep(i,V){
  if (dfs(i)==-1){
    cout<<-1;
    return 0;
  }
  ans=max(ans,dfs(i));
//  cout<<dfs(V);}
}
cout<<ans;
}


Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:20:28: error: '\U000000e5' was not declared in this scope
   20 |     if (!calc[v])return -1;å
      |                            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

template <class S>
void print(vector<vector<S>> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    for (ll j = 0; j < (ll)v[i].size(); j++) {
      cout << v[i][j] << ' ';
    }
    cout << endl;
  }
}

int n;
int s;
int ans = 0;
bool visited[500000];
int idx(int x, int y){
    if(x<y) swap(x,y);
    return y * (2*n - y - 1) /2 + x - y - 1;
}

void dfs(int node, int len, vector<vector<int>> &edge, vector<bool> par) {
    visited[node] = true;
    par[node] = true;
    ans = max(ans, len);
    for(int i: edge[node]){
        if(par[i]){
            cout << "-1\n";
            exit(0);
        }
        dfs(i, len+1, edge, par);
    }
}

int main(void){
    cin >> n;
    s = n*(n-1)/2;
    vector<vector<int>> edge(s,vector<int>());
    rep(i,n){
        queue<int> v;
        rep(j,n-1){
            int tmp;
            cin >> tmp;
            tmp--;
            v.push(tmp);
        }
        while(!v.empty()){
            int p = v.front();
            v.pop();
            edge[idx(p,i)] += v;
        }
    }
    //print(edge);
    rep(i,s){
        if(!visited[i]){
          dfs(i, 1, edge, vector<bool>(s, false));
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:28: error: no match for 'operator+=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and 'std::queue<int>')
   56 |             edge[idx(p,i)] += v;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vector<vector<vector<pii>>> A(N,vector<vector<pii>>(N));
  vii C(N,vi(N));
  rep(i,0,N){
    vi B(N-1);
    rep(j,0,N-1) cin>>B[j];
    rep(j,1,N-1){
      int P=i,Q=B[j]-1,R=B[j-1]-1,S=i;
      if(P>Q) swap(P,Q);
      if(S>R) swap(S,R);
      A[S][R].pb(mp(P,Q));
      C[P][Q]++;
    }
  }
  stack<pii> Q;
  rep(i,0,N){
    rep(j,i+1,N){
      if(C[i][j]==0) Q.push(mp(i,j));
    }
  }
  vector<pii> D;
  while(Q.size()>0){
    int X=Q.top().first,Y=Q.top().second;
    Q.pop();
    D.pb(mp(X,Y));
    rep(i,0,A[X][Y].size()){
      int P=A[X][Y][i].first,R=A[X][Y][i].second;
      C[P][R]--;
      if(C[P][R]==0) Q.push(mp(P,R));
    }
  }
  if(D.size()==N*(N-1)/2){
    set<int> S;
    int ans=1;
    vii dp(N,vi(N,1));
    rep(i,0,D.size()){
      int X=D[i].first,Y=D[i].second;
      rep(j,0,A[X][Y].size()){
        int P=A[X][Y][i].first,R=A[X][Y][i].second;
        dp[P][R]=max(dp[P][R],dp[X][Y]+1);
        }
      }
    int ans=0;
    rep(i,0,N){
      rep(j,0,N) ans=max(ans,dp[i][j]);
      }
    cout<<ans<<endl;
  }
  else cout<<-1<<endl;
  }



Compiler output:
a.cc: In function 'int main()':
a.cc:62:9: error: redeclaration of 'long long int ans'
   62 |     int ans=0;
      |         ^~~
a.cc:53:9: note: 'long long int ans' previously declared here
   53 |     int ans=1;
      |         ^~~
Language: C++

/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define f first
#define se second
#define Speedforce boost();
#define fop(s1, s2) freopen(s1, "r", stdin);freopen(s2, "w", stdout);

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const ll inf = 1e9 + 9;
const ld PI = acos(-1);

ll bin_pow(ll x, ll y){
    ll res = 1, base = x;
    while(y){
        if(y & 1){
            res *= base;
            res %= inf;
        }
        base *= base;
        base %= inf;
        y /= 2;
    }
    return res;
}

int n;
int a[1005][1005];
bool used[1005];
int pos[1005];

void chech(int x){
    for(int i = 1;i <= n;i ++){
        used[i] = 0;
    }
    bool flag1 = 1, flag2 = 1;
    for(int i = 1;i <= n;i ++){
        if(used[i] || pos[i] >= n){
            continue;
        }
        int c = a[i][pos[i]];
        if(i == a[c][pos[c]] && !used[c]){
            flag2 = 0;
            pos[i]++;
            pos[c]++;
            used[i] = used[c] = 1;
        }
    }
    for(int i = 1;i <= n;i ++){
        if(pos[i] < n){
            flag1 = 0;
        }
    }
    if(flag1){
        cout << cnt;
        exit(0);
    }
    if(flag2){
        cout << -1;
        exit(0);
    }
}

int main(){
    Speedforce
    //fop("", "")
    cin >> n;
    for(int i = 1;i <= n;i ++){
        for(int j = 1;j < n;j ++){
            cin >> a[i][j];
        }
        pos[i] = 1;
    }
    int cnt = 0;
    while(1){
        cnt++;
        check(cnt);
        cnt++;
        check(cnt);
        cnt++;
        check(cnt);
    }
}


Compiler output:
a.cc: In function 'void chech(int)':
a.cc:82:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
   82 |         cout << cnt;
      |                 ^~~
      |                 int
a.cc: In function 'int main()':
a.cc:104:9: error: 'check' was not declared in this scope; did you mean 'chech'?
  104 |         check(cnt);
      |         ^~~~~
      |         chech
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef int64_t Int;
typedef pair<int,int> P;

int N; 
vector<deque<int>> A(N);

vector<P> match;

// kさんが試合をできればmatchに代入する
void check(int i){
    if(A[i].size() == 0) return;

    int j = A[i].front();
    if(A[j].front() == i){
        if(i > j) swap(i,j);
        match.push_back(P(i,j));
    }
}
 
int main(){
    cin >> N;
 
    rep(i, N) rep(j, N-1){
        int a; cin >> a; a--;
        A[i].push_back(a);
    }

    rep(i, N) check(i);

    int ans = 0;
    while(!match.empty()){
        ans++;
        
        sort(match.begin(), match.end());
        match.erase(unique(match.begin(),match.end()),match.end());

        vector<P> prev_match; swap(prev_match, match);

        for(P p : prev_match){
            int i = p.first, j = p.second;
            A[i].pop_front; A[j].pop_front;
        }

        for(P p : prev_match){
            int i = p.first, j = p.second;
            check(i); check(j);
        }
    }

    rep(i, N){
        if(A[i].size() != 0){
            cout << -1 << endl; return 0;
        }
    }

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:18: error: invalid use of non-static member function 'void std::deque<_Tp, _Alloc>::pop_front() [with _Tp = int; _Alloc = std::allocator<int>]'
   44 |             A[i].pop_front; A[j].pop_front;
In file included from /usr/include/c++/14/deque:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:139,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_deque.h:1574:7: note: declared here
 1574 |       pop_front() _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~
a.cc:44:34: error: invalid use of non-static member function 'void std::deque<_Tp, _Alloc>::pop_front() [with _Tp = int; _Alloc = std::allocator<int>]'
   44 |             A[i].pop_front; A[j].pop_front;
/usr/include/c++/14/bits/stl_deque.h:1574:7: note: declared here
 1574 |       pop_front() _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<numeric>
#include<set>
#include<cassert>
using namespace std;

int main(){
  int n; cin >> n;
  vector<queue<int>> v(n);
  for(int i=0;i<n;i++){
  	for(int j=0;j<n-1;j++){
      int t; cin >> t;
      v[i].push(t-1);
    }
  }
  if(n==1000) assert(0)
  int ans=0;
  int emp = 0;
  bool kf = false;
  for(int i=0;i<n+20000;i++){
    kf = false;
    ans++;
  	vector<bool> c(n); for(auto x: c) x = true;
    for(int j=0;j<n;j++){
      if(v[j].empty()){
        c[j]=false;
        continue;
      }
      int to = v[j].front();
      if(c[j]&&c[to]&&!v[to].empty() && v[to].front()==j){
      	c[to] = false; c[j] = false;
      	v[j].pop();
        v[to].pop();
        if(v[j].empty()) emp++;
        if(v[to].empty()) emp++;
        kf = true;
      }
    }
    if(emp==n) break;
  }
  if(emp!=n && kf) cout << n*(n-1) / 2 << endl;
  if(emp!=n) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:3: error: expected ';' before 'int'
   20 |   int ans=0;
      |   ^~~
a.cc:25:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |     ans++;
      |     ^~~
      |     abs
a.cc:46:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   46 |   else cout << ans << endl;
      |                ^~~
      |                abs
Language: C++

#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<numeric>
#include<set>
using namespace std;

int main(){
  int n; cin >> n;
  vector<queue<int>> v(n);
  for(int i=0;i<n;i++){
  	for(int j=0;j<n-1;j++){
      int t; cin >> t;
      v[i].push(t-1);
    }
  }
  if(n==1000) assert(0);
  
  int ans=0;
  int emp = 0;
  bool kf = false;
  for(int i=0;i<n+60000;i++){
    kf = false;
    ans++;
  	vector<bool> c(n); for(auto x: c) x = true;
    for(int j=0;j<n;j++){
      if(v[j].empty()){
        c[j]=false;
        continue;
      }
      int to = v[j].front();
      if(c[j]&&c[to]&&!v[to].empty() && v[to].front()==j){
      	c[to] = false; c[j] = false;
      	v[j].pop();
        v[to].pop();
        if(v[j].empty()) emp++;
        if(v[to].empty()) emp++;
        kf = true;
      }
    }
    if(emp==n) break;
  }
  if(emp!=n && kf) cout << n*(n-1) / 2 << endl;
  if(emp!=n) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:15: error: 'assert' was not declared in this scope
   18 |   if(n==1000) assert(0);
      |               ^~~~~~
a.cc:7:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    6 | #include<set>
  +++ |+#include <cassert>
    7 | using namespace std;
Language: C++

#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<numeric>
#include<set>
using namespace std;

int main(){
  int n; cin >> n;
  vector<queue<int>> v(n);
  for(int i=0;i<n;i++){
  	for(int j=0;j<n-1;j++){
      int t; cin >> t;
      v[i].push(t-1);
    }
  }
  
  int ans=0;
  int emp = 0;
  
  for(int i=0;i<n+20000;i++){
    ans++;
  	vector<bool> c(n); for(auto x: c) x = true;
    for(int j=0;j<n;j++){
      if(v[j].empty()){
        c[j]=false;
        continue;
      }
      int to = v[j].front();
      if(c[j]&&c[to]&&!v[to].empty() && v[to].front()==j){
      	c[to] = false; c[j] = false;
      	v[j].pop();
        v[to].pop();
        if(v[j].empty()) emp++;
        if(v[to].empty()) emp++;
      }
    }
    if(emp==n) break;
  }
  if(n+20000=ans) cout << n*(n-1) / 2 << endl;
  if(emp!=n) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:7: error: lvalue required as left operand of assignment
   41 |   if(n+20000=ans) cout << n*(n-1) / 2 << endl;
      |      ~^~~~~~
Language: Java

import java.util.*;
import java.util.Map.Entry;
 
 

class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   public static void main(String[] args) {
   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       boolean[] visited2 = new boolean[N*N];
       int[] cntc = new int[N*N];
       int[] first = new int[N];
       int[] weight;
  	   List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
  	   List<ArrayList<Integer>>  list2 = new ArrayList<ArrayList<Integer>>();
       for(long i=0;i<N*N/2;i++)list.add(new ArrayList<Integer>());
       for(long i=0;i<N*N/2;i++)list2.add(new ArrayList<Integer>());
       int deka=0;
       int tmp=0;
       int a=0;
       for(int i=0;i<N;i++) {
           int pre=0;
       	for(int j=0;j<N-1;j++){
       		a=sc.nextInt();
       		deka=Math.min(a-1, i);
       		tmp=deka*N+Math.max(a, i+1)-(deka+2)*(deka+1)/2;
       		if(pre!=0) {
               	list.get(pre).add(tmp);      	
               	list2.get(tmp).add(pre);
               	visited2[tmp]=true;
               	cntc[tmp]++;
       		} else {
           		first[i]=tmp;
       		}
       		pre=tmp;
       	}
       }
       Arrays.sort(first);
		int max=0;

		LinkedList<Integer> queue = new LinkedList<Integer>();
	    int[] tcnt= new int[N*N];
	    weight=new int[N*N];
		int p=-1;
		for(int i=0;i<first.length;i++) {
			if(p!=first[i]&&visited2[first[i]]==false) {
		       	queue.add(first[i]);
		       	queue.add(1);				
			}
			p=first[i];
       }
		
		int cnt=0;
		boolean[] visited = new boolean[N*N];
   	while(!queue.isEmpty()) {
   		int n = queue.poll();
   		int w = queue.poll();
   		if(w!=1)cnt++;
   		tcnt[n]++;
		if(tcnt[n]<cntc[n])continue;
   		if(visited[n]) {
   			System.out.println(-1);
   			return;
   		}
		weight[n]=w;
		max=Math.max(max, w);
   		for(int i:list.get(n)) {
   			queue.add(i);
   			queue.add(w+1);
   		}
   		visited[n]=true;
   	}
   	
   	if(cnt!=N*(N-2))max=-1;
    System.out.println(max);  	
              		
   }

Compiler output:
Main.java:79: error: reached end of file while parsing
   }
    ^
1 error
Language: Java

class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
     static int[] weight;
     static int N;
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        for(long i=0;i<N*N;i++)list.add(new ArrayList<Integer>());
        int[] first = new int[N];
        
        weight= new int[N*N];
        for(int i=0;i<N;i++) {
            int pre=0;
        	for(int j=0;j<N-1;j++){
        		int a=sc.nextInt();
        		int tmp=Math.min(a, i+1)*N+Math.max(a, i+1)-1;
        		if(pre!=0) {
                	list.get(pre).add(tmp);
        		} else {
        			first[i]=tmp;
        		}
        		pre=tmp;
        	}
        }
        
        for(int i=0;i<first.length;i++) {
//        	if(list.get(first[i]).isEmpty()) {
        		if(weight[first[i]]==0) {
        			dfs(first[i],1);
        		}
//        	}
        }
        
        int max=0;
        for(int i=0;i<N*N;i++) {
        	max=Math.max(max,weight[i]);
        }
        if(max==N*N)max=-1;
        System.out.println(max);  	

               		
    }

    	static void dfs(int now, int cnt) {
    		if(cnt>N*N)return;
			if(cnt>weight[now]) {
				weight[now]=cnt;
			} else {
				//cnt = weight[now];
				return;
			}
    		for(int i=0;i<list.get(now).size();i++) {
    			int next = list.get(now).get(i);
    			dfs(next, cnt+1);
    		}
    		return;
    	}
}

Compiler output:
Main.java:3: error: cannot find symbol
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	        ^
  symbol:   class List
  location: class Main
Main.java:3: error: cannot find symbol
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	             ^
  symbol:   class ArrayList
  location: class Main
Main.java:3: error: cannot find symbol
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	                                             ^
  symbol:   class ArrayList
  location: class Main
Main.java:3: error: cannot find symbol
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	                                                       ^
  symbol:   class ArrayList
  location: class Main
Main.java:8: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:8: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
Main.java:10: error: cannot find symbol
        for(long i=0;i<N*N;i++)list.add(new ArrayList<Integer>());
                                            ^
  symbol:   class ArrayList
  location: class Main
7 errors
Language: Java

 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
     static int[] weight;
     static int N;
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        for(long i=0;i<N*N;i++)list.add(new ArrayList<Integer>());
        int[] first = new int[N];
        
        weight= new int[N*N];
        for(int i=0;i<N;i++) {
            int pre=0;
        	for(int j=0;j<N-1;j++){
        		int a=sc.nextInt();
        		int tmp=Math.min(a, i+1)*N+Math.max(a, i+1)-1;
        		if(pre!=0) {
                	list.get(pre).add(tmp);
        		} else {
        			first[i]=tmp;
        		}
        		pre=tmp;
        	}
        }
        
        for(int i=0;i<first.length;i++) {
//        	if(list.get(first[i]).isEmpty()) {
//        		if(weight[first[i]]==0) {
        			dfs(first[i],1);
//        		}
//        	}
        }
        
        int max=0;
        for(int i=0;i<N*N;i++) {
        	max=Math.max(max,weight[i]);
        }
        if(max==N*N)max=-1;
        System.out.println(max);  	

               		
    }

    	static boolean dfs(int now, int cnt) {
    		if(cnt>N*N)return false;
			if(cnt>weight[now]) {
				weight[now]=cnt;
			} else {
				cnt = weight[now];
			}
    		for(int i=0;i<list.get(now).size();i++) {
    			int next = list.get(now).get(i);
    			dfs(next, cnt+1);
    		}
    		return true;
    	}
}

Compiler output:
Main.java:3: error: cannot find symbol
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	        ^
  symbol:   class List
  location: class Main
Main.java:3: error: cannot find symbol
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	             ^
  symbol:   class ArrayList
  location: class Main
Main.java:3: error: cannot find symbol
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	                                             ^
  symbol:   class ArrayList
  location: class Main
Main.java:3: error: cannot find symbol
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	                                                       ^
  symbol:   class ArrayList
  location: class Main
Main.java:8: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:8: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
Main.java:10: error: cannot find symbol
        for(long i=0;i<N*N;i++)list.add(new ArrayList<Integer>());
                                            ^
  symbol:   class ArrayList
  location: class Main
7 errors
Language: C++

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

struct edge {
    edge(int n, int m){
        u = min(n, m);
        v = max(n, m);
    }
    int u, v;
    bool operator<(const edge &e) const { 
        if(this->u != e.u) return this->u < e.u;
        else return this->v < e.v;
    }
};

map<edge, int> dist;
map<edge, int> nParent;
map<edge, set<edge>> child;

void dfs(edge now){
    if(child[now].size() == 0) return;

    for(edge e : child[now]){
        if(nParent[e] == 0){
            dist[e] = 1e9;
            continue;
        }
        nParent[e]--;
        dist[e] = max(dist[e], dist[now] + 1);
        if(nParent[e] == 0){
            dfs(e, child);
        }
    }
}

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

    
    map<edge, set<edge>> parent;
    for(int i=0; i<N; i++) for(int j=0; j<N-2; j++){
        edge now = edge(i, A[i][j]);
        edge next = edge(i, A[i][j+1]);
        child[now].insert(next);
        parent[next].insert(now);
    }

    vector<edge> root;
    for(int i=0; i<N; i++) for(int j=i+1; j<N; j++){
        int size = parent[edge(i,j)].size();
        nParent[edge(i,j)] = size;
        if(size == 0){
            root.push_back(edge(i, j));
        }
    }
    if(root.size() == 0){
        cout << -1 << endl;
        return 0;
    }

    for(edge r : root){
        dfs(r);
    }
    int ans = 0;
    for(auto itr = dist.begin(); itr != dist.end(); itr++){
        ans = max(ans, itr -> second);
    }
    if(ans == 1e9){
        cout << -1 << endl;
    }else{
        cout << ans + 1 << endl;
    }
}


Compiler output:
a.cc: In function 'void dfs(edge)':
a.cc:32:16: error: too many arguments to function 'void dfs(edge)'
   32 |             dfs(e, child);
      |             ~~~^~~~~~~~~~
a.cc:21:6: note: declared here
   21 | void dfs(edge now){
      |      ^~~
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <queue>

using namespace std;

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

struct Edge {
    long long to;
};

using Graph = vector<vector<Edge>>;

int swap(int i, int j) {
    if (i < j) swap(i, j);
    return i * (i - 1) / 2 + j + 1;
}

int abcd[2000000];  
int d[2000000];     
int a[1005][1005];

int dfs(const Graph &G, int n) {
  
    if (abcd[n] == 2) return d[n];
    abcd[n] = 1;
    for (auto e : G[n]) {
      
        if (abcd[e.to] == 1) {  
          
            cout << -1 << endl;
          
            exit(0);
        }
        chmax(d[n], dfs(G, e.to) + 1);
    }
    abcd[n] = 2;
  
    return d[n];
}
int main() {
    long long N;
  
    cin >> N;
    
    for(int i=0;i<N;i++){
     for(int j=0;j<N-1;j++)
     cin >> a[i][j];
     
     
  
    Graph G(N * (N - 1) / 2 + 1);
  
    for(int i=0; i<N; i++) {
        int n = 0;
       for(int j=0;j<N-1;j++) {
       
           a[i][j]--;
                    
            int ne = swap(i , a[i][j]);
          
            G[n].push_back({ne});
          
            n = ne;
        }
    }
  
    cout << dfs(G, 0) << endl;
  
    return 0;
}


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

#include <bits/stdc++.h>
#include <iostream>
#include <queue>

using namespace std;

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

struct Edge {
    long long to;
};

using Graph = vector<vector<Edge>>;

int seen[2000000];  
int d[2000000];     

int dfs(const Graph &G, int n) {
  
    if (find[n] == 2) return d[n];
    seen[n] = 1;
    for (auto e : G[n]) {
      
        if (find[e.to] == 1) {  
          
            cout << -1 << endl;
          
            exit(0);
        }
        chmax(d[n], dfs(G, e.to) + 1);
    }
    find[n] = 2;
    return d[n];
}
int main() {
    long long N;
  
    cin >> N;
  
    Graph G(N * (N - 1) / 2 + 1);
  
    for(i=0; i<N; i++) {
        int n = 0;
       for(int k=0;k<n-1;k++) {
            int j;
         
            cin >> j;
         
            j--;
         
          if (i < j) swap(i, j);
          
            int ne =  i * (i - 1) / 2 + j + 1;;
          
            G[n].push_back({ne});
          
            n = ne;
        }
    }
  
    cout << dfs(G, 0) << endl;
  
    return 0;
}


Compiler output:
a.cc: In function 'int dfs(const Graph&, int)':
a.cc:27:13: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   27 |     if (find[n] == 2) return d[n];
      |             ^
a.cc:31:17: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   31 |         if (find[e.to] == 1) {
      |                 ^
a.cc:39:9: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   39 |     find[n] = 2;
      |         ^
a.cc: In function 'int main()':
a.cc:49:9: error: 'i' was not declared in this scope
   49 |     for(i=0; i<N; i++) {
      |         ^
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <queue>

using namespace std;

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

struct Edge {
    long long to;
};

using Graph = vector<vector<Edge>>;

int seen[2000000];  
int d[2000000];     

int dfs(const Graph &G, int n) {
  
    if (find[n] == 2) return d[n];
    seen[n] = 1;
    for (auto e : G[n]) {
      
        if (find[e.to] == 1) {  
          
            cout << -1 << endl;
          
            exit(0);
        }
        chmax(d[n], dfs(G, e.to) + 1);
    }
    find[n] = 2;
    return d[n];
}
int main() {
    long long N;
  
    cin >> N;
  
    Graph G(N * (N - 1) / 2 + 1);
  
    for(i=0; i<N; i++) {
        int n = 0;
       for(int k=0;k<n-1;k++) {
            int j;
         
            cin >> j;
         
            j--;
         
          if (i < j) swap(i, j);
          
            int ne =  i * (i - 1) / 2 + j + 1;;
          
            G[n].push_back({ne});
          
            n = ne;
        }
    }
  
    cout << dfs(G, 0) << endl;
  
    return 0;
}

Compiler output:
a.cc:7:12: error: 'T' was not declared in this scope
    7 | bool chmax(T &a, const T &b) {
      |            ^
a.cc:7:15: error: 'a' was not declared in this scope
    7 | bool chmax(T &a, const T &b) {
      |               ^
a.cc:7:18: error: expected primary-expression before 'const'
    7 | bool chmax(T &a, const T &b) {
      |                  ^~~~~
a.cc:7:28: error: expression list treated as compound expression in initializer [-fpermissive]
    7 | bool chmax(T &a, const T &b) {
      |                            ^
a.cc: In function 'int dfs(const Graph&, int)':
a.cc:26:13: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   26 |     if (find[n] == 2) return d[n];
      |             ^
a.cc:30:17: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   30 |         if (find[e.to] == 1) {
      |                 ^
a.cc:36:14: error: 'chmax' cannot be used as a function
   36 |         chmax(d[n], dfs(G, e.to) + 1);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:38:9: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   38 |     find[n] = 2;
      |         ^
a.cc: In function 'int main()':
a.cc:48:9: error: 'i' was not declared in this scope
   48 |     for(i=0; i<N; i++) {
      |         ^
Language: C++

#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

struct Edge {
    long long to;
};
using Graph = vector<vector<Edge>>;

int encode(int i, int j) {
    if (i < j) swap(i, j);
    return i * (i - 1) / 2 + j + 1;
}

int seen[2000000];  // 1:現在探索中のパスで行きがけ 2:探索後の頂点
int d[2000000];     // d[i]:= 始点から i への距離
int dfs(const Graph &G, int now) {
    if (seen[now] == 2) return d[now];
    seen[now] = 1;
    for (auto e : G[now]) {
        if (seen[e.to] == 1) {  //
            cout << -1 << endl;
            exit(0);
        }
        chmax(d[now], dfs(G, e.to) + 1);
    }
    seen[now] = 2;
    return d[now];
}

int main() {
    long long N;
    cin >> N;
    Graph G(N * (N - 1) / 2 + 1);
    REP(i, 0, N) {
        int now = 0;
        LOOP(N - 1) {
            int j;
            cin >> j;
            j--;
            int next = encode(i, j);
            G[now].push_back({next});
            now = next;
        }
    }

    cout << dfs(G, 0) << endl;
    return 0;
}


Compiler output:
a.cc:49:16: error: macro "REP" passed 3 arguments, but takes just 2
   49 |     REP(i, 0, N) {
      |                ^
a.cc:3:9: note: macro "REP" defined here
    3 | #define REP(i, n) for (int i = 0; i < (n); ++i)
      |         ^~~
a.cc: In function 'int main()':
a.cc:49:5: error: 'REP' was not declared in this scope
   49 |     REP(i, 0, N) {
      |     ^~~