akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
// using namespace boost::multiprecision;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
// using int128 = __int128;
// using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC optimization_level 3
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll N, A[100000], B[100000];

signed main() {
    string s;
    cin >> s;
    if (s.size() == 2) {
        cout << s << endl;
    } else {
        rep(i, 3) { cout << s[2 - i]; }
        cout << endl;
    }
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func createNums(len int, ary []int) []int {
	for i := 0; i < len; i++ {
		fmt.Scan(&ary[i])
	}
	return ary
}

func searchMax(ary []int) (max int, secMax int) {
	sort.Ints(ary)
	max = ary[len(ary)-1]
	secMax = ary[len(ary)-2]
	return
}

func main() {
	var a int
	fmt.Scan(&a)

	var nums = make([]int, a)
	var cp = make([]int, a)
	nums = createNums(a, nums)
	copy(cp, nums)
	max, secMax := searchMax(cp)
	for i := 0; i < a; i++ {
		if nums[i] != max {
			fmt.Println(max)
		} else {
			fmt.Println(secMax)
		}
	}
}


Measured memory_bytes: 9088
S = input()
r = True
if not 'KIH' in S:
    r = False
else:
    ps = ''
    for s in S:
        if s != 'A':
            ps += s
    if ps != 'KIHBR':
        r = False
    else:
        hi = S.index('H')
        bi = S.index('B')
        ri = S.index('R')
        if ri - bi > 2:
            r = False
        elif bi-hi > 2:
            r = False
        else:
            if ri < len(S)-2:
                r = False
            else:
                if S[0:2] == 'AA':
                    r = False
print('YES' if r else 'NO')




Measured memory_bytes: 61804
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  string s;
  cin >> s;
  rep(i,0,s.size()){
    if(s[i] == ','){
      s[i]=' ';
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int cost[10]={0,2,5,5,4,5,6,3,7,6};
string dp[11000];

void chmax(string &s,string t){
    if(s=="-") s=t;
    else if(s.size()<t.size()) s=t;
    else if(s.size()==t.size()){
        if(s<t) s=t;
    }
}

signed main()
{   
    int N,M; cin>>N>>M;
    vector<int> A(M);
    REP(i,M) cin>>A[i];
    
    REP(i,11000) dp[i]="-";
    dp[0]="";
    for(int i=0;i<=N;i++){
        for(auto a:A){
            if(i-cost[a]<0) continue;
            if(dp[i-cost[a]]=="-") continue;
            string s=dp[i-cost[a]]+(char)('0'+a);
            chmax(dp[i],s);
        }
    }
    cout<<dp[N]<<endl;

}


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

int main()
{
    char alpha[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
                      'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
                      'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
    int n;
    string s;
    cin >> n;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        s[i] = alpha[(s[i] - 'A' + n) % 26];
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

llong in;

int sum(llong x) {
    int ret = 0;
    while (x) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

struct frac {
    llong b;
    int a;
    frac() : a(0), b(0) {}
    frac(llong i, int j) : a(j), b(i) {}
    bool operator<(const frac &p) const {
        return b * p.a < p.b * a;
    }
    bool operator<=(const frac &p) const {
        return b * p.a <= p.b * a;
    }
};

frac getMax(llong k) {
    frac mx = { k + 9, sum(k + 9) };
    for (llong x = k + 9, i = 1, j = 0; j < 16; x += (i *= 10) * 9, ++j) {
        mx = min(mx, { x, sum(x) });
    }
    return mx;
}

frac mx[16];
frac mn[100000];
frac ar[100000];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> in;
	
	int i = 0;
	for (llong k = 1; i < 16; ++i, k *= 10) {
        mx[i] = getMax(k);
        //printf("%d %lld/%d\n", i, mx[i].b, mx[i].a);
	}
	
	vector<llong> ans;
	for (i = 1; i < 10; ++i) ans.push_back(i);
	
	i = 1;
	llong k = 10, x = 10;
    int t = 1;
	while (ans.size() < in) {
        while (frac(k, 1) < mx[t]) ++i, k *= 10;
        for (llong j = 10 * x / k, tp = 1; j--; tp = 0) {
            ar[j] = { (j + 1) * k - 1, sum((j + 1) * k - 1) };
            if (tp) mn[j] = min(mx[t + 1], ar[j]);
            else mn[j] = min(mn[j + 1], ar[j]);
        }
        for (llong j = x / k; j < 10 * x / k; ++j) {
            if (ar[j] <= mn[j]) ans.push_back((j + 1) * k - 1);
        }
        x *= 10;
        ++t;
	}
	
	for (int i = 0; i < in; ++i) printf("%lld\n", ans[i]);
	
	return 0;
}


Measured memory_bytes: 3456
N, W = map(int, input().split())
w_v = [list(map(int, input().split())) for _ in range(N)]

V = max(w_v, key=lambda x: x[1])[1] * N
# 1~i-1番目の品物から価値の総和がj以下になるように選んだときの重さ
dp = [[float('inf') for _ in range(V+1)] for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    w, v = w_v[i]
    for j in range(V+1):
        if j - v >= 0:
            dp[i+1][j] = min(dp[i][j-v]+w, dp[i][j])
        else:
            #dp[i+1][j] = min(dp[i][j], dp[i+1][j])
            dp[i+1][j] = dp[i][j]

r = 0
for v in range(V+1):
    if dp[N][v] <= W:
        r = v
print(r)

Measured memory_bytes: 318832
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
using namespace std;
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    for(ll i=0;i<m;i++)
    {
        ll a;
        cin>>a;
        sum+=a;
    }
    ll rem=n-sum;
    if(rem<0) cout<<"-1";
    else cout<<rem;
}

Measured memory_bytes: 3640
import numpy as np

N = int(input())
AB = np.vstack([list(map(int, input().split())) for _ in range(N)])
meds = np.median(AB, axis=0)

if N%2 == 0:
    print(int((meds[1]-meds[0])*2+1))
else:
    print(int(meds[1]-meds[0] +1))


Measured memory_bytes: 124596
#include <stdio.h>
#include <string.h>

#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX + 1];

void maxHeapify(int i){
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;
	
	if(l <= H && A[l] > A[i]) {largest = l;}
	else {largest = i;}
	if(r <= H && A[r] > A[largest]) {largest = r;}
	
	if(largest != i){
		int tmp=0;
		tmp=A[i];
		A[i]=A[largest];
		A[largest]=tmp;
		maxHeapify(largest);
	}
}

int extract(){
	int maxv;
	if(H < 1) {return -INFTY;}
	maxv = A[1];
	A[1] = A[H--];
	maxHeapify(1);
	return maxv;
}

void increaseKey(int i, int key){
	if(key < A[i]) {return;}
	A[i] = key;
	while (i > 1 && A[i / 2] < A[i]){
		int tmp = 0;
		tmp = A[i];
		A[i] = A[i / 2];
		A[i / 2] = tmp;
		i = i / 2;
	}
}

void insert(int key){
	H++;
	A[H] = -INFTY;
	increaseKey(H, key);
}

int main(){
	int key;
	char com[10];
	
	while(1){
		scanf("%s", com);
		if(com[0] == 'e' && com[1] == 'n'){break;}
		if(com[0] == 'i'){
			scanf("%d", &key);
			insert(key);
		}
		else{
			printf("%d\n", extract());
		}
	}
	
	return 0;
}



Measured memory_bytes: 5592
#include <iostream>
#include<stdio.h>


using namespace std;



int main(void){
    // Your code here!
    int a,b,c;
    int count=0;
    scanf("%d %d %d",&a,&b,&c);

    for(int i=a; i<b+1; i++){
        
        if( c%i==0 ) count++;
        
    }
    printf("%d\n",count);
    
    return 0;
}



Measured memory_bytes: 3212
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        long n = sc.nextLong();
        long m = sc.nextLong();

        if (n * 2l <= m) {
            long ans = n;
            long remainC = m - n * 2l;
            ans += remainC / 4l;
            System.out.println(ans);
        } else {
            System.out.println(m / 2l);
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 

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

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {COMinit();
    int n,k;std::cin >> n>>k;
    for(int i=1;i<=k;i++){std::cout <<( (COM(n-k+1,i)%1000000007)*(COM(k-1,i-1)%1000000007)%1000000007);cout<<endl;} //<<endl; expected: 252
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pb(a) push_back(a)
#define in(a) insert(a)
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,-1,0,0},dy[4]={-1,0,-1,0};
typedef pair<int,int> P;

int a[1001][1001];
string s[1001],t[2];
char c[3]={'J','O','I'};

void Main() {
  int n,m;
  cin >> n >> m;
  rep(i,n) R s[i];
  rep(i,2) R t[i];
  int cnt=0;
  rep(i,n)rep(j,m)a[i][j]=1;
  rep(i,n-1) {
    rep(j,m-1) {
      rep(ii,2) {
        rep(jj,2) {
          if(s[i+ii][j+jj]!=t[ii][jj]) a[i][j]=0;
        }
      }
      cnt+=a[i][j];
    }
  }
  int ans=cnt;
  rep(i,n) {
    rep(j,m) {
      char ch=s[i][j];
      rep(k,3) {
        s[i][j]=c[k];
        int sum=cnt;
        rep(l,4) {
          int x=i+dx[l],y=j+dy[l],c=1;
          if(!check(n,m,x,y) || !check(n,m,x+1,y+1)) continue;
          rep(ii,2) {
            rep(jj,2) {
              if(s[x+ii][y+jj]!=t[ii][jj]) c=0;
            }
          }
          if(a[x][y] && !c) sum--;
          if(!a[x][y] && c) sum++;
        }
        ans=max(ans,sum);
      }
      s[i][j]=ch;
    }
  }
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);Main();
  return 0;
}


Measured memory_bytes: 6176
package main

import "fmt"

func main() {
	// Code for B - Unhappy Hacking (ABC Edit)
	var s string
	fmt.Scanf("%s", &s)

	var ans string
	for i := 0; i < len(s); i++ {
		if s[i] == '0' {
			ans += string('0')
		} else if s[i] == '1' {
			ans += string('1')
		} else {
			if len(ans) == 0 {
				continue
			} else {
				ans = ans[0 : len(ans)-1]
			}
		}
	}

	fmt.Println(ans)
}


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

int main ()
{
  string s;
  
  cin>>s;
  
  int i=0;
  
  while(s[i]=='h' && s[i+1]=='i')
  {
    i+=2;
  }
  if(i==s.length())
    cout<<"Yes";
  
  else
    cout<<"No";

  return 0;
}

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

int main() {
	int i, j, n, q, cnt =0;
	int S[10002];
	int T[500];

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> T[i];
	}

	for (i = 0; i < q; i++) {
//		番兵設置
		S[n] = T[i];
		j = 0;
		while (S[j] != T[i]) {
			j++;
		}
		if (j != n) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3140
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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!{
        s: i32,
        w: i32,
    }
    println!("{}safe", if s <= w { "un" } else { "" });
}


Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll x;
  cin >> x;
  ll l = 1;
  ll r = INF;
  if (x == 1) {
    cout << 1 << endl;
    return;
  }
  while(r - l > 1) {
    ll m = (r + l) / 2;
    if (x <= m * (m + 1) / 2) r = m;
    else l = m;
  }
  cout << r << endl;
}

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

Measured memory_bytes: 3608
#include<stdio.h>
int main(void){
	int n,d,x,i,sum=0;
	scanf("%d %d %d",&n,&d,&x);
	int a[101];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		int j=1;
		while(j<=d){sum++;j+=a[i];}
	}
	printf("%d",sum+x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
int main() {
    int n;
    cin >>n;
    int x[n],y[n];
    for (int i=0; i<n; i++) {
        cin >> x[i];
    }
    for (int i=0; i<n; i++) {
        cin >> y[i];
    }
    double a,b,c,d;
    a=b=c=d=0;
    for (int i=0; i<n; i++) {
        a+= fabs(x[i]-y[i]);
        b+= pow(x[i]-y[i],2);
        c+= pow(fabs(x[i]-y[i]),3);
        d = max(d,fabs(x[i]-y[i]));
    }
    printf("%.8f\n",a);
    printf("%.8f\n",sqrt(b));
    printf("%.8f\n",pow(c,1.0*1/3));
    printf("%.8f\n",d);
}



Measured memory_bytes: 3336
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	listD := make([]int, k)
	listA := make([][]int, k)
	for i := 0; i < k; i++ {
		fmt.Scan(&listD[i])
		listA[i] = make([]int, listD[i])
		for j := 0; j < listD[i]; j++ {
			fmt.Scan(&listA[i][j])
		}
	}
	count := 0
	list := make([]int, n)
	for i := 0; i < k; i++ {
		for j := 0; j < listD[i]; j++ {
			list[listA[i][j]-1]++
		}
	}
	for i := 0; i < n; i++ {
		if list[i] == 0 {
			count++
		}
	}
	fmt.Println(count)

}


Measured memory_bytes: 2428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int N;
		if(B>=10) {
			N=A*100+B;
			if(B==100) {
				N=A*1000+B;
			}
		}else N=A*10+B;
		for(int i=4;i<1000;i++) {
			if(N==Math.pow(i, 2)) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");
	}

}


Measured memory_bytes: 23764
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 
 
const int N = 1e6 + 100, OO = 1e9 + 7, T = 410, M = 998244353, P = 6151, SQ = 800, lg = 32;
typedef pair <int, int> pii;

int32_t main() {
	use_fast;
	string s;
	cin >> s;
	int n = (int)s.size();
	for(int i = 0; i < n / 2; i++) 
		if(s[i] != s[n - i - 1])
			return cout << "No", 0;
	int q = (n - 1) / 2;
	for(int i = 0; i < q / 2; i++) 
		if(s[i] != s[q - i - 1])
			return cout << "No", 0;
	for(int i = q + 1; i < n; i++) 
		if(s[i] != s[n - i + q])
			return cout << "No", 0;
	cout << "Yes" << endl;
	return 0; 
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0)break;
			int coin=0;
			int c=1000-n;
			if(c>=500){
				c-=500;
				coin++;
			}
			for(int i=0;i<4;i++){
				if(c>=100){
					c-=100;
					coin++;
				}
			}
			if(c>=50){
				c-=50;
				coin++;
			}
			for(int i=0;i<9;i++){
				if(c>=10){
					c-=10;
					coin++;
				}
			}
			if(c>=5){
				c-=5;
				coin++;
			}
			for(int i=0;i<4;i++){
				if(c>=1){
					c-=1;
					coin++;
				}
			}
			System.out.println(coin);
		}
	}
}

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

using namespace std; 
int main()
{
char a[10000];
char b[10000];
cin>>a>>b;
int s1=strlen(a);
int s2=strlen(b);
if(s1!=s2){
	

             if(s1>s2)
			cout<<"GREATER";
			else 

			cout<<"LESS";
}else{

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


             if(a[i]!=b[i])
             {
             	if(a[i]>b[i]){
             		cout<<"GREATER";	
				 }
             	else{
				 
             	cout<<"LESS";
			 }
			 break;
			 }
			 
	if(i+1==s1){
	
			cout<<"EQUAL";	
			continue;
		}
	}}
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int N, M;

    cin >> N >> M;

    vector<int> right_num(N, 0), penalty_num(N, 0);

    for(int i = 0; i < M; i ++){
        int p;
        string S;

        cin >> p >> S;

        if(right_num[p - 1] == 0){
            if(S == "AC"){
                right_num[p - 1] = 1;
            }else{
                penalty_num[p - 1] ++;
            }
        }
    }
    int ans1 = 0;
    int ans2 = 0;

    for(int i = 0; i < N; i ++){
        if(right_num[i] == 1){
            ans1 ++;
            ans2 += penalty_num[i];
        }
    }
    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <array>
#include <list>
#include <string>
#include <algorithm>
#include <queue>
#include <numeric>
#include <random>
#include <iomanip>
#include <chrono>

using namespace std;

int main() {

	int n;
	cin >> n;
	vector<int> x(n);

	for (auto& val : x)
	{
		cin >> val;
	}

	long long int minCost = 9223372036854775807;
	for (int i = 0; i < 101; i++)
	{
		long long int cost = 0;
		for (int id = 0; id < n; id++)
		{
			const int dif = abs(x[id] - (i + 1));
			cost += dif * dif;
		}
		minCost = min(minCost, cost);
	}

	cout << minCost << endl;

	return 0;
}


Measured memory_bytes: 256
import kotlin.math.min

fun main() {
    val S = readLine()!!
    val T = readLine()!!
    var min = 100000
    for (i in 0 until S.length - T.length+1) {
        var count = 0
        for (j in T.indices) {
            if (S.substring(i)[j] != T[j]) count++
        }
        min = min(min,count)
    }
    println(min)
}

Measured memory_bytes: 52652
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 100100
using namespace std;

long long A[MAX];
int main()
{
	long long N, M; scanf("%lld%lld", &N, &M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}
	std::sort(A, A + N);

	long long st, mid, ed, res, ss;
	st = 0; ed = 200005;
	while (st<=ed) {
		mid = (st + ed) / 2;
		long long sum = 0, t = N;
		for (int i = 0; i < N; i++) {
			while (true) {
				if (t == 0 || A[t - 1] + A[i] < mid) break;
				t--;
			}
			sum += N - t;
		}
		if (sum <= M) {
			res = mid;
			ed = mid - 1;
			ss = sum;
		}
		else st = mid + 1;
	}

	long long t = N;
	long long ans = (long long)(M - ss) * (res - 1), sum = 0;
	for (int i = 0; i < N; i++) {
		while (true) {
			if (t == 0 || A[t - 1] + A[i] < res) break;
			t--;
			sum += A[t];
		}
		ans += (long long)(A[i])*(N - t) + sum;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 896
n, x = gets.split.map(&:to_i)
ary = gets.split.map(&:to_i).sort
count = 0
(0...n-1).each do |i|
  if x >= ary[i]
    x-=ary[i]
    count+=1
  end
end
count+=1 if ary[-1] == x
puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
 
typedef long long ll;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
//const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
int main(){
    int n;
    std::cin >> n;
    reprep(i,j,100,100){
        if(i*4+j*7==n){
            std::cout << Yes << std::endl;
            exit(0);
        }
    }
    std::cout << No << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vec A(N); readvec(A);
    SORT(A); REVERSE(A);
    int a = 0, b = 0, i0;
    REP(i, N - 1){
        if(A[i] == A[i + 1]){
            a = A[i];
            i0 = i + 2;
            break;
        }
    }
    FOR(i, i0, N - 1){
        if(A[i] == A[i + 1]){
            b = A[i];
            break;
        }
    }
    
    cout << a * b;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1152
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();

    for(int i = 1 ; i <= k ; ++i){
      if(i%2 ==1){
        if(a%2 == 1){
          a--;
        }
        b += (a/2); 
        a = a/2;
      }else{
        if(b%2 == 1){
          b--;
        }
        a += (b/2);
        b = b/2;
      }
    }
    
    System.out.print(a);
    System.out.print(" ");
    System.out.print(b);

  }
}

Measured memory_bytes: 35724
#include<bits/stdc++.h>
using namespace std;
#define long long ll;
int main(){
    int n;
    cin>>n;
    vector<int> a(n),dp(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[1] - a[0]);
    for(int i=2;i<n;i++){
        dp[i] = min((dp[i-1] + abs(a[i]-a[i-1])),(dp[i-2] + abs(a[i]-a[i-2])));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>

int main(){
    char ch;
    std::cin >> ch;
    if (ch == 'A') std::cout << 'T';
    else if (ch == 'C') std::cout << 'G';
    else if (ch == 'T') std::cout << "A";
    else if (ch == 'G') std::cout << "C";
}

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

int main() {
  int r; cin >> r;
  cout << double(3.1415 * 2 * r) << endl;
  return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long n,t=0,k=0,m=0,l=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        char s[3];
        cin>>s;
         if(s[0]=='A')
          k++;
         else if(s[0]=='W')
          t++;
         else if(s[0]=='T')
          l++;
         else if(s[0]=='R')
          m++;
    }
     cout<<"AC x "<<k<<"\n"<<"WA x "<<t<<"\n"<<"TLE x "<<l<<"\n"<<"RE x "<<m;
    return 0;
}
     
   




Measured memory_bytes: 3656
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, M, Q = [int(x) for x in stdin.readline().rstrip().split()]
abcd = [list(map(int, stdin.readline().rstrip().split())) for _ in range(Q)]

ans = 0

nums = [i for i in range(1, M+1)]
A = list(itertools.combinations_with_replacement(nums, N))

for l in A:
    l = (0,) + l 
    tmp_ans = 0
    for a, b, c, d in abcd:
        if l[b] - l[a] == c:
            tmp_ans += d


    
    ans = max(ans, tmp_ans)

print(ans)


Measured memory_bytes: 89960
using System;

namespace abc164_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] abcd = Console.ReadLine().Split(" ");
            int a = int.Parse(abcd[0]);
            int b = int.Parse(abcd[1]);
            int c = int.Parse(abcd[2]);
            int d = int.Parse(abcd[3]);

            bool yes = false;
            for(int i = 1; i <= 100; i++)
            {
                c -= b;
                if(c <= 0)
                {
                    yes = true;
                }

                a -= d;
                if(a <= 0)
                {
                    break;
                }
            }

            if (yes)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27376
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.
   PREFER CODING RATHER THAN MEDITATION !!!*/
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
#define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
#define T ll t = 1; cin>>t; while(t--)
#define ain ll n,k,i; cin>>n; ll a[n]; for( i=0; i<n; i++) cin>>a[i]
#define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
#define F first
#define S second
#define I insert
#define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
#define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
#define AISORT sort(a,a+n)
#define ADSORT sort(a,a+n,greater<ll>())
#define VISORT sort(x.begin(),x.end())
#define VDSORT sort(x.begin(),x.end(),greater<ll>())
#define pb push_back
#define ppb pop_back
 
const ll maxs = 1e6+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
ll fastpow(ll x,ll y)
{ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
ll inv(ll x){ return fastpow(x , mod - 2);}


bool vis[maxs];
vector<ll>graph[maxs];
//ALWAYS CLEAR THEM WHEN TESTCASES ARE GIVEN




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll k;
    ll a[33];// = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 
    a[1] = 1;
    a[2] = 1;
    a[3] = 1;
    a[4] = 2;
    a[5] = 1;
    a[6] = 2;
    a[7] = 1;
    a[8] = 5;
    a[9] = 2;
    a[10] = 2;
    a[11] = 1;
    a[12] = 5;
    a[13] = 1;
    a[14] = 2;
    a[15] = 1;
    a[16] = 14;
    a[17] = 1;
    a[18] = 5;
    a[19] = 1;
    a[20] = 5;
    a[21] = 2;
    a[22] = 2;
    a[23] = 1;
    a[24] = 15;
    a[25] = 2;
    a[26] = 2;
    a[27] = 5;
    a[28] = 4;
    a[29] = 1;
    a[30] = 4;
    a[31] = 1;
    a[32] = 51;
    
    cin >> k;
    cout << a[k];
       
}
    



Measured memory_bytes: 23808
#include<stdio.h>
int main(void){
	while(1){
	int a,b;
	char op;
	scanf("%d %c %d\n",&a,&op,&b);
	if(op=='?')break;
	else if(op=='+')printf("%d\n",a+b);
	else if(op=='*')printf("%d\n",a*b);
	else if(op=='-')printf("%d\n",a-b);
	else if(op=='/')printf("%d\n",a/b);
	else;}
	return 0;}

Measured memory_bytes: 604
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
#include<algorithm>
using namespace std;

int main(void)
{
    long long N;
    cin >> N;

    long long ans = LLONG_MAX;
    for (long long i = 1; i*i <= N; i++) {
        if (N%i != 0)
            continue;

        long long j = N / i;
        ans = min(ans, i + j - 2);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < 3; i++) {
                sb.append(in.next().charAt(i));
            }
            out.print(sb.toString());
        }

    }
}



Measured memory_bytes: 21716
////////// 標準入力マクロ /////////////////////////////////////////////////
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!{
        v: [i32; 6]
    }

    if v[4] - v[0] > v[5] {
        println!(":(")
    } else {
        println!("Yay!")
    }
}


Measured memory_bytes: 4352
n = int(input())
x = list(map(int, input().split()))
xsort = sorted(x)
x1, x2 = xsort[n//2-1], xsort[n//2]

for i in range(n):
    if x[i] <= x1:
        print(x2)
    else:
        print(x1)

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

int k;

// 左が遅いと正
int compareChar(const char lhs[], const char rhs[], int nl, int nr)
{
    // 空文字列は最後
    if (nl == 0 && nr > 0) return 1;
    if (nr == 0 && nl > 0) return -1;
    if (nl == 0 && nr == 0) return 0;

    int n = min(nl, nr);
    for (int i=0; i<n; i++)
    {
        if (lhs[i] > rhs[i]) return 1;
        if (lhs[i] < rhs[i]) return -1;
    }
    if (nl > nr) return 1;
    if (nl < nr) return -1;
    return 0;
}

int main()
{
    string line;
    cin >> line >> k;
    int len = line.size();
    const char* str = line.c_str();

    std::vector<pair<int, int> > best5(k, make_pair(0, 0));

    int atama = -1;

    while (true)
    {
        int min_ = 1000000;
        for (int i=0; i<len; i++)
        {
            if ((int)str[i] < min_ && (int)str[i] > atama) min_ = str[i];
        }
        if (min_ == 1000000) break;
        atama = min_;

        std::vector<int> min_list;
        for (int i=0; i<len; i++)
        {
            if (str[i] == atama) min_list.push_back(i);
        }

        for (auto i : min_list)
        {
            for (int j=1; j<=5; j++)
            {
                if (i+j>len) break;
                for (int l=0; l<k; l++)
                {
                    int res = compareChar(str + best5[l].first, str + i, best5[l].second, j);
                    if (res > 0)
                    {
                        best5.insert(best5.begin() + l, make_pair(i, j));
                        best5.pop_back();
                        break;
                    }
                    if (res == 0) break;
                    if (res < 0) continue;
                }
            }
        }
        if (best5[k-1].second > 0)
        {
            for (int i = best5[k-1].first; i<best5[k-1].first+best5[k-1].second; i++)
                cout << str[i];
            cout << "\n";
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 9223372036854775807
#define N 200001

using namespace std;

// input
int n,k;
int A[N],next_A[N];
bool n_flag[N];
int n_count = 0;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> n >> k;
  rep(i,n) cin >> A[i];

  rep(_,k) {

    rep(j,n+1) next_A[j] = 0;

    rep(j,n) {
      next_A[max(j-A[j],0)] += 1;
      next_A[min(j+A[j]+1,n)] -= 1;
    }

    rep(j,n) {
      next_A[j+1] += next_A[j];
    }
    rep(j,n) {
      A[j] = next_A[j];

      if(A[j] == n && ! n_flag[j]) {
        n_flag[j] = true;
        n_count += 1;
      }
    }

    if(n_count==n) break;

  }
  rep(i,n) cout << A[i] << " ";

}

Measured memory_bytes: 5404
#include<iostream>

using namespace std;

int main(void) {
	int n, m, l;
	int a[101][101];
	int b[101][101];
	long int c[101][101] = {};

	cin >> n >> m >> l;

	for (int i = 1; i <= n; i++) {
		for (int s = 1; s <= m; s++) {
			cin >> a[i][s];
		}
	}

	for (int i = 1; i <= m; i++) {
		for (int s = 1; s <= l; s++) {
			cin >> b[i][s];
		}
	}

	for (int i = 1; i <= n; i++) {
		for (int t = 1; t <= l; t++) {
			for (int s = 1; s <= m; s++) {
				c[i][t] += a[i][s] * b[s][t];
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		for (int s = 1; s <= l; s++) {
			cout<< c[i][s];
			if (s==l) {
				cout << "\n";
				break;
			}
			cout << " ";
		}
	}
	return 0;
}

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

int main(void){
	int w, h;
	int dx[] = {1,1,0,-1,-1,-1,0,1};
	int dy[] = {0,1,1,1,0,-1,-1,-1};
	while(true){
		cin >> w >> h;
		if(!w&&!h)break;
		vector<int> c[h+2];
		c[0].resize(w+2);
		c[h+1].resize(w+2);
		for(int i = 1; i <= h; ++i){
			c[i].resize(w+2);
			for(int j = 1; j <= w; ++j){
				cin >> c[i][j];
			}
		}
		int ans = 0;
		queue<pair<int, int>> q;
		for(int i = 1; i <= h; ++i){
			for(int j = 1; j <= w; ++j){
				if(c[i][j] == 1){
					q.emplace(i,j);
					ans++;
					c[i][j] = 0;
					while(!q.empty()){
						int x = q.front().first;
						int y = q.front().second;
						q.pop();
						for(int dir = 0; dir < 8; ++dir){
							int nx = x + dx[dir];
							int ny = y + dy[dir];
							if(c[nx][ny]==1){
								q.emplace(nx,ny);
								c[nx][ny]=0;
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N;
    long long K;
    cin >> N >> K;
    long long B[100001] = {0};

    int a,b;
    for(int i=0;i<N;i++){
        cin >> a >> b;
        B[a] += b;
    }

    long long count = 0;
    for(int i=1;i<=100000;i++){
        if(count + B[i] < K){
            count += B[i];
        }else{
            cout << i;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

  ll a,b,c,k,ans=0;
  cin >> a >> b >> c;
  cin >> k;

  if(a>b){
    ans += floor(log2(a)-log2(b))+1;
    b = (int) pow(b, ans+1);
  }else if(a==b){
    ans++;
    b *= 2;
  }
  if(b>c){
    ans += floor(log2(b)-log2(c))+1;
  }else if(b==c){
    ans++;
  }
  
  cout << ( k>=ans? "Yes": "No");
  return 0;
}

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

signed main(void)
{
	long long x, y, ans;
	cin >> x >> y;
	ans = abs(abs(y) - abs(x));
	if (x * y < 0)
		ans += 1;
	else
		if (x > y)
		{
			if (x == 0 || y == 0)
				ans += 1;
			else
				ans += 2;
		}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>


#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define int long long

using namespace std;
using namespace std::chrono;

signed main(){
  int aa, bb, m;
  cin >> aa >> bb >> m;
  int a[aa], b[bb];
  int m_a = 100010, m_b = 100010;
  for (int i = 0; i < aa; i++){
    cin >> a[i];
    m_a = min(m_a, a[i]);
  }
  for (int i = 0; i < bb; i++){
    cin >> b[i];
    m_b = min(m_b, b[i]);
  }
  int bst = m_b + m_a;
  for (int i = 0; i < m; i++){
    int x, y, c;
    cin >> x >> y >> c;
    x--, y--;
    bst = min (bst, a[x] + b[y] - c);
  }
  cout << bst << endl;
  
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    string s[a];
    for(i=0;i<a;i++)
        cin>>s[i];
    sort(s,s+a);
    for(i=0;i<a;i++)
        cout<<s[i];
    return 0;
}



Measured memory_bytes: 3588
#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
typedef long long Int;

int N, M, Q;
vector<pair<int, Int> > g[200000];
Int hi[200000], cy[64];
bool vis[200000];

void add(Int b) {
    for (int x = 63; b; x--) if (b&(1LL<<x)) {
        if (cy[x] == 0) { cy[x] = b; return ; }
        b ^= cy[x];
    }
}

void rec(int at, int pre, Int bit) {
    if (vis[at]) {
        add(bit^hi[at]);
        return ;
    }
    vis[at] = 1;
    hi[at] = bit;
    rep (i, g[at].size()) {
        const  int to = g[at][i].first;
        if (to == pre) continue;
        rec(to, at, bit^g[at][i].second);
    }
}

void build() {
    rec(0, -1, 0);
}

Int solve(int u, int v) {
    Int ans = hi[u]^hi[v];
    for (int x = 63; x >= 0; x--) if (cy[x] && (ans&(1LL<<x)) == 0) {
        ans ^= cy[x];
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M >> Q;
    rep (i, M) {
        int f, t;
        Int p;
        cin >> f >> t >> p;
        g[f].push_back(mp(t, p));
        g[t].push_back(mp(f, p));
    }
    build();
    rep (_, Q) {
        int a, b;
        cin >> a >> b;
        cout << solve(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 16660
n=int(input())
data=[list(map(int,input().split()))for _ in range(n)]
data=sorted(data, key=lambda x: x[0])
data=sorted(data, key=lambda x: x[1])
time=0
for i in data:
  time+=i[0]
  if time>i[1]:
    print("No")
    exit()
print("Yes")

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

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

using namespace std;

int main() {
    int n;
    vector<int> v(n),c(n);
    cin >> n;
    rep(i,n){
        cin >> v[i];
    }
    rep(i, n){
        cin >> c[i];
    }
    int ans = 0;
    rep(i, n){
        if(v[i] > c[i]){
            ans += v[i] - c[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import sys


def int1(x): return int(x) - 1
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def mi1(): return map(int1, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def lli(rows_number): return [li() for _ in range(rows_number)]


if __name__ == "__main__":
    x, y = mi()
    tks = []
    for i in range(x+1):
        tks.append([i, x-i])
    for tk in tks:
        if tk[0]*2 + tk[1]*4 == y:
            print('Yes')
            exit()
    print('No')


Measured memory_bytes: 9200
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

var (
	N, A, B, C int
)

func main() {
	defer stdout.Flush()
	N := readInt()
	A = readInt()
	B = readInt()
	C = readInt()
	l := make([]int, N)
	for i := range l {
		l[i] = readInt()
	}
	println(solve(l, make([]int, 0), make([]int, 0), make([]int, 0)))
}

func calc(x int, a []int) int {
	var sum int
	for _, v := range a {
		sum += v
	}
	return absInt(x-sum) + 10*(len(a)-1)
}

func solve(l, a, b, c []int) int {
	if len(l) == 0 {
		if len(a) == 0 || len(b) == 0 || len(c) == 0 {
			return math.MaxInt32
		}
		return calc(A, a) + calc(B, b) + calc(C, c)
	}
	ret := math.MaxInt32
	ret = minInt(ret, solve(l[1:], append(a, l[0]), b, c))
	ret = minInt(ret, solve(l[1:], a, append(b, l[0]), c))
	ret = minInt(ret, solve(l[1:], a, b, append(c, l[0])))
	ret = minInt(ret, solve(l[1:], a, b, c))
	return ret
}

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

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

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

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

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1920