akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[100005],n,tmp1,tmp2;
int sum=1,ans=1;
int main()
{
	scanf("%d",&n);
	ans=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2==0)ans*=2;
		sum*=3;
	}
	cout<<sum-ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n; cin >> n;
    ll a[n], b[n];
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        cin >> b[i];
    }

    ll sum_a = accumulate(a, a+n, 0LL);
    ll sum_b = accumulate(b, b+n, 0LL);
    if(sum_a < sum_b){
        cout << -1 << endl;
        return 0;
    }

    ll remain[n];
    ll deficit[n];
    rep(i, n){
        remain[i] = a[i] - b[i];
        deficit[i] = -remain[i];
    }

    sort(remain, remain+n, greater<ll>());
    sort(deficit, deficit+n, greater<ll>());

    int ir = 0;
    int id = 0;
    ll ans = 0;
    while(true){
        if(deficit[id] <= 0) break;

        if(remain[ir] > deficit[id]){
            remain[ir] -= deficit[id];
            id++;
        }
        else if(remain[ir] == deficit[id]){
            remain[ir] = deficit[id] = 0;
            ir++;
            id++;
        }
        else{
            deficit[id] -= remain[ir];
            ir++;
        }
    }

    int isum = id + ir;
    cout << (isum == 0 ? 0 : isum + 1) << endl;


    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b;
	while(1){
		c=1;
		for(int i=a;i<=b;i++){
			if(i%4==0&&(i%100>0||i%400==0)){
				cout<<i<<endl;c=0;
			}
			
		}
		if(c)cout<<"NA"<<endl;
		cin>>a>>b;
		if(a==0&&b==0)break;
		else cout<<endl;
	}
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

int main(){
   string str;cin>>str;
   REP(i,str.length()-8){
       cout<<str[i];
   }
   cout<<endl;
   return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
#define int long long
signed main()
{
	int n, a[200000], b[200000], c[200001], total = 0;
	for(int i = 0; i <= 200000; c[i++] = 0);
	scanf("%lld", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%lld", &a[i]);
		b[i] = a[i];
	}
	sort(b, b + n);
	for(int i = 1, j; i <= n; ++i)
	{
		c[i] = distance(lower_bound(b, b + n, i), upper_bound(b, b + n, i));
		total += c[i] * (c[i] - 1) / 2;
	}
	for(int i = 0; i < n; ++i)
	{
		printf("%lld\n", total - (c[a[i]] * (c[a[i]] - 1) / 2) + ((c[a[i]] - 1) * (c[a[i]] - 2) / 2));
	}
}


Measured memory_bytes: 7296
/***
 ** " All that we are is the result of what we have thought. "
 ** 	-- Buddha
***/

/**
  *  Author: dhruv_gheewala
  *  Date:   28.03.2020
  *  Time:   19:27:04
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;

    #define p(str) 7
    #define o(str) 42
    #define fundri 108
    #define d(...) 1729
#endif


typedef unsigned int ui;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const bool testcases = 0;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(),s.end()
#define test int __T__=1;if(testcases)cin>>__T__;while(__T__--)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define make_unique(vec) sort(all(vec));vec.erase(unique(all(vec)),vec.end())
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

ll seed;auto random_address=[]{char *p=new char;delete p;return (uint64_t)p;};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()*(random_address()|1));
inline int rnd(int l=0,int r=INT_MAX){return uniform_int_distribution<int>(l,r)(rng);}

template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}

template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a)
{in>>a.ff>>a.ss;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a)
{for(auto &x : a)in>>x;return in;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}

int main()
{
    std::chrono::time_point<std::chrono::high_resolution_clock> start_time, end_time;
    start_time = std::chrono::high_resolution_clock::now();

    #ifdef DHRUV_GHEEWALA
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","w",stderr);
    #endif
    
    fast;
    int n,x,y;
    test{

    cin>>n>>x>>y;

    vector<ll> ans(n+1, 0);
    ll mini;
    for(int i = 1; i <= n; i++)
    {
    	for(int j = i+1; j <= n; j++)
    	{
    		mini = min({
    			abs(x - i) + 1 + abs(y - j),
    			abs(y - i) + 1 + abs(x - j),
    			j - i});

    		ans[mini]++;
    	}
    }

    for(int i = 1; i < n; i++)
    	cout<<ans[i]<<endl;

    fundri;
    }

    end_time = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
    o("\n\n======\n");
    if(elapsed_time<10000)
        o("Elapsed Time: "<<elapsed_time<<" ms\n");
    else
        o("Elapsed Time: "<<elapsed_time/1000<<" s\n");

    return 0;
}

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 100000 + 10;

bool build(int64 n, int64 m, int64 t){
	if (n >= t){
		return m >= 2 * t;
	}
	else{ // 3 x 5
		return m >= 2 * (t + t - n);
	}
}

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

#ifdef MARX
	freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
#endif

	int64 n, m;

	cin >> n >> m;

	int64 lo = 0, hi = 2 * (n + m);

	while (lo + 1 < hi){
		int64 mid = (lo + hi) / 2;

		if (build(n, m, mid)) lo = mid;
		else hi = mid;
	}

	cout << lo << endl;

	return 0;
}

Measured memory_bytes: 256
/* Coached by rainboy */
#include <stdio.h>

#define H 100
#define W 100

int main() {
	static char cc[H][W + 1];
	int a, b, i, j;

	scanf("%d%d", &a, &b);
	for (i = 0; i < H; i++)
		for (j = 0; j < W; j++)
			cc[i][j] = i < H / 2 ? '.' : '#';
	b--;
	for (i = 0; i < H / 2 - 1; i += 2)
		for (j = 0; j < W && b > 0; j += 2, b--)
			cc[i][j] = '#';
	a--;
	for (i = H / 2 + 1; i < H; i += 2)
		for (j = 0; j < W && a > 0; j += 2, a--)
			cc[i][j] = '.';
	printf("%d %d\n", H, W);
	for (i = 0; i < H; i++)
		printf("%s\n", cc[i]);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;


int main() {
  int x; 
  cin >> x;
  vector<bool> prime(1000000);

  for (int i = 2; i < x; ++i) {
    if (prime[i] == true) continue;
    for (int j = i; j < 1000000; j += i) {
      prime[j] = true;
    }
  }

  for (int i = x; ; ++i) {
    if (!prime[i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

map<ii, int> mapa;
vector<int> adj[3000005];
int dp[3000005], mat[1005][1005];
int vis[3000005];

bool hascycle(int u){
    vis[u] = 1;
    for(int v : adj[u]){
        if(vis[v] == 0 and hascycle(v)) return true;
        else if(vis[v] == 1) return true;
    }
    vis[u] = 2;
    return false;
}

int solve(int u){
    if(dp[u] != -1) return dp[u];
    int res = 0;
    for(int v : adj[u])
        res = max(res, solve(v));
    res++;
    return dp[u] = res;
}

int main(){
    memset(dp, -1, sizeof dp);
    int n; cin >> n;
    int nodos = 1;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n-1; j++)
            scanf("%d", &mat[i][j]), mat[i][j]--;
    for(int i = 0; i < n; i++)
        for(int j = 0; j+1 < n-1; j++){
            ii a = {i, mat[i][j]};
            ii b = {i, mat[i][j+1]};
            if(mapa[a] == 0) mapa[a] = mapa[{mat[i][j], i}] = nodos++;
            if(mapa[b] == 0) mapa[b] = mapa[{mat[i][j+1], i}] = nodos++;
            
            adj[mapa[a]].push_back(mapa[b]); 
        }
    for(int i = 1; i < nodos; i++)
        if(hascycle(i)){
            puts("-1");
            return 0;
        }
    int res = 0;
    for(int i = 1; i < nodos; i++)
        res = max(res, solve(i));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 167808
#include <stdio.h>
#define MAX 1000000001
void mergesort(int *,int ,int );
void merge(int *,int ,int ,int );
int count=0,n,Left[250001],Right[250001],i,j,k,n1,n2;

int main(void){
  int S[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  mergesort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}
void mergesort(int *S,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(S,left,mid);
    mergesort(S,mid,right);
    merge(S,left,mid,right);
  }
}
void merge(int *S,int left,int mid,int right){
  n1=mid-left;n2=right-mid;
  for(i=0;i<n1;i++)
    Left[i]=S[left+i];//not include mid
  for(i=0;i<n2;i++)
    Right[i]=S[mid+i];//include mid
  Left[n1]=MAX;
  Right[n2]=MAX;
  for(i=0,j=0,k=left;k<right;){
    if(Left[j]>Right[i])S[k++]=Right[i++];
    else S[k++]=Left[j++];
  }
  count+=right-left;
}


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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
bool is_odd[200005];
bool has_one[200005];
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  for(int i = 1; i < n+1; ++i) {
    cin >> is_odd[i];
  }
  int total_counter = 0;
  stack<int> ss;
  for(int i = n; i >= 1; --i) {
    int counter = 0;
    for(int j = 2; i*j <= n; ++j) {
      if(has_one[i*j]) ++counter;
    }
    bool tmp_is_odd = counter % 2;
    if(tmp_is_odd != is_odd[i]) {
      has_one[i] = true;
      ++total_counter;
      ss.push(i);
    }
  }
  cout << total_counter << endl;
  for(int i = 0; i < total_counter; ++i) {
    cout << ss.top() << "\n";
    ss.pop();
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 2424
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
using namespace std;

int h[105];

int cnt=0;

//void f(int left, int right) {
//
//
//}
int main()
{
    int n;

    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    int left = 1;
    while (left <= n) {
        if (h[left] == 0) {
            left++;
            continue;
        }
        for (int i = left; i <= n; i++) {
           
            if (h[i] == 0 ) {
                cnt++;
                break;
            }
            h[i]--;
            if (i == n) {
                cnt++;
                
            }
        }


    }
    cout << cnt << endl;

    return 0;




}



Measured memory_bytes: 3160
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
/*C++?????¨????????????*/
int main(){

  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);


  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ){
    C[i] = 0;
  }


  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ){
    C[i] = C[i] + C[i - 1];
  }

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ){
      printf(" ");
    }
    printf("%d", B[i]);
  }
  printf("\n");
  
  
  free(A);
  free(B);
  
  return 0;
}

Measured memory_bytes: 8408
#include<iostream>
#include<string>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a ,ll b)
{
    if(a%b==0)
     return b;
     else if(a<b)
       return gcd(b,a);
       else
     return gcd(b,a%b);
}
int main()
{
    
   ll sum=0;
   ll k;
   cin>>k;
   
   for(ll i=1;i<=k;i++)
   {
       for(ll j=1;j<=k;j++)
       {
           ll hcf=gcd(i,j);
           for(ll m=1;m<=k;m++)
             sum=sum+gcd(hcf,m);
       }
   }
   cout<<sum;
    return 0;
}


Measured memory_bytes: 3640
// :(
#include<iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n == 2){
        cout << -1 << endl;
        return 0;
    }
    if(n == 3){
        cout << "a..\na..\n.aa" << endl;
        return 0;
    }
    char mat[n][n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            mat[i][j] = '.';
        }
    }
    char ord[4][4] = { 
        {'a', 'a', 'c', 'd'}, 
        {'b', 'b', 'c', 'd'}, 
        {'e', 'f', 'g', 'g'}, 
        {'e', 'f', 'h', 'h'},
    };
    int i = 0;
    while(i+7 < n){
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                mat[i+j][i+k] = ord[j][k];
            }
        }
        i += 4;
    }
    if(i+7 == n){
        string s[7] = {"aabbaa.", "bb.cc.a", "..a..ba", "..a..bc", "aa.aa.c", "..a..ab", "..a..ab"};
        for(int j = 0; j < 7; j++){
            for(int k = 0; k < 7; k++){
                mat[i+j][i+k] = s[j][k];
            }
        }
    }else if(i+6 == n){
        string s[6] = {"abcc..", "abdd..", "..efgg", "..efhh", "ii..jk", "ll..jk"};
        for(int j = 0; j < 6; j++){
            for(int k = 0; k < 6; k++){
                mat[i+j][i+k] = s[j][k];
            }
        }
    }else if(i+5 == n){
        string s[5] = {"aabbc", "dee.c", "d..fg", "h..fg", "hiijj"};
        for(int j = 0; j < 5; j++){
            for(int k = 0; k < 5; k++){
                mat[i+j][i+k] = s[j][k];
            }
        }
    }else if(i+4 == n){
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                mat[i+j][i+k] = ord[j][k];
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cout << mat[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a, &b);
    if(a<b){
    printf("a < b\n");
    }else if(a>b){
    printf("a > b\n");
    }else{printf("a == b\n");
    }
    return 0;
}   

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

vector<int> sum(200010, 0);
set<int> st;

int main() {
	int n, k, a;
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {
		cin >> a;
		st.insert(a);
		sum[a]++;
	}

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

	if (st.size() <= k) {
		cout << 0 << endl;
		return 0;
	}

	int ans = 0, cnt = 0;
	for (int i = 1; i <= 200009; i++) {
		if (sum[i] == 0) continue;
		
		ans += sum[i];
		cnt++;
		if (st.size() - cnt <= k) {
			cout << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 10368
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	string s;
	bool a[26];
	for (int i = 0; i < 26; i++)
		a[i] = false;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (a[s[i] - 'a'] == false)a[s[i] - 'a'] = true;
		else {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}

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

int main()
{
	deque<int> a;
	int q;

	cin >> q;

	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;

		if (t == 0) {
			int d, x;
			cin >> d >> x;

			if (d == 0)
				a.push_front(x);
			else if (d == 1)
				a.push_back(x);
		}
		else if (t == 1) {
			int p;
			cin >> p;
			cout << a[p] << endl;
		}
		else if (t == 2) {
			int d;
			cin >> d;
			
			if (d == 0)
				a.pop_front();
			else if (d == 1)
				a.pop_back();
		}
	}

	return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	bool a[n][n];
	for (int i = 0; i < n; i++) {
		std::string s;
		std::cin >> s;
		for (int j = 0; j < n; j++) a[i][j] = s[j] == '#';
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cnt += a[i][j];
	if (!cnt) {
		std::cout << -1 << std::endl;
		return 0;
	} else if (cnt == n * n) {
		std::cout << 0 << std::endl;
		return 0;
	} else {
		// pre
		bool can[n];
		for (int i = 0; i < n; i++) {
			can[i] = false;
			for (int j = 0; j < n; j++) if (a[j][i]) can[i] = true;
		}
		int base = n;
		for (int i = 0; i < n; i++) {
			int cnt = 0;
			for (int j = 0; j < n; j++) if (a[j][i]) cnt++;
			if (cnt == n) base--;
		}
		
		// soro
		int res = 1000000000;
		for (int i = 0; i < n; i++) {
			int cost = 0;
			if (!can[i]) cost++;
			for (int j = 0; j < n; j++) {
				if (!a[i][j]) cost++;
			}
			cost += base;
			res = std::min(res, cost);
		}
		assert(res != 1000000000);
		std::cout << res << std::endl;
		return 0;
	}
	
	
	return 0;
}


Measured memory_bytes: 512
S = input()
N = len(S)

def isOk(s):
    for s, t in zip(s, s[:: -1]):
        if s != t:
            return False
    return True

for s in [S, S[:(N - 1) // 2], S[(N + 3) // 2 - 1:]]:
    if not isOk(s):
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3060
import math
n = int(input())
a = list(map(int, input().split()))
a.sort()

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

maxi = 0
i = -1
key = a[i] // 2
for j in range(n):
    if a[j] > key:
        break
# print(j, n-1)
# print(j, key, a)
if abs(a[j-1] - key) >= abs(a[j] - key) and j < n-1:
    ans = [a[i], a[j]]
else:
    ans = [a[i], a[j-1]]
# ok = n
# ng = -1
# while abs(ok - ng) > 1:
#     mid = (ok + ng) // 2
#     if key <= a[mid]: ok = mid
#     else: ng = mid
# if ok < i: 
#     if comb(a[i], a[ok]) > maxi:
#         maxi = comb(a[i], a[ok])
#         ans = [a[i], a[ok]]
# if ng >= 0: 
#     if comb(a[i], a[ng]) > maxi:
#         maxi = comb(a[i], a[ng])
#         ans = [a[i], a[ng]]
print("{} {}". format(ans[0], ans[1]))

Measured memory_bytes: 84984
N = int(input())
S1 = list(input())
S2 = list(input())
n = 0
ans = 1
MOD = 10 ** 9 + 7
while n < N:
    if S1[n] == S2[n]:
        if n == 0:
            ans = 3
        elif n > 0:
            if S1[n - 1] == S2[n - 1]:
                ans *= 2
            else:
                ans *= 1
        n += 1
    elif S1[n] != S2[n]:
        if n == 0:
            ans = 6
        elif n > 0:
            if S1[n - 1] == S2[n - 1]:
                ans *= 2
            else:
                ans *= 3
        n += 2
    ans = ans % MOD
    #print(ans)
print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] abc = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
        //0 0 0 -> 0
        //1 0 0 -> 1
        //1 1 0 -> 2
        int count = 0;
        int diff = abc.Max() * 3 - abc.Sum();
        if (diff % 2 == 1)
        {
            diff -= 1;
            count += 2;
        }
        count += diff / 2;
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13396
N = int(input())
A = list(map(int, input().split()))
ans = 'DENIED'
for a in A:
  if a%2 == 0:
    if a%3 == 0 or a%5 == 0:
      continue
    else:
      break
else:
  ans = 'APPROVED'
print(ans)

Measured memory_bytes: 9176
l,r = gets.chomp.split(" ").map{|i|i = i.to_i}
#ij_min = l * (l+1)
#ij_max = r * (r-1)

if(r-l >= 2018) then puts 0
else 
  now_min = 2018
  (r-l).times do|ii|
    i = l+ii
    (r-i).times do|jj|
      j = i+jj+1
      now_min = [now_min, ((i*j)%2019)].min
    end
  end
  puts now_min
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+10;
char s[N];
int num[N];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	int ans=0;
	for(int i=2;i<=n;i++)
	{
		if(s[i]==s[i-1])
		{
			num[i]=1;
		}
	}
	
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		sum=sum+num[i];
	}
	while(1)
	{
		if(n>=2)
		for(int i=2;i<=n-1&&k;i++)
		{
			if(s[i]!=s[i-1]&&s[i]!=s[i+1])
			{
				sum=sum+2;
				s[i]=s[i-1];
				k--;
			}
		}
		int m=n;
		n= (unique(s+1, s + n+1) - s )-1;
		if(n==m)
		break;
	}	
	for(int i=2;i<=n&&k;i++)
	{
		if(s[i]!=s[i-1])
		{
			sum=sum+1;
			s[i]=s[i-1];
			k--;
		}
	}
	cout<<sum<<'\n';
   return 0;
}

Measured memory_bytes: 768
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

int di[] = {1, 0, 1, -1}, dj[] = {0, 1, 0, -1};

main {
  int n = in();
  vector<string> v(n);
  cin >> v;
  int cnt = 0;
  auto used = vectors(n, n, false);
  rep(a, n) rep(b, n) {
    queue<pair<int, int>> q;
    q.emplace(a, b);
    bool f = true;
    while (q.size()) {
      int i, j;
      tie(i, j) = q.front();
      q.pop();
      if (i < 0 || j < 0 || i >= n || j >= n || v[i][j] == 'x') continue;
      v[i][j] = 'x';
      cnt += f;
      f = false;
      rep(k, 4) q.emplace(i + di[k], j + dj[k]);
    }
  }
  cout << (cnt - 1) / 3 << endl;
}



Measured memory_bytes: 3208
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int[] abc = new int[3];
      int five =0;
      int seven = 0;
      String ans = "NO";
      for(int i=0;i<3;i++){
        abc[i] = sc.nextInt();
        if(abc[i]==5){
          five++;
        }else if(abc[i]==7){
          seven++;
        }
      }
      if(five==2&&seven==1){
        ans = "YES";
      }
      System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  vector<vector<ld> > dp(n+1, vector<ld>(n+1, 0.0));
  ld p; cin >> p;
  auto q = [](ld p) { return 1.0-p; };
  dp[1][0] = q(p);
  dp[1][1] = p;
  REPC(i, 2, n) {
    cin >> p;
    dp[i][0] = dp[i-1][0] * q(p);
    REP(j, 1, i) {
      dp[i][j] = dp[i-1][j-1] * p + dp[i-1][j] * q(p);
    }
    dp[i][i] = dp[i-1][i-1] * p;
  }
  ld ans = 0.0;
  REPC(i, (n+1)/2, n) ans += dp[n][i];
  cout << fixed << setprecision(10) << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 144364
#define yuki(x, y) for(int i = x, __yuki = y; i < __yuki; ++i)
#define yukj(x, y) for(int j = x, __yukj = y; j < __yukj; ++j)
#define yukii(x, y) for(int i = x; __yukii = y; i <= __yukii; ++i)
#define yukji(x, y) for(int j = x; __yukji = y; j <= __yukji; ++j)
#define yuk(x, y, z) for(int x = y, __yuk = z; x < __yuk; ++x)
#define yui(x, y, z) for(int x = y, __yui = z; x >= __yui; --x)
#define sclr(x) memset(x, 0, sizeof(x))
#define sclr1(x) memset(x, -1, sizeof(x))
#define scl(x, y) memset(x, y, sizeof(x))
#define ft first
#define sc second
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long lol;
lol n;
int f[2][4][2];
const int M = 1000000007;
int main(int argc, char **argv)
{
    scanf("%lld", &n);
    int t = 1;
    f[0][0][0] = 1;
    f[0][1][0] = 1;
    f[0][2][0] = 1;
    f[0][3][0] = 1;
    yuki(0, 63)
	if(n & (1ll<<i))
	{
	    f[t][0][0] = (f[t^1][0][0]*2ll+f[t^1][0][1])%M;
	    f[t][0][1] = (f[t^1][0][1]*2ll+f[t^1][0][0])%M;
	    f[t][1][0] = ((lol)f[t^1][1][0]+f[t^1][1][1]+f[t^1][0][0])%M;
	    f[t][1][1] = ((lol)f[t^1][1][1]+f[t^1][0][1]+f[t^1][0][0])%M;
	    f[t][2][0] = ((lol)f[t^1][2][0]+f[t^1][0][1]+f[t^1][0][0])%M;
	    f[t][2][1] = ((lol)f[t^1][2][1]+f[t^1][0][1]+f[t^1][0][0])%M;
	    f[t][3][0] = ((lol)f[t^1][3][0]+f[t^1][1][1]+f[t^1][0][0])%M;
	    f[t][3][1] = ((lol)f[t^1][1][1]+f[t^1][2][1]+f[t^1][0][0])%M;
	    t ^= 1;
	}
	else
	{
	    f[t][0][0] = (f[t^1][0][0]*2ll+f[t^1][0][1])%M;
	    f[t][0][1] = (f[t^1][0][1]*2ll+f[t^1][0][0])%M;
	    f[t][1][0] = f[t^1][1][0];
	    f[t][1][1] = (f[t^1][1][1]+f[t^1][1][0])%M;
	    f[t][2][0] = (f[t^1][2][0]+f[t^1][2][1])%M;
	    f[t][2][1] = (f[t^1][2][0]+f[t^1][2][1])%M;
	    f[t][3][0] = f[t^1][3][0];
	    f[t][3][1] = f[t^1][3][0];
	    t ^= 1;
	}
    printf("%d\n", f[t^1][3][0]);
    return 0;
}


Measured memory_bytes: 128
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, m;
    scan(n, m);
    long max_x = long.min;
    long min_x = long.max;
    foreach (_; 0 .. m)
    {
        long l, r;
        scan(l, r);
        // writeln(l, r);
        max_x = max(max_x, l);
        min_x = min(min_x, r);

    }
    // writeln("max", max_x);
    // writeln("min", min_x);
    if (min_x >= max_x)
    {
        writeln(min_x - max_x + 1);

    }
    else
    {
        writeln(0);
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

int main() {
	int x;
  	cin >> x;
  
  	bool stop = false;
  
  	if(x <= 3) {
      cout << 1 << endl;
    }else {
  	for(int i = x; i >= 1; i--) {
    	for(int j = 2; j <= i; j++) {
            int altx = i;
     		bool can = true;
     	    if(altx % j == 0) {
            	while(1) {
                  altx /= j;
                  if(altx % j != 0) {
                  can = false;
                  break;
                 }
   				  if(altx / j == 1) break;
                }
               }else {continue;}
              if(can) {
                cout << i << endl;
                stop = true;
             	break;
            }
          }
      	if(stop) break;
        }
    }
    
}


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

#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;

int ar[200][200];
int n, m;
int dp[200][200][2];

int solve(int i, int j, int f) {
    if (i == n){
        return 1e15;
    }
    if (j == m){
        return 1e15;
    }
    if (i == n-1 && j == m-1){
        if (ar[i][j] == 1 && f) return 0;
        else if (ar[i][j] == 0 && !f) return 0;
        return 1e15;
    }
    if (dp[i][j][f] != -1) return dp[i][j][f];
    int ans = 0;
    if (ar[i][j] == 1 && f){
        ans = min(solve(i+1, j, f), solve(i, j+1, f));
        ans = min(ans, min(solve(i+1, j, 0), solve(i, j+1, 0)));
    } else if (ar[i][j] == 1) {
        ans = 1e15;
    } else if (ar[i][j] == 0 && f){
        ans = 1e15;
    } else {
        ans = 1 + min(solve(i+1, j, 1), solve(i, j+1, 1));
        ans = min(ans, min(solve(i+1, j, 0), solve(i, j+1, 0)));
    }
    return dp[i][j][f] = ans;
}

integer main() {
    ios_base::sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            char c;
            cin >> c;
            if (c != '.') {
                ar[i][j] = 1;
            }
        }
    }
    memset(dp, -1, sizeof dp);
    cout << min(1+solve(0, 0, 1), solve(0, 0, 0)) << endl;

}


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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

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

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  string s,t;
  cin >> s >> t;
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  if ( s < t ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

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

using ll=int64_t;

int main(){
  int n; cin >>n;
  vector<int> ans(26,INT_MAX);
  rep(i,0,n) {
    vector<int> temp(26);
    string s; cin >>s;
    rep(j,0,s.size()) temp[s[j]-'a']++;
    rep(k,0,26) ans[k]=min(ans[k],temp[k]);
  }
  rep(i,0,26) {
    rep(j,0,ans[i]) cout <<char(i+'a');
  }
  cout <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        int N;
        cin >> N;
        int order[N];
        for(int i = 0; i < N; i++) {
            cin >> order[i];
            --order[i];
        }
        int k = 0;
        int ans = -1;
        int count = 0;
        for(int i=0;i<10e6;i++){
            k = order[k];
            ++count;
            if(k==1){
                ans = count;
                break;
            }
        }
        cout << ans;
    }


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    int n = s.length();
    VI a(n);
    FOR(i, 0, n)a[i] = s[i] - '0';
    if (a.front() == 0 || a.back() == 1) {
        cout << "-1\n";
        return 0;
    }
    eFOR(i, 0, n / 2) {
        if (a[i] != a[n - 2 - i]) {
            cout << "-1\n";
            return 0;
        }
    }

    int num = 2;
    vector<pair<int, int>> ans = { { 0,1 } };
    for (int i = 1; i < n; i = num - 1) {
        while (num < n && a[num - 1] == 0) {
            ans.emplace_back(i, num);
            ++num;
        }
        if (num == n)break;
        ans.emplace_back(i, num);
        ++num;
    }
    each(i, ans)cout << i.first + 1 << " " << i.second + 1 << "\n";
}

Measured memory_bytes: 2756
#include<iostream>
using namespace std;
int main(){
	int x, y, i;
	for (i = 0; i<4000; i++){
		cin >> x >> y;
		if (x == 0 && y == 0){ break; }
		else if (y >= x){ cout << x <<" "<< y << endl; }
		else{ cout << y <<" "<< x << endl; }

	}
	return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
#define int long long

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

void ans(vi a) {
    int n = a.size();
    cout << n << endl;
    rep(i, n) {
        cout << (i ? " " : "") << a[i];
    }
    cout << endl;
}

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

    int k;
    cin >> k;
    if (k == 0) {
        ans(vi{0, 0});
    }
    else if (k == 1) {
        ans(vi{2, 0});
    }
    else if (k <= 50) {
        ans(vi(k, k));
    }
    else {
        int p = 50 + (k / 50) - 1;
        if (k % 50 == 0) {
            ans(vi(50, p));
        }
        else {
            int m = k % 50;
            vi a(50, p - m);
            rep(i, m) {
                a[i] = p + 50 - (m - 1);
            }
            ans(a);
        }
    }
}


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


/**
 * @Author MaxHeap
 **/

using namespace std;
	

int main(){
  set<int> s;
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    int c; cin >> c;
    s.insert(c);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


ll N, K;

vector<pair<int, int>> p;

int main() {
	cin >> N >> K;
	p.assign(N, make_pair(0, 0));
	for (int i = 0; i < N; i++) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p.begin(), p.end());

	for (int i = 0; i < N; i++) {
		if (p[i].second < K) {
			K -= p[i].second;
			continue;
		}
		else {
			cout << p[i].first << endl;
			return 0;
		}
	}






	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>


using namespace std;

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

int main(int argc, const char * argv[]) {
    
    int N;
    cin>>N;
    
    Graph g;
    g.resize(N);
    
    //vector<int> color(N,0);  //0:未訪問 1:発見 2:訪問済み
   
    int ans[N][N];
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            ans[i][j]=0;
        }
    }
    for(int i=0;i<N-1;++i){
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    int X,Y;
    cin>>X>>Y;
    --X;
    --Y;
    g[X].push_back(Y);
    g[Y].push_back(X);
    
    for(int i=0;i<N;++i){
        vector<int>  dist(N,-1);
        dist[i]=0;
        queue<int> q;
        q.push(i);
        
        while(!q.empty()){
            int v=q.front();
            q.pop();
            for(int j=0;j<g[v].size();++j){
                int nv=g[v][j];
                if(dist[nv]!=-1)continue;
                dist[nv]=dist[v]+1;
                q.push(nv);
            }
        }
        
        
        for(int j=0;j!=N;++j){
            ans[i][j]=dist[j];
        }
        /*for(int a=0;a!=N;++a){
            for(int b=0;b!=N;++b){
                cout<<ans[a][b]<<" ";
            }
            cout<<endl;
        }*/
       
    }
    
    int a[N];
    for(int i=0;i!=N;++i){
        a[i]=0;
    }
    
    for(int i=0;i!=N;++i){
        for(int j=i+1;j!=N;++j){
            ++a[ans[i][j]];
        }
    }
    
    for(int i=1;i!=N;++i){
        cout<<a[i]<<endl;
    }
    
    
}


Measured memory_bytes: 19212
#include <stdio.h>

unsigned long gcd( unsigned long a, unsigned long b )
{
	return (b==0)? a : gcd(b,a%b);
}

unsigned long lcm( unsigned long a, unsigned long b )
{
	return a / gcd(a,b) * b;
}

int main(void)
{
	unsigned long a, b;
	
	while( fscanf(stdin,"%ld %ld\n",&a,&b) >= 0 )
	{
		printf( "%ld %ld\n", gcd(a,b), lcm(a,b) );
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

ll dp[405][405];
int l[405];
int n;

ll solve(int lhs, int rhs) {
  if(lhs == rhs) return 0;
  if(dp[lhs][rhs]) return dp[lhs][rhs];
  ll total = 0;
  for(int i = lhs; i <= rhs; i++) {
    total += l[i];
  }
  dp[lhs][rhs] = 1e18;
  for(int i = lhs; i < rhs; i++) {
    dp[lhs][rhs] = min(dp[lhs][rhs], solve(lhs, i) + solve(i+1, rhs));
  }
  dp[lhs][rhs] += total;
  return dp[lhs][rhs];
}

void solve() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> l[i];
  }
  cout << solve(0, n-1) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


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

int main() {
  string str ;
  cin >> str ;
  
  int count = 0;
  for( int i = 0 ; i < str.size() ; i ++ ){
    if ( str.at(i) == 'o' ){
      count ++;
    }
  }
  
  int F;
  F = 700 + 100 * count ;
  cout << F << endl;
  
}


Measured memory_bytes: 256
K=int(input())

if (K==1)or(K==2)or(K==3)or(K==5)or(K==7)or(K==11)or(K==13)or(K==15)or(K==17)or(K==19)or(K==23)or(K==29)or(K==31):
    print(1)
if (K==4)or(K==6)or(K==9)or(K==10)or(K==14)or(K==21)or(K==22)or(K==25)or(K==26):
    print(2)
if (K==8)or(K==12)or(K==18)or(K==20)or(K==27):
    print(5)
if K==16:
    print(14)
if K==24:
    print(15)
if (K==28)or(K==30):
    print(4)
if K==32:
    print(51)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int const limit = 100005;

struct Edge{
    int to;
    ll cost;
};

ll dist[limit];
vector<Edge> adj[limit];


void dfs(int to, int from, ll d){
    dist[to] = d;

    for(int i=0; i<adj[to].size(); i++){
        if(adj[to][i].to == from) continue;
        else dfs(adj[to][i].to, to, d+adj[to][i].cost);
    }

}

int main(){
    int N; cin >> N;
    for(int i=0; i<N-1; i++){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        adj[a].push_back({b, c});
        adj[b].push_back({a, c});
    }

    int q, k; cin >> q >> k;
    k--;
    dfs(k, -1, 0);

    for(int i=0; i<q; i++){
        int x,y; cin >> x >> y;
        x--; y--;
        cout << dist[x] + dist[y] << endl;
    }
     
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<char> S;


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a-b-c<0)cout<<-1*(a-b-c)<<endl;
    else cout<<"0"<<endl;
    return 0;

}

Measured memory_bytes: 256
#2 個のボタンがあり、大きさはそれぞれ A,B です。大きさ X のボタンを押すと、X 枚のコインを獲得し、そのボタンの大きさが 1 小さくなります。
#あなたは、いずれかのボタンを押すことを 2 回行います。 同じボタンを 2 回押しても構いません。
#最大で何枚のコインを獲得できるでしょうか。

#解説
#大きい方のボタンを選んで押すことを 2 回繰り返すのが最適です。基本的には同じボタンを押しますが、 
#A = B のときは両方のボタンを 1 回ずつ押すのが最適なので、注意する必要があります。
#実装では、以下の 3 つのパターンについて場合分けすると比較的簡単に書くことができます。
#• A > B の場合: A+(A−1) が答えになります。 • A < B の場合: B + (B − 1) が答えになります。 • A = B の場合: A+B が答えになります。

A, B =map(int, input().split())

if A>B:
    ans = A+(A-1)
elif A==B:
    ans = A+B
else:
    ans = B+(B-1)
print(ans)

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++){
		if (s[i] != t[i]){
			char c = s[i];
			for (int j = 0; j < s.size(); j++){
				if (j < i){
					if (t[i] == s[j]){
						cout << "No";
						return 0;
					}
				}
				if (s[j] == c)
					s[j] = t[i];

				else if (s[j] == t[i])
					s[j] = c;
			}
		}
	}
	if (s == t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int n, l[1000006] = {}, r[1000006] = {}, c = 0;
bool b[1000006] = {};
ll m, w[1000006] = {};

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    while (n--) {
        string s;
        cin >> s;
        int d = 0;
        fr(s.length()) {
            if (s[i] == '0') {
                if (!l[d]) l[d] = ++c, w[c] = w[d] + 1;
                d = l[d];
            } else {
                if (!r[d]) r[d] = ++c, w[c] = w[d] + 1;
                d = r[d];
            }
        }
        b[d] = 1;
        //cout << d << '\n';
    }
    //fr(c + 1) cout << l[i] << ' ' << r[i] << '\n';
    //fr(c + 1) cout << w[i] << ' '; cout << '\n';
    ll z = 0;
    fr(1000000) if (!b[i]) {
        if ((!l[i] && r[i]) || (l[i] && !r[i])) z ^= ((m - w[i]) & (w[i] - m));
        
    }
    //cout << x << ' ' << y << '\n';
    if (z) cout << "Alice";
    else cout << "Bob";
    /*
     A:
     x
     1 2
     2 3
     1 4
     1 1 1
     1 1 2
     1 2 2
     2 2 2
     1 1 3
     1 2 3
     2 2 3
     2 3 3
     1 1 2 3
     1 2 3 3
     1 1 1 2
     1 2 2 2
     1 1 1 1 2
     1 1 1 2 2
     1 1 2 2 2
     1 2 2 2 2
     2 2 2 2 2
     B:
     1 1
     2 2
     2 4
     1 1 1 1
     1 1 2 2
     2 2 2 2
     1 1 1 3
     1 2 2 3
     1 3
     */
}


Measured memory_bytes: 7376
n,m=map(int,input().split())
from collections import defaultdict
d=defaultdict(int)
for k in map(int,input().split()):
  d[k]+=1
for i in range(m):
  b,c=map(int,input().split())
  d[c]+=b
sm=0
c=0

for k,v in sorted(d.items(),reverse=True):
  if c+v<n:
    sm+=k*v
    c+=v
  elif c+v==n:
    sm+=k*v
    break
  else:
    sm+=k*(n-c)
    break
print(sm)
  
  

Measured memory_bytes: 43756