akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    string str1;
    string str2;

    cin >> str1;
    cin >> str2;

    int str1_len = str1.size();
    int str2_len = str2.size();

    int result[str1_len + 1][str2_len + 1];

    for(int i = 0; i <= str1_len; i++) {
        for(int j = 0; j <= str2_len; j++) {
            if(i == 0 || j == 0) {
                result[i][j] = 0;
            } else if(str1[i - 1] == str2[j - 1]) {
                result[i][j] = 1 + result[i - 1][j - 1];
            } else {
                result[i][j] = max(result[i - 1][j], result[i][j - 1]);
            }
        }
    }

    int i = str1_len;
    int j = str2_len;
    int idx = result[str1_len][str2_len];

    char common[idx + 1];
    common[idx] = '\0';

    while(i > 0 && j > 0) {
        if(str1[i - 1] == str2[j - 1]) {
            --idx;
            common[idx] = str1[i - 1];
            --i;
            --j;
        } else if(result[i - 1][j] > result[i][j - 1]) {
            --i;
        } else {
            --j;
        }
    }

    cout << common << endl;

    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
    //mint(2).pow(n); 2^n
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


mint dp[2][100005];
std::vector<int> check(100005,-1);
vector<vector<ll>> v(100005);

int dfs(int t,int p){
//  cout<<"t"<<t<<endl;
  if (check[t]!=-1)return 0;
  check[t]=1;
  dp[0][t]=1;  dp[1][t]=1;
  for(int to:v[t]){
    if (to==p)continue;
    dfs(to,t);
    dp[0][t]*=dp[1][to];
    dp[1][t]*=(dp[1][to]+dp[0][to]);
  //  cout<<dp[0][t]<<" "<<dp[1][t]<<"t"<<t<<endl;
  }
  return 0;
}

int main(){
  ll n;
  cin>>n;
  rep(i,n-1){
    ll x1,y1;
    cin>>x1;
    cin>>y1;
    x1--;
    y1--;
    v[x1].push_back(y1);
    v[y1].push_back(x1);

  }
dfs(0,-1);
mint ans=0;
ans+=dp[0][0];
ans+=dp[1][0];
cout<<ans;


}


Measured memory_bytes: 19016
import sys
from itertools import zip_longest

s = input()
t = input()

tmp = list(s)
tmp.sort()
s_ = "".join(tmp)

tmp = list(t)
tmp.sort(reverse=True)
t_ = "".join(tmp)

st_ = [s_, t_]
st_.sort()

if s_ == t_:
    print("No")
elif st_[0] == s_:
    print("Yes")
else:
    print("No")

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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const int N = 1e5 + 5;

ll n, pref[N];
int x, m, a[N], visited[N];

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

    cin >> n >> x >> m;

    a[1] = pref[1] = x;
    visited[x] = 1;

    int cycle_start, cycle_end;
    for (int i = 2;; i++) {
        a[i] = (ll)a[i - 1] * a[i - 1] % m;
        if (visited[a[i]]) {
            cycle_start = visited[a[i]];
            cycle_end = i - 1;
            break;
        } else {
            visited[a[i]] = i;
            pref[i] = a[i] + pref[i - 1];
        }
    }

    if (n <= cycle_end) {
        cout << pref[n] << '\n';
    } else {
        ll ans = pref[cycle_end];
        n -= cycle_end;
        int cycle_length = cycle_end - cycle_start + 1;
        ans += (n / cycle_length) * (pref[cycle_end] - pref[cycle_start - 1]) + (pref[cycle_start - 1 + n % cycle_length] - pref[cycle_start - 1]);
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 4572
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    map<char,int>m;
    rep(i,s.size()){
        m[s[i]]++;
    }
    for(char c='a';c<='z';c++){
        if(m[c]%2)return no,0;
    }
    yes;
}


Measured memory_bytes: 256
l = [10]
s = 0
for i in range(5):
  t = input()
  if t[-1] =="0":s += int(t)
  else:
    s+=(int(t)//10)*10+10
    l.append(int(t[-1]))
if min(l) == 10:
  print(s)
else:
  print(s-10+min(l)) 


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    //FastIO;

    lli N , P;
    cin>>N>>P;

    if(N>40)cout<<1;
    else if(N == 1 || P == 1) cout<<P;
    else{
        lli ans = 1;
        for(lli i=2; (i*i) <= P; i++){

            lli pp = P;
            int j = N;
            for( ; j ; j--){
                if(pp%i) break;
                pp /= i;
            }
            if(j == 0) ans = i;
        }
        cout<<ans;
    }
    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;



int main(void) {
    char a;
    std::cin >> a;

    std::cout << ((a-'['<0)?'A':'a') << std::endl;

    return 0;
}

Measured memory_bytes: 3616
import collections
n=int(input())
a=[input() for i in range(n)]

c=collections.Counter(a)
m=c.most_common()
most=m[0][1]
ans=[]
ans.append(m[0][0])
for i in range(len(m)-1):
  if m[i+1][1]==most:
       ans.append(m[i+1][0])
  else:
       break
for out in sorted(ans):
       print(out)

Measured memory_bytes: 49200
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

ll MOD = 1000000007;

vector<int> get_divisors(int n) {
    vector<int> d;
    for (int i = 1; i * i <= n; ++i) {
        d.push_back(i);
        if (i != n / i) d.push_back(n / i);
    }
    return d;
}

int main() {
    int n, k; cin >> n >> k;
    
    vector<int> divs = get_divisors(n);
    sort(divs.begin(), divs.end());
    int d = divs.size();
    
    ll dp[d + 1][k + 1];
    for (int i = 0; i < d + 1; ++i) for (int j = 0; j < k + 1; ++j) dp[i][j] = 0;
    for (int i = 1; i < d; ++i) dp[i][1] = n / divs[i - 1] - n / divs[i];
    dp[d][1] = 1;
    
    for (int i = 2; i <= k; ++i) {
        int sum = 0;
        for (int j = 1; j <= d; ++j) {
            sum = (sum + dp[d + 1 - j][i - 1]) % MOD;
            dp[j][i] = (dp[j][1] * sum) % MOD;
        }
    }
    
    int answer = 0;
    for (int i = 1; i <= d; ++i) answer = (answer + dp[i][k]) % MOD;
    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 50556
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    std::vector<long long> numbers;
    int N, Q;
    cin >> N >> Q;
    long long m;
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &m);
        numbers.push_back(m);
    }

    long long queue;
    for (int i = 0; i < Q; i++)
    {
        scanf("%lld", &queue);
        long long answer = 0;
        long long start = 0;
        long long end = 0;
        long long sum = numbers[end];
        while(start<N)
        {
            while(sum<=queue&&end+1<N)
            {
                end++;
                sum += numbers[end];
            }
            if(sum>queue)
            {
                sum -= numbers[end];
                end--;
            }
           

            answer += end - start + 1;
            sum -= numbers[start];
            start++;
            if(start>end)
            {
                end = start;
                sum = numbers[start];
            }
        }

        cout << answer << endl;
    }

    return 0;
}



Measured memory_bytes: 3872
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr int kInf = 1e9;
constexpr int kVmax = 51;

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

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N);
  cin >> A >> B;

  vector<vector<int>> dp(1 << N, vector<int>(kVmax, kInf));
  dp[0][0] = 0;

  for (int S = 0; S < (1 << N); ++S) {
    bitset<18> b(S);
    int size = b.count();

    vector<pair<int, int>> cands;  // first: original pos, second: now pos
    int now = size;
    for (int i = 0; i < N; ++i) {
      if (!b.test(i)) {
        cands.emplace_back(i, now);
        ++now;
      }
    }

    for (int last = 0; last < kVmax; ++last) {
      for (const auto& cand_pos : cands) {
        int idx = cand_pos.first;
        int now = cand_pos.second;
        int value = (abs(idx - size) % 2 == 0) ? A[idx] : B[idx];
        if (value >= last) {
          int nextS = S | (1 << idx);
          dp[nextS][value] = min(dp[nextS][value], dp[S][last] + abs(now - size));
        }
      }
    }
  }

  int vmin = kInf;
  for (int last = 0; last < kVmax; ++last) {
    vmin = min(vmin, dp[(1 << N) - 1][last]);
  }

  if (vmin == kInf) cout << -1 << endl;
  else              cout << vmin << endl;
}


Measured memory_bytes: 63744
import java.util.*;
import java.io.*;

public class Main {
	public void solve() throws IOException {
		int n = nextInt();
		int[] v = new int[n+1];
		for(int i = 0; i < n; i++){
			int a = nextInt();
			int x = nextInt();
			v[a] += x;
		}
		int ans = 1;
		for(int i = 1; i <= n; i++){
			if( v[i] > v[ans] ){
				ans = i;
			}
		}
		writer.println(ans + " " + v[ans]);
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() throws IOException {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
}

Measured memory_bytes: 17004
n = int(input())
lst1 = list(map(int,input().split()))
mod = 10**9+7

import fractions as math
#リスト l の最大公約数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]//math.gcd(a,l[i])
    return int(a)

g = lcmlist(lst1)
ans = 0
for i in range(n):
    ans += g//lst1[i]
print(ans%mod)


Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

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

bool bfs(vector<vector<int>> &g, vector<int> &cnt, int sv, int x){
	queue<int> q;
	q.push(sv);
	cnt[sv]+=x;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			cnt[v]+=x;
			q.push(v);
		}
	}
}

int main(void) {
	int n,q; cin >> n >> q;
	vvi g0(n);
	rep(i,n-1){
		int a,b; cin >> a >> b;
		--a; --b;
		g0[a].push_back(b);
		g0[b].push_back(a);
	}
	vi p(n,0);
	rep(i,q){
		int a,b; cin >> a >> b;
		--a;
		p[a]+=b;
	}
	
	vvi g(n);
	vector<bool> flg(n,false);
	queue<int> q0;
	q0.push(0);
	flg[0]=true;
	while(!q0.empty()){
		int now = q0.front(); q0.pop();
		for(auto v : g0[now]){
			if(flg[v]) continue;
			g[now].push_back(v);
			flg[v]=true;
			q0.push(v);
		}
	}	
	vi cnt(n,0);
	cnt[0] = p[0];
	queue<int> que;
	que.push(0);
	while(!que.empty()){
		int now = que.front(); que.pop();
		for(auto v : g[now]){
			cnt[v] = cnt[now] + p[v] ;
			que.push(v);
		}
	}
	rep(i,n) out(cnt[i]);
}




Measured memory_bytes: 25856
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int n;
vector<int> a(200200), G[200200];

vector<int> dp(200200, inf), ans(200200);
vector<bool> seen(200200, false);
int res = 0;
stack<pair<int, int>> s;

void dfs(int v = 0) {
  if (seen[v]) return;
  seen[v] = true;
  if (res == 0) {
    dp[res] = a[v];
    s.push({res, inf});
    res++;
  }
  else {
    if (dp[res - 1] < a[v]) {
      dp[res] = a[v];
      s.push({res, inf});
      res++;
    }
    else {
      int idx = lower_bound(dp.begin(), dp.end(), a[v]) - dp.begin();
      s.push({idx, dp[idx]});
      dp[idx] = a[v];
    }
  }
  ans[v] = res;

  for (int u: G[v]) {
    dfs(u);
  }

  pair<int, int> p = s.top();
  s.pop();
  dp[p.first] = p.second;
  if (p.second == inf) res--;
}

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

  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n - 1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  dfs();
  rep(i, n) cout << ans[i] << '\n';






  
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M;
  cin >> N >> M;
  if(N > M) swap(N, M);
  ll ans = 0;
  if(N == 1 && M == 1) {
    ans = 1;
  } else if(N == 1 && M >= 2) {
    ans = M - 2;
  } else {
    ans = (N - 2) * (M - 2);
  }
  cout << ans << endl;
  return 0;
}

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

#define zerol
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


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



const int MAXN = 2e5+5;
char s[MAXN];
int dp[MAXN][10];
int n;


int main(int argc, char const *argv[])
{
    scanf("%s", s);
    n = strlen(s);
    int ans = 0;
    pair<int, int> la = make_pair(0, 0);
    for (int i=1; i<n; ++i) {
    	if (s[i] == s[i-1] && la.first == la.second && la.first == i-1) {
    		// dbg(i, 1);
    		if (i+1<n) {
    			++i;
    			la = make_pair(i-1, i);
    			++ans;
    		}
    		
    	} else {
    		// dbg(i, 2);
    		la = make_pair(i, i);
    		++ans;
    	}
    	
    }
    printf("%d\n", ans+1);

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
int main()
{
	int l, k;
	std::vector<int>antena;
	for (int i = 0; i < 5; i++)
	{
		std::cin >> l;
		antena.push_back(l);
	}
	std::cin >> k;
	std::string result = "Yay!";
	for (unsigned int i = 0; i < antena.size(); i++)
	{
		for (unsigned int j = i; j < antena.size(); j++)
		{
			if (antena[j] - antena[i] > k)
			{
				result = ":(";
				break;
			}
		}
	}
	std::cout << result << "\n";
    return 0;
}



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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================


template <class T>
class SegmentTree {
    using Op = std::function<T(T, T)>;

private:
    const Op op;
    const T ID;
    std::vector<T> vec;
    int sz;

public:
    explicit SegmentTree(int _n, Op _op, T _identity) : op(_op), ID(_identity) {
        sz = 1;
        while (sz < _n) sz <<= 1;
        vec.resize(sz * 2, ID);
    }
    void set_value(int _idx, T _val) {
        vec[_idx + sz] = _val;
    }
    template <class RandomIt>
    void set_array(RandomIt _begin, RandomIt _end) {
        std::copy(_begin, _end, vec.begin() + sz);
    }
    void set_array(const std::vector<T>& _newvec) {
        set_array(_newvec.begin(), _newvec.end());
    }
    void build() noexcept {
        for (int i = sz - 1; i > 0; i--) {
            vec[i] = op(vec[i * 2], vec[i * 2 + 1]);
        }
    }
    void update(int _idx, T _val) noexcept {
        _idx += sz;
        vec[_idx] = _val;
        for (_idx >>= 1; _idx > 0; _idx >>= 1) {
            vec[_idx] = op(vec[_idx * 2], vec[_idx * 2 + 1]);
        }
    }
    T query(int _l, int _r) const noexcept {
        T l_val = ID, r_val = ID;
        _l += sz, _r += sz - 1;
        for (; _l <= _r; _l >>= 1, _r >>= 1) {
            if (_l & 1) l_val = op(l_val, vec[_l++]);
            if (!(_r & 1)) r_val = op(r_val, vec[_r--]);
        }
        return op(l_val, r_val);
    }
};

using bita = bitset<26>;

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

    ll N;
    cin >> N;
    string S;
    cin >> S;

    SegmentTree<bita> seg(N, [](bita a, bita b) { return a | b; }, 0);

    for (int i = 0; i < N; i++) {
        int d = S[i] - 'a';
        bita u;
        u[d] = true;
        seg.set_value(i, u);
    }

    seg.build();

    ll Q;
    cin >> Q;
    for (int q = 0; q < Q; q++) {
        ll a;
        cin >> a;
        if (a == 1) {
            ll b;
            char c;
            cin >> b >> c;
            --b;
            bita u;
            u[c - 'a'] = true;
            seg.update(b, u);
        }
        else {
            ll b, c;
            cin >> b >> c;
            --b;
            --c;
            bita u = seg.query(b, c + 1);
            ll ans = u.count();
            cout << ans << endl;
        }
    }

    return 0;
}


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

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}
int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    vector<int> nums(N);
    int a=0,b=0,j=0;
    for(int i=0;i<N;i++) {
        cin >> P.at(i);
    }
    for(int i=0;i<N;i++) {
        cin >> Q.at(i);
    }
    for(int i=0;i<N;i++) {
        nums.at(i) = i+1;
    }
    do{
        j++;
        if(nums == P) {
            a = j;
        }
        if(nums == Q) {
            b = j;
        }
    }while(next_permutation(nums.begin(), nums.end()));
    cout << abs(b-a) << endl;
}


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


// 辺を表す構造体 (行き先、容量、逆辺)
struct edge { int to, cap, rev; };
vector<edge> G[200]; // グラフの隣接リスト表現
bool used[200]; // DFSですでに調べたかのフラグ
// fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}
// 増加パスをDFSで探す
int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d; G[e.to][e.rev].cap += d; return d;
            }
        }
    }
    return 0;
}
// sからtへの最大流を求める
int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        memset(used, 0, sizeof(used)); int f = dfs(s, t, 10000000);
        if (f == 0) return flow;
        flow += f;
    }
}

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

    for (int i = 0; i < N; i++) {
        cin >> c[i] >> d[i];
    }

    for(int i = 0; i < N; i++){
        add_edge(0, i+1,1 );
        add_edge(N+i+1, 2*N+1,1);
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (a[i] < c[j] && b[i] < d[j]) {
                add_edge(i+1, N+j+1, 1);
            }
        }
    }

    cout << max_flow(0, 2*N+1) << endl;




}


Measured memory_bytes: 384
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
 
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");
 
T lread(T = long)()
{
    return readln.chomp.to!T();
}
 
T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}
 
void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

long disit_sum(long a)
{
    long sum,disit_num;
    foreach(disit;0 .. 9)
    {
        disit_num = a / pow(10, disit);
        sum += disit_num % 10;
    }
    return sum;
}


void main()
{
    long n,l;
    scan(n,l);
    string[] s = new string[n];
    foreach(ref e; s)
    {
        e = sread();
    }
    sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable)(s);
    foreach(e;s)
    {
        write(e);
    }
    writeln();
}

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

table = [[0]*3 for i in range(N)]

for i in range(N):
    a = list(map(int,input().split()))
    for j in range(3):
        table[i][j] = a[j]


dp = [[0]*3 for i in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + table[i][k])

ans = 0            
for j in range(3):
    ans = max(ans,dp[N][j])
    
print(ans)

Measured memory_bytes: 48692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int tmp = N;
  int sum = tmp%10;
  while (tmp >= 10){
    tmp/=10;
    sum+= tmp%10;
  }
  if (N%sum==0){
  cout << "Yes" << endl;}
  else{
    cout << "No" << endl;}
}

Measured memory_bytes: 3604
#include <iostream>
#include <map>
#include <string>
#include <vector>

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

  std::map<int, int> ac;
  std::map<int, int> wa;
  int cpn = 0;
  for (int i = 0; i < m; ++i) {
    int p;
    std::string s;
    std::cin >> p >> s;

    bool isac = s == "AC";

    if (!ac.count(p))
      ac.emplace(p, isac);
    else
      ac.at(p) += isac;

    if (!wa.count(p))
      wa.emplace(p, !isac);
    else
      wa.at(p) += !isac;

    if (isac)
      if (ac.at(p) == 1)
        cpn += wa.at(p);
  }

  int cac = 0;
  for (auto i : ac)
    cac += i.second > 0;

  std::cout << cac << " " << cpn << std::endl;
}


Measured memory_bytes: 9600
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
#define A first
#define B second
const int MAXN = 1<<10;

int main() {
    int N, K;
    cin >> N >> K;
    cout << (N / 2 + N % 2 < K ? "NO" : "YES") << endl; 
    return 0;
}

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

int N,K,R,S,P;
char T[100010];
int f[100001][4],ans;

int main(){
	scanf("%d%d%d%d%d",&N,&K,&R,&S,&P);
	scanf("%s",T+1);
	for(int k=1;k<=K;k++){
		int i;
		f[k][1]=T[k]=='s'?R:0;
		f[k][2]=T[k]=='p'?S:0;
		f[k][3]=T[k]=='r'?P:0;
		for(i=k+K;i<=N;i+=K){
			f[i][1]=max(f[i-K][2],f[i-K][3])+(T[i]=='s'?R:0);
			f[i][2]=max(f[i-K][1],f[i-K][3])+(T[i]=='p'?S:0);
			f[i][3]=max(f[i-K][1],f[i-K][2])+(T[i]=='r'?P:0);
		}
		// printf("%d\n",i);
		ans+=max(f[i-K][1],max(f[i-K][2],f[i-K][3]));
	}
	//for(int i=1;i<=N;i++) printf("%d ",f[i][1]);
	//puts("");
	//for(int i=1;i<=N;i++) printf("%d ",f[i][2]);
	//puts("");
	//for(int i=1;i<=N;i++) printf("%d ",f[i][3]);
	//puts("");
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1920
n = int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))

mn=10**9
ans=-1
for i in range(n):
        kion = t - (h[i] * 0.006)
        diff = abs(kion-a)
        if diff < mn:
                mn=diff
                ans=i
print(ans+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,sum=0;
    cin>>n>>m;
    int arr[m];
    for (i=0;i<m;i++)
        cin>>arr[i];
    for (i=0;i<m;i++)
        sum+=arr[i];
    if (sum>n)
        cout<<"-1"<<endl;
    else 
        cout<<n-sum<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

const ll inf = 1e18+7;
const ll mod = 1e9+7;

int main(){
	ll n,a=0,b=0,ans=inf;
	cin >> n;

	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			ans = min(ans,n/i+i-2);
		}
	}

	cout << ans << endl;
	return 0;

}

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

int main(){
    int n;
    double a,t;
    cin >> n >> t >> a;
    int mxi = 1;
    vector<double> arr(n+1);
    for(int i = 1; i <= n; ++i)cin >> arr[i];
    for(int i = 2; i <= n; ++i){
        if(abs(a-t+(0.006*arr[i])) < abs(a-t+(0.006*arr[mxi])))mxi = i; 
    }
    cout << mxi;
}

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

#define read(num1, num2, num3) scanf("%d %d %d", &num1, &num2, &num3)

int main()
{
    int a, b, c;
    while(read(a,b,c)!=EOF)
    {
        if(a+b+c == 17) cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}



Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        r: i64,
    }
    let r = r as f64;
    println!("{}", r * 2. * std::f64::consts::PI);
}


Measured memory_bytes: 2132
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main(){
  int n,m;
  int height[100005];
  vector<int>graph[100005];
  int flag[100005];
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>height[i];
    flag[i]=-1;
  }
  
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  
  for(int j=0;j<n;j++){
    if(flag[j]==-1){
      queue<int>que;
      que.push(j);
      flag[j]=true;
      while(!que.empty()){
	int pos=que.front();que.pop();
	for(int i=0;i<(int)graph[pos].size();i++){
	  int next=graph[pos][i];
	  if(flag[next]==-1){
	    que.push(next);
	    flag[next]=true;
	  }
	  if(height[next]>=height[pos]){
	    flag[pos]=false;
	  }
	}
      }
    }
  }
  
  int cnt=0;
  for(int i=0;i<n;i++){
    if(flag[i]){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 9604
#include <bits/stdc++.h>
using namespace std;
#define N 25
#define set(a,v) memset(a,v,sizeof(a))
const int X[4]={1,-1,0,0},Y[4]={0,0,1,-1}; 
int n,m,ans,dst[N][N];bool vs[N][N];char a[N][N];queue<int> qX,qY;
int max(int x,int y) {return x>y?x:y;}
void bfs(int sX,int sY)
{
	set(dst,0);set(vs,0);vs[sX][sY]=1;qX.push(sX);qY.push(sY);
	while(!qX.empty())
	{
		int x=qX.front(),y=qY.front();qX.pop();qY.pop(); 
		for(int i=0,gX,gY;i<4;++i)
		{
			gX=x+X[i];gY=y+Y[i];
			if(gX>0 && gX<=n && gY>0 && gY<=m && a[gX][gY]=='.' && !vs[gX][gY])
				vs[gX][gY]=1,dst[gX][gY]=dst[x][y]+1,qX.push(gX),qY.push(gY);
		}
	}for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) ans=max(ans,dst[i][j]);
}
int main()
{
	scanf("%d %d",&n,&m);for(int i=1;i<=n;++i) scanf("%s",a[i]+1);
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) if(a[i][j]=='.') bfs(i,j);
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 256
//JavaScript(Node.js) での解答例
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
	tmp = input[0].split(" ");
	var S = tmp[0];
	var ans = "abcdefghijklmnopqrstuvwxyz";
	while (S.length !== 0) {
		var regExp = new RegExp(S[0],"g");
		S = S.replace(regExp, "");
		ans = ans.replace(regExp, "");
	}
	if (ans.length === 0) {
		console.log("None");
	} else {
		console.log(ans[0]);
	}
	//出力
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W, K = map(int, readline().split())

    dp = [0] * W
    dp[0] = 1

    for _ in range(H):
        dp, dp_prev = [0] * W, dp
        for mask in range(1 << (W - 1)):
            ok = True
            for i in range(W - 2):
                if mask & (1 << i) and mask & (1 << (i + 1)):
                    ok = False
            if not ok:
                continue
            for i in range(W):
                if i > 0 and mask & (1 << (i - 1)):
                    dp[i - 1] = (dp[i - 1] + dp_prev[i]) % MOD
                elif i < W - 1 and mask & (1 << i):
                    dp[i + 1] = (dp[i + 1] + dp_prev[i]) % MOD
                else:
                    dp[i] = (dp[i] + dp_prev[i]) % MOD

    print(dp[K - 1])

    return


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;


int main() {
    int n; cin >> n;
    vector<ll> l(n, 0);
    rep(i, n) cin >> l[i];
    sort(all(l));

    ll ans = 0;
    rep(i, n) {
        for (int j=i+1;j<n;++j) {
            int k = lower_bound(all(l), l[i] + l[j]) - l.begin();
            ans += max(k - (j + 1), 0);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
    int n , m ;
    cin >> n >> m ;
    vector < int > cost(m);
    vector < int > a(m);
    for( int i = 0 ; i < m ; i++){
        cin >> cost[i] ;
        int x ;
        cin >> x ;
        a[i] = 0 ;
        for( int j = 0 ; j < x ; j++){
            int y ;
            cin >> y ;
            y--;
            a[i] += (1<<y);
        }
    }
    int mask = 1<<n ;
    int dp[mask] ;
    memset(dp , -1 , sizeof dp);
    dp[0] = 0 ;
    for( int i = 0 ; i < m ; i++){
        for( int bit = 0 ; bit < mask ; bit++){
            if(dp[bit]!=-1){
                dp[bit|a[i]] = (dp[bit|a[i]]==-1?dp[bit]+cost[i]:min(dp[bit|a[i]],dp[bit]+cost[i])) ;
            }
        }
    }
    cout << dp[mask-1];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
   //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


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

int main() {
    int N;
    cin >> N;
    vector <int> A(N);
    for (int i=0; i<N; i++) cin >> A.at(i);
    sort(A.begin(), A.end());
    int res = 0;
    for (int i=0; i<A.size()-1; i++) res += A.at(i+1)-A.at(i);
    cout << res << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	char s[10];
	int t[10];
	int i,max=0,cnt=0,len=0;
	scanf("%s",s);
	for(i=0;s[i]!='\0';i++){
		t[i]=s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T';
		len++;
	}
	for(i=0;i<len;i++){
		if(t[i]==1){
			cnt++;
		}
		else{
			max=max<cnt?cnt:max;
			cnt=0;
		}
	}
	printf("%d",max<cnt?cnt:max);
	return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P s){
  Q[tail]=s;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P s=Q[head];
  head=(head+1)%LEN;
  return s;

}


int main(){
  int elaps = 0, c;
  int i, q;
  P y;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;
  while(head!=tail){
    y=dequeue();
    if(q>y.t)c=y.t;
    else c=q;
    y.t=y.t-c;
    elaps=elaps+c;
    if(y.t>0)enqueue(y);
    else printf("%s %d\n",y.name,elaps);
  }
  

  
  return 0;
}



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

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String S=gs();
        int[] c = new int[26];
	    for (int i=0; i<S.length();i++) {
	    	int ind=S.charAt(i) -97;
	    	c[ind]++;
	    }
	    
	    for (int i=0; i<c.length;i++) {
	    	if (c[i]%2!=0) {
	    		System.out.print("No");
	    		return;
	    	}
	    }
   
        System.out.print("Yes");
//        if (a<=c&&c<=b) {
//        	System.out.print("Yes");
//        }else{
//        	System.out.print("No");
//        }

	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35652
#include <stdio.h>
#include <math.h>

double pow_i(double x, double k);

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

    int i;
    double ans = 0;


    for (i = 1; i <= n; i++) {
        ans += pow(2, -pow_i((double)i, (double)k)) / n;
    }

    printf("%.12lf", ans);

    return 0;
}

double pow_i(double x, double k)
{
    double i, y = x;

    if (x >= k) {
        return 0;
    } else {

        for (i = 1; i < k; i++) {
            y *= 2;

            if (y >= k)
                break;
            }

            return i;
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    map<int,bool> mp;
    reverse(h.begin(),h.end());
    for(int i = 0; i < n-1; i++){
        if(h[i+1] <= h[i]) continue;
        else if(h[i+1]-1 == h[i]){
            h[i+1]--;
            mp[i+1] = true;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 5980
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<set>
#include<string>
#include<climits>
using namespace std;

static int N;
static long long  K;
typedef pair<long long, long long> pp;
static vector<pp> ve;

bool cmp(pp p1, pp p2)
{
	return p1.first < p2.first;
}

int main()
{
	while (scanf("%d%lld", &N, &K) != EOF)
	{
		ve.clear();
		ve.resize(N);
		for (int i = 0; i < N; i++) scanf("%lld%lld", &ve[i].first, &ve[i].second);
		sort(ve.begin(), ve.end(), cmp);
		long long sum = 0;
		long long ans = 0;
		for (int i = 0; i < N; i++)
		{
			if (sum + ve[i].second >= K)
			{
				ans = ve[i].first;
				break;
			}
			sum += ve[i].second;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

std::string s;
int K;

void solve() {
    // a: 97, z: 122
    // a --25--> z
    size_t s_size = s.size();
    const int id_z = int('z');
    for (int i = 0; i < s_size; i++) {
        char c = s[i];
        if (c == 'a') {
            continue;
        }
        int diff = (id_z + 1) - int(c);
        if (diff <= K) {
            s[i] = 'a';
            K -= diff;
        }
    }
    if (K != 0) {
        int tmp = K;
        if (26 <= K) {
            tmp = K % 26;
        }
        s[s_size - 1] = char(int(s[s_size - 1]) + tmp);
    }
    std::cout << s << std::endl;
}

int main() {
    std::cin >> s;
    std::cin >> K;
    solve();
    return 0;
}

Measured memory_bytes: 640
from bisect import bisect_left

def solve(n, q, s, t, x, d):
    v = sorted(list(zip(s, t, x)), key=lambda _:_[2])
    res = [-1] * q
    jump = [-1] * q
    for s, t, x in v:
        l = bisect_left(d, s - x)
        r = bisect_left(d, t - x)
        while l < r:
            s = jump[l]
            if s == -1:
                res[l] = x
                jump[l] = r
                l += 1
            else:
                l = s
    return res

n, q = map(int, input().split())
s = [-1] * n
t = [-1] * n
x = [-1] * n
for i in range(n):
    s[i], t[i], x[i] = map(int, input().split())
d = [int(input()) for i in range(q)]

print(*solve(n, q, s, t, x , d), sep="\n")

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

// input
int N;
vector<int> A;


void input() {
    cin >> N;
    A = vector<int>(N);
    rep(i, N) cin >> A[i];
}


ll gcd(ll a, ll b) {
    while (b) {
        ll tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}


map<int, int> prime_factor(int n) {
    map<int, int> x;
    for (int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            x[i]++;
            n /= i;
        }
    }
    if(n != 1) x[n]++;
    return x;
}


bool pairwise_coprime() {
    set<int> s;
    rep(i, N) {
        map<int, int> m = prime_factor(A[i]);
        for (P p : m) {
            if (s.count(p.first)) return false;
            else s.insert(p.first);
        }
    }
    return true;
}


bool setwise_coprime() {
    ll x = A[0];
    rep(i, N) x = gcd(x, A[i]);
    if (x == 1) return true;
    else return false;
}


int main() {
    input();
    bool pc = pairwise_coprime();
    string ans;
    if (pc) {
        ans = "pairwise coprime";
        cout << ans << endl;
        return 0;
    }
    bool sc = setwise_coprime();
    if (sc) ans = "setwise coprime";
    else ans = "not coprime";
    cout << ans << endl;
}


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

int main() {
    int N;
    cin>>N;
    vector<int> vec(N);
    int a=1;
    for(int i=0;i<N;i++){
        cin>>vec.at(i);
    }
    for(int i=0;i<N+1;i++){
        a=vec.at(a-1);
        if(a==2){
            cout<<i+1<<endl;
            break;
        }
      	if(i==N){
			cout<<-1<<endl;
        }
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, l;
    int a[200] = {};
    int ans = 0;
    cin >> n >> l;

    for (int i = 1; i <= n; i++)
    {
        a[i] = l + i - 1;
    }
    sort(a, a + n + 1, [](int i, int j) -> bool { return abs(i) < abs(j); });
    for (int i = 2; i <= n; i++)
    {
        ans += a[i];
    }
    cout << ans << endl;
}


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

struct UnionFind {
  vector<int> par;
  UnionFind(int n = 0): par(n, -1) {}
  int root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool unite(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;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -par[root(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, uf.size(i));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll, ll>
#define ppi pair<int, pii>
#define vpi vector<pii>
#define vpl vector<pll>
#define mt make_tuple
#define eb emplace_back
using namespace std;

const ll N = 2e5 + 5, mod = 1e9 + 7;
const ll inf = 1e18;

struct cmp{
    bool operator() (pii a, pii b){
        if(a.F == b.F) return a.S < b.S;
        return a.F > b.F;
    }
};

ll power(ll x, ll p){
    ll r = 1ll;
    x = x % mod;
    while(p > 0){
        if(p & 1) r = (r * x) % mod;
        p = p >> 1;
        x = (x * x) % mod;
    }
    return r;
}
vector<int> v[N];
bool vis[N];
int ans;
void dfs(int s, int num){
    ans++;
    vis[s] = 1;
    for(int i : v[s]){
        if(!vis[i]){
            dfs(i, num + 1);
        }
    }
}
void solve(){
    int n, m;
    cin >> n >> m;
    mst(vis, 0);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    int mx = 0;
    for(int i = 1; i <= n; i++){
        ans = 0;
        if(!vis[i]){
            dfs(i, 1);
        }
        mx = max(mx, ans);
    }
    cout << mx << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("Input.txt", "r", stdin);
    #endif*/
    //freopen("running_on_fumes_chapter_1_input (1).txt", "r", stdin);
    //freopen("Output.txt", "w", stdout);
    int t = 1, p;
    //cin >> t;
    for(p = 1; p <= t; p++){
        //cout << "Case #" << p << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 24112
#include<stdio.h>
int P,Q,A,N;
int search(int p,int q,int n,int t){
    if(P*q==p*Q) return 1;
    if(P*q<p*Q) return 0;
    if(N==n) return 0;
    int ret=0;
    for(int i=t;q*i<=A;i++){
        ret+=search(p*i+q,q*i,n+1,i);
    }
    return ret;
}
int main(void){
    while(1){
        scanf("%d%d%d%d",&P,&Q,&A,&N);
        if(P==0) break;
        printf("%d\n",search(0,1,0,1));
    }
}



Measured memory_bytes: 2044
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <set>
using namespace std;


int main()
{
	string str;
	cin >> str;
	int N = str.length();
	int n = N, levels = 1;
	while ((n >>= 1) > 0)
		levels++;

	vector<vector<int>> next(N + 2, vector<int>(27, N+1));
	vector<vector<int>> lev(levels, vector<int>(N+2));

	for (int i = N - 1; i >= 0; --i)
	{
		char c = str[i] - 97;
		int prev = next[i][c] = i + 1;
		for (int j = c+1; j < 27 && prev < N; j++)
			prev = next[i][j] = next[prev][j - 1];

		if (prev < N)
			for (int j = 0; j < c; j++)
				next[i][j] = next[prev][j];

		lev[0][i] = next[i][26];
	}
	lev[0][N+1] = lev[0][N] = N + 1;

	for (int i = 1; i < levels; ++i)
		for (int j = 0; j<N+2; ++j)
			lev[i][j] = lev[i-1][lev[i-1][j]];

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++)
	{
		int l, r;
		cin >> l >> r;

		l--;
		int lvl = levels - 1;
		while (l < r)
		{
			while (lev[lvl][l] > r && lvl > 0)
				lvl--;
			l = lev[lvl][l];
		}

		if (l == r)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 114052