akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		double win = 0;
		for(int i=1;i<=n;i++) {
			int m=i;
			int j;
			for(j=1;m<k;j++) {
				m = m*2;
			}
			win = win + Math.pow(0.5, j-1);
		}
		win = win/n;

		System.out.println(win);
	}
}


Measured memory_bytes: 20816
P = 998244353
A, B, C, D = map(int, input().split())
X = [[0] * 3001 for _ in range(3001)]
for a in range(3001):
    for b in range(3001):
        if a < A or b < B: continue
        if a == A and b == B:
            X[a][b] = 1
        elif a == A:
            X[a][b] = X[a][b-1] * a % P
        elif b == B:
            X[a][b] = X[a-1][b] * b % P
        else:
            X[a][b] = (X[a-1][b] * b + X[a][b-1] * a - X[a-1][b-1] * (a-1) * (b-1)) % P

print(X[C][D])

Measured memory_bytes: 138652
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

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

int main() {
	int T;
	int money,year,N;
	bool is_fukuri;
	double per_year;
	int risoku;
	int risi;

	vector<int> final_moneys;
	cout << setprecision(12) << fixed;
	cin >> T;
	rep(t,T) {
		cin >> money >> year >> N;
		rep(i,N) {
			int moneyT = money;
			cin >> is_fukuri >> per_year >> risoku;

			if (is_fukuri) {
				rep(y,year) {
					moneyT = moneyT*(1+per_year) - risoku;
				}
			}
			else {
				risi=0;
				rep(y,year) {
					risi += moneyT*per_year;
					moneyT-=risoku;
				}
				moneyT = moneyT + risi;
			}
			final_moneys.push_back(moneyT);
		}
		cout << *max_element(all(final_moneys)) << endl;
		final_moneys.clear();
	}


	return 0;
}

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

int main () {
  int a, b;
  cin >> a >> b;
  
  if ((a + b) % 2 == 0) {
    cout << (a + b) / 2 << endl;
  }
  else {
    cout << ((a + b) / 2) + 1 << endl;
  }
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

i=0
j=1
NOW=A[0]
ANS=0
while i<N:
    if j==N:
        ANS+=(j-i)
        i+=1
        continue
    if NOW+A[j]==NOW^A[j]:
        NOW=NOW+A[j]
        j+=1
    else:
        ANS+=(j-i)
        NOW=NOW-A[i]
        i+=1      

print(ANS)

Measured memory_bytes: 24712
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ll freq[200001];
ll dp[200001];
signed main()
{
    fast;
    ll n;
    cin>>n;
    ll i;
    dp[0] = 1;
    for(i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        dp[i] = dp[i-1];
        if(freq[x] and freq[x]!=i-1)
        {
            dp[i]+=dp[freq[x]];
        }
        freq[x] = i;
        dp[i]%=mod;
    }
    cout<<dp[n];
    
    
}


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

using namespace std;

const int MAXN = 102;

int n, m, ex, ey;
int a[MAXN][MAXN], p[MAXN][MAXN];
short dp[MAXN][MAXN][MAXN][MAXN];

inline int get (int x1, int x2, int y1, int y2) {
    if (x1 > x2 || y1 > y2) return 0;
    return p[x2][y2] - p[x1 - 1][y2] - p[x2][y1 - 1] + p[x1 - 1][y1 - 1];
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            char c; cin >> c;
            a[i][j] = (c == 'o');
            p[i][j] = a[i][j] + p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1];
            if (c == 'E') ex = i, ey = j;
        }
    }
    for (int x1 = ex; x1 >= 1; x1--) {
        for (int x2 = ex; x2 <= n; x2++) {
            for (int y1 = ey; y1 >= 1; y1--) {
                for (int y2 = ey; y2 <= m; y2++) {
                    short curr = dp[x1][x2][y1][y2];
                    //cout << "bla " << x1 << " " << y1 << " " << x2 << " " << y2 << "  " << curr << endl;
                    if (x1 >= 1) {
                        short val = get(max(x1 - 1, 1 + x2 - ex), min(x1 - 1, n + x1 - ex), max(y1, 1 + y2 - ey), min(y2, m + y1 - ey));
                        dp[x1 - 1][x2][y1][y2] = max(dp[x1 - 1][x2][y1][y2], (short) (curr + val));
                    }
                    if (x2 <= n) {
                        short val = get(max(x2 + 1, 1 + x2 - ex), min(x2 + 1, n + x1 - ex), max(y1, 1 + y2 - ey), min(y2, m + y1 - ey));
                        dp[x1][x2 + 1][y1][y2] = max(dp[x1][x2 + 1][y1][y2], (short) (curr + val));
                    }
                    if (y1 >= 1) {
                        short val = get(max(x1, 1 + x2 - ex), min(x2, n + x1 - ex), max(y1 - 1, 1 + y2 - ey), min(y1 - 1, m + y1 - ey));
                        dp[x1][x2][y1 - 1][y2] = max(dp[x1][x2][y1 - 1][y2], (short) (curr + val));
                    }
                    if (y2 <= m) {
                        short val = get(max(x1, 1 + x2 - ex), min(x2, n + x1 - ex), max(y2 + 1, 1 + y2 - ey), min(y2 + 1, m + y1 - ey));
                        dp[x1][x2][y1][y2 + 1] = max(dp[x1][x2][y1][y2 + 1], (short) (curr + val));
                    }
                }
            }
        }
    }
    cout << dp[1][n][1][m];
    return 0;
}


Measured memory_bytes: 209280
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	float R,G;
	while(scanf("%f%f",&R,&G)!=EOF){
		printf("%.0f\n",2*G-R);	
	}
	
	
	return 0;	
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Item
        {
            public readonly int a;
            public readonly int b;
            public readonly int c;
            public Item(int[] V)
            {
                a = V[0];
                b = V[1];
                c = V[2];
            }
        }
        static int Solve(int N, int Ma, int Mb, Item[] items)
        {
            const int INF = 1 << 15;
            int[][][] dp = new int[N][][];
            for (int i = 0; i < N; ++i)
            {
                dp[i] = new int[401][];
                for (int a = 0; a <= 400; ++a)
                {
                    dp[i][a] = Enumerable.Repeat(INF, 401).ToArray();
                }
            }
            dp[0][0][0] = 0;
            dp[0][items[0].a][items[0].b] = items[0].c;
            for (int i = 1; i < N; ++i)
            {
                for (int a = 0; a <= 400; ++a)
                {
                    for (int b = 0; b <= 400; ++b)
                    {
                        int c = (a >= items[i].a && b >= items[i].b) ? dp[i - 1][a - items[i].a][b - items[i].b] : INF;
                        dp[i][a][b] = Math.Min(dp[i - 1][a][b], c + items[i].c);
                    }
                }
            }
            int min = INF;
            for (int a = 1; a <= 400; ++a)
            {
                for (int b = 1; b <= 400; ++b)
                {
                    if (a * Mb == Ma * b)
                    {
                        min = Math.Min(dp[N - 1][a][b], min);
                    }
                }
            }
            return (min < INF) ? min : -1;
        }
        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int N = V[0];
            var items = new Item[N];
            for (int i = 0; i < N; ++i) { items[i] = new Item(ReadInts()); }
            Console.WriteLine(Solve(N, V[1], V[2], items));
        }
    }
}


Measured memory_bytes: 45828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

ll color(ll a) {
    if ((1 <= a) && (a <= 399)) return 0;
    else if ((400 <= a) && (a <= 799)) return 1;
    else if ((800 <= a) && (a <= 1199)) return 2;
    else if ((1200 <= a) && (a <= 1599)) return 3;
    else if ((1600 <= a) && (a <= 1999)) return 4;
    else if ((2000 <= a) && (a <= 2399)) return 5;
    else if ((2400 <= a) && (a <= 2799)) return 6;
    else if ((2800 <= a) && (a <= 3199)) return 7;
    else if (3200 <= a) return 8; 
}


int main() {
    ll N; cin >> N;
    vector<ll> vec(9);
    for (ll i = 0;i<N;i++) {
        ll a = 0; cin >> a;
        ll c = color(a);
        vec.at(c) += 1;
    }
    ll cnt = 0;
    for (ll i = 0;i<8;i++) {
        if (vec.at(i) != 0) cnt++;
    }
    ll m;
    if (cnt != 0) m = cnt;
    else m = 1;
    ll M = cnt + vec.at(8);
    cout << m << " " << M << endl; 
}

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

struct Node
{
	int num, id;
}a[100010];

inline bool cmp(const Node &x, const Node &y)
{
	return x.num < y.num;
}

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i].num);
		a[i].id = i;
	}
	sort(a + 1, a + 1 + n, cmp);
	for(int i = 1; i <= n; ++i)
		printf("%d ", a[i].id);
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {

	int N;
	ll ans = 0;
	cin>>N;
	vector<ll> A(N+1);
	map<ll, pair<ll, ll>> cnt;
	for (int i = 1;i <= N;++i) {
		cin>>A[i];
		cnt[A[i]].first += 1;
		cnt[A[i]].second = (cnt[A[i]].first * (cnt[A[i]].first - 1)) / 2;
	}

	for (auto const& x : cnt) {
		ans += x.second.second;
	}

	for (int k = 1;k <= N;++k) {
		ll s = cnt[A[k]].second;
		ll t = ((cnt[A[k]].first - 1) * (cnt[A[k]].first - 2)) / 2;
		ans -= s;
		ans += t;
		cout<<ans<<endl;
		ans += s;
		ans -= t;
	}

	return 0;
}


Measured memory_bytes: 12160
#include<iostream>
using namespace std;
int main()
{
	int z,n,k,i,j,ans=0;
	cin>>n>>z;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			k=z-i-j;
			if(k<=n&&k>=0)
			{
				ans++;
				//cout<<i<<" "<<j<<" "<<k<<endl;
			}
		}	
	}	
	cout<<ans<<endl;
	return 0;
} 

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

using namespace std;

int main()
{
	int prices[4];
	long long N;
	for (int i = 0; i < 4; i++)
	{
		cin >> prices[i];
	}
	cin >> N;
	N *= 1000;

	int volumes[4] = { 250, 500, 1000, 2000 };
	pair<int, int> pricesPer2L[4];
	pricesPer2L[0].second = prices[0] * 8;
	pricesPer2L[1].second = prices[1] * 4;
	pricesPer2L[2].second = prices[2] * 2;
	pricesPer2L[3].second = prices[3];

	for (int i = 0; i < 4; i++)
	{
		pricesPer2L[i].first = i;
	}

	sort(begin(pricesPer2L), end(pricesPer2L), [](pair<int, int> a, pair<int, int> b) { return a.second < b.second; });

	long long n = N;
	long long ans = 0;
	for (int i = 0; i < 4; i++)
	{
		int j = pricesPer2L[i].first;
		ans += n / volumes[j] * prices[j];
		n = n % volumes[j];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int m,f,r,x=0;
for(;;){
	scanf("%d %d %d", &m, &f, &r);
	x=m+f;

	if(m==-1&&f==-1&&r==-1){
		break;
	}
	if(m==-1||f==-1){
		printf("F\n");
	}
	else if(80<=x){
		printf("A\n");
	}
	else if(65<=x&&x<80){
		printf("B\n");
	}
	else if(50<=x&&x<65){
		printf("C\n");
	}
	else if(x<30){
		printf("F\n");
	}
	else{
		if(30<=x&&x<50){
			if(50<=r){
				printf("C\n");
			}
			else{
				printf("D\n");
			}
		}
	}
}
	return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    vector<pll> p(n);
    rep(i,n){
        ll cost=in(),dead=in();
        p[i]=mp(dead,cost);
    }
    sort(All(p));
    ll task=0,time=0;
    rep(i,n){
        time=p[i].first;
        task+=p[i].second;
        if(time<task){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

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

int main(){
	int i;
	string s;
	while(getline(cin, s)){
		for (i = 0; i < s.size(); i++) {
			if(s[i] >= 'a' && s[i] <= 'z'){
				s[i] = s[i] - 32;
			}
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans=a+b+c;
  int ma=max(a,b);
  ma=max(ma,c);
  ans-=ma;
  while(k--){
    ma*=2;
  }
  ans+=ma;
  cout<<ans<<endl;
}
  





Measured memory_bytes: 256
#define _USE_MATH_DEFINES  

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

int main(){
    int m, f, r;

    bool flg = true;
    while(flg){
        std::cin >> m >> f >> r;

        char ans = 'F';
        if(-3 == m + f + r){
            break;
        }

        if( 80 <= m + f){
            ans = 'A';
        }else if(65 <= m + f){
            ans = 'B';
        }else if(50 <= m + f){
            ans = 'C';
        }else if(30 <= m + f){
            ans = 'D';
            if(50 <= r){
                ans = 'C';
            }
        }

        if(-1 == m || -1 == f){
            ans = 'F';
        }

        std::cout << ans << std::endl;
    }

    return 0;
}


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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

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

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int N, A, B, C;
vec<int> l;

int INF;

int rec(int i, int a, int b, int c) {
	if (i == N) {
		if (a == 0 || b == 0 || c == 0) {
			return INF;
		}
		else {
			return abs(A - a) + abs(B - b) + abs(C - c);
		}
	}
	int res = rec(i + 1, a, b, c);
	res = min(res, rec(i + 1, a + l[i], b, c) + (a ? 10 : 0));
	res = min(res, rec(i + 1, a, b + l[i], c) + (b ? 10 : 0));
	res = min(res, rec(i + 1, a, b, c + l[i]) + (c ? 10 : 0));
	return res;
}

int main(void) {
	INF = 5000;
	cin >> N >> A >> B >> C;
	resize(l, N);
	for (int i = 0; i < N; ++i) {
		cin >> l[i];
	}
	cout << rec(0, 0, 0, 0) << endl;
	return 0;
}

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

int main(void)
{
  string a, b, c;
  cin >> a >> b >> c;
  cout << ((a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int h,a,ans=0;
  cin >> h >> a;
  while(true){
    h-=a;
    ans++;
    if (h<=0) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
string r(string s);
int main(){
  int n,i,j,k,l,f[8]={};
  cin >> n;
  string str,s1,s2;
  for(i=0;i<n;i++){
    cin >> str;
    int si = str.size();
    vector <string> v;
    for(j=1;j<si;j++){
      string s[8];
      s1=str.substr(0,j);
      s2=str.substr(j,si-j);
      f[0]=0;f[1]=0;f[2]=0;f[3]=0;
      f[4]=0;f[5]=0;f[6]=0;f[7]=0;
      s[0]=s1+s2;s[1]=s2+s1;
      s[2]=r(s2)+s1;s[3]=s2+r(s1);
      s[4]=s1+r(s2);s[5]=r(s1)+s2;
      s[6]=r(s1)+r(s2);s[7]=r(s2)+r(s1);
      for(k=0;k<v.size();k++){
	for(l=0;l<8;l++)
	  if(s[l] == v[k]) f[l]=1;
      }
      for(k=1;k<8;k++)
	for(l=0;l<k;l++)
	  if(s[k]==s[l]) f[k]=1;
      
      for(l=0;l<8;l++)
	if(f[l]==0) v.push_back(s[l]);
    }
    cout << v.size() << endl;
  }
  return 0;
}
string r(string s){
  string b="";
  int i;
  for(i=0;i<s.size();i++) b += s[s.size()-i-1];
  return b;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll N;
vvll A;
vll dp;

ll search(ll state){
  if(dp[state]<INFLL) return dp[state];
  ll ans = 0;
  for(ll i=0; (1<<i)<(1<<N); ++i) for(ll j=0; (1<<j)<(1<<N); ++j){
    if(state&(1<<i) && state&(1<<j)) ans += A[i][j];
  }
  dp[state] = ans;
  for(ll tmp = (state-1)&state; tmp>0; tmp=(tmp-1)&state){
    chmax(dp[state], search(tmp)+search(state-tmp));
  }
  return dp[state];
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(N);
  A.resize(N, vll(N));
  ll ans = 0;
  REP(i,N) REP(j,N){
    IN(A[i][j]);
    ans += A[i][j];
  }
  dp.resize(1<<N, INFLL);

  ll state = (1<<N)-1;

  dp[state] = ans;
  for(ll tmp = (state-1)&state; tmp>0; tmp=(tmp-1)&state){
    chmax(dp[state], search(tmp)+search(state-tmp));
  }

  OUT(dp[state]/2);

  return 0;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
 
int main(){
      int X,Y,x=0,y=0;cin >> X >> Y;
          
      if(X == 1){
            x = 300000;
      }else if(X == 2){
            x = 200000;
      }else if(X == 3){
            x = 100000;
      }
      if(Y == 1){
            y = 300000;
      }else if(Y == 2){
            y = 200000;
      }else if(Y == 3){
            y = 100000;
      }
      if(X==1 && Y == 1){
            cout << 1000000 << endl;
      }else{
            cout << x + y << endl;
      }
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    set<int> a;
    for(int i = 0; i < n; i++){
        int A; cin >> A;
        if(a.count(A)) a.erase(A);
        else a.insert(A);
    }
    cout << a.size() << endl;

    return 0;
}


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

int main(){
  int a;
  cin >> a;
  vector<int> p(a);
  string ans;
  rep(i, a) cin >> p.at(i);
  sort(all(p));
  int l = 0;
  rep(i, a - 1) l += p.at(i);
  if (l > p.at(a - 1)) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        //入力準備
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int cnt = 0;
        
        //配列にデータを入れる
        for(int i = a; i <= b; i++ ){
            if(c % i == 0){
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26420
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()

	L := io.NextInt()
	a := float64(L*L*L) / float64(27.0)
	fmt.Printf("%f\n", a)
	// fmt.Printf("Lucas %d %d\n", combMod(N, M, 13), combination(N, M))

	// write your own code here
}

// Libraries

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// direct calculation of combination
// n, m should be "small"
func combination(n, m int) int {
	if m > n {
		return 0
	} else if m == n || m == 0 {
		return 1
	} else {
		res := 1
		for i := 0; i < m; i++ {
			res *= (n - i)
		}
		for i := 1; i <= m; i++ {
			res /= i
		}
		return res
	}
}

// caluclate combination modulo based on Lucas theorem
func lucas(n, m, p int) int {
	ntemp := n
	mtemp := m
	res := 1
	for i := 0; i < 100; i++ {
		// fmt.Printf("ntemp: %d\n", ntemp)
		nreminder := ntemp % p
		ntemp = ntemp / p
		mreminder := mtemp % p
		mtemp = mtemp / p
		res = res * (combination(nreminder, mreminder) % p)
		if ntemp == 0 {
			break
		}
	}
	return res % p
}

func combMod(n, m, p int) int {
	return lucas(n, m, p)
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=2e5+100;

int a[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int k,n;
    cin>>k>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int mx=a[0]-a[n-1]+k;
    for(int i=0;i<n-1;i++)
        mx=max(mx,a[i+1]-a[i]);
    cout<<k-mx;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
const ll mod = 998244353;


int main() {
    ll n, s;
    cin >> n >> s;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<vector<ll>> dp(n+1, vector<ll>(s+1, 0));
    dp[0][0] = 1;
    rep(i, 0, n) {
        rep(j, 0, s+1) {
            dp[i+1][j] += 2 * dp[i][j];
            dp[i+1][j] %= mod;
            if(j + a[i] <= s){
                dp[i+1][j+a[i]] += dp[i][j];
                dp[i+1][j+a[i]] %= mod;
            }
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 73680
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    int ld = 1;
    ll ans = 0;
    rep(id,n){
        if(a[id] > ld){
            ans += (a[id]-1) / ld;
            if(ld == 1) ld++;
        }else if(a[id] == ld){
            ld++;
        }
    }
    cout << ans << "\n";
    return 0;
}


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


int func(int n, int x, vector<int>& L) {
    int currentLocation = 0;
    int count = 0;
    for (int i = 0; i < n + 1; ++i) {
        if (currentLocation <= x) {
            ++count;
        }
        if (i == n) {
            break;
        }
        currentLocation += L[i];
    }
    return count;
}

int main() {
    int N, X;
    vector<int> L;
    cin>>N>>X;
    int currentL;
    for (int i = 0; i < N; ++i) {
        cin>>currentL;
        L.push_back(currentL);
    }
    cout << func(N, X, L) << endl;
    return 0;
}

Measured memory_bytes: 384
graph = []

def init():
    global graph
    graph = [[False] * 26 + [True] for _ in xrange(27)]
    graph[26][26] = False

def atoi(c):#index
    if c == "#":
        return 26
    return ord(c) - ord("a")

def make_graph(L):
    global graph
    cur = 0
    L = [L[0]] + [L[i] for i in xrange(1, len(L)) if L[i] != L[i-1]]
    tmp = []
    for s1, s2 in zip(L, L[1:]):
        if s1[0] == s2[0]:
            tmp += [s1[1:], s2[1:]]
        else:
            if not tmp == []:
                make_graph(tmp)
            tmp = []
            graph[atoi(s2[0])][atoi(s1[0])] = True
    if not tmp == []:
        make_graph(tmp)

def check(start):
    stack = set([start])
    visited = [False] * 27
    while len(stack) != 0:
        cur = stack.pop()
        visited[cur] = True
        if graph[cur][start]:
            return False
        for i in xrange(27):
            if graph[cur][i] and not visited[i]:
                stack.add(i)
    return True

while True:
    n = input()
    if n == 0:
        break
    L = [raw_input() + "#" for _ in xrange(n)]
    init()
    make_graph(L)
    for i in xrange(27):
        if not check(i):
            print "no"
            break
    else:
        print "yes"

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
string s;
int main()
{
    cin>>s;
    if(s.size() % 2) cout<<"No";
    else {
        bool flag = 1;
        for(int i = 0;i < s.size();i += 2) if(s[i] != 'h' || s[i+1] != 'i') flag = 0;
        cout<<(flag?"Yes":"No"); 
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n , m;
  cin>>n>>m;
  if(n==m)
    cout<<"Yes\n";
  else
  {
    cout<<"No\n";
  }
  
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

struct UnionFind {
    vi par,siz;

    // UnionFind(int N) : par(N) {
    //     for(int i = 0; i < N; i++) par[i] = i;
    // }

    void assign(int N, int n){
        par.resize(N); siz.resize(N,1);
        for(int i = 0; i < N; i++) par[i] = n;
    }

    int root(int x) { 
        if (par[x]<0) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x); 
        int ry = root(y); 
        if (rx == ry) return; 
        if(siz[rx]<siz[ry]) swap(rx,ry);
        par[ry]=rx;
        siz[rx]+=siz[ry];
    }

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return siz[root(x)];
    }
};

int N,M,K; vector<set<int>> rmv; UnionFind uf;
void input()
{
    cin>>N>>M>>K;
    rmv.resize(N);
    uf.assign(N,-1);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin>>a>>b;
        --a; --b;
        rmv[a].insert(b);
        rmv[b].insert(a);
        uf.unite(a,b);
    }
    for (int i = 0; i < K; ++i) {
        int a, b;
        cin>>a>>b;
        --a; --b;
        if(!uf.same(a,b)) continue;
        rmv[a].insert(b);
        rmv[b].insert(a);
    }
}

void solve()
{
    for(int i=0;i<N;++i){
        int ans=uf.size(i)-rmv[i].size()-1;
        // cout<<uf.size(i)<<" "<<rmv[i].size()<<" "<<endl;
        cout<<ans<<" ";
    }
    cout<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

int main(){
    
    int n; cin >> n;
    vector<int> a(n);
    int i;
    for(i=0;i<n;++i) cin >> a[i];
    long int min=1000000001,max=1;
    for(i=0;i<n;++i){
        if(min>a[i])min=a[i];
        if(max<a[i])max=a[i];
    }
    cout << max-min;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int rate;
    
    scanf("%d", &rate);
    
    if (400 <= rate && rate < 600) {
        printf("8\n");
    }
    if (600 <= rate && rate < 800) {
        printf("7\n");
    }
    if (800 <= rate && rate < 1000) {
        printf("6\n");
    }
    if (1000 <= rate && rate < 1200) {
        printf("5\n");
    }
    if (1200 <= rate && rate < 1400) {
        printf("4\n");
    }
    if (1400 <= rate && rate < 1600) {
        printf("3\n");
    }
    if (1600 <= rate && rate < 1800) {
        printf("2\n");
    }
    if (1800 <= rate) {
        printf("1\n");
    }
    
    return 0;
}


Measured memory_bytes: 1596
#include <stdio.h>

int main() {
	int A, B; 
	scanf("%d %d", &A, &B);
	
	int length = A + B + 1, cnt = 0;
	char S[50];
	scanf("%s", S);
	
	if (S[A] == '-') {
		for(int i = 0; i < length; i++) {
			if (S[i] >= '0' && S[i] <= '9') {
				cnt++;
			}
		}
		if (cnt == length -1) {
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	} else {
			printf("No\n");
		}	
	return 0;
}

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

xy = []
F = [[0]*(2*k+1) for _ in range(2*k+1)]
for __ in range(n):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c == 'B':
        y += k
    x %= 2*k
    y %= 2*k

    for _ in range(2):
        x = (x+k)%(2*k)
        y = (y+k)%(2*k)
        #右上
        F[y+1][x+1] += 1
        if x-k >= 0 and y-k >= 0:
            #普通の左上と左上右下
            F[y+1][x-k+1] -= 1
            F[y-k+1][x+1] -= 1
            F[y-k+1][x-k+1] += 1
        elif y-k >= 0:
            #特殊な左
            F[y-k+1][0] += 1
            F[y+1][0] -= 1
            F[y-k+1][x+1] -= 1
            #特殊な左上と左下
            F[y-k+1][x+k+1] += 1
            F[y+1][x+k+1] -= 1
        elif x-k >= 0:
            F[0][x-k+1] += 1
            F[0][x+1] -= 1
            F[y+1][x-k+1] -= 1

            F[y+k+1][x-k+1] += 1
            F[y+k+1][x+1] -=1
        else:
            F[0][x+1] -= 1
            F[y+1][0] -= 1
            F[0][0] += 1
            #左上
            F[y+k+1][0] += 1
            F[y+k+1][x+1] -= 1
            #右下
            F[0][x+k+1] += 1
            F[y+1][x+k+1] -= 1
            #右上
            F[y+k+1][x+k+1] += 1
    if __ == 0:
        pass
        # break
ans = 0
m = 3

from numpy import array
F = array(F)
for i in range(0, 2*k):
    F[:, i+1] += F[:, i]
for i in range(0, 2*k):
    F[i+1, :] += F[i, :]
print(F[:2*k, :2*k].max())

Measured memory_bytes: 74872
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	long long N, K;
	vector<pair<int, int>> ab;
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		ab.push_back(pair<int, int>(a, b));
	}
	sort(ab.begin(), ab.end(), [](pair<int, int> x, pair<int, int> y){return x.first < y.first; });

	long long p = 0;
	for (int i = 0; i < N; ++i) {
		p += ab[i].second;
		if (K <= p) {
			cout << ab[i].first << endl;
			break;
		}
	}



	return 0;
}

Measured memory_bytes: 1400
n = gets.chomp.to_i
task = []
n.times do
    task << gets.chomp.split(" ").map(&:to_i)
end
task.sort_by!{|a, b| b}

sum_time = 0
ans = true
task.each do |a, b|
    sum_time += a
    ans = false if sum_time > b
end
puts ans ? "Yes" : "No"

Measured memory_bytes: 22420
// https://atcoder.jp/contests/abc086/tasks/arc089_a
"use strict"
function Main(input) {
  const params = input.split('\n');
  const n = Number(params[0]);
  let t = [0];
  let x = [0];
  let y = [0];

  let flag = true;
  for(let i=1; i<=n; i++) {
    const line = params[i].split(' ').map(Number);
    t.push(line[0]);
    x.push(line[1]);
    y.push(line[2]);

    const dt = t[i] - t[i-1];
    const dist = Math.abs(x[i] - x[i-1]) + Math.abs(y[i] - y[i-1]);
    if (dt < dist) {
      flag = false;
      break;
    }

    if(dt % 2 !== dist % 2) {
      flag = false;
      break;
    }
  }

  if (flag) {
    console.log('Yes');
  } else {
    console.log('No')
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 47948
#include <iostream>

using namespace std;

int f(int x) {
    return x * x;
}

int main() {
    int d;

    while (cin >> d) {
        int s = 0;
        for (int i = 0; i < 600 / d; i++) {
            int x = i * d;
            s += f(x) * d;
        }

        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
while True:
    n = int(raw_input())
    if n == 0: break
    field = [raw_input() for i in range(n)]
    large = [[0] * (n + 1) for i in range(n + 1)]
    mx = 0
    for i in range(n):
        for j in range(n):
            if field[i][j] == '.':
                large[i][j] = min(large[i][j - 1], large[i - 1][j], large[i - 1][j - 1]) + 1
                if large[i][j] > mx:
                	mx = large[i][j]
    print mx

Measured memory_bytes: 32984
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin(),(c).end())
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { SORT(a); a.erase(unique(ALL(a)),a.end()); }
template <class S, class T> ostream& operator<<(ostream& os, const pair<S,T> a) {
  return os << a.first << ' ' << a.second;
}
const int MOD = 1000000007;
// const int INF = 0x3f3f3f3f3f3f3f3f;
// const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

/* 基本要素 */
using D = double; // 座標値の型 doubleかlong double
using P = complex<D>; // Point
using L = pair<P,P>;  // Line
using VP = vector<P>;
const double EPS = 1e-8;  // 許容誤差
const double INF = 1e12;
#define X real()
#define Y imag()
#define LE(n,m) ((n)<(m)+EPS) // n <= m ?
#define GE(n,m) ((n)+EPS>(m)) // n >= m ?
#define EQ(n,m) (abs((n)-(m))<EPS)

namespace std {
  istream& operator >> (istream& is, P& p) {
    int F, S;
    is >> F >> S;
    p = P(F,S);
    return is;
  }
}

// 内積
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積
D cross(P a, P b) {
  return (conj(a)*b).Y;
}
// 点aから見た、点bから点cへの方向
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b,c) > 0) return +1;  // counter clockwise
  if (cross(b,c) < 0) return -1;  // clockwise
  if (dot(b,c) < 0) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2; // a--b--c on line or a==b
  return 0;                     // a--c--b on line or a==c or b==c
}
// 点pの直線aへの射影点を返す
P proj(P a1, P a2, P p) {
  return a1 + dot(a2-a1,p-a1)/norm(a2-a1) * (a2-a1);
}

P p1, p2;
int q;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> p1 >> p2 >> q;
  REP(i, q) {
    P p;
    cin >> p;
    P ans = proj(p1, p2, p);
    cout << ans.X << " " << ans.Y << endl;
  }

  return 0;
}


Measured memory_bytes: 3356
#include <iostream>

using namespace std;

int main()
{
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    int ans1, ans2;

    if(N%A==0) {
        ans1=(N/A)*B;
    } else {
        ans1=(N/A+1)*B;
    }
    if(N%C==0){
        ans2=(N/C)*D;
    } else {
        ans2=(N/C+1)*D;
    }
    if(ans1<ans2) {
        cout << ans1 << endl;
    } else {
        cout << ans2 << endl;
    }
    return 0;
}



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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
    if (n == 0)return 1;
    if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
    return (x * modexp((x * x) % md, n / 2, md)) % md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    ll n,x,y;
    cin>>n;
    vl a(n),b(n);
    f(i,0,n){
       cin>>x>>y;
       a[i]=x+y;
       b[i]=x-y;
    }
    sort(all(a));sort(all(b));
    ll ans=a[n-1]-a[0];
    ans=max(ans,b[n-1]-b[0]);
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
int N,M,best[110][110];
string s[110];

int main() {
  cin>>N>>M;
  for(int i=0;i<N;++i) {
    cin>>s[i];
  }
  if(s[0][0] == '#') best[0][0] = 1;
  for(int i=0;i<N;++i) {
    for(int j=0;j<M;++j) {
      if(i+j == 0) continue;
      int cand1 = N*M, cand2 = N*M;
      if(j > 0) {
        cand1 = best[i][j-1];
        if(s[i][j] == '#' && s[i][j] != s[i][j-1]) ++cand1;
      }
      if(i > 0) {
        cand2 = best[i-1][j];
        if(s[i][j] == '#' && s[i][j] != s[i-1][j]) ++cand2;
      }
      best[i][j] = min(cand1, cand2);
    } 
  }
  cout<<best[N-1][M-1]<<"\n";
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;
namespace VSCode.SampleApp
{
    class Program
    {
        static int N;
        static long[] An;
        static void Main(string[] args)
        {
            N = int.Parse(ReadLine());
            An = ReadLine().Split().Select(long.Parse).ToArray();
            WriteLine(Solve());
        }

        static long Solve()
        {
            var l = new long[N];
            var r = new long[N];
            l[0] = An[0];
            r[N - 1] = An[N - 1];
            for (int i = 1; i < N; i++)
            {
                l[i] = Gcd(l[i - 1], An[i]);
                r[N - i - 1] = Gcd(r[N - i], An[N - i - 1]);
            }
            var max = Math.Max(r[1], l[N - 2]);
            for (int i = 1; i < N - 1; i++)
            {
                var gcd = Gcd(l[i - 1], r[i + 1]);
                max = Math.Max(gcd, max);
            }
            return max;
        }

        static long Gcd(long a, long b)
        {
            return a < b
                ? Gcd(b, a) : b > 0
                ? Gcd(b, a % b)
                : a;
        }
    }
}


Measured memory_bytes: 27996