akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n); ++i)
typedef long long ll;
using namespace std;

int main(){  
    
  ll a,b;
  cin >> a >> b;
  
  ll x;
 
  x = b * 10;
  
  rep(i,10){
    ll tmp = x + i;
    ll aa = tmp * 0.08;
    if(aa == a){
      cout << tmp << endl;
      return 0;
    }
  }
  
  cout << -1 <<  endl;
  
    return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int a, b, c, d, n, ans;
int ar[234567];
string s;
bool b1, b2;
signed main() {
	cin >> a >> b; cout << a * b << endl;
}


Measured memory_bytes: 3168
import numpy as np

n = int(input())
p = list(map(float, input().split()))

dp = np.zeros(n + 1, float)
dp[0] = 1
for e in p:
    dp[1:] += dp[:-1] * e / (1 - e)
    dp *= 1 - e

ans = dp[(n+1)//2:].sum()
print(ans)


Measured memory_bytes: 27536
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let mut l: Vec<usize> = read_vec();
    l.sort();
    let m = l[n -1];
    let sum = l.iter().fold(0, |acc, x| acc + x);

    if sum >  2 * m {
      println!("Yes");
    } else {
      println!("No");
    }

}


Measured memory_bytes: 4352
import sys
from collections import deque
from collections import Counter

readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))


x = A[0]
y, z = x, x
for a in A:
    if a != x:
        y = a
        break
for a in A:
    if a != x and a != y:
        z = a
        break

if N % 3 == 0:
    cx, cy, cz = A.count(x), A.count(y), A.count(z)
    if x != y and x != z:
        if cx + cy + cz == N:
            if cx == cy and cx == cz and ((x ^ z == y) or (x ^ y == z)):
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    elif x != y:
        x, y = max(x,y), min(x,y)
        cx, cy = A.count(x), A.count(y)
        if cy * 2 == cx and y == 0:
            print('Yes')
        else:
            print('No')
    elif x == y:
        if x == 0:
            print('Yes')
        else:
            print('No')
else:
    if x == y:
        if x == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  string s[N];
  rep(i,N) cin >> s[i];
  ll c[5]={};
  rep(i,N){
    if(s[i][0]=='M') c[0]++;
    if(s[i][0]=='A') c[1]++;
    if(s[i][0]=='R') c[2]++;
    if(s[i][0]=='C') c[3]++;
    if(s[i][0]=='H') c[4]++;
  }
  ll ans=0;
  rep(i,3){
    for(int j=i+1; j<4; j++){
      for(int k=j+1; k<5; k++){
	ans += c[i]*c[j]*c[k];
      }
    }
  }
  cout << ans << endl;
    
  return 0;
    

}


Measured memory_bytes: 5760
#include<iostream>
using namespace std;
bool v[101];
int main()
{
    int a,b,c;
    int cnt=0;
    cin>>a>>b>>c;
    v[a]=true;
    v[b]=true;
    v[c]=true;
    for(int i=1;i<=100;i++)
        if(v[i])
            cnt++;
        cout<<cnt;
}


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

int main() {
    int N, K;
    cin >> N >> K;

    vector<int> vec(N);
    int count = 0;
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    for (int i = 0; i < K; i++) {
        count += vec.at(i);
    }

    cout << count << endl;

}

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

int main()
{
	string str;
	string str1 = " ";
	cin >> str;
	int cnt = 0;
	int i = 0;
	for(i = 0; i < str.size();){
		int t = 1;
//		cout << i << " " << t + i << endl;
//		
		while(str1 == str.substr(i, t)){
			t++;

			if(i + t > str.size()){
				i = str.size();
				break;
			}
		}if(i == str.size() )break;
		str1 = str.substr(i,t);
//		cout << str1 <<  endl;
		i += t;
		cnt++;	
	}
	cout << cnt ;
	return 0;
}

Measured memory_bytes: 640
import java.math.BigInteger;
import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        long[] v = IntStream.range(0, n).mapToLong(i -> scanner.nextLong()).sorted().toArray();

        double ave = Arrays.stream(v).skip(n - a).average().getAsDouble();
        int count = 0;
        int max = 0, min;
        for (int i = 0; i < n; i++) {
            if (v[i] == v[n - a]) {
                count++;
                max = i;
            }
        }

        min = a - n + max + 1;
        max = max + 1 == n ? Math.min(b - n + max + 1, count) : min;

        BigInteger[] fac = new BigInteger[count + 1];
        fac[0] = BigInteger.ONE;
        for (int i = 1; i <= count; i++) {
            fac[i] = fac[i - 1].multiply(BigInteger.valueOf(i));
        }

        long ans = 0;
        for (int i = min; i <= max; i++) {
            ans += fac[count].divide(fac[count - i].multiply(fac[i])).longValue();
        }
        System.out.println(ave);
        System.out.println(ans);
    }
}

Measured memory_bytes: 29268
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 1000000007;
const int inf = 100000005;
const int N = 200005, M = N;
int i,j,n,m;

ll cnt , idx;
vi temp;

void solve() {
   ll x,ans;
   fo(i,0,5) {
    cin>>x;
    if(!x) ans = i;
   }
   cout<<ans+1<<"\n";
}

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

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

    return 0;
}




Measured memory_bytes: 3652
K=int(input())
A,B = map(int, input().split())

iA=A//K
iB=B//K

Ks = [i*K for i in range(iA,iB+1)]

if iB == 0:
    print('NG')
else:
    for k in Ks:
        if A <= k <= B:
            print('OK')
            exit()
    print('NG')

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

//-------------------------------------------------------------------
int M=1;
std::vector<int> seg, seg2;
void init(int N){
  while(M<N) M*=2;
  M=M*2-1;
  for(int i=0;i<M;i++) {
    seg.push_back(0);
    seg2.push_back(0);
  }
}
void update(ll k, int mode){
  k+=(M+1)/2-1;
  (mode==0?seg[k]:seg2[k]) ++;
  while(k>0){
    k = (k-1)/2;
    (mode==0?seg[k]:seg2[k]) = (mode==0?seg[k*2+1]:seg2[k*2+1]) + (mode==0?seg[k*2+2]:seg2[k*2+2]);
  }
}
ll query(int a, int b, int l, int r, int k, int mode){
  if(r<=a||b<=l) return 0;
  if(a<=l&&r<=b) return (mode==0?seg[k]:seg2[k]);
  ll A = query(a, b, l, (l+r)/2, k*2+1, mode);
  ll B = query(a, b, (l+r)/2, r, k*2+2, mode);
  return A+B;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll N;
  ll P = 998244353;
  ll ans = 0;
  std::cin >> N;
  vvl xy = vv(N, 2, 0, ll);
  map<ll, ll> convert;
  for(int i=0;i<N;i++)  std::cin >> xy[i][0] >> xy[i][1];
  sort(xy.begin(), xy.end(), [](std::vector<ll> a, std::vector<ll> b){return a[1]<b[1];});
  for(int i=0;i<N;i++) convert.emplace(xy[i][1], convert.size());
  sort(xy.begin(), xy.end());
  init(N);
  vvl data = vv(N, 4, 0, ll);
  for(int i=0;i<N;i++){
    data[i][0] = query(0, convert.at(xy[i][1]), 0, (M+1)/2, 0, 0);
    data[i][1] = query(convert.at(xy[i][1]), N, 0, (M+1)/2, 0, 0);
    update(convert.at(xy[i][1]), 0);
  }
  for(int i=N-1;i>=0;i--){
    data[i][2] = query(0, convert.at(xy[i][1]), 0, (M+1)/2, 0, 1);
    data[i][3] = query(convert.at(xy[i][1]), N, 0, (M+1)/2, 0, 1);
    update(convert.at(xy[i][1]), 1);
  }
  std::vector<ll> p2(N+1, 1);
  for(int i=1;i<=N;i++) p2[i] = (p2[i-1]*2)%P;
  for(int i=0;i<N;i++){
    ll a = (p2[data[i][0]] + p2[data[i][3]]-1)%P;
    ll b = (p2[data[i][2]] + p2[data[i][1]]-1)%P;
    ll v = (p2[N]-a*b)%P;
    if(v<0) v=v+P;
    ans = (ans+v)%P;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 43876
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {

	ll a, b, c, k;

	cin >> a >> b >> c >> k;

	ll ans = 0;

	if (a < k) {

		ans += a;
		k -= a;

	}
	else if (a >= k) {
		cout << k << endl;
		return 0;
	}
	if (b < k) {

		k -= b;

	}
	else if (b >= k) {
		cout << ans  << endl;
		return 0;
	}
	if (c < k) {

		ans += c*(-1);
		
	}
	else if (c >= k) {
		cout << ans + (k*-1) << endl;
		return 0;
	}
	cout << ans <<endl;
	return 0;

}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

int grid[55][55] = {0};
int dist[55][55] = {0};

int main(){
    int h, w, count=0;
    cin >> h >> w;
    rep(y,h) rep(x, w){
        char s;
        cin >> s;
        if(s == '#'){
            grid[x][y] = 1;
            count++;
        }
    }
    dist[0][0] = 1;
    queue<pii> q;
    q.push(mp(0,0));
    while(!q.empty()){
        pii pos = q.front(); q.pop();
        // printf("pos %d,%d\n", pos.first, pos.second);
        rep(i,4){
            int nx = pos.first + dx[i];
            int ny = pos.second + dy[i];
            if( nx < 0 || w <= nx || ny < 0 || h <= ny ) continue;
            if(grid[nx][ny] == 0 && dist[nx][ny] == 0){
                dist[nx][ny] = dist[pos.first][pos.second] + 1;
                q.push(mp(nx, ny));
            }
            if(nx == h-1 && ny == w-1) break;
        }
    }
    int ans = h*w - count - dist[w-1][h-1];
    if(dist[w-1][h-1] == 0) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 256
import Foundation

let N = Int(readLine()!)!
let managerCodeList = readLine()!.components(separatedBy: " ").map({return Int($0)!})
var bukaCountList = Array<Int>(repeating: 0, count: N)

managerCodeList.forEach({
    bukaCountList[$0-1] += 1
})

bukaCountList.forEach{
    print($0)
}

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

int main(){
    
    int array[3];
    int a,b,c,f = 0,s = 0;
    cin >> a >> b >> c;
    array[0] = a;
    array[1] = b;
    array[2] = c;
    
    for (int x = 0; x <= 2; x++) {
        switch (array[x]) {
            case 5:
                f++;
                break;
            case 7:
                s++;
                break;
            default:
                break;
        }
    }
    
    if(f == 2 && s == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}


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


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

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll l = lcm(c, d);
    ll A = a - 1 - (a - 1) / c - (a - 1) / d + (a - 1) / l;
    ll B = b - b / c - b / d + b / l;
    cout << B - A << endl;
    return 0;
}

Measured memory_bytes: 3604
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


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


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    S = input()

    num = 0
    for i in range(len(S) // 2):
        num += S[i] != S[-i - 1]
    print(num)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9788
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
P p[200005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&p[i].second,&p[i].first);
	}
	sort(p,p+n);
	int sum=0;
	for(int i=0;i<n;i++){
		//printf("%d %d %d\n",sum,p[i].second,p[i].first);
		if(sum+p[i].second>p[i].first){
			printf("No\n");
			return 0;
		}
		sum+=p[i].second;
	}
	printf("Yes\n");
	return 0;
}


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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define ll long long
#define ld long double

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

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()

#define endl '\n'
using namespace std;

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; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double PI=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=1000010;
bool IsPrime[MAX];
int MinFactor[MAX];
vector<int> preprocess(int n = MAX) {
    vector<int> res;
    for (int i = 0; i < n; ++i) IsPrime[i] = true, MinFactor[i] = -1;
    IsPrime[0] = false; IsPrime[1] = false; 
    MinFactor[0] = 0; MinFactor[1] = 1;
    for (int i = 2; i < n; ++i) {
        if (IsPrime[i]) {
            MinFactor[i] = i;
            res.push_back(i);
            for (int j = i*2; j < n; j += i) {
                IsPrime[j] = false;
                if (MinFactor[j] == -1) MinFactor[j] = i;
            }
        }
    }
    return res;
}
vector<pair<int,int> > prime_factor(int n) {
    vector<pair<int,int> > res;
    while (n != 1) {
        int prime = MinFactor[n];
        int exp = 0;
        while (MinFactor[n] == prime) {
            ++exp;
            n /= prime;
        }
        res.push_back(make_pair(prime, exp));
    }
    return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  ll gall = a[0];
  rep(i,n-1) gall=gcd(gall,a[i+1]);
  bool ok = true;
  map<int,int>mp;
  preprocess();
  rep(i,n){
    auto vec = prime_factor(a[i]);
    for(auto v:vec){
      mp[v.first]++;
    }
  }
  for(auto p:mp){
    if(p.second>1)ok= false;
  }
  if(ok)cout << "pairwise coprime" << endl;
  else if(!ok && gall==1)cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
  return 0;
}


Measured memory_bytes: 15708
#include <stdio.h>

int main() {
	int W, H, x, y;
	double menseki;

	scanf("%d %d %d %d", &W, &H, &x, &y);

	menseki = (double)W * H / 2;
	if (x * 2 == W && y * 2 == H) {
		printf("%lf 1\n", menseki);
	}
	else {
		printf("%lf 0\n", menseki);
	}

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] s = scanner.nextLine().toCharArray();
		
		System.out.println(String.valueOf(s[0])+(s.length-2)+String.valueOf(s[s.length-1]));
		
		
		scanner.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase
#include <ctime>    // clock

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int tmp = s.size();
    if(s[tmp-1] != 's') s += "s";
    else s += "es";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3656
#[int(i) for i in input().split()]
n = int(input())
s = {}
for i in range(n):
    tmp = input()
    try:
        s[tmp] += 1
    except:
        s[tmp] = 1
smax = max(s.values())
ls = []
for i in s.keys():
    if s[i] == smax:
        ls.append(i)
ls.sort()
for i in ls:
    print(i)


Measured memory_bytes: 92120
#include <iostream>
#include <vector>

int main(){
    int n, m;
    std::cin >> n >> m;

    std::vector<int> x(m);
    for(int i = 0; i < m; ++i){
        std::cin >> x.at(i);
    }

    std::sort(x.begin(), x.end());

    std::vector<int> y(m - 1);
    for(int i = 0; i < m - 1; ++i){
        y.at(i) = x.at(i + 1) - x.at(i);
    }

    std::sort(y.begin(), y.end());

    int ans = 0;
    if(n < m){
        for(int i = 0; i < m - n; ++i){
            ans += y.at(i);
        }
    }else{
        ans = 0;
    }

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

    return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int D[100000], H[100000];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, K;
	cin>>N>>K;
	for(int i=0;i<N;i++) cin>>H[i];
	for(int i=1;i<N;i++) {
		D[i]=0x7fffffff;
		for(int j=max(i-K,0);j<i;j++) {
			D[i]=min(D[i],D[j]+abs(H[i]-H[j]));
		}
	}
	cout<<D[N-1]<<'\n';
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector dp(n+1, 0LL);
    ll sum = a[0];
    dp[0] = dp[1] = 0;
    for(int i = 2; i <= n; i++) {
        if(i % 2 == 0){
            dp[i] = max(dp[i-2] + a[i-1], sum);
            if(i < n)sum += a[i];
        }
        else {
            dp[i] = max(dp[i-2] + a[i-1], dp[i-1]);
        }
    }

    cout << dp[n] << endl;
}

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

int main(){
	/*input*/
	long int n;	cin >> n;
	long int* d = new long int[n];
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	/*calculation*/
	sort(d, d + n);
	/*output*/
	cout << d[n/2] - d[n/2 - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	int D = B / A;
	if (D >= C) {
		printf("%d", C);
	}
	else if (D <= C) {
		printf("%d", D);
	}


	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,s,t) for (int i=s;i<=t;++i)
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e5+10;
using namespace std;
int dp[42][(1<<17)+10];
int bit[20];
int main(){
    bit[0]=1;
    rep(i,1,19) bit[i]=bit[i-1]*2;
    int n,x,y,z;
    scanf("%d%d%d%d",&n,&x,&y,&z);
    int t=x+y+z;
    int ans=bit[x-1]+bit[x+y-1]+bit[x+y+z-1];
    dp[0][0]=1;
    rep(i,0,n-1){
        rep(j,0,bit[t]-1){
            rep(k,1,10){
                int tmp=(((j<<k)+bit[k-1])&(bit[t]-1));
                if ((tmp&ans)!=ans)(dp[i+1][tmp]+=dp[i][j])%=mod;
            }
        }
    }
    int ret=1;
    rep(i,1,n) ret=ret*10ll%mod;
    rep(i,0,bit[t]-1) ret=(ret-dp[n][i]+mod)%mod;
    printf("%d\n",ret);
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

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

const double PI = 3.14159265358979;

class UnionFind{
public:
  vector<int> p;		// 親
  vector<int> rank;	// サイズ・各集合の根のみ有効
  UnionFind(int n){
    p.resize(n, -1);
    rank.resize(n, 1);
  }
  int root(int x){
    if(p[x] == -1)return x;
    else return p[x] = root(p[x]); // 深さを 1 にしている
  }
  void unite(int x, int y){
    x = root(x); y = root(y);
    if(x == y)return;
    if(rank[x] > rank[y]) swap(x, y); // rankの小さいものを下につける
    rank[y] += rank[x];
    p[x] = y;
  }
  //xが属すグループのサイズ
  int size(int x){ return rank[root(x)]; }
  bool same(int x, int y){ return (root(x) == root(y)); }
};

void solve()
{
  ll n, m, ina, inb;
  cin >> n >> m;

  int ans = 1;
  UnionFind uf(n);
  for(int i = 0; i < m; ++i)
  {
    cin >> ina >> inb;
    uf.unite(ina, inb);
    ans = max(ans, uf.size(ina));
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4780
fun main(args: Array<String>) {
    var N = readInt()
    var S = readString()
    println(S.map { (((it-'A' + N) % 26)  + 'A'.toInt()).toChar() }.joinToString(""))
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun Int.pow(n: Int) = Math.pow(this.toDouble(), n.toDouble())

Measured memory_bytes: 31944
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr;
  walloc1d(&arr, N, &mem);
  for(i=(0);i<(N);i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=(0);i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int T;
int A[3000];
int B[3000];
int dp[6000];
int main(){
  int k;
  wmem = memarr;
  rd(N);
  rd(T);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
      rd(B[Lj4PdHRW]);
    }
  }
  sortA_L(N,A,B);
  for(k=(0);k<(N);k++){
    int i;
    for(i=(T+A[k])-1;i>=(A[k]);i--){
      chmax(dp[i], dp[i-A[k]] + B[k]);
    }
  }
  {
    int xr20shxY;
    int WYIGIcGE;
    if(6000==0){
      WYIGIcGE = 0;
    }
    else{
      WYIGIcGE = dp[0];
      for(xr20shxY=(1);xr20shxY<(6000);xr20shxY++){
        WYIGIcGE = max_L(WYIGIcGE, dp[xr20shxY]);
      }
    }
    wt_L(WYIGIcGE);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20191111-2

// --- original code ---
// int N, T, A[3000], B[3000];
// int dp[6000];
// {
//   rd(N,T,(A,B)(N));
//   sortA(N,A,B);
//   rep(k,N){
//     rrep(i,A[k],T+A[k]) dp[i] >?= dp[i-A[k]] + B[k];
//   }
//   wt(max(dp(6000)));
// }


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

int main(){
  int N;
  cin >> N;
  for (int i = 1; i <= 3500; i++) {
    for (int j = 1; j <= 3500; j++) {
      double w = (double)N*i*j;
      double b = (double)4*i*j - N*i - N*j;
      if (b == 0) continue;
      w /= b;
      if (w == (int)w && w > 0) {
        printf("%d %d %d\n",i,j,(int)w);
        return 0;
      }
    } 
  }
  return 0;
}

Measured memory_bytes: 256
dic = {"I":1, "V":5, "X":10, "L":50, "C":100 ,"D":500,"M":1000}

while True:
  try:
    line = [dic[i] for i in input()]
    acc = 0

    for i in range(len(line) - 1):
      if line[i] < line[i + 1]:
        acc -= line[i]
      else:
        acc += line[i]

    acc += line[-1]
    print(acc)

  except EOFError:
    break
 


Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    for(int i = 1; i<10; i++){
        for(int j = 1; j<10; j++){
            if (i * j == n){
                cout << "Yes" << endl;
                return 0;
            }else if(i * j == 81){
                cout << "No" << endl;
                break;
            }
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

template<typename T>
ostream& operator<< (ostream& out, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        out << *it << " ";
    }
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        in >> *it;
    }
    return in;
}

int main() {
    ll N;
    cin >> N;
    if (N % 10 == 9 || N / 10 == 9) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// clang-format off
#define rep(i, j) for (long long i = 0; i < j; i++)
#define int long long
#define gcn(N) int N;cin >> N;
#define debug(var) do {std::cout << #var << " : "; view(var);} while (0)
template <typename T> void view(T e) { std::cout << e << std::endl; } template <typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void view(const std::vector<std::vector<T>>& vv) { for (const auto& v : vv) { view(v); } } using namespace std; void before_main() { std::cout << std::fixed << std::setprecision(10); } namespace { struct before_main_caller { before_main_caller() { before_main(); } } caller; }
// clang-format on
signed main()
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int n, x, y; cin >> n >> x >> y;
  map<int,int> m;

  rep2(i, 1, n) rep2(j, i+1, n) {
    int dis = MOD;

    chmin(dis, j-i);
    chmin(dis, abs(x-i) + abs(y-j) + 1);
    chmin(dis, abs(y-i) + abs(x-j) + 1);

    ++m[dis];
  }

  rep2(i, 1, n-1) cout << m[i] << endl;

  return (0);
}


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

typedef long long int ll;

vector <ll> a;
vector <ll> ans(100005);

bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

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

    ll i,j,k,l,m,n;

    cin >> n >> k;

    for(i=0;i<n;i++)
    {
        cin >> j;
        a.push_back(j);
    }

    // sort(a.begin(),a.end());

    ans[0] = 0;

    if(a[0]<=1)
    {
        ans[1] = 1;
    }
    else
    {
        ans[1] = 0;
    }

    // cout << ans[0] << " " << ans[1] << " ";


    for(i=2;i<=k;i++)
    {

        // ans[i] = 1;
        for(j=0;j<n;j++)
        {
            if(a[j]<=i)
            {
                if(ans[i - a[j]] == 1)
                    ans[i] = 0;
                else
                    ans[i] = 1;

                if(ans[i]==1)
                {
                    break;
                }
            }

            
        }

        // cout << ans[i] << " ";


    }
    // cout << '\n';

    if(ans[k] == 0)
        cout << "Second\n";
    else
        cout << "First\n";



    


}

Measured memory_bytes: 1024
n=int(input())
h=list(map(int,input().split()))
arr=[x for x in h]
cnt=0

while 1:
  if all([x==0 for x in h]):
    break
  for i in range(n):
    if h[i]!=0:
      s=i
      break
  e=s
  for i in range(s,n-1):
    if h[s]<=h[i+1]:
      e+=1
    else:
      break
  h=[h[i]-1 if s<=i<=e else h[i] for i in range(n)]
  cnt+=1
print(cnt)

Measured memory_bytes: 43868
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

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

int i,j;

int main(void){
    
    int n;
    cin>>n;
    vector<int> a;
    FOR(i,n){
        int w;
        cin>>w;
        a.push_back(w);
    }
    int mn=1000,mx=0;
    FOR(i,n){
        mn=min(mn,a[i]);
        mx=max(mx,a[i]);
    }
    
    cout<<mx-mn;
    
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
    #include <string>
    #include <vector>
    #include <algorithm>
    #include <functional>
    #include <cmath>
    #include <iomanip>
    #include <stack>
    #include <queue>
    #define rep(i,n) for(int i=0;i<(n);i++)
    #define pb push_back
    #define mod 1000000007
    typedef long long ll;
    using namespace std;
     
    int main(){
      int N,M;
      cin >> N >> M;
      vector<string> A(N);
      vector<string> B(M);
      rep(i,N) cin >> A[i];
      rep(i,M) cin >> B[i];
      rep(y,N-M+1){
        rep(x,N-M+1){
          rep(yy,M){
            rep(xx,M){
              if(A[y+yy][x+xx]==B[yy][xx]){}
              else goto OUT;
            }
          }
          {cout << "Yes" << endl; return 0;}
          OUT:{}
        }
      }
      cout << "No" << endl;
      return 0;
    }

Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n,a,b = gi
puts min a*n,b


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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> A(((N+1)/2)*2,0);
    for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    int ans = 0;
    for (size_t i = 0; i < (N+1)/2; i++)
    {
        ans += A.at(i*2) - A.at(2*i+1);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3544
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ans,cnt
    integer(int32), allocatable:: p(:)

    read*, n
    allocate(p(n))
    read*, p

    ans=0
    do i=1,n
        if (p(i) == i) ans=ans+1
    end do

    cnt=1
    do i=2,n
        if (p(i) == i .and. p(i-1) == i-1) then
            cnt=cnt+1
        else
            ans=ans-cnt/2
            cnt=1
        end if
    end do
    ans=ans-cnt/2
    print'(i0)', ans
end program name

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

#define MX 500050
#define mod 1000000007
typedef long long ll;

int a[MX];
int sum[MX];
int dp[1 << 20], dps[1 << 20];

int main() {
	int n; scanf("%d", &n);
	int zc = 0, cur = 0;
	for(int i = 0; i < n; i++) {
		scanf("%d", a + i);
		cur ^= a[i];
		if(i) sum[i] = sum[i - 1];
		if(!cur) zc++, sum[i]++;
	}
	if(cur) {
		int s0 = 0, sv = 0, V = cur;
		cur = 0;
		for(int i = 0; i < n; i++) {
			cur ^= a[i];
			if(!cur) s0 = (s0 + sv) % mod;
			if(cur && cur == V) sv = (sv + s0 + 1) % mod;
		}
		printf("%d\n", (s0 + 1) % mod);
		return 0;
	}
	int res = 1;
	for(int i = 1; i < zc; i++) res = res * 2 % mod;
	for(int i = 0; i < n; i++) {
		cur ^= a[i];
		if(!cur) continue;
		int val = (ll)dp[cur] * sum[i] % mod;
		val = (val + mod - dps[cur] + 1) % mod;
		dp[cur] = (dp[cur] + val) % mod;
		dps[cur] = (dps[cur] + (ll)val * sum[i]) % mod;
	}
	for(int i = 0; i < (1 << 20); i++) res = (res + dp[i]) % mod;
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 12288
#include <iostream>
#define INF 1e+9
using namespace std;

int b(int a1,int a2,int a3,int a4){
	return a1 + a2 * 2 + a3 * 4 + a4 * 8;
}

int main(){
	int h,n,dp[10010][16] = {};
	int ng[10010][4] = {};
	cin >> h >> n;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		ng[y][x] = 1;
	}
	int tmp = 0;
	for(int i = 0;i < 4;i++){
		if(ng[0][i]) tmp += (1 << i);
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < 16;j++) dp[i][j] = -INF;
	}
	dp[0][tmp] = 0;
	for(int i = 1;i < h;i++){
		for(int j = 0;j < 16;j++){
			bool a[4] = {};
			for(int k = 0;k < 4;k++){
				if(!((j >> k) & 1) && !ng[i][k]) a[k] = true;
			}
			dp[i][b(ng[i][0],ng[i][1],ng[i][2],ng[i][3])] = max(dp[i][b(ng[i][0],ng[i][1],ng[i][2],ng[i][3])],dp[i - 1][j]);
			if(a[0] && a[1]) dp[i][b(1,1,ng[i][2],ng[i][3])] = max(dp[i][b(1,1,ng[i][2],ng[i][3])],dp[i - 1][j] + 1);
			if(a[1] && a[2]) dp[i][b(ng[i][0],1,1,ng[i][3])] = max(dp[i][b(ng[i][0],1,1,ng[i][3])],dp[i - 1][j] + 1);
			if(a[2] && a[3]) dp[i][b(ng[i][0],ng[i][1],1,1)] = max(dp[i][b(ng[i][0],ng[i][1],1,1)],dp[i - 1][j] + 1);
			if(a[0] && a[1] && a[2] && a[3]) dp[i][15] = max(dp[i][15],dp[i - 1][j] + 2);
		}
	}
	int ma = 0;
	for(int i = 0;i < 16;i++) ma = max(ma,dp[h - 1][i]);
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 3892
#include <iostream>
#include <algorithm>
using namespace std;
int n, q, x, s[300003]; bool a[300003];
int sum(int l, int r) {
	return s[r - 1] - s[l - 1];
}
int main() {
	scanf("%d%d", &n, &q);
	for(int i = 0; i < n; i++) scanf("%d", &x), a[x] = true;
	for(int i = 1; i <= 300000; i++) s[i] = s[i - 1] + (a[i] ? 1 : 0);
	for(int i = 0; i < q; i++) {
		scanf("%d", &x);
		int ret = 0;
		for(int j = x; j <= 300000; j += x) {
			if(sum(j - x, j) == 0) continue;
			int l = j - x, r = j;
			while(r - l > 1) {
				int m = (l + r) / 2;
				if(sum(m, j) != 0) l = m;
				else r = m;
			}
			//printf("%d %d\n", j - x, l);
			ret = max(ret, l - (j - x));
		}
		printf("%d\n", ret);
	}
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

int n;

lli k;

vector< pii > sweep;

int main()
{
	scanf("%d %lld",&n,&k);

	for(int i = 1 ; i <= n ; i++)
	{
		int a, b;
		scanf("%d %d",&a,&b);

		sweep.push_back( { a , b } );
	}

	sort( sweep.begin() , sweep.end() );

	for(int i = 0 ; i < n ; i++)
	{
		if( k <= sweep[i].second )
		{
			printf("%d\n",sweep[i].first);
			return 0;
		}

		k -= sweep[i].second;
	}
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

// AtCoder
const i64 CYCLES_PER_SEC = 3000000000;

struct Timer {
	i64 start;
	Timer(){reset();}
	void reset(){start=getCycle();}
	inline double get(){return (double)(getCycle()-start)/CYCLES_PER_SEC;}
	inline i64 getCycle(){
		u32 low,high;
		__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
		return ((i64)low)|((i64)high<<32);
	}
};

Timer timer;

uint32_t xor128(){
  static uint32_t x = 123456789;
  static uint32_t y = 362436069;
  static uint32_t z = 521288629;
  static uint32_t w = 88675123;
  uint32_t t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

//INSERT ABOVE HERE
const int A = 26;
const int MAX_D = 365;
int cs[A+1];
int s[MAX_D+1][A+1];
int r[A+1][MAX_D+1];
int ts[MAX_D+1];
int ls[A+1];

using BS = bitset<64 * 6>;
BS vs[A+1];

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

  int D;
  cin>>D;

  for(int j=1;j<=A;j++) cin>>cs[j];

  for(int i=1;i<=D;i++)
    for(int j=1;j<=A;j++)
      cin>>s[i][j],r[j][i]=s[i][j];

  {
    memset(ls,0,sizeof(ls));
    for(int i=1;i<=D;i++){
      vector<int> ss(A+1,0);
      for(int j=1;j<=A;j++)
        ss[j]=s[i][j]+cs[j]*(i-ls[j]);
      ts[i]=max_element(ss.begin()+1,ss.end())-ss.begin();

      ls[ts[i]]=i;
      vs[ts[i]].set(i);
    }
    for(int j=1;j<=A;j++) vs[j].set(D+1);
  }

  auto calcScore=[&]()->int{
    int res=0;
    memset(ls,0,sizeof(ls));
    for(int i=1;i<=D;i++){
      res+=s[i][ts[i]];
      ls[ts[i]]=i;
      for(int j=1;j<=A;j++)
        res-=cs[j]*(i-ls[j]);
    }
    return res;
  };

  auto calcDiff=[&](int p)->int{
    int res=0;
    int cp=cs[p],lp=0;
    for(int i=vs[p]._Find_first();i<(int)vs[p].size();i=vs[p]._Find_next(i)){
      res-=cp*(i-lp)*(i-lp-1)/2;
      res+=r[p][i],lp=i;
    }
    return res;
  };

  int tmpScore=calcScore();

  double start_temp = 2000, end_temp = 200;

  const double LIM = 1.95;
  int iter_num = 0;
  while(timer.get()<LIM){
    iter_num++;
    {
      int d=xor128()%D+1;
      int q=xor128()%A+1;

      int p=ts[d];
      if(p==q) q=(q+1)%A+1;

      int nxtScore=tmpScore;
      nxtScore-=calcDiff(p)+calcDiff(q);
      vs[ts[d]].flip(d);
      ts[d]=q;
      vs[ts[d]].flip(d);
      nxtScore+=calcDiff(p)+calcDiff(q);
      // assert(nxtScore==calcScore());

      double temp = start_temp + (end_temp - start_temp) * timer.get() / LIM;
      double prob = std::exp((nxtScore-tmpScore)/temp);

      const int INF = 1<<30;
      if(prob > (xor128()%INF)/(double)INF){
        tmpScore=nxtScore;
      }else{
        vs[ts[d]].flip(d);
        ts[d]=p;
        vs[ts[d]].flip(d);
      }
    }
  }

  cerr<<iter_num<<endl;
  cerr<<tmpScore<<":"<<calcScore()<<endl;
  for(int i=1;i<=D;i++) cout<<ts[i]<<newl;
  return 0;
}


Measured memory_bytes: 4308
#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 k;
  cin >> k;
  int ans =0;
  for(int i=1;i <=k;i++){
   for(int j=1;j <=k;j++){
    for(int l=1;l <=k;l++){
     ans += gcd(i,gcd(j,l)); 
    }
   }
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

class Die {
public:
  Die(vector<int> numbers) {
    vertical_ = vector<int>(4);
    horizontal_ = vector<int>(4);
    vertical_[0] = numbers[0];
    vertical_[1] = numbers[4];
    vertical_[2] = numbers[5];
    vertical_[3] = numbers[1];
    horizontal_[0] = numbers[0];
    horizontal_[1] = numbers[2];
    horizontal_[2] = numbers[5];
    horizontal_[3] = numbers[3];
  }

  int get_top() const { return vertical_[0]; }
  int get_right() const { return horizontal_[1]; }
  int get_front() const { return vertical_[3]; }
  void rotate_north()
  {
    rotate(vertical_.rbegin(), vertical_.rbegin() + 1, vertical_.rend());
    update(vertical_, horizontal_);
  }
  void rotate_south()
  {
    rotate(vertical_.begin(), vertical_.begin() + 1, vertical_.end());
    update(vertical_, horizontal_);
  }
  void rotate_east()
  {
    rotate(horizontal_.rbegin(), horizontal_.rbegin() + 1, horizontal_.rend());
    update(horizontal_, vertical_);
  }
  void rotate_west()
  {
    rotate(horizontal_.begin(), horizontal_.begin() + 1, horizontal_.end());
    update(horizontal_, vertical_);
  }

  int find_right(int top, int front)
  {
    if (find(horizontal_.begin(), horizontal_.end(), front) != horizontal_.end()) {
      while (get_top() != front) {
        rotate_east();
      }
    }
    while (get_front() != front) {
      rotate_north();
    }

    while (get_top() != top) {
      rotate_east();
    }
    return get_right();
  }

private:
  int top_;
  vector<int> vertical_, horizontal_;

  void update(vector<int>& from, vector<int>& to)
  {
    to[0] = from[0]; to[2] = from[2];
  }

};

int main()
{
  vector<int> digits(6);
  for (int i = 0; i < 6; ++i) {
    fscanf(stdin, "%d", &digits[i]);
  }
  Die die(digits);
  int q;
  fscanf(stdin, "%d", &q);
  for (int i = 0; i < q; ++i) {
    int top, front;
    fscanf(stdin, "%d %d", &top, &front);
    int right = die.find_right(top, front);
    fprintf(stdout, "%d\n", right);
  }
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
const int N=3e6+5,mod=998244353;
typedef long long ll;
int n,m;
ll f[N],invf[N];
ll C(ll n,ll m){return f[n]*invf[n-m]%mod*invf[m]%mod;}
int main()
{
    f[0]=f[1]=invf[0]=invf[1]=1;
    for(int i=2;i<N;i++)
    {
        f[i]=f[i-1]*i%mod;
        invf[i]=(mod-mod/i)*invf[mod%i]%mod;
    }
    for(int i=2;i<N;i++) invf[i]=invf[i-1]*invf[i]%mod;
    scanf("%d%d",&n,&m);
    ll ans=0,res=0;
    for(int i=0;i<=min(n,m);i++)
        if((3*m-i)%2==0)
        ans=(ans+C(n,i)*C((3*m-i)/2+n-1,n-1)%mod)%mod;
    for(int i=0;i<=min(n,m);i++)
        if((m-i)%2==0)
        res=(res+C(n,i)*C((m-i)/2+n-1,n-1)%mod)%mod;
    ans=(ans-res*n%mod)%mod;
    ans=(ans+mod)%mod;
    for(int i=0;i<=min(n-1,m);i++)
        if((m-i)%2==0)
        ans=(ans+C(n-1,i)*C((m-i)/2+n-2,n-2)%mod*n)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 47104
class BIT:
    def __init__(self,N):
        self.N=N
        self.bit=[0]*(N+1)
        self.b=1<<N.bit_length()-1
    def add(self,a,w):
        x=a
        while(x<=self.N):
            self.bit[x]+=w
            x+=x&-x
    def get(self,a):
        ret,x=0,a-1
        while(x>0):
            ret+=self.bit[x]
            x-=x&-x
        return ret
    def cum(self,l,r):
        return self.get(r)-self.get(l) 
    def lowerbound(self,w):
        if w<=0:
            return 0
        x=0
        k=self.b
        while k>0:
            if x+k<=self.N and self.bit[x+k]<w:
                w-=self.bit[x+k]
                x+=k
            k//=2
        return x+1

N=int(input())
P=list(map(int,input().split()))
dic={}
bit=BIT(N)
for i in range(N):
    dic[P[i]]=i+1
dic[0]=0
dic[N+1]=N+1
ans=0
ng=[0,N+1]
for i in reversed(range(1,N+1)):
    bit.add(dic[i],1)
    c=bit.get(dic[i]+1)
    l1,l2=bit.lowerbound(c-1),bit.lowerbound(c-2)
    r1,r2=bit.lowerbound(c+1),bit.lowerbound(c+2)
    S=(l1-l2)*(r1-dic[i])+(r2-r1)*(dic[i]-l1)
    ans+=S*i
print(ans)

Measured memory_bytes: 99996
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,k,a;
    in>>n>>k;
    vector<int> s(n+1);
    unordered_map<int,int> mp;
    ll ans{};
    ++mp[0];
    fr(i,n){
        in>>a;
        s[i+1]=s[i]+a-1;
        s[i+1]%=k;
        if(i>=k-1) --mp[s[i-k+1]];
        ans+=mp[s[i+1]]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9288