akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
  
ans_N = Base_10_to_n(N, K)

print(len(list(str(ans_N))))

Measured memory_bytes: 2940
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ",trim(fgets(STDIN)));
  $num = [];
  for($i=0; $i<$n; $i++){
      $num[$a[$i]]++;
      $num[$a[$i]-1]++;
      $num[$a[$i]+1]++;
  }
  rsort($num);
  echo $num[0];

Measured memory_bytes: 20980
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    char f[3][4];
    while(scanf("%s",f[0]),f[0][0]!='0'){
        for(int i=1;i<3;i++)scanf("%s",f[i]);
        char ans=0;
        for(int i=0;i<3;i++){
            if(f[0][i]==f[1][i]&&f[1][i]==f[2][i]&&f[2][i]!='+')ans=f[0][i];
            if(f[i][0]==f[i][1]&&f[i][1]==f[i][2]&&f[i][2]!='+')ans=f[i][0];
        }
        if(f[0][0]==f[1][1]&&f[1][1]==f[2][2]&&f[1][1]!='+')ans=f[0][0];
        if(f[0][2]==f[1][1]&&f[1][1]==f[2][0]&&f[1][1]!='+')ans=f[0][2];

        if(ans==0)printf("NA\n");
        else printf("%c\n",ans);
    }
    return 0;
}

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

int main()
{
    int x, y;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        if((2 * i + 4 * (x - i)) == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
g = [[] for i in range(N)]

for i in range(N-1):
    u, v, w = list(map(int, input().split()))
    u -= 1; v -= 1

    g[u].append((w, v))
    g[v].append((w, u))

from heapq import heappush, heappop, heapify
INF = float('inf')

dist = [INF] * N
visited = [False] * N

q = g[0]
heapify(q)
dist[0] = 0
visited[0] = True

while q:
    c, v = heappop(q)

    if visited[v]: continue
    visited[v] = True
    dist[v] = c

    for w, u in g[v]:
        if visited[u]: continue
        heappush(q, (c+w, u))

for i in range(N):
    if dist[i] % 2: print(0)
    else: print(1)

Measured memory_bytes: 47560
#include<stdio.h>
#include<string.h>
int main (void){
 char S[2*10*10*10*10*10+1];
 char T[2*10*10*10*10*10+1];
 int len;
 int i,j;
 j=0;
 scanf("%s", S);

 scanf("%s", T);
len = strlen(S);
for(i = 0;i < len;i++){
     if(S[i] != T[i]){
         j++;
     }
     
}
     printf("%d",j);
     return 0;
}
 

Measured memory_bytes: 2108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
  char buf[32] = { 0 };
  int N,A,B;
  int n = 0; //桁数
  int sum = 0; //位の和
  int total = 0;
  
  //入力読み込み
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d %d %d", &N, &A, &B);
  
  n = log10((double)N);
  
  for(int num = 1; num <= N; num++){
    int n_tmp = n;
    int num_tmp = num;
    int pow_tmp = (int)pow(10, n_tmp);
    sum = 0;
    for(;n_tmp >= 0; n_tmp--,pow_tmp = (int)pow(10, n_tmp)){
      if(num_tmp < pow_tmp) continue;
      sum += num_tmp / pow_tmp;
      num_tmp = num_tmp % pow_tmp;   
    }
    if(sum >= A && sum <= B) total += num;
  }
  
  printf("%d\n", total);
  return 0;
}

Measured memory_bytes: 2556
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

val = X
cnt = 0
while val <= Y:
    val *= 2
    cnt += 1
print(cnt)

Measured memory_bytes: 65176
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MOD = 1e9+7;
signed main(){
  init_io();
  ll n;
  cin >> n;
  vector<ll> a(n),sum(n+1,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    sum[i+1] += sum[i] + a[n-1-i];
    sum[i+1] %= MOD;
  }
  ll ans = 0;
  for(int i=0;i<n;i++){
    ans += (a[i] * sum[n-1-i])%MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
ll n,d,a,x,h,ans;
vector<pair<ll,ll>>v;
ll seg[N<<2],lazy[N<<2];

void build(int i, int l, int r) {
	if (l==r){
		seg[i] = v[l].second;
		return ;
	}
	int mid=(l + r)>>1;
	build(i<<1,l,mid);
	build(i <<1|1,mid+1,r);
	seg[i]=max(seg[i << 1],seg[i<<1|1]);
}

void push(int i, int l, int r) {
	if (!lazy[i])return ; 
	seg[i]+=lazy[i];
	if (l!=r) lazy[i << 1]+=lazy[i], lazy[i<<1|1]+=lazy[i];
	lazy[i]=0;
}
void update(int i, int l, int r, int a, int b, ll v) {
	push(i, l, r);
	if (l>b||r<a)return ;
	if (l>=a&&r<=b) {
		lazy[i]+=v;
		return push(i,l,r);
	}
	int mid=(l + r)>>1;
	update(i << 1, l, mid, a, b, v);
	update(i << 1 | 1, mid + 1, r, a, b, v);
	seg[i]=max(seg[i << 1], seg[i << 1 | 1]);
}
ll get(int i, int l, int r, int a, int b) {
	push(i, l, r);
	if (l>b||r<a) return -1e15;
	if (l>=a&&r<=b) return seg[i];
	int mid=(l + r)>>1;
	ll ret=get(i << 1, l, mid, a, b);
	ret=max(ret, get(i << 1 | 1, mid + 1, r, a, b));
	seg[i] = max(seg[i << 1], seg[i << 1 | 1]);
	return ret;
}

int main()
{
    
    cin>>n>>d>>a;
    for(int i=0;i<n;i++){ 
        cin>>x>>h;
        h=(h+a-1)/a;
        v.push_back({x,h});
    } 
    sort(v.begin(),v.end());
    build(1,0,n-1);
    for(int i=0;i<n;i++){ 
       int x=get(1,0,n-1,i,i);
        
       if(x<=0)continue;
       int l=i,r=n-1,end;
       while(l<=r){ 
           int mid=(l+r)/2;
           if(v[i].first+2*d>=v[mid].first){
               end=mid;
               l=mid+1;
           } 
           else r=mid-1;
       } 
       ans+=x;
       update(1,0,n-1,i,end,-x);
    }
    cout<<ans<<'\n';
	        
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int64_t> A(N);
  bool check = false;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] == 0)
      check = true;
  }
  
  int64_t ans = 1;
  for(int i = 0; i < N; i++){
    int64_t ans2 = ans;
    ans *= A[i];
    if(ans > 1000000000000000000 || ans < ans2){
      ans = -1;
      break;
    }
  }
  
  if(check)
    cout << 0 << endl;
  else
    cout << ans << endl;
  
  return 0;
}

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

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

	long double ans = 1.0 * max(int64_t(0), n - k + 1) / n;

	for (int64_t x = 1; x < min(n + 1, k); x++)
	{

		int64_t a = 0;
		while ((1 << a) * x < k)
		{
			a++;
		}
		ans += pow(0.5, a) / n;
	}

	cout << fixed << setprecision(20) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.util.Arrays; 
import java.util.ArrayList; 
import java.util.Collections; 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) {
        try (PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            FastScanner in = new FastScanner(System.in);
            int n = in.nextInt();
            int a;
            int b;
            int c;
            int numberOfTuples = 0;

            for(int i = 1; i < n; i ++) {
                a = i;
                for(int j = 1; j < n; j++) {
                    b = j;
                    if(a*b < n) {
                        c = n - (a*b);
                        numberOfTuples++;
                    } else {
                        break;
                    }
                }
            }
            out.println(numberOfTuples);



        } finally {
            //out.close();
        }
        
           
    }
}


class FastScanner {
   private final BufferedReader br;
   private StringTokenizer st;
 
    FastScanner(InputStream InputStream) {
        br = new BufferedReader(new InputStreamReader(InputStream));
    }
    
    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }
    
    int nextInt() {
        return Integer.parseInt(next());
    }
    
    long nextLong() {
        return Long.parseLong(next());
    }
    
    double nextDouble() {
        return Double.parseDouble(next());
    }


    
    ArrayList<Integer> nextIntList(int count) {
        ArrayList<Integer> array = new ArrayList<>();
        for (int n = 0; n < count; n++) {
            int number = nextInt();
            array.add(number);
        }
        return array;
    }
    
    int[] nextIntArray(int count) {
        int[] array = new int[count];
        for (int n = 0; n < count; n++) {
            array[n] = nextInt();
        }
        return array;
    }
}

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

int main(){
		while(1){
		int x,y;
		cin >> x >> y ;
		if(x==0&&y==0)return 0;
		else if(x<y)cout << x << " " << y <<endl;
		else if(x>y)cout << y << " " << x <<endl;
		else cout << y << " " << x <<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from collections import Counter
N=int(input())
mod=10**9+7
factl=[1]
for i in range(1,N+1):
    factl.append(factl[-1]*i%mod)
invl=[pow(factl[-1],mod-2,mod)]
for i in range(N,0,-1):
    invl.append(invl[-1]*i%mod)
invl.reverse()
def Comb(a,b):
    return factl[a]*invl[a-b]*invl[b]

S=list(input())
RS=S[::-1]
L=[0]*2*N
r=0
for i in range(N):
    if r%2==0 and S[i]=='B':
        L[i]=1
        r+=1
    elif r%2==1 and S[i]=='W':
        L[i]=1
        r+=1
    else:
        r-=1
r=0
L=L[::-1]
S=S[::-1]
for i in range(N):
    if r%2==0 and S[i]=='B':
        r+=1
    elif r%2==1 and S[i]=='W':
        r+=1
    else:
        r-=1
        L[i]=1
L=L[::-1]
Cnt=Counter(L)
if Cnt[0]!=Cnt[1]:
    print(0)
    exit()
l=0
ans=1
for i in range(2*N):
    if L[i]==1:
        l+=1
    else:
        ans*=l
        ans%=mod
        l-=1
ans=ans*factl[N]%mod
print(ans)

Measured memory_bytes: 17660
n = int(raw_input())
a,b = map(int,raw_input().split())
arr = map(int, raw_input().split())
t1 = 0
t2 = 0
t3 = 0
for i in range(n):
    if arr[i] <= a:
        t1 += 1
    elif  a+1<=arr[i]<=b:
        t2 += 1
    else:
        t3 += 1
print min(t1, t2, t3)

Measured memory_bytes: 2568
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long int rui[400006];
long long int now;
long long int lis[400006][2];
int main(){
    int N,K;
    cin>>N>>K;
    for(int i=0;i<K;i++){
        cin>>lis[i][0]>>lis[i][1];
        rui[lis[i][0]+1]++;
        rui[lis[i][1]+2]--;
    }
    long long int now=0;
    for(int i=2;i<=N;i++){
/*
        for(int j=1;j<8;j++){
            printf("[%lld]",rui[j]);
        }
        puts("");
*/
        now+=rui[i];
        now+=998244353;
        now%=998244353;
        if(i==N)cout<<now<<endl;
        for(int j=0;j<K;j++){
            rui[lis[j][0]+i]+=now;
            rui[lis[j][0]+i]+=998244353;
            rui[lis[j][0]+i]%=998244353;
            rui[lis[j][1]+i+1]-=now;
            rui[lis[j][1]+i+1]+=998244353;
            rui[lis[j][1]+i+1]%=998244353;
        }
    }
    return 0;
}


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

#define ll long long 

int main() {
	ll n, m; 
	cin >> n >> m;
	ll a[m], sum = 0;
	for (int i = 0; i < m; i++){ 
		cin >> a[i];
		sum += a[i];
	}
	if(n >= sum) {
		cout << n - sum;
	}
	else {
		cout << "-1";
	}
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#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)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int m;
    cin >> m;
    ll ans = 0;
    ll sum = 0;
    rep(i, m) {
        int d; ll c;
        cin >> d >> c;
        sum += d * c;
        ans += c;
    }
    ans--;
    ans += (sum - 1) / 9;
    cout << ans << endl;
}


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

using ll = long long;

void solve(long long x){
    if(x == 0){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}

int main(){
    long long x;
    scanf("%lld",&x);
    solve(x);
    return 0;
}


Measured memory_bytes: 3680
N = int(input())
H = list(map(int, input().split()))
H += [float('inf')]

ans = 0
tmp_ans = 0
for i in range(N):
    if H[i] >= H[i + 1]:
        tmp_ans += 1
    else:
        ans = max(ans, tmp_ans)
        tmp_ans = 0
else:
    ans = max(ans, tmp_ans)

print(ans)


Measured memory_bytes: 14252
#include<stdio.h>
int main(void)
{
  int n, i=0;
  int a, b, ans, x;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d %d", &a, &b);
    x=b-a+1;
    ans+=x;
    x=0;
  }
  printf("%d", ans);
  return 0;
  }


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

int main() {
	
	int n; cin >> n;
	string ans = "Three";
	for (int i = 0; i < n; i++) {
		char s; cin >> s;
		if (s == 'Y') ans = "Four";
	}
	cout << ans << endl;
    return 0;
}

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

typedef long long LL;
typedef unsigned long long ULL;
const int MAXN=5005;
const int mod=998244353;
const LL INF=1e18+10;
const double EPS=1e-8;

LL n,m;
LL fra[MAXN],inv[MAXN];

LL power(LL a,LL b){
    LL c=1;
    while(b){
        if (b%2==1) c=c*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return c;
}

LL C(LL n,LL m){
    if (n<0 || m<0 || n<m) return 0;
    return (fra[n]*inv[m]%mod)*inv[n-m]%mod;
}

LL f(LL n,LL m){
    return C(n-1,m-1);
}

int main(){
    fra[0]=1; for(int i=1;i<=5000;i++) fra[i]=fra[i-1]*i%mod;
    inv[5000]=power(fra[5000],mod-2); for(int i=4999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
    scanf("%lld%lld",&m,&n);
    for(int t=2;t<=m*2;t++){
        int p=0;
        for(int i=1;i<=m && i<t && i*2<t;i++)
            if (t-i<=m) p++;
        LL ans=0;
        for(int i=0;i<=p;i++){
            if (t%2==1){
                int q=m-2*p;
                ans+=(C(p,i)*power(2,i)%mod)*f(n+q,q+i)%mod;
                if (ans>=mod) ans-=mod;        
            }
            else{
                int q=m-2*p-1;
                ans+=(C(p,i)*power(2,i)%mod)*(f(n+q,q+i)+f(n+q-1,q+i))%mod;
                if (ans>=mod) ans-=mod;
            }
        }        
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

#define MAX_N 100
#define MAX_A 2000
int MAP[MAX_N][MAX_N];

int MinimumSpanningTree(int n) {
	int i, j, k, sum, min, min_node;
	int color[n], colorflag[n];

	// 初期化
	sum = 0;
	k = 1;
	color[0] = 0;
	colorflag[0] = 1;
	for( i=1; i<n; i++) colorflag[i] = 0;

	while(1) {
		// ノードk個の最小全域木を求める
		min = MAX_A + 1;
		for( i=0; i<k; i++) {
			for( j=0; j<n; j++) {
				if(colorflag[j] == 1) continue;
				if(MAP[ color[i] ][j] < 0) continue;
				if(MAP[ color[i] ][j] < min) {
					min = MAP[ color[i] ][j];
					min_node = j;
				}
			}
		}
		
		// ノードk+1個の最小全域木の作成
		if(k < n) {
			color[k] = min_node;
			colorflag[min_node] = 1;
			sum += min;
		}
		else break;

		k++;
	}

	return sum;
}

int main(void) {
	int n, i, j;

	// input
	scanf("%d", &n);
	for( i=0; i<n; i++) {
		for( j=0; j<n; j++) {
			scanf("%d", &MAP[i][j]);
		}
	}

	// output	
	printf("%d\n", MinimumSpanningTree(n) );
	return 0;
}

Measured memory_bytes: 636
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RD-1;
	auto B = RD-1;
	auto d = B - A;

	writeln(d % 2 == 0 ? d/2 : min(A, N-B-1) + (d+1)/2);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)
using namespace std;
int main(){
    int N;
    long long ans = 0;
    cin >> N;
    int C[6]={};
    string dict = "MARCH";
    rep(i,N){
      string S;
      cin >> S;
      C[dict.find(S[0])+1]++;
    }
    REP(i,1,4){
      REP(j,i+1,5){
        REP(k,j+1,6){
          ans += (long long)C[i]*C[j]*C[k];
        }
      }
    }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn=4e5+5;
char a[maxn];
LL book[30];

int main()
{
    int i, j;
    while(~scanf("%s", a))
    {
        LL len=strlen(a);
        for(i=0; i<len; i++)
        {
            book[a[i]-'a']++;
        }
        LL ans=(len-1)*len/2+1;
        for(i=0; i<26; i++)
        {
            if(book[i]>1)
            ans-=book[i]*(book[i]-1LL)/2;
            book[i]=0;
        }
        printf("%lld\n", ans);
    }
    return 0;
}


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

#define rep(i,j) for(int (i) = 0;(i) < (j); ++(i))
vector<string> P;
int C,N;
bool same(int i,int j){
    return P[i][j] == P[i][N-1-j] && P[i][j] == P[N-1-i][j] && P[i][j] == P[N-1-i][N-1-j];
}

int main(){
    cin>>C>>N;
    P.resize(N);
    rep(i,N) cin>>P[i];

    int cnt = 0;
    rep(i,N/2){rep(j,N/2){if(same(i,j)) ++cnt;}}
    int ans = (cnt == N*N/4); 

    rep(i,C-1){
        int d; cin>>d;
        rep(j,d){
            int r,c;cin>>r>>c;--r;--c;
            if(same(r,c)) --cnt;
            P[r][c] = (P[r][c] == '1'?'0':'1');
            if(same(r,c)) ++cnt;
        } 
        ans += (cnt == N*N/4);
    }
    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;

#define FOR(a, b, i) for(int i=a; i<b; i++)
#define RFOR(a, b, i) for(int i=a; i>=b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1e9+7
#define newline cout<<"\n"


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

    int n; cin>>n;
    vector<vector<int> > v(n, vector<int> (3));

    FOR(0, n, i)
    {
        cin>>v[i][0];
        cin>>v[i][1];
        cin>>v[i][2];
    }

    vector<vector<ll> > dp(n, vector<ll> (3, 0));

    FOR(0, 3, i) dp[0][i] = v[0][i];

    FOR(1, n, i)
    {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + v[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + v[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + v[i][2];
    }

    ll ans = *max_element(dp[n-1].begin(), dp[n-1].end());

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 11264
package main

import (
	"bufio"
	"fmt"
	"os"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	input := bufio.NewReader(os.Stdin)

	var a, b, c int
	fmt.Fscanf(input, "%d %d %d\n", &a, &b, &c)
	fmt.Println(max(c-(a-b), 0))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll n,m,k,q[50][4],ch[10],ans;
void cal(){
	ll cnt=0;
	for(ll i=0;i<n;i++){
	//	cout << ch[i];
	}
	for(ll i=0;i<k;i++){
		ll now=ch[q[i][1]-1]-ch[q[i][0]-1];
		if(now==q[i][2]){
			cnt+=q[i][3];
		}
	}
	ans=max(ans,cnt);
	cout <<endl;
}
void dep(ll now,ll cnt){
	if(now==n){
		cal();
		return;
	}
	for(ll i=cnt;i<=m;i++){
		ch[now]=i;
		dep(now+1,i);
	}
}
int main() {
	cin>>n>>m>>k;
	for(ll i=0;i<k;i++){
		for(ll j=0;j<4;j++){
			cin>>q[i][j];
		}
	}
	dep(0,1);
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3644
import sys
import bisect

input = sys.stdin.readline


def main():
    A, B, Q = [int(x) for x in input().split()]
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    for _ in range(Q):
        x = int(input())
        si = bisect.bisect_left(S, x)
        ti = bisect.bisect_left(T, x)
        sl = -float("inf")
        if si != 0:
            sl = S[si - 1]
        sr = float("inf")
        if si != A:
            sr = S[si]
        tl = -float("inf")
        if ti != 0:
            tl = T[ti - 1]
        tr = float("inf")
        if ti != B:
            tr = T[ti]

        tmp1 = max(x - sl, x - tl)
        tmp2 = max(sr, tr) - x
        tmp3 = 2 * (x - sl) + tr - x
        tmp4 = 2 * (x - tl) + sr - x
        tmp5 = x - sl + 2 * (tr - x)
        tmp6 = x - tl + 2 * (sr - x)

        print(min(tmp1, tmp2, tmp3, tmp4, tmp5, tmp6))


if __name__ == '__main__':
    main()


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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
 
/*CODE START HERE*/
int main() {
  int w, a,b;
  cin >> w >> a >> b;
  int c =  abs(b-a) - w ;
  cout << ( c> 0 ? c : 0) << endl;
}


Measured memory_bytes: 3600
import java.util.Scanner;

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

      int min_m = 1000;
      int n = sc.nextInt();
      int x = sc.nextInt();

      int ans = n;

      for(int i = 0; i < n ; i++) {
        int tmp = sc.nextInt();

        x -= tmp;

        min_m = Math.min(tmp,min_m);
      }

      //System.out.println(min_m);

      for(; x - min_m >= 0;) {
        ans++;
        x -= min_m;
        //System.out.println(x);
      }

      System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stack>


int main(void){
  char c;
  bool ok;

  while(1){
    char s[101] = {0};
    ok = true;
    std::stack<char> st;
    for(int i=0; i<101; i++){
      scanf("%c", &c);
      if(c == '\n'){
	s[i] = '\0';
	break;
      }else{
	s[i] = c;
      }
    }
    
    if(s[0] == '.'){
      break;
    }
    
    for(int i=0; i<101; i++){
      if(s[i] == '.'){
	break;
      }
      if(s[i] == '(' || s[i] == '['){
	st.push(s[i]);
      }else if(s[i] == ')'){
	if(st.empty() || st.top()!='('){
	  ok = false;
	  break;
	}else{
	  st.pop();
	}
      }else if(s[i] == ']'){
	if(st.empty() || st.top() != '['){
	  ok = false;
	  break;
	}else{
	  st.pop();
	}
      }
    }
    
    if(!st.empty()){
      ok = false;
    }
    
    if(ok){
      printf("yes\n");
    }else{
      printf("no\n");
    }
    
  }
  return 0;
}

Measured memory_bytes: 992
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	if (n < 1000) {
		cout << "ABC";
		return 0;
	}
	else {
		cout << "ABD";
		return 0;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,a[101],i,w,x,v[101],j;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++){
		v[i]=0;
	}	
	for(i=1;i<=m;i++){
		scanf("%d",&a[i]);
	}	
	for(i=1;i<=m;i++){
	x=0;
		for(j=1;j<=n;j++){
			scanf("%d",&w);
			if(a[i]==w){
				v[j]++;
			}
			else{
				x++;
			}	
		}
		v[a[i]]+=x;		
	}
	for(i=1;i<=n;i++){
		printf("%d\n",v[i]);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
/*
 * 自明
 */

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}



int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll n,m;
	string s,t,s2="",t2="";
	cin>>n>>m>>s>>t;
    ll l=lcm(n,m);
    ll d=l/n*l/m;
    rep(i,s.size()){
        if(i%(d/(l/n))==0) s2+=s[i];
    }
    rep(i,t.size()){
        if(i%(d/(l/m))==0) t2+=t[i];
    }
    if(s2==t2){
        cout<<l<<endl;
    }else cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int m, d; cin >> m >> d;
	int cnt = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= d; j++) {
			if (j % 10 < 2) continue;
			if (j / 10 < 2) continue;
			cnt += i == ((j % 10)*(j / 10));
		}
	}
	cout << cnt << endl;
	return 0;
}



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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int&v : a) cin >> v;
  sort(a.begin(), a.end());
  int ok = a.back() == 0;
  if (n%3 == 0) {
    ok = (a[0]^a[n/3]^a[n*2/3])==0;
    for (int i = 0; i < n; i++)
      if (a[i] != a[i-i%(n/3)]) ok = 0;
  }
  cout << (ok ? "Yes" : "No") << endl;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,y; cin>>n>>y;
	for (int i=0; 10000*i<=y; i++) {
		for (int j=0; 10000*i+5000*j<=y; j++) {
			int k=(y-10000*i-5000*j)/1000;
			if(i+j+k==n) {
				cout<<i<<" "<<j<<" "<<k<<"\n";
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
void solve(int a, int b, int c) {
    bool f = false;
    int max_num = max(a, max(b, c));
    int sub1, sub2;
    if (max_num != a) {
        sub1 = a;
        if (max_num != b) sub2 = b;
        else sub2 = c;
    } else if (max_num != b) {
        sub1 = b;
        sub2 = c;
    }         
    if (pow(max_num, 2) == pow(sub1, 2) + pow(sub2, 2)) f = true;
    if (f) cout << "YES" << endl;
    else cout << "NO" << endl;
}
int main() {
    int num, a, b, c;
    cin >> num;
    for (int i=0; i<num; i++) {
        cin >> a >> b >> c;
        solve(a,b,c);
    }
    return 0;
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(n)      (n).begin(), (n).end()
#define ll long long
#define ull unsigned long long int
void solve() {
    int n; cin >> n;
    vector<ll> a(n,0);
    for(int i = 0; i < n; i++)cin >> a[i];
    ll mx = a[0],ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] <= mx){
            ans += (mx-a[i]);
        }else{
            mx = max(mx,a[i]);
        }
    }
    cout << ans << endl;
    
}
int main(){
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    //Starts here , 
                
    // int T; cin >> T;
    // while(T--){
        solve();
    // }
    return 0;
            
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

string S;
string dp[55][55];

bool f(int i,char c){
    return S[i]==c||S[i]=='?';
}

bool update(string &s,string t){
    if(s.size()<t.size()||(s.size()==t.size()&&s<t))s=t;
}

signed main(){
    cin>>S;
    for(int len=1;len<=S.size();len++){
        for(int i=0;i+len<=S.size();i++){
            int j=i+len;
            string s=S.substr(i,len);
            bool flag=true;
            rep(k,s.size()){
                if(isdigit(s[k]))continue;
                if(s[k]=='?'){
                    s[k]='9';
                    continue;
                }
                flag=false;
            }
            if(flag&&(s[0]!='0'||len==1))dp[i][j]=s;

            if(len<6)continue;
            if(!f(i+1,'(')||!f(j-1,')'))continue;
            if(f(i,'L')||f(i,'R')){
                for(int k=i+3;k+2<j;k++){
                    if(!f(k,','))continue;
                    if(dp[i+2][k]=="")continue;
                    if(dp[k+1][j-1]=="")continue;
                    if(f(i,'L'))update(dp[i][j],dp[i+2][k]);
                    if(f(i,'R'))update(dp[i][j],dp[k+1][j-1]);
                }
            }
        }
    }

    /*
    for(int i=0;i<S.size();i++){
        for(int j=i+1;j<=S.size();j++){
            cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        }
    }*/

    if(dp[0][S.size()]=="")cout<<"invalid"<<endl;
    else cout<<dp[0][S.size()]<<endl;

    return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long A, long long B, long long H, long long M){
  H%=12;
  long double thetaA=2*M_PIf64x*(long double)(H*60+M)/720.0L,
    thetaB=2*M_PIf64x*(long double)(M)/60.0L;
  dump(thetaA);dump(thetaB);
  long double theta=abs(thetaA-thetaB);
  dump(theta);
  cout<<sqrtl(A*A+B*B-2*A*B*cos(theta));
}

int main(){
  cout<<setprecision(1000);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long H;
    scanf("%lld",&H);
    long long M;
    scanf("%lld",&M);
    solve(A, B, H, M);
    return 0;
}


Measured memory_bytes: 4228
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int modpow(ll a, ll n, ll p){
	if(n==0) return 1;
	if(n%2) return (a*modpow(a, n-1, p))%p;
	if(!(n%2)){
		ll t=modpow(a, n/2, p);
		return (t*t)%p;
	}
}


const int MAX = 1000000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int S; cin >> S; ll ans = 0; int cnt = 0;
  COMinit();
  rep(i, S/3){
    ans+=COM(S-3*(cnt+1)+cnt, cnt); cnt++; ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 27072
#include<cstdio>
using namespace std;

int main(){
  long long int n,a,x[50],dp[51][51][2600]={},ans=0;
  dp[0][0][0]=1;
  scanf("%lld %lld",&n,&a);
  for(int i=0;i<n;i++)
    scanf("%lld",&x[i]);
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<=2500;k++)
        if(dp[i][j][k]){
          dp[i+1][j][k]+=dp[i][j][k];
          dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
        }
  for(int i=1;i<=n;i++)
    if(dp[n][i][a*i]){
      ans+=dp[n][i][a*i];
    }
  printf("%lld\n",ans);
}

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

int a[15];

int main()
{
	int k,v,n;
	cin>>n>>k;
	while(k--)
	{
		cin>>v;
		a[v]=1;
	}
	while(1)
	{
		int fl=0;
		int m=n;
		while(m>0)
		{
			if(a[m%10]==1)
			{
				fl=1;
				n=n+1;
				break;
			}
			m=m/10;
		}
		if(fl==0)
			break;
	}
	cout<<n<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = sc.nextInt();
		int Y = sc.nextInt();
		int yen10000 = -1;
		int yen5000 = -1;
		int yen1000 = -1;

		for(int x = 0; x <= N; x++) {
			for(int y = 0; y <= N; y++) {
				int z = N - x - y;
				if (z >= 0) {
					int total = 10000*x + 5000*y + 1000*z;
					if(total == Y) {
						yen10000 = x;
						yen5000 = y;
						yen1000 = z;
					}
				}

			}
		}

		System.out.print(yen10000 + " ");
		System.out.print(yen5000 + " ");
		System.out.print(yen1000);
	}
}


Measured memory_bytes: 21972
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;

int main() {
    string S;
    cin >> S;
    vector<int> v(26, 0);
    for (int i = 0; i < S.size(); i++) {
        v[S[i]-'A']++;
    }

    int flg = -1;
    for (int i = 0; i < 26; i++) {
        if (v[i] == 2 && flg == 0) {
            cout << "Yes" << endl;
            flg = 1;
            break;
        } else if (v[i] == 2) flg = 0;
    }

    if (flg == -1 || flg == 0) cout << "No" << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll X;
    cin >> X;
    ll s = 100;
    ll ans = 1;
    while (true) {
        s = s + s / 100;
        if (s >= X) {
            cout << ans << '\n';
            return;
        }
        ans ++;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N,M;cin>>N>>M;
    vec S1;
    set<int> SN;
    int a,b;
    for(int i=0;i<M;i++){
        cin>>a>>b;
        if(a==1)S1.push_back(b);
        if(b==1)S1.push_back(a);
        if(a==N)SN.insert(b);
        if(b==N)SN.insert(a);
    }
    bool ans=false;
    for(int i=0;i<S1.size();i++){
        if(SN.find(S1[i])!=SN.end())ans=true;
    }
    if(ans)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

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

int main()
{
    long long int a, b, c, k, ans = 0;
    cin>>a>>b>>c>>k;
    if(a >= k) cout<<k<<endl;
    else{
        ans += a;
        k -= a;
        if(b >= k) cout<<ans<<endl;
        else{
            k -= b;
            ans -= k;
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
vector<long long> p(90009),q(90009),z(90009),s(90009);
long long A[310][310];

int main() {  
  long long H,W,D,Q;
  cin >> H >> W >> D;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){cin >> A[i][j];}
  }
  cin >> Q;
  vector<long long> L(Q),R(Q);
  for(int i=0;i<Q;i++)cin >> L[i] >> R[i];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){p[A[i][j]]=i; q[A[i][j]]=j;}
  }
  for(int i=D+1;i<=H*W;i++){
    z[i]=abs(p[i]-p[i-D])+abs(q[i]-q[i-D]);
  }
  for(int i=D+1;i<=H*W;i++){
    s[i]=s[i-D]+z[i];
  }
  for(int i=0;i<Q;i++){
    cout << s[R[i]]-s[L[i]] << endl;
  }
}

Measured memory_bytes: 6272
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }


ll sti(string s) {
	ll len = s.length();
	if (len < 1) return 0;
	return (s[len - 1] - '0') + 10 * (sti(s.substr(0, len - 1)));
}


bool isNum(char c) {
	int t = c - '0';
	if (t<0 || t>=10) return false;
	return true;
}

int main() {
	string s;
	int ans = 0;
	
	while (cin>>s) {
		vcs sub(100, "");
		
		int i = 0;
		for_(j, 0, (int)s.sz) {
			if (isNum(s[j])) {
				sub[i] += s[j];
			} else {
				i++;
			}
		}
		
		for_(j, 0, 100) {
			if (sub[j]!="") ans += sti(sub[j]);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1196
a, b, c = (int(x) for x in input().split())
list = [a, b, c]
MAX = list[0]
if MAX < list[1]:
    MAX = list[1]
if MAX < list[2]:
    MAX = list[2]
list.remove(MAX)
MID = list[0]
MIN = list[1]
if MID < MIN:
    MID = list[1]
    MIN = list[0]
print(MIN, MID, MAX)



Measured memory_bytes: 5604
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;

int main(){
    int N;
    cin >> N;

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

    for (int j=0; j<N; j++){
        for (int i=0; i<N-1-j; i++){
            int b = a[i];
            if (a[i] < a[i+1]){
                a[i]=a[i+1];
                a[i+1]=b;
            }
        }   
    }


    int ans = 0;
    for (int i=0; i<N; i++){
        if (i%2 == 0){
            ans += a[i];
        }else{
            ans -= a[i];
        }
    }
    cout << ans << endl;

    return 0;
    
}

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

string s, t;
int m, n, pre[2000200], match[2000200], f[2000200];

void calcPre()
{
  int i = 0, j = -1;
  pre[0] = -1;
  while (i < n)
  {
    while (j >= 0 && t[i] != t[j])
      j = pre[j];
    pre[++i] = ++j;
  }
}

void findMatch()
{
  int i = 0, j = 0;
  while (i < s.size())
  {
    while (j >= 0 && s[i] != t[j])
      j = pre[j];
    i++;
    j++;
    if (j == n)
    {
      j = pre[j];
      match[(i - n) % m] = 1;
    }
  }
}

int go(int x)
{
  if (f[x] >= 0)
    return f[x];
  if (!match[x])
    return 0;
  return f[x] = go((x + n) % m) + 1;
}

int main()
{
  cin >> s >> t;
  m = s.size();
  n = t.size();
  while (s.size() < m + n)
    s += s.substr(0, m);

  calcPre();
  findMatch();

  int ans = 0, found = 0, hasMatch = 0;
  memset(f, -1, sizeof f);
  for (int i = 0; i < m; i++)
  {
    hasMatch |= match[i];
    if (match[i] && !match[(i - n + m) % m])
    {
      found = 1;
      ans = max(ans, go(i));
    }
  }

  cout << (!found && hasMatch ? -1 : ans) << endl;
}


Measured memory_bytes: 21420