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

#include <iostream>

int main()
{
	/*
		ABC131 E問題
		N K
		頂点数NにおけるKの最大値は(N-1)C2
		したがってひとまず maxK = (N-1)(N-2)/2を計算し、Kがそれより大きければ-1を出力
		小さければ M = N-1 + maxK-K を出力。
		1 2
		1 3
		1 4
		.
		.
		.
		1 N
		と出力。
		その後maxK-Kの数だけ
		2 3
		2 4
		.
		.
		2 N
		3 4
		3 5
		.
		.
		3 N
		.
		.
		を出力する。
	*/
	int N, K,maxK;
	cin >> N >> K;

	maxK = (N - 1)*(N - 2) / 2;
	if (K > maxK) {
		cout << -1;
		return 0;
	}

	//Mを出力
	cout << N - 1 + maxK - K << endl;

	//N-1回
	for (int i = 2; i <= N; i++)
		cout << "1 " << i << endl;

	int time = 0;
	//maxK - K 回
	for (int i = 2; i <= N - 1; i++) {
		for (int j = i + 1; j <= N; j++, time++) {
			if (time >= maxK - K)
				break;
			cout << i << " " << j << endl;
		}
		if (time >= maxK - K)
			break;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   35 |         cin >> N >> K;
      |         ^~~
      |         std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:39:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   39 |                 cout << -1;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:44:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   44 |         cout << N - 1 + maxK - K << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:44:37: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   44 |         cout << N - 1 + maxK - K << endl;
      |                                     ^~~~
      |                                     std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

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

int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    int mx = (n-1)*(n-2)/2;
    if (k > mx)
    {
        puts("-1");
        return 0;
    }
    vector<P> ans;
    rep(i, n-1) {
        ans.push_back(P(i+1, n));
    }
    int add = mx - k;
    vector<P> edge;
    rep(i, n-1) {
        for (int j = i+1; j < n-1; j ++)
        {
            ans.push_back(P(i+1, j+1));
        }
    }
    rep(i, add) ans.push_back(edge[i]);
    puts(ans.size());
    rep(i, ans.size()) {
        cout << ans[i].first << " " << ans[i].second << endl;
        
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:30:18: error: invalid conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'const char*' [-fpermissive]
   30 |     puts(ans.size());
      |          ~~~~~~~~^~
      |                  |
      |                  std::vector<std::pair<int, int> >::size_type {aka long unsigned int}
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/stdio.h:714:30: note:   initializing argument 1 of 'int puts(const char*)'
  714 | extern int puts (const char *__s);
      |                  ~~~~~~~~~~~~^~~
Language: C++

#include <iostream>
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  if(k>(n-1)*(n-2)/2){
    cout << -1;
    return 0;
  }
  cout << n-1+(n-1)*(n-2)/2-k;
  for(int i=0; i<n-1 i++){
    cout << i << ' ' << n-1 << endl;
  }
  for(int i=0; i<(n-1)*(n-2)/2-k){
    int s=i/(n-2);
    cout << s << ' ' << (s+(i%(n-2)+1))%(n-2) << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:21: error: expected ';' before 'i'
   12 |   for(int i=0; i<n-1 i++){
      |                     ^~
      |                     ;
a.cc:15:33: error: expected ';' before ')' token
   15 |   for(int i=0; i<(n-1)*(n-2)/2-k){
      |                                 ^
      |                                 ;
Language: Java

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int max = (n-1)*(n-2)/2;
        if((n-1)*(n-2)/2 < k) System.out.println(-1);
        else{
            int m = (n-1) + (max - k);
            StringBuilder sb = new StringBuilder();
            int t = 0;
            for (int i = 2; i <= n; i++) {
                sb.append("1 " + i + "\n");
                t++;
            }
            for (int i = 2; i < n; i++) {
                for (int j = i+1; j <= n; j++) {
                    sb.append(i + " " + j + "\n");
                    t++;
                    if(m <= t) break;
                }
                if(m <= t) break;
            }
            System.out.println(m);
            System.out.print(sb.toString());
        }
        sc.close();

    }

}


Compiler output:
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, K;
    cin >> N >> K;
    if(K > N * (N - 1) / 2) {
        cout << -1 << endl;
        return 0;
    }
    cout << -((N - 1)(N - 2) / 2 - K) + N - 1 << endl;
    REP(i, N - 1) { cout << 0 << " " << i + 1 << endl; }
    long long cnt = 0;
    for(int i = 1; i < (N - 1)(N - 2) / 2 - K; i++) {
        for(int j = i + 1; j <= N - 1; j++) {
            cout << i << " " << j << endl;
            cnt++;
            if(cnt == K) {
                return 0;
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:22: error: expression cannot be used as a function
   39 |     cout << -((N - 1)(N - 2) / 2 - K) + N - 1 << endl;
      |               ~~~~~~~^~~~~~~
a.cc:42:31: error: expression cannot be used as a function
   42 |     for(int i = 1; i < (N - 1)(N - 2) / 2 - K; i++) {
      |                        ~~~~~~~^~~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int mat[101][101];
int main() {
    int N, K;
    cin >> N >> K;
    if(K > N * (N - 1) / 2) {
        cout << -1 << endl;
        return 0;
    }
    cout << N + K - 1 << endl;
    REP(i, N - 1) { cout << 0 << " " << i + 1 << endl; }
    long long cnt = 0;
    REP(i, N - 1) {
        i++;
        for(int j = i + 1, j <= N - 1, j++) {
            cout << i << " " << j << endl;
            cnt++;
            if(cnt == K) {
                return 0;
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:29: error: expected ';' before '<=' token
   45 |         for(int j = i + 1, j <= N - 1, j++) {
      |                             ^~~
      |                             ;
a.cc:45:30: error: expected primary-expression before '<=' token
   45 |         for(int j = i + 1, j <= N - 1, j++) {
      |                              ^~
a.cc:45:43: error: expected ';' before ')' token
   45 |         for(int j = i + 1, j <= N - 1, j++) {
      |                                           ^
      |                                           ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int ,int> P;
int N,K;
signed main(){
  cin >> N >> K;
  int mx=(N-1)*(N-2)/2;
  if(mx<K){
    puts("-1");
    return 0;
  }
  vector<P> ans;
  for(int i=0;i<N-1;i++){
    ans.push_back(P(i+1,N));
  }
  int add=mx-k;
  vector<P> edge;
  for(int i=0;i<N-1;i++){
    for(int j=0;j<i;j++){
      edge.push_back(P(i+1,j+1));
    }
  }
  for(int i=0;i<add;i++) ans.push_back(edge[i]);
  cout << ans.size() << endl;
  for(int i=0;i<ans.size();i++){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:14: error: 'k' was not declared in this scope
   17 |   int add=mx-k;
      |              ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};


int main()
{
    int n,k;cin>>n>>k;
    int s=(n-1)(n-2)/2;
    if(k>s){cout<<-1<<endl;return 0;}
    s-=k;
    cout<<n-1+s<<endl;
    REP(i,n)
    {
        for(int j=i;j<n&&s>0;j++,s--)
        {
            cout<<i+1<<" "<<j+1<<endl;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: expression cannot be used as a function
   13 |     int s=(n-1)(n-2)/2;
      |           ~~~~~^~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,K;cin>>N>>K;
    int cnt = 0;
    vector<pair<int,int> > v;
    for(int i=2;i<=N;++i){
        v.emplace_back(1,i);
    }
    for(int i=2;i<=N;++i)
        for(int j=i+1;j<=N;++j) ++cnt;

    if(K > cnt){
        cout << -1 << '\n'; return 0;
    }

    for(int i=2;i<=cnt-K;++i){
        v.emplace_back(i,i+1);
    }

    cout << v.size() << '\n';
    REP(i,M) cout << v[i].first << " " << v[i].second << '\n';

    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:11: error: 'M' was not declared in this scope
   38 |     REP(i,M) cout << v[i].first << " " << v[i].second << '\n';
      |           ^
a.cc:9:34: note: in definition of macro 'REP'
    9 | #define REP(i,n) for (int i=0;i<(n);++i)
      |                                  ^
Language: C++

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


int32_t main()
{
    int n,k;
    cin >> n >> k;
    
    vector<pair<int,int> >edges;
    vector<pair<int,int> >overall;

    if(k>((n-1)*(n-2)/2)) 
    {
        cout<<-1<<endl;
        return 0;
    }

    for(int i=2;i<=n;++i)
    {
        for(int j=i+1;j<=n;++j)
        {
            overall.push_back({i,j});
        }
    }

    for(int i=2;i<=n;++i)
    {
        edges.push_back({1,i});
    }

    int left = (n-1)*(n-2)/2 - k;

    for(int i=0;i<left;++i)
    {
        edges.push_back(overall[i]);
    }


    cout<<v.size()<<endl;
        for(auto i : v)
        {
            cout<<i.first<<" "<<i.second<<endl;
        }
        return 0;


    return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:41:11: error: 'v' was not declared in this scope
   41 |     cout<<v.size()<<endl;
      |           ^
Language: C++

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main() {
  int N, K; cin >> N >> K;
  vector<vector<int> > G;

  int M = N*(N-1)/2 - K;
  if(N-1 <= M){
    reps(i,N){
      vector<int> l;
      l.push_back(1);
      l.push_back(i);
      G.push_back(l);
    }
    for(i=2; i<=N; i++){
      for(j=i+1; j<=N; j++){
        if(K>0){
          K--;
        }else{
          vector<int> l;
          l.push_back(j);
          l.push_back(i);
          G.push_back(l);
        }
      }
    }
    cout << M << endl;
    rep(i,G.size()){
      cout << G[i][0] << ' ' << G[i][1] << endl;
    }

  }else{
    cout << -1 << endl;
  }



  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:9: error: 'i' was not declared in this scope
   36 |     for(i=2; i<=N; i++){
      |         ^
a.cc:37:11: error: 'j' was not declared in this scope
   37 |       for(j=i+1; j<=N; j++){
      |           ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    ll N, K;
    cin >> N >> K;

    ll M = N * (N - 1) / 2;
    bool edge[N][N];
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            edge[i][j] = true;
        }
    }

    if(K > (N-1)(N-2) / 2){
        cout << -1 << endl;
        return 0;
    }


    ll del = K;
    ll cnt = 0;
    ll flag = true;
    for(ll i = 0; i < N - 1; i++){
        for(ll j = i + 1; j < N - 1; j++){
            if(flag){
                if(edge[i][j] && i != j){
                    edge[i][j] = false;
                    edge[j][i] = false;
                    cnt ++;
                    if(cnt == del) flag = false;
                }
            }
        }
    }

    if(flag){
        cout << -1 << endl;
        return 0;
    }

    cout << M - del << endl;
    for(ll i = 0; i < N; i++){
        for(ll j = i + 1; j < N; j++){
            if(edge[i][j]){
                cout << i+ 1 << " " << j + 1 << endl;
            }
        }
    }





}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:17: error: expression cannot be used as a function
   29 |     if(K > (N-1)(N-2) / 2){
      |            ~~~~~^~~~~
Language: C++

#include <cstdio>
#include <iostream
using namespace std;

int main() {
    int n, k;
    while (cin >> n >> k) {
        int min = 0;
        int max = (n - 1) * (n - 2) / 2;
        if (k < min || k > max) {
            printf("-1\n");
            continue;
        }
        int m = n * (n - 1) / 2 - k;
        int current = k;
        int last = 1;
        int size = 1;
        for (int i = n - 2; i > 0; --i) {
            if (current <= i) {
                last = current;
                break;
            }
            ++size;
            current -= i;
        }
        printf("%d\n", m);
        for (int i = 1; i < n; ++i) {
            if (i > size) {
                for (int j = n; j > i; --j) {
                    printf("%d %d\n", i, j);
                }
            }
            else if (i < size){
                printf("%d %d\n", i, n);
            }
            else {
                for (int j = n, end_j = n -  current; j > end_j; --j) {
                    printf("%d %d\n", i, j);
                }
            }
        }
    }
}

Compiler output:
a.cc:2:19: error: missing terminating > character
    2 | #include <iostream
      |                   ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()

{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif

    int n,k,i,j;
    cin>>n>>k;
    vector<int> v[n+1];
    if(k>(n-1)*(n-2)/2){
    cout<<-1;
    }else{
    int t=(n-1)*(n-2)/2;	
    for(i=2;i<=n;i++){
    	v[1].push_back(i);
    }
    int flag=0,edges=n-1;
    for(i=2;i<=n-1;i++){
     for(j=i+1;j<=n;j++){
     	if(k<t){
     		edges++;
     		t--;
     		v[i].push_back(j);
     	}
     	if(k==t){
     		flag=1;
     		break;
     	}
     }
     if(flag)
     	break;
    }
    cout<<edges<<endl;
    for(i=1;i<=n;i++){
    	for(j=0;j<v[i].size();j++)
    		cout<<i<<" "<<v[i][j]<<endl;
    }
    }  
    }

    return 0;
}

Compiler output:
a.cc:47:5: error: expected unqualified-id before 'return'
   47 |     return 0;
      |     ^~~~~~
a.cc:48:1: error: expected declaration before '}' token
   48 | }
      | ^
Language: C++

#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

int C(int n, int r){
  if(r < 0) return 0;
  int ret = 1;
  for(int i=1;i<=r;i++){
    ret *= n-i+1;
    ret /= i;
  }
  return ret;
}

int main(){
  int n, k;
  cin >> n >> k;
  if(k == 0){
    cout << n * (n - 1) / 2 << endl;
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        cout << i << " " << j << endl;
      }
    }
  }else if(k < n - 2){
    cout << -1 << endl;
  }else if(k > C(n-1, 2)){
    cout << -1 << endl;
  }else{
    cout << n - 1 + C(n-1, 2) - k << endl;
    for(int i=2;i<=n;i++){
      cout << 1 << " " << i << endl;
    }
    int f = C(n-1, 2) - k << endl;
    for(int i=2;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        if(f == 0)break;
        cout << i << " " << j << endl;
      }
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:67:27: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   67 |     int f = C(n-1, 2) - k << endl;
      |             ~~~~~~~~~~~~~~^~~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,k;
  cin>>n>>k;
  int m;
  int cnt=0;
  if(n*(n-1)/2-k<n-1){
    cout<<-1<<endl;
  }else{
    m = n*(n-1)/2-k;
    cout<<m<<endl;
    REP(i,n){
      REP(j,i){
        if(cnt<m){
          cout<<i<<
    
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:104:3: error: expected primary-expression before 'return'
  104 |   return 0;
      |   ^~~~~~
a.cc:105:2: error: expected '}' at end of input
  105 | }
      |  ^
a.cc:100:15: note: to match this '{'
  100 |       REP(j,i){
      |               ^
a.cc:105:2: error: expected '}' at end of input
  105 | }
      |  ^
a.cc:99:13: note: to match this '{'
   99 |     REP(i,n){
      |             ^
a.cc:105:2: error: expected '}' at end of input
  105 | }
      |  ^
a.cc:96:8: note: to match this '{'
   96 |   }else{
      |        ^
a.cc:105:2: error: expected '}' at end of input
  105 | }
      |  ^
a.cc:89:11: note: to match this '{'
   89 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

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

  if (K >= N) {
    cout << -1 << endl
    return 0;
  }

  if (N >= 4) {
    if (K == 0) {
      cout << N*(N-1)/2 << endl;
      for (int i = 1; i <= N-1; i++) {
        for (int j = i+1; j <= N; j++) {
          cout << i << " " << j << endl;
        }
      }
    } else if (K == N-1) {
      cout << N-1 << endl;
      for (int i = 1; i <= N-1; i++) {
        cout << i << " " << i+1 << endl;
      }
    } else {
      cout << N*(N-1)/2-1 << endl;
      cnt = K;
      for (int i = 1; i <= N-1; i++) {
        for (int j = i+1; j <= N; j++) {
          if (i == 1 && j > 2 && cnt > 0) {
            cnt--;
            continue;
          }
          cout << i << " " << j << endl;
        }
      }
    }
  }

  if (N == 3) {
    if (K == 0) {
      cout << 3 << endl;
      cout << 1 << " " << 2 << endl;
      cout << 1 << " " << 3 << endl;
      cout << 2 << " " << 3 << endl;
    } else if (K == 1) {
      cout << 2 << endl;
      cout << 1 << " " << 2 << endl;
      cout << 2 << " " << 3 << endl;
    } else {
      cout << -1 << endl;
  }

  if (N == 2) {
    if (K == 0) {
      cout << 1 << endl;
      cout << 1 << " " << 2 << endl;
    } else {
      cout << -1 << endl;
    }
  }
      

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:23: error: expected ';' before 'return'
   12 |     cout << -1 << endl
      |                       ^
      |                       ;
   13 |     return 0;
      |     ~~~~~~             
a.cc:31:7: error: 'cnt' was not declared in this scope; did you mean 'int'?
   31 |       cnt = K;
      |       ^~~
      |       int
a.cc:69:2: error: expected '}' at end of input
   69 | }
      |  ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;
int main() {
	int n,k;
	cin>>n>>k;
	if(k>n||n==3)
	cout<<-1<<endl;
	else if(k==n-1||k=n)
	{
	    cout<<k+1<<endl;
	    if(k==n-1)
	    {
	        for(int i=1;i<n-1;i++)
	        cout<<i<<" "<<i+1<<endl;
	        cout<<2<<" "<<n<<endl;
	        cout<<3<<" "<<n<<endl;
	    }
	    else
	    {
	        for(int i=1;i<n-2;i++)
	        cout<<i<<" "<<i+1<<endl;
	        cout<<2<<" "<<n-1<<endl;
	        cout<<3<<" "<<n-1<<endl;
	        cout<<4<<" "<<n<<endl;
	        cout<<5<<" "<<n<<endl;
	    }
	}
	else
	{
	    int s=k+1;
	    for(int i=k+3;i<=n;i++)
	    s+=(i-1);
	    cout<<s<<endl;
	    for(int i=1;i<=n;i++){
	   if(i<=k+1)
	    cout<<i<<" "<<i+1<<endl;
	    else if(i!=k+2)
	    {
	        for(int j=1;j<i;j++)
	        cout<<i<<" "<<j<<endl;
	    }}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:23: error: lvalue required as left operand of assignment
    9 |         else if(k==n-1||k=n)
      |                 ~~~~~~^~~
Language: C++

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=1<<31-1=2147483647
constexpr ll INF = (ll)1e18;//1<<63-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 100;

ll N, K;

void input() {
	scanf("%lld%lld", &N, &K);
}

void solve() {
	if(K > (N-1)*(N-2)/2){
		p(-1);return;
	}

	if(N==2){
		p(-1);return;
	}
	if(N==3){
		if(K==1){
			p(2);
			p("1 2");
			p("2 3");
		}else if(K==0){
			p(3);
			p("1 2")
			p("1 3");
			p("2 3");
		}else
			p(-1);return;
	}

	vector<ll> a(10000+(N)*(N-1)/2,0),b(10000+(N)*(N-1)/2,0);
	ll index=0;
	for(ll i=2;i<=N;i++){
		a[index]=1;
		b[index]=i;
		index++;
	}

	ll count=(N-1)*(N-2)/2;
	ll anum=2;
	ll bnum=3;
	while(1){
		a[index]=anum;
		b[index]=bnum;
		index++;
		count--;
		if(count==K)break;
		bnum++;
		if(bnum>N){
			anum++;
			bnum=anum+1;
		}
	}

	p(index);
	rep(i,index){
		cout<<a[i]<<" "<<b[i]<<endl;
	}


}

signed main() {
	input();
	solve();
	return 0;
}


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

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

int main(){
  int n,k;
  cin >> n >> k;

  set<pair<int,int>> st;

  if(k>n-2){
    cout << -1 << endl;
    return 0;
  }

  for (int i = 1; i < n; i++)
  {
    st.emplace(i,i+1);
  }

  for (int i = 1; i <= k; i++)
  {
    for (int j = i+1; j < n; j++)
    {
      st.emplace(i,j)
    }
  }

  for (int i = k+1; i < n; i++)
  {
    for (int j = i+1; j < n; j++)
    {
      st.emplace(i,j)
    }
  }
  
  cout << st.size() << endl;
  for(auto bbb:st){
    cout << bbb.first << " " << bbb.second << endl;
  }

  
  

  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:22: error: expected ';' before '}' token
   24 |       st.emplace(i,j)
      |                      ^
      |                      ;
   25 |     }
      |     ~                 
a.cc:32:22: error: expected ';' before '}' token
   32 |       st.emplace(i,j)
      |                      ^
      |                      ;
   33 |     }
      |     ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int INF = 1e9;
const int MOD = INF+7;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
using P = pair<int,int>;

signed main(){
	int N,K;
	cin >> N >> K;
	if(K > N-2){
		cout << -1 << endl;
		return 0;
	}
	vector<P> edge;
	vector<unordered_set<int>> edges(N+1);
	for(int i=1;i<N;i++){
		edge.push_back({i,i+1});
		edges[i].insert(i+1);
		edges[i+1].insert(i);
	}
	edge.push_back({N,1});
	edges[N].insert(1);
	edges[1].insert(N);
	edge.push_back({N-1, 1});
	edges[N-1].insert(1);
	edges[1].insert(N-1);
	int k = N-2;
	int i = 1;
	while(K < k){
		for(int j=i+2;j<min(i+2+N-3,N);j++){
			if(edges[i].count(j))continue;
			edge.push_back({i,j);
		}
		i++;
		k--;
	}
	cout << edge.size() << endl;
	for(auto& p : edge){
		cout << p.first << " " << p.second <<endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:44: error: expected '}' before ')' token
   40 |                         edge.push_back({i,j);
      |                                        ~   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k;
	cin>>n>>k;
	if(k>((n-1)*(n-2))/2)
	{
		cout<<-1;
		return 0;
	}
	cout<<(n*(n-1))/2-k;
	for(i=2;i<=n;i++)
	{
		cout<<1<<" "<<i<<endl;
	}
	for(i=2;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			if(k>0)
			{
				k--;
			}
			else
			{
				cout<<i<<" "<<j<<endl;
			}
		}
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:13: error: 'i' was not declared in this scope
   20 |         for(i=2;i<=n;i++)
      |             ^
a.cc:24:13: error: 'i' was not declared in this scope
   24 |         for(i=2;i<=n;i++)
      |             ^
a.cc:26:21: error: 'j' was not declared in this scope
   26 |                 for(j=i+1;j<=n;j++)
      |                     ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()

{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif

    int n,k,i,j;
    cin>>n>>k;
    vector<int> v[n+1];
    if(n==2)cout<<-1;
    else{
    if(k>(n-1)*(n-2)/2){
    cout<<-1;
    }else{
    cout<<t<<endl;
    for(i=2;i<=n;i++){
    	v[1].push_back(i);
    }
    int flag=0,edges=n-1;;
    for(i=2;i<=n-1;i++){
     for(j=i+1;j<=n;j++){
     	if(k<t){
     		edges++;
     		t--;
     		v[i].push_back(j);
     	}else if(k==t){
     		flag=1;
     		break;
     	}
     }
     if(flag)
     	break;
    }
    cout<<edges<<endl;
    for(i=1;i<=n;i++){
    	for(j=0;j<v[i].size();j++)
    		cout<<i<<" "<<v[i][j]<<endl;
    }  
    


    }


    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:11: error: 't' was not declared in this scope
   21 |     cout<<t<<endl;
      |           ^
Language: C++

#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair

using namespace std;

int dp[10100][105];

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	dp[0][0] = 1;
	for (int i = 1; i < 100; ++i) {
		int val = i * (i + 1) / 2;
		int tag = i + 1;
		for (int j = val; j < 10100; ++j) {
			for (int k = i; k < 105; ++k) {
				if (!dp[j][k] && dp[j - val][k - i]) {
					dp[j][k] = tag;
				}
			}
		}
	}
	int n; cin >> n;
	int k; cin >> k;
	if (dp[k][n - 2]) {
		int N = n - 2;
		std::vector<int> v;
		while (dp[k][N] != 1) {
			int y = dp[k][N];
			v.pb(y);
			k -= (y * (y - 1)) / 2;
			N -= (y - 1);
		}
		cout << n - 1 << "\n";
		int las = n;
		print(v);
		for (int i = 0; i < v.size(); ++i) {
			cout << i + 1 << " " << i + 2 << "\n";
			v[i]--;
			if (i + 1 < v.size()) v[i + 1]--; 
			for (int j = 0; j < v[i]; ++j)
				cout << i + 1 << " " << las-- << "\n";
		}
	} else {
		cout << -1;
	}
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:37:17: error: 'print' was not declared in this scope; did you mean 'rint'?
   37 |                 print(v);
      |                 ^~~~~
      |                 rint
Language: C++

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),k=in();
    if(k>(n-1)*(n-2)/2){
        cout<<-1<<endl;
        return 0;
    }
        int m=n*(n-1)/2-k;
        cout<<m<<endl;
        rep(i,n-1){
            cout<<1<<" "<<i+2<<endl;
        }
        int cnt=n-1;
        bool flag = true;
        for(int i=2;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                if(cnt==m){
                    flag = false;
                    break;
                }
                cout<<i<<" "<<j<<endl;
                cnt++;
            }
            if(!flag)break;
        }
    }
}

Compiler output:
a.cc:60:1: error: expected declaration before '}' token
   60 | }
      | ^
Language: C++

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

int main(){
    int n, k, i, j, k;
    cin >> n >> k;
    if((n-2)*(n-1)/2 > k){
        cout << -1;
    }else{
        cout << (n-1)*(n-2)/2 + ((n-2)*(n-1)/2 - k) << '\n';
        for(i=2; i<=n; i++){
            cout << 1 << ' ' << i << '\n';
        }
        i = (n-2)*(n-1)/2 - k;
        j = 2;
        k = 3;
        while(i > 0){
            cout << j << ' ' << k << '\n';
            i--;
            k++;
            if(k > n){
                j++;
                k = j+1;
            }
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:21: error: redeclaration of 'int k'
    5 |     int n, k, i, j, k;
      |                     ^
a.cc:5:12: note: 'int k' previously declared here
    5 |     int n, k, i, j, k;
      |            ^
Language: C++

#include <Bits/stdc++.h>
#define LL long long
using namespace std;
LL A,B,c,d;
LL sum;

LL gcd(LL A,LL B)
{
   return B==0?A:gcd(B,A%B);
}
int main()
{
    scanf("%lld%lld%lld%lld",&A,&B,&c,&d);
    LL t=c/gcd(c,d)*d;
    LL x=(A-1)/c;
    LL y=(A-1)/d;
    LL z=(A-1)/t;
    LL x2=B/c;
    LL y2=B/d;
    LL z2=B/t;
    LL ans=B-(x2+y2-z2)-(A-1-(x+y-z));
    printf("%lld\n",ans);
    return 0;
}


Compiler output:
a.cc:1:10: fatal error: Bits/stdc++.h: No such file or directory
    1 | #include <Bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define forx(i,j,n) for(int i=j;i<n;i++)
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false)
#define testcase int t; cin>>t
#define inputi(xx) scanf("%d",&xx)
#define inputll(xx) scanf("%lld",&xx)
#define printi(xx) printf("%d",xx)
#define printll(xx) printf("%d",xx)

ll fun(ll a,ll b,ll c){
    ll ans=0;
    ans+=b/c;
    ans-=a/c;
    if(a%c==0) ans++;
    return ans;
}

int main() {
    ll n,k;
    cin>>n>>k;
    if(k>n) cout<<"-1";
    if(k==n||k==n-1){
        cout<<n<<endl;
        forx(i,1,n-1) printf("%lld %lld\n",i,i+1);
        if(k==n) cout<<n-1<<" "<<n<<endl<<n<<" 1"<<endl;
        if(k==n-1) cout<<"2 "<<n
    if(k<n-1){
        cout<<(k+1)+((n-k-2)*(k+2))<<endl;
        forx(i,1,k+2) printf("%lld %lld\n",i,i+1);
        forx(i,k+2,n) forx(j,1,k+3+i) printf("%lld %lld\n",i,j);
    }
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:33: error: expected ';' before 'if'
   42 |         if(k==n-1) cout<<"2 "<<n
      |                                 ^
      |                                 ;
   43 |     if(k<n-1){
      |     ~~                           
a.cc:49:2: error: expected '}' at end of input
   49 | }
      |  ^
a.cc:34:12: note: to match this '{'
   34 | int main() {
      |            ^
Language: C++



#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;
vector<ll> x[210005];
vector<ll> used(210005,0);
vector<ll> c(2);


void dfs(ll t){
  //used[n][t]=1;
  if (t>=100005)c[0]++;
  if (t<100005)c[1]++;
  used[t]=1;
  for(ll to:x[t]){
    if (used[to])continue;
    dfs(to);
  }
}


int main() {
  ll N;
  cin >> N;
//  vector<P> v(N);


  rep(i,N){
    ll a1,b1;
    cin>>a1>>b1;
    a1--;b1+=100005;
  //  v[i]=make_pair(a1,b1);
    x[a1].push_back(b1);
    x[b1].push_back(a1);
  }
ll ans=0;
  rep(i,N){

    dfs(v[i].first);
    c[0]=0;c[1]=0;
  //  cout<<"i"<<i<<cx<<" "<<cy<<endl;
    ans+=c[0]*c[1];
  }

  ans-=N;
  cout<<ans;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:9: error: 'v' was not declared in this scope
   43 |     dfs(v[i].first);
      |         ^
Language: C++

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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}

int main(){
	IO();
	set<int> row, col;
	LL n;
	cin>>n;
	int a,b;
	rep(i,0,n){
		cin>>a>>b;
		row.insert(a);
		col.insert(b);
	}
	LL t = (LL)SZ(row) * (LL) SZ(col);
	t -= n;
	t = max(0, t);
	cout<<t;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:16: error: no matching function for call to 'max(int, LL&)'
   46 |         t = max(0, t);
      |             ~~~^~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:46:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'LL' {aka 'long long int'})
   46 |         t = max(0, t);
      |             ~~~^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:46:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   46 |         t = max(0, t);
      |             ~~~^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
void solve(std::istream &in, std::ostream &out);
 
int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}
 
struct DSU {
  int n;
  vector<int> par, sz;
  vector<pair<int, int>> vx;
  int64_t ret = 0;
 
  DSU() = default;
 
  DSU(int n) : n(n) {
    par.resize(2 * n);
    iota(par.begin(), par.end(), 0);
    sz.assign(2 * n, 1);
    vx.resize(2 * n);
    for (int i = 0; i < n; ++i) {
      vx[i] = make_pair(1, 0);
    }
    for (int i = n; i < 2 * n; ++i) {
      vx[i] = make_pair(0, 1);
    }
  }
 
  int get(int x) {
    return x == par[x] ? x : get(par[x]);
  }
 
  int64_t calc(pair<int, int> p) {
    return (int64_t) p.first * p.second;
  }
 
  void unite(int x, int y) { // union-by-rank
    x = get(x), y = get(y);
    if (x == y) {
      hist.emplace_back(-1, -1);
      return;
    }
    if (sz[x] < sz[y]) swap(x, y);
    sz[x] += sz[y];
    par[y] = x;
    ret -= calc(vx[x]);
    ret -= calc(vx[y]);
    vx[x].first += vx[y].first;
    vx[x].second += vx[y].second;
    ret += calc(vx[x]);
  }
};

void solve(std::istream &in, std::ostream &out) {
  int n;
  uf = DSU(1 << 19);
  for (int i = 0, x, y; i < n; ++i) {
    in >> x >> y;
    uf.unite(x, y);
  }
  out << uf.ret << '\n';
}
 

Compiler output:
a.cc: In member function 'void DSU::unite(int, int)':
a.cc:51:7: error: 'hist' was not declared in this scope
   51 |       hist.emplace_back(-1, -1);
      |       ^~~~
a.cc: In function 'void solve(std::istream&, std::ostream&)':
a.cc:67:3: error: 'uf' was not declared in this scope
   67 |   uf = DSU(1 << 19);
      |   ^~
Language: C++

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

#define ll long long
#define pb push_back

const int maxn = 1e5 + 20;

vector<int> adj[2 * maxn];

int ta , tb;

bool visited[maxn * 2];

void dfs(int v)
{
	if(v < maxn)
		ta++;
	else
		tb++;
	visited[v] = 1;

	for(auto u : adj[v])
		if(!visited[u])
			dfs(u);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	for(int i = 0; i < n; i++)
	{
		int x , y;
		cin >> x >> y;
		y += maxn;

		adj[x].pb(y);
		adj[y].pb(x);
	}

	for(int i = 0; i < 2 * maxn; i++)
		if(!visited[i])
		{
			ta = tb = 0;
			dfs(i);
			res += 1LL * ta * tb;
		}

	cout << res << endl;
}










 


Compiler output:
a.cc: In function 'int main()':
a.cc:52:25: error: 'res' was not declared in this scope
   52 |                         res += 1LL * ta * tb;
      |                         ^~~
a.cc:55:17: error: 'res' was not declared in this scope
   55 |         cout << res << endl;
      |                 ^~~
Language: C++

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


int N;
ll cnt, cntx, cnty;
vector<bool> used(2e5, 0);
vector<vector<int> > G(1e5 * 2 + 10);

void dfs(int& idx, int& par){
    used[idx] = true;
    if(idx < 1e5) cntx++;
    else cnty++;
    for(auto& to: G[idx]){
        if(to == par) continue;
        cnt++;
        if(used[to]) continue;
        dfs(to, idx);
    }
}

int main(){
    cin >> N;
    rep(i, 0, N){
        int x, y; cin >> x >> y; x--, y--;
        G[x].push_back(y + 1e5);
        G[y + 1e5].push_back(x);
    }
    ll ans = 0;
    rep(i, 0, 1e5) if(!used[i]){
        cnt = cnty = cntx = 0;
        dfs(i, -1);
        if(cntx > 1 && cnty > 1){
            ans += cntx * cnty - cnt;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:16: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   34 |         dfs(i, -1);
      |                ^~
a.cc:12:25: note:   initializing argument 2 of 'void dfs(int&, int&)'
   12 | void dfs(int& idx, int& par){
      |                    ~~~~~^~~
Language: C++

#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define maxn 100005
using namespace std;
typedef long long ff;
int fo[2*maxn+5];
int kx[2*maxn+5],ty[2*maxn+5];

int fin(int x)
{
       if(fo[x]==x)
       return x;
       else
       return fo[x]=fin(fo[x]);

}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<2*maxn;i++)
    {fo[i]=i;
    ty[i]=0;
    kx[i]=0;
    }
    long long ans=0;
    int x,y;
    for(int i=0;i<n;i++)
    {
       scanf("%d %d",&x,&y);
       fo[fin(x)]=fin(y+maxn);
     //  printf("%d\n",fo[fin(x)]);
      // fo[find(y+maxn)]=y;
    }
     for(int i=1;i<maxn;i++)
     kx[fin(i)]++;
     for(int i=maxn;i<maxn*2;i++)
     ty[fin(i)]++;

     for(int i=1;i<=2*maxn;i++)
     {

     ans+=kx[i]*ty[i];
     if(kx[i]*ty[i]!=0)
     //printf("%d %d\n",i,kx[i]*ty[i]);
     }
     printf("%lld",ans-n);

}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:6: error: expected primary-expression before '}' token
   55 |      }
      |      ^