akhauriyash/Code-Regression huggingface dataset:
#n = int(input())
#m = int(input())
#k = int(input())
#n, m = map(int, input().split())
n,  k = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
print(n-k+1)

Measured memory_bytes: 2940
/*C - Lower*/
#include <bits/stdc++.h>
using namespace std;

int maxConsecutive(int pos, int h);

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int tam;
	int aux = 0;
	int maximo = 0;
	cin >> tam;

	vector <int> alturas(tam);

	for (int i = 0; i < tam; ++i)
	{
		cin >> alturas[i];
	}

	for (int i = 1; i < tam; ++i)
	{
		if(alturas[i] <= alturas[i - 1]){
			aux++;
		}
		else{
			aux = 0;
		}
		
		maximo = max(aux, maximo);
		//cerr << alturas[i - 1] << ' ' << alturas[i] << ' ' << aux << ' ' <<maximo << '\n';
	}

	cout << maximo;	

	return 0;
}



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

int main(){
  int N;
  cin >> N;
  
  vector<int> W(N+1);
  vector<int> sum(N+1);
  for(int i=1; i<N+1; i++){
    cin >> W.at(i);
    sum.at(i) += sum.at(i-1) + W.at(i);
  }
  
  int midi=sum.at(N);
  for(int j=0; j<N+1; j++){
    midi = min(midi, abs((sum.at(N)-sum.at(j))-sum.at(j)));
  }
  cout << midi << endl;
  return 0;
}

Measured memory_bytes: 256
h,w,a,b = gets.split.map(&:to_i)
ans = Array.new(h){[0]*w}

(0...h-b).each do |i|
  (0...a).each do |j|
    ans[i][j] = 1
  end
end

(h-b...h).each do |i|
  (a...w).each do |j|
    ans[i][j] = 1
  end
end

ans.each do |l|
  puts l.join
end

Measured memory_bytes: 12540
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int N = stdIn.nextInt();
		int A = stdIn.nextInt();
		
		System.out.println(N * N - A);

	}

}


Measured memory_bytes: 35520
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
const int mod = 1e9 + 7;



main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b > 0)
    {
        if (a * b * 4 < (c - a - b) * (c - a - b)) cout << "Yes";
        else cout << "No";
    } else cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+50,mod=1e9+7;
int x[10],y[10],J[N],I[N],ans;
int C(int n,int m){return 1ll*J[n]*I[m]%mod*I[n-m]%mod;}
int ptp(int x,int y){return C(x+y,x);}
int pts(int x1,int y1,int x2,int y2){return (0ll+ptp(x2+1,y2+1)-ptp(x1,y2+1)-ptp(x2+1,y1)+ptp(x1,y1))%mod;}
int PTS(int x,int y,int x1,int y1,int x2,int y2){
    if(x>=x2&&y>=y2)return pts(x-x2,y-y2,x-x1,y-y1);
    return pts(x1-x,y1-y,x2-x,y2-y);
}
int main(){
    J[0]=I[0]=I[1]=1;
    for(int i=2;i<N;i++)I[i]=mod-1ll*mod/i*I[mod%i]%mod;
    for(int i=1;i<N;i++)J[i]=1ll*J[i-1]*i%mod,I[i]=1ll*I[i-1]*I[i]%mod;
    for(int i=1;i<=6;i++)scanf("%d",&x[i]);
    for(int i=1;i<=6;i++)scanf("%d",&y[i]);
    for(int i=x[3];i<=x[4];i++)
        ans=(ans-1ll*PTS(i,y[3]-1,x[1],y[1],x[2],y[2])*PTS(i,y[3],x[5],y[5],x[6],y[6])%mod*(i+y[3]))%mod;
    for(int i=y[3];i<=y[4];i++)
        ans=(ans-1ll*PTS(x[3]-1,i,x[1],y[1],x[2],y[2])*PTS(x[3],i,x[5],y[5],x[6],y[6])%mod*(x[3]+i))%mod;
    for(int i=x[3];i<=x[4];i++)
        ans=(ans+1ll*PTS(i,y[4],x[1],y[1],x[2],y[2])*PTS(i,y[4]+1,x[5],y[5],x[6],y[6])%mod*(i+y[4]+1))%mod;
    for(int i=y[3];i<=y[4];i++)
        ans=(ans+1ll*PTS(x[4],i,x[1],y[1],x[2],y[2])*PTS(x[4]+1,i,x[5],y[5],x[6],y[6])%mod*(x[4]+i+1))%mod;
    cout<<(ans+mod)%mod;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll a[100010];

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

  cin>>n;
  rep(i,n)cin>>a[i];
  sort(a,a+n);

  if(n%2==0){
    ll res=0;
    rep(i,n/2){
      if(i==(n/2)-1)res-=a[i];
      else res-=a[i]*2;
    }
    repl(i,n/2,n){
      if(i==n/2)res+=a[i];
      else res+=a[i]*2;
    }
    cout<<res<<endl;
  }else{
    ll resa=0,resb=0;
    {
      rep(i,n/2){
        resa-=a[i]*2;
      }
      repl(i,n/2,n){
        if(i==n/2||i==(n/2)+1)resa+=a[i];
        else resa+=a[i]*2;
      }
    }
    {
      rep(i,(n/2)+1){
        if(i==(n/2)||i==(n/2)-1)resb-=a[i];
        else resb-=a[i]*2;
      }
      repl(i,(n/2)+1,n){
        resb+=a[i]*2;
      }
    }
    cout<<max(resa,resb)<<endl;
  }

  return 0;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  if(1<=A && A<=9 && 1<=B && B<=9){
    cout << A*B << endl;
    return 0;
  }
  cout << "-1" << endl;
  return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	int T; cin>>T;
	rep(_,T){
		vi a(10);
		rep(i,10) cin>>a[i];
		int x=0,y=0;
		bool ok=true;
		rep(i,10){
			if(min(x,y)>=a[i]){
				ok=false;
				break;
			}
			else if(x<a[i])
				x=a[i];
			else if(y<a[i])
				y=a[i];
		}
		cout<<(ok?"YES":"NO")<<endl;
	}
}

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

#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

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 n;
    ll w;
    ll we[110],va[110];
    ll dp[110][100100];
    ll vmax=0;
int main(){
    rep(i,0,110)rep(j,0,100100)dp[i][j]=INF;
    cin>>n>>w;
    rep(i,0,n){
        cin>>we[i]>>va[i];
        vmax = max(vmax,n*va[i]);
    }
    dp[0][0]=0;
    rep(i,0,n){
        rep(sumv,0,vmax+1){
            if(sumv>=va[i])chmin(dp[i+1][sumv],dp[i][sumv-va[i]]+we[i]);
        chmin(dp[i+1][sumv],dp[i][sumv]);
        }
    }
    ll ans=0;
    rep(sumv,0,vmax+1){
        if(dp[n][sumv]<=w)ans=sumv;
    }
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 86272
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int n, m,a;
string s;

int main() {
	cin >> n >> m >> a;
	if (n!=m)
	{
		cout << "No" << endl;
		return 0;
	}
	if (m!=a)
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}



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

typedef long long ll;

int main() {
    //dp[i + 1][j] A[i]までで和がjにできるような場合の数
    ll N, S, MOD = 998244353;
    cin >> N >> S;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<vector<ll>> dp(N + 1, vector<ll>(3001, 0));
    rep(i, N) {
        dp[i + 1][A[i]] += i + 1;
        dp[i + 1][A[i]] %= MOD;
        rep(j, S + 1) {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= MOD;
            if (j + A[i] <= S) {
                dp[i + 1][j + A[i]] += dp[i][j];
                dp[i + 1][j + A[i]] %= MOD;
            }
        }
    }
    int ans = 0;
    rep(i, N + 1) {
        ans += dp[i][S];
        ans %= MOD;
    }
    cout << ans << "\n";
    /*
    rep(i, N + 1) {
        rep(j, S + 1) {
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }
    */
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

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

    if (a <= b)
        cout << a << endl;
    else
        cout << a - 1 << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)

int main(){
	ll n;
	cin>>n;
	vector<ll> v;
	v.push_back(1);
	for(ll i=6;i<=n;i*=6)v.push_back(i);
	for(ll i=9;i<=n;i*=9)v.push_back(i);
	ll dp[100100];
    fill(dp, dp+n+1, inf);
	dp[0]=0;
	rep(i,0,n+1){
		rep(j,0,v.size()){
			if(i>=v[j]){
				dp[i]=min(dp[i],dp[i-v[j]]+1);
			}
		}
	}
	cout<<dp[n]<<endl;
				
}

Measured memory_bytes: 1024
n, k = map(int, input().split())

if n < abs(n-k):
    pass

elif n > k:
    a = n // k
    n = n - a*k
    while abs(n-k) <= n:
        n = abs(n-k)

else:
    while abs(n-k) <= n:
        n = abs(n-k)


print(n)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
  int a, b, i, N, mina=0, minb;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d %d",&a,&b);
    if(mina<a){mina=a;  minb=b;}
    //printf("%d %d\n",mina, minb);
  }
  printf("%d\n",mina+minb);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
 
int main()
{
     long double i,j,n,m,k,l;
    
    string st="ABC";
    string ss="ARC";
    string s;
    
    cin>>s;
    if(s==st)cout<<ss;
    else cout<<st;
    
    
	return 0;
}

Measured memory_bytes: 3576
/* Author - xorier4104 */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define MOD 			(int) 1e9+7
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define mem(a,b)        memset(a,(b),sizeof(a))
#define max(a,b)        ((a)>(b) ? (a):(b))
#define min(a,b)        ((a)<(b) ? (a):(b))
#define abs(a)          ((a)>0 ? (a):(-(a)))
#define sq(a) 			((a)*(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)

int main(){ FastIO;

	int n,m;

		cin>>n>>m;
		int a[m];
		int sum=0;
		for(int i=0;i<m;i++){
			cin>>a[i];
			sum+=a[i];
		}
		if(n>=sum){
			cout<<n-sum<<endl;
		}
		else cout<<"-1"<<endl;

return 0;	
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pint;

int main()
{
    int N; cin>>N;
    vector<vector<int>> a(N,vector<int>(N-1));

    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin>>a[i][j];
            a[i][j]--;
        }
        reverse(a[i].begin(),a[i].end());
    }

    set<pint> st;
    for(int i=0;i<N;i++){
        int j=a[i].back();
        if(a[j].back()==i){
            st.insert({min(i,j),max(i,j)});
        }
    }

    int ans=0;
    while(!st.empty()){
        ans++;
        set<pint> st2;
        for(pint p:st){
            int i=p.first;
            int j=p.second;

            a[i].pop_back();
            a[j].pop_back();

            if(!a[i].empty()){
                int k=a[i].back();
                if(a[k].back()==i){
                    st2.insert({min(i,k),max(i,k)});
                }
            }
            
            if(!a[j].empty()){
                int k=a[j].back();
                if(a[k].back()==j){
                    st2.insert({min(j,k),max(j,k)});
                }
            }
        }
        swap(st,st2);

        /*
        for(int i=0;i<N;i++){
            cout<<i+1<<":";
            for(int x:a[i]) cout<<x+1<<' '; cout<<endl;
        }
        cout<<"-------------"<<endl;
        */
    }

    for(int i=0;i<N;i++) if(!a[i].empty()){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4224
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

vector<ll> solve(vector<ll> &a){
    ll n = a.size();
    vector<ll> basis;
    rrep(i,n,0){
        for(auto &x : basis) chmin(a[i], a[i] ^ x);
        if(a[i]){
            basis.emplace_back(a[i]);
        }

    }
    return basis;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum ^= a[i];
    }
    vector<ll> a2(n);
    const ll LOG = 64;
    rep(j,0,LOG){
        ll cnt = 0;
        rep(i,0,n) if((a[i] >> j) & 1) cnt++;
        if(cnt == 0 || (cnt & 1))continue;
        rep(i,0,n){
            a2[i] ^= (((a[i] >> j) & 1) << j);
        }
    }
    auto b = solve(a2);
    ll ans = 0;
    for(auto &v: b){
        chmax(ans, ans ^ v);
    }
    debug(ans, a2, b);
    cout << ans + (sum ^ ans) << endl;
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
#define int long long
#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++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    int a = 0, b = 0;
    while (prev_permutation(p.begin(),p.end())) a++;
    while (prev_permutation(q.begin(),q.end())) b++;
    cout << abs(a - b) << endl;
    return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mod 998244353
#define MN 205
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
struct st{
	int x,y;
}a[MN];
int pw[MN],n,sum,res;
inline bool cmp(st a,st b){
	return (a.x==b.x)?a.y<b.y:a.x<b.x; 
}
int main()
{
	n=in();pw[0]=1;
	for (int i=1;i<=n;++i) pw[i]=(pw[i-1]<<1)%mod; 
	for (int i=1;i<=n;++i) a[i].x=in(),a[i].y=in();
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;++i)
	for (int j=i+1;j<=n;++j){
		int cnt=0,tmp;
		for (int k=j+1;k<=n;++k)
		if ((1ll*(a[k].x-a[i].x)*(a[j].y-a[i].y))==(1ll*(a[j].x-a[i].x)*(a[k].y-a[i].y))) ++cnt;
		res=(res+pw[cnt])%mod;
	}
	sum=(pw[n]+mod-n-1)%mod;sum=(sum+mod-res)%mod;
	printf("%d",sum);return 0;
}

Measured memory_bytes: 128
const min = -150;
const max = 150;
const m = {};
for (let i = min; i <= max; i++) {
    m[i] = i**5;
}
// console.log(m);

const ans = {};
for (let i = min; i <= max; i++) {
    for (let k = min; k <= max; k++) {
        ans[m[i] - m[k]] = [i, k];
}
}

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const X = +lines[0];
// console.log(X);
console.log(`${ans[X][0]} ${ans[X][1]}`);


Measured memory_bytes: 47388
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
// #pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#define M 1000000007
#define U 998244353
#define N 1000005
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
ll dp[1<<21];
ll ndp[1<<21];
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		cin >> n;
		bool a[n+1][n+1];
		rep(i,1,n+1){
			rep(j,1,n+1) cin >> a[i][j];
		}
		dp[0] = 1;
		// rep(i,0,1<<n) dp[i] = 0;
		rep(i,0,1<<n){
			rep(j,0,n){
				if(!(i&(1<<j)) && a[__builtin_popcount(i)+1][j+1]){
					dp[i^(1<<j)] = (dp[i^(1<<j)]+dp[i])%M;
				}
			}
		}
		// trace(dp[7][2]);
		cout<<dp[(1<<n)-1]%M;
	}
}


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

int main() {
    string s; cin >> s;
    vector<bool> angle(4);
    for (int i=0; i<s.size(); ++i) {
        if (s[i] == 'E') angle[0] = true;
        if (s[i] == 'W') angle[1] = true;
        if (s[i] == 'N') angle[2] = true;
        if (s[i] == 'S') angle[3] = true;
    }
    bool ans = true;
    if ((angle[0] != angle[1]) || (angle[2] != angle[3])) ans = false;
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
var a:Array[1..3,1..3]of Longint;
i,j:Longint;
begin
for i:=1 to 3 do for j:=1 to 3 do read(a[i,j]);
if(a[1,2]-a[1,1]=a[2,2]-a[2,1])and(a[1,2]-a[1,1]=a[3,2]-a[3,1])and(a[1,2]-a[1,3]=a[2,2]-a[2,3])and(a[1,2]-a[1,3]=a[3,2]-a[3,3])then writeln('Yes')else writeln('No');
end.

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

//PwoerSoket

int main(){
	int a=0,b=0,ans=0;

	cin>>a;
	cin>>b;

	for(int i=1;i<=10000;i++){
		if(b==1){
			ans=0;
		}
		else if((a*i)-(i-1)>=b) {
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(n):
    hidari = s[:i]
    migi = s[i:]
    count = 0
    alist = []
    for j in hidari:
        if (j in migi) and (j not in alist):
            count += 1
            alist.append(j)          
    if count > ans:
        ans = count
print(ans)    

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

int main() {
  long long A, B, C;
  cin >> A >> B >> C;
  long long res = 1000000000;
  for (long long i = 0; i < 10000000; i++){
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1){
      res = i;
      break;
    }
    long long A_ = (B + C) / 2;
    long long B_ = (A + C) / 2;
    long long C_ = (A + B) / 2;
    A = A_;
    B = B_;
    C = C_;
  }
  if (res != 1000000000) cout << res << endl;
  else cout << -1 << endl;
}

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

using namespace std;


int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < m; i++) {
        cin >> b[i];
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int counter = c;
        for(int j = 0; j < m; j++) {
            counter += a[i][j] * b[j];
        }
        if(counter > 0) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    LL n,k;
    cin >> n >> k;
    LL ans = 0;
    if (k == 0) {
        ans = n * n;
        cout << ans << endl;
        return 0;
    }
    for (LL b = k+1; b <= n; b++) {
        ans += (n/b)*(b-k);
        ans += max(n%b+1-k,LL(0));
    }
    cout << ans << endl;
    return 0;
}


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

int main() { 
  string a;
  cin >> a;
  if (a == "a" || a == "i" || a == "u" || a == "e" || a == "o") {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n,k;
    cin>>n>>k;

    int cnt = 0;
    while( n )
    {
        cnt++;
        n /= k;
    }
    cout<<cnt,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e12)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ 
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

int n, a, b, c, d;
map<int, int> dp;

bool check(int x){
    return (inf/d) > x;
}

int fun(int x){

    if(x == 0)return 0;
    if(x == 1)return d;
    if(dp.count(x) != 0)return dp[x];

    dp[x] = inf;
    if(check(x))dp[x] = x*d;
     
    int tmp = inf;
    if(check(x-x/2))tmp = d*(x-x/2);
    dp[x] = min(dp[x], fun(x/2)+min(a+(x-x/2*2)*d, tmp));
    if(x != 2)
    dp[x] = min(dp[x], fun(x/2+1)+min(a+abs(x-(x/2+1)*2)*d, tmp));

    tmp = inf;
    if(check(x-x/3))tmp = d*(x-x/3);
    dp[x] = min(dp[x], fun(x/3)+min(b+(x-x/3*3)*d, tmp));
    dp[x] = min(dp[x], fun(x/3+1)+min(b+((x/3+1)*3-x)*d, tmp));

    if(check(x-x/5))tmp = d*(x-x/5);
    dp[x] = min(dp[x], fun(x/5)+min(c+(x-x/5*5)*d, tmp));
    dp[x] = min(dp[x], fun(x/5+1)+min(c+((x/5+1)*5-x)*d, tmp));

    return dp[x];
}

void solve() {
    cin >> n >> a >> b >> c >> d;
    int ans = inf;
    if(check(n))ans = n*d;
    //cout << ans << endl;
    ans = min(ans, fun(n));
    cout << ans << endl;
    dp.clear();
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

  
   
    cin >> t;
    
    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


Measured memory_bytes: 4756
#!/usr/bin/env python3

def main():
    A, B = map(int, open(0).read().split())

    if (A - B) % 2 == 0:
        if A > B:
            print(A - int(abs(A - B) / 2))
        else:
            print(B - int(abs(A - B) / 2))
    else:
        print('IMPOSSIBLE')


main()

Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline int Pow(int a,int b){return b?Pow(a*a,b>>1)*(b&1?a:1):1;}
int main()
{
  int N,now,len=0,A[531441],B[531441];
  char T[200001],S[200001];
  now=scanf("%d %s",&N,T);len=strlen(T);fflush(stdin);
  int pw3=Pow(3,N),x=Pow(3,N>>1),y=Pow(3,N-(N>>1));
  rep(i,pw3)B[i]=B[i/3]*3+(3-i%3)%3;
  rep(i,x)
  {
    int temp=i;now=0;
    rep(j,len)
    {
      if(T[j]=='S'){temp=B[temp];if(S[now]=='S')--now;else S[++now]='S';}
      else{++temp;if(temp==x)S[++now]='R',temp=0;}
    }
    rep(j,y)
    {
      int keep=j;
      rep(k,now)
      {
        if(S[k+1]=='S')keep=B[keep];
        else if(S[k+1]=='R')if((++keep)==y)keep=0;
      }
      A[i+j*x]=temp+keep*x;
    }
  }
  rep(i,pw3)printf("%d%c",A[i],i+1==pw3?'\n':' ');
  return fflush(stdout),0;
}

Measured memory_bytes: 8260
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        400005
#define mod         1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,mx=0;
    cin>>n;
    ll a[n],b[n],c[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        b[i]=a[i];
        c[i]=a[i];
    }
    for(i=1;i<n;i++){
        b[i]=__gcd(b[i-1],b[i]);
    }
    for(i=n-2;i>=0;i--){
        c[i]=__gcd(c[i],c[i+1]);
    }
    mx=max(c[1],b[n-2]);
    for(i=1;i<n-1;i++){
        mx=max({mx,__gcd(b[i-1],c[i+1])});
    }
    cout<<mx;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N,A;
  cin >> N >> A;

  vector<int> X(N+1);
  for(int i = 1;i <= N;i++) {
    cin >> X.at(i);
  }

  long long dp[55][55][2510] = {};
  

  dp[0][0][0] = 1;
  for(int i = 1;i <= N;i++) {
    for(int j = 0;j <= N;j++) {
      for(int k = 0;k < 2510;k++) {
        if(k >= X.at(i)&&j>=1) dp[i][j][k] = dp[i-1][j-1][k - X.at(i)] + dp[i-1][j][k];
        else dp[i][j][k] = dp[i-1][j][k];
      }
    }
  }

  long long ans = 0;
  for(int i = 1;i <= N;i++) {
    ans += dp[N][i][i*A];
  }

  cout << ans << endl;


}


Measured memory_bytes: 59520
n = int(input())
hs = list(map(int, input().strip().split()))

# 足場 i にたどり着くまでに支払うコストの総和の最小値
# 初期値として足場 0 にいるので dp[0] = 0
dp = [0] * n
# 足場 1 に行くための最小値は 0 → 1 と行く場合に当たるので
dp[1] = abs(hs[1] - hs[0])

# DP する
for i in range(2, n):
    cost_sum_1 = dp[i - 1] + abs(hs[i] - hs[i - 1])
    cost_sum_2 = dp[i - 2] + abs(hs[i] - hs[i - 2])
    dp[i] = min(cost_sum_1, cost_sum_2)

print(dp[n - 1])


Measured memory_bytes: 20488
N,K=map(int,input().split())
H=list(map(int, input().split()))
#Nモンスターの数、K必殺回数（モンスターは体力ゼロになる）、Hモンスターの数と各々の体力
H=sorted(H)
if K>=len(H):
  print(0)
else:
  for i in range(0,K):
    del H[-1]
  result=sum(H)
  print(result)

Measured memory_bytes: 31568
import itertools
N,D=map(int,input().split())
zahyo=[]

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
for _ in range(N):
    x=list(map(int,input().split()))
    zahyo.append(x)    
cnt=0
for y in itertools.combinations(zahyo,2):
    
    kyori=[(i-j)**2 for i,j in zip(y[0],y[1])]
    soukyori=(sum(kyori))**(1/2)
    if is_integer_num(soukyori):
        cnt+=1
print(cnt)
        


Measured memory_bytes: 3064
#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main() {
	int a,b,q;cin>>a>>b>>q;
	vector<ll> s(a),t(b),x(q);
	for(auto& y:s){
		cin>>y;
	}
	for(auto& y:t){
		cin>>y;
	}
	for(auto& y:x){
		cin>>y;
	}
	for(auto p:x){
		ll rights,rightt,lefts,leftt;
		rights=lower_bound(s.begin(),s.end(),p)-s.begin();
		rightt=lower_bound(t.begin(),t.end(),p)-t.begin();
		lefts=rights-1;
		leftt=rightt-1;
		ll ans=-1;
		ll temp;
		if((rights!=a)*(rightt!=b)){
			temp=s[rights]-p;
			if(temp<t[rightt]-p){
				temp=t[rightt]-p;
			}
			if(ans>temp)ans=temp;
			if(ans==-1)ans=temp;
		}
		if((rights!=0)*(rightt!=0)){
			temp=p-s[rights-1];
			if(temp<p-t[rightt-1]){
				temp=p-t[rightt-1];
			}
			if(ans>temp)ans=temp;
			if(ans==-1)ans=temp;
		}
		vector<int> av,bv;
		if(rights!=a){
			av.push_back(0);
		}
		if(rights!=0){
			av.push_back(1);
		}
		if(rightt!=b){
			bv.push_back(0);
		}
		if(rightt!=0){
			bv.push_back(1);
		}

		for(int i=0;i<av.size();i++){
			for(int j=0;j<bv.size();j++){
				ll y=s[rights-av[i]]-p;
				if(y<0)y*=-1;
				ll z=t[rightt-bv[j]]-p;
				if(z<0)z*=-1;
				if(y<z){
					temp=2*y+z;
				}else{
					temp=2*z+y;
				}
				if(ans>temp)ans=temp;
				if(ans==-1)ans=temp;
			}

		}
		cout<<ans<<endl;

	}

	return 0;
}

Measured memory_bytes: 3712
n, m = map(int,input().split())
a = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))
b = [0 for i in range(m)]
for j in range(m):
    b[j] = int(input())
for i in range(n):
    ans = 0
    for j in range(m):
        ans += a[i][j] * b[j]
    print(ans)


Measured memory_bytes: 6020
#include <stdio.h>


int main(void) {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    if( a<=b && b<=c ){
        printf("%d %d %d\n",a,b,c);
    }else if( a<=c && c<=b ){
        printf("%d %d %d\n",a,c,b);
    }else if( b<=a && a<=c){
        printf("%d %d %d\n",b,a,c);
    }else if( b<=c && c<=a){
        printf("%d %d %d\n",b,c,a);
    }else if( c<=a && a<=b){
        printf("%d %d %d\n",c,a,b);
    }else if( c<=b && b<=a){
        printf("%d %d %d\n",c,b,a);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<stdlib.h>

int main(){
  int N,M;
  scanf("%d%d",&N,&M);
  int a[N],b[N],c[M],d[M];
  for (int i = 0; i < N; i++)
  {
    scanf("%d%d",&a[i],&b[i]);
  }
  for (int i = 0; i < M; i++)
  {
    scanf("%d%d",&c[i],&d[i]);
  }

  for (int i = 0; i < N; i++){
    int z,ans=0,min_dist=1000000000;
    for (int j = 0; j < M; j++){
      z=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if (min_dist > z){ min_dist = z;ans=j+1; }
    }
    printf("%d\n",ans);
  }

  return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int main(){
    int N;
    cin >> N;
    
    int ABC[9] = {111,222,333,444,555,666,777,888,999};
    
    int ans = 0;
    for(int i=0;i<9;i++){
        if(N>ABC[i]){
            ans = ABC[i+1];
        }else{
            ans = ABC[i];
            break;
            }
        
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,k,l;
	scanf("%d %d %d",&m,&n,&k);
	l=n-m+1;
	if(l>=2*k)
	{
		for(i=m;i<=m+k-1;i++)
		{
			printf("%d\n",i);
		}
		for(i=n-k+1;i<=n;i++)
		{
			printf("%d\n",i);
		}
	}	
	else
	{
		for(i=m;i<=n;i++)
		{
			printf("%d\n",i);
		}
	}
	return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int N, K;

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

	int M = (N-1) + (t-K);
	cout << M << endl;
	// 1からのへん
	/*
	for (int i = 2; i <= N; i++) {
		cout << 1 << " " << i;
		M--;
	}
	*/

	for (int start = 1; start <= N; start++) {
		for (int end = start+1; end <= N; end++) {
			cout << start << " " << end << endl;
			M--;
			if (M == 0) {
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k, j, sum;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> j;
    int jj;
    if (j < k) jj = k-j;
    else jj = j-k;
    if (j < jj) sum += j;
    else sum += jj;
  }
  cout <<  2 * sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int a = Integer.parseInt(scanner.next());
    int[] b = new int [a];
    int count = 0;
    
    for(int i = 0; i < a; i++){
      b[i] = Integer.parseInt(scanner.next());
    }

    loop: for(count = 0; ; count++){
      for(int j = 0; j < a; j++){
        if(b[j] % 2 == 1){
          break loop;
        }
        b[j] /= 2;
      }
    }
    System.out.println(count);
    scanner.close();
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

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

	if(a-b>=c)cout<<0<<endl;
	else cout<<c-(a-b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void) {

	char str1[10000];
	int n;
	int i;
	int temp;
	int h;

	h = scanf("%d", &n);
	h=scanf("%s", str1);
	

	for (i = 0; i < strlen(str1); i++) {
		temp = ((str1[i] - 'A') + n) % 26;
		str1[i] = 'A' + temp;
	}
	printf("%s", str1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch TravelingSalesmanAroundLake | diff TravelingSalesmanAroundLake.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address TravelingSalesmanAroundLake.cpp && ./a.out

/*
 
 3/28/2020
 
 5:05-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N],K,X[MAX_N];
int N;

void solve() {
  REP(i,N-1) X[i]=A[i+1]-A[i];
  X[N-1]=A[0]+K-A[N-1];
  LL res=K-*max_element(X,X+N);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>K>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


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

int main()
{
    int n,a[200006],c=0,mn;
    cin>>n;
    cin>>a[1];
    mn=a[1];
    for(int i=2;i<=n;i++){ 
        cin>>a[i];
        if(a[i]>mn)c++;
        mn=min(mn,a[i]);
     } 
    cout<<n-c;
    

    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(N: int):
    cnt = 0
    for i in range(1, N+1, 2):
        if len(make_divisors(i)) == 8:
            cnt += 1
    print(cnt)
    return


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1;
    string a;
    while(cin>>a)
    {
        x=y=0;
        rep(i,a.sz)
        {
            if(a.at(i)=='1') x++;
            else y++;
        }
        cout<<2*(min(x,y))<<en;
    }
}













Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n,r,b;
string A;
int main()
{
	cin>>n>>A;
	for(ll i=0;i<n;i++) {
		r+=(A[i]=='R');
		b+=(A[i]=='B');
	}
	cout<<(r>b ? "Yes\n":"No\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
ll power(ll x, ll n) {
    ll res = 1;
    for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    }
    return res;
}

int main()
{
 
  IOS
  ll n;
  cin>>n;
  ll a[n];
  ll check =1;
  for(ll i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]%2)
      continue;
    if(!(a[i]%3==0||a[i]%5==0))
      {
        check = 0;
      }
  }
  if(check )
  {
    cout<<"APPROVED";
  }
  else
  {
    cout<<"DENIED"<<endl;
  }
  
  
  
  
  
  
  

}

Measured memory_bytes: 256