akhauriyash/Code-Regression huggingface dataset:
//I just need somebody to love

#include <bits/stdc++.h>

#define all(x) (x).begin(),(x).end()

using namespace std;

const long long maxn = 50 + 1, inf = 1e9 + 420, delta = 1e9 + 7, C = 26 + 1;

void optimization(){
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
}
void show(vector<long long> vec){
    cout << "showing :";
    for(auto v : vec)
        cout << v << ' ';
    cout << "showing is done"<<endl << endl;
}
bool mat[maxn][maxn];


void make_graph(vector<long long> &s){
    for(long long i = 0; i < maxn; i++)
        for(long long j = 0; j < maxn; j++)
            mat[i][j] = false;

    //show(s);

    for(long long i = 0; i < maxn; i++){
        for(auto u : s)
            mat[i][i % u] = true;
        mat[i][i] = true;
    }
}

void flloyd(){
    for(long long k = 0; k < maxn; k++)
        for(long long i = 0; i < maxn; i++)
            for(long long j = 0; j < maxn; j++)
                mat[i][j] |= (mat[i][k] and mat[k][j]);
}

bool stupid(long long a, long long b){
    cout << "accused " << a << ' ' << b << endl;
    return 0;
}

bool check(vector<pair<long long, long long> > &q){
    for(auto p : q){
        //cout << "checking "<<p.first << ' ' << p.second << endl;
        if(!mat[p.first][p.second])
            return false;
    }
    return true;
}



bool achive(vector<long long> &s, vector<pair<long long, long long> > &q){
    make_graph(s);
    flloyd();

    return check(q);
}

void preset_s(vector<bool> &s_r){
    s_r.push_back(false);
    for(long long i = 1; i < maxn; i++)
        s_r.push_back(true);
}

void make_vec(vector<bool> &key, vector<long long> &s){
    s.clear();
    for(long long i = 1; i < maxn; i++)
        if(key[i])
            s.push_back(i);
}

void scream(){
    cout << -1;
    exit(0);
}
void solve(vector<pair<long long, long long> > &q, vector<long long> &s){
    vector<bool> s_r;

    preset_s(s_r);
    make_vec(s_r, s);

    if(!achive(s, q))
        scream();

    for(long long i = 50; i; i--){
        s_r[i] = false;
        make_vec(s_r, s);
        s_r[i] = !achive(s, q);
    }

    make_vec(s_r, s);
}

long long calc_price(vector<long long> &s){
    long long ans = 0;
    //cout <<"ansing: "<<endl;
    for(auto a : s)
        //cout << a << ' ';
        ans += (1ll << a);
    return ans;
}

long long inp(){
    long long x;
    cin >> x;
    return x;
}

void input(vector<pair<long long, long long> > &q){
    long long n;
    cin >> n;

    for(long long i = 0; i < n; i++)
        q.push_back(make_pair(inp(), 0));

    for(long long i = 0; i < n; i++)
        cin >> q[i].second;
}

int main(){
    //optimization();

    vector<pair<long long, long long> > ques;
    vector<long long> s;

    input(ques);
    solve(ques, s);
    cout << calc_price(s);

}


Measured memory_bytes: 256
let k = Scanf.sscanf (read_line ()) "%d" @@ fun k -> k
let que = Queue.create ()


let rec loop que n =
  let v = Queue.pop que in
  if n = 1 then Printf.printf "%d\n" v
  else begin
    let t = v mod 10 in
    if t != 0 then Queue.add (v * 10 + t - 1) que;
    Queue.add (v * 10 + t) que;
    if t != 9 then Queue.add (v * 10 + t + 1) que;
    loop que (n - 1)
  end

let () =
  Array.iter (fun i -> Queue.add i que) @@ Array.init 9 (fun i -> i + 1);
  loop que k

Measured memory_bytes: 11400
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
// #define fi first
// #define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct Data{
    int fi,se,v;
    ll val;
    Data(int fi,int se,int v,ll val):fi(fi),se(se),v(v),val(val) {} 
    bool operator<(const Data &d)const{return d.val<val;}
};
V<int> dy={-1,0,1,0},dx={0,-1,0,1};
int main(){
    ll h,w,k;
    cin>>h>>w>>k;
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    x1--;y1--;x2--;y2--;
    string s[h];
    for(int i=0;i<h;i++)cin>>s[i];
    priority_queue<Data> q;
    ll d[h][w][4]={};
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)for(int k=0;k<4;k++)d[i][j][k]=ll(1e13);
    d[x1][y1][0]=0;
    q.emplace(x1,y1,0,0);
    while(q.size()){
        int x=q.top().fi,y=q.top().se,bfo=q.top().v,val=q.top().val;
        q.pop();
        for(int i=0;i<4;i++){
            int nx=x+dx[i],ny=y+dy[i];
            if(nx<0||nx>=h||ny<0||ny>=w)continue;
            if(s[nx][ny]=='@')continue;
            if(i==bfo&&val>0){
                if(d[nx][ny][bfo]>d[x][y][bfo]+1){
                    d[nx][ny][i]=d[x][y][bfo]+1;
                    q.emplace(nx,ny,i,d[nx][ny][i]);
                }
            }
            else if(d[nx][ny][i]>(d[x][y][bfo]+k-1)/k*k+1){
                    d[nx][ny][i]=(d[x][y][bfo]+k-1)/k*k+1;
                    q.emplace(nx,ny,i,d[nx][ny][i]);
                }
        }
    }
    ll ans=1e13;
    for(int i=0;i<4;i++)chmin(ans,d[x2][y2][i]);
    cout<<(ans>=ll(1e13)?-1:(ans+k-1)/k)<<"\n";
}


Measured memory_bytes: 42044
#include<iostream>
using namespace std;
int main(void){
int N,K,X,Y,i,sum=0;
  cin >> N>>K>>X>>Y;
  for(i=1;i<=N;i++){
    if(i<=K){
      sum+=X;
    }else{
      sum+=Y;
    }
  }
    

    cout << sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;
ll c[200100];
vector<ll> cc[200100];
ll dp[200100];
bool excl[200100];
int main(){
	cin>>n;
	FOR(i,1,n+1){
		cin>>c[i];
		if(c[i-1]!=c[i]){
			cc[c[i]].push_back(i);
		}else{
			excl[i]=1;
		}
	}
	dp[0]=1;
	dp[1]=1;
	dp[2]=1;
	for(ll i=3;i<=n;i++){
		dp[i]=dp[i-1];
		auto itr=lower_bound(cc[c[i]].begin(),cc[c[i]].end(),i);
		if(itr==cc[c[i]].begin())continue;
		if(excl[i])continue;
		itr--;
		dp[i]=dp[i-1]+dp[*itr];
		dp[i]%=MOD;
		//cout<<i<<" "<<dp[i]<<endl;
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 14336
N,K = map(int, input().split())

P = [2**x for x in range(18)]

p_max = 0
for p in P:
    if K <= p:
        p_max = p
        break

ans = 0
for i in range(1,N+1):
    for j in range(18):
        if max(K/i, 1) > p_max/2**j:
            #print('{}, {}'.format(K/i, j-1))
            ans += 2**(j-1)
            break
print(ans/N/p_max)


Measured memory_bytes: 3064
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
n, m = gets_i_list

ans = [0] * (n+1)

m.times do
  a, b = gets_i_list
  ans[a] += 1
  ans[b] += 1
end

1.upto(n+1) do |i|
  puts ans[i]
end

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

#define M 1000000007

ll fact[11111];
ll finv[11111];

//// extended gcd
ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;y=0;
	}
	return d;
}

//// mod inverse
ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

//// mod combination ex.( num of route (0,0)->(x,y)=mod_comb(x+y,x,M)
ll mod_comb(int n,int k,int p){
	if(n<0||k<0||n<k)return 0;
	return ((fact[n]*finv[k])%p)*finv[n-k]%p;
}

//// mod power
ll mod_pow(ll x,ll n,ll mod){
	ll res=1;
	while(n>0){
		if(n&1)res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}

ll dp[1111][1111];
ll a,b,c,d;

int main(){
	cin.sync_with_stdio(false);
	fact[0]=fact[1]=1;
	finv[0]=finv[1]=mod_inverse(1,M);
	repl(i,1,10000){
		fact[i+1]=(fact[i]*(i+1))%M;
		finv[i+1]=mod_inverse(fact[i+1],M);
	}
	ll n;
	cin>>n>>a>>b>>c>>d;
	dp[0][a-1]=1;
	rep(i,n+1)repl(j,a,b+1){
		dp[i][j]=(dp[i][j]+dp[i][j-1])%M;
		for(int k=c;i+j*k<=n&&k<=d;k++){
			dp[i+j*k][j]=(dp[i+j*k][j]+(((((((dp[i][j-1]*fact[n-i])%M)*finv[n-i-k*j])%M)*finv[k])%M)*mod_pow(finv[j],k,M))%M)%M;
		}
	}
	cout<<dp[n][b]<<endl;
	return 0;
}


Measured memory_bytes: 9088
/*Smile Please!*/
//hp1999
#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     fast() 	     ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,M=1e9+7;

struct abc
{
 int u,d,l,r;    
};


void solve()
{
 int n,m;
 
 cin>>n>>m;
 
 vector<string> s(n);
 abc v[n][m];
 
 for(int i=0;i<n;++i)
 cin>>s[i];
 
 int pos;
 
 for(int i=0;i<n;++i)
 {
  pos=-1ll;     
  for(int j=0;j<m;++j)
  {
   if(s[i][j]=='#')
   pos=j;
   else
   v[i][j].l=pos;
  }
  
  pos=m;     
  for(int j=m-1;j>=0;--j)
  {
   if(s[i][j]=='#')
   pos=j;
   else
   v[i][j].r=pos;
  }
 }
 
 for(int i=0;i<m;++i)
 {
  pos=-1ll;     
  for(int j=0;j<n;++j)
  {
   if(s[j][i]=='#')
   pos=j;
   else
   v[j][i].u=pos;
  }
  
  pos=n;     
  for(int j=n-1;j>=0;--j)
  {
   if(s[j][i]=='#')
   pos=j;
   else
   v[j][i].d=pos;
  }
 }
 
 int ans=0,tmp;
 
 for(int i=0;i<n;++i)
 {
  for(int j=0;j<m;++j)
  {
   if(s[i][j]=='.')
   {
    tmp=abs(v[i][j].l-v[i][j].r)+abs(v[i][j].u-v[i][j].d)-3ll;    
    
    //cout<<i<<" "<<j<<" "<<tmp<<"\n";
    
    ans=max(ans,tmp);        
   }
  }
 }
 
 cout<<ans;
}

int32_t main()
{
 fast();

 int t=1;
 //cin>>t;
 while(t--)
 {
  solve();
 }

 return 0;
}


Measured memory_bytes: 129536
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

bool strCmp(char* base, char* comp){
	int length1,length2;
	for(length1=0;base[length1] != '\0';length1++);
	for(length2=0;comp[length2] != '\0';length2++);
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}



int main(){

	char candidate[26][703][5];
	int index;

	for(int head = 0; head < 26; head++){

		candidate[head][0][0] = 'a'+head;
		candidate[head][0][1] = 'a';
		candidate[head][0][2] = '\0';

		index = 1;
		for(int i = 0; i < 26; i++){
			candidate[head][index][0] = 'a'+head;
			candidate[head][index][1] = 'a' + i;
			candidate[head][index][2] = 'a';
			candidate[head][index][3] = '\0';
			index++;
		}

		for(int i = 0; i < 26; i++){
			for(int k = 0; k < 26; k++){
				candidate[head][index][0] = 'a'+head;
				candidate[head][index][1] = 'a' + i;
				candidate[head][index][2] = 'a' + k;
				candidate[head][index][3] = 'a';
				candidate[head][index][4] = '\0';
				index++;
			}
		}
	}

	char table[110][5];
	char str[3];

	printf("?a\n"); fflush(stdout);

	table[0][0] = 'a';
	table[0][1] = '\0';

	index = 1;

	char pre;
	bool FLG;

	while(true){

		pre = 'a';

		scanf("%s",str);

		if(str[0] != pre){
			printf("!OUT\n");
			return 0;
		}

		for(int i = 0; i < index; i++){
			if(strCmp(table[i],str)){
				printf("!OUT\n");
				return 0;
			}
		}

		strcpy(table[index++],str);

		for(int i = 0; str[i] != '\0'; i++){
			pre = str[i];
		}

		for(int i = 0; i < 703; i++){

			FLG = true;

			for(int k = 0; k < index; k++){
				if(strCmp(table[k],candidate[pre-'a'][i])){
					FLG = false;
					break;
				}
			}

			if(FLG){
				printf("?%s\n",candidate[pre-'a'][i]); fflush(stdout);
				strcpy(table[index++],candidate[pre-'a'][i]);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)



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

  int n;
  cin >> n;
  int cn=1;
  vector<int> a(n,0);
  while(1){    
    bool ok = true;
    int c=a[0];
    rep(i,n){
      if(a[i] == c+1){
	c = a[i];
      }
      else if(a[i] > c+1){
	a[i]=0;
	a[i-1]++;
	ok = false;
      }
    }
    if(a[0]!=0) break;
    if(ok){
      rep(i,n) cout << ((char)('a'+a[i]));
      cout << endl;
      a[n-1]++;
    }

  }
  
  return 0;
    

}


Measured memory_bytes: 1536
// https://atcoder.jp/contests/abc172/tasks/abc172_d
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll x = 1; x <= n; ++x)
    {
        ll y = n / x;
        ans += x * y * (y + 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
	string n, t;
	int cnt;
	while (cin >> t)
	{
		if (t[0] == '-')
			break;
		
		if (isdigit(t[0]))
		{
			cnt = atoi(t.c_str());
			
			for (int i = 0; i < cnt; i++)
			{
				cin >> t;
				int h = atoi(t.c_str());
				n = n.substr(h) + n.substr(0, h);
			}
			cout << n << endl;
		}
		else
		{
			n = t;
			continue;
		}
	}
	
	return 0;
	
}

Measured memory_bytes: 1200
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]) + int.Parse(line[3]);
            var b = int.Parse(line[1]) + int.Parse(line[4]);
            var c = int.Parse(line[2]) + int.Parse(line[5]);
            if (a == 0 && b == 0 && c == 0) return;
            var ans0 = case40(a, b, c);
            var ans1 = case41(a, b, c);
            var ans2 = case42(a, b, c);
            Console.WriteLine(Max(ans0,Max(ans1,ans2)));
        }
    }
    static int case42(int a, int b, int c)
    {
        if (a <= 1 | b <= 1 | c <= 1) return 0;
        return 2 + (a - 2) / 3 + (b - 2) / 3 + (c - 2) / 3;
    }
    static int case41(int a, int b, int c)
    {
        if (a == 0 | b == 0 | c == 0) return 0;
        return 1 + (a - 1) / 3 + (b - 1) / 3 + (c - 1) / 3;
    }
    static int case40(int a, int b, int c) => a / 3 + b / 3 + c / 3;
}



Measured memory_bytes: 18012
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    int n;
    cin >> n;
    VI p(n),q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    VI a(n);
    rep(i,n) a[i] = i+1;

    map<vector<int>, int> mp;
    do {
      mp[a] = mp.size();
    } while(next_permutation(a.begin(),a.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;




}


Measured memory_bytes: 7680
#include<stdio.h>

#define MAX 100000

int A[MAX],n;

int partition(int p,int r){
  int x,i,j,t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}
int main(){
  int i,q;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=partition(0,n-1);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    if(i==q)printf("[");
    printf("%d",A[i]);
    if(i==q)printf("]");
  }
  printf("\n");
  return 0;
}



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

int main(void){

  string a, b;
  int a_n, b_n;
  string puts;
  cin >> a >> b;
  
  cin >> a_n >> b_n;
  cin >> puts;
  
  if(a == puts){
    cout << (a_n - 1) << " " << b_n << endl;
  }else{
    cout << a_n << " " << (b_n - 1) << endl;
  
}
  return 0;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static int process(TestCase testCase) {
        int N = testCase.N;
        int K = testCase.K;
        List<Integer> x = testCase.x;

        int min = Integer.MAX_VALUE;
        for (int i = K - 1; i < N; ++i) {
            int leftMost = x.get(i - (K - 1));
            int rightMost = x.get(i);

            int negative = Math.abs(Math.min(0, leftMost));
            int positive = Math.max(0, rightMost);

            min = Math.min(min, 2 * Math.min(negative, positive) + Math.max(negative, positive));
        }

        return min;
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final int result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> x = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            x.add(sc.nextInt());
        }

        sc.close();
        return new TestCase(N, K, x);
    }

    private static void output(int result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int N;
        final int K;
        final List<Integer> x;

        public TestCase(int N, int K, List<Integer> x) {
            this.N = N;
            this.K = K;
            this.x = x;
        }
    }
}


Measured memory_bytes: 57744
n,m,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
acum1=[0]
#累積和ai,bjを求める
for i in range(n): 
	# acum[-1]で一番最後のリストの値を参照している
    # うしろからみている
 acum1.append(acum1[-1]+arr1[i])
acum2=[0]
for i in range(m):
 acum2.append(acum2[-1]+arr2[i])
ans=0
j=m
for i in range(n+1):
    #各iについて、bj<=K-aiを満たす最大のjを求める
    #bj>K-aiの間、ループ。jを大きい方から順に調べていく
    #限界ギリギリを調べるのだから、後ろから調べた方がよいという感じかな
 if acum1[i]>k:
   break
       #各iについて、bj<=K-aiを満たす最大のjを求める
    #bj>K-aiの間、ループ。jを大きい方から順に調べていく
    #限界ギリギリを調べるのだから、後ろから調べた方がよいという感じかな
 while acum2[j]>k-acum1[i] and j>0: 
   j-=1
 ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47524
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int long long
using namespace std;
const int maxn=200005,mod=1e9+7;
int n,flag=1,posl=350000,posr=350000-1;
char a[maxn*4];
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
inline void write(int a)
{
	if(a<0)
	{
		putchar('-');
		write(-a);
	}
	else
	{
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
	}
}
signed main()
{
	string ch;
	cin>>ch;
	int len=ch.length();
	for(int i=0;i<len;++i)
	a[++posr]=ch[i];
	n=read();
	for(int i=1; i<=n; ++i)
	{
		int t;
		cin>>t;
		if(t==1)
			flag*=-1;
		else
		{
			int f;
			char b;
			cin>>f>>b;
			if(f==1)
			{
				if(flag==1)
					a[--posl]=b;
				else
					a[++posr]=b;
			}
			else
			{
				if(flag==-1)
				a[--posl]=b;
				else
					a[++posr]=b;
			}
		}
//		cout<<a<<endl;
	}
	if(flag==1)
		{
		for(int i=posl;i<=posr;++i)
		cout<<a[i];
		}
	else
	{
		for(int i=posr; i>=posl; --i)
			cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 1024
#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <exception>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const ll INF = static_cast<ll>(1e18);

int a[(int)3e5 + 9];

int main() {
	//freopen("in.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < 3 * n; ++i) {
		scanf("%d", &a[i]);
	}
	sort(a, a + 3 * n);
	ll res = 0;
	int maxPos = 3 * n - 1;
	for (int i = 0; i < n; ++i) {
		--maxPos;
		res += a[maxPos];
		--maxPos;
	}
	printf("%lld\n", res);
	return 0;
}

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

ll ans = 0;

// xまでの素数を列挙
vector<bool> makePrimeTable(ll x, vector<ll> &v){
    vector<bool> primeTable(x + 1);
    for(ll i = 0; i <= x; i++){
        primeTable[i] = true;
    }

   for(ll id = 0; id < (ll)v.size(); id++){
       ll i = v[id];
       if(id != (ll)v.size() - 1){
            if( v[id] == v[id + 1] ){
                if(primeTable[i]){

                    primeTable[ i ] = false;                
                    for(ll j = i; j <= x; j += i){
                        primeTable[j] = false;
                    }
                }
            }
       }

        if(primeTable[i]){
            ans ++;
            for(ll j = i; j <= x; j += i){
                primeTable[j] = false;
            }
        }
    }
    return primeTable;
}



int main(){

    ll n;
    cin >> n;
    vector<ll> v(n);
    for(ll i = 0; i < n; i++) cin >> v[i];

    sort(all(v));
    auto tab = makePrimeTable( v.back() + 2, v );
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4744
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    long N, W;
    readlnTo(N, W);

    alias T = Tuple!(long, long);
    T[] l;
    foreach(i; iota(N)) {
        auto t = readLongs();
        l ~= tuple(t[0], t[1]);
    }
    auto w1 = l[0][0];
    long[] a = l.filter!(x => x[0] == w1).map!(x => x[1]).array();
    long[] b = l.filter!(x => x[0] == w1 + 1).map!(x => x[1]).array();
    long[] c = l.filter!(x => x[0] == w1 + 2).map!(x => x[1]).array();
    long[] d = l.filter!(x => x[0] == w1 + 3).map!(x => x[1]).array();
    a.sort();
    a.reverse();
    b.sort();
    b.reverse();
    c.sort();
    c.reverse();
    d.sort();
    d.reverse();
    long ans = 0;
    foreach(i; iota(a.length+1)) {
        foreach(j; iota(b.length+1)) {
            foreach(k; iota(c.length+1)) {
                long wl = W - w1*i - (w1+1)*j - (w1+2)*k;
                if(wl < 0) {
                    continue;
                }
                long m = wl / (w1+3);
                ans = max(ans, sum(a.take(i) ~ b.take(j) ~ c.take(k) ~ d.take(m), 0L));
            }
        }
    }
    writeln(ans);
}



Measured memory_bytes: 1276
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str;
	while((str=input.readLine())!=null)
	    {
		String str_ary[]=str.split(" ");
		int a[]=new int[3];
		for(int i=0;i<3;i++)
		    {
			a[i]=Integer.parseInt(str_ary[i]);
		    }
		int m=0;
		for(int x=0;x<11;x++)
		    {
			if(a[0]+a[1]+x>20 && x!=a[0] && x!=a[1] && x!=a[2])
			    {
				
				m++;
			    }
		    }
		if(m>3)System.out.println("NO");
		else System.out.println("YES");
	    }
    }
}

Measured memory_bytes: 15072
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[55][55],dp[55][55],n,k;

void mutilply(ll dp[][55],ll b[][55])
{
	ll i,j,a[55][55]={0},p;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			for(p=0;p<n;p++)
				a[i][j]=(a[i][j]+((dp[i][p]*b[p][j])%MOD))%MOD;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			dp[i][j]=a[i][j];
	}
}


ll power(ll arr[][55],ll b)
{
	ll i,j,ans[55][55]={0},sum=0;
	if(b==1)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				dp[i][j]=arr[i][j];
				sum=(sum+arr[i][j])%MOD;
			}
		}
		return sum;
	}
	power(arr,b/2);
	mutilply(dp,dp);
	if(b%2==1)
		mutilply(dp,arr);	
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			sum=(sum+dp[i][j])%MOD;
	}
	return sum;
}

int main()
{
	ll i,j;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			cin>>arr[i][j];
	}
	cout<<power(arr,k);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

#define MAX_N 100000
#define MAX_M 100000
#define WHITE 1
#define GREY 2
#define BLACK 3

vector<int> G[MAX_N];
int V[MAX_N];
int V_num[MAX_N];

void init(void){
    for(int i = 0; i < MAX_N; i++){
        V[i] = WHITE;
        V_num[i] = i;
    }
}

void labeling(int target){
    queue<int> Q;
    Q.push(target);
    while(!Q.empty()){
        int num = Q.front(); Q.pop();
        for(int i = 0; i < G[num].size(); i++){
            if(V[G[num][i]] == WHITE){
                Q.push(G[num][i]);
                V[G[num][i]] = GREY;
                V_num[G[num][i]] = target;
            }
        }
        V[num] = BLACK;
    }
}

int main(void){
    init();
    int n, m;
    scanf("%d %d\n", &n, &m);
    for(int i = 0; i < m; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for(int i = 0; i < n; i++){
        if(V[i] != WHITE){
            continue;
        }
        labeling(i);
    }

    int q;
    scanf("%d", &q);
    for(int i = 0; i < q; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        if(V_num[a] == V_num[b]){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }

    /*
    for(int i = 0; i < n; i++){
        printf("%d %d\n", i, V_num[i]);
    }
    */
}



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

using ll = long long;

int main() {
    int n;
    while(cin >> n, n != -1) {
        string res;
        while(n > 0) {
            res += '0' + (n % 4);
            n /= 4;
        }
        reverse(res.begin(), res.end());
        if(res.size() == 0) {
            res += '0';
        }
        cout << res << endl;
    }
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a.at(i);
	}
	int num=0;
	int ans=1;
	bool judge=true;
	while(ans!=2){
		ans=a.at(ans-1);
		num++;
		if(num>n){
			judge=false;
			break;
		}
	}
	if(judge) cout << num << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    ll a,b;
    cin>>a;
    cout<<((a <= 999) ? "ABC":"ABD")<<endl;
}



Measured memory_bytes: 256
# ABC141D - Powerful Discount Tickets
from heapq import heapify, heappop, heappush


def main():
    _, M = map(int, input().split())
    A = [-i for i in map(int, input().split())]
    heapify(A)

    heappop_max = lambda heap: -heappop(heap)
    heappush_max = lambda heap, x: heappush(heap, -x)
    discount = lambda: heappush_max(A, heappop_max(A) // 2)

    for _ in range(M):
        discount()
    print(-sum(A))


if __name__ == "__main__":
    main()


Measured memory_bytes: 20432
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp;
    cin >> temp;
    return temp;
}

bool ACGT(string const& b) {
    //cout << b << endl;
    return b == "AC";
}

int main() {
    int N(in()), Q(in());
    int counter[N];
    string const S(in<string>());

    //int l(in()), r(in());
    string sub = S;
    //.substr(l - 1, r - l + 1);

    int count = 0;
    for (int i = 0; i < sub.size(); i++) {
        if (ACGT(sub.substr(i, 2))) {
            count ++;
        }
        counter[i] = count;

    }

    for (int i = 0; i < Q; i++) {
        int l(in() - 1), r(in() - 2);
        bool hoge = false;
        if (l == 0 && counter[l] == 1) hoge = true;
        else if (counter[l] != counter[l - 1]) hoge = true;
        cout << counter[r] - counter[l] + (hoge ? 1 : 0) << endl;

    }
    return 0;
}




Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k= scan.nextInt();
		int x= scan.nextInt();
		scan.close();
		k-=1;
		for(int i=x-k;i<x+k;i++) {
			System.out.print(i+" ");
		}
		System.out.println(x+k);
	}

}

Measured memory_bytes: 22608
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

struct Input
{
	int h;
	int a;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto array = readln().strip().split();
		h = array[0].to!int;
		a = array[1].to!int;
	}
}

struct Output
{
}

auto main2(Input* input)
{
	uint result = (input.h + input.a - 1) / input.a;
	return result;
}

unittest { writeln("begin unittest"); }

unittest // example1
{
	string example =
`10 4`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 3);
}

unittest // example2
{
	string example =
`1 10000`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 1);
}

unittest // example3
{
	string example =
`10000 1`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 10000);
}

unittest { writeln("end unittest"); }

void parseExample(out Input input, string example)
{
	struct Adapter
	{
		string[] _lines;
		this(string input) { _lines = input.splitLines(); }
		string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
	}
	parseInput(input, Adapter(example));
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writeln(result);
}


Measured memory_bytes: 256
fun main() {
    val (a, b, c, d) = nextLongList()
    println(
        listOf(
            a * c,
            a * d,
            b * c,
            b * d
        ).max()
    )
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}



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

long long f(long long x, long long y){
  long long a = y*(y+1);
  long long b = (2*x-y+1)*y;
  return (b-a)/2+1;
}

int main(){
  long long n,k;
  cin >> n >> k;
  long long ans=0;
  for(long long i=k;i<n+2;i++){
    ans += f(n+1,i);
  }
  cout << ans%1000000007 << endl;
}

Measured memory_bytes: 3636
import math 
N = int(input())
A= list(map(int,input().split()))
memo_gcd_foward = [A[0]]
memo_gcd_backward = [A[N-1]]

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

for i in range(N-1):
    memo_gcd_foward.append(gcd(memo_gcd_foward[-1],A[i+1]))

for i in range(N-1):
    memo_gcd_backward.append(gcd(memo_gcd_backward[-1],A[-i-2]))


cand = []
cand.append(memo_gcd_foward[-1])
cand.append(memo_gcd_foward[-2])
cand.append(memo_gcd_backward[-2])

for i in range(N-2):
    cand.append(gcd(memo_gcd_foward[i],memo_gcd_backward[-i-3]))
print(max(cand))

Measured memory_bytes: 14588
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include<string>
using namespace std;
#define ll long long int
#define maxn 100005
#define mod 1e9+7

void _init() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}



int main() {
	_init();

	int n;
	cin >> n;

	vector<double> dp(n + 1);
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		double phead;
		cin >> phead;
		for (int j = i; j >= 0; j--) {
			dp[j] = (j == 0 ? 0 : dp[j - 1] * phead) + dp[j] * (1 - phead);
		}
	}


	double ans = 0;
	for (int heads = 0; heads <= n; heads++) {
		int tails = n - heads;
		if (heads > tails) {
			ans += dp[heads];
		}
	}

	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}









Measured memory_bytes: 3740
from itertools import chain


N, M = map(int, input().split())

P = [0] * N

I = list(range(M))

Q = [None] * M
Y = [None] * M

for m in range(M):
    Q[m], Y[m] = map(int, input().split())
    P[Q[m]-1] += 1

D = zip(I, Q, Y)
D = sorted(D, key=lambda x: [x[1], x[2]])
I, Q, Y = map(list, zip(*D))

P = list(chain.from_iterable([list(range(1, p+1)) for p in P]))

D = zip(I, Q, Y, P)
D = sorted(D, key=lambda x: x[0])
I, Q, Y, P = map(list, zip(*D))

for i in range(M):
    print('%06d%06d' % (Q[i], P[i]))


Measured memory_bytes: 39648
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
ab = [na() for _ in range(n)]
ab.sort(key=itemgetter(1, 0))
now = 0
ans = 'Yes'
for i in range(n):
    a, b = ab[i]
    now += a
    if now > b:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 61412
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			int r = sc.nextInt();
			int c = sc.nextInt();
			int []a = new int[1000*r+c+1];
			for(int b=0;b<r;++b){
				for(int d=0;d<c;++d){
					a[1000*b+d] = sc.nextInt();
					System.out.print(a[1000*b+d]+" ");
					a[1000*b+c]=a[1000*b+c]+a[1000*b+d];
					a[1000*r+d]=a[1000*r+d]+a[1000*b+d];
				}
				System.out.println(a[1000*b+c]);
			}
			for(int d=0;d<c;++d){
				System.out.print(a[1000*r+d]+" ");
				a[1000*r+c]=a[1000*r+c]+a[1000*r+d];
			}
			System.out.println(a[1000*r+c]);
	}

}

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

int parent(int i){
  return i/2;
}

int main(){
  int h,i,A[250];
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1) printf("parent key = %d, ",A[parent(i)]);
    if(i*2<=h) printf("left key = %d, ",A[2*i]);
    if(2*i+1<=h) printf("right key = %d, ",A[2*i+1]);
    printf("\n");
  }
  return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n,k;
    cin>>n>>k;
    li res=0;
    while(n>0){
        res++;
        n/=k;
    }
    cout<<res<<endl;


    return 0;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



namespace ConsoleApplication2
{

    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');
            string[] string2 = Console.ReadLine().Split(' ');
            int day, task,res;

            day = int.Parse(input[0]);
            task = int.Parse(input[1]);

            int cost=0;



            for (int i=0;i< task;i++)
            {
                cost += int.Parse(string2[i]);
            }

            res = day - cost < 0 ? -1 : day - cost;

  
            Console.Write(res);


        }
    }
}


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

int check (string a) {
    vector<bool> check(3,false);
    for (int i = 0; i < (int)a.size(); i++) {
        if (a[i] == '3') check[0] = true;
        else if (a[i] == '5') check[1] = true;
        else if (a[i] == '7') check[2] = true;
        else return 0;
    }
    return (check[0] && check[1] && check[2] ? 1 : 0);
}

int dfs(string a, string n) {
    int res = check(a);
    if ((int)a.size() == (int)n.size()) return (a <= n ? res : 0);
    res += dfs(a + "3", n);
    res += dfs(a + "5", n);
    res += dfs(a + "7", n);
    return res;
}

int main() {
    string s; cin >> s;
    cout << dfs("", s) << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  double d;
  cin>>n>>d;
  int count=0;
  for(int i=0;i<n;i++){
      double a,b;
      long double c;
      cin>>a>>b;
      c=sqrt((a*a) +( b*b));
      if( c<= d){
          count++;
      }
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3776
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] cin = Console.ReadLine().Split();
        int a = int.Parse(cin[0]);
        int b = int.Parse(cin[1]);

        Console.WriteLine(Math.Max(a * 2 - 1, Math.Max(b * 2 - 1, a + b)));
    }
}

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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> ac(N,0),pena(N,0);
    rep(i,M) {
        int p;
        string S;
        cin >> p >> S;
        --p;
        if (ac.at(p)) continue;
        if (S == "AC") {
            ac.at(p) = 1;
        }else{
            //S == "WA"
            pena.at(p)++;
        }
    }
    int AC = 0,PENA = 0;
    rep(i,N) {
        AC += ac.at(i);
        if (ac.at(i)) PENA += pena.at(i);
    }
    cout << AC << " " << PENA << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#define MAX_H 10
using namespace std;

string jfen[MAX_H];
int jfen_height;

void printJfen() {
    string ans;
    for (int i = 0; i < jfen_height; i++) {
        int count = 0;
        for (int j = 0; j < jfen[i].length(); j++) {
            if (jfen[i][j] == 'b') {
                if (count > 0) {
                    ans.push_back(count + '0');
                }
                ans.push_back('b');
                count = 0;
            } else {
                count++;
                if (j == jfen[i].length() - 1) {
                    ans.push_back(count + '0');
                }
            }
        }
        if (i < jfen_height - 1) ans.push_back('/');
    }

    cout << ans << endl;
}

void makeJfen(string s) {
    int height = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'b') {
            jfen[height].push_back('b');
        } else if (s[i] == '/') {
            height++;
        } else {
            int temp = s[i] - '0';
            for (int j = 0; j < temp; j++) {
                jfen[height].push_back('.');
            }
        }
    }    
    jfen_height = height + 1;
}

int main() {
    while (true) {
        string s;
        cin >> s;
        if (s == "#") return 0;
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        for (int i = 0; i < MAX_H; i++) {
            jfen[i].erase();
        }

        makeJfen(s);
        
        char temp = jfen[a - 1][b - 1];
        jfen[a - 1][b - 1] = jfen[c - 1][d - 1];
        jfen[c - 1][d - 1] = temp;

        printJfen();
        //for (int i = 0; i < jfen_height; i++) {
        //    cout << jfen[i] << endl;
        //}
    }
    
}

Measured memory_bytes: 3096
A, B, C = map(int, input().split())


if A == B == C and A % 2 == 0:
    print('-1')
else:
    count=0
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        A_copy, B_copy, C_copy = A, B, C
        A = int(B_copy/2 + C_copy/2)
        B = int(A_copy/2 + C_copy/2)
        C = int(A_copy/2 + B_copy/2)
        count += 1
    print(count)

Measured memory_bytes: 3060