Language: C++

#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n,k;
    cin>>n>>k;
    if((n<=k){
        cout<<-1<<endl;
        return 0;
    }
    int hen[n][n];
    rep(i,n){rep(j,n) {
            if (i == j)hen[i][j] = 0;
            else hen[i][j] = 1;
        }
    }

    int kk=0;
    set<pair<int,int>> se;

    for(int i=0;i<n;i++){
       for(int j=0;j<n;j++){
           if(i!=j){
               if(i==0){
                   if(j>=2&&j<n-1){
                       hen[i][j]=0;
                       hen[j][i]=0;
                       kk++;
                   }
               }else if(i==n-1){
                   if(j>=1&&j<n-2){
                       hen[i][j]=0;
                       hen[j][i]=0;
                       kk++;
                   }
               }else{
                   if(j>i+1){
                       hen[i][j]=0;
                       hen[j][i]=0;
                       kk++;
                   }else if(j<i-1){
                       hen[i][j]=0;
                       hen[j][i]=0;
                       kk++;
                   }
               }
           }
           if(kk==k){
               rep(t,n){
                   rep(s,n){
                       if(hen[t][s]==1){
                           pair<int,int> ts ;
                           if(t>s){
                               ts={t+1,s+1};
                           }else{
                               ts={s+1,t+1};
                           }
                           se.insert(ts);
                       }
                   }
               }
               cout<<se.size()<<endl;
               for(auto &a:se){
                   cout<<a.first<<" "<<a.second<<endl;
               }
               return 0;

           }
       }
    }


    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:14: error: expected ';' before '{' token
   30 |     if((n<=k){
      |              ^
      |              ;
a.cc:34:9: error: condition declares an array
   34 |     int hen[n][n];
      |         ^~~
a.cc:34:18: error: expected ')' before ';' token
   34 |     int hen[n][n];
      |                  ^
      |                  )
a.cc:30:7: note: to match this '('
   30 |     if((n<=k){
      |       ^
a.cc:36:24: error: 'hen' was not declared in this scope
   36 |             if (i == j)hen[i][j] = 0;
      |                        ^~~
a.cc:37:18: error: 'hen' was not declared in this scope
   37 |             else hen[i][j] = 1;
      |                  ^~~
a.cc:49:24: error: 'hen' was not declared in this scope
   49 |                        hen[i][j]=0;
      |                        ^~~
a.cc:55:24: error: 'hen' was not declared in this scope
   55 |                        hen[i][j]=0;
      |                        ^~~
a.cc:61:24: error: 'hen' was not declared in this scope
   61 |                        hen[i][j]=0;
      |                        ^~~
a.cc:65:24: error: 'hen' was not declared in this scope
   65 |                        hen[i][j]=0;
      |                        ^~~
a.cc:74:27: error: 'hen' was not declared in this scope
   74 |                        if(hen[t][s]==1){
      |                           ^~~