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

#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD =  1000000007;
const int INF = 1e11;
using Graph = vector<vector<int>>;

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

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

  vector<pair<int, int>> ans;
  for( int i = 2; i <= N; i++ ) ans.push_back({1, i});

  int one = 2; int two = 3;
  for( int i = 0; i < K-(N-1)*(N-2)/2; i++ ){
    ans.push_back({one, two});
    two++;
    if( two > N ){
      one++;
      two = one+1;
    }
  }

  cout << ans.size() << endl;
  for( int i = 0; i < min(K, ans.size()); i++ ) cout << ans[i].first << " " << ans[i].second << "\n";

}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:26: error: no matching function for call to 'min(long long int&, std::vector<std::pair<long long int, long long int> >::size_type)'
   32 |   for( int i = 0; i < min(K, ans.size()); i++ ) cout << ans[i].first << " " << ans[i].second << "\n";
      |                       ~~~^~~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:32:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'})
   32 |   for( int i = 0; i < min(K, ans.size()); i++ ) cout << ans[i].first << " " << ans[i].second << "\n";
      |                       ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:32:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |   for( int i = 0; i < min(K, ans.size()); i++ ) cout << ans[i].first << " " << ans[i].second << "\n";
      |                       ~~~^~~~~~~~~~~~~~~
Language: C++

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

int main(){
  int n, k; cin >> n >> k;
  int mx = 0;
  for(int i = 3; i <= n; i++){
    mx += i - 2;
  }
  if(k > mx){
    cout << -1 << endl;
    return 0;
  }
  vector<P> ans;
  for(int i = 2; i <= n; i++){
    ans.push_back(make_pair(1, i));
  }
  int cnt = 0;
  bool brk = false;
  for(int i = 2; i <= n; i++){
    for(int j = i + 1; j <= n; j++){
      if(cnt == mx - k){
        brk = true;
        break;
      }
      ans.push_back(make_pair(i, j));
      cnt++;
    }
    if(brk) break;
  }

  cout << ans[i].size() << endl;
  rep(i, ans.size()){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:15: error: 'i' was not declared in this scope
   36 |   cout << ans[i].size() << endl;
      |               ^
Language: C++

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

int main(){
  int N,K;
  cin>>N>>K;
  if(!(0<=K && K<=(n-2)*(n-1)/2)){
    cout<<-1<<endl;
    return 0;
  }
  
  
  return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:8:20: error: 'n' was not declared in this scope
    8 |   if(!(0<=K && K<=(n-2)*(n-1)/2)){
      |                    ^
Language: C++

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

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



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

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


int main() {
  long N,K;
  cin>>N>>K;
  if(K>(N-1)*(N-2)/2){
    cout<<-1<<endl;
  }
  cout<<N-1+(N-1)*(N-2)/2-K<<endl;

  vector<vector<long>> a(N+1,vector<long>(N+1));
  for(int i=0;i<=N;i++)  a[i][i]=1;
  for(int i=0;i<N-1;i++){
    cout<<1<<" "<<i+2<<endl;
    a[1][i+2]=1;
    a[i+2][1]=1;
  }
  
  int i=0;
  while(i<(N-1)*(N-2)/2-K){
    int j=rand()%N+1;
    int k=rand()%N+1;
    if(a[i][j]==0){
      k++;
      a[i][j]=1,a[j][i]=1;
      cout<<min(i,j)<<" "<<max(i,j)<<endl;
    }
  }

  return 0;
}




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

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



Compiler output:
a.cc:42:5: error: redefinition of 'int main()'
   42 | int main(){
      |     ^~~~
a.cc:5:5: note: 'int main()' previously defined here
    5 | int main() {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:56:2: error: expected '}' at end of input
   56 | }
      |  ^
a.cc:42:11: note: to match this '{'
   42 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}



int main(){
	int n,k;
	cin>>n>>k;
	
	int hoge=(n-1)*(n-2)/2;
	if(k>hoge){
		cout<<-1<<endl;
		return 0;
	}
	
	int m=n-1+hoge-k;
	cout<<m<<endl;
	
	for(int i=2;i<=n;++i) cout<<1<<' '<<i<<endl;
	
	int cnt=0;
	int u=2;
	while(cnt<hoge-k){
		for(int v=u+1;v<=n;++v){
			cout<<u<<' '<<v<<endl;
			if(++cnt>=hoge-k) return;
		}
		u++;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:43: error: return-statement with no value, in function returning 'int' [-fpermissive]
   38 |                         if(++cnt>=hoge-k) return;
      |                                           ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int mx = (N - 1) * (N - 2) / 2;
  if (K > mx) return cout << -1 << "\n", 0;
  int cnt = mx - K;
  cout << N - 1 + cnt << "\n";
  for (int i = 2; i <= N; i++) cout << 1 << " " << i << "\n";
  for (int i = 2; i < N; i++) {
    for (int j = i + 1; j <= N; j++, cnt--) {
      if (cnt > 0) cout << i << " " << j << "\n";
    }
  }

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


#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, K;
    cin >> N >> K;

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

    if (K > k || K < N - 2) {
        print(-1);
        return 0;
    }

    vector<pair<int, int>> ans;
    REP(i, N - 1) {
        ans.eb(1, i + 2);
    }

    int i = 2, j = 3;
    while(k > K && i < N + 1 && j < N + 1) {
        if (i == j) {
            if (j == N) {
                i++; j = i + 1;
            } else {
                j++;
            }
        }

        ans.eb(i, j);
        k--;

        if (j == N) {
            i++; j = i + 1;
        } else {
            j++;
        }
    }
    
    if (k != K) {
        preint(-1);
        return 0;
    }

    print(ans.size());
    for(auto &e: ans) {
        cout << e.fi << " " << e.se << endl;
    }

}


Compiler output:
a.cc: In function 'int main()':
a.cc:91:9: error: 'preint' was not declared in this scope; did you mean 'print'?
   91 |         preint(-1);
      |         ^~~~~~
      |         print
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,K; cin>>n>>K;
	if(K>n-2){ cout<<-1<<'\n'; return 0; }
	
	vii edges;
	forn(i,0,K) edges.pb({i,i+1});
	forn(i,K,n) forn(j,i+1,n) edges.pb({i,j});
	
	cout<<edges.size()<<'\n';
	for(tmp: edges) cout<<tmp.F+1<<" "<<tmp.S+1<<'\n';
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:16: error: found ':' in nested-name-specifier, expected '::'
   44 |         for(tmp: edges) cout<<tmp.F+1<<" "<<tmp.S+1<<'\n';
      |                ^
      |                ::
a.cc:44:13: error: 'tmp' has not been declared
   44 |         for(tmp: edges) cout<<tmp.F+1<<" "<<tmp.S+1<<'\n';
      |             ^~~
a.cc:46:9: error: expected primary-expression before 'return'
   46 |         return 0;
      |         ^~~~~~
a.cc:44:59: error: expected ';' before 'return'
   44 |         for(tmp: edges) cout<<tmp.F+1<<" "<<tmp.S+1<<'\n';
      |                                                           ^
      |                                                           ;
   45 | 
   46 |         return 0;
      |         ~~~~~~                                             
a.cc:46:9: error: expected primary-expression before 'return'
   46 |         return 0;
      |         ^~~~~~
a.cc:44:59: error: expected ')' before 'return'
   44 |         for(tmp: edges) cout<<tmp.F+1<<" "<<tmp.S+1<<'\n';
      |            ~                                              ^
      |                                                           )
   45 | 
   46 |         return 0;
      |         ~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,k;
  cin >> n >> k;
  if(k>(n-2)*(n-1)/2){
    cout << -1 << endl;
    return 0;
  }
  //vector<vector<int>> v(n,vector<int>(n,0));
  Graph v(n);
  rep(i,n-1){
    v[0].push_back(i+1);
  }
  int left=1;
  int right=2;
  cout << n-1+(n-2)*(n-1)/2-k << endl;
  while(k!=(n-2)*(n-1)/2){
    k++;
    v[left].push_back(right);
    if(right<n-1)right++;
    else{
      left++;
      right=left+1;
    }
  }
  rep(i,n){
    for(int h: y[i]){
      cout << i+1 << " " << h+1 << endl;
    }
  }
}   


Compiler output:
a.cc: In function 'int main()':
a.cc:35:16: error: 'y' was not declared in this scope
   35 |     for(int h: y[i]){
      |                ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n, k;
	cin >> n >> k;
	int mx = (n-1)*(n-2)/2;
	if (mx < k) {
		puts("-1");
		return 0;
	}

	vector<P> ans;
	rep(i,n-1){
		//nを真ん中にする
		ans.push_back({i+1,n});
	}
	int add = mx-k;
	// 辺の候補を列挙しとく
	vector<P> edge;
	rep(i,n-1) rep(j,i) {
		edge.push_back({i+1,j+1});
	}

	rep(i,add) ans.push_back(edge[i]);

	cout << ans.size() << endl;
	rep(i,ans.size()){
		cout << ans[i].first << " " << ans[i].second << endl:
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:69: error: expected ';' before ':' token
   41 |                 cout << ans[i].first << " " << ans[i].second << endl:
      |                                                                     ^
      |                                                                     ;
Language: C++

#include <iostream>

int main(){
 cout << "3\n1 2\n1 3\n1 4" << endl; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:2: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    4 |  cout << "3\n1 2\n1 3\n1 4" << endl;
      |  ^~~~
      |  std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:4:32: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    4 |  cout << "3\n1 2\n1 3\n1 4" << 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 int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

using Graph = vector<vector<int>>;

int modpow(int x, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) {  // nが奇数のとき
            res *= x;
            res %= mod;
        }
        x *= x;
        x %= mod;
        n >>= 1;
    }
    return res;
}

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

	int N, K;
	cin >> N >> K;
	int hen;
	if(N % 2 == 1){
		hen = (N/2) * (N/2);
	}
	else{
		hen = N/2 * (N/2-1);
	}

	if(K <= N-2){
		cout << N-1 << endl;
		for(int i=1;i<=K+1;i++){
			cout << i << " " << i+1 << endl;
		}
		for(int i=K+3;i<=N;i++){
			cout << 1 << " " << i << endl;
		}
	}
	else if(K <= (N-1)(N-2)/2){
		cout << K+1 << endl;
		int cnt = 0;
		for(int i=1;i<N;i++){
			cout << i << " " << i+1 << endl;
			cnt++;
		}
		int dx = 3;
		while(true){
			for(int i=1;i+dx<=N-1;i++){
				cout << i << " " << i+dx << endl;
				cnt++;
				if(cnt == K+1) return 0;
			}
			dx += 2;
		}

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

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

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) {
 if (a < b) { a = b; return true; } return false; 
 }
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  ll m;
  if(k>(n-1)*(n-2)/2){
    COUT(-1);
    return 0;
  }
  ll m=n-1;
  ll no=(n-1)*(n-2)/2-k;
  COUT(m+no);
  ll cu=1;
  ll kk=cu+1;
  rep(i,m+no){
    if(i<m){
      cout<<0<<" "<<i<<endl;
    }
    else{
      cout<<cu<<" "<<kk<<endl;
      kk++;
      if(kk==n){
        cu++;
        kk=cu+1;
      }
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:6: error: redeclaration of 'long long int m'
   57 |   ll m=n-1;
      |      ^
a.cc:52:6: note: 'long long int m' previously declared here
   52 |   ll m;
      |      ^
Language: C++

#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl '\n'

int main() {

    fast
    int n;cin>>n;
    int k;cin>>k;
    // if(k>n-2){
    //     cout<<-1;return 0;
    // }
    int t=(n-2)*(n-1);
	t/=2;
	if(k > t){
		cout<<-1<<endl;return 0;
	}
    vector<int> adj[n+1];
    adj[1].push_back(2);
    adj[2].push_back(1);
    for(int i=3; i<=n; ++i){
        adj[2].push_back(i);
        adj[i].push_back(2);
    }
    for(int i=3; i<n; ++i){
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }
    int temp=n;
    int t=k-3;
    while(t--){
        
        adj[temp].push_back(1);
        adj[1].push_back(temp);
        temp--;
    }
    int visi[n+1]={0};
    for(int i=1;i<n; ++i){
        visi[i]=1;
        for(int j=0; j<adj[i].size(); j++){
            if(visi[adj[i][j]]==0){
                cout<<i<<" "<<adj[i][j]<<endl;
            }
        }
    }


#ifndef ONLINE_JUDGE
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: redeclaration of 'int t'
   34 |     int t=k-3;
      |         ^
a.cc:17:9: note: 'int t' previously declared here
   17 |     int t=(n-2)*(n-1);
      |         ^
Language: C++

#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int N,K;

void solve(Int rest) {
    vector<pair<int,int> > uv;
    Int M = 0;

    for(int j = 2;j <= N;j++) {
        M++;
        uv.push_back(make_pair(1,j));
    }

    M += rest;
    Int put = rest;
    for(int i = 2;i <= N;i++) {
        bool flag = false;
        for(int j = i+1;j <= N;j++) {
            uv.push_back(make_pair(i,j));
            put--;
            if(put == 0)
            {
                flag = true;
                break;
            }
        }

        if(flag == true)
            break;
    }

    cout<<M<<endl;
    for(int i = 0;i < uv.size();i++) {
        cout<<uv[i].first<<" "<<uv[i].second<<endl;
    }

    return;
}

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

    if(K > (((N-1)*(N-2))/2) {
        cout<<-1<<endl;

        return 0;
    }

    Int rest = ((N-1)*(N-2))/2-K;
    solve(rest);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:29: error: expected ';' before '{' token
   65 |     if(K > (((N-1)*(N-2))/2) {
      |                             ^~
      |                             ;
a.cc:71:33: error: expected ')' before ';' token
   71 |     Int rest = ((N-1)*(N-2))/2-K;
      |                                 ^
      |                                 )
a.cc:65:7: note: to match this '('
   65 |     if(K > (((N-1)*(N-2))/2) {
      |       ^
a.cc:72:11: error: 'rest' was not declared in this scope
   72 |     solve(rest);
      |           ^~~~
Language: C++

#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int N, K;

void pnode(int i, int j) {
  cout << i << " " << j << endl;
}

signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> N >> K;
  int M = (N - 1) * (N - 2) / 2 - K;
  if (M < (N - 1)) {
    cout << -1 << endl;
    return 0;
  }
  cout << M << endl;
  rep(i, 1, N) pnode(0, i);
  rep(i, 1, N) rep(j, i+1, N) {
    if (--res) pnode(i, j);
    else break;
  }
  return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:59:11: error: 'res' was not declared in this scope; did you mean 'rep'?
   59 |     if (--res) pnode(i, j);
      |           ^~~
      |           rep
Language: C++

#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

using pii = pair<int,int>;

int main(){
    int n,k; cin >> n >> k;
    if(k <= n){
        set<pii> st;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                st.insert(pii(i,j));
            }
        }

        for(int i=0;i<k;i++){
            int j = (i+1) % n;
            int ii = min(i,j);
            int jj = i+j-ii;
            pii p = pii(ii,jj);
            st.erase(p);
        }

        cout << st.size() << endl;
        for(auto& p : st){
            cout << (p.first + 1) << " " << (p.second + 1) << endl;
        }
        return 0;
    }else{
        for(int x = 0; x < n-2; x++){
            int y = n-2-x;
            int sum = x*(x-1)/2+x+y;
            if(sum == k){
                cout << x + y + 1 << endl;

                cout << 1 << " " << 2 << endl;
                for(int i=0;i<x;i++){
                    cout << 1 << " " << 3+i << endl;
                }
                int start = 3+x;
                for(int i=0;i<y;i++){
                    if(i==0){
                        cout << 2 << " " << start << endl;
                    }else{
                        cout << start+i << " " << start+i+1 << endl;
                    }
                }
                return 0;
            }
        }
    }
    assert(false);
    cout << -1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:5: error: 'assert' was not declared in this scope
   54 |     assert(false);
      |     ^~~~~~
a.cc:4:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    3 | #include <algorithm>
  +++ |+#include <cassert>
    4 | using namespace std;
Language: C++

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

using pint = pair<int, int>;
int main(){
    int N, K; cin >> N >> K;
    int ma = (N-1)*(N-2) / 2;
    if (ma < K) cout << -1 << endl;
    else {
        vector<pint> res;
        for (int i = 1; i <= N-1; ++i) res.push_back({i, N});

        int rem = ma - K;
        int ci = 1, cj = 2;
        for (int _ = 0; _ < rem; ++_) {
            res.push_back({ci, cj});
            ++cj;
            if(cj == N) {
                ++ci;
                cj = ci+1;
            }
        }

        cout << res.size() << endl;
    }
    for (auto p : res) cout << p.first << " " << p.second << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:19: error: 'res' was not declared in this scope
   27 |     for (auto p : res) cout << p.first << " " << p.second << endl;
      |                   ^~~
Language: C++

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

int main(){
	int N, K; cin>>N>>K;
  	if(K>(N-1)*(N-2)/2){
    	cout<<-1<<endl;
    	return 0;
    }
  	printf("%d\n", N-1+(N-1)*(N-2)/2-k);
  	for(int i=0;i<N-1;i++){
    	printf("1\n%d\n", i+2);
    }
  	int index=2, path=3;
  	for(int i=0;i<(N-1)*(N-2)/2-k;i++){
    	printf("%d\n%d\n", index, path);
      	if(path!=N)++path;
      	else{
          index++;
          path=index+1;
        }
    }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:42: error: 'k' was not declared in this scope
   10 |         printf("%d\n", N-1+(N-1)*(N-2)/2-k);
      |                                          ^
Language: C++

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int N,K;

int main() {

	cin >> N,K;

	if((N-1)*(N-2)/2 < K)cout << -1 << endl;
	
	cout << "Yes" << endl;
	return 0;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'cin' was not declared in this scope
   11 |         cin >> N,K;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <queue>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:13:30: error: 'cout' was not declared in this scope
   13 |         if((N-1)*(N-2)/2 < K)cout << -1 << endl;
      |                              ^~~~
a.cc:13:30: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:13:44: error: 'endl' was not declared in this scope
   13 |         if((N-1)*(N-2)/2 < K)cout << -1 << endl;
      |                                            ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <queue>
  +++ |+#include <ostream>
    3 | using namespace std;
a.cc:15:9: error: 'cout' was not declared in this scope
   15 |         cout << "Yes" << endl;
      |         ^~~~
a.cc:15:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:26: error: 'endl' was not declared in this scope
   15 |         cout << "Yes" << endl;
      |                          ^~~~
a.cc:15:26: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll 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;
}

int main(){
    int N,K;
    cin >> N >> K;
    int r=(N-1)*(N-2)/2-K;
    if (r<0){
        cout << -1 << endl;
        return 0;
    }
    cout << N+r-1 << endl;
    rep2(i,2,N+1){
        cout << 1 << ' ' << i << endl;
    }
    int s=2;
    int r=(N-1)*(N-2)/2-K;
    while(r>0){
        for (int i=s+1;i<=N&&r>0;i++){
            cout << s << ' ' << i << endl;
            r--;
        }
        s++;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:9: error: redeclaration of 'int r'
   38 |     int r=(N-1)*(N-2)/2-K;
      |         ^
a.cc:28:9: note: 'int r' previously declared here
   28 |     int r=(N-1)*(N-2)/2-K;
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  int n,k;cin>>n>>k;
  int max=(n-1)*(n-2)/2;
  int ans=max-k;
  if(ans<0)cout<<-1<<endl;
  else{
    rep(i,n-1)cout<<n<<' '<<i+1<<endl;
    bool b=false;
    rep(i,n-1){
      Rep(j,i+1,n-1){
        if(ans==0){
          b=true;
          break;
        }
        cout<<i+1<<' '<<j+1<<endl;
        ans--;
      }
      if(b)break;
    }
  }
}


Compiler output:
a.cc:13:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   13 | void chmin(auto &a,auto b){if(b<a)a=b;}
      |            ^~~~
a.cc:13:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   13 | void chmin(auto &a,auto b){if(b<a)a=b;}
      |                    ^~~~
a.cc:14:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   14 | void chmax(auto &a,auto b){if(a<b)a=b;}
      |            ^~~~
a.cc:14:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   14 | void chmax(auto &a,auto b){if(a<b)a=b;}
      |                    ^~~~
a.cc: In function 'int main()':
a.cc:24:11: error: 'j' was not declared in this scope
   24 |       Rep(j,i+1,n-1){
      |           ^
a.cc:24:7: error: 'Rep' was not declared in this scope; did you mean 'rep'?
   24 |       Rep(j,i+1,n-1){
      |       ^~~
      |       rep
Language: C++

#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
#define mp make_pair

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

int cc;
int n;


int edges[100][100];

int main(){
    int k;
    cin >> n>> k;
    int maxk=(n-1)*(n-2)/2;
    if(maxk<k){
        cout<<-1<<endl;
        reutrn 0;
    }
    vector<pair<int,int> > edges;
    rep(i,n-1){
        edges.push_back(mp(i+1,n));
    }
    vector<pair<int,int> >temp;
    rep(i,n-1){
        for(int j=i+1;j<n-2;j++){
            temp.push_back(mp(i+1,j+1));
        }
    }
    rep(i,maxk-k){
        edges.push_back(temp[i]);
    }
    cout<<edges.size()<<endl;
    rep(i,edges.size()){
        cout<<get<0>(edges[i])<<" "<<get<1>(edges[i])<<endl;
    }
    return 0;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'reutrn' was not declared in this scope
   35 |         reutrn 0;
      |         ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

    if(K > (N-1)*(N-2)/2) cout << -1 << endl; 
    
    int m = n * (n-1)/2 - k;
    cout << m << endl;

    for(int i = 1; i < N - 1; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            cout << i << " " << j << endl;
            m--;
            if(m == 0) break;
        }
        if(m == 0) break;
    }
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: 'n' was not declared in this scope
   11 |     int m = n * (n-1)/2 - k;
      |             ^
a.cc:11:27: error: 'k' was not declared in this scope
   11 |     int m = n * (n-1)/2 - k;
      |                           ^
Language: C++

#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include<map>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
//木構造グラフ
struct edge{
  struct treev* to;
  ll length;
};
struct treev{
  int num;
  vector<edge> nexts;
};
struct input{
  int u;
  int v;
  ll w;
};
vector<treev*> vs;
treev* createtreenode(int num){
  treev* newt=new treev;
  if(newt==NULL){
    cout << "memory error" << endl;
    while(1){
      num=1;//メモリエラー対策
    }
  }
  newt->num=num;
  newt->nexts={};
  //cout << "fff" << endl;
  return newt;
}
void insertree(ll len,int Va,int Vb){//結ぶ頂点を
  vs[Va]->nexts.push_back({vs[Vb],len});
  vs[Vb]->nexts.push_back({vs[Va],len});
  return;
}
void search(treev* root,ll depth,treev* pre){
  //cout << "eee" << endl;
  //ここにやりたい処理を書く
  for(auto i:root->nexts){
    if(pre==i.to){
      continue;
    }
    search(i.to,depth+i.length,root);
  }
  return;
}

  
int main(void){
  ll k,n;
  cin>>n>>k;
  rep(i,n){
    vs.push_back(createtreenode(i));
  }
  if((((n-1)*(n-2))/2)<k){
    cout<<-1<<endl;
    return 0;
  }
  cout<<(n-1 + (((n-1)*(n-2))/2-k))<<endl;
  rep(i,n-1){
    cout<<1<<" "<<i+2<<endl;
  }
  rep(i,((n-1)*(n-2))/2-k){
    int i2=(i+1)%n;
    int sub=0;
    if(i1+1>n){
      i2++;
      sub++;
    }
    cout<<i2+2<<" "<<i2+3<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:84:8: error: 'i1' was not declared in this scope; did you mean 'i2'?
   84 |     if(i1+1>n){
      |        ^~
      |        i2
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;
  if(n*(n-1)/2-k<n-1){
    cout<<-1<<endl;
    return 0;
  }
  int m = n-1+(n-1)*(n-2)/2-k;
  int rest = (n-1)*(n-2)/2-k;
  cout<<m<<endl;
  REPP(i,n-1){
    cout<<1<<' '<<i+1<<endl;
  }
  
  cnt = 0;
  bool flag = true;
  REP(j,n){
    REP(i,j){
      if(cnt==rest){
        flag = false;
        break;
      }
      cout<<i+1<<' '<<j+1<<endl;
    }
    if(!flag)break;
  }
  return 0;
}


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

n, k = read_line.split.map(&.to_i)
c = (n - 1) * (n - 2) / 2
if c < k
  puts -1
  exit
end
es = [] of {Int32, Int32}
(n - 1).times do |i|
  es << {n - 1, i}
  i.times do |j|
    break if c == k
    es << {i, j}
    c -= 1
  end
end
puts es.size
es.each do |e|
  puts "#{e[0] + 1} #{e[1] + 1}"
end


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, k = read_line.split.map(&.to_i)
      | ^
a.cc:8:3: error: expected ')' before '-' token
    8 | (n - 1).times do |i|
      | ~ ^~
      |   )
a.cc:10:3: error: 'i' does not name a type
   10 |   i.times do |j|
      |   ^
a.cc:13:5: error: 'c' does not name a type
   13 |     c -= 1
      |     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n,k,m;

int main()
{	cin>>n>>k;
    m=n*(n-1)/2-K;
    if(m<n-1) 
		m=-1;
    cout<<m<<endl;
    if(m!=-1)
	{
        int cnt=n-1;
        while(m>0)
		{
            for(int i=n-cnt+1;i<=min(n,n-cnt+m);++i) 
				cout<<n-cnt<<" "<<i<<endl;
            m-=cnt--;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:17: error: 'K' was not declared in this scope
    7 |     m=n*(n-1)/2-K;
      |                 ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

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

  int n, k;
  cin >> n >> k;
  if (k > (n - 1) * (n - 2) / 2) {
    cout << -1;
    return;
  }

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

  int count = (n - 1) * (n - 2) / 2;
  for (int i = 2; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      edges.push_back(make_pair(i, j));
      count--;
      if (count == k) break;
    }
    if (count == k) break;
  }

  cout << edges.size() << endl;
  for (auto edge : edges) {
    cout << edge.first << " " << edge.second << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
   15 |     return;
      |     ^~~~~~
Language: C++

#include<iostream>

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

int main(int argsv, char* argsv[]){
    int n, k; scanf("%d%d", &n, &k);
    int m = ((n-1) * (n-2)) >> 1;
    if(m < k) puts("-1");
    else{
        printf("%d\n", (n-1)+m-k);
        for(int i = 2; i <= n; ++i) printf("1 %d\n", i);
        int l = 2, r = 3;
        REP(_, m-k){
            printf("%d %d\n", l, r);
            if(r++ == n){ r = ++l + 1; }
        }
    }
    return 0;
}

Compiler output:
a.cc:5:27: error: conflicting declaration 'char** argsv'
    5 | int main(int argsv, char* argsv[]){
      |                     ~~~~~~^~~~~~~
a.cc:5:14: note: previous declaration as 'int argsv'
    5 | int main(int argsv, char* argsv[]){
      |          ~~~~^~~~~
Language: C++


using namespace std;

typedef vector<int> vi;

const int maxn = 100;

vi V[maxn];
int n, k;

int main()
{
  cin >> n >> k;
  if (k > (n - 1) * (n - 2) / 2)
    cout << -1, exit(0);

  int cnt = (n - 1) * (n - 2) / 2, m = 0;
  for (int i = 1; i < n; ++i)
    V[0].push_back(i), ++m;

  for (int i = 1; i < n && k < cnt; ++i)
    for (int j = i + 1; i < n && k < cnt; ++i)
      V[i].push_back(i), --cnt, ++m;

  cout << m << '\n';
  for (int i = 0; i < n; ++i)
    for (int j : V[i])
      cout << i + 1 << ' ' << j + 1 << '\n';
}







Compiler output:
a.cc:4:9: error: 'vector' does not name a type
    4 | typedef vector<int> vi;
      |         ^~~~~~
a.cc:8:1: error: 'vi' does not name a type; did you mean 'void'?
    8 | vi V[maxn];
      | ^~
      | void
a.cc: In function 'int main()':
a.cc:13:3: error: 'cin' was not declared in this scope
   13 |   cin >> n >> k;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:15:5: error: 'cout' was not declared in this scope
   15 |     cout << -1, exit(0);
      |     ^~~~
a.cc:15:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:17: error: 'exit' was not declared in this scope
   15 |     cout << -1, exit(0);
      |                 ^~~~
a.cc:1:1: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
  +++ |+#include <cstdlib>
    1 | 
a.cc:19:5: error: 'V' was not declared in this scope
   19 |     V[0].push_back(i), ++m;
      |     ^
a.cc:23:7: error: 'V' was not declared in this scope
   23 |       V[i].push_back(i), --cnt, ++m;
      |       ^
a.cc:25:3: error: 'cout' was not declared in this scope
   25 |   cout << m << '\n';
      |   ^~~~
a.cc:25:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:27:18: error: 'V' was not declared in this scope
   27 |     for (int j : V[i])
      |                  ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;

int main(){
    int N, K;
    cin >> N >> K;
    
    int limit = (N - 1) * (N - 2) / 2;
    if(K > limit){
        cout << -1 << endl;
        return 0;
    }
    
    cout <<  N - 1 + limit - K << endl;
    
    for(int i = 1; i < N; ++i){
        cout << i << " " << N << endl;    
    }
    
    if(k == limit)      return 0;
    
    vector<P> candidates;
    int cnt = 0;
    for(int i = 1; i < N; ++i){
        for(int j = i; j < N; ++j){
            if(i == j)      continue;
            
            candidates.push_back(P(i, j));
            cnt++;
            
            if(cnt == limit - K)    break;
        }
        if(cnt == limit - K)        break;
    }
    
    for(int i = 0; i < candidates.size(); ++i){
        P p = candidates[i];
        cout << p.first << " " << p.second << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:8: error: 'k' was not declared in this scope
   25 |     if(k == limit)      return 0;
      |        ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a>b)
    cout<<gcd__(a,b);
  if(a<b)
    cout<<"-1";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:11: error: 'gcd__' was not declared in this scope
    8 |     cout<<gcd__(a,b);
      |           ^~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

typedef pair <int, int> pii;
typedef vector <pii> vpii;

int main() {
    int n, k; cin >> n >> k;
    
    vpii vex;
    
    for(int i = 1; i < n; ++i)
        vex.emplace_back(1, i + 1);
    
    int mx = (n - 1) * (n - 2) / 2;
    
    for(int i = 1; i < n; ++i)
        for(int j = i + 1; j < n; ++j) {
            if(mx == k) { n = 0; continue; }
            vex.emplace_back(i + 1, j + 1);
            mx -= 1;
        }
    
    if(k != mx) cout << -1;
    else {
        cout << r.size() << '\n';
        for(pii& r : vex)
            cout << r.first << ' ' << r.second << '\n';
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:17: error: 'r' was not declared in this scope
   30 |         cout << r.size() << '\n';
      |                 ^
Language: C++

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

void solve()
{
	bool edge[101][101]; ll N,K,i,j;
	cin>>N>>K;
	ll mx = (N-1)*(N-2)/2;
	if(K>mx)
	{	cout<<"-1"<<endl;
		return 0;}
	for(ll i=2;i<=N;i++)
		edge[1][j]=1;
	ll diff = mx-K;
	for(i=2;i<=N && diff>0;i++)
	{
		for(j=i+1;j<=N && diff>0;j++)
		{
			if(!edge[i][j])
			{
				edge[i][j]=1;
				diff--;
			}
		}
	}
	ll count = 0;
	vector<pair<ll,ll>> vect;
	for(i=1;i<=N;i++)
	{
		for(j=i+1;j<=N;j++)
		{
			if(edge[i][j])
			{vect.push_back(make_pair(i,j));count++;}
		}
	}
	cout<<count<<endl;
	for(auto x:vect){cout<<x.first<<" "<<x.second<<endl;}
}

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

Compiler output:
a.cc: In function 'void solve()':
a.cc:12:24: error: return-statement with a value, in function returning 'void' [-fpermissive]
   12 |                 return 0;}
      |                        ^