akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct edge{int to, id;};

const int MAX_V = 1e5;
vector<edge> es[MAX_V];
vector<bool> used(MAX_V, false);
vector<int> sum(MAX_V, 0);
int st[MAX_V];

int dfs(int now){
    int size = sum[now];
    used[now] = true;
    for(auto &e: es[now]){
        if(used[e.to]) continue;
        int s = dfs(e.to);
        size ^= s;
        if(s&1){
            if(st[e.id] == now) st[e.id] = e.to;
            else st[e.id] = now;
        }
    }
    return size;
}

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, M){
        int u, v; cin >> u >> v; u--, v--;
        es[u].eb((edge){v, i}), es[v].eb((edge){u, i});
        sum[u] ^= 1, st[i] = u;
    }
    if(M&1) {cout << -1 << endl; return 0;}
    dfs(0);
    rep(i, N){
        for(auto &e: es[i]){
            if(st[e.id] == i) cout << i+1 << ' ' << e.to+1 << endl;
        }
    }
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

int main(){
    string s;
  	ll ans = 0;
    cin >> s;
    char check = s[0];
    RAP(i, s.length()){
        if(s[i]!=check){
            ans++;
            check = s[i];
        }
    }
   
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int gcd(int n,int m){
    if(n==m)return n;
    if(n>m)return gcd(n-m,m);
    else return gcd(m-n,n);
}

int main(){
    int n,m;
    cin >> n >> m;
    cout << gcd(n,m) << endl;
  return 0;
}

Measured memory_bytes: 3072
N = int(input())
A = list(map(int, input().split()))
ans = min(A)
while True:
    for i in range(len(A)):
        if A[i] % ans != 0:
            A[i] %= ans
    if min(A) < ans:
        ans = min(A)
    else:
        break
print(ans)


Measured memory_bytes: 14252
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

class UnionFind{
private:
  vector<int> par, rank;
public:
  UnionFind(int n){
	par.assign(n, 0);
	rank.assign(n, 0);
	for(int i=0;i<n;++i)
	  par[i] = i;
  }

  //find root of x
  int find(int x){
	if(par[x] == x)
	  return x;
	return (par[x] = find(par[x]));
  }

  void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(rank[x] < rank[y])
	  par[x] = y;
	else{
	  par[y] = x;
	  if(rank[x] == rank[y])
		++rank[x];
	}
  }

  bool same(int x, int y){
	return find(x) == find(y);
  }

  bool same(VI& idx){
	if(SZ(idx) == 0) return true;
	for(int i:idx)
	  if(!same(idx[0],i))
		return false;
	return true;
  }
};


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

  int N;
  while(cin >> N, N){
	VI tab[31], sets;
	REP(i,N){
	  int m; cin >> m;
	  REP(j,m){
		int d; cin >> d;
		tab[d].PB(i);
	  }
	  sets.PB(i);
	}

	int i;
	for(i=1;i<31;++i){
	  UnionFind uf(N);
	  if(SZ(tab[i]) == 0) continue;
	  REP(j,SZ(tab[i]))
		uf.unite(tab[i][0], tab[i][j]);
	  for(int k=i-1;k>=0;--k){
		bool flag = false;
		REP(j,SZ(tab[k]))
		  if(uf.same(tab[k][j], tab[i][0])){
			flag = true;
			break;
		  }
		if(flag){
		  REP(j,SZ(tab[k]))
			uf.unite(tab[k][j], tab[i][0]);
		}
	  }
	  if(uf.same(sets))
		break;
	}
	if(i > 30) cout << -1 << endl;
	else cout << i << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1232
N, M, X, Y = gets.strip.split.map(&:to_i)
xs = gets.strip.split.map(&:to_i)
ys = gets.strip.split.map(&:to_i)

Z = ys.min

do_war = true
if xs.all? { |x| x < Z } &&
   ys.all? { |y| y >= Z } &&
   (X < Z && Z <= Y)
  do_war = false
end

puts do_war ? 'War' : 'No War'


Measured memory_bytes: 1788
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0

for index, brave in enumerate(b):
    ans += min(a[index] + a[index+1], brave)
    a[index+1] -= max(0, brave - a[index])
    if a[index+1] < 0:
        a[index+1] = 0

print(ans)


Measured memory_bytes: 18476
from fractions import gcd
N, M = map(int, input().split())
S = input()
T = input()
g = gcd(N, M)
lcm = N * M // g
for i in range(g):
  if S[i*N//g] != T[i*M//g]:
    print(-1)
    exit()
print(lcm)

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

using namespace std;
#define taskname ""
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 2e5 + 5;
string s;
int sum[maxn] , n;
vector<int> v[26];
vector<pair<int,int>> adj;
void update(int x , int val)
{
    for( ; x > 0 ; x &= x - 1)
        sum[x] += val;
}
int query(int x)
{
    int res = 0;
    for( ; x <= n ; x += x & -x)
        res += sum[x];
    return res;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen(taskname".INP", "r",stdin);
	//freopen(taskname".OUT", "w",stdout);
    cin >> s;
    n = s.size();
    s = " " + s;
    for(int i = 1 ; i <= n ; ++i)
        v[s[i] - 'a'].pb(i);
    int odd = 0;int posodd = 0;
    for(int i = 0 ; i < 26 ; ++i)
    {
        odd += v[i].size() % 2;
        int k = v[i].size();
        for(int j = 0 ;  j < k / 2 ; ++j)
        {
            adj.pb({v[i][j] , v[i].back()});
            v[i].pop_back();
        }
        if(k % 2 == 1)posodd = v[i].back();
    }
    if(odd > 1)return cout << -1 ,0;
    sort(adj.begin() , adj.end());
    for(int i = 1 ; i <= n ; ++i)if(posodd != i)update(i, 1);
    ll res = 0;
    for(pair<int,int> c : adj)
    {
        if(odd && ((c.first < posodd && c.second < posodd) || (c.second > posodd && c.first > posodd)))res++;
        res += query(c.second + 1);
        update(c.second , -1);
    }
    cout << res;
}


Measured memory_bytes: 3916
N = input()
cnt1 = 0
for x in N:
  if x == 'B':
    cnt1 += 1
N = N[::-1]
ans =  0
cnt2 = 0
for i in range(len(N)):
  if N[i] == 'B':
    ans += i - cnt2
    cnt2 += 1
print(ans)


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

int main(){
        string s;
        cin >> s;
        int k;
        cin>> k;
        int l = s.size();

        int i = l>k? k:l;
        int b = 1;
        set<string> cnddt;
        while(i--){
                for(int j=0; j<l-i+1; j++) cnddt.insert(s.substr(j, i+1));
        }
        vector<string> ss(cnddt.begin(), cnddt.end());
        cout << ss[k]<< endl;
        return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

bool check(int g, int n, int N, vector< vector<int> > &v){
  REP(i, N) if(i != n && v[g][i] == v[g][n]) return false;
  return true;
}

int main() {
  int N; cin >>N;
  vector<int> P(N, 0);
  vector< vector<int> > v(3, vector<int>(N));
  REP(j, N) REP(i, 3) cin >>v[i][j];
  REP(g, 3) REP(n, N) if(check(g, n, N, v)) P[n] += v[g][n];
  REP(i, N) cout <<P[i] <<endl;
  return 0;
}

Measured memory_bytes: 1220
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, L, T = list(map(int, sys.stdin.readline().split()))
X, W = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

X = np.array(X)
D = np.array(W)
D[D == 2] = -1

if all(D == 1):
    ans = (X + T) % L
    print('\n'.join(map(str, ans)))
    exit()
if all(D == -1):
    ans = (X - T) % L
    print('\n'.join(map(str, ans)))
    exit()

positions = (X + T * D) % L
positions.sort()

# T 秒間で何回ぶつかるか
x1 = X[D == 1][0]
ops = (X[D == -1] - x1) % L
ops.sort()
collision_count = np.searchsorted(ops, T * 2 % L) + T * 2 // L * len(ops)

# x1 がすり抜けたらいる場所
p = (x1 + T) % L
# そこに誰がいるか
w = ((D == 1).argmax() + collision_count) % N
ans = np.roll(positions, w - np.searchsorted(positions, p))
print('\n'.join(map(str, ans)))



Measured memory_bytes: 62244
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]
 
def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))
 
def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))
 
def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD
 
    return (num*(pow(den,MOD-2,MOD)))%MOD
 
def flush():
    return sys.stdout.flush()
 

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
x = int(input())

print('Yes' if x>=30 else 'No')

Measured memory_bytes: 147440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

struct UnionFind{
	vector<int> par;
	UnionFind(int n) : par(n,-1) { }
	void init(int n) { par.assign(n,-1); }
	int root(int x){
		if(par[x]<0) return x;
		else return par[x]=root(par[x]);
	}
	bool issame(int x,int y){
		return root(x)==root(y);
	}
	bool merge(int x,int y){
		x=root(x);
		y=root(y);
		if(x==y) return false;
		if(par[x]>par[y]) swap(x,y);
		par[x]+=par[y];
		par[y]=x;
		return true;
	}
	int size(int x){
		return -par[root(x)];
	}
};

int main(){
	int N,M; cin>>N>>M;
	vector<int> X(M),Y(M),Z(M);
	rep(i,M) cin>>X[i]>>Y[i]>>Z[i], X[i]--,Y[i]--;
	UnionFind uf(N);
	rep(i,M) uf.merge(X[i],Y[i]);
	set<int> se;
	rep(i,N) se.insert(uf.root(i));
	cout<<se.size()<<endl;
}

Measured memory_bytes: 6400
#include<stdio.h>
int main(){
	int a,b,c;
	int i,count;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0)count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
    ll n,y; cin >> n >> y;
    ll Y = y / 1000;
    
    int ans_a = -1;
    int ans_b = -1;
    int ans_c = -1;
    rep(i,n + 1){
        rep(j,n + 1){
            if(9 * i + 4 * j == Y - n && 0 <= n - i - j){
                ans_a = i;
                ans_b = j;
                ans_c = n - i - j;
                break;
            }
        }
    }
    cout << ans_a << " " << ans_b << " " << ans_c;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////


int main(){
    
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    rsort(t.begin(),t.end(),char);
   
    if(s < t)Yes;
    else No;
    
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=18;
const int M=N*N;
const int mod=1e9+7;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,m,E[N],f[1<<N],pw[M],sz[1<<N];
int main() {
    n=gi(),m=gi();
    for(int i=1,u,v;i<=m;i++) u=gi()-1,v=gi()-1,E[u]|=1<<v;
    f[0]=1;
    for(int i=1;i<(1<<n);i++) sz[i]=sz[i>>1]+(i&1);
    pw[0]=1;for(int i=1;i<=m;i++) pw[i]=2ll*pw[i-1]%mod;
    for(int s=1;s<(1<<n);s++)
        if((s&1)==(s>>1&1))
            for(int t=s;t;t=(t-1)&s)
                if((t&1)==(t>>1&1)) {
                    int cnt=f[s^t];
                    for(int i=0;i<n;i++)
                        if(s>>i&1) {
                            if(t>>i&1) cnt=1ll*cnt*pw[sz[E[i]&(s^t)]]%mod;
                            else cnt=1ll*cnt*(pw[sz[E[i]&t]]-1+mod)%mod;
                        }
                    f[s]=(f[s]+cnt)%mod;
                }
    printf("%d\n",(pw[m]-f[(1<<n)-1]+mod)%mod);
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] stones = new int[n];
        for(int i = 0; i < n; i++) {
            stones[i] = sc.nextInt();
        }
        boolean[] dp = new boolean[k + 1];
        for(int i = 1; i <= k; i++) {
            inner:
            for(int stone : stones) {
                if(stone <= i && !dp[i - stone]) {
                    dp[i] = true;
                    break inner;
                }
            }
        }
        System.out.println(dp[k] ? "First" : "Second");
    }
}


Measured memory_bytes: 22740
#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);

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n)cin >> a[i];

  int lb = 1;
  ll ans=0;

  rep(i,n){
    if(a[i]==lb) lb++;
    else if(a[i]>lb){
      ans += (a[i]-1)/lb;
      if(i==0) lb++;
    }    
  }
  cout << ans << endl;
  
  return 0;
    

}


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

int main(){
	int cnt=0,cnt2=0;
	string s;
	cin >> s;
	char ch=s[0];
	for(int i=1;i<s.size();i++){
		if(s[i]!=ch){
			cnt++;
			ch=s[i];
		}
	}
	ch=s[s.size()-1];
	for(int i=s.size()-2;i>=0;i--){
		if(s[i]!=ch){
			cnt2++;
			ch=s[i];
		}
	}
	
	cout << min(cnt,cnt2) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
#define int long long
using namespace std;
signed main() {
    string S;
    cin >> S;
    S.at(3) = '8';
    cout << S << endl;
}


Measured memory_bytes: 3612
n,a,b=map(int,input().split())
t=a-b

ans=[0]*2

d=[]
for i in range(n):
    h=int(input())
    d.append(h)
d.sort(reverse=True)
ans[1]=max(d)
while ans[1]-ans[0]!=1:
    x=z=(ans[1]+ans[0])//2
    y=x*b
    for i in range(n):
        p=d[i]-y
        if p<=0:
            break
        x-=(p+t-1)//t
        if x<0:
            break
    if x<0:
        ans[0]=z
    else:
        ans[1]=z
print(ans[1])

Measured memory_bytes: 55000
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define revsot(a) sort(a.begin(),a.end(),greater<>())
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define pb push_back
#define mp make_pair
#define AlphabetNUM 26
#define vint vector<int>
using namespace std;

template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T>T gcd( T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T>bool chmax(T& a,T b){if(a<b){a=b;return true;}else{return false;}}
template<typename T>bool chmin(T& a,T b){if(a>b){a=b;return false;}else{return true;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
template<typename T>void out(T data){cout<<data<<endl;}
lint MOD=pow(10,9)+7;
int inf=-1+pow(2,31);
int dirx[]={0,1,0,-1};
int diry[]={-1,0,1,0};

int main(){
	int n,weight;
	cin>>n>>weight;
	int v[n],w[n];
	rep(i,n){
		scanf("%d%d",v+i,w+i);
	}
	int dp[n+1][weight+1];
	memset(dp,0,sizeof(dp));
	rep(i,n){
		rep(j,weight+1){
			dp[i+1][j]=dp[i][j];
			if(j-w[i]>=0)chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
		}
	}
	out(dp[n][weight]);
	return 0;
}


Measured memory_bytes: 7108
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ARRAY_LEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
using namespace std;
typedef  unsigned long long ull;
typedef  long long ll;

int main(void){
  int x;
  int y;
  cin >> x >> y;
  vector<int> s = {1,3,5,7,8,10,12};
  vector<int> t = {4,6,9,11};

  bool sx,sy,tx,ty;
  sx = false;
  sy = false;
  tx = false;
  ty = false;
  REP(i,7){
    if(x == s[i]) sx = true;
    if(y == s[i]) sy = true;
    if(i <= 3){

      if(x == t[i]) tx = true;
      if(y == t[i]) ty = true;

    }

  }
  if( (sx && sy) || (tx && ty)) cout << "Yes" << endl;
  else cout << "No" << endl;


}

Measured memory_bytes: 768
N, K = map(int, input().split())

lst = [i for i in range(N+1)]
lst1 = lst[::-1]

ans = 0
mod = 10**9+7
tmp = sum(lst[:K-1])
tmp1 = sum(lst1[:K-1])

for i in range(K-1, N+1):
    tmp += lst[i]
    tmp1 += lst1[i]
    ans += (tmp1-tmp+1)
print(ans%mod)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll mod = 1000000007;


int main()
{
	string s;
	cin >> s;
	int n = s.size();
	bool res = true;
	string t = s;
	reverse(t.begin(), t.end());
	if(t != s)res = false;
	t = "";
	for(int i = 0; i < (n - 1) / 2; i++)t.push_back(s[i]);
	string k = t;
	reverse(k.begin(), k.end());
	if(k != t)res = false;
	t = "";
	for(int i = (n + 3) / 2 - 1; i < n; i++)t.push_back(s[i]);
	k = t;
	reverse(k.begin(), k.end());
	if(k != t)res = false;
	cout << (res ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > G;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Yes[2] = {"No", "Yes"};
string YES[2] = {"NO", "YES"};
string Psb[2] = {"Impossible", "Possible"};
string psb[2] = {"impossible", "possible"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n;
    vi a(n);
    forn(i, n) cin >> a[i];
    cout << accumulate(all(a), -n);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
//#define int __int128
//#define ll __int128
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}

void smain();

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

#ifdef RUS_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}
const int oo = 1e9;
const int N = 51;
int MOD = 1e9 + 7;



void smain() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int u = b - a + 1, v = b / d - (a - 1) / d, k = b / c - (a - 1) / c, r = c * d / __gcd(c, d);
    int y = b / r - (a - 1) / r;
    cout << u - v - k + y;


}

Measured memory_bytes: 256
main(){
putchar(getchar());
putchar(getchar());
putchar(getchar());
putchar(getchar());
putchar(getchar());
putchar(getchar()-12);
putchar(getchar());
putchar(getchar());
putchar(getchar());
putchar(getchar());
putchar(getchar());
putchar(getchar());
putchar(getchar());
putchar(getchar()-12);
putchar(getchar());
putchar(getchar());
putchar(getchar());
putchar(getchar());
putchar(getchar());
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    ll ans = 0;
    ll w_cnt = 0;
    rep(i,0,N){
        if(S[i] == 'W'){
            w_cnt++;
        }
    }
    vector<ll> mv;
    rep(i,0,w_cnt){
        if(S[i] == 'B'){
            mv.push_back(i);
        }
    }
    // print(mv.size());
    ll mv_num = w_cnt - mv.size();
    // print(mv_num);
    ll cnt = 0;
    ll idx = 0;
    rep(i,0,N){
        if(S[i] == 'W'){
            cnt++;
        }
        if(cnt > mv_num && S[i] == 'W'){
            // print(idx);
            ans += (i - mv[idx]);
            idx++;
        }
    }
    print(ans);

}


Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, c[200008], dp[200008], cnt[200008];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	rep(i, 1, n){
		cin >> c[i];
	}
	
	cnt[c[1]] = 1;
	memset(dp, 0, sizeof(dp));
	rep(i, 1, n){
		if(c[i] != c[i+1]){
			dp[i] += cnt[c[i]];
			dp[i] %= MOD;
			cnt[c[i+1]] += dp[i];
			cnt[c[i+1]] += MOD;
		}
	}
	
	print(dp[n])
	return 0;
}

Measured memory_bytes: 4992
n = int(input())
arr = sorted(list(map(int,input().split())))
arr1 = arr[::-1]
dp = [[0]*2 for i in range(n)]
dp1 = [[0]*2 for i in range(n)]

dp[0][0] = arr[0]
dp[0][1] = arr[1]
dp1[0][0] = arr1[0]
dp1[0][1] = arr1[1]

def gcd(a,b):
    x = max(a,b)
    y = min(a,b)
    if x%y:
        return gcd(y,x%y)
    else:
        return y
for i in range(n-1):
    dp[i+1][0] = gcd(dp[i][0],arr[i+1])
    dp[i+1][1] = max(dp[i][0],gcd(dp[i][1],arr[i+1]))
    dp1[i+1][0] = gcd(dp1[i][0],arr1[i+1])
    dp1[i+1][1] = max(dp1[i][0],gcd(dp1[i][1],arr1[i+1]))
print(max(dp[-1][0],dp[-1][1],dp1[-1][0],dp1[-1][1]))

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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int d, t, s;
	cin >> d >> t >> s;
	d <= t * s ? cout << "Yes\n" : cout << "No\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;
typedef long long ll;

int n, m;
int s[60],t[60];
bool glaph[60][60];
bool visit[60];

void dfs(int x){
    visit[x] = true;
    for (int i = 0; i < n; i++){
        if (glaph[x][i] && !visit[i]){
            dfs(i);
        }
    }
    return;
}

int main(void){

    cin >> n >> m;

    for (int i = 0; i < 60; i++){
        for (int j = 0; j < 60; j++){
            glaph[i][j] = false;
        }
    }

    for (int i = 0; i < m; i++){
        cin >> s[i] >> t[i];
        s[i]--; t[i]--;
        glaph[s[i]][t[i]] = true;
        glaph[t[i]][s[i]] = true;
    }

    int ans = 0;

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

        for (int j = 0; j < n; j++){
            visit[j] = false;
        }

        glaph[s[i]][t[i]] = false;
        glaph[t[i]][s[i]] = false;

        dfs(0);

        bool flag = false;
        for (int j = 0; j < n; j++){
            if (!visit[j]){
                flag = true;
                break;
            }
        }
        if (flag) ans++;

        glaph[s[i]][t[i]] = true;
        glaph[t[i]][s[i]] = true;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll N,K,ans,a;
	ans = 0;
	cin >> N >> K;
	for (int i = 0;i < N;i++){
		cin >> a;
		if(a >= K){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))

ad = []
for i in range(n):
    if i != (n-1):
        ad.append(a[i+1] - a[i])
    if i == (n-1):
        ad.append(k-a[n-1] + a[0])

ad_max = max(ad)
ad_max_ind = ad.index(ad_max)

if ad_max_ind == (n-1):
    ans = a[n-1] - a[0]
if ad_max_ind != (n-1):
    ans = k - a[ad_max_ind+1] + a[ad_max_ind]
    
print(ans)

Measured memory_bytes: 26444
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

def dijkstra(src):
    from heapq import heappush, heappop

    que = [(0, src)]
    dist = {}
    dist[src] = 0
    while que:
        cost, u = heappop(que)
        if u >= 5:
            x = u % 5
            v = (u-x) // 5
            if v not in dist or cost+c+d*x < dist[v]:
                dist[v] = cost+c+d*x
                heappush(que, (cost+c+d*x, v))
            if u % 5 != 0:
                x = 5 - u % 5
                v = (u+x) // 5
                if v not in dist or cost+c+d*x < dist[v]:
                    dist[v] = cost+c+d*x
                    heappush(que, (cost+c+d*x, v))
        if u >= 3:
            x = u % 3
            v = (u-x) // 3
            if v not in dist or cost+b+d*x < dist[v]:
                dist[v] = cost+b+d*x
                heappush(que, (cost+b+d*x, v))
            if u % 3 != 0:
                x = 3 - u % 3
                v = (u+x) // 3
                if v not in dist or cost+b+d*x < dist[v]:
                    dist[v] = cost+b+d*x
                    heappush(que, (cost+b+d*x, v))
        if u >= 2:
            x = u % 2
            v = (u-x) // 2
            if v not in dist or cost+a+d*x < dist[v]:
                dist[v] = cost+a+d*x
                heappush(que, (cost+a+d*x, v))
            if u % 2 != 0:
                x = 2 - u % 2
                v = (u+x) // 2
                if v not in dist or cost+a+d*x < dist[v]:
                    dist[v] = cost+a+d*x
                    heappush(que, (cost+a+d*x, v))
    return dist

for _ in range(INT()):
    N, a, b, c, d = MAP()

    res = dijkstra(N)
    ans = INF
    for u, cost in res.items():
        ans = min(ans, cost + abs(u) * d)
    print(ans)


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

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

#define DEBUG

int main()
{
	string s;
	cin >> s;

	int cnt;
	rep(i,s.size())
	{
		if(s[i] == 'o') cnt++;
	}

	int ans = 700 + 100*cnt;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
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 long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>a(n); rep(i, n)cin >> a[i];
	int f = 0;
	int g = 0;
	rep(i, n) {
		if (a[i] % 2)f++;
		else g++;
	}
	if (!(f % 2) && !((f / 2 + g) % 2))cout << "YES" << endl;
	else if (!(f % 2) && !(f % 2)) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main(void){
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  x4 = -(y2 - y1) + x1;
  y4 = x2 - x1 + y1;
  x3 = x4 + x2 - x1;
  y3 = y4 + y2 - y1;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(n)]

li = sorted(li,key = lambda x:x[0])
cnt = 0
for i in range(n):
  cnt += li[i][1]
  if k <= cnt:
    print(li[i][0])
    exit()

Measured memory_bytes: 29912
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,q;
  cin >> n >> q;
  map<LL,LL> ans;
  ans[-p] = -1;
  vector<tuple<LL,LL,LL>> xst;
  REP(i,n) {
    LL s,t,x;
    cin >> s >> t >> x;
    xst.emplace_back(x,s,t);
  }
  sort(xst.rbegin(),xst.rend());
  for(auto tu:xst) {
    LL s,t,x;
    tie(x,s,t) = tu;
    auto ite = ans.upper_bound(t-x);
    --ite;
    LL prev = ite->second;
    ans[s-x] = x;
    ans.erase(ans.upper_bound(s-x), ans.lower_bound(t-x));
    if(!ans.count(t-x)) ans[t-x] = prev;
  }
  REP(i,q) {
    LL d;
    cin >> d;
    auto ite = ans.upper_bound(d);
    --ite;
    cout << ite->second << endl;
  }
  return 0;
}


Measured memory_bytes: 31340
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n,k;
	rl2(n,k);
	ll r,s,p;
	rl3(r,s,p);
	string str,tmp;
	cin>>str;
	ll ans=0;
	tmp=str;
	fr(i,0,n)
	{
		if(i<k)
		{
			if(str[i]=='r')
			{
				ans+=p;
				tmp[i]='p';
			}
			else if(str[i]=='s')
			{
				ans+=r;
				tmp[i]='r';
			}
			else
			{
				ans+=s;
				tmp[i]='s';
			}
		}
		else
		{
			if(str[i]=='r')
			{
				if(tmp[i-k]!='p')
				{
				ans+=p;
				tmp[i]='p';
				}
				else
				{
					if(i+k<SZ(str))
					{
						if(str[i+k]=='p')
						{
							tmp[i]='r';
						}
						else
							tmp[i]='s';
					}
				}
			}
			else if(str[i]=='s')
			{
				if(tmp[i-k]!='r')
				{
					ans+=r;
					tmp[i]='r';
				}
				else
				{
					if(i+k<SZ(str))
					{
						if(str[i+k]=='r')
							tmp[i]='s';
						else
							tmp[i]='p';
					}
				}
			}
			else
			{
				if(tmp[i-k]!='s')
				{
					ans+=s;
					tmp[i]='s';
				}
				else
				{
					if(i+k<SZ(str))
					{
						if(str[i+k]=='s')
							tmp[i]='p';
						else
							tmp[i]='r';
					}
				}
			}
		}
	}
	wl(ans);
	NL;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 512
N, D, A = gets.split.map(&:to_i)
E = N.times.map { gets.split.map(&:to_i) }

E.sort_by! { |x, h| x }
ans = 0
current_damage = 0

dp = []

E.each do |x, h|
  if dp.empty?
    point = x + 2 * D
    cnt = Rational(h, A).ceil
    damage = A * cnt
    ans += cnt
    current_damage = damage

    dp << [point + 1, -damage]
  else
    while !dp.empty? && dp[0][0] <= x
      current_damage += dp[0][1]
      dp.shift
    end

    remain = h - current_damage

    if remain > 0
      cnt = Rational(remain, A).ceil
      ans += cnt
      ad = A * cnt
      np = x + 2 * D
      current_damage += ad
      dp << [np + 1, -ad]
    end
  end
end

puts ans


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
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; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B && A != C || B == C && B != A || C == A && C != B) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return (0);
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

const long mod = 1e9 + 7;

long powmod(long x, long n){
  long ret = 1;
  while(n > 0){
    if(n&1) ret *= x, ret %= mod, n -= 1;
    else x *= x, x %= mod, n >>= 1;
  }
  return ret;
}

vector<long> fact;
vector<long> revfact;

void setfact(int n){
  fact.resize(n+1); revfact.resize(n+1);
  fact[0] = 1;
  rep(i, n) fact[i+1] = fact[i] * (i+1) % mod;
  
  revfact[n] = powmod(fact[n], mod-2);
  for(int i=n-1; i>=0; i--) revfact[i] = revfact[i+1] * (i+1) % mod;
}

int main(){
    int n; cin >> n;
    int A[100010]; rep(i, n) cin >> A[i];
    setfact(n);
    long p[100010];
    rep(i, n+1) p[i] = (fact[n] * (powmod(i, mod-2))) % mod;
    long psum[100010];
    rep(i, 100010) psum[i] = 0;
    rep(i, n+1) psum[i+1] = (psum[i] + p[i]) % mod;
    long a[n]; rep(i, n) a[i] = 0;
    rep(i, n) a[i] = (psum[n-i+1] + psum[i+2] - psum[2] + mod) % mod;
    long ans = 0;
    rep(i, n) ans = (ans + a[i] * A[i] % mod) % mod;
    cout << ans << endl;
    /*rep(i, n) cout << a[i] << " ";
    cout << endl;
    rep(i, n+2) cout << psum[i] << " ";*/
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    for (int n = 0; n < N; n++) cin >> W[n];

    int S1 = 0, S2 = 0;
    int res = 1'000'000'000;
    for (int n = 0; n < N; n++) S2 += W[n];
    for (int n = 0; n < N - 1; n++) {
        S1 += W[n];
        S2 -= W[n];
        if (abs(S1 - S2) < res) res = abs(S1 - S2);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int u, n, t=0, N=0, i=0;
	while (scanf("%d,%d", &u, &n)>0) {
		t += u*n;
		N += n;
		i ++;
	}
	printf("%d\n%d\n", t, (N+i/2)/i);
	return 0;
}

Measured memory_bytes: 0
def main():
    N = int(input())
    # N,= [int(a) for a in input().split()]
    A = [int(a) for a in input().split()]

    AA = sorted(enumerate(A), key=lambda a: a[1])

    print(" ".join([str(i+1) for i, a in AA]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 24932
K,T = map(int,input().split())
A = list(map(int,input().split()))

mx = max(A)
if mx <= (K+1)//2:
    print(0)
    exit()

if K%2:
    print(2 *(mx - (K+1)//2))
else:
    print(2 * (mx - K//2) - 1)


Measured memory_bytes: 2940