akhauriyash/Code-Regression huggingface dataset:
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif
using namespace std;

string solve() {
    int N;
    cin >> N;
    for(int i = 0;; i++) {
        int cost = i + i * 8 / 100;
        if(N < cost) break;
        if(N == cost) return to_string(i);
    }
    return ":(";
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    if(a > b) {
        swap(a, b);
    }
    ll diff = b - a;
    if(diff % 2 == 0) {
        cout << diff / 2 << endl;
    } else {
        ll ans = min(b - 1, n - a);
        ll rec = a - 1;
        ll bb = max(b - (a - 1), 1LL);
        if(bb == 1) {
            chmin(ans, rec);
        } else {
            bb = max(bb - 1, 1LL);
            rec++;
            if(bb == 1) {
                chmin(ans, rec);
            } else {
                rec += (bb - 1) / 2;
                chmin(ans, rec);
            }
        }
        rec = n - b;
        ll aa = min(a + (n - b), n);
        if(aa == n) {
            chmin(ans, rec);
        } else {
            aa = min(aa + 1, n);
            rec++;
            if(aa == n) {
                chmin(ans, rec);
            } else {
                rec += (n - aa) / 2;
                chmin(ans, rec);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    long MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] count = new int[26];
        for(int i = 0; i < s.length(); i++) {
            count[s.charAt(i) - 'A']++;
        }
        int a = 0;
        for(int i = 0; i < 26; i++) {
            if(count[i] == 2) a++;
        }
        if(a == 2) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef pair<double, double> P;

double Helon(P pa, P pb, P pc)
{
	double a, b, c;
	a = sqrt((pb.first - pa.first) * (pb.first - pa.first) + (pb.second - pa.second) * (pb.second - pa.second));
	b = sqrt((pc.first - pb.first) * (pc.first - pb.first) + (pc.second - pb.second) * (pc.second - pb.second));
	c = sqrt((pa.first - pc.first) * (pa.first - pc.first) + (pa.second - pc.second) * (pa.second - pc.second));
	double s = (a + b + c) / 2;
	return(sqrt(s * (s - a) * (s - b) * (s - c)));
}

void solve()
{
	vector<P> p(4);
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &p[0].first, &p[0].second, &p[1].first, &p[1].second, &p[2].first, &p[2].second, &p[3].first, &p[3].second))
	{
		double S1, S2;
		S1 = Helon(p[0], p[1], p[2]);
		S1 += Helon(p[0], p[2], p[3]);

		S2 = Helon(p[0], p[1], p[3]);
		S2 += Helon(p[1], p[2], p[3]);
		if(fabs(S1 - S2) < 1e-10)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
        #define s(a) cin >> a;
        #define s2(a,b) cin >> a>> b;
        #define s3(a,b,c) cin >> a>> b>> c;
        #define s4(a,b,c,d) cin >> a>> b >> c >> d;
        #define sp(b) cout << b << "\n";
        #define sp2(b,c) cout << b << " "<<c <<endl; 
        #define sp3(a,b,c) cout <<a <<" "<< b << " "<<c <<endl; 
        #define p(a) //////printf("%lld\n",a);
        #define p2(a,b) //////printf("%lld %lld",a,b);
        #define pm(a) //////printf("a\n");
        #define test(t) while(t>0)
        #define sl(a) a.length()
        #define f(a,b,c) for(a=b;a<c;a++)
        #define fr(a,b,c) for(a=c-1;a>=0;a--)
        #define v(a,b) vector<a> b;
        #define pb(a,b) a.push_back(b);
        #define ll long long
        #define mem(a,b) memset(a,b,sizeof(a));
        #define fillar(ar,n) f(i,0,n) s(ar[i]);
        #define diff(a,b) abs(a-b);
        using namespace std;
        #define MOD 1000000007
        #define flush fflush(stdout);
struct flist
{
    int val;
    int pos;
    
};
ll mincomp[100001];
ll maxcomp[100001];
ll mx=1e5+1;
ll getans(ll start,ll end,ll minn,ll maxx,ll com,ll *ar){
    //printf("start=%lld,end=%lld\n",start,end );
    //printf("mnn=%lld,maxx=%lld\n",minn,maxx );
    if(start>end){
        return 0;
    }
    if(start==end){
        if(com==0){
            ar[start]=minn;
            //printf("1.ar[%lld]=%lld\n",start,ar[start] );
        }
        else{
            return 0;
        }
    }
    ll range=end-start+1;
    ll maxxx=maxcomp[range];
    ll minnn=mincomp[range];
    if(com<minnn || com > maxxx){
        return 0;
    }
    int i;
    ll remain=com-(range-1);
    f(i,minn,maxx+1){
        ll left=i-minn;
        ll right=maxx-i;
        ll minbound=mincomp[left]+mincomp[right];
        ll maxbound=maxcomp[left]+maxcomp[right];
        //printf("left=%lld,right=%lld\n",left,right );
        if(remain>=minbound&&remain<=maxbound){
            if(remain-mincomp[left] <=maxcomp[right]){
                ar[start]=i;
                //printf("2.ar[%lld]=%lld\n",start,ar[start] );
                getans(start+1,start+left,minn,i-1,mincomp[left],ar);
                getans(start+left+1,end,i+1,maxx,remain-mincomp[left],ar);
                break;
            }
            else if(remain-maxcomp[left]>=mincomp[right]){
                ar[start]=i;
                //printf("3.ar[%lld]=%lld\n",start,ar[start] );

                getans(start+1,start+left,minn,i-1,maxcomp[left],ar);
                getans(start+left+2,end,i+1,maxx,remain-maxcomp[left],ar);
                break;
            }
        }

    }
    return 1;


}
int main(){
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        int i,j,k;
        int n;
        s(n);
        ll power=1;
        f(i,1,n+1){
            power *=i;
            power %=MOD;
        }
        printf("%lld\n",power );

}

          

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define ll long long

int main() {
    bool a[15];
    memset(a,true,sizeof(a));
    int n,d,x;
    cin>>n>>d;
    lp(i,d){
        cin>>x;
        a[x]=false;
    }
    for(int i=n; ; i++){
        bool flag=true;
        int k=i;
        while(k!=0){
            int t=k%10;
            if(a[t]==false){
                flag=false;
                break;
            }
            k/=10;
        }
        if(flag){
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long t = 4;
        boolean istrue = false;
        long ans;
        for(long i=1;i<=3500;i++){
            for(long j=1;j<=3500;j++){
                if((t*i-n)*j - n*i>0) {
                    ans = (n * i * j) / ((t * i - n) * j - n * i);
                    if (ans > 0 && (n * i * j) % ((t * i - n) * j - n * i) == 0) {
                        System.out.println(i + " " + j + " " + ans);
                        istrue = true;
                        break;
                    }
                }

            }
            if(istrue == true) break;
        }

    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
typedef long long ll;

int main(){
  int k, x;
  cin >> k >> x;
  if(k*500>=x){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 3564
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 13;
int n,m,x;
int cost[MAXN],A[MAXN][MAXN],le[MAXN];
const int INF= 0x3f3f3f3f;
int solve(int msk){
    int cst = 0;
    memset(le,0,sizeof(le));
    for(int i = 0; i < n; ++i){
        if(msk&(1<<i)){
            cst += cost[i];
            for(int j = 1; j <= m; j++) le[j] += A[i][j];
        }
    }
    for(int i = 1; i <= m; i++) if(le[i]<x) return INF;
    return cst;
}
int main(){
    ____();
    cin >> n >> m >> x;
    for(int i = 0; i < n; i++){
        cin >> cost[i];
        for(int j = 1; j <= m; j++) cin >> A[i][j];
    }
    int ret = INF;
    for(int msk = 1; msk < (1<<n); msk++) ret = min(ret,solve(msk));
    if(ret==INF) ret = -1;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>

using namespace std;
const int maxn = 1e5 + 30;
int a[maxn];

int main(){
  int n; cin >> n;
  int x; cin >> x;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  long long ans = 0;
  for(int i=0;i<n-1;i++){
    if(a[i] + a[i+1] > x){
      ans += a[i] + a[i+1] - x;
      a[i+1] -= (a[i] + a[i+1] - x);
      if(a[i+1] < 0) a[i+1] = 0;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        int len=S.length();
        int[] num=new int[len];
        
        for(int i=0;i<len;i++){
            num[i]=Character.getNumericValue(S.charAt(i));
        }
        
        int[] mod=new int[len];
        mod[len-1]=1;
        
        for(int i=len-1;i>=1;i--){
            mod[i-1]=(mod[i]*10)%2019;
        }
        
        int[] U=new int[len+1];
        U[len-1]=num[len-1];
        U[len]=0;
        
        for(int i=len-1;i>=1;i--){
            U[i-1]=(U[i]+num[i-1]*mod[i-1])%2019;
        }
        
        Arrays.sort(U);
        int count=1;
        long ans=0;
        
        for(int i=0;i<len;i++){
            if(U[i]==U[i+1]){
                count++;
            }else{
                ans+=(count*(count-1))/2;
                count=1;
            }
        }
        
        ans+=(count*(count-1))/2;
        System.out.println(ans);
    }
}


Measured memory_bytes: 43064
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n,i;
	cin >> n;
	long a[n+1];
	for(i=0;i<n;i++){
		cin >> a[i];	
	}
	sort(a, a+n);
	cout << a[n-1]-a[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int n , v[20];

map<int,int> memo[20];

int f(int pos , int sum){
	return pos == n ? abs(sum) : memo[pos].count(sum) ? memo[pos][sum] : memo[pos][sum] = min( f(pos+1,sum+v[pos] ) , f(pos+1,abs(sum-v[pos])) );
}

int main(){
	while(cin >> n && n){
		for(int i = 0 ; i < n ; i++) cin >> v[i] , memo[i].clear() ;
		cout << f(0,0) << endl;
	}
}

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

int main(){
  int n;
  cin >> n;
  int human[n][n];
  rep(i,n){
      cin >> human[i][0] >> human[i][1];
  }
  
  int sum = 0;
  for(int i=0; i < n; i++){
    sum += (human[i][1]-human[i][0]) + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
using namespace std;

int main() {
	string r, a;
	while(cin >> r >> a, 1){
		if( r == "0" && a == "0") break;
		int hit = 0, blow = 0;
		for(int i=0; i < 4; i++){
            for(int j=0; j<4; j++){
                if(r[i] == a[j]){
                    if(i == j){
                        hit++;
                    }else{
                        blow++;
                	}
                }
            }
        }
        cout << hit << " " << blow << endl;
	}
	return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long 

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);

    const int dx[] = {1,1,0,-1,-1,-1,0,+1};
    const int dy[] = {0,1,1,1,0,-1,-1,-1};

    for(int i=0; i<h; ++i)
        cin >> s[i];

    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            if(s[i][j]=='#'){
                cout << "#";
                continue;
            }

            int ans=0;
            for(int k=0; k<8; ++k){
                int nx = i+dx[k];
                int ny = j+dy[k];

                if(nx<0 || nx>=h || ny<0 || ny>=w)
                    continue;
                
                if(s[nx][ny] == '#')
                    ans++;
            }
            cout << ans;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int a[N], dp[N];

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, i;
	cin>>n;
	for(i=0; i<n; i++){
		cin>>a[i];
	}
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for(i=2; i<n; i++){
		dp[i] = min(dp[i-2] + abs(a[i] - a[i-2]), dp[i-1] + abs(a[i] - a[i-1]));		
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#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 sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define whatIs(x) cout<<#x<<" is "<<x<<endl;
#define fillA(a,value) memset(a,value,sizeof(a));
#define len(s) s.length()
#define reached cout<<"reached "<<endl;
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define prq priority_queue<int>
#define mii map<int,int>
#define msi multiset<int>
#define nl "\n"
#define sii set<int,int>
#define sz size

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	int a,b,c;
	cin>>a>>b>>c;
	if(c<=b&&c>=a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
s=[input() for _ in range(h)]
dp=[[10**9]*w for _ in range(h)]
dp[0][0]=(s[0][0]=='#')+0


for i in range(h):
    for j in range(w):
        a = dp[i-1][j]
        b = dp[i][j-1]
        if s[i-1][j] == "." and s[i][j] == "#":
            a += 1
        if s[i][j-1] == "." and s[i][j] == "#":
            b += 1
        # print(i, j, a, b, dp[i][j])
        dp[i][j] = min(a, b, dp[i][j])
        

print(dp[-1][-1])



Measured memory_bytes: 9268
#include <bits/stdc++.h>
#define pb push_back
#define tam 100000
#define se second
#define fi first
#define pitem item*
#define forr(i,p,n) for(ll i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
typedef vector<vector<ll> > vvi;
typedef  double lld;
int main()
{
    int N;
    int i=1,tot=0;
    cin>>N;
    while(tot+i<=N)
    {
        tot+=i;
        i++;
    }
    if (tot==N)
        cout<<i-1<<endl;
    else
        cout<<i<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
lamps = [list(map(lambda x: int(x) - 1, input().split()))[1:] for _ in range(M)]

p = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    for r in range(M):
        on_sum = 0
        for j in range(N):
            if (i >> j) & 1 and j in lamps[r]:
                on_sum += 1
        if on_sum % 2 != p[r]:
            break
    else:
        ans += 1
print(ans)




Measured memory_bytes: 9064
import sys
N = int(input())
for h in range(1,3501):
    for n in range(h,3501):
        if (4*h*n - N*n - N*h) > 0:
            w = N*h*n//(4*h*n - N*n - N*h)
        else: continue
    
        if w != 0 and 4/N == (1/h + 1/n + 1/w):
            print(h, n, w)
            sys.exit()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  int a = (N+999)/1000;
  fin(a*1000 - N);
  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI X(N),Y(N);
  rep(i,N) cin>>X[i]>>Y[i];
  double sum=0;
  rep(i,N) rep(j,N){
    if(i!=j){
      sum+=sqrt((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]));
    }
  }
  sum/=double(N);
  cout.precision(10);
  cout<<sum<<endl;
}

Measured memory_bytes: 256
using System;
class AOJ2001
{
    static void Main()
    {
        while(true){
            string[] inputbase=Console.ReadLine().Split(' ');
            if(inputbase[0]=="0"&&inputbase[1]=="0"&&inputbase[2]=="0")break;
            int n=int.Parse(inputbase[0]);
            int m=int.Parse(inputbase[1]);
            int a=int.Parse(inputbase[2]);
            int[,] amida=new int[1000,n];
            for(int i=0;i<m;i++){
                string[]inputhr=Console.ReadLine().Split(' ');
                int h=int.Parse(inputhr[0])-1;
                int p=int.Parse(inputhr[1]);
                int q=int.Parse(inputhr[2]);
                amida[h,p-1]=q;
                amida[h,q-1]=p;
            }
            for(int i=999;i>=0;i--){
                int lookup=amida[i,a-1];
                if(lookup!=0)a=lookup;
            }
            Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 7184
n, h = gets.split.map(&:to_i)

a = []
b = []

n.times do |i|
  a[i], b[i] = gets.split.map(&:to_i)
end

amax = a.max
bb = b.select{|i|i>amax}
bb.sort_by!{|i|-i}

atk = 0
bb.each do |thw|
    atk += 1
    h   -= thw
    break if h <= 0 
end

atk += Rational(h, amax).ceil if h > 0

p atk


Measured memory_bytes: 7396
from math import factorial


def cmb(n, r):
    if n-r < 0 or r < 0:
        return 0
    else:
        return factorial(n) // (factorial(r) * factorial(n - r))


def solve(n, k):
    if k < 0:
        return 0

    if n == [] or sum(n) == 0:
        if k == 0:
            return 1
        else:
            return 0

    for i in range(len(n)):
        if n[i] != 0:
            break

    n = n[i:]

    l = len(n)
    ans = 0

    # n-1桁からKこ取る
    tmp1 = (9**k)*cmb(l-1, k)

    # 最上位から1つ（最上位の数以外）とる。
    tmp2 = (n[0]-1)*(9**(k-1))*cmb(l-1, k-1)

    # 最上位からその数をとる。
    tmp3 = solve(n[1:], k-1)

    ans = tmp1 + tmp2 + tmp3
    return int(ans)


n = list(map(int, input()))
k = int(input())

print(solve(n, k))


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > A(n, vector<int>(m));
  vector<int> b(m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> A.at(i).at(j);
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> b.at(i);
  }

  vector<int> c(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      c.at(i) += A.at(i).at(j) * b.at(j);
    }
  }

  for (int i = 0; i < n; ++i) {
    cout << c.at(i) << endl;
  }

  return 0;
}


Measured memory_bytes: 3180
a, b, c, x, y = map(int, input().split())

ans = 0
if a+b > c*2:
    xy = max(x, y)-abs(x-y)
    ans = c*xy*2
    x -= xy
    y -= xy
    if a <= c*2 and b <= c*2:
        ans += a*x+b*y
    elif a > c*2 and x > 0:
        ans += c*x*2
        y -= x
        if y > 1:
            ans += b*y
    else:
        ans += c*y*2
        x -= y
        if x > 1:
            ans += a*x
else:
    ans = a*x+b*y

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;

bool ok(int node, vector<bool> used, vector<int> G[]) {
    bool flg = true;
    for (int to : G[node]) {
        if (used[to])continue;
        flg = false;
        break;
    }
    return flg;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> G[100010];
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    deque<int> dq;
    vector<bool> used(N, false);
    dq.push_back(0);
    used[0] = true;
    for (int to : G[0]) {
        if (used[to])continue;
        dq.push_back(to);
        used[to] = true;
        break;
    }

    while (true) {
        if (ok(dq.front(), used, G))break;
        for (int to : G[dq.front()]) {
            if (used[to])continue;
            dq.push_front(to);
            used[to] = true;
            break;
        }
    }

    while (true) {
        if (ok(dq.back(), used, G))break;
        for (int to : G[dq.back()]) {
            if (used[to])continue;
            dq.push_back(to);
            used[to] = true;
            break;
        }
    }

    cout << dq.size() << endl;
    for (auto i = dq.begin(); i != dq.end(); i++) {
        if (i == dq.begin())cout << *i + 1;
        else cout << " " << *i + 1;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 6784
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    string s; cin >> s;
    int c = 0;
    rep(i, s.size()) {
        if (i % 2 == 0) { //g
            if (s[i] == 'p') {
                c--;
            }
        } else {
            if (s[i] == 'g') {
                c++;
            }
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e18 + 7;


int main (){
    int a, b, c;
    cin >>a >> b >> c;

    cout << max(0, c -(a - b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main() {
   ll n,i,l,s=0; vector<ll>a; cin>>n;
   for(i=0;i<n;i++) {cin>>l; a.pb(l); }
   sort(a.begin(),a.end(),greater<int>());
   for(i=0;i<n-1;i++)
   { s+=a[(i+1)/2];}
   cout<<s;
	return 0;
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin >> s>>t;
	int count=0,m=1001;
	for(int i=0;i<s.length()-t.length()+1;i++){
		count=t.length();
		for(int j=0;j<t.length();j++){
			if(s[i+j]==t[j])count--;
		}
		m=min(m,count);
	}
	cout << m;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>

#ifdef DONLINE_JUDGE
//freopen("a.in", "r", stdin);
//freopen("a.out","w",stdout); // console output is better (in most cases)
#else
// add i/o method of specific testing system
#endif

using namespace std;

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

    int n;
    cin >> n;
    int min_a = 1000000, max_a = -1000000;
    long long sum = 0;
    for (int i = 0; i < n; ++i)
    {
        int k;
        cin >> k;
        min_a = min(min_a, k);
        max_a = max(max_a, k);
        sum += k;
    }
    cout << min_a << " " << max_a << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3208
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		String t = sc.next();
		int sn = sc.nextInt();
		int tn = sc.nextInt();
		String u = sc.next();
		
		// 計算
		//int result = 0;
		if(u.equals(s)){
		    sn--;
		}else{
		    tn--;
		}
		
		// 出力
		System.out.println(sn + " " + tn);
	}
}



Measured memory_bytes: 24020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str1,str2;
    cin>>str1;
    cin>>str2;
    int n = str1.size();
    int m = str2.size();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0 || j==0)
                dp[i][j] = 0;
            else
            {
                if(str1[i-1] == str2[j-1])
                    dp[i][j] = dp[i-1][j-1] + 1;
                else
                {
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }    
    }
    string ans = "";
	int i = n,j = m;
 
	while(i > 0 && j> 0)
	{
	    if(str1[i-1] == str2[j-1])
	    {
	        ans = ans + str1[i-1];
	        i--;
	        j--;
	    }
	    else
	    {
	        if(dp[i-1][j]>dp[i][j-1])
	        {
	            i = i-1;
	        }
	        else
	        {
	            j = j-1;
	        }
	    }
	}
 
	reverse(ans.begin(),ans.end());
	cout<<ans;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, x;
  cin >> N;
  x = N /100 % 10;
  
  if(N <= x * 111) cout << x * 111 << endl;
  else cout << (x * 111) + 111 << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
#define ull unsigned long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>

using pint  = pair<int, int>;
using plint = pair<ll, ll>;

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rrep1(i, n) for (int i = ((int)(n)); i > 0; --i)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back

// template<class T>bool maxc(T &a, const T &b) { if (a<b) { a=b; return 1; } }
// template<class T>bool minc(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;

    // 処理
    int    cnt = 0;
    string s0  = "CODEFESTIVAL2016";
    rep(i, sz(s)) {
        if (s0[i] != s[i]) {
            cnt++;
        }
    }

    // 出力
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0) break;
    n++;
    int a[101];
    for(int i = 0;i < n;i++) cin >> a[i];

    bool flag = false;
    for(int i = 0;i < n;i++){
      int j = 0;
      bool flag = false;
      while(1){
        int tmp,tmp1,tmp2;
        tmp = i != j ? j : j+1;
        tmp1 = tmp+1 != i ? tmp + 1 : tmp + 2;
        tmp2 = tmp1+1 != i ? tmp1 + 1 : tmp1 + 2;
        if(a[tmp2] - a[tmp1] != a[tmp1]-a[tmp]){
          break;
        }
        if(i < n-1 && tmp2 == n-1 || i == n-1 && tmp2 == n-2 ){
          flag = true;
          break;
        }
        j++;
      }
      if(flag){
        cout << a[i] << endl;
        break;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3084
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0], 10);
  var ints = input[1].split(" ").map((n) => parseInt(n, 10));

  var mean = 0;
  var ans = 0;
  for (var i = 0; i < N; i++) {
    mean += ints[i];
  }
  mean = Math.round(mean / N);

  for (var i = 0; i < N; i++) {
    var int = Math.abs(mean - ints[i]);
    var pow = Math.pow(int, 2);
    ans += pow;
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
N,W = map(int, input().split())
DP = [[0 for j in range(W+1)] for i in range(N+1)]
v = [0]*(N+1)
wt = [0]*(N+1)
for i in range(1,N+1):
    v[i], wt[i] = map(int, input().split())
for i in range(1,N+1):
    for j in range(W+1):
        if j-wt[i]<0:
            DP[i][j] = DP [i-1][j]
        else:
            DP[i][j] = max(DP[i-1][j], v[i]+DP[i-1][j-wt[i]])
print(DP[N][W])


Measured memory_bytes: 25940
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int A[N], B[N], C[N - 1];
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        --a;
        A[i] = a;
    }
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < N - 1; i++)
    {
        cin >> C[i];
    }
    int ans = 0;
    int prev = -100;
    for (int i = 0; i < N; i++)
    {
        if (prev + 1 == A[i])
        {
            ans += C[prev];
        }
        prev = A[i];
        ans += B[prev];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll K, S;
  cin >> K >> S;

  ll ans = 0;

  rep(x, K + 1){
    if(x > S) break;
    
    rep(y, K + 1){
      if(x + y > S) break;

      if(S - x - y <= K) ans++;
    }
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double x;
  static const double pi = 3.141592653589793;
  double rad_b, rad_a, rad;
  rad_b = pi * M / 30;
  rad_a = pi * H / 6 + pi * M / 360;
  if (rad_a > rad_b) {
    rad = rad_a - rad_b;
  }
  else {
    rad = rad_b - rad_a;
  }
  if (rad > pi) {
    rad = 2 * pi - rad;
  }
  double x_2;
  x_2 = A * A + B * B - 2 * A * B * cos(rad);
  x = sqrt(x_2);
  cout << fixed << setprecision(12) << x <<endl;
}

Measured memory_bytes: 4224
#pragma comment(linker, "/STACK:36777216")

#include <bits/stdc++.h>
using namespace std;
#define LSON            id << 1 , l , mid
#define RSON            id << 1 | 1 , mid + 1 , r
#define ROOT            1 , 1 , n
#define CLR(x , y)      memset(x , y , sizeof(x))
#define LOWBIT(x)       x & (-x)
#define FORN(i , a , n)  for(int i = (a) ; i <= (n) ; ++i)
#define FORP(i , n , a)  for(int i = (n) ; i >= (a) ; --i)
#define CASE(x)		printf("Case %d: ", x)
#define SFD(x)      scanf("%lf" , &x)
#define SFC(x)      scanf(" %c" , &x)
#define SFS(x)      scanf(" %s" , x)
#define SFI(x)      scanf("%d" , &x)
#define SFL(x)      scanf("%lld" , &x)
#define SFI64(x)    scanf("%I64d" , &x)
#define PFF(x)         printf("%f" , x)
#define PFD(x)         printf("%lf" , x)
#define PFI(x)         printf("%d" , x)
#define PFC(x)         printf("%c" , x)
#define PFS(x)         printf("%s" , x)
#define PFI64(x)       printf("%I64d" , x)
#define PFL(x)         printf("%lld" , x)
#define SPACE          printf(" ")
#define PUT            puts("")
#define LPUP(i , j , k) for(int i = j ; i <= k ; ++i)
#define LPDW(i , j , k) for(int i = j ; i >= k ; --i)
#define PB(x)          push_back(x)
#define ALL(A)         A.begin(), A.end()
#define SZ(A)          int((A).size())
#define LBD(A, x)      (lower_bound(ALL(A), x) - A.begin())
#define UBD(A, x)      (upper_bound(ALL(A), x) - A.begin())
#define LOCAL
static const double PI = acos(-1.0);
static const double EPS = 1e-8;
static const int INF = 0X3fffffff;
typedef long long LL;
typedef double DB;
template<class T> inline
T read(T &x)
{
    x = 0;
    int f = 1 ; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    x *= f;
}

/************************Little Pea****************************/


int main()
{
#ifndef ONLINE_JUDGE
    //freopen("D:\\系统优化\\Desktop\\littlepea\\in.data" , "r" , stdin);
#endif
    char a[20] , b[20] , c[20];
    SFS(a + 1);SFS(b + 1);SFS(c + 1);
    int la = strlen(a + 1);int lb = strlen(b + 1);int lc = strlen(c + 1);
    if(a[la] == b[1] && b[lb] == c[1])
        puts("YES");
    else
        puts("NO");

#ifndef ONLINE_JUDGE
    fclose(stdin), fclose(stdout);
#endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main() {

	int k;cin >> k;
	long long ans{0};
	for(int i = 1;i <= k; ++i)
		for(int j = 1;j <= k; ++j)
			for(int l=1;l <= k; ++l)
				ans += (long long)gcd(i, gcd(j, l));

	cout << ans;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int s[N], sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    sum += s[i];
  }
  if (sum%10) {
    cout << sum;
  } else {
  	sort(s,s+N);
    for (int i = 0; i < N; i++) {
      if (s[i]%10) {
        cout << sum-s[i];
        return 0;
      }
    }
    cout << 0;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;

typedef long long ll;

int main()
{
    ll N, X, Y;
    cin >> N >> X >> Y;

    ll *O = new ll [N];
    for(ll k=0; k<N; k++)
    {
        O[k] = 0;
    }

    for(int i=1; i<=N; i++)
    {
        for(int j=i+1; j<=N; j++)
        {
            ll d = j - i;
            if(i <= X)
            {
                if(Y <= j)
                {
                    d = j - i - (Y - X) + 1;
                }
                else if((X+Y) / 2 < j)
                {
                    d = X - i + (Y - j) + 1;
                }
            }
            else if(i < (X+Y) / 2)
            {
                if(Y <= j)
                {
                    d = j - Y + (i -X) + 1;
                }
            }

            if(X<=i && i<=Y && X<=j && j<=Y )
            {
                ll d0 = (i - X) + (Y - j) + 1;
                if(d0 < d)
                {
                    d = d0;
                    //cout << "#" << d0 << endl;
                }
            }
            //cout << i << "," << j << "," << d << endl;
            O[d]++;
        }   
    }

    //出力
    for(ll k=1; k<N; k++)
    {
        cout << O[k] << endl;
    }

    delete [] O;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(void) {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N, 0);

  for (long long i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (long long i = 0; i < K; i++) {
    vector<long long> imos(N + 1, 0);
    for (long long j = 0; j < N; j++) {
      imos[max(0LL, j - A[j])]++;
      imos[min(j + A[j] + 1, N)]--;
    }
    for (long long j = 1; j < N + 1; j++) {
      imos[j] += imos[j - 1];
    }

    bool is_same = true;
    for (long long j = 0; j < N; j++) {
      is_same &= A[j] == imos[j];
    }
    if (is_same) break;

    for (long long j = 0; j < N; j++) {
      A[j] = imos[j];
    }
  }

  for (int i = 0; i < N; i++) {
    cout << A[i] << " \n"[i == N - 1];
  }
  return 0;
}

Measured memory_bytes: 6364
/* Atcoder abc146b
 * See tasks at: https://atcoder.jp/contests/abc146/tasks/abc146_b
 */
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
int main()
{
    string s;
    int32_t n;
    cin >> n >> s;
    
    const char offset = 'A';

    for (auto& c: s)
    {
        c = ((c - offset) + n) % 26 + offset;
    }

    cout << s << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
	
	int x, y;
	cin >> x >> y;
	
	if(y%2 == 0)
	{
		if(y >= 2*x && y <= 4*x) cout << "Yes\n";
		else cout << "No\n";
	}
	else cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String x = "";
        int i;
        for (i=0;i<s.length();i++) {
            x = x + "x";
        }
        System.out.println(x);
    }
}

Measured memory_bytes: 21844
from math import gcd 
from collections import defaultdict

def to_irreducible(a, b):
    if a == 0:
        return [0, 1]
    GCD = gcd(a, b)
    return [a//GCD, b//GCD]

MOD = 10**9 + 7
N = int(input())
daiichi_dict = defaultdict(int)
daini_dict = defaultdict(int)
zero_cases = 0

for i in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero_cases += 1
    elif a * b >=0 and b != 0:
        a, b = to_irreducible(abs(a), abs(b))
        daiichi_dict[(a,b)] += 1
    else:
        a, b = to_irreducible(abs(b), abs(a))
        daini_dict[(a,b)] += 1
        daiichi_dict[(a,b)] += 0


ans = 1 
for key, value_daiichi in daiichi_dict.items():
    value_daini = daini_dict[key]
    ans *= (2**value_daiichi + 2**value_daini -1)
    ans %= MOD
print((ans+zero_cases-1) % MOD)

Measured memory_bytes: 69080
from itertools import product
import bisect

N, A, B, C = map(int, input().split()) 
tl = [C,B,A]

ll = []
for _ in range(N):
    ll.append(int(input()))



ans = 10**8
ite = product(range(4),repeat=N)
for pattern in ite:
    bag = [[],[],[]]
    singles = []
    mp = 0
    for i, p in enumerate(pattern):
        if p == 3: singles.append(ll[i])
        else: bag[p].append(ll[i])
    
    zero_cnt = 0
    for b in bag:
        if not b: zero_cnt+=1
        else: mp += (len(b)-1)*10
    if not singles: zero_cnt+=1
    if zero_cnt >= 2: continue

    bamboos = []
    for b in bag:
        if b: bamboos.append(sum(b))
    for s in singles:
        bamboos.append(s)

    bamboos.sort()
    # print(bamboos)
    
    for t in tl:
        curr_min = 10000
        curr_min_i = 0
        for i, ba in enumerate(bamboos):
            if abs(ba - t) < curr_min:
                curr_min = abs(ba-t)
                curr_min_i = i
        mp += curr_min
        bamboos.pop(curr_min_i)

    ans = min(ans,mp)

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll n,k;cin>>n>>k;
	ll cnt=(n-1)*(n-2)/2;
	if(k>cnt)cout<<-1;
	else{
		vector<pii>ans;
		rep(i,1,n)ans.pb({0,i});
		ll i=1,j=2;
		while(cnt>k){
			ans.pb({i,j});
			j++;
			if(j==n){
				i=i+1;
				j=i+1;
			}
			cnt--;
		}
		cout<<sz(ans)<<"\n";
		rep(i,0,sz(ans))cout<<ans[i].fi+1<<" "<<ans[i].se+1<<"\n";
	}
	
	
	
	return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
struct edge{
	int v,next;
};
edge e[200001];
int pos[100001];
int num=0;
void init(int x,int y){
	e[num]=(edge){y,pos[x]};
	pos[x]=num++;
}
int lj[100001];
int len=0;
bool vis[100001];
bool dfs1(int x){
	//cout<<x<<endl;
	if(x==n){
		lj[len++]=n;
		return 1;
	}
	vis[x]=1;
	for(int i=pos[x];i>=0;i=e[i].next){
		if(!vis[e[i].v]){
			if(dfs1(e[i].v)){
				lj[len++]=x;
				return 1;
			}
		}
	}
	return 0;
}
int sp[100001];
void dfs2(int x,int fa){
	sp[x]=1;
	for(int i=pos[x];i>=0;i=e[i].next){
		if(e[i].v==fa)continue;
		dfs2(e[i].v,x);
		sp[x]+=sp[e[i].v];
	}
}
int main(){
	memset(pos,-1,sizeof(pos));
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		init(x,y);
		init(y,x);
	}
	memset(vis,0,sizeof(vis));
	bool jl=dfs1(1);
	int ss=(len)/2;
	//cout<<ss<<" "<<lj[ss]<<" "<<len<<endl;
	dfs2(lj[ss],lj[ss]);
	//for(int i=1;i<=n;i++)cout<<sp[i]<<" ";
	//cout<<endl;
	int ansb=sp[lj[ss-1]],ansa=sp[lj[ss]]-sp[lj[ss-1]];
	if(ansa>ansb)cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<c-(d-b)<<' '<<d+(c-a)<<' '<<a-(d-b)<<' '<<b+(c-a)<<endl;
}


Measured memory_bytes: 256
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  10000500

ll int dp[N];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		for(ll int i = 1; i < N; i++)
		{
			for(ll int j = i; j < N; j += i)
			{
				dp[j] += j;
			}
		}
		ll int n;
		cin >> n;
		ll int ans = 0;
		for(ll int i = 1; i <= n; i++)
		{
			ans += dp[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 81776
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;



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

	ll N;
	cin >> N;

	vector<ll> A(N);
	map<ll,ll> cnt; // 数字,数字の個数

	rep(i, N) {
		cin >> A[i];
		cnt[A[i]]++;
	}

	ll count = 0;
	for (auto p : cnt) {
		count += p.second * (p.second - 1) / 2;
	}
	
	rep(i, N) {
		cout << count - (cnt[A[i]] - 1) << endl;
	}

	return 0;
}


Measured memory_bytes: 11904
N = int(input())
H = list(map(int,input().split()))
max_n = 0
count = 0

for i in range(N):
  if i > 0:
    if before >= H[i]:
      count += 1
    else:
      count = 0
  if count > max_n:
    max_n = count
  before = H[i]
print(max_n)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

int main(void){
   int s; cin >> s;
   s = s%10;
   if(s==3) cout <<"bon\n";
   else if(s==0 || s==1 || s==6
    || s==8 ) cout << "pon\n";
    else cout << "hon\n";
}

Measured memory_bytes: 3596