akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> dy = { 0,1,0,-1 };
vector<int> dx = { 1,0,-1,0 };

int main() {

	int h, w; cin >> h >> w;
	vector<vector<char>> c(h + 2, vector<char>(w + 2, 'e'));
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> c[i][j];
		}		
	}
	bool can = true;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			bool tmpCan = false;
			if (c[i][j] == '#') {
				for (int k = 0;  k < 4;  k++) {
					if (c[i + dy[k]][j + dx[k]] == '#') {
						tmpCan = true;
					}
				}
				if (!tmpCan) can = false;
			}			
		}
	}
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3580
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

all_list = list(itertools.permutations(range(1, N + 1)))
p_index = all_list.index(P)
q_index = all_list.index(Q)
print(abs(p_index - q_index))

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

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

    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    vector<int> v, w;

    ll b = 0, a = 0, d = 0;
    ll c = 0;
    rep(i, n) {
        for (int j = 0; j < s[i].size() - 1; j++) {
            if (s[i][j] == 'A' && s[i][j + 1] == 'B') {
                c++;
            }
        }

        if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') {
            d++;
        } else if (s[i][0] == 'B') {
            b++;
        } else if (s[i][s[i].size() - 1] == 'A') {
            a++;
        }
    }

    if(d==0){
        c += min(a, b);
    }else{
        if((a+b)==0){
            c += d - 1;
        }else{
            c += d + min(a, b);
        }
    }

    cout << c << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int n,m;
vector<int> child[maxn];
bool type[maxn];
bool used[maxn];

bool flag=1;

void dfs(int u,bool t){
	debug(u);
	used[u]=1;
	type[u]=t;
	
	for(int v:child[u]){
		if(used[v]){
			if(type[v]==t){
				flag=0;
				return;
			}
		}
		else{
			dfs(v,!t);
		}
	}
}

ll c(int n){
	return 1LL*n*(n-1)/2;
}

int main()
{
	cin>>n>>m;
	REP(i,m){
		int u,v;
		cin>>u>>v;
		child[u-1].pb(v-1);
		child[v-1].pb(u-1);
	}
	dfs(0,0);
	debug(flag);
	if(flag){
		int cnt=0;
		REP(i,n) if(type[i]) cnt++;
		cout<<c(n)-c(cnt)-c(n-cnt)-m;
	}
	else{
		cout<<c(n)-m;
	}
	return 0;
}












Measured memory_bytes: 6656
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  vector<int> d(b);
  rep(i,b)
    cin>>d[i];
  int e[a][b];
  rep(i,a)rep(j,b)
    cin>>e[i][j];
  int g=0;
    rep(i,a){
      int k=c;
  rep(j,b){
    k+=e[i][j]*d[j];
  }
      if(k>0)
        g++;
  }
  out(g);
}

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

#define Max(a,b) max({a,b})
#define Min(a,b) min({a,b})
#define rep(i,m,n) for(int (i)=(m);(i)<(int)(n);(i)++)
#define len(n) n.size()
#define print(n) cout << (n) << endl;


// s.substr(i,n)

typedef long long ll;

using namespace std;

//char a = 65;
long long int inf = 1000000007;
int n,m,a,b,c,d,cou,co;
long long int lla,llb,llc;
double k;
const ll LINF = 1e18;
char num = 65;
string s,t;
int lis[20];
/*
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}
*/

int main(){
    
    cin >> s;

    if(s[0]==s[2]){
        print("Yes")
    }
    else{
        print("No")
    }

    return 0;
}

Measured memory_bytes: 256
import copy

h, w, k = map(int, input().split())
c = [[] for i in range(h)]
for i in range(h):
    c[i] = list(input())

ans = 0

for i in range(2**(h+w)):
    m = copy.deepcopy(c)
    for j in range(w):
        if i&(1<<j):
            for x in range(h):
                if m[x][j] == '#':
                    m[x][j] = 'r'
    for j in range(w, w+h):
        if i&(1<<j):
            for x in range(w):
                if m[j-w][x] == '#':
                    m[j-w][x] = 'r'
    cur = 0
    for x in range(h):
        for j in range(w):
            if m[x][j] == '#':
                cur += 1
    if cur == k:
        ans += 1

print(ans)

Measured memory_bytes: 77304
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <time.h>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);

}
ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x*x%mod;
		n >>= 1;
	}
	return res;
}
signed main() {
	int n;
	scanf("%d", &n);
	map<int, int> cou, cor;


	REP(i, n) {
		int a;
		scanf("%d", &a);
		cou[a]++;
		cor[abs(i - (n - i - 1))]++;
	}

	if (cor != cou)
		printf("0\n");
	else
		printf("%lld\n", mod_pow(2, n/2, MODU)%MODU);


	return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int M=1e9+7;
int n,k,a[100005],ans;
vector<int> v;
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*x%M)
		if (y&1)(ans*=x)%=M;
	return ans;
}
signed main(){
	scanf("%lld%lld",&n,&k);
	for (int i=1;i*i<=n;i++)
		if (n%i==0){
			v.push_back(i);
			if (i*i!=n)v.push_back(n/i);
		}
	sort(v.begin(),v.end());
	for (int i=0;i<(int)v.size();i++){
		a[i]=ksm(k,(v[i]+1)/2);
		for (int j=0;j<i;j++)
			if (v[i]%v[j]==0)(a[i]+=M-a[j])%=M;
		if (v[i]&1)(ans+=v[i]*a[i])%=M;
		else (ans+=v[i]/2*a[i])%=M;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;

string S;

int main() {
  cin >> S;
  char key = S[0];
  rep(i, 3) {
    if(S[i+1] == key) {
      cout << "Bad" << endl;
      return 0;
    }
    key = S[i+1];
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define For(i,a,n) for(i=a;i<n;i++)
#define all(ar) ar.begin(),ar.end() 
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
const ll mod = 1000000007;
ll mod2 = 10000000000007, dum = 252097800623;
ll binex(ll a,ll b){
    ll ans = 1,pa = 0;
    while(b){
        if(b%2) ans = (ans * (a%mod2)) % mod2;
        a %= mod2;
        a = (a * a) % mod2; 
        b /= 2; 
        if(ans < pa) return dum;
        else pa = ans;
    }
    return ans;
}
void gcc(ll p,ll n){
    ll gcd = 1;
    for(ll i = 1;i * i <= p;i++){
        if(p % i == 0){
            ll y = p/i;
            ll num1 = binex(i,n);
            ll num2 = binex(y,n);
            if(p % num1 == 0) gcd = max(gcd,i);
            if(p % num2 == 0) gcd = max(gcd,y);
        }
    }
    cout<<gcd;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    ll n,p;
    cin>>n>>p;
    gcc(p,n);
    return 0;
}

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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  int N,O=0;
  long long int X,Y,D;
  cin >> N >> D;

  for(int i=0;i<N;i++){
    cin >> X >> Y;
    if(X*X+Y*Y<=D*D){
      O++;
    }
  }
  cout << O;
  
  return 0;
}


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 3616
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    Arrays.sort(A);
    
    TreeMap<Integer, Long> map = new TreeMap<>(Comparator.reverseOrder());
    for (int i = 0; i < M; i++) {
      int B = sc.nextInt();
      int C = sc.nextInt();
      map.put(C, map.getOrDefault(C,0L)+B);
    }
    
    long ans = 0;
    Iterator<Map.Entry<Integer, Long>> itr = map.entrySet().iterator();
    int i = N-1;
    long left = 0;
    while (i >= left && itr.hasNext()) {
      Map.Entry<Integer, Long> entry = itr.next();
      int val = entry.getKey();
      long count = entry.getValue();
      while (i >= left && val <= A[i]) {
        ans += A[i];
        i--;
      }
      if (i >= left && val > A[i]) {
        long len = Math.min((long) i-left+1, count);
        ans += val*len;
        left += len;
      }
    }
    while (i >= left) {
      ans += A[i];
      i--;
    }
    
    System.out.println(ans);
  }
}


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

int main(){

	int n; cin >> n;
	string T;
	string H;
	int T_score=0;
	int H_score=0;

	for(int i=0; i<n; i++){
		cin >> T >> H;
		if(T>H)
			T_score += 3;
		else if(T<H)
			H_score += 3;
		else{
			T_score ++;
			H_score ++;
		}
	}
	cout << T_score << " " << H_score << endl;
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    int D = read();
    printf("Christmas");
    for(int i=D;D<25;D++) printf(" Eve");
    printf("\n");
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

int main(int argc, char *argv[])
{
	int a, b;
	char buf[100], buf2[100];
	char *lt = "<";
	char *gt = ">";
	char *eq = "==";

	scanf("%s %s", buf, buf2);

	a = atoi(buf);
	b = atoi(buf2);

    printf("a %s b\n", a < b ? lt : (a > b ? gt : eq));

	return 0;
}

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


int main(){
    int n; cin >> n;
    vector<int> H;
    vector<pair<int, int>> p;
    for(int i = 0; i < n; i++){
        int h; pair<int, int> xy;
        cin >> xy.first >> xy.second >> h;
        p.push_back(xy);
        H.push_back(h);
    }
    
    for(int cx = 0; cx <= 100; cx++){
        for(int cy = 0; cy <= 100; cy++){
            int top_H;
            for(int i = 0; i < n; i++){
                if(H[i] > 0){
                    top_H = (H[i] + abs(p[i].first - cx) + abs(p[i].second - cy));
                    break;
                }
            }

            for(int i = 0; i < n; i++){
                //if( i == 0 )top_H = max((H[i] + abs(p[i].first - cx) + abs(p[i].second - cy)),0);

                //if(top_H != max((H[i] + abs(p[i].first - cx) + abs(p[i].second - cy)),0)){
                if(H[i] != max(0, top_H- abs(p[i].first - cx) - abs(p[i].second - cy))){
                    break;
                }else if( i == n - 1){
                    cout << cx << " " << cy << " " << top_H << endl;
                    //cout << abs(p[i].first - cx) << abs(p[i].second - cy) << endl;
                    exit(0);
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;



main(){
#ifdef LOCAL
	freopen("J_input.txt", "r", stdin);
	//freopen("J_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, m, v, p;
	cin >> n >> m >> v >> p;
	v--;

	vector<int> arr(n);
	for (int i=0; i < n; ++i) cin >> arr[i];

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

	int l = 0, r = arr.size() + 1;
	while (r - l > 1) {
		int mid = (l+r)/2;
		int cur = n-1;
		int votes = m*v;

		for (int i = 0; i < p - 1; ++i) {
			while (cur == mid - 1) cur--;
			votes -= m;
			votes = max(votes, 0LL);
			cur--;
		}

		bool cfn = true;

		for (;cur >= 0; cur--) {
			if (cur == mid-1) continue;
			int my_val = arr[mid - 1] + m;
			int can = my_val - arr[cur];
			if (can < 0) cfn = false;
			votes -= max(0LL, min(can, m));
			votes = max(votes, 0LL);
		}

		if (votes == 0 && cfn) r = mid;
		else l = mid;
	}

	cout << n-l;



}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
 
#define ELEMENT_CNT_MIN 1
#define ELEMENT_CNT_MAX 1000000
#define ELEMENT_MIN 0
#define ELEMENT_MAX 1000000000
#define SHELL_SROT_CNT_MIN 1
#define SHELL_SROT_CNT_MAX 100

void shell_sort(int *p_arr, int size);
int insertion_srot(int *p_arr, int size, int interval);
void put_arr(int *p_arr, int size);
int get_int_sequence(int *p_num, int min, int max, int size);
int get_int(int *p_num, int min, int max);
int judge_constraint(int test_num, int min, int max);

 
int main(void){
     
    int element_num;
    int element[ELEMENT_CNT_MAX];
     
    if(get_int(&element_num, ELEMENT_CNT_MIN, ELEMENT_CNT_MAX) == -1)
    {
        return -1;
    }
     
    if(get_int_sequence(&element[0], ELEMENT_MIN, ELEMENT_MAX, element_num) == -1)
    {
        return -1;
    }
    
    shell_sort(&element[0], element_num);
    
    put_arr(&element[0], element_num);
    
    return 0;
}
 
int insertion_srot(int *p_arr, int size, int interval)
{
    int cnt = 0;    /* calculation amount */
    int i;
    int j;
    int locator;
    
    for(i = interval; i < size; i++)
    {
        locator = p_arr[i];
        j = i - interval;
        while(j >= 0 && p_arr[j] > locator)
        {
            p_arr[j + interval] = p_arr[j];
            j = j - interval;
            cnt++;
        }
        p_arr[j + interval] = locator;
    }
    
    return cnt;
}

void shell_sort(int *p_arr, int size)
{
   int cnt = 0;
   int interval = 1;    /* (pow(3, 0) - 1) / 2 == 0 */
   int i;
   int shell_sort_cnt = SHELL_SROT_CNT_MIN;
   
  for(i = shell_sort_cnt ;i <= SHELL_SROT_CNT_MAX; i++)
  {
      interval =  (int)((pow(3, i) - 1) / 2);
      if(interval > size)
      {
          shell_sort_cnt = i - 1;
          printf("%d\n",shell_sort_cnt);
          break;
      }
  }
   
   
   for(i = shell_sort_cnt;;i--)
   {
       interval =  (int)((pow(3, i) - 1) / 2);
       cnt += insertion_srot(p_arr, size, interval);
       printf("%d ", interval);
       if(interval <= 1)
       {
           printf("\n");
           break;
       }
   }
   
   printf("%d\n", cnt);
   
   return;
}
 
void put_arr(int *p_arr, int size)
{
    int i;
     
    for(i = 0; i < size; i++)
    {
        printf("%d\n", p_arr[i]);
    }
    
    return;
}
 
int get_int_sequence(int *p_num, int min, int max, int size)
{
    int i;
     
    for(i = 0; i < size; i++)
    {
        if(get_int(&p_num[i], min, max) == -1)
        {
            return -1;
        }
    }
     
    return 0;
}
 
int get_int(int *p_num, int min, int max)
{
    scanf("%d%*c", p_num);
     
    if(judge_constraint(*p_num, min, max) == -1)
    {
        return -1;
    }
     
    return 0;
}
int judge_constraint(int test_num, int min, int max)
{
    if(test_num < min || test_num > max)
    {
        return -1;
    }
     
    return 0;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n; cin >> n;
  vector<int> a(n); for(int i=0;i<n;i++) { cin >> a[i]; }
  lint q; cin >> q;
  vector<lint> b(q),c(q); for(int i=0;i<q;i++) { cin >> b[i] >> c[i]; }

  lint sum=0;
  vector<lint> d(100000,0);
  for(int i=0;i<n;i++) {
    sum += a[i];
    d[a[i]-1]++; 
  }

  for(int i=0;i<q;i++) {
    sum += (c[i]-b[i])*d[b[i]-1];
    d[c[i]-1] += d[b[i]-1];
    d[b[i]-1] = 0;
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 5892
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
int n;
set<int>ans;
vector<int>v;
void gf(int x);
bool jdg(int x);
signed main(){
	Rd(n),gf(n-1);
	for(int i:v)if(i>=2)ans.insert(i);
	gf(n);
	for(int i:v)if(i>=2&&jdg(i))ans.insert(i);
	wr(ans.size());
}
void gf(int x){
	v.clear();
	for(int i(1);i*i<=x;++i)if(!(x%i)){
		v.push_back(i);
		if(i*i<x)v.push_back(x/i);
	}
}
bool jdg(int x){
	int r(n);
	while(!(r%x)){
		r/=x;
		if(!((r-1)%x))return 1;
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define N 100
using namespace std;

struct Card{
  char suit;
  char value;
};

void trace (Card C[], int n) {
  int i;
  rep(i,n) {
    cout << C[i].suit << C[i].value;
    if (i < n-1) cout << " ";
  }
  cout << endl;
}

void swap (Card* C1, Card* C2) {
  Card tmp;
  tmp = *C1;
  *C1 = *C2;
  *C2 = tmp;
}

void BubbleSort (Card C[], int n) {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = n - 1; j > i; j--) {
      if (C[j].value < C[j-1].value) swap(C[j],C[j-1]);
    }
  }
}

void SelectionSort (Card C[], int n) {
  int i, j, mini;
  for (i = 0; i < n; i++) {
    mini = i;
    for (j = i; j < n; j++) {
      if (C[j].value < C[mini].value) mini = j;
    }
    swap(C[i], C[mini]);
  }
}

bool IsStable (Card C1[], Card C2[], int n) {
  int i;
  rep(i,n) if (C1[i].suit != C2[i].suit) return false;
  return true;
}
  

int main () {
  Card C1[N],C2[N];
  int n,i;
  string card;
  
  // input
  cin >> n;
  rep(i,n) {
    cin >> card;
    C1[i].suit = card[0];
    C1[i].value = card[1];
  }
  rep(i,n) C2[i] = C1[i];

  // sort
  BubbleSort(C1,n);
  SelectionSort(C2,n);

  // output
  trace(C1,n);
  cout << "Stable" << endl;
  trace(C2,n);
  (IsStable(C1, C2, n))? cout << "Stable" : cout << "Not stable";
  cout << endl;
  return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO

    string s;
    cin >> s;

    if(s != "AAA" && s != "BBB") cout << "Yes\n";
    else cout << "No\n";

}








Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.next();
        String t = stdIn.next();
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        String u = stdIn.next();

        if (s.equals(u)) {
            a -= 1;
        } else {
            b -= 1;
        }

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


Measured memory_bytes: 21844
# frozen_string_literal: true

@k, @n = gets.split.map(&:to_i)

array = gets.split.map(&:to_i).sort
list = []
array.each_with_index do |e, i|
  if i < array.size - 1
    list.push(array[i + 1] - e)
  else
    list.push(@k + array[0] - e)
  end
end

puts @k - list.max


Measured memory_bytes: 20592
a,b = map(int, input().split())
ans = 0
if b % 2 == 0:
    half = b // 2
    ex_half = a - half
    # print(ex_half)
    n_half = ex_half // b + 1
    # print(n_half)
    ans = ans + n_half
    if n_half >= 2:
        ans = ans + 3 * n_half * (n_half-1)
    if n_half >= 3:
        ans = ans + 6 * n_half * (n_half-1) * (n_half-2) // 6
else:
    pass
n_baisuu = a // b
# print(n_baisuu)
ans = ans + n_baisuu
if n_baisuu >= 2:
    ans = ans + 3 * n_baisuu * (n_baisuu-1) // 2 * 2
if n_baisuu >= 3:
    ans = ans + 6 * n_baisuu * (n_baisuu-1) * (n_baisuu-2) // 6
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  int n, k;cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;i++){
    ans+=pow(double(0.5), double(max(double(0), ceil(log2(double(k)/double(i))))));
  }
  cout << fixed << setprecision(12) << ans/double(n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x,y,z;
	cin >> x >> y >> z;
	ll ans=0;
	x -= z;
	ans += x/(y+z);
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader r = new InputReader(System.in);
		char[] arr = r.next().toCharArray();
		int k = r.nextInt();
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] != 'a') {
				int dist = 'z' - arr[i] + 1;
				if (dist <= k) {
					arr[i] = 'a';
					k -= dist;
				}
			}
		}
		if (k > 0) {
			k %= 26;
			for (int j = 0; j < k; j++)
				if (arr[arr.length - 1] != 'z')
					arr[arr.length - 1]++;
				else
					arr[arr.length - 1] = 'a';
		}
		System.out.println(new String(arr));
	}

	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader(FileReader stream) {
			reader = new BufferedReader(stream);
			tokenizer = null;
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 12276
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
int main()
{    
	int n,m;
	cin>>n>>m;
	string a[10001];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		cout<<a[i];
	}
    cout<<endl;
	return 0;
}



Measured memory_bytes: 384
a, b, c = [ int(i) for i in input().split(" ") ]

# (a, b) c
if a == b and (a != c or b != c):
  print("Yes")
# (a, c) b
elif a == c and (a != b or c != b):
  print("Yes")
# (b, c) a
elif b == c and (b != a or c != a):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define PI 3.14159265
	
int main(void){
	int num;
	while(1){
		double ave=0,sd=0,data;
		cin>>num;
		if(num==0)
			break;
		for(int i=0;i<num;i++){
			cin>>data;
			sd += data*data;
			ave += data;
		}
		sd /= num;
		ave /= num;
		sd -= ave*ave;
		cout.precision(8);
		cout<<sqrt(sd)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1284
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ins(s1, s2, s3);
    cout << (char)toupper(s1.front());
    cout << (char)toupper(s2.front());
    cout << (char)toupper(s3.front());
    out();
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	ll n, m;
	cin >> n >> m;
	ll N = (n == 1) ? 1 : n - 2;
	ll M = (m == 1) ? 1 : m - 2;
	ll ans = N * M;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate,chain



def max_merit(b,l,u):
    return u*(X-b) + l*b

def merit(a,b,l,u):
    return (u if a > b else l)*(a-b) + l*b

N,X = map(int,input().split())

blu = list(tuple(map(int,input().split())) for _ in range(N))
required = sum(l*b for b,l,u in blu)
blu = sorted(((max_merit(*x), x) for x in blu), reverse=True)


for mi,x in enumerate(accumulate(m for m,_ in blu)):
    if x >= required:
        msum2 = x
        msum1 = x - blu[mi][0]
        break

def helper():
    for i,(m,x) in enumerate(blu):
        if i >= mi:
            r = required - msum1
        else:
            r = required + m - msum2

        b,l,u = x
        if r <= l*b:
            yield mi*X + (r-1)//l + 1
        else:
            r -= l*b
            yield mi*X + b + (r-1)//u + 1

print(min(helper()))



Measured memory_bytes: 32052
import heapq
V,E,r = map(int, input().split())
Graph = [[] for _ in range(V)] 
for _ in range(E):
        s,t,d = map(int, input().split())
        Graph[s].append((t,d)) 
pq = []
dist = [10**10]*V
dist[r] = 0
heapq.heappush(pq, (0, r))
while pq:
        w, n = heapq.heappop(pq)
        for node, weight in Graph[n]:
                newlen = w + weight
                if newlen < dist[node]:
                        dist[node] = newlen
                        heapq.heappush(pq, (dist[node], node))
for i in dist:
        if i == 10**10:
                print("INF")
        else:
                print(i)


Measured memory_bytes: 89280
#include<cstdio>
#define MN 100000
int a[MN+5];
inline int z(int x){return x<0?-x:x;}
int main()
{
	int n,i,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]);
	for(i=0;i<=n;++i)ans+=z(a[i]-a[i+1]);
	for(i=1;i<=n;++i)printf("%d\n",ans-z(a[i-1]-a[i])-z(a[i]-a[i+1])+z(a[i-1]-a[i+1]));
}

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

using namespace std;

int main(){
	int H, W; cin >> H >> W;
	char a[H][W];
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < H + 2; ++i){
		for(int j = 0; j < W + 2; ++j){
			if(i == 0 || i == H + 1){
				cout << '#';
				continue;
			}
			if(j == 0 || j == W + 1){
				cout << '#';
				continue;
			}
			cout << a[i-1][j-1];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let n, m = Scanf.sscanf (read_line ()) "%d %d" ( fun n m -> n, m)

let lst = List.init n ( fun _ -> 
        List.tl (Str.split (Str.regexp " ") (read_line ()))
        |> List.map int_of_string 
        |> Set.of_list
)

let () =
        Set.cardinal (List.fold_left (fun a b -> Set.intersect a b) (List.hd lst) (List.tl lst)) 
        |> Printf.printf "%d\n"


Measured memory_bytes: 3584
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, A, B, C;
    scan(N, A, B, C);
    ubyte mask = cast(ubyte)((1 << N) - 1);
    long[] L = new long[](N);
    foreach (i; 0 .. N)
        scan(L[i]);
    long ans = long.max;
    foreach (ubyte i; 0 .. 255)
        foreach (ubyte j; 0 .. 255)
            foreach (ubyte k; 0 .. 255)
            {
                ubyte a, b, c;
                a = cast(ubyte)(i + 1);
                b = cast(ubyte)(j + 1);
                c = cast(ubyte)(k + 1);
                if ((a & mask) != a || (b & mask) != b || (c & mask) != c)
                    continue;
                if ((a & b) != 0 || (b & c) != 0 || (c & a) != 0)
                    continue;
                long[] len = [0, 0, 0];
                ubyte[] choice = [a, b, c];
                long cost;
                foreach (l; 0 .. 8)
                {
                    ubyte mask2 = cast(ubyte)(1 << l);
                    foreach (m, x; choice)
                        if ((x & mask2) != 0)
                        {
                            cost += (len[m] == 0) ? 0 : 10;
                            len[m] += L[l];
                        }
                }
                cost += abs(len[0] - A);
                cost += abs(len[1] - B);
                cost += abs(len[2] - C);
                // if (cost < ans)
                //     writefln("%d %d %d", a, b, c);
                ans = min(ans, cost);
            }
    writeln(ans);
}


Measured memory_bytes: 1276
#include<iostream>
using namespace std;
int main(){
  int n,a,cake,eat,sum=0,mycake;
    cin>>n>>a;
  for(int i=0;i<a;i++){
    cin>>cake;
    sum=cake+sum;
  }
  if(sum%(n+1)>0){
    mycake=sum/(n+1)+1;
    cout<<mycake<<endl;
  }
  else{
    mycake=sum/(n+1);
    cout<<mycake<<endl;
  }
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll a,b,curr=2,ans=0;
		cin>>a>>b;
		ll fin=(ll)pow(2,floor(log(b)/log(2))+1);
		while(curr<=fin)
		{
			ll c=(b/curr-a/curr)*curr/2;
			c-=min(curr/2,a%curr);
			c+=min(curr/2,b%curr+1);
			//cout<<curr<<" "<<c<<endl;
			if((b-a+1-c)&1)
				ans+=curr/2;
			curr*=2;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var (
		n      int
		y      int
		result string = "-1 -1 -1"
	)

	fmt.Scan(&n, &y)

	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			k := n - i - j

			if y == 10000*i+5000*j+1000*k {
				result = strconv.Itoa(i) + " " + strconv.Itoa(j) + " " + strconv.Itoa(k)
			}
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, s, n) for (int i = (s); i < (n); ++i)
#define repsr(i, n, s) for (int i = (n); i >= (s); --i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
const int64_t inf = (int64_t)1e18;

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

  int N; cin >> N;
  vector<int> as(3 * N);
  rep(i, 3 * N) cin >> as[i];
  
  priority_queue<int, vector<int>, greater<int>> pql;
  priority_queue<int> pqr;
  int64_t sum_l = 0;
  int64_t sum_r = 0;
  vector<int64_t> bs(N + 1, 0);


  rep(i, N) {
    sum_l += as[i];
    pql.push(as[i]);
  }
  bs[0] = sum_l;

  reps(i, N, 2 * N) {
    if (pql.top() < as[i]) {
      sum_l -= pql.top(); pql.pop();
      sum_l += as[i];
      pql.push(as[i]);
    }
    bs[i - N + 1] = sum_l;
  }


  reps(i, 2 * N, 3 * N) {
    sum_r += as[i];
    pqr.push(as[i]);
  }
  bs[N] -= sum_r;

  repsr(i, 2 * N - 1, N) {
    if (pqr.top() > as[i]) {
      sum_r -= pqr.top(); pqr.pop();
      sum_r += as[i];
      pqr.push(as[i]);
    }
    bs[i - N] -= sum_r;
  }

  int64_t ans = -inf;
  repe(i, N) ans = max(ans, bs[i]);
  cout << ans << "\n";

  return 0;
}

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

int main(){
  ll N;
  cin >> N;
  vector<int> S;
  if(N==0){
    cout << 0 << endl;
    return 0;
  }
  while(N!=0){
    S.push_back(abs(N)%2);
    N-=abs(N)%2;
    N/=-2;
  }
  for(int i=(int)S.size()-1;i>=0;--i){
    cout << S[i];
  }
  cout << endl;
}

Measured memory_bytes: 3532
n, m = gets.split.map(&:to_i)
b = Array.new(n+1)
b[1] = true
c = Array.new(n+1){1}

m.times{
  x, y = gets.split.map(&:to_i)
  b[y] = true if b[x]
  c[x] -= 1
  c[y] += 1
  b[x] = false if c[x] == 0
}
p b.count(true)

Measured memory_bytes: 3324
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 2147483647
#define Max 500000
#define NTL -1
#define min(a,b) ((a>b)?b:a)
#define max(a,b) ((a<b)?b:a)

#include<stdio.h>
int main(){
  int a[5],tmp,i,j;
  for(i=0;i<5;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<4;i++){
    for(j=4;j>i;j--){
      if(a[j]>a[j-1]){
    tmp=a[j];
    a[j]=a[j-1];
    a[j-1]=tmp;
      }
    }
  }
  printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
  return 0;
}


Measured memory_bytes: 2100
N = int(input())
CSF = [[0] * 3 for i in range(N-1)]

for i in range(N-1):
    c, s, f = map(int, input().split())
    CSF[i][0] = c
    CSF[i][1] = s
    CSF[i][2] = f

for i in range(N-1):
    now = CSF[i][1]+CSF[i][0]
    for j in range(i+1, N-1):
        # 1本目の前なら1本目まで待つ
        if now <= CSF[j][1]:
            now += CSF[j][0]+(CSF[j][1]-now)

        # 1本目以降なら待ち時間と移動時間を加算する
        else:
            while (now - CSF[j][1]) % CSF[j][2] != 0:
                now += 1
            now += CSF[j][0]
    print(now)
print(0)


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

using namespace std;

typedef long long LL;

int main() {
    int k, x;
    scanf("%d%d", &k, &x);
    int l = max(-1000000, x - k + 1);
    int r = min(1000000, x + k - 1);
    for (int i = l; i <= r; ++i) printf("%d%c", i, i == r ? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int f[1000000];
int main(){
//	freopen("j.txt","r",stdin);
	int n;
	cin>>n;
	memset(f,0,sizeof(f));
	for (int i=1;i<=n;i++)
		cin>>f[i];
	sort(f+1,f+1+n);
	int flag=0,max1=0,max2=0;
	for (int i=n-1;i>=1;i--)
		if (f[i]==f[i+1] && !flag){
			max1=f[i];
			flag=1;
		} else if (f[i]==f[i+1] && flag){
			if (f[i]==f[i-1] && f[i]==max1) {
				max2=f[i];
				break;
			}
				else if (f[i]!=max1){
					max2=f[i];
					break;
				} 
		}
    long long s;
	s=(long long)max1*(long long)max2;
	//cout<<max1<<" "<<max2<<endl;
	cout<<s<<endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define N (int)1e5
#define INF (int)1e9
#define mod (int)1e9 + 7
#define LL long long
LL n, a[N], c, d, cnt, cnt2, gyo;
map<LL, LL> b;
int main()
{
	cin >> n;
	gyo = (n + 1) * (n / 2);
	if (n % 2)
		gyo += n / 2 + 1;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		cnt += a[i];
		cnt2 += cnt / gyo;
		cnt %= gyo;
		if (i)
			b[a[i] - a[i - 1]]++;
	}
	if (cnt)
	{
		cout << "NO" << endl;
		return 0;
	}
	for (auto i = b.begin(); i != b.end(); i++)
	{
		d = i->first;
		while (d < cnt2)
		{
			d += n;
		}
		if (d != cnt2)
		{
			cout << "NO" << endl;
			return 0;
		}
	}


	cout << "YES" << endl;
}
//1 2 3 4 5
//1 2 3 4 5
//3 4 5 1 2
//
//5 8 11 9 12
//
//3 3 -2 3 -7

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;

    ll ans=0;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i==0 && n/i-1>i) ans+=n/i-1;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3648
//
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;

ll max(ll x, ll y)
{
	return x < y ? y : x;
}

ll n, m, w[maxn], v[maxn], f[maxn];

int main()
{
    cin >> n >> m;
    
    for(int i = 1; i <= n; i++)
    {
        cin >> v[i] >> w[i];
    }
    
    for(int i = 1; i <= n; i++)
    {
        for(int j = m; j >= v[i]; j --)
        {
            f[j] = max(f[j], f[j - v[i]] + w[i]);
        }
    }
    cout << f[m] << endl;
    
    return 0;
}

Measured memory_bytes: 1024
=begin
a = gets.split("").map{|x| x.to_s}
b = gets.split("").map{|x| x.to_s}
count = 0
3.times do |i|
  if a[i] == b[i]
    count += 1
  end
end

p count
=end

a = gets.split(" ").map{|x| x.to_i}
if a[1] == 1
  p 0
  exit()
end
a[1] -= a[0]
ans = 1
while true
  break if (a[1] <= 0)
  a[1] -= a[0] - 1
  ans += 1
end
p ans


Measured memory_bytes: 1788
public class Main {
    public static void main(String[] args) {

        // ??????????????????????????????.
        // ??¢?´¢????±???¨???????????????????????????.
        java.util.Scanner sc = new java.util.Scanner(System.in);
        String W = sc.next();

        // END_OF_TEXT ?????§?????????????????????.
        // ???????????????????????????????????????. ????????\??? (????????????????????????) ?????????????????????????????????.
        // ???????????????????????¢?´¢????±???¨?????´??????????????????.
        int count = 0;
        String T;
        String[] word;
        while (true) {
            T = sc.nextLine();
            if (T.equals("END_OF_TEXT")) { break; }
            word = T.split("[.,!\"?:... ]");
            for (int i = 0; i < word.length; i ++) {
                if (word[i].equalsIgnoreCase(W)) { count ++; }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 26120
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  int num = 0;
  cin>>N;
  string S = to_string(N);
  for(int i = 0;i < S.size();i++){
    if(S[i] == '7'){
      cout<<"Yes"<<'\n';
      num = 1;
      break;
    }
  }
  if(num == 0){
    cout<<"No"<<'\n';
  }
}

Measured memory_bytes: 3660