Language: C++

#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N,K;
  in(N,K);
  if(K==0){
    long M=N*(N-1)/2;
    out(M);
    vector<long>v(N);
    v[N-1]=1;
    v[N-2]=1;
    do{
      long a=0,b=0;
      bool check=false;
      rep(i,M){
        if(!check&&v[i]==1){
          a=i+1;
          check=true;
        }
        else if(v[i]==1){
          b=i+1;
          break;
        }
      }
      out(a,b);
    }while(next_permutation(all(v)));
  }else{
    if(N==2){
      out(-1);
    }else if(N==3){
      if(K==1){
        out(2);
        out(1,2);
        out(2,3);
      }else{
        out(-1);
      }
    }else if(N==4){
      if(K==1){
        out(5);
        out(1,2);
        out(1,3);
        out(1,4);
        out(2,3);
        out(3,4);
      }else if(K==2){
        out(3);
        out(1,2);
        out(2,3);
        out(3,4);
      }else if(K==3){
        out(3);
        out(1,2);
        out(1,3);
        out(1,4);
      }else{
        out(-1);
      }
    }else{
      long T=(N-2)*(N-1)/2;
      if(K>T){
        out(-1);
        return;
      }
      out(N-1+T-K);
      up(i,2,N)out(1,i);
      long cnt=0;
      up(i,2,N){
        up(j,i+1,N){
          out(i,j);
          cnt++;
          if(T-K==cnt)return;
        }
      }
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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