akhauriyash/Code-Regression huggingface dataset:
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>
#include <random>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007ll
#define eps 1e-6
#define infi 1000000107
#define infll 1000000000000000000ll
#define MX 1000000
#define X real()
#define Y imag()
#define left(i) i<<1
#define right(i) (i<<1)|1
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
//#define rotate(a, theta) (a) * (polar(1.0, (theta) ))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c) cross(vec(a,b) , vec(a,c)) > eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 1000500001ll
#define mod2 1000300001ll
#define base1 137ll
#define base2 31ll
#define PI acos(-1.0l)
#define sz(a) (int) (a).size()
#define isbit(x,k)  ((x) & (1<<(k))) > 0


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef complex<ld> point;
typedef pair<point, point> line;
typedef pair<ld , point> Circle;
typedef pair<point, int> Point;


const int N = 200005;



int main(){
    
    int x,y;
    scanf("%d%d",&x,&y);
    printf("%d\n", x+y/2);
    
    
    return 0;
}



/*
 
 5 100
 1 2 4 8 16
 5 1
 5 2
 5 3
 5 4
 5 581 58

 
 
 */

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);


// https://pastebin.com/H4VU3ZvM tree walk

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define dbg(x) cerr<<#x" = "<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge*i=G[x];i;i=i->nxt)
typedef long long ll;
typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;
inline int rd() {
    int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
    while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
const int N=100011;
struct Edge{int v;Edge*nxt;}pl[N<<2],*cur=pl,*G[N];
inline void ins(int u,int v){*cur=(Edge){v,G[u]},G[u]=cur++;}
int n,v[N],t;
void dfs(int x,int c){
	if(v[x]==c);
	else if(v[x]&&v[x]!=c){
		t=1;
	}
	else{
		v[x]=c;
		Es(x,i)dfs(i->v,-c);
	}
}
int main(){
	n=rd();
	int m=rd();
	rep(i,1,m){
		int u=rd(),v=rd();
		ins(u,v),ins(v,u);
	}
	ll a=0,b=0,c=0;
	rep(i,1,n)if(!v[i]){
		if(G[i]){
			t=0,dfs(i,1),++(t?a:b);
		}else ++c;
	}
	printf("%lld\n",2*n*c-c*c+a*a+2*b*(a+b));
}

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


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int ans=0;
  for(int i=0;i<n;++i){
    cin >> a[i];
    a[i]--;
  }
  for(int i=0;i<n;++i){
    int tmp=a[i];
    if(tmp>i && a[tmp]==i) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3660
from sys import stdin

def main():
    input = stdin.readline

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

    s = [0] * M
    c = [0] * M

    ans = [None] * N
    for i in range(M):
        s[i], c[i] = map(int, input().split())

        if(ans[s[i]-1] is None):
            ans[s[i]-1] = c[i]
        elif(ans[s[i]-1] == c[i]):
            continue
        else:
            print("-1")
            return
    
    if(ans[0] is None)&(N > 1):
        ans[0] = 1
    elif(ans[0] is None)&(N==0):
        ans[0] = 0

    for i in range(N):
        if(ans[i] is None):
            ans[i] = 0
    
    ans_num = int(''.join(map(str,ans)))

    if(ans_num == 0)&(N > 1):
        print(-1)
    else:
        print(ans_num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i, n) for(i=0; i<n; i++)
using namespace std;
int main() {
    int i, n;
    cin >> n;
    vector<int> b;
    rep(i, n-1){
        int x;
        cin >> x;
        b.push_back(x);
    }
    //vector<int> a;
    //a[0] = b[0];
    int sum = b[0];
    for(i=1; i<n-1; i++){
        //a[i] = min(b[i], )
        sum += min(b[i], b[i-1]);
    }
    sum += b[n-2];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
char s[101], t[101];
int main(int argc, char** argv)
{
	int n;
	scanf("%d", &n);
	scanf("%s %s", s, t);
	for (int i = 0; i < n; i++)
	{
		putchar(s[i]);
		putchar(t[i]);
	}
	return 0;
}

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

vector<vector<int>> p;
int n, m;
int ans = 0;

void dfs(int state, int pos){
	if(state + 1 == (1<<n)){
		ans++;
		return;
	}
	for(int i = 0; i < n; ++i){
		if((state & (1<<i)) != 0) continue;
		if(p[pos][i] == 1){
			dfs((state | (1<<i)), i);
		}
	}
}


int main(void){
	cin >> n >> m;
	p.resize(n+1);
	for(int i = 0; i <= n; ++i){
		p[i].resize(n+1);
	}
	for(int i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		a--; b--;
		p[a][b] = 1;
		p[b][a] = 1;
	}
	dfs(1,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <queue>

#define fr(i,y) for(int i=0;i<y;i++)

using namespace std;
long long int n,a[200001],x;
int main() {

	cin >> n;
	fr(i, n - 1) {
		cin >>x;
		a[x]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i] <<endl;
	}


}
	


Measured memory_bytes: 5128
#include <iostream>

using namespace std;

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  int last = -1, ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;

    if (last == x) {
      ans++;
      last = -1;
    } else {
      last = x;
    }
  }

  cout << ans << endl;
}


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

int main(){
  int A,B,C,D; //高橋の体力攻撃　青木の体力攻撃
  cin >> A >> B >> C >> D;
  while(1){
    C -= B;
    A -= D;
    if(C <= 0){
      cout << "Yes" << endl;
      break;
    }
    if(A <= 0){
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N/10 % 111 == 0 || N %1000 % 111 == 0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
using namespace std;

void test() {
    string s, t;
    cin >> s >> t;
    cout << (s == t.substr(0, s.size()) ? "Yes\n" : "No\n");
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main()
{
	int b,a[3];
	for(int i = 0;i < 3;i++){
	cin>>a[i];
	}
	for(int j =0;j<3;j++){
		for(int w = 0;w<2;w++){
			if(a[w]<=a[w+1]){
			}
			else if(a[w]>a[w+1]){
				b=a[w];
				a[w]=a[w+1];
				a[w+1]=b;
			}
		}
	}
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
   return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int h, w, k;
ll dp[101][8], p[7] = {1, 2, 3, 5, 8, 13, 21};


int main() {
  cin >> h >> w >> k;
  dp[0][0] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
        dp[i + 1][j] += dp[i][j] * p[max(0, j - 1)] * p[max(0, w - j - 2)];
        dp[i + 1][j] %= MOD;
        if (j > 0) {
          dp[i + 1][j - 1] += dp[i][j] * p[max(0, j - 2)] * p[max(0, w - j - 2)];
          dp[i + 1][j - 1] %= MOD;
        }
        if (j < w - 1) {
          dp[i + 1][j + 1] += dp[i][j] * p[max(0, j - 1)] * p[max(0, w - j - 3)];
          dp[i + 1][j + 1] %= MOD;
        }
    }
  }
  cout << dp[h][k - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int n,m;


int main() {
  cin >> n >> m;
  priority_queue<ll> a;
  rep(i,n) {
    ll x;cin >> x;
    a.push(x);
  }
  
  rep(i,m) {
    ll t = a.top(); a.pop();
    a.push(t/2);
  }
  ll ans = 0;
  rep(i,n) {
    ans += a.top();
    a.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4304
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int A[] ={ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

signed main(){
    int K;
    cin >> K;
    cout << A[K-1] << endl;
}

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

typedef long long ll;
const int N = 100005;
const int M = 1000000007;

char s[N];

int main() {
  while (~scanf("%s", s)) {
    bool v[123] = {0};
    for (int i = 0; s[i]; i++) { v[s[i]] = true; }
    puts(v['N'] == v['S'] && v['E'] == v['W'] ? "Yes" : "No");
  }
}


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

using namespace std;

const int N = 1 << 21;
const int MOD = 1e9 + 7;
int n, a[21][21];
long long dp[21][N];

long long solve(int i, int w)
{
	if (i == n)
		return 1;
	if (dp[i][w] != -1)
		return dp[i][w];
	long long ans = 0;
	for (int j = 0; j < n; j++)
	{
		if (a[i][j] && ((1 << j)&w))
			ans = (ans + solve(i + 1, w - (1 << j))) % MOD;
	}
	return dp[i][w] = ans;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	memset(dp, -1, sizeof(dp));
	cout << solve(0, (1 << n) - 1) << endl;
	return 0;
}

Measured memory_bytes: 344320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-10
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())

int aa[400005],ab[400005],ac[400005];
double a[400005],b[400005],c[400005];
int n;
struct BIT
{
	ll bit[100005];
	void init(){ memset(bit,0ll,sizeof(bit)); }
	int f(int x)
	{
		return x&-x;
	}
	void add(int i,ll x)
	{
		for(int s=i;s<100005;s+=f(s)) bit[s]+=x;
	}
	ll sum(int i)
	{
		ll res=0;
		for(int s=i;s>0;s-=f(s)) res+=bit[s];
		return res;
	}
}bit;
int main(){
	cin>>n;
	repn(i,n) cin>>aa[i]>>ab[i]>>ac[i];
	repn(i,n){
	    a[i]=(double)(aa[i]);
	    b[i]=(double)(ab[i]);
	    c[i]=(double)(ac[i]);
//cout<<a[i]<<b[i]<<c[i]<<endl;
	}
	//x & y is reigai
	double lb = -1e18,ub = 1e18;
	ll cnt = 1LL*n*(n-1)/2;
	rep(t,100){
		double mid = (lb+ub)/2; //mid = 1.001;
		// mid ika point cnt
		ll val = 0;
		vector<pair<double,double> >vec;
		vector<double>za;
		repn(i,n){
			//a[i]x + b[i]y = c[i]
			//x = mid
			vec.pb(mp((c[i]-a[i]*mid)/(double)(ab[i]),-a[i]/(double)(ab[i])));
			za.pb(-a[i]/(double)(ab[i]));
		}//return 0;
		SORT(vec);
		SORT(za);// ERASE(za);
		for(int i=0;i<vec.size();i++){
			vec[i].sc = POSL(za,vec[i].sc);
			vec[i].sc++;
		}
		bit.init();
		for(int i=0;i<vec.size();i++){
			val += bit.sum(vec[i].sc-1);
			bit.add(vec[i].sc,1);
		}
		ll lim;
		if(cnt%2 == 1){
			lim = (cnt+1)/2;
		}
		else{
			lim = cnt/2;
		}
		if(lim <= val){
			ub = mid;
		}
		else{
			lb = mid;
		}
	}
	double X = ub;
	lb = -1e18,ub = 1e18;
	rep(t,100){
		double mid = (lb+ub)/2;
		// mid ika point cnt
		ll val = 0;
		vector<pair<double,double> >vec;
		vector<double>za;
		repn(i,n){
			//b[i]y + a[i]x = c[i]
			//y = mid
			vec.pb(mp((c[i]-b[i]*mid)/(double)(aa[i]),-b[i]/(double)(aa[i])));
			za.pb(-b[i]/(double)(aa[i]));
		}
		SORT(vec);
		SORT(za);// ERASE(za);
		for(int i=0;i<vec.size();i++){
			vec[i].sc = POSL(za,vec[i].sc);
			vec[i].sc++;
		}
		bit.init();
		for(int i=0;i<vec.size();i++){
			val += bit.sum(vec[i].sc-1);
			bit.add(vec[i].sc,1);
		}
		ll lim;
		if(cnt%2 == 1){
			lim = (cnt+1)/2;
		}
		else{
			lim = cnt/2;
		}
		if(lim <= val){
			ub = mid;
		}
		else{
			lb = mid;
		}
	}
	double Y = ub;
	printf("%.10f %.10f\n",X,Y);
}

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

int n,m,p,memo[7][7][7],ans;
bool c,en,win;
int dx[] = { 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1};
int dy[] = { 0, 1, 0, 1,-1, 0, 0, 1, 1, 1, 1,-1,-1};
int dz[] = { 0, 0, 1, 0, 0, 1,-1, 1,-1, 1,-1, 1,-1};

void check(int a)
{
	if(en) return;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			for (int k = 0; k < n; ++k)
			{
				for (int l = 0; l < 13; ++l)
				{
					int nx=i,ny=j,nz=k;
					int conti=0;
					while(0<=nx&&nx<n&&0<=ny&&ny<n&&0<=nz&&nz<n&&c==memo[nx][ny][nz])
					{
						nx+=dx[l],ny+=dy[l],nz+=dz[l],++conti;
					}
					if(conti>=m) en=1,win=c,ans=a;
				}
			}
		}
	}
}

int main(int argc, char const *argv[])
{
	while(cin>>n>>m>>p,n+m+p)
	{
		c=0,en=0;
		for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) for (int k = 0; k < n; ++k)	memo[i][j][k]=-1;
		for (int i = 0; i < p; ++i)
		{
			int x,y;
			cin>>x>>y;
			--x,--y;
			int t=0;
			while(memo[x][y][t]!=-1) ++t;
			memo[x][y][t]=c;
			check(i);
			c=!c;
		}
		if(en) cout<<(win?"White ":"Black ")<<ans+1<<endl;
		else cout<<"Draw\n";
	}
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool flg = true;
    for (int i = 0; i < n/2; ++i) {
      if (s[i] != s[n-1-i]) flg = false;
      if (s[i] != s[n/2-1-i]) flg = false;
      if (s[n/2+1+i] != s[n-1-i]) flg = false;
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def merge(a, left, mid, right):
    global cnt
    l = a[left:mid] + [10**9 + 1]
    r = a[mid:right] + [10**9 + 1]

    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if l[i] <= r[j]:
            a[k] = l[i]
            i += 1
        else:
            a[k] = r[j]
            j += 1


def mergesort(a, left, right):
    if left+1 < right:
        mid = (left + right)//2
        mergesort(a, left, mid)
        mergesort(a, mid, right)
        merge(a, left, mid, right)
    pass


n = int(input())
S = list(map(int, input().split()))
cnt = 0
mergesort(S, 0, n)
print(*S)
print(cnt)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n = s.size();
    set<char> S;
    rep(i,n){
        if (S.count(s[i])){
            cout<<"no\n";
            return 0;
        }
        S.ins(s[i]);
    }
    cout<<"yes\n";
    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    cardlist = list(map(int, input().split()))
    cardlist.sort()

    alice_s, bob_s = 0, 0
    while cardlist != []:
        alice_s += cardlist.pop()
        if cardlist == []:
            break
        bob_s += cardlist.pop()
    ans = alice_s - bob_s
    print(ans)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			char c='h';
			var n = N%10;
			if(n==3) c='b';
			else if(n==0||n==1||n==6||n==8) c='p';
			Console.WriteLine(c+"on");

		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}

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

void solve()
{
    ll N;
    cin>>N;

    ll res = 0;

    for(ll i = 1; i <= N; i++)
    {
        res += (N - 1)/i;
    }

    cout<<res<<endl;
}

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

    return 0;
}

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

using namespace std;

const int N = 1e5 + 5;

vector<int> cnt(N, 0);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    sum += 1LL * x;
    ++cnt[x];
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    sum -= 1LL * cnt[a] * a;
    sum += 1LL * cnt[a] * b;
    cnt[b] += cnt[a];
    cnt[a] = 0;
    cout << sum << '\n';
  }
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod (ll)1e9+7
vector<ll> v;
//map<ll,ll> mp;

int main()
{
  ll a,b;
  cin>>a>>b;
  ll c[b];
  for(ll i=0;i<b;i++)cin>>c[i];
  ll maxm=INT_MAX;
  for(ll i=0;i<b;i++)
  {
    maxm=min(maxm,(c[(i+b-1)%b]-c[i]+2*a)%a);
  }
  cout<<maxm<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define N 200009
#define pb push_back
using namespace std;
typedef long long ll;
void slv()
{
    int n;
    string s;
    cin >> n >> s;
    int hi=n-1;
    int cnt=0;
    for(int lo=0;(lo<hi);lo++) {
        if(s[lo]=='W') {
            bool ok=0;
            while (hi>lo)
            {
                if(s[hi]=='R') {
                    ok=1;
                    break;
                }
                hi--;
            }
            if(ok) {
                cnt ++;
                swap(s[lo],s[hi]);
            }
        }
    }
    cout<<cnt<<endl;
}
int main()
{
    int t;
    t=1;
    for(int cs=1;cs<=t;cs++)
    {
        //printf("Case #%d: ",cs);
        slv();
    }
    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <algorithm>
using namespace std;

int main(){
  int c,t,i=0,l[1001]={0};
  map<int,bool> m;
  string s;
  char cm;
  while(getline(cin,s)&&s.size()>0){
    stringstream ss(s);
    ss>>c>>cm>>t;
    l[c]++;
  }
  while(getline(cin,s)){
    stringstream ss(s);
    ss>>c>>cm>>t;
    if(l[c]>0){
      m[c]=true;l[c]++;
    }
  }
  for(map<int,bool>::iterator it=m.begin();it!=m.end();++it){
    cout<<it->first<<" "<<l[it->first]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

int main() {
	int x, y;
	cin >> x >> y;
	for (int t = 0; t <= 100; t++) {
		for (int k = 0; k <= 100; k++) {
			if (x == t + k && y == t * 2 + k * 4) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}


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

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

using namespace std;

int n;
double memo[301][301][301];

double dfs(int a,int b,int c){
	if(a+b+c==0) return 0;

	if(memo[a][b][c]!=-1) return memo[a][b][c];

	double r=1.0*(n-a-b-c)/n,sum=1;
	if(a>0) sum+=dfs(a-1,b,c)*a/n;
	else    r+=1.0*a/n;
	if(b>0) sum+=dfs(a+1,b-1,c)*b/n;
	else    r+=1.0*b/n;
	if(c>0) sum+=dfs(a,b+1,c-1)*c/n;
	else    r+=1.0*c/n;
	return memo[a][b][c]=sum/(1-r);
}

int main(){
	int cnt[3]={}; scanf("%d",&n);
	rep(i,n){ int a; scanf("%d",&a); cnt[a-1]++; }

	rep(i,n+1) rep(j,n+1) rep(k,n+1) memo[i][j][k]=-1;

	printf("%.9f\n",dfs(cnt[0],cnt[1],cnt[2]));

	return 0;
}


Measured memory_bytes: 213376
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		
		Map<Integer,List<Integer>> tree = new HashMap<Integer,List<Integer>>();
		
		for(int i = 0 ;i < n-1;i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			tree.computeIfAbsent(x, a->new ArrayList<Integer>()).add(y);
			tree.computeIfAbsent(y, a->new ArrayList<Integer>()).add(x);
		}
		
		int[] ans = search(tree,1,0);
		
		System.out.println((ans[0]+ans[1]) % mod);
		
	}
	
	Map<Integer,int[]> memo = new HashMap<Integer,int[]>();
	int[] search(Map<Integer,List<Integer>> tree, int now, int prev){
		if(memo.containsKey(now)){
			return memo.get(now);
		}
		
		int[] res = new int[2];
		
		int zero = 1;
		int all = 1;
		
		
		for(int next: tree.getOrDefault(now,new ArrayList<Integer>())){
			if(next != prev){
				int[] nv = search(tree,next,now);
				
				zero = prod(zero, nv[0]);
				all = prod(all,nv[0] + nv[1]);
			}
		}
		
		res[0] = all;
		res[1] = zero;

		memo.put(now, res);
		return res;
	}
	
	int mod = 1000000007;
	int prod(int a, int b){
		return (int)(((long)((long)a % mod )* ((long)b % mod)) % mod);
	}
	
}


Measured memory_bytes: 131088
#include<bits/stdc++.h>
using namespace std;
int f[100001],a[100001];
int main()
{
	int n,i,j,k,flag,minv=INT_MAX;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		minv=min(minv,a[i]);
	}
	for(i=0;i<=minv;i++)
		f[i]=1;
	for(i=1;i<=k;i++)
	{
		flag=1;
		for(j=1;j<=n;j++)
			if(a[j]<=i&&f[i-a[j]]!=0)
				flag=0;
		if(flag)
			f[i]=1;
		else
			f[i]=0;
	}
	if(f[k]==0)
		printf("First");
	else
		printf("Second");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <math.h>
using namespace std;


int main(){
	int A,B,C,D;	
	cin>>A>>B>>C>>D;
	int a,c;
	a=0; //後攻の攻撃回数 
	c=0; //先行の攻撃回数

	while(A>0){
		a++;
		A=A-D;
	}
	while(C>0){
		c++;
		C=C-B;
	}
	if(c<=a){
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
	return 0;

}

Measured memory_bytes: 3632
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let m: Vec<i32> = procon_read();
	let n = m[0];
	let m: Vec<i32> = procon_read();
	let v:Vec<i32> = m.clone();
	let m: Vec<i32> = procon_read();
	let c:Vec<i32> = m.clone();
	
	let mut x = 0;
	let mut y = 0;
	for i in 0..n {
		if x - y < (x + v[i as usize]) - (y+c[i as usize]) {
			x = x + v[i as usize];
			y = y + c[i as usize];
		}
	}
	println!("{}", x-y);
}

Measured memory_bytes: 4352
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 105;
int n;
int a[maxn], cnt[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

void solve() {
  sort(a, a + n);
  int d = (a[0] == a[1]? 2 * a[0] - 1 : 2 * a[0]);
  if (a[n - 1] > d) {
    printf("Impossible\n");
    return;
  }
  for (int i = 0; i < maxn; i++) {
    cnt[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    cnt[a[i]]++;
  }
  if (cnt[a[0]] > 2) {
    printf("Impossible\n");
    return;
  }
  for (int i = a[0] + 1; i <= d; i++) {
    if (cnt[i] < 2) {
      printf("Impossible\n");
      return;
    }
  }
  printf("Possible\n");
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    if(a + b == c + d){
        cout << "Balanced" << endl;
    }else if(a + b > c + d){
        cout << "Left" << endl;
    }else{
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;
  
#define rep(i,n) for(int i=0;i<int(n);++i)
  
static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;
static const double eps = 1e-8;


string s[10];
int sq[10][10]={0};
int x,y;

int solve(){
	if(sq[x][y+1]==1&&sq[x+1][y]==1&&sq[x+1][y+1]==1) return 1;
	else if(sq[x+3][y]==1) return 2;
	else if(sq[x][y+3]==1) return 3;
	else if(sq[x+2][y-1]==1) return 4;
	else if(sq[x+1][y+2]==1) return 5;
	else if(sq[x+2][y+1]==1) return 6;
	else if(sq[x+1][y-1]==1) return 7;
}


int main(){
	
	while(cin>>s[0]){
		x = y = -1;
		
		rep(i,7){
			cin>>s[i+1];
		}
		rep(i,8){
			rep(j,8){
				if(s[i][j]=='0') sq[i+1][j+1]=0;
				else sq[i+1][j+1]=1;
			}
		}
 		
		rep(i,8){
			bool f=false;
			rep(j,8){
				//cout<<i+1<<" "<<j+1<<" "<<sq[i+1][j+1]<<endl;
				if(sq[i+1][j+1]==1){
					x=i+1;
					y=j+1;
					f=true;
					break;
				}
			}
			if(f) break;
		}
					
		//cout<<"x,y= "<<x<<" "<<y<<endl;
		/*
		rep(i,8){
			rep(j,8){
				cout<<sq[i+1][j+1];
			}
			cout<<endl;
		}
		cout<<endl;
		*/
		switch (solve()){
			case 1: cout<<"A\n";
					break;
			case 2: cout<<"B\n";
					break;
			case 3: cout<<"C\n";
					break;
			case 4: cout<<"D\n";
					break;
			case 5: cout<<"E\n";
					break;
			case 6: cout<<"F\n";
					break;
			case 7: cout<<"G\n";
					break;
		default: cout<<"error\n";
			break;
		}
		rep(i,10){
			rep(j,10){
				sq[i][j]=0;
			}
		}
	}
	//while(cin>>t) cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 1164
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	pos := make([][]float64, n)
	for i := 0; i < n; i++ {
		pos[i] = make([]float64, 2)
		for j := 0; j < 2; j++ {
			fmt.Scan(&pos[i][j])
		}
	}

	var sum float64
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			sum += math.Sqrt((pos[i][0]-pos[j][0])*(pos[i][0]-pos[j][0]) + (pos[i][1]-pos[j][1])*(pos[i][1]-pos[j][1]))
		}
	}

	fmt.Println(sum / float64(n))
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  int a[n], sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  double ok = (double) sum / (4 * m);
  int count = 0;
  for(int i = 0; i < n; i++){
    if(ok <= a[i]){
      count++;
    }
  }
  if(count >= m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
	
  
  


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

int main() {

  int H,N;
  cin >> H >> N;
  string ans = "No";

  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    H -= a;
    if(H<=0){
      ans ="Yes";
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e16
#define mod 1000000007
#define en '\n'
#define ld long double
ll pw(ll b, ll r){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%mod;
		b = (b*b)%mod;
		r>>=1;
	}
	return ans;
}
ll par[100010];
ll fnd(ll u){
	if(par[u]==u)return u;
	return par[u]=fnd(par[u]);
}
void uni(ll u, ll v){
	ll p1 = fnd(u),p2=fnd(v);
	par[p1]=p2;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,m,k;cin>>n>>m>>k;
	ll sz[n+1];memset(sz,0,sizeof sz);
	ll ans[n+1];memset(ans,0,sizeof ans);
	for(int i = 1 ; i <= n ; i ++ )par[i]=i;
	for(int i = 0 ; i < m ; i ++ ){
		ll a,b;cin>>a>>b;
		uni(a,b);
		ans[a]--;ans[b]--;
	}
	for(int i = 1 ; i <= n ; i ++ )sz[fnd(i)]++; 
	for(int i = 1 ; i <= n ; i ++ )ans[i]+=sz[fnd(i)];
	for(int i = 0 ; i < k ; i ++ ){
		ll a,b;cin>>a>>b;
		if(fnd(a)==fnd(b)){
			ans[a]--;
			ans[b]--;
		}
	}
	for(int i = 1 ; i <= n ; i ++ )cout<<ans[i]-1<<" ";
	cout<<en;
	return 0 ; 
}



Measured memory_bytes: 3840
#include<iostream>
#include<vector>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;
int n, I[1 << 10], R[1 << 10], O[1 << 10], V[1 << 10];
vector<tuple<long double, int, int, int>>vec;
int main() {
	while (true) {
		cin >> n; vec.clear(); if (n == 0)break;
		for (int i = 1; i <= n; i++) { cin >> I[i]; }
		for (int S = 0; S < 16; S++) {
			for (int A = 0; A < 16; A++) {
				for (int C = 0; C < 16; C++) {
					R[0] = S; long double sum = 0.0l;
					for (int i = 1; i <= n; i++) { R[i] = (A*R[i - 1] + C) % 256; }
					for (int i = 1; i <= n; i++) { O[i] = (I[i] + R[i]) % 256; }
					for (int i = 0; i < 256; i++) { V[i] = 0; }
					for (int i = 1; i <= n; i++) { V[O[i]]++; }
					for (int i = 0; i < 256;i++){
						if (V[i] >= 1) {
							long double F = 1.0*V[i] / n;
							sum -= F*log(F);
						}
					}
					vec.push_back(make_tuple(sum, S, A, C));
				}
			}
		}
		sort(vec.begin(), vec.end());
		cout << get<1>(vec[0]) << ' ' << get<2>(vec[0]) << ' ' << get<3>(vec[0]) << endl;
	}
	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;

    vector<vector<char>> C(H, vector<char>(W, '0'));
    rep (i, H) {
        rep (j, W) {
            cin >> C[i][j];
        }
    }

    rep (i, H) {
        rep (j, 2) {
            rep (k, W) {
                cout << C[i][k];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<queue>
#define MN 100000
using namespace std;
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*10+ch-'0';ch=getchar();}
	return x*f;
}
struct hito{int a,b,c;}s[MN+5];
int n,X,Y,Z,b[MN+5];long long res=0;
priority_queue<pair<int,int> > q1,q2;
bool cmps(const hito&x,const hito&y){return x.b-x.a>y.b-y.a;}
int main()
{
	X=read();Y=read();Z=read();n=X+Y+Z;
	for(int i=1;i<=n;++i) s[i].a=read(),s[i].b=read(),s[i].c=read();
	sort(s+1,s+n+1,cmps);
	for(int i=1;i<=Y;++i) b[i]=2,res+=s[i].b,q1.push(make_pair(s[i].c-s[i].b,i));
	for(int i=Y+1;i<=n;++i) b[i]=1,res+=s[i].a,q2.push(make_pair(s[i].c-s[i].a,i));
	
//	puts("");
//	for(int i=1;i<=n;++i) printf("%d %d %d\n",s[i].a,s[i].b,s[i].c);
	
	for(int i=1,j=Y+1;i<=Z;++i)
	{
		while(!q2.empty()&&b[q2.top().second]!=1) q2.pop();
		if(q2.empty()||(q1.size()&&q1.top().first+s[j].b-s[j].a>q2.top().first))
		{
			int x=q1.top().second;q1.pop();
			b[x]=3;res+=s[x].c-s[x].b+s[j].b-s[j].a;
			b[j]=2;q1.push(make_pair(s[j].c-s[j].b,j));
		//	cout<<"Choose"<<x<<" "<<j<<endl;
		}
		else 
		{
			int x=q2.top().second;q2.pop();
			b[x]=3;res+=s[x].c-s[x].a;
	//		cout<<"Choooose"<<x<<endl;
		}
		while(b[j]!=1) ++j;
	}
	printf("%lld\n",res);
	return 0;
}



Measured memory_bytes: 3192
#include<iostream>
#include<queue>
using namespace std;
int main(){
	queue<int> tab;
	int x,z,y,temp;
	while(cin>>x>>y>>z){
		temp=0;
		for(int i=1;i<11;i++){
			if(i!=x&&i!=y&&i!=z)
			tab.push(i);
		}
		for(int i=0;i<7;i++){
			if(tab.front()+x+y<=20)
			temp++;
			tab.pop();
		}
		if(temp*100>=7*50)
		cout<<"YES"<<endl;
		else
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#define rep(i, n) for(ll i = 0; i < n; i++)
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
	ll n,k;
	cin >> n >> k;
	vector<P> a(n);
	rep(i,n) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());
	ll cnt = 0;
	ll ans = 0;
	rep(i,n) {
		cnt += a[i].second;
		ans = a[i].first;
		if (cnt >= k) break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int n,A[50];
int solve(int i,int m){
	if(m==0)return 1;
	if(i>=n)return 0;
	int res=solve(i+1,m) || solve(i+1,m-A[i]);
	return res;
}

int main(){
	int q,M,i;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	
	for(i=0;i<q;i++){
		scanf("%d",&M);
		if(solve(0,M))printf("yes\n");
		else
		printf("no\n");
	}
	
	return 0;
}


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

int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
}
 for(int k=0;k<n-1;k++){
        cout<<a[k]<<" ";
    }
    cout<<a[n-1]<<endl;
for(int i=1;i<n;i++){
    int v=a[i];
    int j=i-1;
    while(j>=0 && a[j]>v){
        a[j+1]=a[j];  //a[i]=vがその左のカードより小さい限り左に移動していく
        j--;
    }
    a[j+1]=v;
   
    for(int k=0;k<n-1;k++){
        cout<<a[k]<<" ";
    }
    cout<<a[n-1]<<endl;
}


return 0;
}




Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  string s;
  int ans =0;
  cin >> s;

  if(s=="SAT")  ans=1;
  if(s=="FRI")  ans=2;
  if(s=="THU")  ans=3;
  if(s=="WED")  ans=4;
  if(s=="TUE")  ans=5;
  if(s=="MON")  ans=6;
  if(s=="SUN")  ans=7;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    for(int i = 2; i < N; i += 2) {
        bool ok = true;
        for(int j = 0; j < (N - i) / 2; j++) {
            if(S[j] != S[j + (N - i) / 2]) {
                ok = false;
                break;
            }
        }
        if(ok) {
            cout << N - i;
            return 0;
        }
    }
    cout << 0;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
def kore(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return kore(num//26-1)+chr(90)
    else:
        return kore(num//26)+chr(64+num%26)
s=kore(N)
s=s.lower()
print(s)


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    string S;
    cin>>S;
    if(S=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <climits>
#include <stack>
#define FOR(i,p,k) for(int i = (p);i<(k);i++)
typedef long long int LL;
using namespace std;

string s;
int k ;

void dane() {
	cin>>s;
	cin>>k;

	int pos = 0;
	int last = s.length() - 1;
	//przechodzimy i zmieniamy na A
	FOR(i,0, last+1) {
		//sprawdzamy czy da sie zmienic na A
		if(s[i] == 'a') 
			continue;
	
		int roznica = 'z' - s[i] + 1;
		if(roznica <= k) {
			//zmieniamy na A
			s[i] = 'a';
			k-=roznica;			
		}
	}

	//pozostałe operacje od tyłu przesuwamy
	//cout<<"ZOSTALO : "<<k<<"\n";
	int ile = 'z' - 'a' + 1;
	k%=ile;
	s[last] = s[last] + k;
	while(s[last] > 'z')
		s[last]-=('z'-'a' +1);

	cout<<s<<"\n";
}

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

Measured memory_bytes: 512
# 入力を受け取る
N = int(input().strip())
A = input().strip().split()
A = [None] + [int(a) for a in A] # 整数に変換
B = input().strip().split()
B = [None] + [int(b) for b in B] # 整数に変換
C = input().strip().split()
C = [None] + [int(c) for c in C] # 整数に変換

satisfaction = 0
for i in range(1, N+1): # i = 0, 1, ..., N-1
    satisfaction += B[A[i]]
    if i >= 2 and A[i] == A[i - 1] + 1 :
        satisfaction += C[A[i - 1]]

print(satisfaction)

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll H; cin >> H;
	ll cnt{0};
	ll res{0};
	while (true)
	{
		res += pow(2, cnt);
		++cnt;
		if (H == 1) break;
		else H = H/2;
	}

	std::cout << res << std::endl;
	
	return 0;
}


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

int main(){
 int x, y, z;
 x = 1;
 y = 1;
 z = 1;

 while(true){
  cin >> x >> y;
  if(x == 0 && y == 0) break;
  if(x>y){
   z = x;
   x = y;
   y = z;
  }
  cout << x << " " << y << endl;
 }

} 




Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, x; cin >> n >> x;
	int now = 0, ans = 1;
	for (int i = 0; i < n; i++){
		int l; cin >> l;
		now += l;
		if (now <= x) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int count(ll x){
	int cnt = 0;
	while(x != 0){
		cnt++;
		x /= 10;
	}
	return cnt;
}

int main()
{
	int x , a , b;
	cin >> x >> a >> b;
	if(a >= b)
		cout << "delicious" << endl;
	else if(b > a && b <= a + x)
		cout << "safe" << endl;
	else 
		cout << "dangerous" << endl;
	return 0;
} 




Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

#define ll long long

int main()
{
	ll n;
	cin>>n;
	for(ll i=sqrt(n);i>=1;i--)
	{
		ll a = floor(1.0 * n / i);
		ll b = ceil(1.0 * n / i);
		if(a == b)
		{
			ll k = 0;
			while(a)
			{
				a /= 10;
				k++;
			}
			cout<<k<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
<?php

class Distance
{
    public function __construct(Point $point1, Point $point2)
    {
        $this->point1 = $point1;
        $this->point2 = $point2;
    }

    public function compute()
    {
        return sqrt(
            pow($this->point2->x() - $this->point1->x(), 2)
          + pow($this->point2->y() - $this->point1->y(), 2)
        );
    }
}

class Point
{
    private $x;
    private $y;

    public function __construct($x, $y)
    {
        $this->x = $x;
        $this->y = $y;
    }

    public function x()
    {
        return $this->x;
    }

    public function y()
    {
        return $this->y;
    }
}

fscanf(STDIN, '%f %f %f %f', $x1, $y1, $x2, $y2);

$point1 = new Point($x1, $y1);
$point2 = new Point($x2, $y2);

echo (new Distance($point1, $point2))->compute(), PHP_EOL;

Measured memory_bytes: 15444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod  1000000007
#define pb push_back
#define mk make_pair
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ld long double
#define fi first
#define se second
#define setbits __builtin_popcount
//Please check edge cases
int main()
{
    fastIO;
    string str;
    cin>>str;
    ll i,x,y,ans=0;
    x=str.length();
    y=x;
    y/=2; 
    for(i=0;i<y;i++)
    {
        if(str[i]!=str[x-1-i])
        {
            ans++;
        }
    }
  
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int n;
  int multiple_of_4 = 0;
  int multiple_of_2 = 0;
  int not_multiple_of_4 = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    if(a%4 == 0) multiple_of_4++;
    else if(a%2 == 0) multiple_of_2++;
    else not_multiple_of_4++;
  }
  if(not_multiple_of_4 == 0) cout << "Yes" << endl;
  else {
    if(multiple_of_4 == 0) cout << "No" << endl;
    else {
      if(multiple_of_2 == 0) {
        if(multiple_of_4 >= not_multiple_of_4-1) cout << "Yes" << endl;
        else cout << "No" << endl;
      }else {
        if(multiple_of_4 >= not_multiple_of_4) cout << "Yes" << endl;
        else cout << "No" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y, Z;
    cin >> X >> Y >> Z;
    swap(X, Y);
    swap(X, Z);
    cout << X << " " << Y << " " << Z << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    rep(i, h)cin >> c[i];
    int ans = 0;
    rep(h_bit, (1<<h)){
        rep(w_bit, (1<<w)){
            int now = 0;
            rep(i, h){
                rep(j, w){
                    if(c[i][j] == '#'){
                        if((h_bit & (1<<i)) && (w_bit & (1<<j)))now++;
                    }
                }
            }
            ans += (k == now);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628