akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int n = 0;
		char[] conv = new char[123];
		StringBuilder sb = new StringBuilder();

		while ((line = br.readLine()) != null) {
			if (n == 0) {
				if ((n = Integer.parseInt(line)) == 0)
					break;
			} else {
				if (line.contains(" ")) {
					conv[line.charAt(0)] = line.charAt(2);
				} else {
					if (conv[line.charAt(0)] != '\0')
						sb.append(conv[line.charAt(0)]);
					else
						sb.append(line);
				}
				n--;
				if (n == 0 && line.length() == 1) {
					System.out.println(sb.toString());
					conv = new char[123];
					sb = new StringBuilder();
				}
			}
		}
	}
}

Measured memory_bytes: 30028
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] h = new int[N];

        for(int i=0; i<N; ++i) {
            h[i] = sc.nextInt();
        }

        int r = jump(N, K, h);
        System.out.println(r);
    }

    public static int jump(int N, int K, int[] h) {
        int[] v = new int[N];

        K = Math.min(N-1, K);

        for(int j=1; j<N; ++j) {
            int t = Integer.MAX_VALUE;
            boolean bContinue = true;
            for(int d=1; d<=K && bContinue; ++d) {
                int i = j-d;
                if(i>=0){
                    t = Math.min(Math.abs(h[i]-h[j]) + v[i], t);
                }
                else {
                    bContinue = false;
                }
            }

            v[j] = t;
        }

        return v[N-1];
    }
}


Measured memory_bytes: 50216
import math

N=int(input())
ans=0
for i in range(1,N+1,1):
    for j in range(i,N+1,1):
        for k in range(j,N+1,1):
            list =[i,j,k]
            ff=len(set(list))
            a = math.gcd(i,j)
            b = math.gcd(a,k)
            if ff == 1:
                ans += b
            elif ff == 2:
                ans += 3*b
            else:
                ans += 6*b
print(ans)            

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

using namespace std;

int main(void){

    int n;
    float amount, total = 0;
    string currency;
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> amount >> currency;

        if(currency == "JPY"){
            total += amount;
        } else {
            total += amount*380000;
        }
    }

    cout << total;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int k;
string s, ans;

typedef string::const_iterator State;
int number(State&);
string factor(State&);
string expression(State&);

int number(State& begin){
	int res = 0;
	while(isdigit(*begin)){
		res *= 10;
		res += *begin - '0';
		begin++;
	}
	return res;
}

string factor(State &begin){
	begin++;
	string ret = expression(begin);
	begin++;
	return ret;
}

string expression(State& begin){
	string res;
	while(begin != s.end() or res.size() > k){
		if(isdigit(*begin)){
			int loop = number(begin);

			string tmp;
			if(*begin == '('){
				tmp = factor(begin);
			}else{
				tmp = *begin;
				begin++;
			}

			rep(i,loop){
				if(res.size() > k) break;
				res += tmp;
			}
		}else if(isupper(*begin)){
			res += *begin;
			begin++;
		}else{
			break;
		}
	}
	return res;
}

int main(){
	while(cin >> s >> k, s != "0"){
		State tmp = s.begin();
		string t = expression(tmp);
		if(t.size() - 1 < k) cout << 0 << endl;
		else cout << t[k] << endl;
	}
}



Measured memory_bytes: 8560
#include<stdio.h>
#include<stdlib.h>
struct crystal
{
	long long x;
	long long h;
	long long t;
}mon[200005];
int inc(const void *a, const void *b)
{
    struct crystal m = *(struct crystal *)a;
    struct crystal n = *(struct crystal *)b;
    if(m.x<n.x)return -1;
    else return 1;
}
int erfen(long long x,int n)
{
    int l=0,r=n,mid=(r+l)/2;
    while(l<r)
    {
        mid=(r+l)/2;
        if(mon[mid].x>x)r=mid;
        else l=mid;
        if(r==l+1)return l;
    }
    return -1;
}
int main()
{
    int n,a;
	long long d,sum=0,kill;
    scanf("%d%lld%d",&n,&d,&a);
    for(int i=0;i<n;i++)scanf("%lld%lld",&mon[i].x,&mon[i].h);
    qsort(mon,n,sizeof(struct crystal),inc);
    mon[0].t=mon[0].h;
    for(int i=1;i<n;i++)mon[i].t=mon[i].h-mon[i-1].h;
    int l,r;
    for(int i=0;i<n;i++)
    {
    	if(mon[i].t<=0)mon[i+1].t+=mon[i].t;
    	else
        {
            l=i;
            r=erfen(mon[i].x+2*d,n)+1;
            if(mon[l].t%a==0)kill=mon[l].t/a;
            else kill=mon[l].t/a+1;
            sum+=kill;
            mon[r].t+=kill*a;
            mon[l].t-=kill*a;
            mon[i+1].t+=mon[i].t;
        }
	}
    printf("%lld\n",sum);
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int N,C,X;
int D[30][39];
int t[3][30];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;cin>>N>>K;
    vector<int> a(N);
    REP(i,N) cin>>a[i];
    if(N<=K) cout<<1<<endl;
    else cout<<1+(N-K)/(K-1)+((N-K)%(K-1)!=0)<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>

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

    while (1) {
        scanf("%d %d %d", &m, &f, &r);

        if (m == -1 && f == -1 && r == -1) break;

        if (m == -1 || f == -1) printf("F\n");
        else if ((m + f) >= 80) printf("A\n");
        else if ((m + f) >= 65) printf("B\n");
        else if ((m + f) >= 50) printf("C\n");
        else if ((m + f) >= 30) {
            if (r >= 50) printf("C\n");
            else printf("D\n");
        }
        else printf("F\n");
    }

    return 0;
}


Measured memory_bytes: 2088
def f(n, k, a_s):
    md = 10 ** 9 + 7
    dp = [0] * (k + 1)
    dp[0] = 1
    for a in a_s[:-1]:
        ndp = [0] * (k + 1)
        ndp[0] = s = dp[0] % md
        for j in range(1, a + 1):
            ndp[j] = s = (s + dp[j]) % md
        for j in range(a + 1, k + 1):
            ndp[j] = s = (s + dp[j] - dp[j - a - 1]) % md
        dp = ndp
    return sum(dp[k - a_s[-1]:]) % md


n, k = map(int, input().split())
a_s = list(map(int, input().split()))
print(f(n, k, a_s))


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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >>n;
	vector<pii> ab(n), cd(n);
	rep(i,n) cin >>ab[i].first >>ab[i].second;
	rep(i,n) cin >>cd[i].first >>cd[i].second;
	
	sort(all(ab));
	sort(all(cd));
	
	int ans =0;
	for(auto x: cd){
		int mx = -1, svj=-1;
		rep(j, n){
			if(x.first < ab[j].first) break;
			if(x.second < ab[j].second) continue;
			if(mx < ab[j].second){
				mx = ab[j].second; svj =j;
			}
		}
		if(svj>=0){
			ans++;
			ab[svj].second = 999;
		}
	}
	cout << ans <<"\n";
	return 0;
	
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string res = "No";
    for(int i = 0;i < n / 2;i++){
        if(s[i] != s[n / 2 + i] || n % 2 != 0){
            break;
        }
        if(i + 1 == n / 2){
            res = "Yes";
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        d: u32,
        x: u32,
        a: [u32;n]
    }
    let sum = a.iter().fold(0, |acc, i| acc + ((d + i - 1) / i));
    println!("{}", sum + x);
}


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

int main(){
    ll n;cin >> n;
    int d = 3600;
    rep(a,d)rep(b,d){
        if(ll(4*a*b)-n*(a+b) > 0){
            //printf("%d %d \n",a,b);
            if(n*a*b%(ll(4*a*b)-n*(a+b)) == 0){
                printf("%d %d %lld \n",a,b,n*a*b/(ll(4*a*b)-n*(a+b)));
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3760
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a,b,c;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		if(a<b+c||((b+c)%2!=a%2)) {
			cout<<"No"<<endl;
			return 0;
		}
	} 
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i++)
#define re0(i, n) for (rint i = 0; i < (int) n; i++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template <class T> inline void read(T &x) {
	x = 0; char c = getchar(); int f = 0;
	for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
	for (; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = getchar());
	if (f) x = -x;
}

const int N = 3e5 + 233;
int n;
int t[N];
string s;
string str[N];

int main(void) {
	read(n);
	rep (i, n) {
		cin >> str[i] >> t[i];
	}
	cin >> s;
	int ans = 0;
	for (int i = n; i >= 1; i--) {
		if (str[i] == s)
			break;
		ans += t[i];
	}
	cout << ans << "\n";
}


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

int dp[3001][3001];

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

	string s, t;
	cin >> s >> t;
	for(int i=1; i<=s.size(); ++i) {
		for(int j=1; j<=t.size(); ++j) {
			if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
		}
	}
	//cout << dp[s.size()][t.size()];
	int i=s.size(), j=t.size();
	string ans;
	while(i and j) {
		if(s[i-1]==t[j-1]) {
			ans=s[i-1]+ans;
			--i;
			--j;
			continue;
		}
		if(dp[i-1][j]>dp[i][j-1])
			--i;
		else
			--j;
	}
	cout << ans;
}


Measured memory_bytes: 38868
/***********************************************************
*   Falling down is an accident, Staying down is a choice. *
************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) //Fast IO
#define PI acos(-1.0) //3.14159265358
#define EPS 1e-9 //epsilon, 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
const int inf=1e9+7; //10^9 +7
const int modc=998244353;
typedef long long int ll;typedef vector<int> vi;typedef vector<ll> vll;
typedef pair<int,int> ii;typedef map<int,int> mii;typedef complex<double> cd;
inline void rvi(vi &v, int n){int temp; rep(i,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll &v, int n){ll temp;rep(i,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi &a){rep(i,sz(a)){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll &a){rep(i,sz(a)){cout<<a[i]<<" ";}cout<<endl;}
inline vll prefixsum(vi &a){vll b;b.pb(a[0]);for(int i=1;i<sz(a);i++){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vi &a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];for(int i=sz(a)-2;i>=0;i--){b[i]=a[i]+b[i+1];}return b;}
inline vll prefixsum(vll &a){vll b;b.pb(a[0]);for(int i=1;i<sz(a);i++){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vll &a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];for(int i=sz(a)-2;i>=0;i--){b[i]=a[i]+b[i+1];}return b;}
void solve();int main(){ios;solve();return 0;}
/***************************************************************************************************************************/
typedef struct node
{
	int index;
	string name;
	int score;
}node;


bool cmp(node o,node t)
{
	if(o.name<t.name) return true;
	else if(o.name==t.name)
	{
		if(o.score>t.score) return true;
		else return false;
	}
	else return false;
}

void solve()
{
	int n;cin>>n;
	vector<node> ans;
	vector<string> li;
	for(int i=1;i<=n;i++)
	{
		string s;int p;
		cin>>s>>p;
		li.pb(s);
		ans.pb({i,s,p});
	}
	sort(ans.begin(),ans.end(),cmp);
	// cout<<endl<<endl;
	for(auto x:ans)
	{
		// cout<<x.name<<" "<<x.score;
		cout<<x.index<<endl;
	}
	// cout<<endl;
	// map<string,vector<int> > mp;
	// for(int i=0;i<n;i++)
	// {
	// 	mp[ans[i].name].pb(i+1);
	// }
	// for(int i=0;i<n;i++)
	// {
	// 	string tname=li[i];
	// 	for(auto x:mp[tname])
	// 	{
	// 		cout<<x<<" ";
	// 	}
	// 	cout<<endl;
	// }
}


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


int main(){
  int n,k;
  cin >> n >> k;
  int ans=1;
  for(int i=0;i<n;++i){
    ans=min(ans*2,ans+k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i, n, time;
    int flag = 0;
    scanf("%d", &n);

    int t[n], x[n], y[n];
    int mem=0, xma=0, yma=0;
    for(i=0; i<n; i++)
    {
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }

    mem = x[0] + y[0];
    if(mem > t[0])
    {
        flag = 1;
    }
    else
    {
        if((t[0] - mem) % 2 != 0)
        {
            flag = 1;
        }
    }
 
    for(i=1; i<n; i++)
    {
        time = t[i] - t[i-1];
        xma = x[i] - x[i-1];
        yma = y[i] - y[i-1];
        mem = abs(xma) + abs(yma);
        if(mem > t[i])
        {
            flag = 1;
        }
        else
        {
            if((time - mem) % 2 != 0)
            {
                flag = 1;
            }
        }
    }

    if(flag == 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;

}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){

int H,W,h,w;
cin >> H >> W >> h >> w;

int ans = 0;
ans = H * W;

ans = ans - (h * W) - (w * H) + (h * w);

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin>>a.at(i);
  sort(a.begin(),a.end());
  cout << a.at(n-1) - a.at(0) << endl;
}

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


int S( int n )
{
int i;
int iSum;

	i = n;
	iSum = 0;
	while( i > 0 )
	{
		iSum += i % 10;
		i /= 10;
	}

	return iSum;
}

int main()
{
int n;
int iSum;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> n;

	iSum = S( n );
	if( n % iSum == 0 )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1000000000000
#define fr first
#define sc second
using vl =vector<ll>;
using vvl =vector<vl>;
const ll md = 1000000007;
vl fac(2,1), ifac(2,1);

ll ad(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod) % mod;
}

ll ml(ll a, ll b, ll mod = md) {
    return ( (a%mod) * (b%mod) ) % mod;
}

ll pw(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = (n >> 1);
        x = (x*x)%mod;
    }
    return res;
}

void cachefact(ll lim, ll mod = md) {
    for(int i = 2; i <= lim; i++) {
        ifac.push_back((ifac[mod%i] * (mod - mod/i) % mod)%mod);
    }
    for(ll i = 2; i <= lim; i++) {
        fac.push_back((fac[i-1] * i)%mod);
        ifac[i] = (ifac[i-1] * ifac[i])%mod;
    }
}

ll C(ll n, ll r, ll mod = md) {
    if(n < r) return 0;
    return ml(fac[n], ml(ifac[r], ifac[n-r], mod), mod);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cachefact(1e4);
    ll s;
    cin >> s;
    ll ans = 0;
    for(int i = 1; i <= s/3; ++i) {
    	// a1 + a2 + a3 + ... ai = s-i*3
    	ans += C(s-2*i-1, i-1);
    	ans %= md;
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)2e5 + 9;
const int MOD = (int)1e9 + 9;
const int P = 8873;

int a[N], b[N];
int c[N], d[N];
int pwr[N];

int mult(int a, int b){
  return (a * 1ll * b) % MOD;
}

void add(int &a, int b){
  a += b;
  if(a >= MOD) a -= MOD;
}

int suf[N];
int pref[N];

int main(){
  fastIO;
  pwr[0] = 1;
  for(int i = 1; i < N ; i ++ ) pwr[i]=mult(pwr[i-1], P);
  int n;
  cin >> n;
  for(int i = 0 ; i < n; i ++ ){
    cin >> a[i];
  }
  for(int i = 0 ; i < n; i ++ ){
    cin >> b[i];
  }
  for(int i = 0 ; i < n; i ++ ){
    c[i] = (a[i] ^ a[(i+1)%n]);
    d[i] = (b[i] ^ b[(i+1)%n]);
  }
  for(int i = n-1; i >= 0 ; i -- ){
    add(suf[i], mult(suf[i + 1], P));
    add(suf[i], c[i]);
  }
  for(int i = 0 ; i < n; i ++ ){
    if(i) add(pref[i], pref[i-1]);
    add(pref[i], mult(pwr[i], c[i]));
  }
  int bb = 0;
  for(int i = 0 ; i < n; i ++ ){
    add(bb, mult(d[i], pwr[i]));
  }
  vector<pii> ans;
  int sum;
  for(int k = 0 ; k < n; k ++ ){
    sum = suf[k];
    if(k > 0){
      add(sum, mult(pref[k-1], pwr[n-k]));
    }
    if(sum == bb){
      ans.push_back(mp(k, (a[k]^b[0])));
    }
  }
  for(auto x : ans)
    cout << x.fi << " " << x.se << "\n";
  return 0;
}

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

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

	string s; cin>>s;
	set<char> houkou;
	for(int i=0; i<s.size(); i++){
		houkou.insert(s[i]);
	}

	if(houkou.size()==4){
		cout << "Yes" << endl;
	}
	if(houkou.size()==3){
		cout << "No" << endl;
	}
	if(houkou.size()==2){
		if(houkou.count('N') && houkou.count('S')){
			cout << "Yes" << endl;
		}else if(houkou.count('W') && houkou.count('E')){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	if(houkou.size()==1){
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
const int mod = 1e9 + 7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main() {
    string s; cin >> s;
    ll ans = 0;
    ll ca = 0;
    rep(i, s.size()) {
        if (s[i] == 'A') {
            while (s[i] == 'A') {
                ca++;
                i++;
                if (i == s.size()) break;
            }
            ll c = 0;
            while (i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C') {
                c++;
                i += 2;
                if (i == s.size()) break;
            }
            i--;
            ans += ca * c;
        } else {
            ca = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }






int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    std::vector<int> v(n);
    //std::map<int, int> mp;
    ll int x = 0;
    REP(i,n){
         cin>>v[i];
         x ^= v[i];
     }
     for (int i = 0; i < n; ++i)
     {
        cout<<(x ^ v[i])<<" ";
     }
     return 0;
 }


Measured memory_bytes: 3932
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

bool park[10][10];
bool next[10][10];
int x,y;

int xxx[]={-1,0,1,2,2,2,1,0,-1,-2,-2,-2},yyy[]={-2,-2,-2,-1,0,1,2,2,2,1,0,-1};

void f(int a,int b){
	int i;
	for(i=0;i<12;i++){
		if(a+xxx[i]<0)continue;
		if(10<=a+xxx[i])continue;
		if(b+yyy[i]<0)continue;
		if(10<=b+yyy[i])continue;
		if(a+xxx[i]<x-1)continue;
		if(x+1<a+xxx[i])continue;
		if(b+yyy[i]<y-1)continue;
		if(y+1<b+yyy[i])continue;
		next[b+yyy[i]][a+xxx[i]]=true;
	}
	return;
}

int main() {
	int xx,yy,n;
	while(cin>>xx>>yy,xx!=0||yy!=0){
		cin>>n;
		int i;
		for(y=0;y<10;y++){
			for(x=0;x<10;x++){
				park[y][x]=false;
			}
		}
		park[yy][xx]=true;
		for(i=0;i<n;i++){
			for(y=0;y<10;y++){
				for(x=0;x<10;x++){
					next[y][x]=false;
				}
			}
			cin>>x>>y;
			int a,b;
			for(b=0;b<10;b++){
				for(a=0;a<10;a++){
					if(park[b][a]){
						f(a,b);
					}
				}
			}
			for(y=0;y<10;y++){
				for(x=0;x<10;x++){
					park[y][x]=next[y][x];
				}
			}
		}
		bool ok=false;
		for(y=0;y<10;y++){
			for(x=0;x<10;x++){
				if(park[y][x]){
					ok=true;
				}
			}
		}
		cout<<(ok?"OK":"NA")<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a.at(i);
    }
    ll a1=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            a1 += a.at(i);
        }else {
            a1 -= a.at(i);
        }
    }
    cout << a1;
    ll cur = a1;
    rep(i,n-1){
        cur = a.at(i)*2-cur;
        cout << " " << cur;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

template<class T> class bit {
public:
    vector<T> dat;
    int N;

    bit(){}
    bit(int N) : N(N) { dat.assign(N,0); }
    // sum [0,i)
    T sum(int i){
        int ret = 0;
        for(--i; i>=0; i=(i&(i+1))-1) ret += dat[i];
        return ret;
    }
    // sum [i,j)
    T sum(int i, int j) { return sum(j) - sum(i); }
    // add x to i
    void add(int i, T x) { for(; i < N; i|=i+1) dat[i] += x; }
};


int main() {
      //std::ifstream in("02-small-00");
  //std::cin.rdbuf(in.rdbuf());

    ll N, Q;
    string S;
    cin >> N;
    cin >> S;
    cin >> Q;

    vector<bit<int>> b(27);
    REP(i, 27){
        bit<int> hoge = bit<int>(N);
        b[i] = hoge;
    }
    REP(i, N) b[S[i] - 'a'].add(i, 1);

    vector<int> ans;
    ll mode, l, r;
    char c;
    REP(i, Q){
        cin >> mode;
        if (mode == 1) {
            cin >> l >> c;
            char t = S[l-1];
            b[t - 'a'].add(l-1, -1);
            b[c - 'a'].add(l-1, 1);
            S[l - 1] = c;
            }

        else {
            cin >> l >> r;
            int tmp = 0;
            REP(i, 27) {
                if (b[i].sum(l - 1, r) > 0) 
                {
                    tmp++;
                    //cout << char('a' + i)  << " "<< b[i].sum(l - 2, r) << endl;
                    }
            }
            ans.push_back(tmp);
        }
    }

    REP(i, ans.size()) cout << ans[i] << endl;
    return 0;
}



Measured memory_bytes: 55520
#include <iostream>

using namespace std;

int main()
{
	int x, y;
	char c;

	

	while (true) {
		cin >> x;
		cin >> c;
		cin >> y;

		if (c == '+')
		{
			cout << x + y << endl;
		}
		else if (c == '-')
		{
			cout << x - y << endl;
		}
		else if (c == '*')
		{
			cout << x * y << endl;
		}
		else if (c == '/')
		{
			cout << x / y << endl;
		}
		else if (c == '?')
		{
			break;
		}
		
	}
}


Measured memory_bytes: 3100
def main():
    H, W = map(int, input().split())
    a = [input() for _ in range(H)]

    # ans = f(H, W, a)
    # ans = T(H, W, a)
    ans = editorial(H, W, a)
    for x in ans:
        print(*x, sep="")


def editorial(H, W, a):
    # 出力する部分の記憶
    row = [False] * H
    col = [False] * W

    for i in range(H):
        for j in range(W):
            if a[i][j] == "#":
                row[i] = True
                col[j] = True

    ans = []
    for i in range(H):
        if not row[i]:
            continue

        line = []
        for j in range(W):
            if col[j]:
                line.append(a[i][j])
        ans.append(line)

    if not ans:
        return [[]]

    return ans


def T(H, W, a):
    """
    転置
    本番ではバグらせるのを恐れて愚直に実装した
    """
    b = []
    c = []
    for line in a:
        if len(line) != line.count("."):
            b.append(line)

    for line in zip(*b):
        if len(line) != line.count("."):
            c.append(line)

    if not c:
        return [[]]

    return list(zip(*c))


def f(H, W, a):
    b = []
    for line in a:
        if len(line) != line.count("."):
            b.append(line)

    if not b:
        return [[]]

    idxes = []
    for x in range(len(a[0])):
        y = sum(1 for i in range(len(b)) if b[i][x] == ".")
        if y != len(b):
            idxes.append(x)

    if not idxes:
        return [[]]

    ans = []
    for i in range(len(b)):
        line = []
        for j in range(len(a[0])):
            if j in idxes:
                line.append(b[i][j])
        ans.append(line)

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 4724
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int arr[MAXN];
int main(){
    //~ freopen("file.in", "r", stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	
		scanf("%d",arr+i);
	pair<ll,ll> ans=mp(2,2);
	for(int i=n;i>=1;i--){
		ans.ff=(ans.ff+arr[i]-1)/arr[i];
		ans.ff=ans.ff*1LL*arr[i];
		ans.ss=(ans.ss)/arr[i]+1;
		ans.ss=ans.ss*1LL*arr[i]-1;
		if(ans.ff>ans.ss)
			return puts("-1")*0;
	}
	printf("%lld %lld\n",ans.ff,ans.ss);
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX/2+2],R[MAX/2+2];

llong merge(int A[],int n,int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	llong count=0;
	for(int i=0;i<n1;i++)
	{
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++)
	{
		R[i]=A[mid+i];
	}

	L[n1]=R[n2]=SENTINEL;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++)
	{
		if(L[i]<=R[j])
		{
			A[k]=L[i++];
		}
		else
		{
			A[k]=R[j++];
			count+=n1-i;
		}
	}
	return count;
}

llong mergesort(int A[],int n,int left,int right)
{
	llong v1,v2,v3;
	if(left+1<right)
	{
		int mid =(left+right)/2;
		v1=mergesort(A,n,left,mid);
		v2=mergesort(A,n,mid,right);
		v3=merge(A,n,left,mid,right);
		return v1+v2+v3;
	}
	else return 0;
}

int main(void)
{
	int A[MAX],n,i;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	llong ans =mergesort(A,n,0,n);
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 3360
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;
int n;
long double ans = 0;

int perm[10];
void dfs(int pos, vector<bool> & used, vector<int> & x, vector<int> & y){
  if(pos == n){
    rep(i, 0, n-1){
      ans += sqrt(pow(x[perm[i]] - x[perm[i+1]], 2) + pow(y[perm[i]] - y[perm[i+1]], 2));
    }
  }
  for(int i=0; i<n; i++){
    if(!used[i]){
      perm[pos] = i; 
      used[i] = true;
      dfs(pos + 1, used, x, y);
      used[i] = false;
    }
  }
}
int main(){
  cin >> n;
  vector<int> x(n), y(n);
  vector<bool> used(n, false);
  rep(i, 0, n){
    cin >> x[i] >> y[i];
  }
  dfs(0, used, x, y);
  int b = 1;
  rep(i, 1, n+1){
    b *= i;
  }
  double res = ans / b;
  printf("%.10f\n", res);
  // cout << ans / b << endl;
}
     


Measured memory_bytes: 256
def f(x):
	return x * (x-1) // 2

n = int(input())
a = list(map(int, input().split()))
b = [0] * n
c = [0] * n
d = [0] * n
e = [0] * n
s = 0
for aa in a:
	b[aa-1] += 1
for i in range(n):
	c[i] = f(b[i])
	d[i] = f(b[i] - 1)
	s += c[i]
for i in range(n):
	e[i] = s - c[i] + d[i]
# print(b,c,d,e)
for i in range(n):
	print(e[a[i]-1])


Measured memory_bytes: 87244
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left,bisect_right
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**18+3
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,A,B=map(int,input().split())
    v=list(map(int,input().split()))
    v.sort()
    ans=0
    for i in range(A,B+1):
        ans=max(ans,sum(v[-i:])/i)
    def COMinit(n,MOD):
        fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1)
        fac[0]=fac[1]=1
        finv[0]=finv[1]=1
        inv[1]=1
        for i in range(2,(n+1)):
            fac[i]=fac[i-1]*i%MOD
            inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
            finv[i]=finv[i-1]*inv[i]%MOD
        return fac,finv,inv
    
    fac,finv,inv=COMinit(N,MOD)
    
    def COM(n, k, MOD=MOD):
        if n<k or n<0 or k<0:
            return 0
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
    ans2=0
    for i in range(A,B+1):
        if sum(v[-i:])/i==ans:
            x=v[-i]
            n=bisect_right(v,x)-bisect_left(v,x)
            m=bisect_right(v,x)-(N-i)
            ans2+=COM(n,m)
    print(ans)
    print(ans2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
    FLASH;
    int h,w;
    cin>>h>>w;
    if(h==1 or w==1)
    {
        cout<<1<<endl;
    }
    else
    {
      int ans=h*w;
      if(ans%2==0)
        {
            cout<<(h*w)/2<<endl;
        }
       else
       {
        cout<<((h*w)+1)/2<<endl;
       }
    }
    
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int N,M;
int par[200010];
int rk[200010];
void init(int n){
  for(int i=1;i<=n;i++){
    par[i] = i;
    rk[i] = 1;
  }
}
int find(int x){
  if(par[x]==x) return x;
  return par[x] = find(par[x]);
}
void unite(int x,int y){
  int nx = find(x);
  int ny = find(y);
  if(nx==ny) return;
  par[nx] = ny;
  rk[ny] += rk[nx];
  rk[nx] = rk[ny];
}
int main(){
  cin >> N >> M;
  init(N);
  for(int i=0;i<M;i++){
    int x,y;
    cin >> x >> y;
    unite(x,y);
  }
  int ans = 0;
  for(int i=1;i<=N;i++){
    int num = par[i];
    ans = max(ans,rk[num]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 5196
#include <cstdio>
#include <cstdint>
#include <vector>
#include <string>

int main() {
  char buf[32];
  scanf("%s", buf);
  std::string s = buf;

  int res = 0;
  for (size_t i = 0; i < s.length(); ++i)
    res += s[i]-'0';

  --s[0];
  for (size_t i = 1; i < s.length(); ++i) s[i] = '9';
  int cur = 0;
  for (size_t i = 0; i < s.length(); ++i)
    cur += s[i]-'0';

  res = std::max(res, cur);
  printf("%d\n", res);
}


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

using namespace std;

int main() {
	string a;

	for (int i = 0; i < 1000; i++) {
		cin >> a;
		bool hantei = true;
		for (int j = 0; j < a.size()-1; j++) {
			if (a[j] == 'A') {
				if (a[j+1] == 'B' || a[j+1] == 'D') {
				} else {
					hantei = false;
					break;
				}
			} else if (a[j] == 'B') {
				if (a[j+1] == 'A' || a[j+1] == 'C' || a[j+1] == 'E') {
				} else {
					hantei = false;
					break;
				}
			} else if (a[j] == 'C') {
				if (a[j+1] == 'B' || a[j+1] == 'F') {
				} else {
					hantei = false;
					break;
				}
			} else if (a[j] == 'D') {
				if (a[j+1] == 'A' || a[j+1] == 'E' || a[j+1] == 'G') {
				} else {
					hantei = false;
					break;
				}
			} else if (a[j] == 'E') {
				if (a[j+1] == 'B' || a[j+1] == 'D' || a[j+1] == 'F' || a[j+1] == 'H') {
				} else {
					hantei = false;
					break;
				}
			} else if (a[j] == 'F') {
				if (a[j+1] == 'C' || a[j+1] == 'E' || a[j+1] == 'I') {
				} else {
					hantei = false;
					break;
				}
			} else if (a[j] == 'G') {
				if (a[j+1] == 'D' || a[j+1] == 'H') {
				} else {
					hantei = false;
					break;
				}
			} else if (a[j] == 'H') {
				if (a[j+1] == 'E' || a[j+1] == 'G' || a[j+1] == 'I') {
				} else {
					hantei = false;
					break;
				}
			} else if (a[j] == 'I') {
				if (a[j+1] == 'F' || a[j+1] == 'H') {
				} else {
					hantei = false;
					break;
				}
			}
		}
		if (hantei) {
			cout << a << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1176
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<utility>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define inf 0x7f7f7f
#define p(x) (x)*(x)
#define PI 3.14159265358979
using namespace std;

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

int main()
{
	//ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	t.erase(--t.end());
	if(s == t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
    return 0;
}















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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod 		1000000007
#define inf 		1e18
#define IOS 		ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

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

	int ans = max({a * c, a * d, b * c, b * d});
	if (a <= 0 && b >= 0 || c <= 0 && d >= 0) {
		ans = max(0ll, ans);
	}

	cout << ans;

	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;


const int SIZE = 1e5+100;
ll n, k;
ll a[SIZE], b[SIZE];
pair<ll, ll> mem[SIZE];


int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        mem[i].first = a[i];
        mem[i].second = b[i];
    }

    sort(mem, mem+n);
    for(int i = 0; i < n; i++){
        k -= mem[i].second;
        if(k <= 0){
            cout << mem[i].first << endl;
            break;
        }
    }
}

Measured memory_bytes: 3328
<?php

fscanf(STDIN, '%d', $n);
$line = trim(fgets(STDIN));
$x = explode(' ', $line);
$line = trim(fgets(STDIN));
$y = explode(' ', $line);
$p = range(1, 4);

for ($i = 0; $i < 4; $i++) {
    $result = 0;
    foreach ($x as $j => $n) {
        $m = $y[$j];
        switch ($i) {
            case 0:
                $result += abs($n - $m);
                break;
            case 3:
                $result = max($result, abs($n - $m));
                break;
            default:
                $result += pow(abs($n - $m), $i + 1);
                break;
        }
    }

    if ($i === 1 || $i === 2) {
        $result = pow($result, 1 / ($i + 1));
    }

    printf("%f\n", $result);
}

Measured memory_bytes: 6740
let n = cin.int
switch n%10 {
    case 2,4,5,7,9:
        print("hon")
    case 0,1,6,8: 
        print("pon")
    case 3:
        print("bon")
    default:
        break
}

// MARK: #### 以下、ライブラリ ####

import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif

enum cin {
    // 123
    static var int: Int { Int(readLine()!)! }
    // 12 23
    static var pair: (Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!) }
    // 12 23 34
    static var triple: (Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!) }
    // AtCoder
    static var str: String { readLine()! }
    // At Coder
    static var arrayStr: [String] { str.components(separatedBy: " ") }
    // 1 2 3 4
    static var array: [Int] { str.components(separatedBy: " ").map { Int($0)! } }
    // 1
    // 2
    // 3
    static func v_array(count: Int) -> [Int] { (0..<count).map { _ in int } }
}

extension Int {
    // 123 -> [1, 2, 3]
    var digits: [Int] { Array(String(self)).map { Int(String($0))! } }
}

extension Array where Element == Int {
    // [2, 1, 3, 2] -> 8
    var sum: Int { self.reduce(0, +) }
    // [2, 1, 3, 2] -> [1, 2, 2, 3]
    var orderBy: [Int] { sorted() }
    // [2, 1, 3, 2] -> [3, 2, 2, 1]
    var orderByDesc: [Int] { sorted(by: { $0 > $1 }) }
    // [2, 1, 3, 2] -> [2, 1, 3]
    var distinct: [Int] { Array(Set(self)) }
}

precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence }
infix operator ^^ : PowerPrecedence
func ^^ (radix: Int, power: Int) -> Int {
    return Int(pow(Double(radix), Double(power)))
}

extension String {
    // e.g. cin.line.regex(match: "^(dream|dreamer|erase|eraser)*$")
    func regex(match pattern: String) -> Bool {
        let regex = try! NSRegularExpression(pattern: pattern)
        return regex.firstMatch(in: self, range: NSRange(location: 0, length: self.count)) != nil
    }
    // "ABC"[1] -> "B"
    subscript(i: Int) -> Character {
        get {
            self[index(at: i)]
        }
        set(char) {
            var characters = Array(self)
            characters[i] = char
            self = String(characters)
        }
    }
    func index(at offset: Int) -> String.Index { index(startIndex, offsetBy: offset) }
    // "ABC".swapAt(0, 1) -> "BAC"
    mutating func swapAt(_ index1: Int, _ index2: Int) {
        var characters = Array(self)
        characters.swapAt(index1, index2)
        self = String(characters)
    }
}


Measured memory_bytes: 12904
# 解説 AC

# 参考1: https://twitter.com/rickytheta/status/1175412019006074880
# 参考2: https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2019-09-21agc-038

def make_prime_checker(n):
    is_prime = [False, True, False, False, False, True] * (n//6+1)
    del is_prime[n+1:]
    is_prime[1:4] = False, True, True
    for i in range(5, int(n**0.5)+1):
        if is_prime[i]:
            is_prime[i*i::i] = [False] * (n//i-i+1)
    return is_prime

def make_modinv_list(n, mod=10**9+7):
    # 0 から n までの mod 逆元のリストを返す O(n)
    modinv = [0, 1]
    for i in range(2, n+1):
        modinv.append(mod - mod//i * modinv[mod%i] % mod)
    return modinv

def main():
    mod = 998244353
    max_A = 10**6
    N = int(input())
    A = list(map(int, input().split()))
    
    # nまでの自然数が素数かどうかを表すリストを返す  O(nloglogn)
    
    primes = [p for p, is_prime in enumerate(make_prime_checker(max_A)) if is_prime]  # max_A 以下の素数のリスト
    
    g = [0] * (max_A+1)
    for a in A:
        g[a] += a
    for p in primes:
        # 倍数集合の高速ゼータ変換みたいなやつ  O((max_A)loglog(max_A))
        # 参考: http://noshi91.hatenablog.com/entry/2018/12/27/121649
        # 大量に約数列挙みたいなことをするときはこれで高速化できる場合が多そう？（みんぷろ 2018 本戦 A - Uncommon など）
        for k in range(max_A//p, 0, -1):
            g[k] += g[k*p]
    
    # この時点で g[d] = Σ_{d|a} a  (A の要素のうち d の倍数であるものの総和)
    
    g = [v * v % mod for v in g]
    
    # この時点で
    # g[d] = (Σ_{d|a} a)(Σ_{d|b} b)
    #      = Σ_{(d|a)∧(d|b)} ab
    #      = Σ_{d | gcd(a,b)} ab
    
    # この式変形天才すぎないか？（これを使った一連の操作を gcd 畳み込み というらしい？）
    
    for p in primes:
        # 倍数集合の高速メビウス変換みたいなやつ  O((max_A)loglog(max_A))
    
        # for k in range(1, max_A//p+1):
        #     g[k] -= g[k*p]  # 包除原理ヤバい
    
        for k, g_kp in enumerate(g[p::p], 1):  # 高速化（ゼータ変換の方は途中で g が変化するので高速化できない）
            g[k] -= g_kp  # 包除原理ヤバい
    
    # この時点で g[d] = Σ_{gcd(a,b)=d} ab
    
    modinv_list = make_modinv_list(max_A, mod)
    ans = sum((gg * minv % mod for gg, minv in zip(g, modinv_list)))
    ans %= mod
    
    # この時点で
    # ans = Σ_d ( Σ_{gcd(a,b)=d} ab/d )
    #     = Σ_d ( Σ_{gcd(a,b)=d} lcm(a,b) )
    #     = Σ_a Σ_b lcm(a,b)
    
    ans -= sum(A)
    ans *= modinv_list[2]
    ans %= mod
    
    # この時点で ans = Σ_{i<j} lcm(a,b)
    
    print(ans)

main()


Measured memory_bytes: 80496
#include<stdio.h>

struct Node {
  int p, l, r;
};

struct Node T[100000];
int n;
int D[100000];

void deper(int u,int p){
  D[u]=p;
  if(T[u].r != -1) deper(T[u].r,p);
  if(T[u].l != -1) deper(T[u].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;

  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = -1;
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j == 0) T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p == -1)
      r=i;
  }
  deper(r,0);

  for(i=0;i<n;i++){
    int h,m;
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("depth = %d, ",D[i]);

    if(T[i].p==-1) printf("root, ");
    else if(T[i].l==-1) printf("leaf, ");
    else printf("internal node, ");

    printf("[");

    for( h=0,m=T[i].l ; m!=-1 ; h++, m=T[m].r ){
      if(h) printf(", ");
      printf("%d",m);
    }
    printf("]\n");
  }
  return 0;
}



Measured memory_bytes: 6392
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int N = Cin<int>();
        int M = Cin<int>();
        List<int>[] to = new List<int>[N];
        for (int i = 0; i < N; i++) to[i] = new List<int>();
        int[] come = new int[N];
        int[] ans = new int[N];
        for (int i = 0; i < N + M - 1; i++)
        {
            int[] inp = Line<int[]>().Select(v => v - 1).ToArray();
            to[inp[0]].Add(inp[1]);
            come[inp[1]]++;
        }
        Queue<int> queue = new Queue<int>();
        for (int i = 0; i < N; i++)
        {
            if (come[i] == 0) { queue.Enqueue(i); ans[i] = -1; }
        }
        while (queue.Count() != 0)
        {
            var i = queue.Dequeue();
            foreach (var j in to[i])
            {
                come[j]--;
                if (come[j] == 0)
                {
                    ans[j] = i;
                    queue.Enqueue(j);
                }
            }
        }
        ans.ToList().ForEach(v => Console.WriteLine(v + 1));
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    public static T Cin<T>()
    {
        if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s);
        if (typeof(T) == typeof(int)) return (T)(object)int.Parse(queue.Dequeue());
        else if (typeof(T) == typeof(long)) return (T)(object)long.Parse(queue.Dequeue());
        else if (typeof(T) == typeof(string)) return (T)(object)(queue.Dequeue());
        else if (typeof(T) == typeof(double)) return (T)(object)double.Parse(queue.Dequeue());
        else return (T)(object)(-1);
    }
    public static T Line<T>()
    {
        if (typeof(T) == typeof(int[]))
        {
            return (T)(object)Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        else if (typeof(T) == typeof(long[]))
        {
            return (T)(object)Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        else if (typeof(T) == typeof(string[]))
        {
            return (T)(object)Console.ReadLine().Split(' ').ToArray();
        }
        else if (typeof(T) == typeof(double[]))
        {
            return (T)(object)Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
        else return (T)(object)(-1);
    }
}

Measured memory_bytes: 29272