stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <math.h>



using namespace std;



int main(){



    

    long long a,b,min,max,num=0;



    cin>>a;

    cin>>b;



    if(a<b){

        min = a;

        max = b;

    }else{

        min = b;

        max = a;

    }



    for (int i = min+1; i <= max; i++)

    {   

        if(abs(a-i) == abs(b-i)){

            num = i;

        }

    }



    if(num != 0){

        cout<<num<<endl;

    }else{

        cout<<"IMPOSSIBLE"<<endl;

    }

    

}

// Faster C++ solution for the same problem (measured speedup: 2.2500623841629857x):
#include <iostream>

#include <sstream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <cctype>

#include <string>

#include <vector>

#include <list>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <algorithm>

#include <functional>





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

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)

#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];

#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;



typedef long long ll;

using namespace std;



int main()

{

     ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

     int n,k,l,c,d,p,nl,np;

    ll a,b;

    cin>>a>>b;

    if((a+b)%2==0)

        cout<<(a+b)/2;

    else

        cout<<"IMPOSSIBLE";







}
// Slower C++ solution:
#include <iostream>

#include <math.h>



using namespace std;



int main(){



    

    long long a,b,min,max,num=0;



    cin>>a;

    cin>>b;



    if(a<b){

        min = a;

        max = b;

    }else{

        min = b;

        max = a;

    }



    for (int i = min+1; i <= max; i++)

    {   

        if(abs(a-i) == abs(b-i)){

            num = i;

        }

    }



    if(num != 0){

        cout<<num<<endl;

    }else{

        cout<<"IMPOSSIBLE"<<endl;

    }

    

}

// Faster C++ solution for the same problem (measured speedup: 2.2765615222249873x):
#include <iostream>

using namespace std;



int main()

{

	int a, b;

	cin >> a >> b;



	if(a % 2 == b % 2){

		cout << (a + b) / 2 << endl;

	} else{

		cout << "IMPOSSIBLE" << endl;

	}

}
// Slower C++ solution:
#include <iostream>

#include <math.h>



using namespace std;



int main(){



    

    long long a,b,min,max,num=0;



    cin>>a;

    cin>>b;



    if(a<b){

        min = a;

        max = b;

    }else{

        min = b;

        max = a;

    }



    for (int i = min+1; i <= max; i++)

    {   

        if(abs(a-i) == abs(b-i)){

            num = i;

        }

    }



    if(num != 0){

        cout<<num<<endl;

    }else{

        cout<<"IMPOSSIBLE"<<endl;

    }

    

}

// Faster C++ solution for the same problem (measured speedup: 2.2785283895178527x):
#include<bits/stdc++.h>

#define ll long long

using namespace std;

int main()

{

	ll a,b;

	cin>>a>>b;

	ll c = a+b;

	if(c%2==0)

	{

		cout<<c/2<<endl;

	}

	else

	{

		cout<<"IMPOSSIBLE"<<endl;

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <math.h>



using namespace std;



int main(){



    

    long long a,b,min,max,num=0;



    cin>>a;

    cin>>b;



    if(a<b){

        min = a;

        max = b;

    }else{

        min = b;

        max = a;

    }



    for (int i = min+1; i <= max; i++)

    {   

        if(abs(a-i) == abs(b-i)){

            num = i;

        }

    }



    if(num != 0){

        cout<<num<<endl;

    }else{

        cout<<"IMPOSSIBLE"<<endl;

    }

    

}

// Faster C++ solution for the same problem (measured speedup: 2.276958488507519x):
#include<iostream>

using namespace std;

int main(){

int a,b;

cin >> a>>b;

int sum=a+b;

if(sum%2==0)

cout <<sum/2<<endl;

else 

cout<<"IMPOSSIBLE"<<endl;

}
// Slower C++ solution:
#include <iostream>

#include <math.h>



using namespace std;



int main(){



    

    long long a,b,min,max,num=0;



    cin>>a;

    cin>>b;



    if(a<b){

        min = a;

        max = b;

    }else{

        min = b;

        max = a;

    }



    for (int i = min+1; i <= max; i++)

    {   

        if(abs(a-i) == abs(b-i)){

            num = i;

        }

    }



    if(num != 0){

        cout<<num<<endl;

    }else{

        cout<<"IMPOSSIBLE"<<endl;

    }

    

}

// Faster C++ solution for the same problem (measured speedup: 2.276958488507519x):
#include<iostream>



int main()

{

    int a,b;

    std::cin>>a>>b;

    ((a+b)%2==0)?

    std::cout<<(a+b)/2<<std::endl:

    std::cout<<"IMPOSSIBLE"<<std::endl;

}
// Slower C++ solution:
#include <iostream>

#include <math.h>



using namespace std;



int main(){



    

    long long a,b,min,max,num=0;



    cin>>a;

    cin>>b;



    if(a<b){

        min = a;

        max = b;

    }else{

        min = b;

        max = a;

    }



    for (int i = min+1; i <= max; i++)

    {   

        if(abs(a-i) == abs(b-i)){

            num = i;

        }

    }



    if(num != 0){

        cout<<num<<endl;

    }else{

        cout<<"IMPOSSIBLE"<<endl;

    }

    

}

// Faster C++ solution for the same problem (measured speedup: 2.2765615222249873x):
#include <bits/stdc++.h>

 using namespace std;

 int main() {

     int firstIn, secondIn,value,temp1,temp2;

     cin >> firstIn>> secondIn;

     temp1=firstIn%2;

     temp2=secondIn%2;



      if(temp1!=temp2)

        cout << "IMPOSSIBLE" << endl;

      else

      {

          value= (firstIn + secondIn) / 2;

          cout <<value<< endl;

      }



     return 0;

}
// Slower C++ solution:
#include<iostream>

#include<math.h>

using namespace std;

int main()

{

	long long x,k,a,i;

	cin>>k;

	x=0;a=1;

	while(k>0)

	{

		x+=a;

		a*=2;

		k/=2;

	}

	cout<<x;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.25070532805362x):
#include<stdio.h>

long long num=1,sum=0,H;

int main()

{

    scanf("%lld",&H);

    while(H>1e-10)

    {

        H=H/2;

        sum+=num;

        num*=2;

    }

    printf("%lld\n",sum);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



using i32 = std::int_fast32_t;

using i64 = std::int_fast64_t;

template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;



#define REP(i, stop) FOR(i, 0, stop)

#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)

#define RREP(i, n) for (int i = n; i-- > 0;)

#define ALL(v) (v).begin(), (v).end()

#define RALL(v) (v).rbegin(), (v).rend()

#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }



template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }

template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }



void LOG(const int& x) { cerr << x << "\n"; }

template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }

template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }

template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }



i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }

i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }

i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }

i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }

i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }

i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }

i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }



struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;



signed main() {

  i64 n, k;

  cin >> n >> k;

  if (k > (n - 2) * (n - 1) / 2) {

    cout << -1 << endl;

  } else {

    cout << ((n - 1) + (n - 2) * (n - 1) / 2 - k) << endl;

    for (i64 i = 1; i <= n - 1; ++i) {

      cout << i << " " << n << endl;

    }

    i64 c = (n - 2) * (n - 1) / 2 - k;

    for (i64 i = 1; i <= n - 2; ++i) {

      for (i64 j = i + 1; j <= n - 1; ++j) {

        if (c > 0) {

          cout << i << " " << j << endl;

          c -= 1;

        } else {

          return 0;

        }

      }

    }

  }

}


// Faster C++ solution for the same problem (measured speedup: 5.270610232874384x):
#include <cstdio>



signed main() {

	int n, k;

	scanf("%d%d", &n, &k);

	if (k > (n - 2) * (n - 1) / 2) {

		puts("-1\n");

	} else {

		printf("%d\n", n * (n - 1) / 2 - k);

		for (int i = 1; i <= n - 1; ++i) {

			printf("%d %d\n", i, n);

		}

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

		for (int i = 1; i <= n - 2; ++i) {

			for (int j = i + 1; j <= n - 1; ++j) {

				if (c > 0) {

					printf("%d %d\n", i, j);

					--c;

				} else {

					return 0;

				}

			}

		}

	}

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define pi acos(0.0)

#define ll long long

#define f first

#define s second

#define gap ' '

#define pb push_back

int main()

{

    int n,k;

    cin>>n>>k;

    if(((n-2)*(n-1))/2 < k)

    {

        cout<<-1;

        return 0;

    }

    pair<int,int> ara[100005];

    int m=0;

    for(int i=2;i<=n;i++)

    {



       ara[m].f=1;

       ara[m].s=i;

       m++;



    }

    vector<pair<int,int> >p;

    for(int i=2;i<=n;i++)

    {

       for(int j=i+1;j<=n;j++)

       {

          p.pb({i,j});

       }

    }

    for(int i=0;i<((n-2)*(n-1))/2-k;i++)

    {

        ara[m]=p[i];

        m++;



    }

    cout<<m<<endl;

    for(int i=0;i<m;i++)

    {

        cout<<ara[i].f<<gap<<ara[i].s<<endl;

    }





}


// Faster C++ solution for the same problem (measured speedup: 1.815357214420189x):
#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;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define pi acos(0.0)

#define ll long long

#define f first

#define s second

#define gap ' '

#define pb push_back

int main()

{

    int n,k;

    cin>>n>>k;

    if(((n-2)*(n-1))/2 < k)

    {

        cout<<-1;

        return 0;

    }

    pair<int,int> ara[100005];

    int m=0;

    for(int i=2;i<=n;i++)

    {



       ara[m].f=1;

       ara[m].s=i;

       m++;



    }

    vector<pair<int,int> >p;

    for(int i=2;i<=n;i++)

    {

       for(int j=i+1;j<=n;j++)

       {

          p.pb({i,j});

       }

    }

    for(int i=0;i<((n-2)*(n-1))/2-k;i++)

    {

        ara[m]=p[i];

        m++;



    }

    cout<<m<<endl;

    for(int i=0;i<m;i++)

    {

        cout<<ara[i].f<<gap<<ara[i].s<<endl;

    }





}


// Faster C++ solution for the same problem (measured speedup: 1.8074449699078061x):
#include<bits/stdc++.h>

using namespace std;



typedef pair<int,int> pii;



int n,k;



vector<pii> adj;

int isi[105];



int main(){

	scanf("%d%d",&n,&k);

	if(k>((n-1)*(n-2)/2)){

		cout << "-1\n";

		return 0;

	}

//	adj.push_back(make_pair(1,2));

	int cur = (n-1)*(n-2)/2;

	for(int i=2;i<=n;i++) adj.push_back(make_pair(1,i));

	for(int i=2;i<=n;i++){

		for(int j=i+1;j<=n;j++){

			if(cur == k) break;

			adj.push_back(make_pair(i,j));

			cur--;

		}

	}

	cout << adj.size() << endl;

	for(int i=0;i<adj.size();i++){

		cout << adj[i].first << " " << adj[i].second << endl;

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define pi acos(0.0)

#define ll long long

#define f first

#define s second

#define gap ' '

#define pb push_back

int main()

{

    int n,k;

    cin>>n>>k;

    if(((n-2)*(n-1))/2 < k)

    {

        cout<<-1;

        return 0;

    }

    pair<int,int> ara[100005];

    int m=0;

    for(int i=2;i<=n;i++)

    {



       ara[m].f=1;

       ara[m].s=i;

       m++;



    }

    vector<pair<int,int> >p;

    for(int i=2;i<=n;i++)

    {

       for(int j=i+1;j<=n;j++)

       {

          p.pb({i,j});

       }

    }

    for(int i=0;i<((n-2)*(n-1))/2-k;i++)

    {

        ara[m]=p[i];

        m++;



    }

    cout<<m<<endl;

    for(int i=0;i<m;i++)

    {

        cout<<ara[i].f<<gap<<ara[i].s<<endl;

    }





}


// Faster C++ solution for the same problem (measured speedup: 9.449872667816264x):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;



int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    int n,k;

    scanf("%d %d",&n,&k);

    int ans = (n-1)*(n-2)/2;

    if(ans < k)

    {

        printf("-1");

    }

    else

    {

        printf("%d\n",n-1 + ans - k );

        for(int i=2;i<=n;i++)

            printf("%d %d\n",1,i);



        for(int i=2;i<=n;i++)

            for(int j=i+1;j<=n;j++)

            {

                if(ans == k) return 0;

                printf("%d %d\n",i,j);

                ans--;

                

            }

    }

    return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.2055169047456475x):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;



int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    int n,k;

    scanf("%d %d",&n,&k);

    int ans = (n-1)*(n-2)/2;

    if(ans < k)

    {

        printf("-1");

    }

    else

    {

        printf("%d\n",n-1 + ans - k );

        for(int i=2;i<=n;i++)

            printf("%d %d\n",1,i);



        for(int i=2;i<=n;i++)

            for(int j=i+1;j<=n;j++)

            {

                if(ans == k) return 0;

                printf("%d %d\n",i,j);

                ans--;

                

            }

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef pair<int,int> pii;



int n,k;



vector<pii> adj;

int isi[105];



int main(){

	scanf("%d%d",&n,&k);

	if(k>((n-1)*(n-2)/2)){

		cout << "-1\n";

		return 0;

	}

//	adj.push_back(make_pair(1,2));

	int cur = (n-1)*(n-2)/2;

	for(int i=2;i<=n;i++) adj.push_back(make_pair(1,i));

	for(int i=2;i<=n;i++){

		for(int j=i+1;j<=n;j++){

			if(cur == k) break;

			adj.push_back(make_pair(i,j));

			cur--;

		}

	}

	cout << adj.size() << endl;

	for(int i=0;i<adj.size();i++){

		cout << adj[i].first << " " << adj[i].second << endl;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.228304498973643x):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;



int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    int n,k;

    scanf("%d %d",&n,&k);

    int ans = (n-1)*(n-2)/2;

    if(ans < k)

    {

        printf("-1");

    }

    else

    {

        printf("%d\n",n-1 + ans - k );

        for(int i=2;i<=n;i++)

            printf("%d %d\n",1,i);



        for(int i=2;i<=n;i++)

            for(int j=i+1;j<=n;j++)

            {

                if(ans == k) return 0;

                printf("%d %d\n",i,j);

                ans--;

                

            }

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define pi acos(0.0)

#define ll long long

#define f first

#define s second

#define gap ' '

#define pb push_back

int main()

{

    int n,k;

    cin>>n>>k;

    if(((n-2)*(n-1))/2 < k)

    {

        cout<<-1;

        return 0;

    }

    pair<int,int> ara[100005];

    int m=0;

    for(int i=2;i<=n;i++)

    {



       ara[m].f=1;

       ara[m].s=i;

       m++;



    }

    vector<pair<int,int> >p;

    for(int i=2;i<=n;i++)

    {

       for(int j=i+1;j<=n;j++)

       {

          p.pb({i,j});

       }

    }

    for(int i=0;i<((n-2)*(n-1))/2-k;i++)

    {

        ara[m]=p[i];

        m++;



    }

    cout<<m<<endl;

    for(int i=0;i<m;i++)

    {

        cout<<ara[i].f<<gap<<ara[i].s<<endl;

    }





}


// Faster C++ solution for the same problem (measured speedup: 1.8141694556001784x):
#include <iostream>

#include <queue>

#include <algorithm>

#include <cstring>

#define INF 10050

using namespace std;

int main()

{

	int n,k;

	cin>>n>>k;

//	while(cin>>n>>k)

//	{

		int sum = (1+n-2)*(n-2)/2;

		if(k>sum) {

			cout<<"-1"<<endl;

		}else{

			cout << (n-1) + sum - k <<endl;

			for(int i=2;i<=n;i++) {

				cout<<"1 "<<i<<endl;

			}

			

			for(int i=2; i<=n; i++) {

				for(int j=i+1; j<=n; j++) {

					if(sum == k)	return 0;

					cout<<i<<" "<<j<<endl;

					sum--;

				}

			}

		}

//	}

	

	

	

	

	

	

	

	return 0;



}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define pi acos(0.0)

#define ll long long

#define f first

#define s second

#define gap ' '

#define pb push_back

int main()

{

    int n,k;

    cin>>n>>k;

    if(((n-2)*(n-1))/2 < k)

    {

        cout<<-1;

        return 0;

    }

    pair<int,int> ara[100005];

    int m=0;

    for(int i=2;i<=n;i++)

    {



       ara[m].f=1;

       ara[m].s=i;

       m++;



    }

    vector<pair<int,int> >p;

    for(int i=2;i<=n;i++)

    {

       for(int j=i+1;j<=n;j++)

       {

          p.pb({i,j});

       }

    }

    for(int i=0;i<((n-2)*(n-1))/2-k;i++)

    {

        ara[m]=p[i];

        m++;



    }

    cout<<m<<endl;

    for(int i=0;i<m;i++)

    {

        cout<<ara[i].f<<gap<<ara[i].s<<endl;

    }





}


// Faster C++ solution for the same problem (measured speedup: 1.8072737305033977x):
#include <bits/stdtr1c++.h>

#define pb push_back

#define fi first

#define sc second

#define inf	1000000000LL

#define MP make_pair

#define N 300005

#define MOD 1000000007 

#define orta ((a+b)/2)

using namespace std;

typedef long long int lint;

typedef pair<int,int> ii;



ii d[N];

std::vector<ii> v;

int main()

{

	int n,k;

	cin >> n >> k;



	int sum=0;

	int t=1;

	v.pb(MP(2,1));

	int i=3,mx=2;

		

	for ( ; i <=n; ++i)

	{

		if(k>0)

		{

			k-=t;

			t++;

			v.pb(MP(i,1));

			mx=max(mx,i);

			if(k==0) break;

		}

		else break;

	}

	if(k>0)

	{	

		printf("-1\n");

		return 0;

	}

	for (int i = 0; i < -k; ++i)

	{

		v.pb(MP(2,i+3));

	}

	for (int i = mx+1; i <= n; ++i)

	for (int j = 1; j <= i-1; ++j)

		v.pb(MP(i,j));

	cout << v.size() << endl;

	for (int i = 0; i < v.size(); ++i)

	{

		cout << v[i].fi << " " << v[i].sc << endl;

	}

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define pi acos(0.0)

#define ll long long

#define f first

#define s second

#define gap ' '

#define pb push_back

int main()

{

    int n,k;

    cin>>n>>k;

    if(((n-2)*(n-1))/2 < k)

    {

        cout<<-1;

        return 0;

    }

    pair<int,int> ara[100005];

    int m=0;

    for(int i=2;i<=n;i++)

    {



       ara[m].f=1;

       ara[m].s=i;

       m++;



    }

    vector<pair<int,int> >p;

    for(int i=2;i<=n;i++)

    {

       for(int j=i+1;j<=n;j++)

       {

          p.pb({i,j});

       }

    }

    for(int i=0;i<((n-2)*(n-1))/2-k;i++)

    {

        ara[m]=p[i];

        m++;



    }

    cout<<m<<endl;

    for(int i=0;i<m;i++)

    {

        cout<<ara[i].f<<gap<<ara[i].s<<endl;

    }





}


// Faster C++ solution for the same problem (measured speedup: 1.8190880350568597x):
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using namespace std;

const int N = 2e3 + 5, M = 1e5 + 5;



int n, k;

int main(){

    scanf("%d%d", &n, &k);

    int x = n - 2;

    int kam = (x * (x + 1)) / 2;

    if(k > kam){

        puts("-1");

        return 0;

    }

    vector<pair<int, int> > out;

    for(int i = 2 ; i <= n ; ++i)

        out.emplace_back(1, i);

    int u = 2, v = 3;

    while(kam > k){

        --kam;

        out.emplace_back(u, v);

        ++v;

        if(v > n)v = ++u + 1;

    }

    printf("%d\n", out.size());

    for(auto p : out)printf("%d %d\n", p.first, p.second);

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>



using namespace std;



int main(){

	int n; scanf("%d", &n);

	for(int k = 1; k * (k + 1) / 2 <= n; k++) if(k * (k + 1) / 2 == n){

		int s[500][500] = {};

		for(int i = 0, p = 1; i < k; i++){

			for(int j = 0; j < k - i; j++) s[i][j + i] = p++;

		}

		int t[500][500] = {};

		for(int i = 0; i < k; i++) for(int j = 0; j < k; j++) if(s[i][j] > 0) t[j + 1][i] = s[i][j];

		for(int i = 0; i < k + 1; i++) for(int j = 0; j < k; j++) if(s[i][j] == 0) s[i][j] = t[i][j];

		puts("Yes");

		printf("%d\n", k + 1);

		for(int i = 0; i < k + 1; i++){

			printf("%d ", k);

			for(int j = 0; j < k; j++) printf("%d%c", s[i][j], j + 1 == k ? '\n' : ' ');

		}

		return 0;

	}

	puts("No");

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8446432748374844x):
#include<cstdio>

#include<algorithm>



using namespace std;



int main(){

	int n; scanf("%d", &n);

	for(int k = 1; k * (k + 1) / 2 <= n; k++) if(k * (k + 1) / 2 == n){

		int s[500][500] = {};

		for(int i = 0, p = 1; i < k; i++) for(int j = 0; j < k - i; j++) s[i][j + i] = p++;

		for(int i = 0; i < k; i++) for(int j = 0; j < k - i; j++) s[j + i + 1][i] = s[i][j + i];

		puts("Yes");

		printf("%d\n", k + 1);

		for(int i = 0; i < k + 1; i++){

			printf("%d ", k);

			for(int j = 0; j < k; j++) printf("%d%c", s[i][j], j + 1 == k ? '\n' : ' ');

		}

		return 0;

	}

	puts("No");

	return 0;

}