akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <iomanip>
using namespace std;
#define GETINT(x) int (x); cin >> (x);
#define FOR(i, N) for(int i = 0; i < (N); (i)++)
#define RET cout << endl;
constexpr int _10e(int n) { return n == 0 ? 1 : 10 * _10e(n - 1); }

int main() {
    GETINT(N);

    int sum = 0;
    int max = -1;
    FOR(i, N) {
        int p;
        cin >> p;
        sum += p;
        if (max < p) max = p;
    }
    
    cout << (sum - max / 2) << endl;

    return 0;
}

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

int main()
{
  int n, k, tag[101];
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> tag[i];

  for (int i = 1; i <= k; i++){
    for (int j = 0; j < n - 1; j++){
      if (tag[j] % i > tag[j + 1] % i) swap(tag[j], tag[j + 1]);
    }
  }

  for (int i = 0; i < n; i++){
    cout << tag[i] << '\n';
  }
}

Measured memory_bytes: 3080
n, k = map(int, input().split())
h =[]
for i in range(n):
    h.append(int(input()))
h.sort()
ans = int(1e10)
for i in range(n-(k-1)):
    if h[i+(k-1)] - h[i] < ans:
        ans = h[i+(k-1)] - h[i]
#print(h)
print(ans)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
bitset<4000010>dp;
int n,sum=0;
int main(){
	scanf("%d",&n);
	dp[0]=1;
	for(int i=1,w;i<=n;i++){
		scanf("%d",&w);
		sum+=w;
		dp|=(dp<<w);
	}
	for(int i=(sum+1)/2;i<=sum;i++) if(dp[i]){
		printf("%d\n",i);
		return 0;
	}
} 

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

using namespace std;

int n;
char grid[2][52];
vector<int> t;

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

    cin >> n;

    long long ans = 1;

    for(int i = 0;i < n;i++){
        cin >> grid[0][i];
    }
    for(int i = 0;i < n;i++){
        cin >> grid[1][i];
    }
    
    for(int i = 0;i < n;i++){
        if(grid[0][i] == grid[0][i+1]){
            t.push_back(2);
            i++;
        } else t.push_back(1);
    }

    if (t[0] == 1) ans = 3;
    else ans = 6;

    for(int i = 1;i < t.size();i++){
        if(t[i] == 1){
            if (t[i-1] == 1) ans = (ans * 2) % 1000000007;
            else ans = ans % 1000000007;
        }else{
            if (t[i-1] == 1) ans = (ans * 2) % 1000000007;
            else ans = (ans * 3) % 1000000007;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n, a[105], pos[105], flags[2025] = {0}, k, c, i;

    scanf("%d", &n);
    for(i=1;i<=n;i++){
        scanf("%d", &a[i]);
        pos[i] = a[i];
        flags[pos[i]] = 1;
    }
    scanf("%d", &k);
    while(k--){
        scanf("%d", &c);
        if(flags[pos[c]+1] == 0 && pos[c]<2019){
            flags[pos[c]+1] = 1;
            flags[pos[c]] = 0;
            pos[c]++;
        }
    }
    for(i=1;i<=n;i++){
        printf("%d\n", pos[i]);
    }
return 0;
}



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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	int a,b;

	cin>>a>>b;

	map<int,int>mp;
	f(i,1,999){
	    ara[i]=ara[i-1]+i;
        arr[ara[i]]++;
	}

	for(i=1;i<499500;i++){
        int x=a+i;
        int y=b+i;
        if(arr[x]==1 && arr[y]==1){
            flag=true;
            for(j=x+1;j<y;j++){
                if(arr[j]) {
                    flag=false;
                    break;
                }
            }
            if(flag==true) cout<<i<<endl,exit(0);
        }
	}
    //cout<<1<<endl;
}


Measured memory_bytes: 5612
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

	int x[5];
	cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

	for (int i = 0; i < 5; i++) {
		if (x[i] == 0)
			cout << i + 1 << endl;
	}

EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}




Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll H, W; cin >> H >> W;
    vector<string> field(H); REP(i, H) cin >> field[i];
    
    ll total = 0;
    REP(i, H) REP(j, W) if (field[i][j] == '#') total++;
    
    ll x = 0;
    ll y = 0;
    ll visit = 0;
    while (true) {
        visit++;
        
        if (field[y][x] != '#') {
            cout << "Impossible" << endl;
            return 0;
        }
        
        ll cnt = 0;
        if (x + 1 < W and field[y][x+1] == '#') cnt++;
        if (y + 1 < H and field[y+1][x] == '#') cnt++;
        
        if (cnt != 1) {
            cout << "Impossible" << endl;
            return 0;
        }
        
        if (x + 1 < W and field[y][x+1] == '#') x++;
        else if (y + 1 < H and field[y+1][x] == '#') y++;
        
        if (x == W - 1 and y == H - 1) {
            if (visit + 1 == total) cout << "Possible" << endl;
            else cout << "Impossible" << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<pair<string,int>> p(N);
  for(int i=0; i<N; i++){
    cin >> p[i].first >> p[i].second;
  }
  int sum = 0;
  string X;
  cin >> X;
  for(int i=0; i<N; i++){
    if(p[i].first == X){
      for(int j=i+1; j<N; j++){
        sum += p[j].second;
      }
      break;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
if N * M == 1:
    print(1)
elif N == 1 or M == 1:
    if N == 1:
        print(M-2)
    if M == 1:
        print(N-2)
elif N == 2 or M == 2 :
    print(0)
else:
    print((N-2)*(M-2))

Measured memory_bytes: 3060
// ==   ||
// 			||
//	*	  ||	
//	*		||
//      ||
// ==   ||
//
//
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 2e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

int C[maxn], sum[maxn], dp[maxn];

int N;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++)	
		cin >> C[i];
	dp[0] = 1;
	sum[C[0]] = 1;
	for (int i = 1; i < N; i++) {
		if (C[i] == C[i - 1]) {
			dp[i] = dp[i - 1];
			continue;
		}
		dp[i] = (sum[C[i]] + dp[i - 1]) % MO;
		sum[C[i]] = (sum[C[i]] + dp[i - 1]) % MO; 
	}
	cout << dp[N - 1] << "\n";
}



Measured memory_bytes: 2688
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main(){
  int l;
  cin >> l;
  int r=1;
  int itr=0;
  vector<pair<pair<int,int>,int>> ans;
  while(l>=r){
    r*=2;
    itr++;
  }
  cerr<<r<<endl;
  int n=itr;
  rep(i,n-1){
    ans.push_back(mp(mp(i,i+1),0));
    
    ans.push_back(mp(mp(i,i+1),pow(2,i)));
    
  }
  cerr<<itr<<endl;
  for(int t=itr;t>0;t--){
    if(l-pow(2,t-1)>=r/2){
      ans.push_back(mp(mp(t-1,n-1),l-pow(2,t-1)));
      l-=pow(2,t-1);
    }
  }
  int m=2*(n-1);
  cout<<n<<' '<<ans.size()<<endl;
  rep(i,ans.size()){
    pair<pair<int,int>,int> o;
    o=ans[i];
    int a,b,c;
    a=o.first.first;
    b=o.first.second;
    c=o.second;
    cout<<a+1<<' '<<b+1<<' '<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))
mtd = 1000
for i in range(n):
    if abs(a - (t - (H[i] * 0.006))) < mtd:
        mtd = abs(a - (t - (H[i] * 0.006)))
        ans = i + 1
print(ans)

Measured memory_bytes: 9140
N = int(input())
M = 2**N
A = list(map(int,input().split()))
A.sort(reverse=True)

ar = [A[0]]
A[0] = -1
for _ in range(N):
    ar.sort(reverse=True)
    br = []
    i = 0
    while i < M and len(br) < len(ar):
        if A[i] >= 0:
            if ar[len(br)] > A[i]:
                br.append(A[i])
                A[i] = -1
        i += 1
    if len(br) < len(ar):
        print('No')
        exit()
    ar += br
print('Yes')

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

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  
  int i=0;
  while (A >= B){
    B *= 2;
    i++;
  }
  while (B >= C){
    C *= 2;
    i++;
  }
  
  if (i <= K)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
  
}

Measured memory_bytes: 3604
def diff(a, b):
  res = 0
  for (ca, cb) in zip(a, b):
    if ca != cb:
      res += 1
  return res

def solve(s, t):
  res = len(t)
  for i in range(0, len(s) - len(t) + 1):
    res = min(res, diff(s[i : i + len(t)], t))
  return res

s = input()
t = input()
print(solve(s, t))


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

typedef long long ll;

int main(){
	vector<ll> P(6);
	rep(i,6)cin >> P[i];
	ll mn = 1e18;
	rep(i,5){ mn = min(mn,P[i+1]); }
	ll time= (P[0]+mn-1) / mn + 4;

	cout << time << endl;

}




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

using namespace std;

int main() {
	string s1, s2;
	cin >> s1 >> s2;
	int count = 0;
	rep(i, s2.size()) {
		if (s1[i] != s2[i])
			count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    ll n;
    cin >> n;
    vector<ll> t(n+1),x(n+1),y(n+1);
    t[0] = 0,x[0] = 0,y[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }

    for(int i = 1; i <= n; i++)
    {
        if ((t[i]-t[i-1] - abs(x[i]-x[i-1]) - abs(y[i]-y[i-1])) % 2 != 0 || (t[i]-t[i-1] - abs(x[i]-x[i-1]) - abs(y[i]-y[i-1]) < 0))
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cassert>
#include <vector>

namespace comprog {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace comprog

#include <cstdio>

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    comprog::dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main() {
	long double a,b,c;
	cin>>a>>b>>c;
	if(a+b+2.0*sqrt(a*b)<c){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	} 
	return 0;
}


Measured memory_bytes: 256
### coding: UTF-8

#import math
#import random as rd
#import numpy as np

n=int(input())
line=list(map(int,input().split( )))
#n=4
#line=[4,16,12,8]


count_line=[]

for i in range(n):
    num=0
    while line[i]%(2**(num+1))==0:
        num+=1
    count_line.append(num)
    
    

print(min(count_line))

Measured memory_bytes: 3060
import itertools

n = int(input())

#順列のリストを生成
per_list = []
for i in itertools.permutations([x for x in range(1, n + 1)]) :
    per_list.append(i)

#入力されたタプルが何番目にあるか検索
a = []
for j in range(2) :
    y = tuple(map(int, input().split()))
    a.append(per_list.index(y))

print(abs(a[0] - a[1]))

Measured memory_bytes: 13824
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

int main(){
	int n;
	cin>>n;
	vector<string> v(n);
	rep(i, n) cin>>v[i];
	int t;
	vi u;
	rep(i, n){
		rep(j, n){
			if(i != j){
				t = atoi((v[i]+v[j]).c_str());
				if(u.size()<3) u.pb(t);
				else if(u[2] > t){
					u[2] = t;
					sort(all(u));
				}
			}
		}
	}
	int ans = u[2];
	cout<<ans<<endl;
}

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

int main() {
    int T, H, S;
    while (cin >> T >> H >> S, T != -1) {
        int r = 7200 - T*3600 - H*60 - S;
        int r3 = r*3;
        printf("%02d:%02d:%02d\n", r/3600, r/60%60, r%60);
        printf("%02d:%02d:%02d\n", r3/3600, r3/60%60, r3%60);
    }
    return 0;
}


Measured memory_bytes: 3192
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../../../bits/stdc++.h"
#endif

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

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int main(){
  cin.tie(0);
  
  int N;
  cin>>N;
  int n=1;
  while(2*n<=N) {
    n*=2;
  }

  cout<<n<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  long long int n,p,q,r,s;
  cin>>n;
  p=n/3;
  q=n/5;
  r=n/15;
  p=p*(p+1)/2;
  q=q*(q+1)/2;
  r=r*(r+1)/2;
  s=3*p+5*q-15*r;
  p=n*(n+1)/2;
  cout<<p-s;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;
const int mask = (1 << 26) - 1;

P dp[MAX_N];
int nx[MAX_N][26];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = len(s);
    rep(i,26){
        nx[n][i] = n;
    }
    rrep(i,n){
        rep(j,26){
            if(j == (s[i]-'a')){
                nx[i][j] = i;
            }else{
                nx[i][j] = nx[i+1][j];
            }
        }
    }
    dp[n] = P(0,0);
    rrep(i,n){
        if(dp[i+1].se == mask){
            dp[i] = P(dp[i+1].fi+1,(1 << (s[i]-'a')));
        }else{
            dp[i] = P(dp[i+1].fi,dp[i+1].se|(1 << (s[i]-'a')));
        }
    }
    int res = dp[0].fi + 1;
    if(dp[0].se == mask) res++;
    int nw = 0;
    string ans;
    while(1){
        rep(i,26){
            if(nx[nw][i] == n){
                ans.pb((char)('a'+i));
                cout << ans << "\n";
                return 0;
            }
            P p = dp[nx[nw][i]+1];
            if(p.fi+1+(p.se == mask) == res-1){
                ans.pb((char)('a'+i));
                nw = nx[nw][i]+1;
                res--;
                break;
            }
        }
    }
    return 0;
}


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

int main(){
  int n;
  cin>>n;       
  vector<int> v(n);
  
  for(int i=0;i<n;i++){
  
    cin>>v[i];
  }
  int result=0;
  while(1){
  
    for(int i=0;i<n;i++){
      if(v[i]%2==0){
        v[i]/=2;
      }else{
      goto END;
      }
    }
    result++;
  }
  END:;
  
  cout<<result<<endl;
  
}

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

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


int n;

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  scanf("%d", &n);

  LL ans = 0;
  for (LL i = 1; i <= n; i++) {
    ans += i * (n / i) * (n / i + 1) / 2;
  }
  cout << ans << endl;



  
#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 3660
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    string str;
    cin >> str;
    if(str[2] == str[3] && str[4] == str[5])
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if(a+b > a-b) {
      if(a+b > a*b) cout << a+b << endl;
      else cout << a*b << endl;
  }
  else {
      if(a-b > a*b) cout << a-b << endl;
      else cout << a*b << endl;
  }
}

Measured memory_bytes: 3588
n = input()
a = int(n[-1:])

if a == 2 or a == 4 or a == 5 or a == 7 or a == 9:
    print("hon")
elif a == 0 or a == 1 or a == 6 or a == 8:
    print("pon")
elif a == 3:
    print("bon")

Measured memory_bytes: 9160
#include <stdio.h>
main()
{
  int a, b, n, temp;
 
  scanf("%d%d",&a,&b);

  if(a < b){
    temp = a;
    a = b;
    b = temp;
  }
 
  while((n = a % b)!=0) {
    a = b;
    b = n;
  }
  printf( "%d\n",b);

return 0;

}

Measured memory_bytes: 592
/*
    Author: Jerry Yang C.H. (tico88612)
    Date: 2019/12/15
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

bool validate(int now, int a, int b){
    int total = 0;
    while(now){
        total += now % 10;
        now /= 10;
    }
    if(total >= a && total <= b)
        return 1;
    return 0;
}

/********** Good Luck :) **********/
int main()
{
    IOS();
    int N, a, b;
    cin >> N >> a >> b;
    int sum = 0;
    REP1(i, N){
        if(validate(i, a, b)){
            sum += i;
        }
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF 1LL<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll n; cin >> n;
    vl a(n);
    ll ans = 0;
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        REP(j,i+1,n) ans += a[i]*a[j];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

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

typedef long long int64;

class DBannedK {
 public:
  void solveOne(int caseNumber, std::istream &in, std::ostream &out) {
    int n;
    in >> n;
    vector<int> v(n);
    map<int, int> m;
    forn(i, n)in >> v[i], m[v[i]]++;

    map<int, int64> ways;
    int64 total = 0;
    for (auto e : m) {
      int64 times = 1LL * e.second * (e.second - 1) / 2;
      ways[e.first] = times;
      total += times;
    }

    for (int e : v) {
      int64 cur = total - ways[e];
      int64 times = 1LL * (m[e] - 1) * (m[e] - 2) / 2;
      out << cur + times << '\n';
    }

  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(i + 1, in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  DBannedK solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 16256
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

a.sort()
cnt = 0
for i in range(n):
    x = x - a[i]
    if x < 0:
        break
    elif i == n-1 and x > 0:
        break
    else:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt() - i - 1;
        }
        Arrays.sort(as);
        long median = as[n / 2];
        // if (n == 1) {
        //     median = as[0];
        // } else {
        //     median = n % 2 == 1 ? as[n / 2] : Math.round((as[n / 2 - 1] + as[n / 2]) / 2);
        // }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.abs(as[i] - median);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 66416
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong x, y, z;

int main() {
    cin >> x >> y >> z;

    swap(x, y);
    swap(x, z);

    cout << x << ' ' << y << ' ' << z << endl;

    return 0;
}


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

int n ;
LL ar[200005] ;

pair<LL,LL> BS(const int lower, const int upper){
	LL extra ;
	if(lower == 0)	extra =  0 ;
	else 	extra = ar[lower - 1] ;

	int l = lower, u = upper, mid, indx = -1 ;
	LL min_diff = LLONG_MAX ;

	while(l <= u){
		mid = (l + u) / 2 ;
		LL left = ar[mid] - extra ;
		LL right = ar[upper] - ar[mid] ;
		
		if(abs(left - right) < min_diff){
			min_diff = abs(left - right) ;
			indx = mid ;
		}
		
		if(left == right)
			break ;
		else if(left > right)
			u = mid - 1 ;
		else 
			l = mid + 1 ;
	}

	return {ar[indx] - extra, ar[upper] - ar[indx]} ;
}

int main(){

	cin >> n >> ar[0] ;
	for(int i = 1 ; i < n ; i++){
		cin >> ar[i] ;
		ar[i] += ar[i-1] ;
	}
	
	LL ans = LLONG_MAX ;
	for(int i = 1 ; i + 2 < n ; i++){
		pair<LL,LL> p1 = BS(0, i) ;
		pair<LL,LL> p2 = BS(i + 1, n - 1) ;
		ans = min(ans, ( max(p1.first, max(p1.second, max(p2.first, p2.second)))
					- min(p1.first, min(p1.second, min(p2.first, p2.second))) )) ;
	}
	cout << ans << endl ;

	return 0;
}

Measured memory_bytes: 1792
from sys import stdin
import math
import itertools
import re
import sys
sys.setrecursionlimit(10**8)
 
 
def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]
 
dp = {}
T = {}
 
def solve(input_string):
    N, Q = map(int, input_string[0].split())
    S = input_string[1]
    intMatrix = makeIntMatrix(input_string[2:])
    #print(input_string[2:])
    t=[0]*(N+1)
    for i in range(N):
        t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
    #for i in range(Q):
    for line in intMatrix:
        l, r = line
        #print(l, r)
        #print(S[l:r+1])
        #cnt = len(re.findall(r'AC', S[l-1:r]))
        #totalCnt = cntAC(L, R, S)
        totalCnt = t[r-1] - t[l-1]
        print(totalCnt)
    return
 

"""
wrong answer
def cntAC(l, r, D, S, cnt):
    global dp
    global T
    if r-l == D+1:
        return cnt
    if str(l)+str(r) not in T:
        T[str(l)+str(r)] = S[l-1:r]
        t = T[str(l)+str(r)]
    if str(l)+str(r) not in dp:
        #print(t)
        dp[str(l)+str(r)] = len(t.split('AC'))-1
        cnt = dp[str(l)+str(r)]
        return cntAC(l-1, r, D, S, cnt)
    else:
        cnt = dp[str(l)+str(r)]
        return cntAC(l-1, r, D, S, cnt)
"""
 

"""
wrong answer
def cntAC(L, r, S):
    global dp
    global T
    for l in range(L, r)[::-1]:
        if str(l)+str(r) not in T:
            T[str(l)+str(r)] = S[l-1:r]
            t = T[str(l)+str(r)]
        else:
            t = T[str(l)+str(r)]
        if str(l)+str(r) not in dp:
            dp[str(l)+str(r)] = len(t.split('AC'))-1
            cnt = dp[str(l)+str(r)]
        else:
            cnt = dp[str(l)+str(r)]
    return cnt
"""
 
def cntAC(L, R, S):
    cnt = 0
    for l in range(L, R):
        t = S[l-1:l+1]
        cnt +=  1 if t == 'AC' else 0
    return cnt

def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    #print(answer)
 
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 58612
#include <iostream>

using namespace std;

int main()
{
    int A , B , X ;
    cin >> A >> B >> X;

    if (A+B >= X ){
        if(A <= X){
            cout << "YES"<< endl;
        }
        else{
            cout << "NO"<<endl;
        }

    }
    else{
        cout <<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main()
{
    int p,q,r;
    scanf("%d%d%d",&p,&q,&r);
    int sum1,sum2,sum3;
    sum1=p+q;
    sum2=p+r;
    sum3=q+r;
    int t;
    if(sum1>sum2)
    {
        t=sum2;
        sum1=t;
        sum2=sum1;
    }
    if(sum1>sum3)
    {
        t=sum3;
        sum1=t;
        sum3=sum1;
    }
    printf("%d\n",sum1);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> ans(n+1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int s = x*x + y*y + z*z;
        s += x*y + y*z + z*x;
        if (s > n) continue;
        ans[s]++;
      }
    }
  }

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

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int map[3][105];
int a[105],b[105];
int main()
{
	int n;
	int num=0;
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&map[i][j]);
			if(i==1)a[++num]=map[i][j];
			if(i==2) b[++num]=map[i][j];
		}
		num=0;
	}
	int mon=0;
	int maxn=-1;
	for(int i=1;i<=n;i++)
	{
		mon=0;
		mon+=a[i];
		//printf("%d\n",mon);
		for(int j=i;j<=n;j++)
		{
		mon+=b[j];
		}
		//printf("%d\n",mon);
		for(int k=1;k<i;k++)
		{
			mon+=a[k];
		}
		//printf("%d\n",mon);
		if(mon>maxn) maxn=mon;
		//printf("\n\n");
	}
	printf("%d",maxn);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define mod 1000000007
#define inf 10010010010
using namespace std;

map<ll, ll> l;

map<ll,map<ll, ll> > dp;

map<ll,ll> prime_fact(ll n){
	if (dp.count(n)) return dp[n];
	map<ll, ll> m;
	ll root = n;
	for (ll i = 2; i*i <= root; i++){
		while (!(n % i)){
			n /= i;
			m[i]++;
		}
		if (m.count(i)) l[i] = max(l[i], m[i]);
	}
	if (n != 1){
		m[n]++;
		l[n] = max(l[n], m[n]);
	}
	dp[root] = m;
	return m;
}

//O(logB)
ll mpow(ll a, ll b, ll m){
	if (!b) return 1 % m;
	if (b == 1) return a % m;
	if (b % 2) return (a*mpow(a, b - 1, m)) % m;
	else return mpow((a*a) % m, b / 2, m) % m;
}

int main(){
	ll n; cin >> n;
	vl a(n);
	rep(i, n) cin >> a[i];
	rep(i, n) prime_fact(a[i]);
	ll val = 1;
	for (pair<ll, ll> lp : l){
		val = (val * mpow(lp.first, lp.second, mod)) % mod;
	}
	ll ans = 0;
	rep(i, n){
		ans = (ans + (val*mpow(a[i], mod - 2, mod)) % mod) % mod;
	}cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define N 13
#define pi M_PI

int main(){
   while(1){
	   int n;
	   scanf("%d",&n);
	   if(n==0)break;
	   double a[1000];
	   double m,tmp,ans;
           m=0;
           tmp=0;
           ans=0;
	   for(int i=0;i<n;i++){
		   scanf("%lf",&a[i]);
		   tmp+=a[i];
	   }
	   m=tmp/n;
		for(int i=0;i<n;i++){
			ans+=(a[i]-m)*(a[i]-m);
		}
		ans=ans/n;
		printf("%f\n",sqrt(ans));
   }
   return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define REP(var, num) for(int var = 0; var < num; var++)
#define REP2(var, num) for(; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;

int main() {
    sll n, y;
    cin >> n >> y;

    sll a=0, b;
    REP2(a, n+1) {
        b = 0;
        REP2(b, n+1) {
            int r = y - (10000*a + 5000*b);
            if (r < 0) {
                break;
            }

            int c = r / 1000;
            if (r % 1000 == 0 && a + b + c == n) {
                cout << a << ' ' << b << ' ' << c << endl;
                return 0;
            }
        }
    }

    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    X, Y, A, B, C = list(map(int, input().split()))
    P = sorted(list(map(int, input().split())), reverse=True)
    Q = sorted(list(map(int, input().split())), reverse=True)
    R = sorted(list(map(int, input().split())), reverse=True)
    eatreds = P[:X]
    eatgreens = Q[:Y]
    import heapq
    heapq.heapify(eatreds)
    heapq.heapify(eatgreens)
    for r in R:
        smallred = heapq.heappop(eatreds)
        smallgreen = heapq.heappop(eatgreens)
        reddiff = r-smallred
        greendiff = r-smallgreen
        if reddiff < 0 and greendiff < 0:
            heapq.heappush(eatreds, smallred)
            heapq.heappush(eatgreens, smallgreen)
            break
        if reddiff > greendiff:
            heapq.heappush(eatreds, r)
            heapq.heappush(eatgreens, smallgreen)
        else:
            heapq.heappush(eatreds, smallred)
            heapq.heappush(eatgreens, r)
    print(sum(eatreds)+sum(eatgreens))


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 106472
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int n,k;
    int a[110];
    while(scanf("%d%d",&n,&k)==2)
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            if(abs(a[i]-k)<a[i])
            {
                sum+=abs(a[i]-k);
            }
            else
            {
                sum+=a[i];
            }
        }
        printf("%d\n",sum*2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  if(s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()

using pii=pair<int,int>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }


int solve(){
  int n,d,x;
  cin >> n>> d>> x;
  vvi box(d,vi(n));
  rep(i,d)rep(j,n) cin>>box[i][j];

  rep(day,d-1){
    vi dp(100001,0);
    rep(i,x+1)dp[i]=i;
    rep(i,n){
      auto W=box[day][i];
      for(int w=W;w<=x;++w){
        dp[w]=max(dp[w],dp[w-W]+box[day+1][i]);
      }
    }
    int y=0;
    rep(w,x+1) y=max(y,dp[w]);
    x=y;
  }
  return x;
}


int main(){
  cout << solve() << endl;
}



Measured memory_bytes: 3536
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;


int main()
{
	int a,b,c,d;
	cin >> a >>b >> c >>d;
	int num1 = ceil(a * 1.0/ d);
	int num2 = ceil(c * 1.0 / b);
	if(num1 >= num2)
		cout << "Yes" <<endl;
	else
		cout << "No" << endl; 

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n, k;
  cin >> n >> k;
  vi h(n);
  ll count = 0;
  rep(i,n){
    cin >> h[i];
    if(h[i]>=k){
      count++;
    }
  }
  print(count);
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int dp[101010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    fill(dp, dp + N, inf);
    dp[0] = 0;
    int num;
    REPS(i, 1, N) {
        dp[i] = dp[i-1] + 1;
        num = 1;
        while (num <= i) {
            chmin(dp[i], dp[i-num] + 1);
            num *= 6;
        }
        num = 1;
        while (num <= i) {
            chmin(dp[i], dp[i-num] + 1);
            num *= 9;
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 640
p = input()
num = int(input())
for i in range(num):
    order = list(map(str,input().split()))
    a = int(order[1])
    b = int(order[2])
    if order[0] == 'print':
        print(p[a:b+1])
    elif order[0] == 'replace':
        rep = order[3]
        p = p[:a] + rep + p[b+1:]
    else:
        p = p[:a] + p[a:b+1][::-1] + p[b+1:]



Measured memory_bytes: 5612
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;

int main()
{
     int sum,a,c;
    cin>>sum>>a;
    for(int i=0;i<a;i++)
    {
        cin>>c;
        sum-=c;
    }
    if(sum<0)
    cout<<-1<<endl;
    else
    {
        cout<<sum<<endl;
    }
    return 0;
}


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

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

//ｍじゅれい７いくご；い８


Measured memory_bytes: 3068
#include<cstdio>
#define MAXN 105
int N,a[MAXN],ans;
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==a[i-1]) 
		{
			ans++;
			a[i]=0;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            long a = Long.parseLong(sl[0]);
            long b = Long.parseLong(sl[1]);
            long x = Long.parseLong(sl[2]);

            long ad = a / x;
            if (a % x != 0) ad++;

            long bd = b / x;

            System.out.println(b < ad * x ? 0 : bd - ad + 1);
        }
    }
}


Measured memory_bytes: 22996
N,M = map(int,input().split())
L = [0]*M
R = [0]*M
for i in range(M):
  l,r = map(int,input().split())
  L[i] = l
  R[i] = r
if min(R)-max(L) >= 0:
  print(min(R)-max(L)+1)
else:
  print(0)

Measured memory_bytes: 10868