akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N, X;
    cin >> N >> X;
    vector<long> L(N);
    long count = 1;
    long pos = 0;
    for(size_t i=0;i<N; i++)
    {
        cin >> L[i];
        pos += L[i];
        if(pos <= X) count++;
        else break;
    }
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 19,2019
 * 
 */

#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 
    ivv(a);
    sv(s);
    cout<<(a>=3200?s:"red")<<endl;
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];

    map<string, int> mp;
    for (int i = 0; i < n; i++)
        mp[s[i]]++;

    int mx = 0;
    for (int i = 0; i < n; i++)
        if (mx < mp[s[i]])
            mx = mp[s[i]];

    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++)
    {
        if (iter->second == mx)
            cout << iter->first << endl;
    }

    return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define eprintf(...) fprintf(stderr,__VA_ARGS__)

ll n;
int m,idx;
vector<int> a;

int main(){
	scanf("%lld", &n);
	ll nn = n;
	n++;
	for(int j = 40; j >= 0; j--){
		if (n >> (j + 1)) {
			++idx;
			a.insert(a.begin() + a.size() / 2, idx);
			a.push_back(idx);
		}
		if ((n >> j) != 1 && (n >> j &1)) {
			++idx;
			a.insert(a.begin(), idx);
			a.push_back(idx);
		}
	}
	printf("%d\n",a.size());
	for(int i=0; i<int(a.size()); i++) printf("%d%c", a[i], " \n"[i + 1 == a.size()]);
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int wait[8];
	int jenny[15]={1,2,1,2,1,4,1,4,1,2,1,2,1,4,1};
	int priority[8]={7,3,6,2,4,0,5,1};
	int i,j,cannot,min,pos;

	while(scanf("%d %d %d %d %d %d %d %d",wait,wait+1,wait+2,wait+3,wait+4,wait+5,wait+6,wait+7)!=EOF)
	{
		for(i=0;i<8;i++)
		{
			cannot=0;
			for(j=0;j<8;j++)
			{
				if(wait[j]>jenny[i+j])
				{
					cannot+=wait[j]-jenny[i+j];
				}
			}
			if(i==0)
			{
				min=cannot;
				pos=i;
			}
			else if(min>cannot)
			{
				min=cannot;
				pos=i;
			}
			else if(min==cannot)
			{
				if(priority[i]>priority[pos])
				{
					min=cannot;
					pos=i;
				}
			}
		}
		printf("%d %d %d %d %d %d %d %d\n",jenny[pos],jenny[pos+1],jenny[pos+2],jenny[pos+3],jenny

[pos+4],jenny[pos+5],jenny[pos+6],jenny[pos+7]);
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
INF = 1000000000000000000
ans = 1
flag = 0

for cnt in range(n):
    if a[cnt] == 0:
        print(0)
        flag = 1
        break

if flag == 0:
    for cnt in range(n):
        ans *= a[cnt]
        if ans > INF:
            print(-1)
            flag = 1
            break

if flag == 0:
    print(ans)


Measured memory_bytes: 21640
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
using namespace std;
#define MOD          1000000007
#define PI           3.14159265358979
#define rep(i, n)    for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)   for (auto i : v)
#define all(x)       (x).begin(), (x).end()
#define rall(x)      (x).rbegin(), (x).rend()
#define pb(x)       push_back(x)
#define mp(x, y)     make_pair((x), (y))
#define fi           first
#define se           second
#define setp(x)      setprecision(x)
#define mset(m, v)   memset(m, v, sizeof(m))
//#define int          long long
//static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
static const int INF =        0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef long long             ll;
typedef vector<int>           vi;
typedef vector<double>        vd;
typedef vector<long long>     vll;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef pair<int, int>        pii;
typedef pair<long, long>      pll;
typedef vector<pii>           vpii;
typedef vector<pll>           vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

int main() { 
        ll a[7];
        rep(i, 7) cin >> a[i];
        ll res = 0;
        res += a[0] - (a[0] & 1) + a[3] - (a[3] & 1) + a[4] - (a[4] & 1);
        res += a[1];
        ll ans = res;
        res = 0;
        res += 3;
        if (a[0] >= 1 && a[3] >= 1 && a[4] >= 1) {
                a[0] --, a[3] --, a[4] --;
                res += a[0] - (a[0] & 1) + a[3] - (a[3] & 1) + a[4] - (a[4] & 1);
                res += a[1];
                amax(ans, res);
        }
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


int main(){
	ll n,m; cin >>n>>m;
	string s,t; cin >>s>>t;
	if(s[0]!=t[0]){
		cout << -1 << endl;
		return 0;
	}
	ll g=GCD(n,m);
	for(int i=0;i<g;i++){
		if(s[i*n/g]!=t[i*m/g]){
			cout << -1 << endl;
			return 0;
		}
	}
	ll ans=n*m/g;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n;
    long int k;

    scanf("%d %ld", &n, &k);


    vector<long int> num_count(100000, 0);

    for (int i = 0; i < n; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        num_count[a-1] += b;

    }

    int ans;

    for (int i = 0; i < num_count.size(); i++) {
        k -= num_count[i];
        if (k <= 0) {
            ans = i + 1;
            break;
        }
    }

    printf("%d", ans);

}


Measured memory_bytes: 1024
#include<cstdio>
long long Mod=998244353;
long long n,a,b,k;
long long Ans;
long long frc[300001]={1,1},inv[300001]={1,1};
long long C(int x,int y){
	return frc[x]*inv[y]%Mod*inv[x-y]%Mod;
}
int main(){
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	for(int i=2;i<=n;++i) frc[i]=frc[i-1]*i%Mod;
	for(int i=2;i<=n;++i) inv[i]=(Mod-Mod/i)*inv[Mod%i]%Mod;
	for(int i=2;i<=n;++i) inv[i]=inv[i-1]*inv[i]%Mod;
	for(int i=0;i<=n&&i*a<=k;++i){
		if((k-i*a)%b) continue;
		int j=(k-i*a)/b;
		if(j>n) continue;
		Ans=(Ans+C(n,i)*C(n,j))%Mod;
	} printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> v(n);
    vector< pair<int,int> > even, odd;
    for(int i=0; i<n; i++) {
        int v;
        cin >> v;
        if(i%2 == 0) {
            bool isFound = false;
            for(int i=0; i<even.size(); i++) {
                if(even.at(i).first == v) {
                    even.at(i).second ++;
                    isFound = true;
                    break;
                }
            }
            if(isFound == false) {
                even.emplace_back(v, 1);
            }
        } else {
            bool isFound = false;
            for(int i=0; i<odd.size(); i++) {
                if(odd.at(i).first == v) {
                    odd.at(i).second ++;
                    isFound = true;
                    break;
                }
            }
            if(isFound == false) {
                odd.emplace_back(v, 1);
            }
        }
    }
    even.emplace_back(0,0);
    odd.emplace_back(0,0);

    sort(even.begin(), even.end(), [](const auto &lhs, const auto &rhs) {return lhs.second > rhs.second;});
    sort(odd.begin(), odd.end(), [](const auto &lhs, const auto &rhs) {return lhs.second > rhs.second;});
    if(even.at(0).first != odd.at(0).first) {
        cout << n - even.at(0).second - odd.at(0).second << endl;
    } else {
        cout << n - even.at(0).second - max(even.at(1).second, odd.at(1).second) << endl;
    }
    return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read();
    string S = read_s();
    int K = read();
    for (int i = 0; i<S.size(); i++) {
        if (S[i]==S[K-1]) putchar(S[i]);
        else putchar('*');
    }
    putchar('\n');
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

typedef struct pair{
  int x,y;
}point;

point data[100000];

int compare_int(const void *b,const void *a){
  return (*(point*)a).y < (*(point*)b).y;
}


int main(void){
  int N,M;
  scanf("%d%d",&N,&M);

  for(int i = 0;i < M;i++){
    scanf("%d%d",&data[i].x,&data[i].y);
  }

  qsort(data,M,sizeof(point),compare_int);

  int pos = data[0].y;
  int ans = 1;
  for(int i = 1;i < M;i++){
    if(pos <= data[i].x){
      ans++;
      pos = data[i].y;
    }
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<string>ans;
string a;
main()
{
	cin>>a;
	int n;cin>>n;n--;
	for(int c=1;c<=5;c++)
	{
		for(int i=0;i+c<=a.size();i++)ans.push_back(a.substr(i,c));
	}
	sort(ans.begin(),ans.end());
	ans.erase(unique(ans.begin(),ans.end()),ans.end());
	cout<<ans[n]<<endl;
}


Measured memory_bytes: 1660
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, T b ) { if ( a < b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, T b ) { if ( a > b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )


int main()
{
	int N, M, C;
	cin >> N >> M >> C;

	vector<int> B( M );
	rep( i, M )
	{
		cin >> B[i];
	}

	vector<vector<int>> A( N, vector<int>( M ) );
	rep( i, N )
	{
		rep( j, M )
		{
			cin >> A[i][j];
		}
	}

	vector<int> ans( N, 0 );
	rep( i, N )
	{
		rep( j, M )
		{
			ans[i] += A[i][j] * B[j];
		}
		ans[i] += C;
	}

	int counter = 0;
	rep( i, N )
	{
		if ( ans[i] > 0 )
		{
			counter++;
		}
	}

	cout << counter << endl;

	return ( 0 );
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 998244353
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 300003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
long long kiri[mx],kanan[mx],n,idx;
vector<long long>ve;
long long l;
string ss[mx];
void upd(long long now,long long ke,int apa){
	if(ke+1==ss[apa].length())return;
	if(ss[apa][ke+1]=='0'){
		if(!kiri[now])kiri[now]=++idx;
		upd(kiri[now],ke+1,apa);
	}
	else{
		if(!kanan[now])kanan[now]=++idx;
		upd(kanan[now],ke+1,apa);
	}
}
long long hit=0;
bool sudah[mx];
void coba(long long now,long long ke){
	if(sudah[now])return;
	assert(ke<l);
	sudah[now]=true;
	long long cnt=0;
	hit++;
	assert(hit<=300000);
	if(kiri[now])cnt++;
	if(kanan[now])cnt++;
	if(cnt==0)return;
	if(cnt==1){
		if(l-ke-1>0)ve.pb(l-ke-1);
		assert(ve.size()<=100000);
	}
	if(kiri[now])coba(kiri[now],ke+1);
	if(kanan[now])coba(kanan[now],ke+1);
}

long long mex(long long x){
	long long ret=1;
	assert(x>0);
	while(x%2==0)ret=ret*2,x/=2;
	return ret;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>l;
	int total=0;
	for(long long i=1;i<=n;i++){
		cin>>ss[i];
		total+=ss[i].length();
	}
	idx=1;
	for(long long i=1;i<=n;i++){
		upd(1,-1,i);
	}
	coba(1,-1);
	long long grundy=0;
	assert(ve.size()<=100000);
	for(long long i:ve){
		grundy=grundy^mex(i);
	//	debug(i);
	//	debug(grundy);
	}
	//debug(grundy);
	if(grundy==0){
		cout<<"Bob\n";
	}
	else cout<<"Alice\n";
}




Measured memory_bytes: 11844
import Control.Applicative

main = do
    [d,n] <- map read . words <$> getLine
    print $ solve d n

solve :: Int -> Int -> Int
solve d n | d == 0 = (filter (\x-> mod x 100 /= 0) [1..]) !! (n-1)
          | d == 1 = (filter (\x-> mod x 100 /= 0) [1..]) !! (n-1) * 100
          | d == 2 = (filter (\x-> mod x 100 /= 0) [1..]) !! (n-1) * 10000

Measured memory_bytes: 508
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool a=true;
  for(int i=1;i<s.size();i++){
    if(s[i-1]==s[i])a=false;
  }
  puts(a?"Good":"Bad");
}

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

int N,M;
vector<int> H;

int main() {
    cin>>N>>M;
    H.resize(N);
    for (int i=0; i<N; i++) cin>>H[i];
    vector<bool> flag(N,true);
    for (int i=0; i<M; i++) {
        int temp1,temp2; cin>>temp1>>temp2;
        if (H[temp1-1]>H[temp2-1]) flag[temp2-1]=false;
        else if (H[temp1-1]<H[temp2-1]) flag[temp1-1]=false;
        else flag[temp1-1]=false,flag[temp2-1]=false;
    }
    int ans=0;
    for (int i=0; i<N; i++){
        if (flag[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3732
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		String b=scan.next();
		int R=0;
		int B=0;
		for(int i=0;i<n;i++) {
			char ch=b.charAt(i);
			if(ch=='B') {
				B++;
			}
			else {
				R++;
			}
		}
		System.out.println(R>B?"Yes":"No");
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second

vector<int> ans;
void dfs(vector<pair<vector<int>, vector<int>>> &G, int n, int vert, int color = 0)
{
    static vector<bool> visited(n + 1);
    if(visited[vert]) return;
    visited[vert] = true;
    ans[vert] = color;
    for(int v : G[vert].fi) dfs(G, n, v, color);
	color ^= 1;
	for(int v : G[vert].se) dfs(G, n, v, color);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
    cin >> n;
	ans = vector<int>(n + 1);
    vector<pair<vector<int>, vector<int>>> G(n + 1);
    forn(i, n - 1)
    {
        int u, v, w;
        cin >> u >> v >> w;
		if(w % 2) G[u].se.push_back(v), G[v].se.push_back(u);
		else G[u].fi.push_back(v), G[v].fi.push_back(u);
    }
	dfs(G, n, 1);
	fori(i, 1, n + 1) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 12672
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

orders_ = []
for order in [A, B, C, D, E]:
  if order % 10 == 0:
    orders_.append((order, 0))
  else:
    orders_.append((order, 10 - order % 10))
orders = sorted(orders_, key=lambda x: x[1])
tet = 0
for order in orders[:-1]:
  tet += order[0] + order[1]
tet += orders[-1][0]  
print(tet)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}


int main(){
    lint N,a,b;
    cin>>N>>a>>b;
    cout<<min(a*N,b);
}

Measured memory_bytes: 256
N=int(input())
X=list(map(int,input().split()))
cost=0
for i in range(len(X)):
    cost=cost+X[i]**2

for i in range(1,101):
    cost2=0
    for j in range(len(X)):
        cost2=cost2+(X[j]-i)**2
    cost=min(cost,cost2)

print(cost)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
    int n,l,r,a[100],top=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)a[i]=0;
    for(int i=1;i<=n;i++){
        scanf("%d%d",&l,&r);
        a[l]+=r;
    }
    for(int i=1;i<=n;i++)if(a[i]>a[top])top=i;
    printf("%d %d\n",top,a[top]);
}

Measured memory_bytes: 2724
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
using namespace std;

void Onigiri()
{
  int x,n;
  cin>>x>>n;
  set<int> s;
  rep(i,0,n)
  {
   int x;
   cin>>x;
   s.insert(x);
  }
  for(int i=0;i<=1000;i++)
  {
   if(s.find(x-i)==s.end())
   {
      cout<<x-i;
      return;
   }
   if(s.find(x+i)==s.end())
   {
      cout<<x+i;
      return;
   }
  }


}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("in", "r", stdin);freopen("out", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void printVector(const std::vector<double>& vec) {
    for (double value : vec) {
		std::cout << value << " ";
    }
	std::cout << std::endl;
}

int main(){
	std::string s,t;
	std::cin >> s;
	std::cin >> t;
	for(int i ; i < s.size(); i ++) {
		if(s[i] != t[i]){
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	if(s.size() == t.size() - 1) {
		std::cout << "Yes" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
string s,v;
int32_t main(){
CODE_START;
cin>>s;
n=s.size();
for(ll i=0;i<n;i++)
if(s[i]!='B'){
    if(s[i]=='0'){
        v.pb('0');
    }else if(s[i]=='1'){
    v.pb('1');
    }
}else if(s[i]=='B'){
if(v.size()>=1){
    v.erase(v.size()-1,1);
}
}
cout<<v;
return 0;}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
dic = defaultdict(list)

for i in range(1,N+1):
  inf = input().split()
  a = int(inf[0])
  b = int(inf[1])
  dic[b] += [a]

keys = list(dic.keys())
keys.sort()
ps = 0

for k in keys:
  ls = dic[k]
  need = sum(ls)
  ps += need
  if ps>k:
    print('No')
    break
else:
  print('Yes')


Measured memory_bytes: 53192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;

int main() {
  ll h,w,d;
  cin >> h >> w >> d;
  vector<pll> a(h*w+1);
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      ll temp;
      cin >> temp;
      a[temp]=pll(i,j);
    }
  }
  vec p(h*w+1);
  for(ll i=1;i<=d;i++) {
    for(ll j=i+d;j<=h*w;j+=d) {
      p[j]=p[j-d]+abs(a[j].first-a[j-d].first)+abs(a[j].second-a[j-d].second);
    }
  }
  ll q;
  cin >> q;
  vec l(q);
  vec r(q);
  for(ll i=0;i<q;i++) {
    cin >> l[i] >> r[i];
  }
  for(ll i=0;i<q;i++) {
    cout << p[r[i]]-p[l[i]] << endl;
  }
}

Measured memory_bytes: 4864
N,K=map(int,input().split())
A=[int(x)-1 for x in input().split()]

seen={0}
town=0
while K>0:
    town=A[town]
    K-=1
    if town in seen:
        break
    seen.add(town)

start=town
i=0
while K>0:
    town=A[town]
    i+=1
    K-=1
    if town is start:
        break

K=K%i if i>0 else 0
while K>0:
    town=A[town]
    i+=1
    K-=1

print(town+1)


Measured memory_bytes: 112708
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,k; string s; cin >> n >> s >> k;
  
  rep(i,ll(s.size())){
    if(s[i] != s[k-1]){
      s[i] = '*';
    }
  }
  
  cout << s << endl;
  
  
}

Measured memory_bytes: 3612
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int A = sc.nextInt();
        double[] H = new double [N];
        for (int i = 0; i < N; ++i) {
            H[i] = sc.nextInt();
        }

        double[] dif = new double [N];
        int ans = 0;
        for (int i = 0; i < N; ++i) {
            dif[i] = Math.abs(T - H[i] * 0.006 - A);
            if(dif[i] < dif[ans]) {
                ans = i;
            }
        }

        System.out.println(ans + 1);
	}
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int p[22000];
int a[22000], b[22000];
signed main() {
    cin >> N;
    reps(i, N) { cin >> p[i]; }
    reps(i, N) {
        a[p[i]] += i, a[N + 1] -= i;
        b[1] += i, b[p[i] + 1] -= i;
    }
    reps(i, N) { a[i] += a[i - 1], b[i] += b[i - 1]; }
    reps(i, N) { cout << a[i] + i << " "; }
    cout << endl;
    reps(i, N) { cout << b[i] + N - i << " "; }
    cout << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
int main()
{
    int b=0;
    string s;
    cin >> s;
    string ans="AC";
    if(s[0]!='A')
        ans="WA";
    int a=s.size();
    for(int i=1; i<a; i++)
    {
        if(isupper(s[i]))
        {
            if(i==1||i==a-1||s[i]!='C')
            {
                ans="WA";
            }
            b++;
        }
    }
    if(b!=1)
        ans="WA";
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define N 105

int cnt[N];

int main(void) {
	int n, k;
	scanf("%d%d", &n, &k);
	CL(cnt, 0);
	REP(i, k) {
		int d;
		scanf("%d", &d);
		REP(j, d) {
			int x;
			scanf("%d", &x);
			x--;
			cnt[x]++;
		}
	}

	int ans = 0;
	REP(i, n) {
		if (cnt[i] == 0) {
			ans++;
		}
	}

	printf("%d\n", ans);
}


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

string sa, sb, sc;
int main(){
  cin >> sa >> sb >> sc;
  char turn = sa[0];
  while(1){
      if(turn == 'a'){
          if(sa.size()==0) break;
          turn = sa[0];
          sa = sa.substr(1,sa.size()-1);
      }
      else if(turn == 'b'){
          if(sb.size()==0) break;
          turn = sb[0];
          sb = sb.substr(1,sb.size()-1);
      }
      else if(turn == 'c'){
          if(sc.size()==0) break;
          turn = sc[0];
          sc = sc.substr(1,sc.size()-1);
      }
  }
if(turn == 'a') cout << 'A' << endl;
if(turn == 'b') cout << 'B' << endl;
if(turn == 'c') cout << 'C' << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 硬貨の入力
		int A = sc.nextInt();
      	int B = sc.nextInt();
        int C = sc.nextInt();
      	String result = (A + B >= C) ? "Yes" : "No";
		// 出力
		System.out.println(result);
	}
}

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

int N;
vector<vector<pair<int, long long>>> G;
vector<int> color;
vector<bool> seen;

void Input(){
    cin >> N;
    G.assign(N, vector<pair<int, long long>>());
    color.assign(N, 0);
    seen.assign(N, false);
    for (int i = 1; i < N; i++) {
        int a, b; long long c; 
        cin >> a >> b >> c; a--; b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }
}

void dfs(int now){
    seen[now] = true;
    for (auto e : G[now]) {
        int v; long long l; tie(v, l) = e;
        if (seen[v]) continue;
        if (l % 2 == 0) {
            color[v] = color[now];
        } else {
            color[v] = color[now] * -1;
        }
        dfs(v);
    }
}

int main(){
    Input();
    int s = 0;
    for (int i = 0; i < N; i++) {
        if (G[i].size() == 1) {s = i; break;}
    }
    color[s] = 1;
    dfs(s);
    for (auto c : color) {
        if (c != 1) cout << 0 << endl;
        else cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5+3;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n,k;
	cin>>n>>k;
	int a;
	vector<int> count;
	set<int> kind;
	rep(i,n+1){
		count.push_back(0);
	}
	rep(i,n){
		cin>>a;
		kind.insert(a);
		count[a]++;
	}

	sort(all(count));
	int ci = 0;
	while(ci < count.size() && count[ci] == 0){
		ci++;
	}
	ll nas = 0;
	rep(i, kind.size()-k){
		nas += count[ci+i];
	}
	cout<<nas<<endl;
	return 0;
}


Measured memory_bytes: 10356
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    multiset<ll> S;
    ll N, M,j;
    cin >> N >> M;
    rep(i,N)
    {
        cin >> j;
        S.insert(j);
    }
    rep(i,M)
    {
    auto maxitr = --S.end();
    int max = *maxitr;
    S.erase(maxitr);
    S.insert(max/2);
    }
    ll ans = 0;
    for(auto i : S)
    {
        ans += i;
    }
    cout << ans;
    return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  int q,w;
  q=max(-1000000,b-a+1);
  w=min(b+a-1,1000000);
  int ans=q;
  while (q<=w) {
    cout<<q<<" ";
    q+=1;
  }
}



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

int main() {
  int N;
  int l;
  int r;
  int s = 0;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    cin >> l >> r;
    s += r - l + 1;
  }
  
  cout << s << endl;
}

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

int main()
{
  int64_t a,b,k;
  cin >> a >> b >> k;
  
  if(k >= a){
    k -= a;
    a = 0;
    if(k >= b){
      b = 0;
    }else{
      b -= k;
    }
  }else{
    a -= k;
  }
  
  cout << a << " " << b << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,k; cin>>n>>k;
    int ans=0;
    vector<int> x(n);
    for(int i=0; i<n; i++){
        cin>>x.at(i);
        ans+=2*min(abs(x.at(i)),abs(x.at(i)-k));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int N = 10000;
const int Q = 500;

bool search(int s[], int n, int se)
{
	for (int i = 0; i < n; i++)
	{
		if (s[i] == se)
			return true;
	}
	return false;
}


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

	int S[N], T[Q], n, q, num;
	num = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> S[i];
	cin >> q;
	for (int i = 0; i < q; i++)
		cin >> T[i];

	for (int i = 0; i < q; i++)
	{
		if (search(S, n, T[i]))
			num++;
	}

	cout << num << endl;
	return 0;
}



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

L = []
for i in range(100000):
	L.append(0)

for i in range(N):
	a, b = list(map(int, input().split()))
	L[a - 1] += b

sm = 0
for i in range(100000):
	sm += L[i]
	if sm >= K:
		print(i + 1)
		break

Measured memory_bytes: 5904
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin>>n>>k;
    set<int>s;
    map<int,int>mp;
    while(n--)
    {
        int a;
        cin>>a;
        s.insert(a);
        mp[a]++;
    }
    vector<pair<int,int> >v;
    for(auto i:s)
    {
        v.push_back({mp[i],i});
    }
    int cnt=0;
    if(v.size()>k){
        sort(v.begin(),v.end());
        for(int i=0;i<v.size()-k;i++)
            cnt+=v[i].first;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 23900
#include <iostream>
#include<string>
#include<fstream>
#include<vector>
#include <algorithm>
#include <set>
#include <math.h>
using namespace ::std;
vector<int> v, a;
#define INT_MAX 2100000000
signed  main()
{
	int n, k;
	cin >> n;
	cin >> k; 
	v.resize(n);
	a.resize(n, INT_MAX);
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	a[0] = 0;

	for (int i = 1; i<n; i++)
	{
		for (int j = 1; j <= k && i - j >= 0; j++)
			a[i] = min(a[i], a[i - j] + abs(v[i - j] - v[i]));

	}
	cout << a[n - 1];
	cin >> n;
}
//   aaaddda

Measured memory_bytes: 1024
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long total = 0;

        for(int i = 0; i<n; i++) {
            a[i] = sc.nextInt();
            total += Math.abs(a[i]);
        }

        Arrays.sort(a);
////        for(long i : a) {
////            System.out.print(i+ " ");
////        }
//        System.out.println();

        int cnt = 0;
        for(int i = 0; i<n; i++) {
            if(a[i]>=0) break;
            cnt++;
        }
        if(cnt == 0 ) {
            System.out.println(total-a[0]*2);
            System.out.println(a[0] +" "+ a[1]);
            a[1] = a[0]-a[1];
            for(int i = 1; i<n-2; i++) {
                System.out.println(a[i] +" "+ a[i+1]);
                a[i+1] = a[i] - a[i+1];
            }
            if(n!=2) System.out.println(a[n-1]+" "+a[n-2]);
            return;
        }
        if(cnt == n) {
            System.out.println(total+a[n-1]*2);
            System.out.println(a[n-1] +" "+ a[n-2]);
            a[n-2] = a[n-1]-a[n-2];
            for(int i = n-2; i>0; i--) {
                System.out.println(a[i] +" "+ a[i-1]);
                a[i-1] = a[i] - a[i-1];
            }
            return;
        }
        int minus = cnt;
        int plus = n-cnt;
        int left = 0;
        int right = n-1;
        System.out.println(total);
        for(int i = 0; i<n-1; i++) {
            if(minus<plus) {
                System.out.println(a[left] + " " + a[right]);

                plus--;
                a[left] = a[left]-a[right];
                right--;
            }
            else {
                System.out.println(a[right] + " " + a[left]);
                minus--;
                a[right] = a[right]-a[left];
                left++;
            }
        }


    }

}

Measured memory_bytes: 103996
#include<iostream>

using namespace std;

int N;
int a[112345];
long long int ans[2];
int main () {
    cin >> N;
    for(int i=0; i<N; i++) cin >> a[i];
    for(int i=0; i<2; i++) {
        long long int sum = 0;
        for(int j=0; j<N; j++) {
            sum += a[j];
            if(j % 2 == i ) {
                if(sum <= 0) {
                    ans[i] += 1 - sum;
                    sum = 1;
                }
            } else {
                if(sum >= 0) {
                    ans[i] += sum + 1;
                    sum = -1;
                }
            }
        }
    }
    cout << min(ans[0],ans[1]) << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	int w, h, x, y, r;
	
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	if((x - r) < 0 || (y - r) < 0 || (x + r) > w || (y + r) > h){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	
	return 0;
} 


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define endl "\n"
#define INF (int)1e9
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    int ok = a <= 9 and b <= 9;

    if (ok)
    {
        cout << a * b << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,k;
    cin>>n>>k;
    vector<vector<ll>> a(k);
    for(int i=0;i<n;i++){
        ll c,v;
        cin>>c>>v;
        c--; v*=2;
        a[c].push_back(v);
    }
    vector<pair<ll,pll>> A;
    priority_queue<pll> Tri;
    for(int i=0;i<k;i++){
        sort(a[i].begin(),a[i].end(),greater<ll>());
        a[i][0]+=a[i][1];
        a[i][0]/=2;
        a[i][1]=a[i][0];
        if(a[i].size()>=3){
            Tri.push({a[i][0]+a[i][1]+a[i][2],i});
        }
        for(int t=0;t<a[i].size();t++){
            A.push_back({a[i][t],{i,n-t}});
        }
    }
    priority_queue<pair<ll,pll>> Sgl;
    priority_queue<pair<ll,pll>,vector<pair<ll,pll>>,greater<pair<ll,pll>>> D_Sgl;
    priority_queue<pll,vector<pll>,greater<pll>> D_Dbl;
    sort(A.begin(),A.end(),greater<pair<ll,pll>>());
    ll sum=0;
    vector<ll> cnt(k,0);
    for(int i=0;i<n;i++){
        cnt[A[i].S.F]++;
        if(A[i].S.S!=n-0){sum+=A[i].F;}
        if(A[i].S.S==n-1){sum+=A[i].F;}
        ll ans=-E;
        if(A[i].S.S!=n-0){ans=sum;}
        else{
            while(!Sgl.empty() && Sgl.top()>=A[i]){Sgl.pop();}
            while(!Tri.empty() && A[i]<pair<ll,pll>(a[Tri.top().S][0],pll(Tri.top().S,n-0))){Tri.pop();}
            while(!D_Dbl.empty() && cnt[D_Dbl.top().S]==3){D_Dbl.pop();}
            if(!Sgl.empty()){
                ans=max(ans,sum+Sgl.top().F);
            }
            if(!D_Sgl.empty()){
                ans=max(ans,sum-D_Sgl.top().F+A[i].F*2);
            }
            if(!D_Dbl.empty() && !Tri.empty()){
                ans=max(ans,sum-D_Dbl.top().F+Tri.top().F);
            }
        }
        cout<<(ans==-E?-1:ans/2)<<endl;
        if(A[i].S.S<=n-2){
            D_Sgl.push(A[i]);
        }
        if(A[i].S.S==n-1 || A[i].S.S<=n-3){
            D_Dbl.push({a[A[i].S.F][n-A[i].S.S]+a[A[i].S.F][n-A[i].S.S-1],A[i].S.F});
        }
        if(A[i].S.S==n-1){
            for(int t=2;t<a[A[i].S.F].size();t++){
                Sgl.push({a[A[i].S.F][t],{A[i].S.F,n-t}});
            }
        }
    }
    
    
    
    return 0;
}


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

using namespace std;

typedef long long ll;

constexpr int M = 1000 * 1000 * 1000 + 7;

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int pat[51];
int arr[51];

//レベルlvバーガーの下からx層食べた時に食えるパティの数
int rec(int lv, int x)
{
	if (x == 1) { 
		if(lv == 0) return 1;
		else return 0;
	}
	//lv-1バーガー一個目に差し掛かる
	else if (arr[lv - 1] + 1 >= x) {
		return rec(lv - 1, x - 1);
	}
	//真ん中のパティが食える
	else if (arr[lv - 1] + 2 >= x) {
		return pat[lv - 1] + 1;
	}
	//二個目に差し掛かる
	else if (arr[lv - 1] * 2 + 2 >= x) { 
		return rec(lv - 1, x - (arr[lv - 1] + 2)) + pat[lv - 1] + 1; 
	}
	//全部食える
	else { 
		return pat[lv - 1] * 2 + 1;
	}
}

signed main() {
	int N, X;
	cin >> N >> X;

	for (int i = 0; i < 51; i++) {
		if (i == 0) { 
			arr[0] = 1; 
			pat[0] = 1;
			continue;
		}
		pat[i] = 2 * pat[i - 1] + 1;
		arr[i] = 2 * arr[i - 1] + 3;
	}

	//int lv = N;
	//rec(2, 4);

	cout << rec(N, X) << "\n";



	return 0;
}

Measured memory_bytes: 256