akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N : usize,
        A : usize,
        B : usize,
        C : usize,
        D : usize,
        E : usize
    }
    let pipes = vec![A, B, C, D, E];
    let min_pipe = pipes.iter().min().unwrap();
    println!("{}", 4 + (N + min_pipe - 1) / min_pipe);
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;



int main() {
    int n; cin >> n;
    vector<vector<int>> graph(n);
    rp(i, 0, n) {
        rp(j, 0, n-1) {
            int a; scanf("%d", &a); a--;
            graph.at(i).emplace_back(a);
        }
    }

    vector<int> prog(n);
    set<int> s;
    rp(i, 0, n) s.insert(i);
    int day = 0;
    while(!s.empty()) {
        set<int> next_s;
        for(auto x: s){
            int y = graph.at(x).at(prog.at(x));
            if(x == graph.at(y).at(prog.at(y))) {
                if(prog.at(x) < n-2) next_s.insert(x);
                if(prog.at(y) < n-2) next_s.insert(y);
            }
        }

        for(auto x: next_s) {
            // printf("%d ", x);
            prog.at(x) ++;
        }
        // printf("\n");
        day++;
        s = next_s;
    }
    rp(i, 0, n) {
        if(prog.at(i) < n-2) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << day << endl;
    return 0;
}

Measured memory_bytes: 7836
N,Y = map(int,input().split())
for i in range(0,N+1):
    for j in range(0,N-i+1):
        k = N - i - j
        cal = 10000*i + 5000*j + 1000*k
        if cal == Y:
            ans = [i,j,k]
            break
    if cal == Y:
        break

if cal != Y:
    ans = [-1,-1,-1]

print(ans[0],ans[1],ans[2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  string S;
  for (int i=0; i < N; i++){
    cin >> S;
    if(S =="Y"){
      break;
    }
  }
  if (S == "Y")
    cout << "Four"<<endl;
  
  else if (S =="P"|S=="W"|S=="G")
    cout << "Three" << endl;
}

Measured memory_bytes: 256
import std.conv;
import std.string;
import std.algorithm;
import std.array;
import std.stdio;

void main() {
	auto n = readln.chomp.to!int;
	auto a = readln.chomp.split(' ').map!(to!uint).array;
	assert(n == a.length);

	auto xor = a.reduce!"a ^ b";
	a.map!(x => to!string(xor ^ x)).join(' ').writeln;
}


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

int main(){

	long long int n, k, tmp, ans=0, ex;
	vector<long long int> v, ma;
  	bool flag=false;
	//bitset<100> bs;
  
	cin>> n >> k;
  	v.resize(n);
  	ma.resize(50, 0);
  
	for(int i=0;i<n;i++){
      	cin>> v[i];
      	tmp=v[i];
      	for(int j=0;j<50;j++){
          	ma[j]+=tmp%2;
          	tmp=tmp>>1;
        }
    }
  
  	/*for(int i=49;i>=0;i--) cout<< ma[i] << " ";
  	cout<< endl;*/

	for(long long int i=49;i>=0;i--){
      	tmp=k;
      	tmp=tmp>>i;
      	ex=pow(2, i);
      	//cout<< ex <<endl;
      
      	if(tmp%2 && n/2<ma[i]) flag=true;
      	if(flag || tmp%2){
          	//cout<< "#";
          	ans+=ex*max(ma[i], n-ma[i]);
        }else{
          	//cout<< "$" << ex*ma[i] << " ";
          	ans+=ex*ma[i];
        }
  		//cout<< i  << " " << ans <<endl;
    }
  
  	cout<< ans <<endl;

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void) {
	int h[1000],k[1000],i,a,b,c,d,h1=0,k1=0;
	scanf("%d %d", &h[0], &h[1]);
	scanf("%d %d", &k[0], &k[1]);
	scanf("%d %d %d %d", &a, &b,&c,&d);
	for (i = 0; i < h[0]; i++) {
		if (i % 10 == 0) {
			h1 += c;
		}
		h1 += a;
	}
	for (i = 0; i < h[1]; i++) {
		if (i % 20 == 0) {
			h1 += d;
		}
		h1 += b;
	}
	for (i = 0; i < k[0]; i++) {
		if (i % 10 == 0) {
			k1 += c;
		}
		k1 += a;
	}
	for (i = 0; i < k[1]; i++) {
		if (i % 20 == 0) {
			k1 += d;
		}
		k1 += b;
	}
	if(h1>k1){
		printf("hiroshi\n");
	}
	else if (h1 < k1) {
		printf("kenjiro\n");
	}
	else if (h1==k1) {
		printf("even\n");
	}
	return 0;
}


Measured memory_bytes: 2120
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(check(s)) {
			System.out.println("AC");
		}
		else {
			System.out.println("WA");
		}
	}
	public static boolean check(String s) {
		if(s.charAt(0)!='A') {
			return false;
		}
		int c = 0;
		for(int i = 2; i <s.length()-1; i++) {
			if(s.charAt(i)=='C') {
				c++;
			}
		}
		if(c!=1) {
			return false;
		}
		int upper = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i)>='A'&&s.charAt(i)<='Z') {
				upper++;
			}
		}
		if(upper!=2) {
			return false;
		}
		return true;
	}
}


Measured memory_bytes: 23252
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

//最長回文の長さを求める。
//O(N)

int Manarcher(const string &_s) {
  int n = _s.size();
  string s(2 * n + 1, '#');
  for (int i = 0; i < n; i++) s[2 * i + 1] = _s[i];
  n = 2 * n + 1;

  vector<int> rad(n);
  for (int i = 0, j = 0; i < n;) {
    while (i - j >= 0 && i + j < n && s[i - j] == s[i + j]) j++;
    rad[i] = j;

    int k;
    for (k = 1; i - k >= 0 && rad[i] - k > rad[i - k]; k++) rad[i + k] = rad[i - k];

    i += k;
    j = max(j - k, 0LL);
  }
  return *max_element(rad.begin(), rad.end()) - 1;
}

signed main() {
  string s;
  int ans = 0;
  while (cin >> s) {
    if (s.size() == Manarcher(s)) ans++;
  }

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



Measured memory_bytes: 3152
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut s = Vec::new();

    let mut ans = 0;
    let mut fb = 0;
    let mut fbla = 0;
    let mut la = 0;
    for _ in 0..n {
        let si: Vec<char> = read::<String>().chars().collect();
        for i in 0..si.len()-1 {
            if si[i] == 'A' && si[i+1] == 'B' {
                ans += 1;
            }
        }
        if si[0] == 'B' {
            if si[si.len()-1] == 'A' {
                fbla += 1;
            } else {
                fb += 1;
            }
        } else if si[si.len()-1] == 'A' {
            la += 1;
        }
        s.push(si);
    }

    while fbla > 0 {
        if la > 0 {
            ans += 1;
            fbla -= 1;
        } else if fb > 0 {
            ans += 1;
            fbla -= 1;
        } else if fbla > 1 {
            ans += 1;
            fbla -= 1;
        } else {
            break;
        }
    }

    println!("{}", ans + std::cmp::min(fb, la));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    double ma = 0, mi = INF, n;

    while(cin >> n){
        if(n > ma) ma = n;
        if(n < mi) mi = n;
    }

    printf("%.1f\n", ma - mi);

    return 0;
}

Measured memory_bytes: 1236
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
int dp[200][200];
struct z{
	int a,b,c;
};
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	int n,m;cin>>n>>m;
	queue<int> A[n];
	for(int i = 0; m > i; i++){
		int a,b;cin>>a>>b;
		if(a==1){
			int mn = A[0].size();
			for(int i = 0; n > i; i++){
				mn = min((int)A[i].size(),mn);
			}
			for(int i = 0; n > i; i++){
				if(mn == A[i].size()){
					A[i].push(b);
					break;
				}
			}
		}else{
			b--;
			cout << A[b].front() << endl;
			A[b].pop();
		}
	}
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    string str;
    string cf("CODEFESTIVAL2016");
    cin >> str;

    int sum = 0;
    REP(i, str.size()) {
       if ( str[i] != cf[i] ) {
           ++sum;
       }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

string s;
i64 n;

const i64 MOD = 1e9 + 7;

int main() {
  cin >> n >> s;
  map<char,i64> mp;
  for(char c: s) mp[c]++;
  i64 ans = 1;
  for(auto p: mp) ans = (ans * (p.second + 1)) % MOD;
  cout << (ans - 1 + MOD) % MOD << endl;
}


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

int main(){
    int i, n;
    double a, s, x, x2;
    while(1){
        cin >> n;
        if (n == 0) return 0;
        x = 0;
        x2 = 0;
        for (i=0;i<n;i++){
            cin >> s;
            x += s;
            x2 += s * s;
        }
        x /= n;
        cout << fixed << sqrt(x2/n-x*x) << endl;
    }
}


Measured memory_bytes: 3220
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int64_t a,b,k;
  cin >> a >> b >> k;
  for(int i = a; i <= b; i++){
    if(i < a + k || i > b - k){
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N, M;
	cin >> N >> M;
	vector<int> X(M), Y(M);
	for(int i=0;i<M;i++) cin >> X[i] >> Y[i];
	
	
	vector<int> cnt(N,0);
	vector<int> red(N,0);
	for(int i=0;i<N;i++) cnt[i] = 1;
	red[0] = 1;
	
	for(int i=0;i<M;i++){
		cnt[X[i] - 1]--;
		cnt[Y[i] - 1]++;
		if(red[X[i] - 1] == 1) red[Y[i] - 1] = 1;
		if(cnt[X[i] - 1] == 0) red[X[i] - 1] = 0;
	}
	
	int tot = 0;
	for(int i=0;i<N;i++) tot += red[i];
	cout << tot << endl;
	
	
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

int main()
{
    int n;
    cin >> n;

    vector<int> a(n), b(n), c(n - 1);

    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 - 1; ++i)
        cin >> c[i];

    int prev = -1;
    ll sum = 0;
    for(int x: a) {
        int i = x - 1;
        sum += b[i];
        if(prev != -1 && prev + 1 == i)
            sum += c[prev];

        prev = i;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(int arg_x,int arg_y){
		x = arg_x;
		y = arg_y;
	}
	bool operator<(const struct Info &arg) const{
		if(x != arg.x){
			return x < arg.x;
		}else{
			return y < arg.y;
		}
	}
	int x,y;
};

int N;
vector<Info> V;

int main(){

	scanf("%d",&N);

	int tmp_x,tmp_y;

	for(int loop = 0; loop < N; loop++){
		scanf("%d %d",&tmp_x,&tmp_y);
		V.push_back(Info(tmp_x,tmp_y));
	}
	sort(V.begin(),V.end());

	for(int i = 0; i < N; i++){
		printf("%d %d\n",V[i].x,V[i].y);
	}

	return 0;
}



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

int main(){
	long long X,K,D,E;
	cin>>X;
	cin>>K;
	cin>>D;
	X=abs(X);
	long long ans;

	if(X/D>=K){
		ans=X-K*D;
	}else{
		E=X/D;
		K=K-E;
		X=X-E*D;
		if(K%2!=0){
			ans=abs(X-D);
		}else{ans=X;}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
long long num[87];
int main()
{
	num[0] = 2;
	num[1] = 1;
	for (int i = 2; i < 87; i++) {
		num[i] = num[i - 1] + num[i - 2];
	}
	int n;
	scanf("%d", &n);
	printf("%lld", num[n]);
	return 0;
}

Measured memory_bytes: 256
// C - Dice and Coin
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K; cin>>N>>K;
	double ans = 0;
	for(int n=1; n<=N; ++n){
		double part_ans = 1./N;
		for(int k=n; k<K; k*=2) part_ans /= 2;
		ans += part_ans;
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	int N;
	cin>>N;
	vector<ll> s(N);
	REP(i, N) cin>>s[i];
	ll sum = 0;
	REP(i, N) sum += s[i];
	sort(ALL(s));

	if(sum % 10 != 0) cout<<sum<<endl;
	else {
		ll hoge = -INF;
		REP(i, N) {
			if(s[i] % 10 != 0) {
				hoge = s[i];
				break;
			}
		}
		if(hoge != -INF) cout<<sum - hoge<<endl;
		else cout<<0<<endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  const ll msize = 60;

  // the index of the most significant bit
  auto msbi = [](ll x) -> ll {
    return 63 - __builtin_clzll(x);
  };

  auto solve = [&]() -> ll {
    ll N; cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) cin >> A[i];
    string S; cin >> S;
    reverse(A.begin(), A.end());
    reverse(S.begin(), S.end());

    // basis of vector space gen. by {A_i, A_i+1, ..., A_N}
    // for each bit j, there is at most one v in basis such that msbi(v) == j
    vector<ll> basis;
    
    // basis[m2i[j]] is the index of the basis element v that satisfies msbi(v) == j
    vector<ll> m2i(msize, -1);  

    // If x is in the subspace generated by basis, returns false.
    // Otherwise, extend basis so that x is in space gen. by basis, and returns true.
    auto extend = [&](ll x) -> bool {
      while (true) {
	if (x == 0) return false;
	ll m = msbi(x);
	ll j = m2i[m];
	if (j < 0) {
	  m2i[m] = basis.size();
	  basis.push_back(x);
	  return true;
	}
	x ^= basis[j];
      }
    };

    for (ll i = 0; i < N; i++) {
      bool b = extend(A[i]);
      if (S[i] == '1' && b) return 1;
    }
    return 0;
  };

  ll T; cin >> T;
  for (ll _t = 0; _t < T; _t++) cout << solve() << "\n";

  return 0;
}



Measured memory_bytes: 3564
#include <stdio.h>
int main(){
    int a,b,c,tmp;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }

    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2076
from collections import Counter

S = input()

cnt = Counter(S).most_common()

#print(cnt)

cand = [chr(i) for i in range(97, 97+26)]

anss = float('inf')
for c in cand:
    alp = c
    ans = 0
    tmp = 0
    for s in S:
        if s == alp:
            ans = max(ans, tmp)
            tmp = 0
        else:
            tmp += 1
    if tmp:
        ans = max(ans, tmp)
    anss = min(anss, ans)
print(anss)

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

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
 
int main() {
  int N,K,L;
  cin >> N >> K >> L;
  
  UnionFind tree1(N),tree2(N);
  for (int i=0;i<K;i++){
    int p,q;
    cin >> p >> q;
    tree1.unite(p-1,q-1);
  }
  for (int i=0;i<L;i++){
    int r,s;
    cin >> r >> s;
    tree2.unite(r-1,s-1);
  }
  map<pair<int,int>,int> m;
  for (int i=0;i<N;i++){
    m[make_pair(tree1.root(i),tree2.root(i))]++;
  }
  for (int i=0;i<N;i++){
    cout << m[make_pair(tree1.root(i),tree2.root(i))];
    if (i!=N-1){
      cout << ' ';
    }
    else {
      cout << endl;
    }
  }
}

Measured memory_bytes: 13568
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion

int main()
{
	int n; cin >> n;
	vector<int> a(n); rep(i, n)cin >> a[i];
	vector<int> l(n), r(n + 1);
	l[0] = a[0]; r[n] = a[n - 1];
	for (int i = 1; i < n; ++i)l[i] = gcd(a[i], l[i - 1]);
	for (int i = n - 1; 0 < i; --i)r[i] = gcd(a[i], r[i + 1]);
	int res = max(l[n - 2], r[1]);
	for (int i = 1; i <= n - 2; ++i)res = max(res, gcd(l[i - 1], r[i + 1]));
	cout << res << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <stack>

using namespace std;


int n;
int A[10];

bool solve(stack<int> v1, stack<int> v2, int index){
    if (index == 10)
        return true;
    if (v1.empty() || A[index] > v1.top())
        v1.push(A[index]);
    else if(v2.empty() || v2.top() < A[index])
        v2.push(A[index]);
    else
        return false;
    return solve(v1,v2, index + 1);
}

int main(){
    cin>>n;
    stack<int> v1,v2;
    while(n--){
        for (int i = 0; i < 10; ++i) {
            cin>>A[i];
        }
        if (solve(v1,v2,0))
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 2964
#include<stdio.h>
#define true 1
#define false 0
int a[20],n;
int solve(int i,int m){
  int res;
  if(m == 0) return true;
  if(i >= n) return false;
  res = solve(i + 1, m) || solve(i + 1, m - a[i]);
  return res;
}
int main(){
  int i,q,b[200];
  scanf("%d",&n);
  for(i =0; i < n; i++) scanf("%d",&a[i]);
  scanf("%d",&q);
  for(i =0; i < q; i++) scanf("%d",&b[i]);
  for(i =0; i < q; i++){
    if(solve(0,b[i]) == true) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
int main()
{
    fastread;
    ll i,j,k,n,m,y,t;
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

#define llint long long int
#define pb push_back

using namespace std;

int main(){
  string s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  for(int i = 0; i < n; i++){
    int temp;
    if((s[i] == 'A')||(s[i] == 'C')||(s[i] == 'G')||(s[i] == 'T')){
      int j = i+1;
      while(j < s.length()){
        if((s[j] == 'A')||(s[j] == 'C')||(s[j] == 'G')||(s[j] == 'T')){
          j++;
        }
        else{
          break;
        }
      }
      temp = j-i;
    }
    if(temp > ans)
      ans = temp;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	auto used = new bool[][](S.length + 1, 26);

	foreach (i, c; S)
	{
		auto u = used[i].dup;
		u[c-'a'] = true;
		used[i+1] = u;
	}

	string ans;
	(){
	foreach_reverse (i; 0..used.length)
	{
		debug writeln(used[i]);
		foreach (j; 0..used[i].length)
		{
			debug writeln("1:", [cast(char)('a'+j)]);
			if (used[i][j]) continue;
			debug writeln("2:", [cast(char)('a'+j)]);
			if (i < S.length)
				if (j <= S[i] - 'a') continue;

			ans = S[0..i] ~ cast(char)('a' + j);
			return;
		}
	}}();

	if (ans.length == 0)
		writeln(-1);
	else
		writeln(ans);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    ll q;
    cin >> q;
    bool isRev = false;
    rep(i,q){
        ll t;
        cin >> t;
        if(t==1) isRev = !isRev;
        if(t==2){
            ll f;
            string c;
            cin >> f >> c;
            if(f==1) s.insert(isRev?s.size():0,c);
            if(f==2) s.insert(isRev?0:s.size(),c);
        }
    }
    if(isRev) reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 3864
n,m=map(int,input().split())

d={}
ind=[0]*n

for i in range(n):
    d[i+1]='*'

for j in range(m):
    s,c=map(int,input().split())

    if ind[s-1]==0:
        d[s]=c
        ind[s-1]=1
    else:
        if d[s]!=c:
            print(-1)
            exit(0)


ans=''

if n>=2:
    if d[1]==0:
        print(-1)
        exit(0)

for k in range(n):
    if k==0:
        if n>=2:
            if d[k+1]=='*':
                ans+='1'
            else:
                ans+=str(d[k+1])
        else:
            if d[k+1]=='*':
                ans+='0'
            else:
                ans+=str(d[k+1])
    else:
        if d[k+1]=='*':
            ans+='0'
        else:
            ans+=str(d[k+1])

print(ans)

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

typedef long long ll;
typedef unsigned long long ull;

#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

//for(int i = 0; i < size; i++)
//    cout << a[i] << " ";

int main(){

    fast_io;

    int t;
    int ac = 0, wa = 0, tle = 0, re = 0;

    cin >> t;

    string temp;

    for(int i = 0; i < t; i++){
        cin >> temp;
        if(temp == "AC"){
            ac++;
        }
        else if(temp == "WA"){
            wa++;
        }
        else if(temp == "TLE"){
            tle++;
        }
        else{
            re++;
        }
    }
    cout << "AC x " << ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re << '\n';
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;
ll fac(ll n){
	if(n==1||n==0)
		return 1 ;
	else
		return n*fac((n-1));
}
ll posi(ll n,vector<ll> &a,vector<ll> &b){
	// cerr<<"n="<<n<<", ";
	if(n==1)
		return 0 ;
	else{

		ll x =0;
		ll cnt = 0;
		ll tmp = a[((int)a.size())-n];
		for(ll idx=((int)a.size())-n; idx < a.size(); idx++)
			if(a[idx] < tmp)
				cnt++;
		x+=fac(n-1)*(cnt);
		// rep(i,a.size()){
		// 	cerr<<"i="<<i<<", ";
		// 	if(==b[i]){
		// 		x+=fac(n-1)*(i);
		// 		break;
		// 	}
		// }
		// cerr<<"x="<<x<<endl;
		return x + posi(n-1,a,b) ;
	}
}


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
	// int t ;
	// cin>>t;
	// whln(t){
	ll n ;
	cin>>n;
	vector<ll>a(n),b(n),c(n);
	rep(i,n){
		cin>>a[i];
		c[i]=a[i];
	}
	rep(i,n)
		cin>>b[i];
	sort(c.begin(),c.end());

	// cerr<<posi(n,a,c)<<endl;
	cout<<abs(posi(n,a,c)-posi(n,b,c))<<"\n";
		
}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

Measured memory_bytes: 3616
#include<iostream>
#include<bitset>
#include<algorithm>
#include<vector>

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int h,w,m; std::cin >> h >> w >> m;
  int br[300000];
  int bc[300000];
  int cntr[300000] = {};
  int cntc[300000] = {};
  static std::vector<int> vr[300001];
  static std::vector<int> vc[300001];
  int maxr=0,maxc=0;
  for(int i = 0; i < m; ++i){
    std::cin >> br[i] >> bc[i];br[i]--;bc[i]--;
    maxr = std::max(maxr,++cntr[br[i]]);
    maxc = std::max(maxc,++cntc[bc[i]]);
    if(maxr == cntr[br[i]])vr[maxr].push_back(br[i]);
    if(maxc == cntc[bc[i]])vc[maxc].push_back(bc[i]);
  }
  std::bitset<300000>r,c;
  int cr=0,cc=0,cntd=0;
  for(int i = 0,sz = (int)vr[maxr].size(); i < sz; ++i)cr+=r[vr[maxr][i]] = 1;
  for(int i = 0,sz = (int)vc[maxc].size(); i < sz; ++i)cc+=c[vc[maxc][i]] = 1;
  cntd = cr*cc;
  for(int i = 0; i < m; ++i)
    cntd -= c[bc[i]]&r[br[i]];
  std::cout << maxr + maxc - (!cntd) << '\n';
}


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

int solve(int n, int x) {
    int cnt=0;
    for (int i=1; i<=n; i++){
        for (int j=i+1; j<=n; j++){
            for (int k=j+1; k<=n; k++){
                if (i+j+k==x){
                    cnt++;
                }
            }
        }
    }

    return cnt;
}

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

    while (true) {
        int n, x;
        cin >> n >> x;
        if (n==0 && x==0){
            break;
        }
        else {
            int ans = solve(n, x);
            cout << ans << endl;
        }
    }
}


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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back


int32_t main(){
sp;
    unordered_map<string,int> mp;
    int n;
    cin>>n;
    string s;
    for(int i=0; i<n; ++i){
        cin>>s;
        sort(s.begin(),s.end());
        ++mp[s];
    }
    int ans=0;
    for(auto &it:mp)
        ans+=(it.second*(it.second-1))/2;
    cout<<ans;

    return 0;
}


Measured memory_bytes: 10660
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 998244353;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
vl A,B;
int main() {
	float aans = 0;
	cin >> n;
	rep(i, n) {
		cin >> a >> b;
		A.push_back(a);
		B.push_back(b);
	}

	rep(i, n) {
		rep(j, i) {
			aans += 2*sqrtf(float((A[i] - A[j]) * (A[i] - A[j]) + (B[i] - B[j]) * (B[i] - B[j]))) / float(n);
		}
	}

	cout <<setprecision(10)<< aans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int A,B,C,K;
    scanf("%d %d %d %d",&A,&B,&C,&K);
//    printf("%d %d %d %d",A,B,C,K);
    if(K<=A){
        printf("%d",K);
    }
    else if((A<K)&&(K<=A+B)){
        printf("%d",A);
    }
    else if((A+B<K)&&(K<=A+B+C)){
        printf("%d",A-(K-(A+B)));
    }

    
}

Measured memory_bytes: 1712
from operator import itemgetter
import math

n, h = map(int, input().split())
ab = []
A = 0
B = 1
maxA = 0
for i in range(n):
    ab.append(list(map(int, input().split())))
    maxA = max(maxA, ab[i][A])

ab.sort(key=itemgetter(B), reverse=True)

sumB = 0
for _ab in ab:
    sumB += _ab[B]

ans = 0
damage = 0
i = 0
while damage < h and ans < n:
    damage += max(maxA, ab[ans][B])
    ans += 1

ab.sort(key=itemgetter(A), reverse=True)

if damage < h:
    ans += math.ceil((h - damage)/ab[0][A])

print(ans)

Measured memory_bytes: 28904
from itertools import product
N,*ABC=map(int,input().split())
L=list(int(input()) for _ in range(N))
mp=10**9
for i in product([0,1,2,3] ,repeat=N):
    if {0,1,2}<=set(i):
        m=[0,0,0]
        for x,y in zip(i,L):
            if x!=3:
                m[x]+=y
        t=sum(abs(p-q) for p,q in zip(ABC,m))
        r=sum(1 if k!=3 else 0 for k in i)-3
        mp=min(mp,t+r*10)
print(mp)


Measured memory_bytes: 3064
import numpy as np
n,m,x = map(int,input().split())
c_list = []
a_list = []
flag = False
ans = 10**9
for i in range(n):
    tmp = list(map(int,input().split()))
    c_list.append(tmp[0])
    a_list.append(tmp[1:])
    
a_list = np.array(a_list)

for i in range(2**n):
    tmp_a = np.array([0]*m)
    tmp_c = 0
    for j in range(n):
        if ((i >> j) & 1):
            tmp_a += a_list[j]
            tmp_c += c_list[j]
    
    if min(tmp_a) >= x:
        flag = True
        if tmp_c < ans:
            ans = tmp_c
            
if flag:
    print(ans)
    
else:
    print(-1)

Measured memory_bytes: 26632
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define all(c) begin(c),end(c)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const long double pi = acos(-1.0);
typedef complex<ld> cd;

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

  int n; cin >> n;
  vector<int> a,b;
  rep(i,n){
    int tmp; cin >> tmp;
    a.push_back(tmp);
    cin >> tmp;
    b.push_back(tmp);
  }
  sort(all(a));
  sort(all(b));
  if(n&1){
    int l = a[n/2],r = b[n/2];
    cout << r - l + 1 << endl;
  }
  else{
    int l = (a[n/2-1]+a[n/2]),r = b[n/2-1]+b[n/2];
    cout << r- l + 1 << endl;
  }
}


Measured memory_bytes: 5136
fun main(args: Array<String>) {
    val (n, l) = readLine()!!.split(" ").map(String::toInt)
    val list = (1..n).map { l + it - 1 }.toList()
    val absMin = list.map(Math::abs).min()!!
    val relMin = if (list.min()!! > 0) absMin else -absMin
    println(list.sum() - relMin)
}

Measured memory_bytes: 37868
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = list(input())
k = int(input())
for i in range(k):
    if n[i] != '1':
        print(n[i])
        sys.exit()
print(1)


Measured memory_bytes: 5460
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int MaxN = 1e5;
typedef long long LL;

int n;
LL k;
struct PP
{
	int a, b;
}num[MaxN + 5];
int cmp(PP x, PP y)
{
	return x.a < y.a;
}
int main()
{
	while(scanf("%d %lld", &n, &k) != EOF)
	{
		for(int i = 1; i <= n; i++)
			scanf("%d %d", &num[i].a, &num[i].b);
		sort(num + 1, num + n + 1, cmp);
		LL cnt = 0;
		for(int i = 1; i <= n; i++)
		{
			cnt += (LL)num[i].b;
			if(cnt >= k)
			{
				printf("%d\n", num[i].a);
				break;
			}
		}
		memset(num, 0, sizeof(num));
	}
	return 0;
}

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

const int MAXN = 5010;
int n;
int absx(int x) { return x < 0 ? -x : x; }
char S[MAXN], T[MAXN];
int ax[MAXN], axt[MAXN], ay[MAXN], ayt[MAXN], baka, bakb;
int prea[MAXN], preb[MAXN];
void getmin(int & x, int y) { x > y ? x = y : 0; }

int dp[MAXN][MAXN];
int pre(int typ, int i) { return typ == 0 ? prea[i] : preb[i]; }
int suc(int typ, int i) {
	int res = typ == 0 ? prea[baka] - prea[i - 1] : preb[bakb] - preb[i - 1];
	res = (typ == 0 ? baka - i + 1 : bakb - i + 1) * n - res;
	return res;
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> S + 1 >> T + 1;
	if (n <= 2) {
		int ans = 0;
		for (int i = 1; i <= n; ++i) ans += S[i] != T[i];
		std::cout << ans << std::endl;
		return 0;
	}
	for (int i = 1; i < n; ++i) {
		if (S[i] != S[i + 1]) {
			ax[++baka] = i;
			axt[baka] = S[i] == '1';
		}
		if (T[i] != T[i + 1]) {
			ay[++bakb] = i;
			ayt[bakb] = T[i] == '1';
		}
	}
	for (int i = 1; i <= baka; ++i) prea[i] = prea[i - 1] + ax[i];
	for (int i = 1; i <= bakb; ++i) preb[i] = preb[i - 1] + ay[i];
	int ans = std::numeric_limits<int>::max();
	memset(dp, 0x3f, sizeof dp);
	for (int i = 0; i <= baka; ++i)
		for (int j = 0; j <= bakb; ++j) {
			getmin(dp[i][j], pre(0, i) + pre(1, j));
			getmin(ans, dp[i][j] + suc(0, i + 1) + suc(1, j + 1));
			if (i < baka && j < bakb && axt[i + 1] == ayt[j + 1])
				getmin(dp[i + 1][j + 1], dp[i][j] + absx(ax[i + 1] - ay[j + 1]));
		}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 98560
//
// Created by tac on 2016/10/12.
//

#include <cstdlib>
#include <iostream>
#include <iomanip>

int main() {
    int a, b;
    int d, r;
    double f;
    std::cin >> a >> b;
    d = a / b;
    r = a % b;
    f = static_cast<double>(a) / b;
    std::cout << d << " " << r << " " << std::fixed << std::setprecision(6) << f << std::endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3256
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(n*n*n);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  int N;
  vector<int> A;

  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

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

  for (int i = 1; i < A.size(); i++) {
    if (A[i] == A[i - 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

set<ll> v;

void lulunfinder(ll init,int now_len) {
	v.insert(init);
	if (now_len >=10) {
		return;
	}
	string s = to_string(init);
	int ldg = s[s.length() - 1] - '0';
	if (ldg == 0) {
		lulunfinder(stoll(s + '0'), now_len + 1);
		lulunfinder(stoll(s + '1'), now_len + 1);
	}
	else if (ldg == 9) {
		lulunfinder(stoll(s + '8'), now_len + 1);
		lulunfinder(stoll(s + '9'), now_len + 1);
	}
	else{
		for (int i = ldg - 1; i <= ldg + 1; i++) {
			char c = '0' + i;
			lulunfinder(stoll(s + c), now_len + 1);
		}
	}
	return;
}

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int k; cin >> k;
	for (int i = 1; i <= 9; i++) {
		lulunfinder(i, 1);
	}
	vector<ll> a;
	for (auto iter = v.begin(); iter != v.end(); iter++) {
		a.push_back((*iter));
	}
	cout << a[k - 1];
}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

Measured memory_bytes: 11764
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
import numpy as np
n,k,q =  map(int, sys.stdin.readline().split())
l=[0]*n
l = np.array(l)
l+=q

# a=[l[i-1]-1 for i in  list(map(int,sys.stdin.readlines()))]
# print(a)
for i in range(q):
    a =  int(sys.stdin.readline())
    l[a-1]-=1

for e in l:
    if e >=k:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 16632
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    int H, W;
    cin >> H >> W;
    vector< vector<int> > grid(H+2, vector<int>(W+2));
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            int A;
            cin >> A;
            grid[i][j] += A;
        }
    }
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            int B;
            cin >> B;
            grid[i][j] -= B;
        }
    }

    vector< vector< bitset<100'000> > > dp(H+2, vector< bitset<100'000> >(W+2));
    dp[1][1].set(50'000 + grid[1][1]);
    dp[1][1].set(50'000 - grid[1][1]);
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            for(int k=100; k<=99'900; k++) {
                if(dp[i][j][k]) {
                    dp[i+1][j].set(k + grid[i+1][j]);
                    dp[i+1][j].set(k - grid[i+1][j]);
                    dp[i][j+1].set(k + grid[i][j+1]);
                    dp[i][j+1].set(k - grid[i][j+1]);
                }
            }
        }
    }

    int ans = numeric_limits<int>::max();
    for(int k=100; k<=99'900; k++) {
        if(dp[H][W][k]) {
            ans = min(ans, abs(50'000 - k));
        }
    }

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


Measured memory_bytes: 84628
#include <iostream>
#include <string>
#include <stack>
using namespace std;
string s;
bool solve() {
  stack<char> stk;
  for(int i=0; i!=(int)s.length(); ++i) {
    if(s[i] == '[' || s[i] == '(') stk.push(s[i]);

    else if(s[i] == ']') {
      if(stk.empty()) return 0;
      if(stk.top() != '[') return 0;
      stk.pop();
    }
    else if(s[i] == ')') {
      if(stk.empty()) return 0;
      if(stk.top() != '(') return 0;
      stk.pop();
    }
  }
  return stk.empty();
}

int main() {
  while(getline(cin, s) && s != ".") {
    cout << (solve() ? "yes" : "no") << endl;
  }
  return 0;
}



Measured memory_bytes: 3204
#include <stdio.h>
int main(void){
  int n,a,b,i,j,sum=0,tmp,ttl;
  scanf("%d %d %d",&n,&a,&b);
  for(i=1;i<=n;i++){
    tmp=i;ttl=0;
    while(tmp!=0){
      ttl+=tmp%10;
      tmp/=10;
    }
    if(ttl>=a&&ttl<=b) sum+=i;
  }
  printf("%d",sum);
  return 0;
}

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

using ll = long long;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  if((B - A) % 2 == 0) {
    cout << (B - A) / 2 << endl;
    return 0;
  }
  ll a = (A - 1) + 1 + (B - A - 1) / 2;
  ll b = (N - B) + 1 + (B - A - 1) / 2;
  cout << min(a, b) << endl;
  return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,m; cin>>n>>m;
  vector<int> cost = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  vector<int> a(m);
  rep(i,m) cin>>a[i];
  vector<string> dp(10010, "");
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      int p = i+cost[a[j]];
      if (p>n) continue;
      string tmp = dp[i];
      if (i>0&&dp[i]=="") continue;
      tmp.push_back(a[j]+'0');
      if (dp[p].length() < tmp.length() || (dp[p].length() == tmp.length() && dp[p] < tmp)) {
        dp[p] = tmp;
      }
    }
  }
  cout << dp[n] << endl;
}

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


Measured memory_bytes: 43648