akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x));
#define SORT(x) sort(ALL(x));
#define SUM(x) accumulate(ALL(A), 0);
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll N,W;
	ll result=0;
	ll dp[101][10100] = {};
	memset(dp, 0, sizeof(dp));
	cin>>N>>W;
	VI wei(N),val(N);
	REP(i, N) cin >> val[i]>>wei[i];
	REP(i,N){
		FOR(j,0,W){
			if(j>=wei[i]) dp[i+1][j]=max(dp[i][j-wei[i]]+val[i],dp[i][j]);
			else dp[i+1][j]=dp[i][j];
		}
	}
	result=dp[N][W];

	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}



Measured memory_bytes: 11196
//{{{
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
const int MOD = 1e9+7;
//}}}

int main(void){
	int N, A;
	cin >> N >> A;
	N %= 500;
	bool ans = A >= N;
	puts(ans ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
h_list = list(map(int, input().split()))
dp = [float('INF') for i in range(N)]
dp[0] = 0

def change_min(a, b):
  if a > b: return b
  else: return a

for i in range(N):
  for j in range(1, K + 1):
    if i + j > N - 1: continue
    dp[i + j] = change_min(dp[i] + abs(h_list[i] - h_list[i + j]), dp[i + j])

print(dp[N - 1])

Measured memory_bytes: 57312
# -.- coding:utf-8 -.-

number = int(input())
hl = [int(i) for i in input().split()]

# 1の場合はYes
if number == 1:
  print("Yes")
  exit()
  
for i in range(number):
  if i == 0:
    hl[0] = hl[0] - 1
  if i == number - 1 :
    print("Yes")
    exit()
    
  if (hl[i+1] - hl[i]) == 0:
    continue
  elif (hl[i+1] - hl[i]) > 0:
    hl[i+1] -= 1
  elif (hl[i+1] - hl[i]) < 0:
    print("No")
    exit()

Measured memory_bytes: 14396
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#define FAST ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
using namespace std;

priority_queue <ll, vector<ll>, greater<ll> > q1;//小的在前
priority_queue <ll> q2;//大的在前

ll a[maxn * 3];
ll l[maxn * 3], r[maxn * 3];//维护l最大,r最小

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i++){
		scanf("%lld", &a[i]);
	}
	ll sum = 0;
	for(int i = 1; i <= 3 * n; i++){
		q1.push(a[i]);
		sum += a[i], l[i] = sum;
		while(q1.size() > n){
			sum -= q1.top();
			q1.pop();
			l[i] = sum;
		}
	}
//---------------------------------------
	sum = 0;
	for(int i = 3 * n; i >= 1; i--){
		q2.push(a[i]);
		sum += a[i], r[i] = sum;
		while(q2.size() > n){
			sum -= q2.top();
			q2.pop();
			r[i] = sum;
		}
	}
	ll ans = -1e15;
	for(int i = n; i <= 2 * n; i++){
		ans = max(ans, l[i] - r[i+1]);//left - right
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 9204
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var A = G;
		int N = A[0], K = A[1], Q = A[2];
		A = G;
		var s = new HashSet<int>(A);
		var min = int.MaxValue;
		foreach (var y in s)
		{
			var small = new List<int>();
			var l = 0;
			while (l < N)
			{
				if (A[l] < y) { l++; continue; }
				var r = l + 1;
				while (r < N && A[r] >= y) r++;
				var t = new List<int>();
				for (var j = l; j < r; j++) t.Add(A[j]);
				t.Sort();
				small.AddRange(t.Take(t.Count - K + 1));
				l = r;
			}
			small.Sort();
			if (small.Count >= Q) min = Min(min, small[Q - 1] - y);
		}
		WriteLine(min);
	}
}


Measured memory_bytes: 39120
/// 1 ĐẤM AC NÀO
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
struct var
{
    int s,t,x;
};
vector<var> v;
bool cmp(var a, var b)
{
    if(a.s==b.s) return a.t<b.t;
    return a.s<b.s;
}
typedef pair<int,int> pii;
int main()
{
    //freopen("inp","r",stdin);
    //freopen("out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n,q;
    cin>>n>>q;
    v.resize(n);
    for(int i=0;i<n;++i)
    {
        int x,y;
        cin>>x>>y>>v[i].x;
        v[i].s=max(x-v[i].x,0);
        v[i].t=max(y-v[i].x,0);
    }
    sort(v.begin(),v.end(),cmp);
    priority_queue< pii, vector<pii> , greater<pii> >Q;
    int j=0;
    for(int i=0;i<q;++i)
    {
        int r;
        cin>>r;
        while(j<n&&v[j].s<=r)  Q.push(make_pair(v[j].x,v[j].t)),++j;
        while(!Q.empty())
        {
            pii t=Q.top();
            if(t.second<=r)
            {
                Q.pop();
                continue;
            }
            cout<<t.first<<endl;
            break;
        }
        if(Q.empty())  cout<<"-1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 5360
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;

char s[MAXN]; int n;
vector <pair <int, int>> mod;
void modify(char *s, int n, int x, int y) {
	for (int i = 1; i <= n; i++)
		if (s[i] == x + 'A') s[i] = y + 'A';
		else if (s[i] == y + 'A') s[i] = x + 'A';
}
void init() {
	scanf("%s", s + 1);
	int m = strlen(s + 1);
	int cnt[3] = {0, 0, 0};
	for (int i = 1; i <= m; i++)
		if (s[n] != s[i]) {
			s[++n] = s[i];
			cnt[s[i] - 'A']++;
		}
	s[n + 1] = 0;
	if (cnt[0] > cnt[1]) swap(cnt[0], cnt[1]), modify(s, n, 0, 1), mod.emplace_back(0, 1);
	if (cnt[1] > cnt[2]) swap(cnt[1], cnt[2]), modify(s, n, 1, 2), mod.emplace_back(1, 2);
	if (cnt[0] > cnt[1]) swap(cnt[0], cnt[1]), modify(s, n, 0, 1), mod.emplace_back(0, 1);
	if (cnt[0] == 0) puts(""), exit(0);
}
void sela() {
	int b = 0, c = 0;
	static int pos[MAXN]; int cnt = 0;
	for (int i = 1; i <= n; i++)
		if (s[i] == 'A') pos[++cnt] = i;
	for (int i = 1; i <= cnt; i++) {
		bool occur = false;
		for (int j = pos[i - 1] + 1; j <= pos[i] - 1; j++)
			occur |= s[j] == 'B';
		b += occur;
	}
		bool occur = false;
		for (int j = pos[cnt] + 1; j <= n; j++)
			occur |= s[j] == 'B';
		b += occur;
	for (int i = 1; i <= cnt - 1; i++)
		c += pos[i] == pos[i + 1] - 2 && s[pos[i] + 1] == 'C';
	if (b >= c) return;
	int lft = c - b, tmp = n; n = 0;
	for (int i = 1; i <= tmp; i++)
		if (s[i] == 'A') {
			if (lft != 0 && n >= 2 && s[n] == 'C' && s[n - 1] == 'A') lft--;
			else s[++n] = s[i];
		} else if (s[n] != s[i]) s[++n] = s[i];
	assert(lft == 0);
}
void delc() {
	int delta = 0;
	for (int i = 1; i <= n; i++)
		if (s[i] == 'C') delta++;
		else if (s[i] == 'B') delta--;
	assert(delta >= 0);
	int tmp = n; n = 0; s[tmp + 1] = 0;
	for (int i = 1; i <= tmp; i++)
		if (s[i] == 'C') {
			if (delta != 0 && (!n || s[n] != s[i + 1])) delta--;
			else s[++n] = s[i];
		} else s[++n] = s[i];
	assert(delta == 0);
}
void delb() {
	int a = 0, b = 0, c = 0;
	for (int i = 1; i <= n; i++)
		if (s[i] == 'C') c++;
		else if (s[i] == 'B') b++;
		else a++;
	assert(b == c && b >= a);
	int tmp = n; n = 0; s[tmp + 1] = -1;
	for (int i = 1; i <= tmp; i++)
		if (s[i] == 'A') s[++n] = s[i];
		else if (b > a && n >= 1 && s[n] != 'A' && s[i] != s[n] && s[i + 1] != s[n - 1]) n--, b--, c--;
		else s[++n] = s[i];
	s[n + 1] = 0;
}
int main() {
	init();
	sela();
	delc();
	delb();
	while (!mod.empty()) {
		modify(s, n, mod.back().first, mod.back().second);
		mod.pop_back();
	}
	printf("%s\n", s + 1);
	return 0;
}


Measured memory_bytes: 5248
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
    //cout << fixed << setprecision(8);

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(a-b)<=d && (c-b) <= d)|| abs(a-c)<=d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<double> value(N);
    vector<string> S(N);
    double ans = 0;
    rep(i, N){
        cin >> value[i] >> S[i];
        if(S[i] == "JPY"){
            ans += value[i];
        }
        else{
            ans += value[i]*380000;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n, m;
  cin >> n >> m;

  priority_queue<ll> a;
  for (ll i = 0; i < n; ++i) {
    ll v;
    cin >> v;
    a.push(v);
  }

  for (ll i = 0; i < m; ++i) {
    ll v = a.top();
    a.pop();
    a.push(v/2);
  }

  ll ans = 0;
  while(!a.empty()) {
    ans += a.top();
    a.pop();
  }

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

Measured memory_bytes: 1400
#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 pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

int a[100001];
vector<int> v;
map<int,int> t;
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    int cnt=0;
    rep(i,n){
        if(a[i]==a[n-i-1]&&cnt==0) v.pb(i+1);
        else if(a[i]==a[n-i-1]&&cnt>=1) continue;
        else if(a[i]!=a[n-i-1]){
            ++t[a[i]];--t[a[n-i-1]];
            if(t[a[i]]==0) --cnt;
            else if(t[a[i]]==1) ++cnt;
            if(t[a[n-i-1]]==0) --cnt;
            else if(t[a[n-i-1]]==-1) ++cnt;
            if(cnt==0) v.pb(i+1);
        }
    }
    rep(i,v.size()){
        cout<<v[i]<<(i+1==v.size()?"":" ");
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 5892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "Yes";
const string NO = "No";

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    vector<pair<ll, ll>> task(N);
    for (int i = 0; i < N; i++)
    {
        ll a, b;
        cin >> a >> b;
        task[i] = make_pair(b, a);
    }
    SORT(task);
    ll t = 0;
    for (int i = 0; i < N; i++)
    {
        t += task[i].second;
        if (task[i].first < t)
        {
            cout << NO << endl;
            return 0;
        }
    }

    cout << YES << endl;

    return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    int n,c;
    cin>>n>>c;

    int t_table[100010][31]={};
    rep(i,n){
        int s,t,c;
        cin>>s>>t>>c;
        t_table[s][c]++;
        t_table[t+1][c]--;
    }

    rep2(i,c){
        rep2(k,100000){
            t_table[k][i]+=t_table[k-1][i];
        }
    }
    /*
    rep2(i,c){
        rep2(k,50){
            cout<<t_table[k][i]<<" ";
        }
        cout<<endl;
    }*/
    long long ans=-1;
    rep2(k,100000){
        long long tmp=0;
        rep2(i,c){
            if(t_table[k][i])tmp++;
        }
        ans=max(tmp,ans);
    }
    cout<<ans<<endl;
    return 0;

}
/*

3 2
1 7 2
7 8 1
8 12 1

2

3 4
1 3 2
3 4 4
1 4 3

3


9 4
56 60 4
33 37 2
89 90 3
32 43 1
67 68 3
49 51 3
31 32 3
70 71 1
11 12 3

2
*/


Measured memory_bytes: 12416
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(l[K-1])

Measured memory_bytes: 3060
//s2.clear();
//        s2 = s.substr(i, d);
//        for(j = 0; j < s2.size() ; j++)
//            {
//                if(s2[j] != s1[j])
//                {
//                    boo++;
//                }
//            }
//            if(boo == s1.size())
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main()
{
    ll x,y,z; cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
   cout << x << ' ' << y << ' '<< z << '\n';










}


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

int main(void){
  string x,y;
  cin >> x >> y;
  if(x[0] == y[2] && x[1] == y[1] && x[2] == y[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <random>
#include <complex>


using namespace std;
typedef long long ll;


int main() {
	int H, A; cin >> H >> A;
	cout << (H + A - 1) / A << endl;
	return 0;
}

Measured memory_bytes: 256
import math
Q = int(input())
lr = [list(map(int, input().split())) for i in range(Q)]

max_l = max(lr, key=lambda x:x[1])[1]

prime = list(range(2,int(math.ceil(max_l**0.5)+1)))

m = 1
while True:
    b = filter(lambda x: x%prime[m-1] != 0,prime[m:])
    prime = prime[:m]
    prime.extend(b)
    m += 1
    if m > len(prime):
        break

like2017 = {-1:0,1:0}
for i in range(3,max_l+2,2):
    k = 0
    for j in prime:
        if (i%j == 0 or ((i+1)/2)%j == 0) and i != j and (i+1)/2 != j:
            k += 1
            break
    if k == 0:
        like2017[i] = like2017[i-2] + 1
    else:
        like2017[i] = like2017[i-2]


for i in range(Q):
    print(like2017[lr[i][1]]-like2017[lr[i][0]-2])


Measured memory_bytes: 33504
#include<iostream>
#include <cstdio>
#include<cmath>
#include<vector>


using namespace std;

////Nayeem Shahriar Joy,Applied Physics &Electronic Engineering,University of Rajshahi.

void primefactor(int n)

{
    vector<int>p;
    cout<<n<<": ";
    while(n%2==0)
    {
        p.push_back(2);
        n=n/2;
    }
    for(int i=3;i<=sqrt(n);i=i+2)
    {
        while(n%i==0)
        {
            p.push_back(i);
            n=n/i;
        }
    }
    if(n>2)
    {
        p.push_back(n);
    }
    for(int j=0;j<p.size();j++)
    {
        if(j==p.size()-1)
        {
            cout<<p[j]<<endl;
        }
        else{
        cout<<p[j]<<" ";
        }
    }
}

int main() {

    int N;

    cin>>N;

    primefactor(N);

}

Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int A[110];

signed main() {
    int N, x;
    cin >> N >> x;
    rep(i, N) {
        cin >> A[i];
    }
    sort(A, A + N);
    int a = 0;
    rep(i, N) {
        a += A[i];
        if (a > x) {
            cout << i << endl;
            return 0;
        }
    }
    if (a == x)cout << N << endl;
    else cout << N - 1 << endl;
    return 0;
}


Measured memory_bytes: 764
from math import sin,cos,acos,pi
while 1:
  A = map(float,raw_input().split())
  if all([e==-1 for e in A]):break
  [a,b,c,d] = [e*pi/180 for e in A]
  print int(round(acos(cos(a)*cos(c)*cos(b-d)+sin(a)*sin(c))*6378.1))

Measured memory_bytes: 4448
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);

const int MAX_N=2e5+2;

int main(){
    int H,W;
    cin>>H>>W;
    int cnt[26];
    CLR(cnt);
    REP(h,H)REP(w,W){
        char c;
        cin>>c;
        cnt[c-'a']++;
    }
    vector<int>vec;
    int sum=0;
    REP(i,26){
        if(cnt[i]%4!=0){
            sum+=cnt[i]-(cnt[i]%4);
            vec.PB(cnt[i]%4);
        }else{
            sum+=cnt[i];
        }
    }
    bool f=1;
    if(H%2==0&&W%2==0){
        if(SZ(vec)!=0)f=0;
    }else if(H%2!=W%2){
        if(H%2==1&&sum<H*W-W)f=0;
        else if(W%2==1&&sum<H*W-H)f=0;
        REP(i,SZ(vec))if(vec[i]%2==1)f=0;
    }else{
        if(sum<H*W-(H+W-1))f=0;
        int odd=0;
        REP(i,SZ(vec)){
            if(vec[i]%2==1)odd++;
        }
        if(odd!=1)f=0;
    }
    if(f){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

// input
int N, M, C;
vector<int> B;
int A[21][21];


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


int main() {
    input();
    int ans = 0;
    rep(i, N) {
        int s = C;
        rep(j, M) s += A[i][j] * B[j];
        if (s > 0) ans++;
    }
    cout << ans << endl;
}


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

#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 int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    string a,b,c;
    cin >> a >> b >> c;
    int na = a.size();
    int nb = b.size();
    int nc = c.size();
    if(a[na-1] == b[0] && b[nb-1] == c[0]) cout<< "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

def io_generator():
	while True:
		yield raw_input()

#+++++++++++++++++++

def main(io):
	a=int(io.next())
	diff=[]
	for i in range(a):
		b,c= map(int, io.next().split())
		diff.append((b,c,b+c))
	diff = sorted(diff, key=lambda a:-a[2])
	#print diff
	ret= sum([x[i%2]*(1-2*(i%2)) for i,x in enumerate(diff)])
	
	return ret


#++++++++++++++++++++

if __name__ == "__main__":
	io=io_generator()
	print main(io)


Measured memory_bytes: 25340
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define repll(i,n) for(ll i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define INF 1000000001
#define LL_INF 1001001001001001001
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(void) {
	int n,k; cin >> n >> k;
	vi a(n); rep(i,n) cin >> a[i];
	mint ans=0;
	combination c(n+5);	
	SORT(a);	
	rep(i,n){
		mint now = c(i,k-1);
		ans += now*a[i];
	}
	REV(a);	
	rep(i,n){
		mint now = c(i,k-1);
		ans -= now*a[i];
	}
	
	ll ret = ans.x;
	out(ret);
}




Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right; }Node;

Node Tree[MAX];
int size, Depth[MAX], Height[MAX];

void preParse(int u);
void inParse(int u);
void postParse(int u);
int getDepth(int u);
int getSibling(int u);
void print(int u);

int main(int argc, char** argv) {
    int i, index, left, right, root;
    scanf("%d", &size);

    //Initialize the binary tree
    for ( i = 0; i < size; i++ ) {
      Tree[i].parent = NIL;
    }

    //Put all value into the tree
    for ( i = 0; i < size; i++ ){
      scanf("%d %d %d", &index, &left, &right);
      Tree[index].left = left;
      Tree[index].right = right;
      if ( left != NIL ) Tree[left].parent = index;
      if ( right != NIL ) Tree[right].parent = index;
    }

    //Get depth of each node
//    for ( i = 0; i < size; i++ ){
//      Depth[i] = getDepth(i);
//      Height[i] = 0;
//    }
//
    for ( i = 0; i < size; i++ ){
          if ( Tree[i].left == NIL && Tree[i].right == NIL )
            {
              Height[i] = 0;
              int parent = Tree[i].parent;
              int child = left;
              while(left)
              {
                  if ( parent == NIL ) break;
                  if ( Height[parent] < child ) Height[parent] = child;
                  child++;
                  parent = Tree[parent].parent;
              }
          }
    }
    for (i = 0; i < size; ++i) if (Tree[i].parent == NIL){ root = i; break; }
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
//    for ( i = 0; i < size; i++ ) print(i);
    return (EXIT_SUCCESS);
}

void preParse(int u)
{
    if (u == NIL) return;
    printf(" %d", u);
    preParse(Tree[u].left);
    preParse(Tree[u].right);
}

void inParse(int u)
{
    if (u == NIL) return;
    inParse(Tree[u].left);
    printf(" %d", u);
    inParse(Tree[u].right);
}

void postParse(int u)
{
    if (u == NIL) return;
    postParse(Tree[u].left);
    postParse(Tree[u].right);
    printf(" %d", u);
}

int getDepth(int u)
{
    int depth = 0;
    while(1){
        u = Tree[u].parent;
        if ( u == NIL ) break;
        depth++;
    }
    return depth;
}

int getSibling(int u)
{
    if ( Tree[u].parent == NIL ) return NIL;
    if ( Tree[Tree[u].parent].left != u && Tree[Tree[u].parent].left != NIL ) return Tree[Tree[u].parent].left;
    if ( Tree[Tree[u].parent].right != u && Tree[Tree[u].parent].right != NIL ) return Tree[Tree[u].parent].right;
    return NIL;
}


Measured memory_bytes: 2112
/*" بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ -In the name of Allah."
   Never stop chasing!-MD.SOURAV.

   ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
   ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
   ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
   [███████████████████].░░░░░░░░░░░░░░
   ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░
*/


#include <bits/stdc++.h>


#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll             long long int
#define li              ong int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define MOD 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
#define ignore         cin.ignore (std::numeric_limits<std::streamsize>::max(),'\n');
#define MAX 32000
#define endl "\n"

using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;
typedef vector<pair<ll,ll>> vpllll;
typedef vector<pair<int,int>> vpiiii;
typedef map<ll,ll> mllll;
typedef map<char,ll> mchll;
typedef map<string,ll>msll;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

        int n;
        cin>>n;
        vector<ll>v;
        enter(v,n);
        ll ans=0;
        for(int i=1;i<n;i++)
		{
			if(v[i]<v[i-1])
			{
				ans=ans+(v[i-1]-v[i]);
				v[i]=v[i]+(v[i-1]-v[i]);
			}
		}
		cout << ans << endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll test_case=1;
    //cin>>test_case;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int n; cin >> n;
  if(n-1){
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  else cout << "Hello World" << endl;

  return 0;
}


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

int main(){
	int n;	cin>>n;
	vector<int> a(n+2);
	for(int i=1; i<=n;i++) cin>>a[i];
	a[0]=a[n+1]=0;

	int sum=0;
	for(int i=0; i+1<=n+1; i++){
		sum += abs(a[i]-a[i+1]);
	}

	for(int i=1; i<=n; i++){
		cout<< sum + abs(a[i-1]-a[i+1]) -(abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]))<<endl;
	}

	return 0;
}


Measured memory_bytes: 1664
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

x,y = I2()
for i in range(x+1):
    for j in range(x-i+1):
      #print(i,j)
      if y == i*2+j*4 and i+j == x:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 9228
public partial class IntroductionToProgramming{
	static int TIMES = 3;	// ???????????°
	public static void Main(){
		string[] line = System.Console.ReadLine().Split(' ');
		int n = int.Parse(line[0]);
		int x = int.Parse(line[1]);

		while (!(n == 0 && x == 0))
		{
			int sum = 0;
			int counter = 0;

			System.Console.WriteLine((Count(true, 1, n, x, counter, sum) + Count(false, 1, n, x, counter, sum)).ToString());

			string[] line2 = System.Console.ReadLine().Split(' ');
			n = int.Parse(line2[0]);
			x = int.Parse(line2[1]);
		}
	}

	public static int Count(bool addFlg, int me, int n, int x, int counter, int sum)
	{
		// ??????????¶???????????????????????????´???????????????
		if (addFlg)
		{
			sum += me;
			counter++;
		}
		// ??????????????????????????°??¨?????´????????´??????????¨??????????
		if (counter == TIMES)
		{
			if (sum == x)
			{
				return 1;
			}
			else
			{
				return 0;
			}
		}
		// ??????????¨???°???????????°????¶???????????????´???????????????
		if (sum + me * (TIMES - counter) > x)
		{
			return 0;
		}
		// ?????????????????°????????´???????????????
		if (me == n)
		{
			return 0;
		}

		// ?¬???????????????????
		return Count(true, me + 1, n, x, counter, sum) + Count(false, me + 1, n, x, counter, sum);
	}
}

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

#define endl '\n'
typedef long long ll;

ll const M = 1000000007;
ll mult(ll a, ll b){
    return ( (a%M) * (b%M))%M;
}

ll fpow(ll b, ll e){
    if (e == 0) return 1;
    if (e == 1) return b;
    if (e & 1) return mult(b, fpow(b, e-1));
    ll temp = fpow(b, e/2);
    return mult(temp, temp);
}

ll fat(ll x){
    ll ans = 1;
    for (ll i =1; i<=x; i++) ans = mult(ans, i);
    return ans;
}
ll fat(ll x, ll y){
    if (x > y) return 1LL;
    ll ans = x;
    for (ll i = x+1; i<=y; i++) ans = mult(ans, i);
    return ans;
}

ll inv(ll x){
    return fpow(x, M-2);
}

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

    ll n, a, b; cin >> n >> a >> b;

    if (a > n-a) a = mult(fat(a+1, n), inv(fat(n-a)));
    else a = mult(fat(n-a+1, n), inv(fat(a)));
    if (b > n-b) b = mult(fat(b+1, n), inv(fat(n-b)));
    else b = mult(fat(n-b+1, n), inv(fat(b)));

    ll resp = fpow(2, n);
    resp = (resp - 1 + M)%M;
    resp = (resp - a + M)%M;
    resp = (resp - b + M)%M;
    cout << resp << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,mod,fac[3005],inv[3005];
int f[3005][3005],c[3005][3005];
inline int qpow(int a,int b,int mod)
{int res=1,tp=a;
while (b)
{if (b&1) res=1ll*res*tp%mod;
tp=1ll*tp*tp%mod;b>>=1;
}
return res;
}
int main (){
	int i,j,k,ans=0;
	fac[0]=1;
	scanf ("%d%d",&n,&mod);
	for (i=1;i<=n;i++)
	{fac[i]=1ll*fac[i-1]*i%mod;
	inv[i]=qpow(fac[i],mod-2,mod);
	}
	for (i=0;i<=n;i++)
	{c[i][0]=c[i][i]=1;
	for (j=1;j<i;j++)
	{c[i][j]=c[i-1][j-1]+c[i-1][j];
	if (c[i][j]>=mod) c[i][j]-=mod;
	}
	}
	f[0][0]=1;
	for (i=1;i<=n;i++)
	{f[i][0]=1;
	for (j=1;j<=i;j++)
	{f[i][j]=1ll*f[i-1][j]*(j+1)%mod;
	f[i][j]=(f[i][j]+f[i-1][j-1]>=mod?f[i][j]+f[i-1][j-1]-mod:f[i][j]+f[i-1][j-1]);
	}
	}
	for (i=0;i<=n;i++)
	{int wys=qpow(2,n-i,mod),now=1,res=0;
	int rm=qpow(2,qpow(2,n-i,mod-1),mod);
	for (j=0;j<=i;j++)
	{res+=1ll*f[i][j]*now%mod;
	now=1ll*now*wys%mod;
	if (res>=mod) res-=mod;
	}
	res=1ll*res*rm%mod;
	res=1ll*res*c[n][i]%mod;
	if (i&1) {ans-=res;}
	else {ans+=res;}
	if (ans<0) ans+=mod;
	if (ans>=mod) ans-=mod;
	}
	printf ("%d\n",ans);
	return 0;
}

Measured memory_bytes: 69504
#include <stdio.h>
#include <vector>
using namespace std;
#define N (1010)
#define M (200010)
#define PB push_back
int n, m;
int v[N][N];
int src, cv;
int vst[N], a[M], b[M], suc[N], cnt[N];
int f[N][N], g[N][N];
void dfs(int x){
    vst[x] = cv;
    for (int i = 0, y; i < cnt[x]; ++i){
        y = v[x][i];
        if (cv != vst[y]){
            if (suc[y]) f[src][y] = 1;
            dfs(y);
        }
    }
}
void dfs2(int x){
    vst[x] = cv;
    for (int i = 0, y; i < cnt[x]; ++i){
        y = v[x][i];
        if (vst[y] != cv){
            dfs2(y);
        }
    }
}
int main(){
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++i) {
        scanf("%d%d", a+i, b+i);
        v[a[i]][cnt[a[i]]++] = b[i];
    }
    for (int i = 1; i <= n; ++i){
        src = i;
        for (int j = 1; j <= n; ++j){
            suc[j] = 0;
        }
        for (int j = 0; j < cnt[i]; ++j){
            suc[v[i][j]] = 1;
        }
        vst[i] = ++cv;
        for (int j = 0; j < cnt[i]; ++j){
            dfs(v[i][j]);
        }
        vst[i] = ++cv;
        for (int j = cnt[i]-1; ~j; --j){
            dfs(v[i][j]);
        }
        cv++;
        dfs2(i);
        for (int j = 1; j <= n; ++j){
            g[i][j] = vst[j] == cv;
        }
    }
    for (int i  =1; i <= m; ++i){
        // printf("%d %d\n", f[a[i]][b[i]], g[b[i]][a[i]]);
        printf("%s\n", !(f[a[i]][b[i]] ^ g[b[i]][a[i]]) ? "same" : "diff");
    }
}

Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n;
    cin >> n;
    double t = (-1.0 + sqrt(8.0 * n + 1.0)) / 2.0;
    int ans = ceil(t);
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
 
int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
 
  cout << fixed << setprecision(6) << sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)) << endl;
}


Measured memory_bytes: 3280
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int main()
{
	char c,cc=32;bool flag(false);
	while((c=getchar())!=10){if((!(c-67))&&(!(cc-65))){flag=true;break;}cc=c;}
	puts(((flag)?("Yes"):("No")));
	return 0;
}

Measured memory_bytes: 256
#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 mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define P pair<int,int>
#define prique priority_queue
int n,k,ans;
vector<P>vec;
signed main(){
    cin>>n>>k;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        P p=make_pair(a,b);
        vec.push_back(p);
    }
    sort(vec.begin(),vec.end());
    for(int i=0;k>0;i++){
        k-=vec[i].second;
        if(k<=0)ans=vec[i].first;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3444
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int n, k;
	cin >> n >> k;
	int c = 0;
	rep(i, n) {
		int h;
		cin >> h;
		if (h >= k) {
			c++;
		}
	}
	cout << c << endl;
	
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)

{
 char a[100][100];
 char b[100][100];

 int i, j, n, s, minj;
 int f;
 int k = 0;

 scanf("%d", &n);

 for(i = 0; i < n; i++)
{
  scanf("%s", &a[i]);
  b[i][0] = a[i][0];
  b[i][1] = a[i][1];  
}

  for(i = 0; i < n; i++)
{
    for(j = n-1; j >= i+1; j--)
{

  if(a[j][1] < a[j-1][1])
{
 s = a[j][1];
   a[j][1] = a[j-1][1];
   a[j-1][1] = s;
   f = a[j][0];
   a[j][0] = a[j-1][0];
   a[j-1][0] = f;

}
}

 }


  for(i = 0; i < n; i++)
{
  minj = i;
  for(j = i; j < n; j++)
{
   if(b[j][1] < b[minj][1])
{
     minj = j;
}

}
  s = b[minj][1];
  b[minj][1] = b[i][1];
  b[i][1] = s;
  f = b[minj][0];
  b[minj][0] = b[i][0];
  b[i][0] = f;

}

 for(i = 0; i < n; i++)
{
  printf("%c", a[i][0]);
 if(i < n-1)
  printf("%c ", a[i][1]);
 else
  printf("%c\n", a[i][1]);
}

 printf("Stable\n");

 for(i = 0; i < n; i++)
{
  printf("%c", b[i][0]);
 if(i < n-1)
  printf("%c ", b[i][1]);
 else
  printf("%c\n", b[i][1]);
}

 for(i = 0; i < n; i++)
{
 if(b[i][0] == a[i][0])
{
  k++;
}

}

 if(k == n)
   printf("Stable\n");
 else
  printf("Not stable\n");


 return 0;

}

  


Measured memory_bytes: 1968
/*
	DATE:		2020-03-10 11:19:28
	NAME:		
	PROBLEM:	ABC158D
*/
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5;

int a[MAXN + 7];

char s0[MAXN + 7];

int main() {
  scanf("%s", s0 + 1);
  
  deque<char> dq;
  int len = strlen(s0 + 1);
  for (int i = 1; i <= len; i++) {
    dq.push_back(s0[i]);
  }

  int q;
  scanf("%d", &q);

  bool is_reversed = false;

  while (q--) {
    int ty;
    scanf("%d", &ty);
    if (ty == 1) {
      is_reversed ^= 1;
    }
    else {
      int f;
      char ch;
      scanf("%d %c", &f, &ch);
      f--;
      f ^= is_reversed;
      if (f == 0) {
        dq.push_front(ch);
      }
      else {
        dq.push_back(ch);
      }
    }
  }

  if (is_reversed) {
    reverse(dq.begin(), dq.end());
  }

  for (int i = 0; i < dq.size(); i++) {
    printf("%c", dq[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>

using namespace std;

int a[100];
int n,N;

int binary_search(int N){

  int r = n - 1;
  int l = 0;
  int cnt = 0;

  while( r >= l ){
    int x = (r + l)/2;
    cnt++;
    if( a[x] < N ) l = x + 1;
    else if( N < a[x] ) r = x - 1;
    else break;
  }
  return cnt;
}

int main(void){

  while( cin >> n , n ){
    for( int i = 0 ; i < n ; i++ ){ 
    cin >> a[i];
    }

  cin >> N;

  cout << binary_search(N) << endl;
  }
  return 0;
}

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

typedef long long ll;

ll N;
vector<tuple<string, ll, ll>> Rest;

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    string s;
    ll p;
    cin >> s >> p;
    Rest.push_back(make_tuple(s, -p, i + 1));
  }
  sort(Rest.begin(), Rest.end());
  for (auto rest : Rest) {
    cout << get<2>(rest) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
a=int(input())
b=int(input())
if a==b:
  print(1)
  exit()
abin=bin(a)[2:]
bbin=bin(b)[2:]
la=len(abin)
lb=len(bbin)
if la==lb:
  while abin[0]==bbin[0]:
    abin=abin[1:]
    bbin=bbin[1:]
  while len(abin)>1 and abin[0]=="0":
    abin=abin[1:]
cbin=bbin[1:]
while cbin and cbin[0]=="0":
  cbin=cbin[1:]
c=2**(len(cbin))-1
a=int(abin,2)
b=int(bbin,2)
lb=len(bbin)
lbnd=2**(lb-1)+c
hbnd=2**(lb-1)+a
if lbnd>=hbnd:
  print(2**lb-a)
else:
  print(2**(lb-1)-a+lbnd-a+1)


Measured memory_bytes: 3064
import java.util.*;

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();

		if(a > b) {
			int n = b;
			b = a;
			a = n;
		} 

		if(b > c) {
			int n = c;
			c = b;
			b = n;
		}

		if(a > b) {
			int n = b;
			b = a;
			a = n;
		}

		System.out.println(a + " " + b + " " + c);

	}
}




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


int main(void){
  int N, L;
  cin>> N;
  map<long long, int> mp;
  for(int i = 0; i < N; i++){
    cin >> L;
    if(mp[L] == 1){
      cout << "NO";
      return 0;
    }
    else{
      mp[L] = 1;
    }
  }
  cout << "YES";
  return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long x,y,z;
    cin>>x;
    cin>>y;
    cin>>z;
    set<long> s;
    s.insert(x);
    s.insert(y);
    s.insert(z);
    if(s.size()==2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    i64 n;
    cin >> n;
    vector<i64> as(n);
    map<i64, i64> nums;
    for (int i=0;i<n; ++i) {
        cin >>as[i];
        auto it = nums.find(as[i]);
        if (it == nums.end())
            nums[as[i]] = 1;
        else
            ++nums[as[i]];
    }
    i64 q;
    cin >> q;

    i64 sum{0};
    for (auto kv:nums) {
        sum += kv.first * kv.second;
    }

    for (int i=0; i<q; ++i) {
        i64 b,c;
        cin >> b >> c;
        auto it =nums.find(b);
        if (it != nums.end()) {
            auto it2=nums.find(c);
            if (it2 == nums.end()) {
                nums[c] = it->second;
            } else {
                it2->second += it->second;
            }
            sum += (c-b) * it->second;
            nums.erase(it);
        }
        cout << sum <<endl;
    }

    return 0;
}


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

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

    int n;
    cin >> n;
    int m = INT_MAX;
    int res = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x < m) {
            m = x;
            res++;
        }
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a=Integer.parseInt(sc.next());
int b=Integer.parseInt(sc.next());
int c=Integer.parseInt(sc.next());
int d=Integer.parseInt(sc.next());
if((dist(a,b)<=d&&dist(b,c)<=d)||dist(a,c)<=d){

System.out.println("Yes");}else{
System.out.println("No");
}

}
private static int dist(int person1,int person2){
return Math.abs(person2-person1);
}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
using namespace std;

int INF = 1e9 + 7;

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

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

	for (int i = 1; i <= k; i++) {
		if (a < b) {
			if (b < c) {
				c = 2 * c;
			}
			else {
				b = 2 * b;
			}
		}
		else {
			if (a < c) {
				c = 2 * c;
			}
			else {
				a = 2 * a;
			}
		}
	}
	cout << a + b + c << endl;
}

Measured memory_bytes: 256