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

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n,m;
    cin >> n >> m;
    vector<vector<int128_t>> a(n,vector<int128_t>(m));
    rep(i,0,n) rep(j,0,m) cin >> a[i][j];

    rep(i,1,n){
        if(a[i][0]<a[i-1][0]){
            cout << -1 << endl;
            return;
        }
    }

    auto magic=[&](int i){
        rep(j,1,m){
            a[i][j]+=a[i][j-1];
        }
    };

    int ans=0;
    rep(i,1,n){
        while(a[i]<=a[i-1]){
            magic(i);
            ++ans;
        }
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:30:19: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
   30 |     vector<vector<int128_t>> a(n,vector<int128_t>(m));
      |                   ^~~~~~~~
      |                   int8_t
a.cc:30:19: error: template argument 1 is invalid
a.cc:30:19: error: template argument 2 is invalid
a.cc:30:27: error: template argument 1 is invalid
   30 |     vector<vector<int128_t>> a(n,vector<int128_t>(m));
      |                           ^~
a.cc:30:27: error: template argument 2 is invalid
a.cc:30:49: error: template argument 2 is invalid
   30 |     vector<vector<int128_t>> a(n,vector<int128_t>(m));
      |                                                 ^
a.cc:30:53: error: expression list treated as compound expression in initializer [-fpermissive]
   30 |     vector<vector<int128_t>> a(n,vector<int128_t>(m));
      |                                                     ^
a.cc:31:35: error: invalid types 'int[int]' for array subscript
   31 |     rep(i,0,n) rep(j,0,m) cin >> a[i][j];
      |                                   ^
a.cc:34:13: error: invalid types 'int[int]' for array subscript
   34 |         if(a[i][0]<a[i-1][0]){
      |             ^
a.cc:34:21: error: invalid types 'int[int]' for array subscript
   34 |         if(a[i][0]<a[i-1][0]){
      |                     ^
a.cc: In lambda function:
a.cc:42:14: error: invalid types 'int[int]' for array subscript
   42 |             a[i][j]+=a[i][j-1];
      |              ^
a.cc:42:23: error: invalid types 'int[int]' for array subscript
   42 |             a[i][j]+=a[i][j-1];
      |                       ^
a.cc: In function 'void solve()':
a.cc:48:16: error: invalid types 'int[int]' for array subscript
   48 |         while(a[i]<=a[i-1]){
      |                ^
a.cc:48:22: error: invalid types 'int[int]' for array subscript
   48 |         while(a[i]<=a[i-1]){
      |                      ^
Language: C++

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef long double ld;

int n,m;
int a[1005][1005];

int main() {
	ios::sync_with_stdio(0); cin.tie();
	cin >> n >> m;
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < m; ++j)
			cin >> a[i][j];
	ll ans = 0;
	ll last = 0;
	for(int i = 1; i < n; ++i) {
		if(a[i-1][0] > a[i][0]) {
			cout << "-1\n";
			return 0;
		}
		if(a[i-1][0] < a[i][0]) {
			last = 0;
		} else {
			if(n == 1) {
				cout << "-1\n";
				return 0;
			}
			ll b = last*a[i-1][0] + a[i-1][1];
			ll y = a[i][1];
			ll x = a[i][0];
			if((b-y)%x == 0 && n > 2 && a[i][2] > a[i-1][2]) {
				last = (b-y)/x;
			} else {
				ll k = max(0LL,ll(1+(b - y)/x)));
				last = k;
			}
		}
		ans += last;
	}
	cout << ans << "\n";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:64: error: expected ',' or ';' before ')' token
   46 |                                 ll k = max(0LL,ll(1+(b - y)/x)));
      |                                                                ^
Language: C++

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n,m;
    cin >> n >> m;
    vector<vector<__int12>> a(n,vector<__int12>(m));
    rep(i,0,n) rep(j,0,m) cin >> a[i][j];

    rep(i,1,n){
        if(a[i][0]<a[i-1][0]){
            cout << -1 << endl;
            return;
        }
    }

    auto magic=[&](int i){
        rep(j,1,m){
            a[i][j]+=a[i][j-1];
        }
    };

    int ans=0;
    rep(i,1,n){
        while(a[i]<=a[i-1]){
            magic(i);
            ++ans;
        }
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:30:19: error: '__int12' was not declared in this scope; did you mean '__int128'?
   30 |     vector<vector<__int12>> a(n,vector<__int12>(m));
      |                   ^~~~~~~
      |                   __int128
a.cc:30:19: error: template argument 1 is invalid
a.cc:30:19: error: template argument 2 is invalid
a.cc:30:26: error: template argument 1 is invalid
   30 |     vector<vector<__int12>> a(n,vector<__int12>(m));
      |                          ^~
a.cc:30:26: error: template argument 2 is invalid
a.cc:30:47: error: template argument 2 is invalid
   30 |     vector<vector<__int12>> a(n,vector<__int12>(m));
      |                                               ^
a.cc:30:51: error: expression list treated as compound expression in initializer [-fpermissive]
   30 |     vector<vector<__int12>> a(n,vector<__int12>(m));
      |                                                   ^
a.cc:31:35: error: invalid types 'int[int]' for array subscript
   31 |     rep(i,0,n) rep(j,0,m) cin >> a[i][j];
      |                                   ^
a.cc:34:13: error: invalid types 'int[int]' for array subscript
   34 |         if(a[i][0]<a[i-1][0]){
      |             ^
a.cc:34:21: error: invalid types 'int[int]' for array subscript
   34 |         if(a[i][0]<a[i-1][0]){
      |                     ^
a.cc: In lambda function:
a.cc:42:14: error: invalid types 'int[int]' for array subscript
   42 |             a[i][j]+=a[i][j-1];
      |              ^
a.cc:42:23: error: invalid types 'int[int]' for array subscript
   42 |             a[i][j]+=a[i][j-1];
      |                       ^
a.cc: In function 'void solve()':
a.cc:48:16: error: invalid types 'int[int]' for array subscript
   48 |         while(a[i]<=a[i-1]){
      |                ^
a.cc:48:22: error: invalid types 'int[int]' for array subscript
   48 |         while(a[i]<=a[i-1]){
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll unipar[4010];
ll unilen[4010];
struct edge{
  int len,from,to;
};
bool cmp(edge& a,edge& b){
  return a.len<b.len;
}
void init(ll n){
  for(ll i=1;i<=n;i++){
    unipar[i]=i;
    unilen[i]=0;
  }
}
ll root(ll n){
  if(unipar[n]==n)return n;
  return unipar[n]=root(unipar[n]);
}
void unit(ll a,ll b){
  a=root(a);
  b=root(b);
  if(a==b)return;
  if(unilen[a]<unilen[b]){
    unipar[a]=b;
  }
  else{
    unipar[b]=a;
    if(unipar[b]==unipar[a])unilen[a]++;
  }
}
int main(){
  ll n,m;cin>>n>>m;
  vector<edge> v;
  for(ll i=0;i<m;i++){
    ll a,b,c;cin>>a>>b>>c;
    v.push_back((edge){c,a,b});
  }
  sort(v.begin(),v.end(),cmp);
  init(n);
  ll now=0;
  ll sum=0;
  vector<pll> vn[n+1];
  for(ll i=0;i<m;i++){
    edge e=v[i];
    ll a=e.from,b=e.to;
    if(root(a)!=root(b)){
      unit(a,b);
      sum+=e.len;
      vn[a].push_back(make_pair(b,c));
      vn[b].push_back(make_pair(a,c));
      now++;
    }
    if(now==n-1)break;
  }
  

Compiler output:
a.cc: In function 'int main()':
a.cc:40:24: warning: narrowing conversion of 'c' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   40 |     v.push_back((edge){c,a,b});
      |                        ^
a.cc:40:26: warning: narrowing conversion of 'a' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   40 |     v.push_back((edge){c,a,b});
      |                          ^
a.cc:40:28: warning: narrowing conversion of 'b' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   40 |     v.push_back((edge){c,a,b});
      |                            ^
a.cc:53:35: error: 'c' was not declared in this scope
   53 |       vn[a].push_back(make_pair(b,c));
      |                                   ^
a.cc:58:4: error: expected '}' at end of input
   58 |   }
      |    ^
a.cc:35:11: note: to match this '{'
   35 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <queue>
#include <tuple>
#include <vector>

using namespace std;

using ll = long long;

const int MAX_V = 5000;

class UnionFind {
public:
    // コンストラクタ
    explicit UnionFind(int N) : V_NUM(N) {
        for (int i = 0; i < V_NUM; ++i) {
            par[i] = i;
        }
        fill(rank, rank + V_NUM, 0);
    }

    // xの親を返す+更新
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    // xとyを含むグループを統合する
    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if (x == y) return;

        // rank[x] >= rank[y]にする
        if (rank[x] < rank[y]) swap(x, y);
        par[y] = x;
        if (rank[x] == rank[y]) ++rank[x];
    }

    // xとyが同じグループに属するか判定
    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int V_NUM;
    int par[MAX_V], rank[MAX_V];
};

int main() {
    int N, M;
    cin >> N >> M;

    tuple<ll, int, int> edges[M];
    for (int i = 0; i < M; ++i) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        edges[i] = make_tuple(c, --a, --b);
    }

    sort(edges, edges + M);
    UnionFind uf(N);

    // 最小全域木の辺とコスト
    vector<pair<int, ll>> path[N];
    ll total = 0;

    // Kruskalで最小全域木を構築
    for (int i = 0; i < M; ++i) {
        int a, b;
        ll c;
        tie(c, a, b) = edges[i];

        if (uf.same(a, b)) continue;
        uf.unite(a, b);
        total += c;
        path[a].push_back(make_pair(b, c));
        path[b].push_back(make_pair(a, c));
    }

    ll emax[N][N];
    // emax[i][j] = iからjのパス上で最大コストの辺のコスト

    // 各頂点始点のBFS
    for (int r = 0; r < N; ++r) {
        fill(emax[r], emax[r] + N, -1);
        emax[r][r] = 0;
        queue<int> que;
        que.push(r);

        while (!que.empty()) {
            int v = que.front();
            que.pop();

            for (auto p : path[v]) {
                int sv;
                ll cost;
                tie(sv, cost) = p;

                if (emax[r][sv] >= 0) continue;
                emax[r][sv] = max(emax[r][v], cost);
                que.push(sv);
            }
        }
    }

    // クエリ処理
    int Q;
    cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int s, t;
        cin >> s >> t;
        cout << total - emax[--s][--t] << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   65 |     sort(edges, edges + M);
      |     ^~~~
      |     short
Language: Java

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}

	public void run() {
		solver();
	}

	class DJSet {
		int[] upper;

		public DJSet(int n) {
			upper = new int[n];
			Arrays.fill(upper, -1);
		}

		int root(int x) {
			return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
		}

		boolean equiv(int x, int y) {
			return root(x) == root(y);
		}

		void union(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y)
				return;
			if (upper[x] < upper[y]) {
				x ^= y;
				y ^= x;
				x ^= y;
			}
			upper[y] += upper[x];
			upper[x] = y;
		}
	}

	class Edge implements Comparable<Edge> {
		int u, v;
		int cost;

		public Edge(int u_, int v_, int cost_) {
			u = u_;
			v = v_;
			cost = cost_;
		}

		@Override
		public int compareTo(Edge arg0) {
			return Integer.compare(cost, arg0.cost);
		}
	}

	int[][] max;

	void dfs(int cur, int par, int src, int ma, ArrayList<Edge>[] g) {
		max[src][cur] = Math.max(max[src][cur], ma);
		for (Edge e : g[cur]) {
			if (e.v == par)
				continue;
			dfs(e.v, cur, src, Math.max(ma, e.cost), g);
		}
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		ArrayList<Edge>[] g = new ArrayList[N];
		int[][] es = new int[M][3];
		for (int i = 0; i < g.length; ++i)
			g[i] = new ArrayList();
		for (int i = 0; i < M; ++i) {
			int u = Integer.parseInt(sc.next());
			int v = Integer.parseInt(sc.next());
			int c = Integer.parseInt(sc.next());
			--u;
			--v;
			es[i] = new int[] { u, v, c };
		}
		Arrays.sort(es, new Comparator<int[]>() {
			@Override
			public int compare(int[] arg0, int[] arg1) {
				return Integer.compare(arg0[2], arg1[2]);
			}
		});
		{
			DJSet ds = new DJSet(N);
			long ans = 0;
			for (int[] e : es) {
				if (!ds.equiv(e[0], e[1])) {
					ans += e[2];
					g[e[0]].add(new Edge(e[0], e[1], e[2]));
					g[e[1]].add(new Edge(e[1], e[0], e[2]));
					ds.union(e[0], e[1]);
				}
			}
		}
		System.gc();
		max = new int[N][N];
		for (int i = 0; i < N; ++i) {
			dfs(i, -1, i, 0, g);
		}
		PrintWriter pw = new PrintWriter(System.out);
		int Q = Integer.parseInt(sc.next());
		for (int i = 0; i < Q; ++i) {
			int s = Integer.parseInt(sc.next());
			int d = Integer.parseInt(sc.next());
			--s;
			--d;
			pw.println(ans - max[s][d]);
		}
		pw.close();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Compiler output:
Main.java:120: error: cannot find symbol
			pw.println(ans - max[s][d]);
			           ^
  symbol:   variable ans
  location: class Main
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++

#include <vector>
#include <queue>
#include <cstdio>
using namespace std;

typedef long long Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

Graph opt; //optimal edges for minimum-spanning
vector<vector<int>> max_edge;
Weight minimumSpanningForest(const Graph &g) {
  int n = g.size();
  priority_queue<Edge> Q;
  for(int u=0;u<n;u++) for(auto &e: g[u]) /*if (u < e->dst)*/ Q.push(*e);
  UnionFind uf(n);

  Weight total = 0;
  Edges F;
  while (F.size() < n-1 && !Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (uf.unionSet(e.src, e.dst)) {
      F.push_back(e);
      total += e.weight;
      opt[e.src].emplace_back(e.src,e.dst,e.weight);
      opt[e.dst].emplace_back(e.dst,e.src,e.weight);
    }
  }
  return total; //pair<Weight, Edges>(total, F);
}

void dfs(int z,int c,long long k,vector<int>&v){
	max_edge[z][c]=k;
	v[c]=1;
	for(auto &e:opt[c])if(!v[e.dst])dfs(z,e.dst,max(k,e.weight),v);
}

int main(){
	int N,M,Q,a,b,c;
	scanf("%d%d",&N,&M);
	opt.resize(N);
	Weight w;
	{
		Graph g(N);
		for(;M--;){
			scanf("%d%d%d",&a,&b,&c);
			g[a-1].emplace_back(a-1,b-1,c);
		}
		w=minimumSpanningForest(g);
	}
	max_edge.resize(N);
	for(int i=0;i<N;i++)max_edge[i].resize(N);
	for(int i=0;i<N;i++){
		vector<int>v(N);
		dfs(i,i,0,v);
	}
	scanf("%d",&Q);
	for(;Q--;){
		scanf("%d%d",&a,&b);
		printf("%lld\n",w-max_edge[a-1][b-1]);
	}
}

Compiler output:
a.cc: In function 'Weight minimumSpanningForest(const Graph&)':
a.cc:47:70: error: no match for 'operator*' (operand type is 'const Edge')
   47 |   for(int u=0;u<n;u++) for(auto &e: g[u]) /*if (u < e->dst)*/ Q.push(*e);
      |                                                                      ^~
Language: C++

#include "inspect.hpp"
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

Graph opt; //optimal edges for minimum-spanning
vector<vector<int>> max_edge;
Weight minimumSpanningForest(const Graph &g) {
  int n = g.size();
  priority_queue<Edge> Q;
  REP(u, n) FOR(e, g[u]) /*if (u < e->dst)*/ Q.push(*e);
  UnionFind uf(n);

  Weight total = 0;
  Edges F;
  while (F.size() < n-1 && !Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (uf.unionSet(e.src, e.dst)) {
      F.push_back(e);
      total += e.weight;
      opt[e.src].emplace_back(e.src,e.dst,e.weight);
      opt[e.dst].emplace_back(e.dst,e.src,e.weight);
    }
  }
  return total; //pair<Weight, Edges>(total, F);
}

void dfs(int z,int c,long long k,vector<int>&v){
	max_edge[z][c]=k;
	v[c]=1;
	for(auto &e:opt[c])if(!v[e.dst])dfs(z,e.dst,max(k,e.weight),v);
}

int main(){
	int N,M,Q,a,b,c;
	scanf("%d%d",&N,&M);
	opt.resize(N);
	Weight w;
	{
		Graph g(N);
		for(;M--;){
			scanf("%d%d%d",&a,&b,&c);
			g[a-1].emplace_back(a-1,b-1,c);
		}
		w=minimumSpanningForest(g);
	}
	max_edge.resize(N);
	for(int i=0;i<N;i++)max_edge[i].resize(N);
	for(int i=0;i<N;i++){
		vector<int>v(N);
		dfs(i,i,0,v);
	}
	scanf("%d",&Q);
	for(;Q--;){
		scanf("%d%d",&a,&b);
		printf("%lld\n",w-max_edge[a-1][b-1]);
	}
}

Compiler output:
a.cc:1:10: fatal error: inspect.hpp: No such file or directory
    1 | #include "inspect.hpp"
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef int long long;
//typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
class KRK{//c++11
	public:
	struct edge{
		int from,to,cost;
	};
	vector<edge>G,tG;
	int n;
	KRK(int size){
		n=size;
	}
	void add_edge(int a,int b,int c){
		edge e={a,b,c};
		G.pb(e);
	}
	int krk(){
		int sum=0;
		sort(all(G),[](edge a,edge b){
			return a.cost<b.cost;
		});
		UnionFind uf(n);
		rep(i,G.size()){
			edge e=G[i];
			if(!uf.findSet(e.from,e.to)){
				sum+=e.cost;
				tG.pb(e);
				uf.unionSet(e.from,e.to);
			}
		}
		return sum;
	}
	void solve(){
		int out=krk();
//		rep(i,tG.size())cout<<tG[i].from<<" "<<tG[i].to<<endl;
		int ma=0;
		rep(i,tG.size())ma=max(ma,tG[i].cost);
		map<pii,int>m;
		rep(i,tG.size())m[pii(tG[i].to,tG[i].from)]=m[pii(tG[i].from,tG[i].to)]=tG[i].cost;
		int q;
		cin>>q;
		while(q--){
			int a,b;
			cin>>a>>b;
			a--;b--;
			if(m[pii(a,b)])cout<<out-m[pii(a,b)]<<endl;
			else cout<<out-ma<<endl;
		}
	}
};
signed main(){
	int n,m;
	cin>>n>>m;
	KRK krk(n);
	while(m--){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		krk.add_edge(a,b,c);
	}
	krk.solve();
}









Compiler output:
a.cc:23:18: error: declaration does not declare anything [-fpermissive]
   23 | typedef int long long;
      |                  ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

std::string S;
int K;
const std::string INF(100, '9');

std::string bigger(const std::string& a, const std::string& b){
    if(a.size() > b.size()){return a;}
    else if(a.size() < b.size()){return b;}
    return a > b ? a : b;
}

std::string smaller(const std::string& a, const std::string& b){
    if(a.size() < b.size()){return a;}
    else if(a.size() > b.size()){return b;}
    return a < b ? a : b;
}

std::string solve200(){
    int S_size = S.size();
    int unitSize = S_size / K;
    
    std::function<std::string(int,int,std::string)> loop = [&](int position, int n, std::string mx){
        if(position == S_size || n == K){
            if(position == S_size && n == K){
                return mx;
            }

            return INF;
        }

        std::string s1 = loop(position + unitSize, n + 1, bigger(mx, S.substr(position, unitSize))),
        s2 = position + unitSize + 1 > S_size ? INF : loop(position + unitSize + 1, n + 1, bigger(mx, S.substr(position, unitSize + 1)));

        return smaller(s1, s2);
    };

    return loop(0, 0, "");
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> K;
    std::cin >> S;
    
    ++K;

    if(S_size <= 16){
        std::cout << solve200() << std::endl;
        return 0;
    }

    std::cout << "-1" << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:61:8: error: 'S_size' was not declared in this scope; did you mean 'dysize'?
   61 |     if(S_size <= 16){
      |        ^~~~~~
      |        dysize
Language: C++

#include <cassert>
#include <iostream>
#include <string>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef vector<int> VI;

/*
 * Suffix Array.
 * Required Headers: algorithm, cassert, string, vector
 * Verified by: http://arc050.contest.atcoder.jp/submissions/818745
 * Reference: http://mayokoex.hatenablog.com/entry/2016/04/03/145845
 */
struct compare_sa {
  const std::vector<int> &rank;
  int n, k;
  compare_sa(const std::vector<int> &rank, int n, int k) : rank(rank), n(n), k(k) {}
  bool operator () (int i, int j) {
    if (rank[i] != rank[j]) {
      return rank[i] < rank[j];
    }
    int ri = i + k <= n ? rank[i + k] : -1;
    int rj = j + k <= n ? rank[j + k] : -1;
    return ri < rj;
  }
};

std::vector<int> create_sa(const std::string& s) {
  int n = s.length();
  std::vector<int> sa(n + 1, -1);
  std::vector<int> rank(n + 1, -1);
  std::vector<int> tmp(n + 1, -1);
  
  for (int i = 0; i <= n; ++i) {
    sa[i] = i;
    rank[i] = i < n ? s[i] : -1;
  }
  
  for (int k = 1; k <= n; k *= 2) {
    compare_sa cp = compare_sa(rank, n, k);
    std::sort(sa.begin(), sa.begin() + n + 1, cp);
    tmp[sa[0]] = 0;
    for (int i = 1; i <= n; ++i) {
      tmp[sa[i]] = tmp[sa[i - 1]] + (cp(sa[i - 1], sa[i]) ? 1 : 0);
    }
    for (int i = 0; i <= n; ++i) {
      rank[i] = tmp[i];
    }
  }
  return sa;
}

int main(void){
  int k;
  string s;
  cin >> k >> s;
  if (k == 0) {
    cout << s << endl;
    return 0;
  }
  int n = s.length();
  VI sa = create_sa(s);
  VI sa_inv(n + 1);
  REP(i, 0, n + 1) {
    sa_inv[sa[i]] = i;
  }
  VI sat;
  int q = (n + k) / (k + 1);
  int r = q * (k + 1) - n; // 0 <= r <= k
  REP(i, 0, sa.size()) {
    int w = sa[i];
    if (w <= n - q) {
      sat.push_back(w);
    }
  }
  int lo = -1;
  int hi = n - q + 1;
  while (hi - lo > 1) {
    int mid = (hi + lo) / 2;
    // try to divide, so that all the divided strings <= s[sat[mid]..]
    // We want to avoid making more than r strings of length q - 1.
    int rem = r;
    REP(i, 0, k + 1) {
      if (rem < 0) {
	break;
      }
      int idx = i * q - r + rem;
      if (idx >= n - q + 1) {
	break;
      }
      if (sa_inv[idx] > sa_inv[sat[mid]]) {
	rem--;
      }
    }
    if (rem >= 0) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  cout << s.substr(sat[hi], q) << endl;
}


Compiler output:
a.cc: In function 'std::vector<int> create_sa(const std::string&)':
a.cc:44:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   44 |     std::sort(sa.begin(), sa.begin() + n + 1, cp);
      |          ^~~~
      |          qsort
Language: C++

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int K;
char S[100010];
int dp[2010][2010];
const int INF = 1e9 + 7;

int main(){
	scanf("%d" , &K);
	scanf(" %s" , S);
	int n = 0;
	while(S[n] != 0) ++n;
	if(n <= 2){
		if(K == 0){
			printf("%s\n" , s);
		} else if(K == 1){
			printf("%s\n" , s[0] < s[1] ? s[0] : s[1]);
		}
	} else {
		printf("%s\n" , s);
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:41: error: 's' was not declared in this scope
   36 |                         printf("%s\n" , s);
      |                                         ^
a.cc:38:41: error: 's' was not declared in this scope
   38 |                         printf("%s\n" , s[0] < s[1] ? s[0] : s[1]);
      |                                         ^
a.cc:41:33: error: 's' was not declared in this scope
   41 |                 printf("%s\n" , s);
      |                                 ^
Language: C++

#include <stdio.h>
#include <string.h>

int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

char S[5];
int K;

int main(){
scanf("%d",&K);
scanf("%s",&S);
if(K!=0){

if(strlen(S)==2){
if(ctoi(S[0])>=ctoi(S[1])){printf("%d¥n",ctoi(S[0]));}
else{printf("%d¥n",ctoi(S[1]));}
}
else{printf("%d¥n",ctoi(S[0]));}

}
else{printf("%d¥n",atoi(S));}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:20: error: 'atoi' was not declared in this scope; did you mean 'ctoi'?
   35 | else{printf("%d¥n",atoi(S));}
      |                    ^~~~
      |                    ctoi
Language: C++

#include <stdio.h>

int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

char S[5];
int K;

int main(){
scanf("%d",&K);
scanf("%s",&S);
if(K!=0){

if(strlen(S)==2){
if(ctoi(S[0])>=ctoi(S[1])){printf("%d¥n",ctoi(S[0]));}
else{printf("%d¥n",ctoi(S[1]));}
}
else{printf("%d¥n",ctoi(S[0]));}

}
else{printf("%d¥n",atoi(S));}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:4: error: 'strlen' was not declared in this scope
   27 | if(strlen(S)==2){
      |    ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <stdio.h>
  +++ |+#include <cstring>
    2 | 
a.cc:34:20: error: 'atoi' was not declared in this scope; did you mean 'ctoi'?
   34 | else{printf("%d¥n",atoi(S));}
      |                    ^~~~
      |                    ctoi
Language: C++

#include <stdio.h>

int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

char S[5];
int K;

int main(){
scanf("%d",&K)
scanf("%s",&S);
if(K!=0){

if(strlen(S)==2){
if(ctoi(S[0])>=ctoi(S[1])){printf("%d¥n",ctoi(S[0]));}
else{printf("%d¥n",ctoi(S[1]));}
}
else{printf("%d¥n",ctoi(S[0]));}

}
else{printf("%d¥n",atoi(S));}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:15: error: expected ';' before 'scanf'
   23 | scanf("%d",&K)
      |               ^
      |               ;
   24 | scanf("%s",&S);
      | ~~~~~          
a.cc:27:4: error: 'strlen' was not declared in this scope
   27 | if(strlen(S)==2){
      |    ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <stdio.h>
  +++ |+#include <cstring>
    2 | 
a.cc:34:20: error: 'atoi' was not declared in this scope; did you mean 'ctoi'?
   34 | else{printf("%d¥n",atoi(S));}
      |                    ^~~~
      |                    ctoi
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
struct SHIT
{
    int one,two;
    bool operator<(const SHIT  &b)const {
        if(this->one!=b.one) return (this->one<b.one);
        return (this->two<b.two);
    }
}shit[maxn];
bool cmp(SHIT a,SHIT b)
{
    if(a.one+a.two!=b.one+b.two)
        return a.one+a.two<b.one+b.two;
    return a.one<b.one;
}
map<SHIT,bool>mp;
int main()
{
    int n;
    mp.clear();
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&shit[i].one,&shit[i].two);
        mp[shit[i]]=1;
    }
    if(!(shit[1].one==shit[2].two&&shit[1].two==shit[2].one&&shit[1].one==0&&shit[1].two!=0)){
        puts("-1");
        return 0;
    }
    int mn=shit[1].two;
    int ans=2*n-2;
    for(int i=3;i<=n;i++)
    {
        if(shit[i].one==0||shit[i].two==0||shit[i].one+shit[i].two<mn){
            puts("-1");
            return 0;
        }
    }
    sort(shit+1,shit+n+1,cmp);
    for(int i=1,j;i<=n;i=j)
    {
        j=i+1;
        while(j<=n&&shit[j].one+shit[j].two==shit[i].one+shit[i].two)
            j++;
        for(int k=i;k<j;k++)
            mp[shit[k]]=1;
        int last=0,left=0;
        for(int k=i,tk;k<j;k=tk)
        {
            tk=k+1;
            while(tk<j&&shit[tk].one==shit[k].one){
                tk++;
            }
            int now=tk-k;
            bool one=0,two=0;
            SHIT tmp1,tmp2;
            tmp1.one=shit[k].one-1;
            tmp1.two=shit[k].two-1;
            if(mp.count(tmp1)){
                ans-=now;
                now=min(now,left);
                ast=shit[k].one;
                left=now;
                continue;
                one=1;two=1;
            }


            tmp1.one=shit[k].one-1;
            tmp1.two=shit[k].two+1;
            tmp2.one=shit[k].one+1;
            tmp2.two=shit[k].two-1;



            one=one|mp.count(tmp1);
            two=two|mp.count(tmp2);

            tmp1.two--;
            tmp2.one--;
            one=one|mp.count(tmp1);
            two=two|mp.count(tmp2);

            if(shit[k].one==0)one=1;
            if(shit[k].two==0) two=1;
            if(one==0||two==0){
                puts("-1");
                return 0;
            }
            int del=0;
            if(last+1==shit[k].one){
                del=min(now,left);
                ans-=del;
            }
            tmp1.two--;

            last=shit[k].one;
            left=now;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:17: error: 'ast' was not declared in this scope; did you mean 'last'?
   65 |                 ast=shit[k].one;
      |                 ^~~
      |                 last
Language: C++

#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while( ch < '0' || ch > '9' ) { if( ch == '-' ) f = -1; ch = getchar(); }
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

const int MAXN = 100005;

int n, a[MAXN], b[MAXN];
map < pa, bool > cnt;
pa c[MAXN];

inline void GG() { puts( "-1" ); exit( 0 ); }

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	n = read();
	for( int i = 1 ; i <= n ; i++ )
	{
		a[ i ] = read(), b[ i ] = read(), c[ i ] = mp( a[ i ] + b[ i ], b[ i ] );
		if( !a[ i ] && i != 1 ) GG();
		if( !b[ i ] && i != 2 ) GG();
		cnt[ mp( a[ i ], b[ i ] ) ] = 1;
	}
	if( a[ 1 ] || b[ 2 ] ) GG();
	sort( c + 1, c + n + 1 );
	int ret = n - 1 << 1;
	for( int l = 1, r = 1 ; l <= n ; l = r )
	{
		while( r <= n && c[ r ].xx == c[ l ].xx )
		{
			int x = c[ r ].xx - c[ r ].yy, y = c[ r ].yy;
			if( x )
			{
				bool flag = false;
				for( int d = -1 ; d <= 1 ; d++ ) if( cnt.find( mp( x - 1, y + d ) ) != cnt.end() ) flag = true;
				if( !flag ) GG();
			}
			if( y )
			{
				bool flag = false;
				for( int d = -1 ; d <= 1 ; d++ ) if( cnt.find( mp( x + d, y - 1 ) ) != cnt.end() ) flag = true;
				if( !flag ) GG();
			}
			r++;
		}
		for( int i = l, j = l, last = 0, left = 0 ; i < r ; i = j )
		{
			while( j < r && c[ j ].yy == c[ i ].yy ) j++;
			int now = j - i, del = 0;

			if( cnt.find( mp( c[ i ].xx - c[ i ].yy - 1, c[ i ].yy - 1 ) ) != cnt.end() ) ret -= now, last=c[i].yy,left=min(now,left),continue;;
            if( c[ i ].yy == last + 1 ) del = min( now, left ), ret -= del;
			last = c[ i ].yy; left = now;
		}
	}
	return printf( "%d\n", ret ), 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:147: error: expected primary-expression before 'continue'
   69 |                         if( cnt.find( mp( c[ i ].xx - c[ i ].yy - 1, c[ i ].yy - 1 ) ) != cnt.end() ) ret -= now, last=c[i].yy,left=min(now,left),continue;;
      |                                                                                                                                                   ^~~~~~~~
Language: C++

#include <vector>
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int N;
	scanf("%d", &N);
	vector<pair<int, int> > A;
	for(int i=0; i<N; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		A.emplace_back(a, b);
	}
	if(A[0].first!=0 || A[1].second!=0 || A[1].first!=A[0].second) {
		printf("-1\n");
		return 0;
	}
	int ab = A[0].second;
	int sum = ab;
	{
		vector<int> vec(ab+1);
		for(auto & p : A) {
			if(p.first+p.second==ab) {
				++vec[p.first];
			}
			if(p.first+p.second<ab) {
				printf("-1\n");
				return 0;
			}
		}
		if(vec[0]!=1 || vec[ab]!=1) {
			printf("-1\n");
			return 0;
		}
		for(int i : vec) {
			if(i==0) {
				printf("-1\n");
				return 0;
			}
			if(2<=i) {
				sum += (i-1)*2;
			}
		}
	}
	{
		vector<pair<int, int> > vec;
		vector<pair<int, int> > vec2;
		for(auto & p : A) {
			if(ab<p.first+p.second) {
				int aa = p.first+p.second - ab;
				int aaHalf = (aa+1)>>1;
				int aaa = p.first-aaHalf;
				if(aa&1) {
					vec2.emplace_back(p.first-aaHalf, aaHalf);
					++sum;
				}
				else {
					vec.emplace_back(p.first-aaHalf, aaHalf);
					++sum;
				}
			}
		}
		sort(vec.begin(), vec.end());
		sort(vec2.begin(), vec2.end());
		{
			int beforeF = -1;
			int beforeS = 0;
			for(auto & p : vec) {
				if(p.first!=beforeF) {
					beforeF = p.first;
					beforeS = 0;
				}
				if(p.second!=beforeS && p.second!=beforeS+1) {
					printf("-1\n");
					return 0;
				}
				beforeS = p.second;
			}
		}
		{
			int beforeF = -10;
			int beforeS = 0;
			for(auto & p : vec2) {
				if(p.first!=beforeF) {
					if(s.first!=beforeF+1) {
						++sum;
					}
					beforeF = p.first;
					beforeS = 0;
				}
				if(p.second!=beforeS && p.second!=beforeS+1) {
					printf("-1\n");
					return 0;
				}
				beforeS = p.second;
			}
		}
	}
	printf("%d\n", sum);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:88:44: error: 's' was not declared in this scope
   88 |                                         if(s.first!=beforeF+1) {
      |                                            ^
Language: C++

#include <stdio.h>
#include <string.h>
#include <algorithm>

long long int N;
char A[1000000000000];
int f[12], ans = 0;

int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

int main(void) {
	scanf("%lld", &N);
	int cou = 0;
	for (int i = 0; i < N; ++i) {
		scanf("%s", &A);
		for (int j = strlen(A) - 1; j >= 0; --j) {
			f[cou] = std::max(f[cou], ctoi(A[j]));
			++cou;
		}
	}

	for (int i = 0; i < cou; ++i) { ans += f[i]; }
	printf("%d\n", ans);
	return 0;
}

Compiler output:
/tmp/ccjY87ua.o: in function `main':
a.cc:(.text+0x11f): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccjY87ua.o
a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccjY87ua.o
a.cc:(.text+0x190): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccjY87ua.o
a.cc:(.text+0x199): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccjY87ua.o
a.cc:(.text+0x1a1): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccjY87ua.o
a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccjY87ua.o
collect2: error: ld returned 1 exit status
Language: C++

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010],B[101010];
int L;
int did[101010];
int ok[101010];

set<pair<int,int>> S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i]>>B[i];
	
	if(A[0]!=0) return _P("-1\n");
	if(B[1]!=0) return _P("-1\n");
	if(A[1]!=B[0]) return _P("-1\n");
	L=A[1];
	ok[0]=ok[L]=1;
	did[0]=did[1]=1;
	
	S.insert({0,L});
	S.insert({L,0});
	vector<pair<int,int>> V;
	int ret=1;
	for(i=2;i<N;i++) {
		if(A[i]==0 || B[i]==0) return _P("-1\n");
		if(A[i]+B[i]<L) return _P("-1\n");
		if(A[i]+B[i]==L) {
			did[i]=1;
			if(ok[A[i]]==1) ret++;
			ok[A[i]]=1;
			ret++;
			S.insert({A[i],B[i]});
		}
		else {
			V.push_back({A[i]+B[i],i});
		}
	}
	FOR(i,L+1) if(ok[i]==0) return _P("-1\n");
	sort(ALL(V));
	FORR(r,V) {
		x = r.second;
		if(S.count({A[x]-1,B[x]-1})) {
			ret++;
		}
		else if(S.count({A[x]-1,B[x]}) && S.count({A[x],B[x]-1})) {
			ret+=2;
		}
		else {
			return _P("-1\n");
		}
		S.insert({A[x],B[x]});
	}
	aseert(0);
	_P("%d\n",ret);
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:69:9: error: 'aseert' was not declared in this scope; did you mean 'assert'?
   69 |         aseert(0);
      |         ^~~~~~
      |         assert
Language: C++

#include <stdio.h>
#include <string.h>
#include <algorithm>

long long int N;
char A[1000000000000];
int f[12], ans = 0;

int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

int main(void) {
	scanf("%lld", &N);
	int cou = 0;
	for (int i = 0; i < N; ++i) {
		scanf("%s", &A);
		for (int j = strlen(A) - 1; j >= 0; --j) {
			f[cou] = std::max(f[cou], ctoi(A[j]));
			++cou;
		}
	}

	for (int i = 0; i < cou; ++i) { ans += f[i]; }
	printf("%d\n", ans);
	return 0;
}

Compiler output:
/tmp/ccrIzefY.o: in function `main':
a.cc:(.text+0x11f): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccrIzefY.o
a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccrIzefY.o
a.cc:(.text+0x190): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccrIzefY.o
a.cc:(.text+0x199): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccrIzefY.o
a.cc:(.text+0x1a1): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccrIzefY.o
a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccrIzefY.o
collect2: error: ld returned 1 exit status
Language: C++

#include <stdio.h>
#include <string.h>
#include <algorithm>

int N;
char A[1000000000000];
int f[12], ans = 0;

int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

int main(void) {
	scanf("%d", &N);
	int cou = 0;
	for (int i = 0; i < N; ++i) {
		scanf("%s", &A);
		for (int j = strlen(A) - 1; j >= 0; --j) {
			f[cou] = std::max(f[cou], ctoi(A[j]));
			++cou;
		}
	}

	for (int i = 0; i < cou; ++i) { ans += f[i]; }
	printf("%d\n", ans);
	return 0;
}

Compiler output:
/tmp/ccGsxCy7.o: in function `main':
a.cc:(.text+0x11f): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccGsxCy7.o
a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccGsxCy7.o
a.cc:(.text+0x189): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccGsxCy7.o
a.cc:(.text+0x192): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccGsxCy7.o
a.cc:(.text+0x19a): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccGsxCy7.o
a.cc:(.text+0x1ac): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccGsxCy7.o
collect2: error: ld returned 1 exit status
Language: C++

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<string>> s(h, vector<string>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
            if (s[i][j] == "snuke") {
                char r = j + 'A'
                cout << r << i+1 << endl;
                return 0;
            }
        } 
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: expected ',' or ';' before 'cout'
   13 |                 cout << r << i+1 << endl;
      |                 ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll k,t;
cin>>k>>t;
string s;
for(ll i=1; i<=t*k; i++){
cin>>s;
if(s=="snuke"){
if(i%t==0){
char q;
q = 'A' + (int)t-1;}
else{
char q = 'A' + (int)i%t-1;}
cout<<q<<i/t+1<<endl;}}}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:7: error: 'q' was not declared in this scope
   31 | cout<<q<<i/t+1<<endl;}}}
      |       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll k,t;
cin>>k>>t;
string s;
for(ll i=1; i<=t*k; i++){
cin>>s;
if(s=="snuke"){
if(i%t==0){
string q = 'A' + (int)t-1;}
else{
string q = 'A' + (int)i%t-1;}
cout<<q<<i/t+1<<endl;}}}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:24: error: conversion from 'int' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   27 | string q = 'A' + (int)t-1;}
      |            ~~~~~~~~~~~~^~
a.cc:29:26: error: conversion from 'll' {aka 'long long int'} to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   29 | string q = 'A' + (int)i%t-1;}
      |            ~~~~~~~~~~~~~~^~
a.cc:30:7: error: 'q' was not declared in this scope
   30 | cout<<q<<i/t+1<<endl;}}}
      |       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll k,t;
cin>>k>>t;
string s;
for(ll i=1; i<=t*k; i++){
cin>>s;
if(s=="snuke"){
if(i%t==0){
string q = 'A' + t-1;}
else{
string q = 'A' + i%t-1;}
cout<<q<<i/t+1<<endl;}}}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:19: error: conversion from 'll' {aka 'long long int'} to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   27 | string q = 'A' + t-1;}
      |            ~~~~~~~^~
a.cc:29:21: error: conversion from 'll' {aka 'long long int'} to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   29 | string q = 'A' + i%t-1;}
      |            ~~~~~~~~~^~
a.cc:30:7: error: 'q' was not declared in this scope
   30 | cout<<q<<i/t+1<<endl;}}}
      |       ^