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

#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define debug(x) cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define OUT2(n1,n2) cout << n1 << " " << n2 << endl
#define OUT3(n1,n2,n3) cout << n1 << " " << n2 << " " << n3 << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  IN(n);
  vector<deque<ll> > a(n, deque<ll>(n-1));
  FOR(i,0,n) {
    VIN(a[i]);
  }

  unordered_set<ll> yesterday;
  FOR(i,0,n) yesterday.insert(i);
  while (true) {
    bool updated = false;
    unordered_set<ll> done;
    for(auto itr = yesterday.begin(); itr != yesterday.end(); ++itr) {
    //FOR(i,0,n) {
      ll i = *itr;
      if (a[i].empty()) continue;
      if (done.find(i) != done.end()) continue;
      ll aite = a[i].front() - 1;
      if (done.find(aite) != done.end()) continue;

      if (a[aite].front() == i + 1) {
        a[i].pop_front();
        a[aite].pop_front();
        done.insert(i);
        done.insert(aite);
        updated = true;
      }
    }
    
    //VOUT2(a);
    unordered_set<ll> yesterday(done);
    ans++;
    if (!updated) break;
  }
  bool flg = true;
  FOR(i,0,n) {
    if (!a[i].empty()) {
      flg = false;
      break;
    }
  }
  if (flg) OUT(ans-1);
  else OUT(-1);

}

Compiler output:
main.c:2:9: fatal error: bits/stdc++.h: No such file or directory
    2 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define debug(x) cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define OUT2(n1,n2) cout << n1 << " " << n2 << endl
#define OUT3(n1,n2,n3) cout << n1 << " " << n2 << " " << n3 << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  IN(n);
  vector<deque<ll> > a(n, deque<ll>(n-1));
  FOR(i,0,n) {
    VIN(a[i]);
  }

  unordered_set<ll> yesterday;
  FOR(i,0,n) yesterday.insert(i);
  while (true) {
    bool updated = false;
    unordered_set<ll> done;
    for(auto itr = yesterday.begin(); itr != yesterday.end(); ++itr) {
    //FOR(i,0,n) {
      ll i = *itr;
      if (a[i].empty()) continue;
      if (done.find(i) != done.end()) continue;
      ll aite = a[i].front() - 1;
      if (done.find(aite) != done.end()) continue;

      if (a[aite].front() == i + 1) {
        a[i].pop_front();
        a[aite].pop_front();
        done.insert(i);
        done.insert(aite);
        updated = true;
      }
    }

    //VOUT2(a);
    unordered_set<ll> yesterday(done);
    ans++;
    if (!updated) break;
  }
  bool flg = true;
  FOR(i,0,n) {
    if (!a[i].empty()) {
      flg = false;
      break;
    }
  }
  if (flg) OUT(ans-1);
  else OUT(-1);

}

Compiler output:
main.c:2:9: fatal error: bits/stdc++.h: No such file or directory
    2 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

bool find(int n, vector<int> a) {
  bool result = false;
  for(int i=0;i<a.size();i++) {
    if(a[i] == n) {
      result = true;
      break;
    }
  }

  return result;
}

vector<int> oneDay(vector<vector<int>> order) {
  vector<int> erased(0);

  for(int i=0;i<order.size();i++) {
    int size1 = order[i].size();
    if(size1 == 0) {
      continue;
    }
    int opponent = order[i][size1-1] - 1;
    if(opponent < i) {
      continue;
    }
    int size2 = order[opponent].size();
    if(size2 == 0) {
      continue;
    }
    int opponentOpponent = order[opponent][size2-1] - 1;

    if (opponentOpponent == i) {
      if (find(i, erased) || find(opponent, erased)) {
        continue;
      } else {
        erased.push_back(i);
        erased.push_back(opponent);
      }
    } else {
      continue;
    }
  }

  return erased;
}

int main() {
  int N;
  cin >> N;
  vector<vector<int> > order(N, vector<int>(N-1));

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

  int days = 0;

  int left = N * (N-1) / 2;

  while(left > 0) {
    bool can = true;
    vector<int> erased = oneDay(order);

    if(erased.size == 0) {
      can = false;
    } else {
      for(int i=0;i<erased.size();i++) {
        order[erased[i]].pop_back();
      }
    }

    left = left - (erased.size() / 2);

    if(!can) {
      days = -1;
      break;
    } else {
      days++;
    }
  }

  cout << days << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:15: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   68 |     if(erased.size == 0) {
      |        ~~~~~~~^~~~
      |                   ()
Language: C++

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

void main() {
    int N, day = 1, j, num = 0;
    scanf("%d", &N);
    queue<int> A[N];
    unordered_set<int> Check;

    for  (int i = 0; i < N; i++) {
        for (int j = 0; j < N - 1; j++) {
            int a;
            scanf("%d", &a);
            A[i].push(a - 1);
        }
    }

    while (true) {
        
        for (int i = 0; i < N; i++) {
            if (A[i].empty()){
                continue;
            }
            j = A[i].front();
            if (A[j].empty()) {
                continue;
            }
            if (A[j].front() == i){
                Check.insert(i);
            }
        }
        num += Check.size() / 2;
        for (int x : Check) {
            A[x].pop();
        }
        if (Check.empty()){
            cout << -1 << endl;
            return;
        }
        if (num == N * (N - 1) / 2) {
            cout << day << endl;
            return;
        }
        day++;
        Check.clear();
    }
}


Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | void main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:38:13: error: return-statement with no value, in function returning 'int' [-fpermissive]
   38 |             return;
      |             ^~~~~~
a.cc:42:13: error: return-statement with no value, in function returning 'int' [-fpermissive]
   42 |             return;
      |             ^~~~~~
Language: C++

#include <bits/stdc++.h>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const ll INF = 10241024;
int N;
vector<vector<int>> A(1000, vector<int>(1000,-1));
void input(){
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            int a;
            cin >> a;
            A[i][j] = a
            A[i][j]--;
        }
    }
}

void solve(){
    input();
    int ans = 0;
    vector<int> v(N, -1);
    rep(i,N)v[i][0] = 0;
    bool ok = true;

    while(true){
        ok = false;
        for(int i=0;i<N;i++){
            if(v[i] == N - 2)continue;
            if(v[i] == -1)continue;
            int b = A[i][v[i]];
            if(A[b][v[b]] == i){

                v[i]++;v[b]++;ans++;
                ok = true;//一回でもループ出来たのならもう一周やる必要あり
            }
        }
        if(!ok){
            cout << -1 << endl;
            return;
        }
    }

    cout << ans << endl;
}
int main () {
    solve();
    return 0;
}




Compiler output:
a.cc: In function 'void input()':
a.cc:30:24: error: expected ';' before 'A'
   30 |             A[i][j] = a
      |                        ^
      |                        ;
   31 |             A[i][j]--;
      |             ~           
a.cc: In function 'void solve()':
a.cc:40:17: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   40 |     rep(i,N)v[i][0] = 0;
      |                 ^
Language: C++

#include <bits/stdc++.h>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const ll INF = 10241024;
int N;
vector<vector<int>> A;
void input(){
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
}

void solve(){
    input();
    int ans = 0;
    vector<int> v(N, 0);
    rep(i, N){
        a[i][0] = 1;
    }
    bool ok = true;
    while(true){
        ok = false
        for(int i=0;i<N;i++){
            if(v[i] == N - 2)continue;
            int b = A[i][v[i]];
            if(A[b][v[b]] == i){
                v[i]++;v[b]++;ans++;
                ok = true;//一回でもループ出来たのならもう一周やる必要あり
            }
        }
        if(!ok){
            cout << -1 << endl;
        }
    }
    
}
int main () {
    solve();
    return 0;
}




Compiler output:
a.cc: In function 'void solve()':
a.cc:39:9: error: 'a' was not declared in this scope
   39 |         a[i][0] = 1;
      |         ^
a.cc:43:19: error: expected ';' before 'for'
   43 |         ok = false
      |                   ^
      |                   ;
   44 |         for(int i=0;i<N;i++){
      |         ~~~        
a.cc:44:21: error: 'i' was not declared in this scope
   44 |         for(int i=0;i<N;i++){
      |                     ^
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;

int 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]--;
    }
    reverse(a[i].begin(), a[i].end());
  }
  vector<P> q;

  auto check = [&](int i){
    if(a[i].size()==0) return;
    int j = a[i].back();
    if(a[j].back()==i){
      P p(i,j);
      if(p.first > p.second) swap(p.first,p.second);
      q.push_back(p);
    }
  };
  
  rep(i,n){
    check[i];
  }
  
  int day = 0;
  while(q.size()!=0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P> prevQ;
    swap(q,prevQ);
    for(P p : prevQ){
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for(P p : prevQ){
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
  
  rep(i,n){
    if(a[i].size()!=0){
      puts("-1");
      return 0;
    }
  }
  
  cout << day << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:10: error: no match for 'operator[]' (operand types are 'main()::<lambda(int)>' and 'int')
   31 |     check[i];
      |          ^
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;

int 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]--;
    }
    reverse(a[i].begin(), a[i].end());
  }
  vector<P> q;

  auto check = [&](int i){
    if(a[i].size()==0) return;
    int j = a[i].back();
    if(a[j].back()==i){
      P p(i,j);
      if(p.first > p.second) swap(p.first,p.second);
      q.push_back(p);
    }
  }
  
  rep(i,n){
    check[i];
  }
  
  int day = 0;
  while(q.size()!=0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P> prevQ;
    swap(q,prevQ);
    for(P p : prevQ){
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for(P p : prevQ){
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
  
  rep(i,n){
    if(a[i].size()!=0){
      puts("-1");
      return 0;
    }
  }
  
  cout << day << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:18: error: expected ',' or ';' before 'for'
    2 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |                  ^~~
a.cc:30:3: note: in expansion of macro 'rep'
   30 |   rep(i,n){
      |   ^~~
a.cc:30:7: error: 'i' was not declared in this scope
   30 |   rep(i,n){
      |       ^
a.cc:2:34: note: in definition of macro 'rep'
    2 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |                                  ^
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;

int 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]--;
    }
    reverse(a[i].begin(), a[i].end());
  }
  vector<P> q;

  auto check = [&](int i){
    if(a[i].size()==0) return;
    int j = a[i].back();
    if(a[j].back()==i){
      P p(i,j);
      if(p.first > p.second) swap(p.first,p.second);
      q.push_back(p);
    }
  }
  
  rep(i,n){
    check[i];
  }
  
  int day = 0;
  while(q.size()!=0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P> prevQ;
    swap(q,prevQ);
    for(P p : prevQ){
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for(P p : prevQ){
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
  
  rep(i,n){
    if(a[i].size()!=0){
      puts("-1");
      return 0;
    }
  }
  
  cout << day << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:18: error: expected ',' or ';' before 'for'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                  ^~~
a.cc:30:3: note: in expansion of macro 'rep'
   30 |   rep(i,n){
      |   ^~~
a.cc:30:7: error: 'i' was not declared in this scope
   30 |   rep(i,n){
      |       ^
a.cc:2:30: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                              ^
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;

int 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]--;
    }
  }
  vector<P> q;

  auto check = [&](int i){
    if(a[i].size()==0) return;
    int j = a[i].back();
    if(a[j].back()==i){
      P p(i,j);
      if(p.first > p.second) swap(p.first,p.second);
      q.push_back(p);
    }
  }
  
  rep(i,n){
    check[i];
  }
  
  int day = 0;
  while(q.size()!=0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P> prevQ;
    swap(q,prevQ);
    for(P p : prevQ){
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for(P p : prevQ){
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
  
  rep(i,n){
    if(a[i].size()!=0){
      puts("-1");
      return 0;
    }
  }
  
  cout << day << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:18: error: expected ',' or ';' before 'for'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                  ^~~
a.cc:29:3: note: in expansion of macro 'rep'
   29 |   rep(i,n){
      |   ^~~
a.cc:29:7: error: 'i' was not declared in this scope
   29 |   rep(i,n){
      |       ^
a.cc:2:30: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                              ^
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;

int 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]--;
    }
  }
  vector<int> q;

  auto check = [&](int i){
    if(a[i].size()==0) return;
    int j = a[i].back();
    if(a[j].back()==i){
      P p(i,j);
      if(p.first > p.second) swap(p.first,p.second);
      q.push_back(p);
    }
  }
  
  rep(i,n){
    check[i];
  }
  
  int day = 0;
  while(q.size()!=0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P> prevQ;
    swap(q.prevQ);
    for(P p : prevQ){
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for(P p : prevQ){
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
  
  rep(i,n){
    if(a[i].size()!=0){
      puts("-1");
      return 0;
    }
  }
  
  cout << day << endl;
}

Compiler output:
a.cc: In lambda function:
a.cc:25:18: error: no matching function for call to 'std::vector<int>::push_back(P&)'
   25 |       q.push_back(p);
      |       ~~~~~~~~~~~^~~
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 'P' {aka 'std::pair<int, 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 'P' {aka 'std::pair<int, int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:2:18: error: expected ',' or ';' before 'for'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                  ^~~
a.cc:29:3: note: in expansion of macro 'rep'
   29 |   rep(i,n){
      |   ^~~
a.cc:29:7: error: 'i' was not declared in this scope
   29 |   rep(i,n){
      |       ^
a.cc:2:30: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                              ^
a.cc:39:12: error: 'class std::vector<int>' has no member named 'prevQ'
   39 |     swap(q.prevQ);
      |            ^~~~~
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;

int 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]--;
    }
    reverse(a[i].begin(),a[i].end());
  }
  vector<P> q;
  auto check = [&](int i){
    if(a[i].size==0) return;
    int j = a[i].back();
    if(i = a[j].back()){
      P p(i,j);
      if(p.first > p.second) swap(p.first,p.second);
      q.push_back(p);
    }
  };
  rep(i,n){
    check(i);
  }
  int day = 0;
  while(q.size > 0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P> prevQ;
    swap(q,prevQ);
    for(P p : prevQ){
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for(P p : prevQ){
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
   rep(i,n){
      if(a[i].size==0){
        puts("-1");
      }
   }
  cout << day << endl;
}

Compiler output:
a.cc: In lambda function:
a.cc:20:13: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   20 |     if(a[i].size==0) return;
      |                 ()
a.cc: In function 'int main()':
a.cc:32:11: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; size_type = long unsigned int]' (did you forget the '()' ?)
   32 |   while(q.size > 0){
      |         ~~^~~~
      |               ()
a.cc:50:15: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   50 |       if(a[i].size==0){
      |                   ()
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;

int 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]--;
    }
    reverse(a[i].begin(), a[i].end());
  }
  vector<P> q;
  void check = [&](int i) {
    if (a[i].size() == 0) return;
    int j = a[i].back();
    if (a[j].size() == 0) return;
    if (a[j].back() == i) {
      P p(i,j);
      if (p.second < p.first) swap(p.first, p.second);
      q.push_back(p);
    }
  };
  rep(i,n) {
    check(i);
  }
  int day = 0;
  while (q.size() > 0) {
    day++;
    sort(q.begin(), q.end());
    q.erase(unique(q.begin(), q.end()), q.end());
    vector<P> prevQ;
    swap(prevQ, q);
    for (P p : prevQ) {
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for (P p : prevQ) {
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
  rep(i,n) {
    if (a[i].size() != 0) {
      puts("-1");
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:8: error: variable or field 'check' declared void
   19 |   void check = [&](int i) {
      |        ^~~~~
a.cc:30:5: error: 'check' was not declared in this scope
   30 |     check(i);
      |     ^~~~~
a.cc:46:7: error: 'check' was not declared in this scope
   46 |       check(i);
      |       ^~~~~
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;

int 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]--;
    }
  }
  vector<P> q;
  void check = [&](int i){
    if(a[i].size==0) return;
    int j = a[i].back();
    P p(i,j);
    if(p.first > p.second) swap(p.first,p.second);
    q.push_back(p);
  }
  rep(i,n){
    check(i);
  }
  int day = 0;
  while(q.size()>0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P> prevQ;
    swap(q,prevQ);
    for(P p : prevQ){
      int i = p.first;
      int j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for(P p : prevQ){
      int i = p.first;
      int j = p.second;
      check(i);
      check(j);
    }
  }
  rep(i,n){
    if(a[i].size!=0){
      puts("-1");
      return 0;
    }
  }
  cout << day << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:8: error: variable or field 'check' declared void
   18 |   void check = [&](int i){
      |        ^~~~~
a.cc: In lambda function:
a.cc:19:13: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   19 |     if(a[i].size==0) return;
      |                 ()
a.cc: In function 'int main()':
a.cc:25:7: error: 'i' was not declared in this scope
   25 |   rep(i,n){
      |       ^
a.cc:2:30: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                              ^
a.cc:44:7: error: 'check' was not declared in this scope
   44 |       check(i);
      |       ^~~~~
a.cc:49:13: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   49 |     if(a[i].size!=0){
      |                 ()
Language: C++

#include <bits/stdc++.h>
using namespace std;
using Match = pair<int, int>;

const bool DEBUG = true;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n - 1));
  for (size_t i = 0; i < N; i++) {
    for (size_t j = 0; j < n - 1; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
    reverse(a[i].begin(), a[i].end());
    // 次の人を末尾から探せるように反転しておく
  }

  vector<Match> queue;

  auto check = [&](int i) {
    if (a[i].size() == 0) return;
    int j = a[i].back();  // 次の対戦相手
    if (a[j].size() == 0) return;
    if (a[j].back() == i) {
      // i<->jなら次の試合のキューに追加
      Match m(i, j);
      if (m.second < m.first) swap(m.first, m.second);
      queue.push_back(m);
    }
  };

  // キューの初期化
  for (size_t i = 0; i < n; i++) check(i);

  int day = 0;
  while (queue.size() > 0) {
    day++;

    // 要素のユニークを取る
    sort(queue.begin(), queue.end());
    queue.erase(unique(queue.begin(), queue.end()), queue.end());

    // 前のキューをprev_queueにうつしてqueueを空にする
    vector<Match> prev_queue;
    swap(prev_queue, queue);

    for (auto &&m : prev_queue) {
      // 試合を行う
      int i = m.first, j = m.second;
      a[i].pop_back();  // 試合結果を削除
      a[j].pop_back();
    }

    for (auto &&m : prev_queue) {
      // 試合が終了したペアについて新しく試合ができるかチェック
      int i = m.first, j = m.second;
      check(i);
      check(j);
    }
  }

  for (size_t i = 0; i < n; i++) {
    if (a[i].size() != 0) {
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:11:26: error: 'N' was not declared in this scope
   11 |   for (size_t i = 0; i < N; i++) {
      |                          ^
Language: C++

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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> id(N+1, vector<int>(N+1, 0));
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            id[i][j] = min(i, j) * N + max(i, j);
        }
    }
    
    vector<int> in((N+1)*(N+1), 0);
    vector<vector<int>> edge((N+1)*(N+1));
    for (int i = 1; i <= N; i++) {
        vector<int> game(N-1);
        for (int j = 0; j < N-1; j++) {
            cin >> game[j];
            if (j >= 1) {
                edge[id[i][game[j-1]]].push_back(id[i][game[j]]);
                in[id[i][game[j]]]++;
            }
        }
    }
    
    queue<int> q;
    vector<int> day((N+1)*(N+1), 0);
    for (int i = 1; i <= N-1; i++) {
        for (int j = i+1; j <= N; j++) {
            if (in[id[i][j]] == 0) {
                q.push(id[i][j]);
                day[id[i][j]] = 1;
                cnt++;
            }
        }
    }
    
    int cnt = 0;
    int ans = 1;
    
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (int g : edge[now]) {
            in[g]--;
            if (in[g] == 0) {
                day[g] = day[now]+1;
                if (day[g] > ans) ans = day[g];
                q.push(g);
                cnt++;
            }
        }
    }
    
    if (cnt < N) cout << "-1\n";
    else cout << ans << endl;
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
int max_v = 0;
map<pair<int,int>,int>uniq;
int get_idx(pair<int,int>p){
    if(uniq.find(p) == uniq.end()){
        uniq[p] = max_v++;
    }
    return uniq[p];
}
vector<vector<int>>edge;
void dfs(vector<int>&d,int v,int value){
    for(auto nxt : edge[v]){
        if(d[nxt] < value + 1){
            d[nxt] = value + 1;
            dfs(nxt,d[nxt]);
        }
    }
    return;
}
signed main(){
    int N; cin >> N;
    vector<vector<int>>g(N);
    for(auto& v : g){
        for(int i = 0; i < N - 1; ++i){
            int t; cin >> t;
            v.push_back(--t);
        }
    }
    // 0-index
    vector<vector<int>>pos(N,vector<int>(N,-1LL));
    for(int i = 0; i < g.size(); ++i){
        for(int j = 0; j < g[i].size(); ++j){
            auto e = g[i][j];
            pos[i][e] = j;
        }
    }
    vector<vector<bool>>used(N,vector<bool>(N-1,false));
    edge.resize(N*N);
    vector<int>d(N*N,-1);
    vector<int>in(N*N);
    auto f = [](int i, int j){
        return make_pair(min(i,j), max(i,j));
    };
    for(int j = 0; j < N - 1; ++j){
        for(int i = 0; i < N; ++i){
            if(used[i][j])continue;
            //cout <<  i + 1 << " " << g[i][j]+ 1 << endl;
            auto e = g[i][j];
            int rj = pos[e][i];
            auto p = f(i,e);
            if(j + 1  < N - 1){
                auto nxt = f(i,g[i][j + 1]);
                in[get_idx(nxt)]++;
                edge[get_idx(p)].push_back(get_idx(nxt));
            }
            if(rj + 1 < N - 1 ){
                auto nxt = f(e,rj + 1);
                in[get_idx(nxt)]++;
                edge[get_idx(p)].push_back(get_idx(nxt));
            }
            used[i][j] = used[e][rj] = true;
        }
    }
    bool valid = false;
    for(int p = 0; p < max_v; ++p){
        if(in[p])continue;
        valid = true;
        if(d[p]  == -1)
            dfs(d,p,1LL);
        
    }
    if(not valid) return puts("-1") * 0;
    cout << *max_element(d.begin(), d.end()) << endl;
}


Compiler output:
a.cc: In function 'void dfs(std::vector<int>&, int, int)':
a.cc:16:17: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'int'
   16 |             dfs(nxt,d[nxt]);
      |                 ^~~
a.cc:12:22: note: in passing argument 1 of 'void dfs(std::vector<int>&, int, int)'
   12 | void dfs(vector<int>&d,int v,int value){
      |          ~~~~~~~~~~~~^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

P toporogical_sort(const vector<vector<int>> &g){
	int n = g.size();
	vector<int> in_degree(n,0);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < g[i].size(); j++){
			in_degree[g[i][j]]++;
		}
	}

	vector<int> res,length(n,0);
	stack<int> S;
	for(int i = 0; i < n; i++){
		if(in_degree[i]==0) S.push(i),length[i]=1;
	}

	while(!S.empty()){
		int p = S.top();
		S.pop();
		res.push_back(p);
		for(int i = 0; i < g[p].size(); i++){
			in_degree[g[p][i]]--;
			if(in_degree[g[p][i]]==0) S.push(g[p][i]),length[g[p][i]]=length[p]+1;
		}
	}

	//res.size()==nならばgはDAG
	//resはトポロジカルソートされた頂点列
	//*max_element(all(length))はgの最長パスの長さ
	int cnt = (res.empty()?-1:res.size());
	return P(cnt,*max_element(all(length)));
}

int 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]--;
		}
	}


	vector<P> point;
	rep(i,n){
		for (int j = i+1; j < n; j++){
			point.push_back(P(i,j));
		}
	}
	map<P,int> m;
	rep(i,point.size()) m.insert(make_pair(point[i],i));

	vector<vector<int>> g(point.size());
	rep(i,n){
		rep(j,n-2){
			int p=i,from=a[i][j];
			if(p>from){
				int tmp=p;
				p=from;
				from=tmp;
			}

			int q=i,to=a[i][j+1];
			if(q>to){
				int tmp=q;
				q=to;
				to=tmp;
			}
			int& x = m[P(p,from)];
			int& y = m[P(q,to)];
			g[x].push_back(y);
		}
	}


	// P ans=toporogical_sort(g);
	// cout<<(ans.first==n*(n-1)/2?ans.second:-1)<<endl;
	cout<-1<<endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:108:16: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
  108 |         cout<-1<<endl;
      |              ~~^~~~~~
Language: C++

// 解説前
#include <iostream>
#include <vector>

int A[1001][1001];

int solve_E() {
  size_t N;
  std::cin >> N;

  for (size_t i = 1; i <= N; ++i) {
    for (size_t j = 1; j <=  N - 1; ++j) {
      std::cin >> A[i][j];
    }
  }

  std::vector<size_t> heads(N + 1, 1);  // 現在見ているA[i]の先頭のインデックス
  std::vector<size_t> matches;  // 試合を組んだ選手の番号
  matches.reserve(N);
  size_t result = 0;  // 総日数
  size_t remains = N * (N - 1);  // 残りの試合数 * 2
  while (true) {
    matches.clear();
    for (size_t i = 1; i <= N; ++i) {
      const auto head = heads[i];

      // 試合予定が組まれていない場合
      if (std::find(matches.begin(), matches.end(), i) == matches.end()) {
        // 試合予定が残っている場合
        if (head <= N - 1) {
          const int opponent = A[i][head];
          const int opponent_opponent = A[opponent][heads[opponent]];

          // 互いが互いを対戦相手としていれば、その試合を組む
          if (i == opponent_opponent) {
            matches.push_back(i);
            matches.push_back(opponent);
          }
        }
      }
    }

    // 試合を組めない場合
    if (matches.empty()) {
      std::cout << "-1";
      return 0;
    }

    // 日程を進める
    for (auto m : matches) {
      heads[m]++;
      remains--;
    }
    result++;

    // すべての試合を組んだら終了
    if (remains == 0) break;
  }

  std::cout << result;
  return 0;
}

int main() { return solve_E(); }


Compiler output:
a.cc: In function 'int solve_E()':
a.cc:28:20: error: no matching function for call to 'find(std::vector<long unsigned int>::iterator, std::vector<long unsigned int>::iterator, size_t&)'
   28 |       if (std::find(matches.begin(), matches.end(), i) == matches.end()) {
      |           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:28:20: note:   '__gnu_cxx::__normal_iterator<long unsigned int*, std::vector<long unsigned int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   28 |       if (std::find(matches.begin(), matches.end(), i) == matches.end()) {
      |           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main() {
    int N, day = 1, j, num = 0;
    cin >> N;
    bool a = false;
    vector<queue<int>> A(N);
    unordered_set<int> Check;

    for  (int i = 0; i < N; i++) {
        for (int j = 0; j < N - 1; j++) {
            int a;
            cin >> a;
            A.at(i).push(a - 1);
        }
    }

    while (true) {
        
        for (int i = 0; i < N - 1; i++) {
            if (A.at(i).empty()){
                continue;
            }
            j = A.at(i).front();
            if (A.at(j).empty()) {
                continue;
            }
            if (A.at(j).front() == i){
                if ((Check.count(i) ^ Check.count(j)) && add == false) {
                    day++;
                    add = true;
                }
                Check.insert(i);
                Check.insert(j);
                A.at(i).pop();
                A.at(j).pop();
                num++;
            }
        }
        if (Check.empty()){
            cout << -1 << endl;
            return 0;
        }
        if (num == N * (N - 1) / 2) {
            cout << day << endl;
            return 0;
        }
        day++;
        Check.clear();
        add = false;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:58: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'?
   30 |                 if ((Check.count(i) ^ Check.count(j)) && add == false) {
      |                                                          ^~~
      |                                                          std::filesystem::perm_options::add
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here
  219 |       add       = 0x2,
      |       ^~~
a.cc:51:9: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'?
   51 |         add = false;
      |         ^~~
      |         std::filesystem::perm_options::add
/usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here
  219 |       add       = 0x2,
      |       ^~~
Language: C++

{
    Int n;
    scanf("%d", &n);
    REP(i, n){
        REP(j, n - 1){
            scanf("%d", &a[i][j]);
            a[i][j]--;
        }
    }
    REP(i, n){
        REP(j, n - 2){
            Int v1 = i, v2 = a[i][j], v3 = i, v4 = a[i][j + 1];
            if(v1 > v2) swap(v1, v2);
            if(v3 > v4) swap(v3, v4);
            auto &vec = g[v1][v2];
            vec.push_back({v3, v4});
        }
    }
    REP(i, n) REP(j, n) for(auto &next : g[i][j]){
        cnt[next.first][next.second]++;
    }
    auto dfs = [f = [&](auto f, pair<Int, Int> now) -> void {
        if(cnt[now.first][now.second] > 0) return;
        auto &used_tmp = used[now.first][now.second];
        if(used_tmp) return;
        used_tmp = true;
        for(auto &next : g[now.first][now.second]){
            auto &dp_next = dp[next.first][next.second];
            dp_next = max(dp_next, dp[now.first][now.second] + 1);
            cnt[next.first][next.second]--;
            f(f, next);
        }
    }](pair<Int, Int> now){ f(f, now); };
    REP(i, n){
        Int v1 = i, v2 = a[i][0];
        if(v1 > v2) swap(v1, v2);
        pair<Int, Int> v = {v1, v2};
        dfs(v);
    }
    REP(i, n) REP(j, n) for(auto &v : g[i][j]){
        if(!used[v.first][v.second]) {
            printf("-1\n");
            exit(0);
        }
    }
    Int ans = 0;
    REP(i, n) REP(j, n) ans = max(ans, dp[i][j]);
    printf("%d\n", ans + 1);
}

Compiler output:
a.cc:1:1: error: expected unqualified-id before '{' token
    1 | {
      | ^
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;
const int MAXV=MAXN*(MAXN-1)/2;
vector<int> to[MAXV];
int id[MAXN][MAXN];
int toId(int i,int j){
  if(i<j)swap(i,j);
  return id[i][j];
}
bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV];
int dfs(int v){
  if (visited[v]) {
    if (!calculated[v])return -1;
    return dp[v];
  visited[v]=true;
  dp[v]=0;
  for (int u: to[v]){
    int res=dfs(u);
    if (res==-1)return -1;
    dp[v]=max(dp[v],dfs(u)+1);
  }
  calculated[v]=true;
  return dp[v];
}
  
int 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 V=0;
  rep(i,n)rep(j,n){
    if (i<j){
      id[i][j]=V++;
    }
  }
  rep(i,n){
    rep(j,n-1){
      a[i][j]=toId(i,a[i][j]);
    }
    rep(j,n-2){
      to[a[i][j+1]].push_back(a[i][j]);
    }
  }
  int ans=0;
  rep(i,n){
    int res=dfs(i);
    if (res==-1){
      puts("-1");
      return 0;
    }
    ans=max(ans,dfs(i));
  }
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:32:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   32 | int main(){
      |         ^~
a.cc:32:9: note: remove parentheses to default-initialize a variable
   32 | int main(){
      |         ^~
      |         --
a.cc:32:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:32:11: error: a function-definition is not allowed here before '{' token
   32 | int main(){
      |           ^
a.cc:67:2: error: expected '}' at end of input
   67 | }
      |  ^
a.cc:17:15: note: to match this '{'
   17 | int dfs(int v){
      |               ^
a.cc:67:2: warning: control reaches end of non-void function [-Wreturn-type]
   67 | }
      |  ^
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;

int 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]--;
    }
    reverse(a[i].begin(),a[i].end());
  }
  vector<P> q;
  auto check=[&](int i){
    if (a[i].size()==0) return;
    int j=a[i].back();
    if (a[j].size()==0) return;
    if (a[j].back()==i) {
      P p(i,j);
      if (p.second <p.first) swap(p.first,p.second);
      q.push_back(p);
    }
  };
  rep(i,n) {
    check(i);
  }
  int day=0;
  while (q.size()>0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P> prevQ;
    for (P p:prevQ){
      int i=p.first,j=p.second;
      a[i].pop_back();
      a[j].pop_back();
      check(i);
      check(k);
    }
  }
  rep(i,n);
  return 0;
}
   
      

Compiler output:
a.cc: In function 'int main()':
a.cc:43:13: error: 'k' was not declared in this scope
   43 |       check(k);
      |             ^
Language: C++

#include <iostream>
#include <utility>
#include <vector>
#include <tuple>
#include <unordered_map>
#include <boost/functional/hash.hpp>

int main(){
  int N;
  std::cin >> N;
  std::unordered_map<std::tuple<int,int>, std::vector<std::tuple<int,int>>,boost::hash<std::tuple<int,int>>> t_arr;
  std::unordered_map<std::tuple<int,int>, int,boost::hash<std::tuple<int,int>>> in_nodes;

  for(int i = 0; i < N; i++){
    int a;
    std::cin >> a;
    std::pair<int,int> p = std::minmax(i, a-1);
    in_nodes[p];
    for(int j = 1; j < N-1; j++){
      std::cin >> a;
      std::pair<int,int> q = std::minmax(i, a-1);
      t_arr[p].push_back(q);
      in_nodes[q] += 1;
      p = q;
    }
  }

  std::vector<std::tuple<int,int>> p1, p2;
  for(auto&& it: in_nodes){
    if(it.second == 0) p1.push_back(it.first);
  }

  int ncount = 0, nd = 0;
  while(ncount < in_nodes.size()){
    if(p1.size() == 0){
      nd = -1;
      break;
    }
    ncount += p1.size();
    nd++;
    for(auto&& it: p1){
      for(auto&& it2: t_arr[it]){
        in_nodes[it2] -= 1;
        if(in_nodes[it2] == 0) p2.push_back(it2);
      }
    }
    p1.clear();
    std::swap(p1, p2);
  }

  std::cout << nd << std::endl;

  return 0;
}



Compiler output:
a.cc:6:10: fatal error: boost/functional/hash.hpp: No such file or directory
    6 | #include <boost/functional/hash.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

int mat[1005][1005], last[1005];
int adj[1005], vis[1005];

bool iscycle(int u, int p){
    if(adj[u] == -1) return true;
    vis[u] = 1;
    if(vis[adj[u]] == 1 and adj[u] != p) return true;
    else if(vis[adj[u]] == 0 and iscycle(adj[u], u)) return true;
    vis[u] = 2;
    return false;
}

int main(){
    int n; cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n-1; j++)
            cin >> mat[i][j], mat[i][j]--;
    
    int cnt = 0;
    while(1){
        memset(adj, -1, sizeof adj);
        memset(vis, 0, sizeof vis);
        int flag = 0;
        for(int i = 0; i < n; i++){
            if(last[i] >= n-1) continue;
            flag = 1;
            int u = i, v = mat[i][last[i]];
            // cout << u+1 << " indo pra " << v+1 << endl;
            adj[u] = v;
        }
        if(!flag) break;
        for(int i = 0; i < n; i++)
            if(last[i] < n-1 and !vis[i] and iscycle(i, -1)){
                puts("-1");
                return 0;
            }
        for(int i = 0; i < n; i++)
            if(adj[i] != -1 and adj[adj[i]] == i){
                // cout << "achou o par " << i+1 << " e " << adj[i]+1 << endl;
                last[i]++, last[adj[i]]++;
                adj[i] = -1;
                adj[adj[i]] = -1;
            }
        
        cnt++;
        if(cnt > 1500000{
            cnt = -1;
            break;
        })
    }
    cout << cnt << endl;
    
    //  cout << "oi '-'" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:25: error: expected ')' before '{' token
   50 |         if(cnt > 1500000{
      |           ~             ^
      |                         )
a.cc:54:5: error: expected primary-expression before '}' token
   54 |     }
      |     ^