akhauriyash/Code-Regression huggingface dataset:
#ifndef TEMPLATE
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define mp make_pair
#define sz(a) ((int)(a).size())
#define mem(x,v) memset((x),(v),sizeof((x)));
#define A(x) (x).begin(),(x).end()
#define re(i,n) for(int i=0;i<(int)n;i++)
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define erp(i,k,n) for(int i=n;i>=k;i--)
#define input(v,n) re(i,n)cin>>v[i]
using vi = vector<int>;
using vpi = vector<pair<int,int>>;
using vvi = vector<vi>;
using tp = tuple<int,int,int>;
using pi = pair<int,int>;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = numeric_limits<int> :: max() - (int)9e6;
#endif
// ===================== MANASH =================== //

int n;

void test() {

      int W; cin >> n >> W;
      vvi dp(n+1,vi(W+1));
      vpi vec(n+1);
      rep(i,1,n) {
            cin >> vec[i].second >> vec[i].first;
      }
      for( int i = 1; i <= n; i++) {
            for( int w = 0; w <= W; w++) {
                  dp[i][w] = dp[i-1][w];
                  if (vec[i].second <= w ) {
                        dp[i][w] = max(dp[i][w],vec[i].first+dp[i-1][w-vec[i].second]);
                  }
            }
      }
      cout << dp[n][W];
}

signed main() {

      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
      int T = 1;
      //cin >> T;
      for( int tt = 1; tt <= T; tt++) {
            //cout << "Case #" << tt << " ";
            test();
            cout << "\n";
      }
      return 0;

}

Measured memory_bytes: 83144
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
LL A[N],n,wynik;
int32_t main(void) {
    boost;
    cin>>n;
    int zle=0;
    f1(i,n) {
        cin>>A[i];
        if(A[i]>i-1) zle=1;
    }
    int akt=0;
    for(int i=n;i>0;i--) {
        if(akt>A[i]) zle=1;
        if(akt<A[i]) {
            akt=A[i];
            wynik+=akt;
        }
        akt--;
    }
    if(zle==1) cout<<"-1\n";
    else cout<<wynik<<endl;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = 25 - Integer.parseInt(sc.next());
		ou.print("Christmas");
		for(int i = 0 ; i < n ; i++) ou.print(" Eve");
		ou.println();
		ou.flush();
	}
}

Measured memory_bytes: 35436
//#include "/Users/HIMANSHU PANDEY/Desktop/coding/stdc++.h"
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define ins insert
#define sb substr
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define pll pair<ll,ll>
#define pld pair<ld,ld>
using namespace std;
 
ll power(ll x, ll y);
ll mpower(ll x, ll y, ll p);
ll modInv(ll a, ll m);
ll gcdExtended(ll a, ll b, ll *x, ll *y);
bool isPrime(ll n);
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,i,j,k,l,h,p,q,r,x,y,z,a,b,c,d,f,n,m,M=1000000007;
    char ch,ch2,ch3;
    string s,s1,s2,s3;
     t=1;
  // cin>>t;
    while(t--)
    {
        vector<ll> v,w;
        unordered_map<ll,ll> N;
        set<ll> S,SS;
		cin>>n;
		z=0,k=0;
		for(i=0;i<n;i++)
		{
		    cin>>x>>y;
		    if(x==y)
		    {
		        z++;
		    }
		    else
		    {
		        k=max(k,z);
		        z=0;
		    }
		}
		k=max(k,z);
		if(k>=3)
		{
		    cout<<"Yes";
		}
		else
		{
		    cout<<"No";
		}
    }
    return 0;
}
 
ll modInv(ll a, ll m)
{
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}
 
ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}
 
ll mpower(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while(y > 0){
        if(y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
 
ll power(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}
 
bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}

Measured memory_bytes: 3668
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define SIZE 26     
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int N = 3005;

signed main(){
    fastio;
    ll i,j,n;
    cin>>n;
    ld dp[n+1][n+1],p[n+1],ans=0;
    for(i=1;i<=n;++i){
        cin>>p[i];
    }
    fill(dp,0);
    dp[0][0]=1;
    for(i=1;i<=n;++i){
        for(j=1;j<=i;++j){
            dp[j][i-j]+=dp[j-1][i-j]*p[i];
            dp[i-j][j]+=dp[i-j][j-1]*(1.00000-p[i]);
        }
    }
    for(i=n;i>=(n+1)/2;--i){
        ans+=dp[i][n-i];
    }
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }

    vector<vector<int>> db;
    vector<int> cur(n);
    db.push_back(a);
    int j = 0;
    for(ll i = 2; i <= k; i *= 2) {
        // vector<int> cur(n);
        rep(i, n) {
            cur[i] = db[j][db[j][i]];
        }
        db.push_back(cur);
        ++j;
    }

    int now = 0;
    for(int dg = 0; k > 0; dg++) {
        if(k % 2) {
            now = db[dg][now];
        }
        k /= 2;
    }
    cout << now + 1 << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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


Measured memory_bytes: 51668
s = input()
t = input()
n = len(s)
m = len(t)
dp = [[0 for j in range(1 + m)] for i in range(1 + n)]
for i in range(1, n + 1):
    for j in range(1, m + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
res = ""
i, j = n, m
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        res = s[i - 1] + res
        i -= 1
        j -= 1
print(res)

Measured memory_bytes: 153080
#include<stdio.h>

int main()
{
  int A[100];
  int N;
  int key;
  int i, j, k;

  //Read N and keys
  scanf("%d", &N);
  for(i=0; i<N; i++)scanf("%d", &A[i]);

  //Sort
  for(i=0; i<N; i++)
    {
      key=A[i];
      j=i-1;

      //if A[j]>key, change A[j] into A[j+1]
      while(j>=0 && A[j]>key)
	{
	  A[j+1]=A[j];
	  j=j-1;
	}
      A[j+1]=key;

      //print
      for(k=0; k<N; k++)
	{
	  printf("%d", A[k]);
	  if(k!=N-1)printf(" ");
	}
      printf("\n");
    }

  return 0;
}

Measured memory_bytes: 0
// Ref. https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve() {
	int ans = 0;

	bool V[MAX];
	for (int i = 0; i < n; i++) {
		B[i] = A[i];
		V[i] = false;
	}
	sort(B, B + n);
	for (int i = 0; i < n; i++) T[B[i]] = i;
	for (int i = 0; i < n; i++) {
		if (V[i]) continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while (1) {
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if (V[cur]) break;
		}
		ans += min(S + (an - 2)*m, m + S + (an + 1)*s);
	}
	return ans;
}

int main() {
	cin >> n;
	s = VMAX;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		s = min(s, A[i]);
	}
	int ans = solve();
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(){

    vector<int> s, t;
    int a;
    int ans=0;

    int n; scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a);
        s.push_back(a);
    }
    int m; scanf("%d", &m);
    for(int i = 0; i < m; i++){
        scanf("%d", &a);
        t.push_back(a);
        if(binary_search(s.begin(), s.end(), a)) ans++;
    }
    printf("%d\n", ans);

}



Measured memory_bytes: 3548
using System;

namespace ITP1_6_A {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            string[] s = Console.ReadLine().Split(' ');
            for(int i = 0; i < n; i++) {
                a[i] = int.Parse(s[i]);
            }
            Array.Reverse(a);
            for(int i = 0; i < n; i++) {
                if(i == n - 1) {
                    Console.Write(a[i] + "\n");
                } else {
                    Console.Write(a[i] + " ");
                }
            }
        }
    }
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

// <---------------------- > //

ll f(ll n, ll x)  {
	if(n < 0) return 0;
	return n/x+1;
}

// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,x;
	cin>>a>>b>>x;

	ll left = f(b,x);
	ll ri = f(a-1,x);

	cout<<left - ri;
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {

		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
int mod=998244353;

int main(){
    int N;cin>>N;
    vec D(100010);
    cin>>D[0];
    if(D[0]==0){
        map<int,int> mp;
        for(int i=1;i<N;i++){
            cin>>D[i];
            mp[D[i]]++;
        }
        int k=1,front=1;
        ll ans=1;
        for(auto itr=mp.begin();itr!=mp.end();itr++){
            if(itr->first==k){
                ll res=1;
                for(int j=0;j<itr->second;j++){
                    res=(ll)(res*(ll)front)%mod;

                }
                ans=(ans*res)%mod;
                k++;
                front=itr->second;;
            }
            else{
                cout<<0<<endl;
                return 0;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    else {
        cout<<0<<endl;
        return 0;
    }
    
}

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

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

#define int ll


main(){
	int n;
	cin >> n;
	int a =  1000 - (n%1000);
	if(a==1000){
		cout << "0" << endl;
	}else{
		cout << a << endl;
	}


	return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <cassert>
 
using namespace std;
 
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define S(x) 			scanf("%d",&x)
#define SS(x,y)         scanf("%d%d",&x,&y)
#define all(c) 			(c).begin(),(c).end() 
#define sz(c) 			int((c).size())
#define pb 				push_back
#define present(c,x) 	((c).find(x) != (c).end()) 
#define rep(i,x,y) 		for(int i = x; i <= y; i++)
#define REV(i,x,y) 		for(int i = x; i >= y; i--)
#define foreach(c,itr)	for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define FILL(a,v) 		memset(a,v,sizeof(a))
#define DB(x)			cerr<<#x<<" = "<<x<<endl
#define debugarr(A,a,b) cerr<<#A<<" : ";rep(i,a,b) cerr<<A[i]<<" ";cerr<<endl;
//#define R(x) 			((rand()%x) + 1)
 
typedef long long int LL;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii;
typedef vector<ii> vii;
 
/* ------------------------Main Code----------------------- */
const int MAX = 200001, mod = 1e9 + 7;
 
LL A[MAX];

bool cmp(const LL &x, const LL &y)
{
	return abs(x) < abs(y);
}

LL findMin(int l, int r,int parity)
{
	LL mn = mod;
	rep(i,l,r) if(A[i]*parity > 0) mn = min(mn,abs(A[i]));
	return mn;
}

LL findMax(int l, int r, int parity)
{
	LL mx = -1;
	rep(i,l,r) if(A[i]*parity > 0) mx = max(mx,abs(A[i]));
	return mx;
}

LL inv(LL a, LL b, LL m)
{
	if(b == 0) return 1;
	LL k = inv(a,(b>>1),m);
	k = (k*k) % m;
	if(b&1) k = (k*a) % m;
	return k;
}

int main()
{

		int n, k;
		SS(n,k);
		rep(i,0,n-1) scanf("%lld",&A[i]);
		sort(A,A+n,cmp);
		int l = 0, r = n-1, cntNegative = 0;
		LL res = 1;
		rep(i,1,k){
			res = (res*abs(A[n-i])) % mod;
			if(A[n-i] < 0) cntNegative++;
		}
		if(cntNegative & 1){
			LL abovePositive = findMin(n-k,n-1,1);
			LL belowNegative = findMax(0,n-k-1,-1);
			LL aboveNegative = findMin(n-k,n-1,-1);
			LL belowPositive = findMax(0,n-k-1,1);
			if(abovePositive != mod && aboveNegative != mod && belowPositive != -1 && belowNegative != -1){
				if(belowNegative*aboveNegative < belowPositive*abovePositive){
					res = (res * belowPositive) % mod;
					res = (res * inv(aboveNegative,mod-2,mod)) % mod;
				}else{
					res = (res * belowNegative) % mod;
					res = (res * inv(abovePositive,mod-2,mod)) % mod;
				}
			}else if(abovePositive != mod && belowNegative != -1){
				res = (res * belowNegative) % mod;
				res = (res * inv(abovePositive,mod-2,mod)) % mod;
			}else if(aboveNegative != mod && belowPositive != -1){
				res = (res * belowPositive) % mod;
				res = (res * inv(aboveNegative,mod-2,mod)) % mod;
			}else{
				
				rep(i,0,n-1) if(A[i] < 0){
					A[i] *= -1;
				}
				sort(A,A+n);
				res = 1;
				rep(i,0,k-1) res = (res*A[i]) % mod;
				if(res != 0) res = mod - res;
			}
		}
		printf("%lld\n",res);
	
	return 0;
} 


Measured memory_bytes: 5408
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    vl b = a;
    sort(all(b));
    ll s = b[n/2-1];
    ll t = b[n/2];
    rep(i,n){
        if(s==t) cout << s << endl;
        else{
            if(a[i] <= s) cout << t << endl;
            if(a[i] >= t) cout << s << endl;
        }
    }
}

Measured memory_bytes: 5376
use std::cmp::{max, min};

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut min_x = 1;
    let mut max_x = n;
    for _ in 0..m {
        let l: i32 = read(&mut stdin_lock, &mut buf, b' ');
        let r: i32 = read(&mut stdin_lock, &mut buf, b'\n');
        min_x = max(min_x, l);
        max_x = min(max_x, r);
    }
    let ans = if max_x < min_x { 0 } else { max_x - min_x + 1 };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<ll> a(n),b(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	// sort(all(b));

	ll ans = 0;
	rep(k,29){
		ll target = 1<<k;
		ll m = target*2;
		vector<ll> b2=b,a2=a;
		rep(i,n) b2[i]%=m,a2[i]%=m;
		sort(all(b2));
		int cnt = 0;
		rep(i,n){
			int l = lower_bound(all(b2),target-a2[i])-b2.begin();
			int r = lower_bound(all(b2),2*target-a2[i])-b2.begin();
			cnt += r-l;

			l = lower_bound(all(b2),3*target-a2[i])-b2.begin();
			r = lower_bound(all(b2),4*target-a2[i])-b2.begin();

			cnt += r-l;
		}
		if(cnt%2!=0) ans += target;
	}

	cout<<ans<<endl;

	return 0;
}

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

#define lli long long int
#define LLI(n) lli n; scanf("%lld", &n);
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define YES puts("YES");
#define NO puts("NO");

//素数
bool IsPrime(lli num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)return false;
  }
  return true;
}
//各桁の和
lli Sum(lli n)
{
  lli sum=0;
  if (n<0) return 0;
  while (n>0)
  {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  LLI(a);
  LLI(b);
  LLI(c);
  a = a*100 + b*10 + c;
  if(a%4==0)YES
  else NO
  return 0;
 }


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

using namespace std;

const int N = 2000000 + 10;

// struct Node {
//     int pos, v;
//     bool operator < (const Node &tmp) const { return v < tmp.v; }
// }a[N], b[N];

int a[N], b[N], c[N], n;

int check() {
    unordered_map <int, int> ump1, ump2;
    for (int i = 1; i <= n; i++)    ump1[a[i]]++;
    for (int i = 1; i <= n; i++)    ump2[b[i]]++;
    int res = 0;
    for (auto x : ump1) {
        if (ump2.count(x.first)) {
            if (min(x.second, ump2[x.first]) > n / 2) {
                return -1;
            }
            res = max(res, max(x.second, ump2[x.first]));
        }
    }
    return res;
}

int main() {
    cin >> n;    
    for (int i = 1; i <= n; i++)    scanf("%d", a + i);
    for (int i = 1; i <= n; i++)    scanf("%d", b + i);
    unordered_map <int, pair<int,int>> ump1, ump2;
    for (int i = 1; i <= n; i++) {
        if (ump1.count(a[i]))   ump1[a[i]].second = i;
        else    ump1[a[i]] = {i, i};
    }
    for (int i = 1; i <= n; i++) {
        if (ump2.count(b[i]))   ump2[b[i]].second = i;
        else    ump2[b[i]] = {i, i};
    }
    int L = 0, R = 2 * n;
    for (auto x : ump1) {
        int val = x.first;
        if (ump2.count(val)) {
            int l1 = ump1[val].first, r1 = ump1[val].second;
            int l2 = ump2[val].first, r2 = ump2[val].second;
            L = max(L, r1 - l2 + 1);
            R = min(R, l1 + n - r2 - 1);
        }
    }
    if (L <= R) {
        cout << "Yes\n";
        int dx = L;
        for (int i = 1; i <= n; i++)    c[(i + dx - 1) % n + 1] = b[i];
        for (int i = 1; i <= n; i++)    cout << c[i] << ' ';
    }
    else {
        cout << "No\n";
    }
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}


Measured memory_bytes: 21840
def solve():
  N, K = map(int, input().split())
  if K > (N - 1) * (N - 2) // 2:
    print(-1)
    return
  else:
    root = [[False for _ in range(N + 10)] for _ in range(N + 10)]
    M = (N - 1) * (N - 2) // 2 - K
    i = 1
    j = 2
    print(M + N - 1)
    for k in range(N - 1):
      print('1 {}'.format(k + 2))
    for _ in range(M):
      print('{0} {1}'.format(i + 1, j + 1))
      j += 1
      if j == N:
        i += 1
        j = i + 1
    return
solve()

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

int main(){
  int x;
  string y;
  cin>>x;
  int i=0;
  while(i<x){
    cin>>y;
    if(y=="Y"){
      cout<<"Four"<<endl;
      break;
    }
    else{
    i++;
    }
  }
  if(i==x&&y!="Y"){
  cout<<"Three"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};

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


signed main(void) {
	int n;
	cin >> n;

	int d[201][201] = {};
	vector<vector<int>> g(n);
#define INF 10000

	REP(i, n) {
		string s;
		cin >> s;
		REP(j, n) {
			
			d[i][j] = s[j] - '0';
			if (d[i][j] == 0 ) {
				if(i != j)
					d[i][j] = INF;
			}
			else {
				g[i].push_back(j);
			}
		}
	}

	int label[201] = {};

	function<bool(int, int)> check = [&](int cur, int par) {

		if (label[cur] != 0) {
			if (label[cur] == label[par])
				return true;
			else
				return false;
		}

		if (label[par] == 1)
			label[cur] = 2;
		if (label[par] == 2)
			label[cur] = 1;
		if (label[par] == 0)
			label[cur] = 1;

		
		for (auto itr : g[cur]) {
			if (itr == par) continue;
			bool ret = check(itr, cur);
			if (ret)
				return true;
		}
		return false;
	};

	if (check(0,0)) {
		cout << -1 << endl;
		return 0;
	}


	for (int k = 0; k < n; k++) {       // 経由する頂点
		for (int i = 0; i < n; i++) {    // 始点
			for (int j = 0; j < n; j++) {  // 終点
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	int Min = 0;
		REP(i, n) {
			REP(j, n) {
				Min = max(Min, d[i][j] + 1);
			}
		}
	cout << Min << endl;

	return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**5)
def input():
    return sys.stdin.readline()[:-1]
N,u,v = map(int,input().split(' '))
l = [None]*N
for i in range(N-1):
    l[i] = list(map(int, input().split()))

MAP = {}
for i in range(N):
    if l[i]==None:
        continue
    a,b = l[i]
    if a in MAP:
        MAP[a].append(b)
    else:
        MAP[a] = [b]
    if b in MAP:
        MAP[b].append(a)
    else:
        MAP[b] = [a]

#Tがたどり着くのにかかる手数
t_MAP = [0]*(N+1)
cost = 0

def t_dfs(n,c):
    t_MAP[n] = c
    c += 1
    if n in MAP:
        for j in MAP[n]:
            if t_MAP[j]==0 and j!=u:
                t_dfs(j,c)
t_dfs(u,cost)

a_visited = [False]*(N+1)
break_even = False
pre_tcost = 10**5
ANS = [0]
def a_dfs(n,c,pre_c):
    a_visited[n] = True
    t_cost = t_MAP[n]
    if t_cost>c:
        if t_cost>pre_c:
            return
    ANS[0] = max(c,ANS[0])
    c += 1
    if n in MAP:
        for j in MAP[n]:
            if not a_visited[j]:
                a_dfs(j,c,t_cost)
a_visited[v] = True
a_dfs(v,cost,pre_tcost)
print(ANS[0]-1)


Measured memory_bytes: 119704
#include <stdio.h>

int main( void ) {
	int h, m, s, t1, t2;

	for ( ; scanf( "%d %d %d", &h, &m, &s ), h != -1; printf( "%02d:%02d:%02d\n%02d:%02d:%02d\n", t1 / 3600, t1 / 60 % 60, t1 % 60, t2 / 3600, t2 / 60 % 60, t2 % 60 ) ) {
		t1 = 7200 - h * 3600 - m * 60 - s;
		t2 = t1 * 3;
	}

	return 0;
}

Measured memory_bytes: 612
def readInts():
	return list(map(int, input().split()))

n,m = readInts()
ab = [readInts() for i in range(n)]
cd = [readInts() for i in range(m)]

for i in ab:
	ansv = float("inf")
	ansi = -1
	for j in range(len(cd)):
		if abs(i[0]-cd[j][0])+abs(i[1]-cd[j][1])<ansv:
			ansv = abs(i[0]-cd[j][0])+abs(i[1]-cd[j][1])
			ansi = j+1
	print(ansi)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int arr[] = {10, 5, 1};
int a, b, c;
int n;
bool isok(int y)
{
  repn(i, 0, n)
  {
    repn(j, 0, n)
    {
      ll l = 10*i + 5*j;
      int k = n - i - j;
      if(l+k == y && k >= 0)
      {
        a = i, b= j, c= k;
        return true;
      }
    }
  }
  return false;
}

int main()
{
  int y;
  cin>>n>>y;
   y = y / 1000;
   if(isok(y)) printf("%d %d %d\n", a, b, c);
   else printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

struct edge{int from,to,c;};

int main(){
    int MAX_V = 2510, MAX_E = 5020;
    int V,E,P; cin>>V>>E>>P;
    vector<edge> ed(MAX_E);
    vector<ll> p(MAX_V,INF);
    rep(i,E){cin>>ed[i].from>>ed[i].to>>ed[i].c; ed[i].c *= -1;}

    p[1] = 0;
    rep(i,V){
        rep(j,E){
            edge e = ed[j];
            if(p[e.from] != INF && p[e.to]> p[e.from]+e.c+P){
                p[e.to] = p[e.from]+e.c+P;
            }
        }
    }

    vector<bool> neg(MAX_V,false);
    rep(i,V){
        rep(j,E){
            edge e = ed[j];
            if(p[e.from] != INF && p[e.to]> p[e.from]+e.c+P){
                p[e.to] = p[e.from]+e.c+P;
                neg[e.to] = true;
            }
            if(neg[e.from])neg[e.to] = true;
        }
    }

    if(neg[V])cout<<-1<<endl;
    else cout<<max(-p[V],0LL)<<endl; return 0;
}


Measured memory_bytes: 384
// https://atcoder.jp/contests/abc163/tasks/abc163_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    cout << setprecision(12) << 2 * 3.14159265358979 * N << endl;

    return 0;
}


Measured memory_bytes: 3792
use std::collections::HashMap;
use std::num;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        p: usize,
    }
    let mut p = p;
    let mut hash = HashMap::new();
    let sqrt = (p as f64).sqrt() as usize;

    for i in 2..sqrt+1 {
        let mut r = 0;
        if p % i == 0 {
            loop {
                r += 1;
                p /= i;
                if p % i != 0{
                    break;
                }
            }
            hash.insert(i, r);
        }
    }
    if p > sqrt {
        hash.insert(p, 1);
    }

    println!("{}", hash.iter().fold(1, |med, mer| med * (mer.0).pow(((mer.1)/n) as u32)));
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    cin>>str;
    if(str[0]==str[1]&&str[1]==str[2]){
    	cout<<"No\n";
    }
    else cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//ABC130
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int n,m; cin>>n>>m;
    vector<int> s(n),t(m);
    rep(i,n)cin>>s[i];
    rep(i,m)cin>>t[i];

    vector<vector<int>> dp(n+1,vector<int>(m+1,1));
    rep(i,n){
        rep(j,m){
            if(s[i]==t[j]){
                dp[i+1][j+1]=(dp[i][j+1]+dp[i+1][j])%mod;
            }else{
                int tmp=dp[i+1][j]+dp[i][j+1];
                tmp%=mod;
                tmp-=dp[i][j];
                tmp%=mod;
                if(tmp<0)tmp+=mod;
                dp[i+1][j+1]=tmp;
            }
        }
    }
    cout<<dp[n][m]<<endl;

}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int t; cin>>t;
  int ac=0,wa=0,tle=0,re=0;
  while(t--)
  {
    string s; cin>>s;
    if(s=="AC") ++ac;
    if(s=="WA") ++wa;
       if(s=="TLE") ++tle;
    if(s=="RE") ++re;
  }
  cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";

    cout<<"TLE x "<<tle<<"\n";

    cout<<"RE x "<<re<<"\n";

  return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c1 = new char[s.length() / 2];
        char[] c2 = new char[s.length() / 2 + 1];
        for (int i = 0; i < s.length() / 2; i++) {
            c1[i] = s.charAt(i);
        }
        for (int i = s.length() - 1; i >= s.length() / 2; i--) {
            c2[s.length() - 1 - i] = s.charAt(i);
        }
        int ans = 0;
        for (int i = 0; i < s.length() / 2; i++) {
            if (c1[i] != c2[i]) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#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: 2040
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    ll n, k, q; cin >> n >> k >> q;
    vector<ll> lis(n+1, k-q);
    REP(i, 0, q){
        int a; cin >> a;
        lis[a]++;
    }
    REP(i, 1, n+1){
        if(lis[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

ll gcd(ll x,ll y){
    if (y==0) return x;
    return gcd(y,x%y);
}
ll lcm(ll x,ll y){
    return x/gcd(x,y)*y;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,X,D; cin >> N >> X >> D;
    if (X==0&&D==0){
        cout << 1 << endl;
        return 0;
    }
    if (D==0){
        cout << N+1 << endl;
        return 0;
    }
    if (X==0){
        cout << N*(N-1)/2+1 << endl;
        return 0;
    }
    ll G=gcd(abs(X),abs(D)); X/=G,D/=G;
    if (D<0) X*=-1,D*=-1;
    map<ll,multiset<Pll>> border;
    rep(i,N+1){
        ll m=(i-1)*i/2,M=i*(2*N-1-i)/2+1;
        border[i%D].emplace(i*X+m*D,1);
        border[i%D].emplace(i*X+M*D,-1);
    }
    ll ans=0;
    for (auto b:border){
        ll now=0,pre;
        for (auto p:b.second){
            if (!now) pre=p.first;
            now+=p.second;
            if (!now) ans+=(p.first-pre)/D;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 50304
# coding: UTF-8
import sys
sys.setrecursionlimit(10**5)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

R, G, B, N = map(int, input().split())
count = 0
for i in range(N + 1):
    for j in range(N + 1):
        t = N - (i * R + G * j)
        if t < 0:
            break
        if t % B == 0:
            count += 1
print(count)

Measured memory_bytes: 6480
using System;

namespace ABC061C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            int N = Int32.Parse(bufs[0]);
            long K = Int64.Parse(bufs[1]);

            int[] a = new int[N];
            int[] b = new int[N];

            for (int i = 0; i < N; i++)
            {
                bufs = Console.ReadLine().Split(' ');
                a[i] = Int32.Parse(bufs[0]);
                b[i] = Int32.Parse(bufs[1]);
            }

            Array.Sort(a, b);
            int idx = -1;
            while (K > 0)
            {
                idx++;
                K -= b[idx];
            }

            Console.WriteLine(a[idx]);
        }
    }
}


Measured memory_bytes: 15816
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int q;
	cin>>q;
	vi dp(20010);
	loop(i,-150,150)loop(j,-150,150)if(1<=i*i+j*j&&i*i+j*j<20010)dp[i*i+j*j]++;
	while(q--){
		int a,b;
		cin>>a>>b;
		a=a*a+b*b;
		bool h=true;
		loop(i,2,a)if(dp[i]&&a%i==0)h=false;
		if(h)cout<<"P"<<endl;
		else cout<<"C"<<endl;
	}
}

Measured memory_bytes: 3172
#include<iostream>
#include<stack>
using namespace std;
int main(){
  int N;
  cin >> N;
  int boll[10];
  stack<int> B,C;
  for(int i=0;i<N;i++){
    B.push(0); C.push(0);
    for(int j=0;j<10;j++) cin >> boll[j];
    for(int j=0;j<10;j++){
        if(boll[j]>B.top()) B.push(boll[j]);
        else if(boll[j]>C.top()) C.push(boll[j]);
        else{
          cout << "NO" << endl;
          break;
        }
        if(j==9) cout << "YES" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-7
long long mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
int n , h[100005] , memo[100005];
ll solve(int i)
{
    if(i == n - 1)
        return 0;
    if(memo[i] != -1)
        return memo[i];
    ll ans = 0;
    if(i + 2 <= n - 1)
        ans += min(abs(h[i] - h[i + 1]) + solve(i + 1) , abs(h[i] - h[i + 2]) + solve(i + 2));
    else
        ans += abs(h[i] - h[i + 1] + solve(i + 1)) ;
    memo[i] = ans;
    return ans;
}

int main()
{
    em3
    cin >> n ;
    memset(memo , -1 , sizeof memo);
    for(int i = 0 ; i < n ; i++)
        cin >> h[i];
    cout << solve(0) << endl;


    return 0;
}


Measured memory_bytes: 3328
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var a = cin.ReadIntArray(N);
            var m = N + N - 1;
            WriteLine(m);
            if (Abs(a.Max()) >= Abs(a.Min()))
            {
                for (int i = 0; i < N; i++)
                {
                    WriteLine((Array.IndexOf(a, a.Max()) + 1) + " " + (i + 1));
                }
                for (int i = 0; i < N - 1; i++)
                {
                    WriteLine(i + 1 + " " + (i + 2));
                }
            }
            else
            {
                for (int i = 0; i < N; i++)
                {
                    WriteLine((Array.IndexOf(a, a.Min()) + 1) + " " + (i + 1));
                }
                for (int i = N; i >= 2; i--)
                {
                    WriteLine(i + " " + (i - 1));
                }
            }

        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.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; }
        }
    }
}


Measured memory_bytes: 13396
N = int(input())

W = [input() for i in range(N)]

def alg1(W):
  list = [W[0],]
  point = W[0]
  for i in range(1,N):
    if W[i] not in list and W[i][0] == point[-1]:
      list.append(W[i])
      point = W[i]
    else:
      return 'No'
  return 'Yes'

print(alg1(W))

Measured memory_bytes: 3060
def main():
    n,k = map(int,input().split())
    s = input()

    res = []
    buf = '1' # start:1 kara NG->s[0]
    cnt = 0
    for i in range(n):
        if s[i] == buf:
            cnt += 1
        else:
            res.append(cnt)
            buf = s[i]
            cnt = 1
    if cnt != 0:
        res.append(cnt)

    if len(res)%2 == 0:
        res.append(0) # end:1 no kosu

    #from itertools import accumulate
    #rui = list(accumulate(res))
    rui = [0]*(len(res)+1)
    for i in range(len(rui)-1):
        rui[i+1] = rui[i] + res[i]

    ans = 0
    for i in range(0,len(res),2): # 1 only
        left = i
        right = min(i+2*k+1, len(res))
        tmp = rui[right] - rui[left]
        ans = max(tmp,ans)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 46192