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

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
    int N,ans=0;cin >> N;
    vector<vector<int>> A(N,vector<int>(N-1));
    REP(i,N){
        REP(j,N-1){
            cin >> A.at(i).at(j);
        }
    }

    vint nokori(N); REP(i,N) nokori.at(i) = N-1;
    vector<bool> check(N),tle(N); REP(i,N) check.at(i) = true;

    int test=0;
    bool battle,reigai= false;

    tle = check;

    while(accumulate(ALL(nokori),0) != 0){
        battle = false;
        REP(i,N) check.at(i) = true;
        REP(i,N){
            if(tle[i] & check[i] & nokori[i]>=1){
            int j = abs(nokori[i] - (N-1));
            int vs = A.at(i).at(j); // vs が相手の数字
            // cout << i+1 << "さんの次の対戦 : " << "A.at(" << i << ").at(" << j << ") = " << vs << endl;

            if(check[vs-1] & nokori[vs-1] >= 1){
                int vs_i = vs-1;
                int vs_j = abs(nokori[vs-1] - (N-1));
                // cout << "対戦相手の次の相手 : " << "A.at(" << vs_i << ").at(" << vs_j << ") = " << A.at(vs_i).at(vs_j) << endl;

                if(A.at(vs_i).at(vs_j) == i+1 ){
                    // cout << i+1 << " vs " << vs << endl;
                    nokori[i]--;
                    nokori[vs-1]--;
                    check[vs-1] = false;
                    check[i] = false;
                    battle = true;
                    
                }

            }
            }
        }

        
        // test++;
        // cout << test << "日終了" << endl;
        ans++;
        tle = !check;


        if(!battle) {
            reigai = true;
            cout << "-1" << endl;
            break;
        }

    }
    
    if(!reigai){
        cout << ans << endl;
    }


}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:15: error: no match for 'operator!' (operand type is 'std::vector<bool>')
   62 |         tle = !check;
      |               ^~~~~~
a.cc:62:15: note: candidate: 'operator!(bool)' (built-in)
a.cc:62:15: note:   no known conversion for argument 1 from 'std::vector<bool>' to 'bool'
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(auto a,long long b){
    long long ans=1;
    //cout<<ans;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    ///cout<<ans<<" ";    
    return ans;
        
}
void maxi(auto &a,auto b){
    a=max(a,b);
}
void mini(auto &a,auto b){
    a=min(a,b);
}
int dp[1005][1005],b[1005][1005];
int fun(int i,int j){
    //if(i==-1||j==-1)return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    int ans=1;
    if(b[i][j]!=0)ans=max(ans,fun(i,a[i][b[i][j]-1]));
    if(b[j][i]!=0)ans=max(ans,fun(j,a[j][b[i][j]-1]));
    return dp[i][j]=ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n][n-1];
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            cin>>a[i][j];
            b[i][a[i][j]]=j;
        }
    }
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        if(b[i][a[i][0]]==0)dp[i][a[i][0]]=1;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,fun(i,a[i][n-1]));
    }
    return 0;
}

Compiler output:
a.cc:19:17: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   19 | long long power(auto a,long long b){
      |                 ^~~~
a.cc:31:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   31 | void maxi(auto &a,auto b){
      |           ^~~~
a.cc:31:19: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   31 | void maxi(auto &a,auto b){
      |                   ^~~~
a.cc:34:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   34 | void mini(auto &a,auto b){
      |           ^~~~
a.cc:34:19: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   34 | void mini(auto &a,auto b){
      |                   ^~~~
a.cc: In function 'long long int fun(long long int, long long int)':
a.cc:42:37: error: 'a' was not declared in this scope
   42 |     if(b[i][j]!=0)ans=max(ans,fun(i,a[i][b[i][j]-1]));
      |                                     ^
a.cc:43:37: error: 'a' was not declared in this scope
   43 |     if(b[j][i]!=0)ans=max(ans,fun(j,a[j][b[i][j]-1]));
      |                                     ^
Language: C++

#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#define Max 1005
using namespace std;


vector<int>vec[Max*Max];
int map[Max][Max],indegree[Max*Max];
queue<int>q;


void init(){
	int i,j;
	for(i=0;i<Max;i++){
		for(j=0;j<Max;j++){
			map[i][j] = -1;
			
		}	
	}

	for(i=0;i<Max*Max;i++){
		indegree[i] = 0;
		
	}
}

int main(){
	
	int n,i,j,x;
	
	init();

	scanf("%d",&n);
	int node = 1,prev_node;
	for(i=1;i<=n;i++){
		for(j=0;j<n-1;j++){
			scanf("%d",&x);
			if(map[i][x] == -1){
				map[i][x] = node;
				map[x][i] = node;
				node++;
			}

			if(j>0){
				vec[prev_node].push_back(map[i][x]);
				indegree[map[i][x]]++;
			}

			prev_node = map[i][x];

		}
	}

	int day = 0;
	
	for(i=1;i<node;i++){
		if(indegree[i] == 0){
			q.push(i);
		}
	}


	int src,u,totalMatch=0;
	while(!q.empty()){
		day++;
		queue<int>sq;
		while(!q.empty()){
			src = q.front();
			q.pop();
			totalMatch++;
			for(i=0;i<vec[src].size();i++){
				indegree[vec[src][i]]--;
				if(indegree[vec[src][i]] == 0){
					sq.push(vec[src][i]);
				}
			}	
		}

		q = sq;
		

	}

	int x = (n*(n-1))/2;
	if(totalMatch == x){
		printf("%d\n",day);	
	}else 
		printf("-1\n");
	

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:88:13: error: redeclaration of 'int x'
   88 |         int x = (n*(n-1))/2;
      |             ^
a.cc:33:19: note: 'int x' previously declared here
   33 |         int n,i,j,x;
      |                   ^
Language: C++

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"
#include "boost/functional/hash.hpp"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
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();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

struct Node {
    pair<int,int> number;
    vector<pair<int,int>> destinations;
    int in;
    Node() {
        in = 0;
        number = {-1, -1};
    }
};

class ELeague {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    const int num = N * (N-1) / 2;
	    vector<vector<Node>> nodes(N+1, vector<Node>(N+1));

        REP(i,1,N+1) REP(j,0,N-1) {
            int prev, cur;
            in >> cur;
            Node *curNode = &nodes[min(i,cur)][max(i,cur)];
            curNode->number = {min(i,cur), max(i,cur)};
            if (j!=0) {
                Node *prevNode = &nodes[min(i,prev)][max(i,prev)];
                prevNode->destinations.push_back(curNode->number);
                curNode->in++;
            }
            prev = cur;
        }
        queue<Node*> que, nextQue;
        REP(i,1,N+1) REP(j,i+1,N+1) {
            if (nodes[i][j].in == 0) que.push(&nodes[i][j]);
        }
        int answer = 0;
        int cnt = 0;
        while (!que.empty()) {
            while (!que.empty()) {
                Node* node = que.front();
                que.pop();
                cnt++;

                for (const auto& next : node->destinations) {
                    Node* nextNode = &nodes[next.first][next.second];
                    assert(nextNode->in > 0);
                    nextNode->in--;
                    if (nextNode->in == 0) nextQue.push(nextNode);
                }
            }
            swap(que,nextQue);
            answer++;
            assert(nextQue.size() == 0);
        }
        if (cnt != num) {
            out << -1 << "\n";
            return;
        }
        out << answer << "\n";
    }
};


int main() {
	ELeague solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;


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

#include "bits/stdc++.h"
#include "boost/functional/hash.hpp"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long
 
using namespace std;
 
// conversion
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();}
 
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
 
typedef long long ll;
 
const ll MOD = 1e9 + 7;

struct Node {
    pair<int,int> number;
    unordered_set<pair<int,int>, boost::hash<pair<int,int>>> destinations;
    int in=0;
};

class ELeague {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    int num = N * (N-1) / 2;
	    vector<vector<Node>> nodes(N+1, vector<Node>(N+1));

        REP(i,1,N+1) REP(j,0,N-1) {
            int prev, cur;
            in >> cur;
            Node *curNode = &nodes[min(i,cur)][max(i,cur)];
            curNode->number = {min(i,cur), max(i,cur)};
            if (j!=0) {
                Node *prevNode = &nodes[min(i,prev)][max(i,prev)];
                if (prevNode->destinations.find(curNode->number) == prevNode->destinations.end()) {
                    prevNode->destinations.insert(curNode->number);
                    curNode->in++;
                }
            }
            prev = cur;
        }
        queue<Node*> que, nextQue;
        REP(i,1,N+1) REP(j,i+1,N+1) {
            if (nodes[i][j].in == 0) que.push(&nodes[i][j]);
        }
        int answer = 0;
        while (!que.empty()) {
            while (!que.empty()) {
                Node* node = que.front();
                que.pop();

                for (const auto& next : node->destinations) {
                    Node* nextNode = &nodes[next.first][next.second];
                    assert(nextNode->in > 0);
                    nextNode->in--;
                    if (nextNode->in == 0) nextQue.push(nextNode);
                }
            }
            swap(que,nextQue);
            answer++;
        }
        REP(i,1,N+1) REP(j,i+1,N+1) {
            if (nodes[i][j].in != 0) {
                assert(nodes[i][j].in > 0 && nodes[i][j].number.first != 0);
                out << -1 << "\n";
                return;
            }
        }
        out << answer << "\n";
    }
};


Compiler output:
a.cc:2:10: fatal error: boost/functional/hash.hpp: No such file or directory
    2 | #include "boost/functional/hash.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] A = new int[N][N - 1];
		V[][] vs = new V[N][N];
		int[][] d = new int[N][N];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N - 1; j++) {
				A[i][j] = sc.nextInt() - 1;
			}
		}
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				vs[i][j] = vs[j][i] = new V(i, j);
			}
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N - 2; j++) {
				vs[i][A[i][j]].add(vs[i][A[i][j+1]]);
				d[i][A[i][j+1]]++;
				d[A[i][j+1]][i]++;
			}
		}
		Queue<V> que = new LinkedList<>();
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (d[i][j] == 0) {
					que.offer(vs[i][j]);
					vs[i][j].depth = 1;
				}
			}
		}
		int cnt = 0;
		while (!que.isEmpty()) {
			V v = que.poll();
			cnt++;
			for (V w: v) {
				d[w.p][w.q]--;
				w.depth = Math.max(w.depth, v.depth + 1);
				if (d[w.p][w.q] == 0) {
					que.offer(w);
				}
			}
		}
		if (cnt != N * (N - 1) / 2) {
			System.out.println(-1);
			return;
		}
		int diam = 0;
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				diam = Math.max(diam, vs[i][j].depth);
			}
		}
		System.out.println(diam);
	}
	static class V extends ArrayList<V>
	{
		int p, q;
		int depth = 0;
		V(int _p, int _q) {p = _p; q = _q;}
	}

Compiler output:
Main.java:65: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/*template*/
template<class T>constexpr bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>constexpr bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
constexpr int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
constexpr int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
constexpr int32_t LCM(int32_t a, int32_t b){return a / GCD(a, b) * b;}
constexpr int64_t LCM(int64_t a, int64_t b){return a / GCD(a, b) * b;}

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7;
constexpr int32_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

#define int int64_t

/*global*/



signed main()
{
	int n; cin >> n;
	vector<vector<int>> a(n, vector<int>(n-1));

	for(int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n-1; ++j)
		{
			cin >> a[i][j];
			a[i][j]--;
		}
		reverse(a[i].begin(), a[i].end());
	}
	using pi = pair<int, int>;
	vector<pi> q;//直近の試合の予定を保持するため

	//選手iの試合の予定のチェックと作成
	auto check = [&](int i)
	{
		if(a[i].size == 0) return;
		int j = a[i].back();
		if(a[j].back() == i)
		{
			pi p(i, j);
			if(p.second < p.first) swap(p.first, p.second);
			q.emplace_back(p);
		}
	};

	for (int i = 0; i < n; ++i)
	{
		check(i);
	}

	int day{};
	//qには試合の予定が入る
	//qの試合の予定を整形してからprevQに移して、本体aの予定消化（予定から削除してやったことにする）
	//選手i,jだけが試合を行ったのでi,jについてだけcheck
	while(q.size() > 0)
	{
		day++;
		sort(q.begin(), q.end());
		q.erase(unique(q.begin(), q.end()), q.end());
		vector<pi>  prevQ;
		swap(prevQ, q);
		for(pi p: prevQ)
		{
			int i = p.first; int j = p.second;
			a[i].pop_back();
			a[j].pop_back();
		}
		
		for(pi p: prevQ)
		{
			int i = p.first; int j = p.second;
			check(i);
			check(j);
		}
	}
	
	for(int i = 0; i < n; ++i)
	{
		if(a[i].size() != 0)
		{
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << day << '\n';

}

Compiler output:
a.cc: In lambda function:
a.cc:76:25: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long int; _Alloc = std::allocator<long int>; size_type = long unsigned int]' (did you forget the '()' ?)
   76 |                 if(a[i].size == 0) return;
      |                             ()
Language: C++

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = [list(map(int,input().split())) for _ in range(n)]
    ans = 0

    while any(len(a[i]) != 0 for i in range(n)):
        ans += 1
        li = [True]*n
        for i in range(n):
            if li[i] and len(a[i]) != 0:
                if li[a[i][0]-1] and a[a[i][0]-1][0]-1 == i:
                    li[i] = False
                    li[a[i][0]-1] = False
                    a[a[i][0]-1].pop(0)
                    a[i].pop(0)
        if all(li[i] for i in range(n)):
            print(-1)
            exit()

    print(ans)

if __name__ == '__main__':
    main()

Compiler output:
a.cc:25:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   25 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

const int bound = 1000;
vector<int> g[bound*bound];

// トポロジカルソート
// 入次数が 0 のものから DFS する

int h[bound*bound];		// 入次数
int cnt = 0;

void tps( int p ){
	if( h[p] <= 1  ){
		++cnt;
		if( h[p] == 1 ) h[p] = 0;
		for( auto next : g[p] ) tps( next );
	} else {
		--h[p];
	}
}

// DAG 上の最長経路を求める
// メモ化再帰，EDPC-G

int dist[bound*bound];
bool besucht[bound*bound];

int dfs( int p ){
	if( besucht[p] ) return dist[p];
	besucht[p] = true;
	int res = 0;
	for( auto nextp : g[p] ){
		res = max(res, dfs(nextp)+1);
	}
	return dist[p] = res;
}

int main(){
	int n; cin >> n;
    set<int> candy;
	int prev = 0, cur = 0;
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n-1; ++j ){
			prev = cur;
			int a = i, b; cin >> b; --b;
			if( a > b ) swap(a, b);
			cur = bound*a+b;
			candy.insert(cur);
			if( j == 0 ) continue;
			g[prev].push_back(cur);
			++h[cur];
		}
	}
	vector<int> zerocandy;
	for( auto p : candy ) if( h[p] == 0 ) zerocandy.push_back(p);
	for( auto p : zerocandy ) tps(p);
	// トポロジカルソートが完了する ⇔ DAG であるから cnt を見て閉路判定
	if( cnt != candy.l_ength() ){
		cout << -1 << endl;
		return 0;
	}
	int ans = 0;
	for( auto p : candy )　ans = max(ans, dfs(p));
	cout << ans+1 << endl;
}

Compiler output:
a.cc:68:30: error: extended character 　 is not valid in an identifier
   68 |         for( auto p : candy )　ans = max(ans, dfs(p));
      |                              ^
a.cc: In function 'int main()':
a.cc:68:30: error: '\U00003000ans' was not declared in this scope
   68 |         for( auto p : candy )　ans = max(ans, dfs(p));
      |                              ^~~~~
Language: C++

#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

const int bound = 1000;
vector<int> g[bound*bound];

// トポロジカルソート
// 入次数が 0 のものから DFS する

int h[bound*bound];		// 入次数
int cnt = 0;

void tps( int p ){
	if( h[p] <= 1  ){
		++cnt;
		if( h[p] == 1 ) h[p] = 0;
		for( auto next : g[p] ) tps( next );
	} else {
		--h[p];
	}
}

// DAG 上の最長経路を求める
// メモ化再帰，EDPC-G

int dist[bound*bound];
bool besucht[bound*bound];

int dfs( int p ){
	if( besucht[p] ) return dist[p];
	besucht[p] = true;
	int res = 0;
	for( auto nextp : g[p] ){
		res = max(res, dfs(nextp)+1);
	}
	return dist[p] = res;
}

int main(){
	int n; cin >> n;
    set<int> candy;
	int prev = 0, cur = 0;
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n-1; ++j ){
			prev = cur;
			int a = i, b; cin >> b; --b;
			if( a > b ) swap(a, b);
			cur = bound*a+b;
			candy.insert(cur);
			if( j == 0 ) continue;
			g[prev].push_back(cur);
			++h[cur];
		}
	}
	vector<int> zerocandy
	for( auto p : candy ) if( h[p] == 0 ) zerocandy.push_back(p);
	for( auto p : zerocandy ) tps(p);
	// トポロジカルソートが完了する ⇔ DAG であるから cnt を見て閉路判定
	if( cnt != candy.l_ength() ){
		cout << -1 << endl;
		return 0;
	}
	int ans = 0;
	for( auto p : candy )　ans = max(ans, dfs(p));
	cout << ans+1 << endl;
}

Compiler output:
a.cc:68:30: error: extended character 　 is not valid in an identifier
   68 |         for( auto p : candy )　ans = max(ans, dfs(p));
      |                              ^
a.cc: In function 'int main()':
a.cc:60:9: error: expected initializer before 'for'
   60 |         for( auto p : candy ) if( h[p] == 0 ) zerocandy.push_back(p);
      |         ^~~
a.cc:61:23: error: 'zerocandy' was not declared in this scope
   61 |         for( auto p : zerocandy ) tps(p);
      |                       ^~~~~~~~~
a.cc:68:30: error: '\U00003000ans' was not declared in this scope
   68 |         for( auto p : candy )　ans = max(ans, dfs(p));
      |                              ^~~~~
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
using namespace std;
inline int read()
{
	ubt s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')w=-1;ch=getchar();
	}
	while(ch>='0'&&ch<='9') 
		s=s*10+ch-'0',ch=getchar();
	return s*w;
}
#define maxn 1009
bool vis[maxn];
int a[maxn][maxn],dd[maxn];
int main()
{
	int n,cnt=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		dd[i]=1;
		for (int j=1;j<n;j++)
			a[i][j]=read();
	}
	int ans=0;
	bool flag=1;
	while (flag)
	{
		ans++;
		bool vis[maxn]={};
		flag=0;
		for (int i=1;i<=n;i++)
		{
			int temp=a[i][dd[i]];
			if (dd[i]==n||vis[i]||vis[temp]||a[temp][dd[temp]]!=i||dd[temp]==n) continue;
			flag=1;
			vis[i]=vis[temp]=1;
			dd[i]++;
			dd[temp]++;
		}
	}
	for (int i=1;i<=n;i++)
		if (dd[i]!=n)
		{
			puts("-1");
			return 0;
		}
	printf("%d\n",ans-1);
	return 0;
}


Compiler output:
a.cc: In function 'int read()':
a.cc:6:9: error: 'ubt' was not declared in this scope
    6 |         ubt s=0,w=1;
      |         ^~~
a.cc:10:28: error: 'w' was not declared in this scope
   10 |                 if(ch=='-')w=-1;ch=getchar();
      |                            ^
a.cc:13:17: error: 's' was not declared in this scope
   13 |                 s=s*10+ch-'0',ch=getchar();
      |                 ^
a.cc:14:16: error: 's' was not declared in this scope
   14 |         return s*w;
      |                ^
a.cc:14:18: error: 'w' was not declared in this scope
   14 |         return s*w;
      |                  ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1002;
const int INF  = 1<<30;
const int mod  = 1e9+7;

int s[maxn][maxn];
int pos[maxn];
int pre[maxn];
bool v[maxn][maxn];
bool vv[maxn];
void solve(){
    int n,ans=0,tot = 0,cnt = 0;
    cin>>n;
    tot = n*(n-1)/2;
    for(int i=1;i<=n;i++) pos[i] = 1,pre[i] = 1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<n;j++)
            cin>>s[i][j];
    for(int i=1;i<=n*n;i++){
        for(int j=1;j<=n;j++) v[j] = false;
        for(int j=1;j<=n;j++){
            int to = s[j][pos[j]];
            if(!vv[j] && !vv[to] && to < n && s[to][pos[to]] == j && !v[j][to]){
                v[j][to] = v[to][j] = true;
                pos[j]++; pos[to]++;
                vv[j] = vv[to]  =true;
                ++cnt;
            }
        }
        int flag = 1;
        for(int i=1;i<=n;i++){
            if(pre[i]!=pos[i]){
                flag = 0;break;
            }
        }
        for(int i=1;i<=n;i++)pre[i] = pos[i];
        if(flag){
            break;
        }
        ++ans;
        if(cnt == tot)break;
        flag = 1;
        for(int j=1;j<=n;j++){
            if(pos[j] < n){
                flag= 0 ;break;
            }
        }
        if(flag){
            break;
        }
    }
    int flag = 1;
    for(int i=1;i<=n;i++){
        if(pos[i] != n){
            flag = 0;break;
        }
    }
    if(flag){
        printf("%d\n",ans );
    }else{
        printf("-1\n");
    }
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:38:36: error: incompatible types in assignment of 'bool' to 'bool [1002]'
   38 |         for(int j=1;j<=n;j++) v[j] = false;
      |                               ~~~~~^~~~~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1002;
const int INF  = 1<<30;
const int mod  = 1e9+7;

int s[maxn][maxn];
int pos[maxn];
int pre[maxn];
bool v[maxn][maxn];
bool vv[maxn];
void solve(){
    int n,ans=0,tot = 0,cnt = 0;
    cin>>n;
    tot = n*(n-1)/2;
    for(int i=1;i<=n;i++) pos[i] = 1,pre[i] = 1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<n;j++)
            cin>>s[i][j];
    for(int i=1;i<=n*n;i++){
        for(int j=1;j<=n;j++) v[j] = false;
        for(int j=1;j<=n;j++){
            int to = s[j][pos[j]];
            if(!vv[j] && !vv[to] && to < n && s[to][pos[to]] == j && !v[j][to]){
                v[j][to] = v[to][j] = true;
                pos[j]++; pos[to]++;
                vv[j] = vv[to]  =true;
                ++cnt;
            }
        }
        int flag = 1;
        for(int i=1;i<=n;i++){
            if(pre[i]!=pos[i]){
                flag = 0;break;
            }
        }
        for(int i=1;i<=n;i++)pre[i] = pos[i];
        if(flag){
            break;
        }
        ++ans;
        if(cnt == tot)break;
        flag = 1;
        for(int j=1;j<=n;j++){
            if(pos[j] < n){
                flag= 0 ;break;
            }
        }
        if(flag){
            break;
        }
    }
    int flag = 1;
    for(int i=1;i<=n;i++){
        if(pos[i] != n){
            flag = 0;break;
        }
    }
    if(flag){
        printf("%d\n",ans );
    }else{
        printf("-1\n");
    }
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:38:36: error: incompatible types in assignment of 'bool' to 'bool [1002]'
   38 |         for(int j=1;j<=n;j++) v[j] = false;
      |                               ~~~~~^~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
//Nチームで総当たり戦を行う。各チーム戦う相手の順番が決まっているものとする
//各チーム1日で１試合しか行えない。異なるチームは同日に並行して試合を行える
//総当たり戦を完了するまでに必要な最小日数は何日か
//試合が行えるものからどんどん行えばよい日数の効率的な数え方を考える
//愚直に全チーム見て試合できそうなところを貪欲に行うとすると間に合わない
//そこで２日目以降は前日に試合の実施状況に変化があった人のみ次の試合が可能か判定する
int N;
deque<int>A[1010];//両端キュー
int step[1010];//step[i]>numだったらその日iチームは試合を行えない
int M;
int main() {
	int i, j, k, l, r, x, y; string s;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N - 1; ++j) {
			cin >> x;
			A[i].push_back(x - 1);
		}
	}
	M = N * (N - 1) / 2;
	queue<int>Q;
	for (int i = 0; i < N; ++i)Q.push(i);
	int num = 0;
	while (Q.size()) {
		//このループ一回ごとに一日で行える試合を処理していく
		int ok = 0;
		queue<int>Q2;
		while (Q.size()) {
			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;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:69:31: error: cannot resolve overloaded function 'front' based on conversion to type 'int'
   69 |                         i = Q.front;
      |                               ^~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define rep(i,n) for(int i = 0; i < (n); i++)

template<class T, class U>
using umap = unordered_map<T, U>;
using ll = long long;

ll n;
vector<vector<ll>> a;
umap<ll, vector<ll>> to;

int main(){
  const ll MAXN = 1005;
  const ll MAXV = MAXN*(MAXN-1)/2;
  cin >> n;  
  a.resize(n, vector<ll>(n-1));
  set<ll> v;
  auto id = [](ll i, ll j){
	   if(i > j) swap(i, j);
	   return i*MAXN + j;
	 };

  rep(i, n){
    rep(j, n-1){
      cin >> a[i][j];a[i][j]--;
      if(j)to[id(i,a[i][j-1])].push_back(id(i,a[i][j]));
      v.insert(id(i,a[i][j-1]));
      v.insert(id(i,a[i][j]));
    }
  }
  
  ll dist[MAXV] = {};
  set<ll> vst, fin;
  auto dfs = [&](ll i, auto func) -> ll{
	       if(vst.count(i) == 1) {
		 if(fin.count(i) == 0) return -1;
		 return dist[i];
	       }
	       vst.insert(i);
	       ll ret = 1;
	       for(auto&e : to[i]){
		 ll d = func(e, func);
		 if(d == -1) return -1;
		 else ret = max(ret, d + 1);
	       }
	       fin.insert(i);
	       dist[i] = ret;
	       return dist[i];
	     };
  ll ans = 1;
  for(auto&&e:v){
    ll val = dfs(e.dfs);
    if(val == -1){
      ans = -1; break;
    }
    ans = max(ans, val);
  }
  // rep(i,MAXV){
  //   ll val = dfs(i, dfs);
  //   if(val == -1){
  //     ans = -1; break;
  //   }
  //   ans = max(ans, val);
  // }
  cout << ans << endl;
  return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:56:20: error: request for member 'dfs' in 'e', which is of non-class type 'const long long int'
   56 |     ll val = dfs(e.dfs);
      |                    ^~~
Language: C++

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

int main(){
	ios_base::sync_with_stdio(false);
	int n,tot,ans=0;
	cin >> n;
	tot = n*(n-1);
	vector<queue<int>> x(n);
	for(int i = 0 ; i < n ; i += 1){
		for(int j = 0 ; j < n-1 ; j += 1){
			int a;
			cin >> a;
			a -= 1;
			x[i].push(a);
		}
	}
	while(true){
		ans += 1;
		vector<bool> seen(n,false);
		bool t = false;
		for(int i = 0 ; i < n ; i += 1){
			if(x[i].size() > 0 && !seen[i] && !seen[x[i].front()]){
				if(x[x[i].front()].front() == i){
					x[x[i].front()].pop();
					seen[x[i].front()] = true;
					x[i].pop();
					seen[i] = true;
					t = true;
					tot -= 2;
				}else{
					seen[x[i].front] = true;
					seen[i] = true;
				}
			}
		}
		if(!t){
			break;
		}
	}
	if(tot > 0){
		cout << -1 << endl;
	}else{
		cout << ans-1 << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:45: error: no match for 'operator[]' (operand types are 'std::vector<bool>' and '<unresolved overloaded function type>')
   32 |                                         seen[x[i].front] = true;
      |                                             ^
In file included from /usr/include/c++/14/vector:67,
                 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_bvector.h:1086:7: note: candidate: 'std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](size_type) [with _Alloc = std::allocator<bool>; reference = std::vector<bool>::reference; size_type = long unsigned int]'
 1086 |       operator[](size_type __n)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:1086:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<bool>::size_type' {aka 'long unsigned int'}
 1086 |       operator[](size_type __n)
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_bvector.h:1091:7: note: candidate: 'std::vector<bool, _Alloc>::const_reference std::vector<bool, _Alloc>::operator[](size_type) const [with _Alloc = std::allocator<bool>; const_reference = bool; size_type = long unsigned int]'
 1091 |       operator[](size_type __n) const
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:1091:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<bool>::size_type' {aka 'long unsigned int'}
 1091 |       operator[](size_type __n) const
      |                  ~~~~~~~~~~^~~
Language: C++

def func(x, y):
    if x > y:
        return func(y, x)
    return (x, y)

N = int(input())
A = [None]
A += [[0] + list(map(int, input().split())) for _ in range(N)]
v = [[[] for _ in range(N+1)] for _ in range(N+1)]
cnt = [[0]*(N+1) for _ in range(N+1)]
for i in range(1, N+1):
    for j in range(1, N):
        if j == 1:
            continue
        pre = func(i, A[i][j-1])
        to = func(i, A[i][j])
        v[pre[0]][pre[1]].append(to)
        cnt[to[0]][to[1]] += 1

vis = [[0]*(N+1) for _ in range(N+1)]

def dfs(x, y):
    ok = True
    vis[x][y] = -1
    for s, t in v[x][y]:
        if vis[s][t] == 0:
            ok = ok and dfs(s, t)
        elif vis[s][t] == -1:
            return False
    vis[x][y] = 1
    return ok

for i in range(1, N+1):
    for j in range(1, N):
        if not dfs(i, j):
            print(-1)
            exit()

vis2 = [[0]*(N+1) for _ in range(N+1)]
stack = []

def dfs2(x, y):
    vis2[x][y] = 1
    for s, t in v[x][y]:
        if vis2[s][t] == 0:
            dfs2(s, t)
    stack.append((x, y))

for i in range(1, N+1):
    for j in range(1, N):
        if cnt[i][j] == 0:
            dfs2(i, j)

dp = [[0]*(N+1) for _ in range(N+1)]
while stack:
    x, y = stack.pop()
    for s, t in v[x][y]:
        dp[s][t] = max(dp[s][t], dp[x][y] + 1)

ans = 0
for i in range(1, N+1):
    ans = max(ans, max(dp[i]))

print(ans + 1)

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def func(x, y):
      | ^~~
Language: C

n=int(input())
print(int(((n-1)*n)//2))

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | n=int(input())
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:1:3: error: expected expression before 'int'
    1 | n=int(input())
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back
 
#define N 200010
#define MOD 1000000007


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

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

	int po[n + 1] = {};
	ll ans = 0;
	while(1)
	{
		int done[n + 1] = {}, f = 0;
		for(int i = 1; i <= n; ++i)
		{
			if(po[i] == n - 1)
				continue;
			int k = a[i][po[i]];
			if(a[k][po[k]] == i && done[i] == 0 && done[k] == 0)
			{
				f = 1;
				done[i] = done[k] = 1;
				po[i]++, po[k]++;
			}
		}

		if(f == 0)
			break;

		ans++;
	}
	if(ans == 0)
		ans = -1;
	cout << ans;
	return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:29:12: error: expected initializer before 'ans'
   29 |         ll ans = 0;
      |            ^~~
a.cc:49:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   49 |                 ans++;
      |                 ^~~
      |                 abs
a.cc:51:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   51 |         if(ans == 0)
      |            ^~~
      |            abs
a.cc:53:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   53 |         cout << ans;
      |                 ^~~
      |                 abs
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define rep(i,n) for(int i = 0; i < (n); i++)

template<class T, class U>
using umap = unordered_map<T, U>;
using ll = long long;

ll n;
vector<vector<ll>> a;
umap<ll, vector<ll>> to;

int main(){
  const ll MAXN = 1005;
  const ll MAXV = MAXN*(MAXN-1)/2;
  cin >> n;  
  a.resize(n, vector<ll>(n-1));
  auto id = [](ll i, ll j){
	   if(i > j) swap(i, j);
	   return i*MAXN + j;
	 };

  rep(i, n){
    rep(j, n-1){
      cin >> a[i][j];a[i][j]--;
      if(j)to[id(i,a[i][j-1])].push_back(id(i,a[i][j]));      
    }
  }
  
  ll dist[MAXV] = {};
  bitset<MAXV> vst;
  bitset<MAXV> fin;
  auto dfs = [&](ll i, auto func) -> ll{
	       if(vst[i] == 1) {
		 if(fin[i] == 0) return -1;
		 return dist[i];
	       }
	       vst[i] = 1;
	       int ret  1;
	       for(auto&e : to[i]){
		 ll d = func(e, func);
		 if(d == -1) return -1;
		 else ret = max(ret, d + 1);
	       }
	       fin[i] = 1;
	       dist[i] = ret;
	       return dist[i];
	     };
  ll ans = 1;
  rep(i,MAXV){
    ll val = dfs(i, dfs);
    if(val == -1){
      ans = -1; break;
    }
    ans = max(ans, val);
  }
  cout << ans << endl;
  return 0;
}




Compiler output:
a.cc: In lambda function:
a.cc:42:25: error: expected initializer before numeric constant
   42 |                int ret  1;
      |                         ^
a.cc:46:23: error: 'ret' was not declared in this scope; did you mean 'rep'?
   46 |                  else ret = max(ret, d + 1);
      |                       ^~~
      |                       rep
a.cc:49:26: error: 'ret' was not declared in this scope; did you mean 'rep'?
   49 |                dist[i] = ret;
      |                          ^~~
      |                          rep
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define rep(i,n) for(int i = 0; i < (n); i++)

template<class T, class U>
using umap = unordered_map<T, U>;
using ll = long long;

ll n;
vector<vector<ll>> a;
umap<ll, vector<ll>> to;

int main(){
  const ll MAXN = 1005;
  const ll MAXV = MAXN*(MAXN-1)/2;
  cin >> n;  
  a.resize(n, vector<ll>(n-1));
  auto id = [](ll i, ll j){
	   if(i > j) swap(i, j);
	   return i*MAXN + j;
	 };

  rep(i, n){
    rep(j, n-1){
      cin >> a[i][j];a[i][j]--;
      if(j)to[id(i,a[i][j-1])].push_back(id(i,a[i][j]));      
    }
  }
  
  ll dist[MAXV] = {};
  bitset<MAXV> fin;
  auto dfs = [&](ll i, auto func){
	       if(dist[i]) {
		 if(fin[i] == 0) return -1;
		 return dist[i];
	       }
	       dist[i] = 1;
	       for(auto&e : to[i]){
		 ll d = func(e, func);
		 if(d == -1) return -1;
		 else dist[i] = max(dist[i], d + 1);
	       }
	       fin[i] = 1;
	       return dist[i];
	     };
  ll ans = 1;
  rep(i,MAXV){
    ll val = dfs(i, dfs);
    if(val == -1){
      ans = -1; break;
    }
    ans = max(ans, val);
  }
  cout << ans << endl;
  return 0;
}




Compiler output:
a.cc: In instantiation of 'main()::<lambda(ll, auto:28)> [with auto:28 = main()::<lambda(ll, auto:28)>; ll = long long int]':
a.cc:51:17:   required from here
   51 |     ll val = dfs(i, dfs);
      |              ~~~^~~~~~~~
a.cc:38:31: error: inconsistent types 'int' and 'long long int' deduced for lambda return type
   38 |                  return dist[i];
      |                         ~~~~~~^
a.cc:47:29: error: inconsistent types 'int' and 'long long int' deduced for lambda return type
   47 |                return dist[i];
      |                       ~~~~~~^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {

	public static void main(String[] args) throws IOException {
      	long s = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] inputs = br.readLine().split(" ");
		int N = Integer.parseInt(inputs[0]);

		int tb[][] = new int[N + 1][N]; // pのn番目の対戦相手 r = tb[p][n]  (1-origin 
		int pIdx[] = new int[N + 1];	// pの試合消化数 = pIdx[p]       同上

		// p:player  r:rival
		for ( int p = 1; p <= N; p++ ) {
			pIdx[p] = 1;

			inputs = br.readLine().split(" ");
			for ( int n = 1; n <= N - 1; n++ ) {
				int r = Integer.parseInt(inputs[n - 1]);
				tb[p][n] = r;
			}
		}

		int match = N * (N - 1) / 2;
		int days = 0;

		HashSet<Integer> todayDone = new HashSet<>(); // その日の試合が成立して除外された選手をここに入れる
		do {
          	// 嘘解法：時間がかかるケースは日数＝試合数と推測
			long e = System.currentTimeMillis();
			if(e - s > 600) {
				System.out.print(n * (n - 1) / 2);
				br.close();
				return;
			}
          
			days++;
			todayDone.clear();

			for ( int p = 1; p <= N; p++ ) {
				if ( todayDone.contains(p) || pIdx[p] >= N ) continue;

				int r = tb[p][pIdx[p]];
				if ( todayDone.contains(r) || pIdx[r] >= N ) continue;
				
				// pの「相手の相手」がpだったら試合成立
				int r_r = tb[r][pIdx[r]];				
				if ( p == r_r ) {
					todayDone.add(p);
					todayDone.add(r);
					pIdx[p]++;
					pIdx[r]++;
					match--;
				}
			}

		} while ( todayDone.size() > 0 );

		System.out.println(match == 0 ? days - 1 : -1);
		br.close();
	}
}


Compiler output:
Main.java:37: error: cannot find symbol
				System.out.print(n * (n - 1) / 2);
				                 ^
  symbol:   variable n
  location: class Main
Main.java:37: error: cannot find symbol
				System.out.print(n * (n - 1) / 2);
				                      ^
  symbol:   variable n
  location: class Main
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
struct node {
	int to,next,v;
} a[2000001];
int head[2000001],cnt,vis[1000001];
void add(int x,int y,int v) {
	a[++cnt].to=y;
	a[cnt].next=head[x];
	a[cnt].v=v;
	head[x]=cnt;
}
int f[1001][10001];
int dp[1000001];
int DP(int i) {
	if(dp[i]>0) return dp[i];
	for(int j=head[i]; j; j=a[j].next)
		dp[i]=max(dp[i],DP(a[j].to)+a[j].v);
	return dp[i];
}
const int N=10000010;
int tot,ans;
vector<int> e[N];
queue<int> que;
int dis[N];
void topo() {
	ans=0;
	while(!que.empty()) que.pop();
	for(int i=1; i<=tot; i++)
		if(dis[i]==0)
			que.push(i);
	while(!que.empty()) {
		int q1,q2,q3;
		q1=que.front();
		que.pop();
		ans++;
		for(int j=0; j<e[q1].size(); j++) {
			dis[e[q1][j]]--;
			if(!dis[e[q1][j]])
				que.push(e[q1][j]);
	}
	if(ans!=tot) puts("-1"),exit(0);
}
main() {
	int n=read(),maxx=0,x,last;
	for(int i=1; i<=n; i++)
		for(int j=1; j<i; j++)
			f[j][i]=f[i][j]=++tot;
	for(int i=1; i<=n; i++)
		for(int j=1; j<n; j++) {
			x=read();
			if(j>1) add(f[i][last],f[i][x],1),dis[f[i][x]]++,e[f[i][last]].push_back(f[i][x]);
			last=x;
		}
	cout<<"-1",exit(0);
	topo();
	for(int i=1; i<=tot; i++)
		maxx=max(DP(i),maxx);
	cout<<maxx+1<<endl;
}


Compiler output:
a.cc: In function 'void topo()':
a.cc:53:1: error: 'main' was not declared in this scope
   53 | main() {
      | ^~~~
a.cc:69:2: error: expected '}' at end of input
   69 | }
      |  ^
a.cc:35:13: note: to match this '{'
   35 | void topo() {
      |             ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

typedef std::vector<std::vector<int>> graph;

int n;
bool cycle(const int s, const int size, const graph &g)
{
  vector<int> d(size);
  REP(i, size)
  {
    d[i] = INF;
  }
  d[s] = 0;

  int counter = 0;
  while (true)
  {
    counter++;
    bool update = false;
    REP(i, g.size())
    {
      for (auto e : g[i])
      {
        if (d[i] != INF && d[e] > d[i] - 1)
        {
          d[e] = d[i] - 1;
          update = true;
        }
      }
    }
    if (!update)
      break;
    if (update && counter >= size)
    {
      return true;
    }
  }
  return false;
}

int dfs(int i, int len, const graph &g)
{
  int ans = len;
  for (auto v : g[i])
  {
    ans = max(ans, dfs(v, len + 1, g));
  }
  return ans;
}

int f(int i, int j)
{
  if (j < i)
  {
    int tmp = j;
    j = i;
    i = tmp;
  }
  int ans = n * (i - 1) - i * (i - 1) / 2;
  return ans + j - i - 1;
}

int main()
{
  cin >> n;
  graph g(n * (n - 1) / 2);
  vector<bool> in(n * (n - 1) / 2, false);
  REP(i, n)
  {
    vector<int> a(n - 1);
    REP(j, n - 1)
    {
      cin >> a[j];
    }

    FOR(j, 1, n - 1)
    {
      g[f(i + 1, a[j - 1])].push_back(f(i + 1, a[j]));
      in[f(i + 1, a[j])] = true;
    }
  }

  if (cycle(i, n * (n - 1) / 2, g))
  {
    cout << -1 << endl;
    return 0;
  }

  // 最長パスの計算
  int ans = 0;
  REP(i, n * (n - 1) / 2)
  {
    if (in[i])
      continue;
    ans = max(ans, dfs(i, 1, g));
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:89:13: error: 'i' was not declared in this scope; did you mean 'in'?
   89 |   if (cycle(i, n * (n - 1) / 2, g))
      |             ^
      |             in
Language: C++

N = gets.to_i
A = N.times.map{ gets.split.map{|_| _.to_i-1 } }

Remain = lambda{ A.map(&:size).inject(&:+) }
before = Remain.call
day = 0
loop {
	match_waiting = []
	N.times{|i|
		target = A[i].first
		next unless target
		if i < target
			match_waiting << [i, target] 
		else
			j = match_waiting.find_index([target, i])
			if j
				match_waiting.delete_at j
				A[target].shift
				A[i].shift
			end
		end
	}
	after = Remain.call
	break if before == after

	before = after
	day += 1
}
p (Remain.call == 0 ? day : -1)


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = gets.to_i
      | ^
a.cc:4:1: error: 'Remain' does not name a type
    4 | Remain = lambda{ A.map(&:size).inject(&:+) }
      | ^~~~~~
a.cc:5:1: error: 'before' does not name a type
    5 | before = Remain.call
      | ^~~~~~
a.cc:29:3: error: expected constructor, destructor, or type conversion before '(' token
   29 | p (Remain.call == 0 ? day : -1)
      |   ^