akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, double> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	int n;
	cin >> n;
	int k;
	cin >> k;
	vector<int> d(k);
	rep(i, k) cin >> d.at(i);
	
	
	while (1) {
		int num = n;
		int cnt = 0;
		while (num != 0) {
			num = num / 10;
			cnt++;
		}
		int value = 0;
		bool cheak = true;
		int num2 = n;
		rep(i, cnt) {
			num2 = num2 - value * pow(10, cnt - i);
			value = num2 / pow(10, cnt - (i + 1));
			rep(j, k) {
				if (value == d.at(j)) {
					cheak = false;
					break;
				}
			}
			if (cheak == false) break;
		}
		if (cheak == true) {
			cout << n << endl;
			break;
		}
		n++;
	}
	
	return 0;
}

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

int count(int sy, int ey, int W, vector< string >& f, char c) {
	int ret = 0;
	for (int y=sy; y<ey; ++y) for (int x=0; x<W; ++x) if (f[y][x] != c) ++ret;
	return ret;
}

int main() {
	int N, M;
	cin >> N >> M;
	
	vector< string > f(N);
	for (int i=0; i<N; ++i) cin >> f[i];
	
	int ans = N * M;
	for (int s=1; s<N-1; ++s) for (int t=s+1; t<N; ++t) {
		int w = count(0, s, M, f, 'W');
		int b = count(s, t, M, f, 'B');
		int r = count(t, N, M, f, 'R');
		ans = min(ans, w + b + r);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;

    int res;
    rep(i, n, 1000){
        int x = i;
        int pre = -1;
        bool ok = true;

        while(x > 0){
            int cur = x % 10;
            if(pre != -1 and pre != cur){
                ok = false;
                break;
            }
            pre = cur;
            x /= 10;
        }

        if(ok){
            res = i;
            break;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll N=1e6+7;
const ll mod=1e9+7;
ll maxn,minn;
ll T,n,m,q;
ll a,b,c,d;
ll arr[10];

int main(){
	cin >> arr[1] >> arr[2] >> arr[3] >> arr[4];
	ll ans = -INF;
	for(ll i = 1; i <= 2; i ++ ){
		for(ll j = 3; j <= 4; j++ ){
			ans = max(ans,arr[i] * arr[j]);
		}
	}
	cout << ans << endl;
	
	
	return 0;
}



Measured memory_bytes: 3544
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  a = readInts()[0]
  b = readInts()[0]
  c = readInts()[0]
  d = readInts()[0]
  e = readInts()[0]
  k = readInts()[0]

  if e - a <= k:
    print("Yay!")
  else:
    print(":(")

if __name__ == "__main__":
  main()


Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))
c = a.count(0)
    
odd_count = len(list(filter(lambda x: (x%2 != 0) , a)))

if(n%2 == 1):
    if(c != 1 or odd_count !=0):
        print(0)
        exit()
else:
    if(c != 0 or odd_count !=n):
        print(0)
        exit()
        
m = 1000000007
p = n//2
ans = 1
for _ in range(0,p):
    ans = 2*ans % m
print(ans)

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

int main()
{
	string S;
	cin >> S;

	int ans = 0;
	for( int i = 0; i < S.size(); i++ ) {
		if( S[i] == '0' ) continue;
		ans++;
	}

	cout << ans << endl;
}


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

int main()
{
    int n,a[9],k,i;
    while(scanf("%d",&n)!=EOF)
    {
        for (i=0;i<9;i++) a[i]=0;
        for (i=0;i<n;i++)
        {
            scanf("%d",&k);
            if (k<400) a[0]++;
            else if (k<800) a[1]++;
            else if (k<1200) a[2]++;
            else if (k<1600) a[3]++;
            else if (k<2000) a[4]++;
            else if (k<2400) a[5]++;
            else if (k<2800) a[6]++;
            else if (k<3200) a[7]++;
            else a[8]++;
        }
        int mi=0,ma=0;
        for (i=0;i<8;i++) if (a[i]) mi++;
        ma=mi+a[8];
        if (mi==0&&a[8]) mi=1;
        printf("%d %d\n",mi,ma);
    }
    return 0;
}


Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))

count=0
for i in range(N):
    A=list(map(int,input().split()))
    total=0
    for j in range(M):
        a=A[j]*B[j]
        total +=a
    ans=total+C
    if ans > 0:
        count +=1

print(count)

Measured memory_bytes: 3060
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[2];
int main(){
	scanf("%s",in);
	in[0]++;
	printf("%s\n",in);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
#define MK make_pair
#define PB push_back
using namespace std;

typedef long long LL;
typedef pair<int ,int> PII;
const int N=1e6+10;
const LL MOD = 998244353;
LL fac[N], inv[N], ifac[N], pwm[N], pwn[N];
int n, m;
LL C(int n, int m){return fac[n]*ifac[m]%MOD*ifac[n-m]%MOD;}
LL P(int n, int m){return fac[n]*ifac[n-m]%MOD;}
void upsum(LL &a, LL b){a=(a+b)%MOD;}
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	for (int i=0; i<2; ++i)fac[i] = ifac[i] = inv[i]=1;
	for (int i=2; i<=1000000; ++i){
		inv[i] = (MOD-inv[MOD%i])*(MOD/i)%MOD;
		fac[i] = fac[i-1]*i%MOD;
		ifac[i] = ifac[i-1]*inv[i]%MOD;
	}
	scanf("%d%d", &n, &m);
	if (n>m)swap(n,m);
	pwn[0]=pwm[0]=1;
	for (int i=1; i<=m; ++i) pwn[i]=pwn[i-1]*(n+1)%MOD, pwm[i]= pwm[i-1]*(m+1)%MOD;
	LL ans=0;
	for (int k=0,sgn=1; k<=n; ++k,sgn=MOD-sgn){
		upsum(ans, C(n,k)*P(m,k)%MOD*pwm[n-k]%MOD*pwn[m-k]%MOD*sgn%MOD);
		#ifdef che
		debug("k=%d, ans=%lld\n", k, ans);
		#endif
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 35200
#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    
    int answer = 0;
    
    if (s.substr(0, 1) == "+") {
        answer ++;
    } else {
        answer --;
    }
    
    if (s.substr(1, 1) == "+") {
        answer ++;
    } else {
        answer --;
    }
    
    if (s.substr(2, 1) == "+") {
        answer ++;
    } else {
        answer --;
    }
    
    if (s.substr(3, 1) == "+") {
        answer ++;
    } else {
        answer --;
    }
    
    cout << answer;
    
    return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

vector<ll> sieve_of_eratosthenes(int upper) {
    vector<char> is_prime(upper, true);
    is_prime[0] = is_prime[1] = 0;
    vector<ll> res;
    for(int i = 2; i < upper; i++) {
        if(not is_prime[i]) continue;
        for(int j = i * 2; j < upper; j += i) is_prime[j] = false;
        res.push_back(i);
    }
    return res;
}

vector<ll> factors(ll x) {
    auto primes = sieve_of_eratosthenes(sqrt(x) + 1);
    vector<ll> res;
    for(ll p : primes) while(x % p == 0) {
            x /= p;
            res.push_back(p);
        }
    if(x > 1) res.push_back(x);
    return res;
}

double heron(double x1, double y1, double x2, double y2, double x3, double y3) {
    double a = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
    double b = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
    double c = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
    double s = (a + b + c) / 2.0;
    //cerr << a << " " << b << " " << c << " " << s << endl;
    return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main() {
    ll S; cin >> S;
    ll s;
    {
        ll l = 0, r = 1e9+1;
        while(l + 1 < r) {
            ll m = (l + r) / 2;
            (m * m < S ? l : r) = m;
        }
        s = r;
    }
    ll diff = s * s - S;
    ll a = 0, b = 0;
    if(diff > 0) {
        auto fac = factors(diff);
        if(diff == 1) {
            a = 1;
            b = 1;
        } else if(fac.size() > 1) {
            a = 1;
            b = 1;
            for(int i = 0; i < fac.size(); i += 2) {
                a *= fac[i];
                if(i + 1 < fac.size()) b *= fac[i + 1];
            }
        } else {
            assert(fac.size() == 1);
            a = 1;
            b = fac[0];
        }
    }

    cout << 0 << " " << 0 << " ";
    cout << s << " " << a << " ";
    cout << b << " " << s << endl;

    // debug(heron(0, 0, s, a, b, s)*2);

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<string> vec(n);
	rep(i,n) cin >> vec[i];
	map<string,int> m;
	string k = "";
	rep(i,n){
		m[vec[i]]++;
	}
	cout << m["E869120"] << endl;
	return 0;
}


Measured memory_bytes: 3360
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


template <typename T>
T gcd(T a, T b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b){
    return a / gcd(a, b) * b;
}

int main(){
    int n;
    ll com_mul = 1;
    cin >> n;
    REP(i, n){
        ll t;
        cin >> t;
        com_mul = lcm(com_mul, t);
    }
    cout << com_mul << endl;
    return 0;
}



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

int main() {
	vector<int> v(5);
	for (int i = 0; i < 5; i++) {
		cin >> v.at(i);
	}

	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	for (int i = 0; i < 5; i++) {
		cout << v.at(i);
		if (i == 4) {
			cout << endl;
		}
		else {
			cout << ' ';
		}
	}
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
int main(void) {
    int n; cin >> n;
    vector<int> a(n+1);
    rep(i ,n) cin >> a[i+1];
    vector<bool> flag(n+1,false);
    int ans = 0;
    for(int i=n; i>0; i--) {
        int cnt = 0;
        for(int j=i*2; j<=n; j+=i) {
            if(flag[j]) cnt++;
        }
        if((cnt+a[i])%2 == 1) flag[i] = true, ans++;
    }
    cout << ans << endl;
    rep(i, n) {
        if(flag[i+1])  {
            cout << i+1 << endl;
        }
    }
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  int N;
  int cnt=0;
  set<int> S;
  cin>>N;
  FOR(i,0,N){
    int A;
    cin>>A;
    if(A>=3200){
      cnt++;
      continue;
    }
    int B=A/400;
    S.insert(B);
  }
  if(S.size()){
    cout<<S.size()<<" "<<S.size()+cnt<<endl;
  }else{
    cout<<"1"<<" "<<cnt<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;


int main(void){
  for(int i=1;i<=5;i++){
    int x;
    cin >> x;
    if(x == 0){
      cout << i << endl;
    }
  }
}


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

#include <bits/stdc++.h>
using namespace std;

struct edge { int to, cost; };
typedef pair<int, int> P; // firstは最短距離、secondは頂点の番号

const int VV = 222222;
const int INF = 1e8;
int V, M;
vector<edge> G[VV];
int d[VV];

void dijkstra(int s) {
   // 最短距離firstが小さい順に取り出せるようにする
   priority_queue<P, vector<P>, greater<P>> que;
   fill(d, d + V, INF); // 距離全てをINFで初期化
   d[s] = 0; // スタート地点を0で初期化
   que.push(P(0, s)); // キューに初期位置のコスト、初期位置をpush

   while (que.size()) {
      P p = que.top(); que.pop(); // p: 今の{最短距離、頂点番号}
      int v = p.second; // 今の頂点番号
      if (d[v] < p.first) continue; // 今見ている頂点の歴代最小距離 < 今見ている頂点の最短距離
      for (int i = 0; i < G[v].size(); i++) { // 今の頂点に隣接する頂点を調べる
         edge e = G[v][i];
         if (d[e.to] > d[v] + e.cost) { // 遷移先の頂点の歴代最小距離 > 今の距離 + 遷移コスト
            d[e.to] = d[v] + e.cost; // 歴代最小距離の更新
            que.push(P(d[e.to], e.to)); // 更新した遷移先の頂点をキューに突っ込む
         }
      }
   }
}

int main() {
   cin >> V >> M;
   for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      G[a].push_back({b, 1});
      G[b].push_back({a, 1});
   }

   dijkstra(0);

   if (d[V-1] == 2) {
      puts("POSSIBLE");
   } else {
      puts("IMPOSSIBLE");
   }

   return 0;
}


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

int main() {
  int r;
  cin >> r;
  cout << 3 * pow(r, 2) << endl;
  return 0;
}


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

Measured memory_bytes: 1716
#include <iostream>

std::string solve(const std::string a, const std::string b) {
    std::string res = "EQUAL";
    if (a.size() < b.size()) {
        res = "LESS";
    } else if (a.size() > b.size()) {
        res = "GREATER";
    } else {
        for (int i=0; i<a.size(); ++i) {
            if (a[i] < b[i]) {
                res = "LESS";
                break;
            } else if (a[i] > b[i]) {
                res = "GREATER";
                break;
            }
        }
    }
    return res;
}

int main() {
    std::string a, b, res;
    std::cin >> a >> b;
    std::cout << solve(a, b) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int x,n,num,vis[105];
int main(){
	x=read(),n=read();
	for(int i=1;i<=n;i++) num=read(),vis[num]=1;
	for(int i=0;;i++){
		if(!vis[x-i]){
			printf("%d\n",x-i);
			return 0;
		}
		if(!vis[x+i]){
			printf("%d\n",x+i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>
static int n,k,x,y;
int max(int a,int b){return a>=b?a:b;}
int min(int a,int b){return a<=b?a:b;}
int main(void){
    scanf("%d%d%d%d",&n,&k,&x,&y);
    printf("%d\n",x*min(k,n)+y*max(0,n-k));
    return 0;}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> p_x1(N), p_x2(N), p_y1(N), p_y2(N);
	vector<int> X, Y;
	for (int i = 0; i < N; i++) {
		cin >> p_x1[i] >> p_y1[i] >> p_x2[i] >> p_y2[i];
		X.push_back(p_x1[i]); X.push_back(p_x2[i]);
		Y.push_back(p_y1[i]); Y.push_back(p_y2[i]);
	}
	sort(X.begin(), X.end()); sort(Y.begin(), Y.end());
	X.erase(unique(X.begin(), X.end()), X.end());
	Y.erase(unique(Y.begin(), Y.end()), Y.end());
	vector< vector<int> > matrix1(Y.size()),matrix2(Y.size());
	for (int i = 0; i < N; i++) {
		p_x1[i] = lower_bound(X.begin(), X.end(), p_x1[i]) - X.begin();
		p_y1[i] = lower_bound(Y.begin(), Y.end(), p_y1[i]) - Y.begin();
		p_x2[i] = lower_bound(X.begin(), X.end(), p_x2[i]) - X.begin();
		p_y2[i] = lower_bound(Y.begin(), Y.end(), p_y2[i]) - Y.begin();

		matrix1[p_y1[i]].push_back(i); matrix2[p_y2[i]].push_back(i);
	}
	vector<int> flag(X.size() - 1,0);
	long long ans = 0;
	for (int i = 0; i < Y.size();i++) {
		if (i != 0) {
			long long sum = 0;
			for (int j = 0; j < X.size() - 1;j++) {
				if (flag[j]) { sum += X[j + 1] - X[j]; }
			}
			ans += sum *(Y[i] - Y[i - 1]);
		}
		for (int m : matrix1[i]) {
			for (int j = p_x1[m]; j < p_x2[m]; j++) flag[j]++;
		}
		for (int m : matrix2[i]) {
			for (int j = p_x1[m]; j < p_x2[m]; j++) flag[j]--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3396
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
typedef long long ll;
using namespace std;

int main() {
    int n;cin>>n;
    if(n%2==0)cout<<(n-1)/2<<endl;
    else cout<<n/2<<endl;
}

Measured memory_bytes: 256
h, w, m = map(int, input().split())

target_pos = set()
target_n_row = [0] * h
target_n_col = [0] * w
for i in range(m):
    y, x = map(lambda x: int(x) - 1, input().split())
    target_n_row[y] += 1
    target_n_col[x] += 1
    target_pos.add((y, x))

sorted_row = [(a, i) for i, a in enumerate(target_n_row)]
sorted_row.sort(reverse=True)
sorted_col = [(a, i) for i, a in enumerate(target_n_col)]
sorted_col.sort(reverse=True)

max_r = sorted_row[0][0]
max_c = sorted_col[0][0]

i = 0
max_val = max_r + max_c - 1
while i < h and sorted_row[i][0] == max_r:
    j = 0
    while j < w and sorted_col[j][0] == max_c:
        if not (sorted_row[i][1], sorted_col[j][1]) in target_pos:
            max_val = sorted_row[i][0] + sorted_col[j][0]
            break
        j += 1
    i += 1
print(max_val)


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

	Scanner sc = new Scanner(System.in);
	public boolean pln(long val){
		System.out.print('?');
		System.out.print(' ');
		System.out.println(val);
		return get();
	}
	
	public boolean get(){
		return sc.next().equals("Y");
	}
	
	public void solve(){
		long num = 1000000000;
		
		
		if(pln(num)){
			long num2 = 9;
			num = 1;
			while(true){
				if(pln(num2)){
					break;
				}
				num *= 10;
				num2 = (num2 * 10) + 9;
			}
			System.out.println("! " + num);
		}else{
			int digit = 9;
			while(digit > 1){
				num /= 10;
				if(pln(num)){
					break;
				}
				digit--;
			}
			
			long ans = 0;
			for(int i = 0; i < digit - 1; i++){
				if(pln(ans * 10 + 5)){
					if(pln(ans * 10 + 7)){
						if(pln(ans * 10 + 8)){
							if(pln(ans * 10 + 9)){
								ans = ans * 10 + 9;
							}else{
								ans = ans * 10 + 8;
							}
						}else{
							ans = ans * 10 + 7;
						}
					}else{
						if(pln(ans * 10 + 6)){
							ans = ans * 10 + 6;
						}else{
							ans = ans * 10 + 5;
						}
					}
				}else{
					if(pln(ans * 10 + 3)){
						if(pln(ans * 10 + 4)){
							ans = ans * 10 + 4;
						}else{
							ans = ans * 10 + 3;
						}
					}else{
						if(pln(ans * 10 + 2)){
							ans = ans * 10 + 2;
						}else{
							if(pln(ans * 10 + 1)){
								ans = ans * 10 + 1;
							}else{
								ans = ans * 10 + 0;
							}
						}
					}
				}
			}
			
			if(!pln(ans * 100 + 40)){
				if(!pln(ans * 100 + 60)){
					if(!pln(ans * 100 + 70)){
						if(!pln(ans * 100 + 80)){
							ans = ans * 10 + 9;
						}else{
							ans = ans * 10 + 8;
						}
					}else{
						ans = ans * 10 + 7;
					}
				}else{
					if(!pln(ans * 100 + 50)){
						ans = ans * 10 + 6;
					}else{
						ans = ans * 10 + 5;
					}
				}
			}else{
				if(!pln(ans * 100 + 20)){
					if(!pln(ans * 100 + 30)){
						ans = ans * 10 + 4;
					}else{
						ans = ans * 10 + 3;
					}
				}else{
					if(!pln(ans * 100 + 10)){
						ans = ans * 10 + 2;
					}else{
						if(!pln(ans * 100)){
							ans = ans * 10 + 1;
						}else{
							ans = ans * 10 + 0;
						}
					}
				}
			}
			System.out.println("! " + ans);
		}
		
	}
	
	public static void main(String[] args){
		new Main().solve();
	}
}

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

int main()
{
	int i;
	double a, b;
	vector< vector<double> > Time(7, vector<double>(2));
	Time[0][0] = 35.50; Time[0][1] = 71.00;
	Time[1][0] = 37.50; Time[1][1] = 77.00;
	Time[2][0] = 40.00; Time[2][1] = 83.00;
	Time[3][0] = 43.00; Time[3][1] = 89.00;
	Time[4][0] = 50.00; Time[4][1] = 105.00;
	Time[5][0] = 55.00; Time[5][1] = 116.00;
	Time[6][0] = 70.00; Time[6][1] = 148.00;
	vector<string> Class(8);
	Class[0] = "AAA";
	Class[1] = "AA";
	Class[2] = "A";
	Class[3] = "B";
	Class[4] = "C";
	Class[5] = "D";
	Class[6] = "E";
	Class[7] = "NA";
	while (cin>>a>>b) {
		for (i = 0; i < 7; i++)
			if (a<Time[i][0] && b<Time[i][1]) break;
		cout<<Class[i]<<endl;
	}
	return 0;
}

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

const int N = 1E5 + 10;
const int P = 10 + 5;

int n, m, q;
vector<int> G[N];
pair<int, int> f[N][P];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int u, d, c;
    scanf("%d%d%d", &u, &d, &c);
    f[u][d] = make_pair(c, 1 + i);
  }
  for (int i = 10; i >= 1; i--) {
    for (int j = 1; j <= n; j++) {
      if (f[j][i].first == 0) continue;
      for(int k = 0; k < (int)G[j].size(); k++) {
        int u = G[j][k];
        if(f[u][i - 1].second < f[j][i].second) {
          f[u][i - 1] = f[j][i];
        }
      }
      if(f[j][i - 1].second < f[j][i].second) {
        f[j][i - 1] = f[j][i];
      }
    }
  }
  for(int i = 1; i <= n; i++) {
    printf("%d\n", f[i][0].first);
  }
  return 0;
}


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

signed main() {
	ll n, d;
	cin >> n >>d;
	vector<vector<ll>> x(n, vector<ll>(d));
	rep(i, n){
		rep(j, d){
			cin >> x.at(i).at(j);
		}
	}
	ll ans = 0;
	for(ll i = 0; i < n; i++){
		for(ll j = i + 1; j < n; j++){
			ll kazu = 0;
			for(ll k = 0; k < d; k++){
				ll siki = abs(x[i][k] - x[j][k]);
				kazu += siki * siki;
			}
			bool tadashi = false;
			for(ll k = 0; k <= kazu; k++){
				if(k * k == kazu) tadashi = true;
			}
		if(tadashi) ans++;
		}
	}
	cout << ans << endl;
}


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

int main() {
    int n;
    int a;
    cin >> n;
    cin >> a;
    while (n >= 500){
        n = n - 500;
    }
    if (n <= a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

string s;

int main() {
	cin >> s;
int	n = s.size();
	ll k;
	cin >> k;
	for (int i = 0; i < (int)s.size(); ++i) {
		if (i == n - 1) {
			s[i] = (s[i] - 'a' + k) % 26 + 'a';
		}
		else {
			if (s[i] == 'a')
				continue;
			if ('z' - s[i] + 1 <= k) {
				k -= 'z' - s[i] + 1;
				s[i] = 'a';
			}
		}
	}
	cout << s << "\n";
	return 0;
}




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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m, q;
string s;

int main() {
    cin >> n >> q >> s;

    Vi v(n, 0);
    REP2(i, 1, n) {
        if (s.substr(i-1, 2) == "AC") {
            v[i] = v[i-1] + 1;
        } else {
            v[i] = v[i-1];
        }
    }

    REP(i, q) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        std::cout << v[r]-v[l] << '\n';
    }

    return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
typedef long long ll;
ll bits[50],now[50];
int n,m;
ll x[MAXN],y[MAXN];
bool flag[2];
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++){
		SF("%lld%lld",&x[i],&y[i]);
		flag[((x[i]+y[i])%2+2)%2]=1;
	}
	if(flag[0]==1&&flag[1]==1){
		PF("-1");
		return 0;
	}
	bits[0]=1;
	for(int i=1;i<40;i++)
		bits[i]=bits[i-1]*2ll;
	if(flag[1]==1){
		m=39;
		PF("39\n");
		for(int i=0;i<39;i++){
			PF("%lld ",bits[i]);
			now[i]=bits[i];
		}
		PF("\n");
	}
	else{
		m=40;
		PF("40\n1 ");
		now[0]=1;
		for(int i=0;i<39;i++){
			PF("%lld ",bits[i]);
			now[i+1]=bits[i];
		}
		PF("\n");
	}
	stack<char> s;
	for(int i=1;i<=n;i++){
		for(int j=m-1;j>=0;j--){
			ll t1=x[i]+y[i];
			ll t2=x[i]-y[i];
			if(t1>=0&&t2>=0){
				s.push('R');
				x[i]-=now[j];
			}
			else if(t1>=0&&t2<=0){
				s.push('U');
				y[i]-=now[j];
			}
			else if(t2<=0&&t1<=0){
				s.push('L');
				x[i]+=now[j];
			}
			else{
				s.push('D');
				y[i]+=now[j];
			}
		}
		while(!s.empty()){
			PF("%c",s.top());
			s.pop();
		}
		PF("\n");
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

void solve_A(){
    
    REP(i,5){
        int x;
        cin >> x;
        if(x == 0) cout << i + 1 << endl;
    }
}

void solve_B(){
    int x, y;
    cin >> x >> y;

    bool flag = false;
    if((y-2*x >= 0) && (y-2*x) % 2 == 0){
        if((4*x-y >= 0) && (4*x - y) % 2 == 0){
            flag = true;
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(void){
    solve_B();
    
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<iostream>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BP(n) __builtin_popcount(n)
#define bs(v,x) binary_search(all(v),x)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=1;j<n;j++)
#define Unique(v) vector<string>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define PI 3.14159265358979323846
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
void input(vector<int>& v,int n){ int i; int io; rep(i,n) { cin>>io; v.pb(io);} }
/*void output(vector<int> v) { int i; rep(i,v.size()) cout<<v.at(i)<<" "; }
map<string,int>  frequency(vector<string> v){  int i; map<string,int> m; rep (i,v.size()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(ll n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }*/

int main() {
	fastio;
	int i,n,c=0;
	cin>>n;
	vector<int> v;
	input(v,n);
	rep(i,n) {
		if ((i+1)%2==1 and v.at(i)%2==1)
			c++;
	}
	cout<<c<<endl;
} 	

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

int main(){

        int a[3];
        int i;
        int tmp;

        cin >> a[0] >> a[1] >> a[2];

        if(a[0]>a[1]){
                tmp=a[0];
                a[0]=a[1];
                a[1]=tmp;
        }
        if(a[1]>a[2]){
                tmp=a[1];
                a[1]=a[2];
                a[2]=tmp;
        }
        if(a[0]>a[1]){
                tmp=a[0];
                a[0]=a[1];
                a[1]=tmp;
        }

        for(i=0;i<3;i++){
        cout << a[i];
        if(i==2){
        break;
        }
        cout << " ";
        }
        cout <<endl;



        return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <set>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    ll n;
    cin >> n;
    ll p[200010];
    rep(i, n) cin >> p[i];
    ll pos[200010];
    rep(i, n) pos[p[i]] = i;
    set<ll> larger_pos;
    larger_pos.insert(pos[n]);
    ll sum = 0;

    const int invalid = -1053;

    for (ll t = n - 1; t >= 1; t--) {
        ll l1, l2, r1, r2;
        auto itr = larger_pos.lower_bound(pos[t]);

        if (itr == larger_pos.end()) {
            r1 = n;
            r2 = invalid;
        } else {
            r1 = *itr;
            itr++;
            r2 = (itr == larger_pos.end() ? n : *itr);
            itr--;
        }
        if (itr == larger_pos.begin()) {
            l1 = -1, l2 = invalid;
        } else {
            itr--;
            l1 = *itr;
            if (itr == larger_pos.begin()) l2 = -1;
            else {
                itr--;
                l2 = *itr;
                itr++;
            }
        }

        if (l2 != invalid) sum += (l1 - l2) * (r1 - pos[t]) * t;
        if (r2 != invalid) sum += (r2 - r1) * (pos[t] - l1) * t;

        larger_pos.insert(pos[t]);
    }
    
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 7808
def main():
    buf = input()
    N = int(buf)
    edge = dict()
    for i in range(N):
        edge[i] = [] # zero index
    for i in range(N-1):
        buf = input()
        buflist = list(buf.split())
        u = int(buflist[0])-1 # zero index
        v = int(buflist[1])-1 # zero index
        w = int(buflist[2])
        edge[u].append((w, v))
        edge[v].append((w, u))
    vertex_color = []
    for i in range(N):
        vertex_color.append(None)
    stack = [(0, 0)] # distance, vertex_id
    while stack:
        current = stack.pop()
        if current[0] % 2 == 0:
            vertex_color[current[1]] = 1
        else:
            vertex_color[current[1]] = 0
        for e in edge[current[1]]:
            if vertex_color[e[1]] == None:
                stack.append((current[0]+e[0], e[1]))
    for x in vertex_color:
        print(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 47332
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#include <utility>
using namespace std;
bool c[200];
bool used[200];
int main() {
	int n;
	while(scanf("%d",&n),n) {
		memset(c,0,sizeof(c));
		memset(used,0,sizeof(used));
		for(int i=0;i<n;i++) {
			int x;
			scanf("%d",&x);
			c[x-1]=true;
		}
		int f=-1,turn=1,T=n,H=n;
		while(T>0 && H>0) {
			int nx;
			for(nx=f+1;nx<2*n;nx++) {
				if(!used[nx] && c[nx]==turn) {used[nx]=true;break;}
			}
			if(nx>=2*n) {
				f=-1;
			}else {
				f=nx;
				if(turn) T--; else H--;
			}
			turn^=1;
		}
		printf("%d\n%d\n",H,T);
	}
}

Measured memory_bytes: 1188
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a,b,d;
bool cmp(const P &lhs,const P &rhs)
{
	if(lhs.first+lhs.second==rhs.first+rhs.second)
		return lhs.first*a+lhs.second*b<rhs.first*a+rhs.second*b;
	return lhs.first+lhs.second<rhs.first+rhs.second;
}
vector<P> v;
int main()
{
	while(1)
	{
		cin>>a>>b>>d;
		if(a==0 && b==0)
			break;
		v.clear();
		//b側を変化させる
		for(ll i=0;i<1e5;i++)
		{
			if((b*i+d)%a==0)
				v.push_back(P((b*i+d)/a,i));
		}
		//a側を変化させる
		for(ll i=0;i<1e5;i++)
		{
			if((a*i+d)%b==0)
				v.push_back(P(i,(a*i+d)/b));
		}
		//両方とも変化させる
		for(ll i=0;i*a<=d;i++)
		{
			for(ll j=0;i*a+j*b<=d;j++)
			{
				if(i*a+j*b==d)
					v.push_back(P(i,j));
			}
		}
		sort(v.begin(),v.end(),cmp);
		cout<<v[0].first<<" "<<v[0].second<<endl;
	}
}


Measured memory_bytes: 6856
//abc134.cpp
//Sat Oct 12 12:39:21 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[n];
	vector<int> heads;
	for (int i=0;i<n;i++){
		int a;
		cin >> a;
		if (heads.size()==0){
			heads.push_back(a);
		}else{
			if (a<=heads[0]){
				heads.insert(heads.begin(),a);
			}else {
				auto iter = lower_bound(heads.begin(),heads.end(),a);
				heads[iter-heads.begin()-1] = a;
			}
		}
	}

	cout << heads.size()<< endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 892
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        int ans = 0;
        while (n-- > 0) {
            int num = sc.nextInt();
            int tmp = Math.min(k-num, num);
            ans += tmp;
        }
        System.out.println(ans*2);
    }
}


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

const int MAX = 1e6;

using namespace std;

int main(){
  int N;
  scanf("%d", &N);
  
  vector<int> min_primes(MAX + 1);
  for(int i = 0; i <= MAX; i++) min_primes[i] = i;
  
  for(int i = 2; i * i <= MAX; i++){
    if(min_primes[i] < i) continue;
    
    for(int j = i; j <= MAX; j += i){
      if(min_primes[j] == j) min_primes[j] = i;
    }
  }
  
  vector<bool> used_primes(MAX + 1, false);
  int all_gcd = 0;
  bool pairwise_coprime = true;
  for(int i = 0; i < N; i++){
    int A;
    scanf("%d", &A);
    all_gcd = gcd(all_gcd, A);
    
    while(A > 1){
      int d = min_primes[A];
      if(used_primes[d]){
        pairwise_coprime = false;
        break;
      }
      
      used_primes[d] = true;
      while(min_primes[A] == d) A /= d;
    }
  }
  
  if(all_gcd == 1){
    if(pairwise_coprime) puts("pairwise coprime");
    else puts("setwise coprime");
  }else{
    puts("not coprime");
  }
  
  return 0;
}

Measured memory_bytes: 7248
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define trace(x) cerr << #x << " = " << x << endl
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define pi acos(-1)
#define en '\n'
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 2e5+123;
const ll MOD = 1e9+7;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class T> void print(vector<T> &v){for(T u:v){cout<<u<<" ";}cout<<endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}
bool vis[mx];
vi adj[mx];
ll ans=0,m = -1;
void dfs(ll u)
{
    vis[u]=1;
    ans++;
    for(auto v:adj[u])
    {
        if(!vis[v])
            dfs(v);
    }
    m = max(m,ans);
}

int main()
{
    speed();
    ll a,b,i,u,v;
    cin>>a>>b;
    rep(i,b)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    mem(vis,0);

    for(i=1;i<=a;i++)
    {
        if(!vis[i]){
            ans=0;
            dfs(i);
        }
    }
    cout<<m<<endl;



return 0;
}



Measured memory_bytes: 20996
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/
vector<int> h;
int a, b;

bool solve(ll w) {
  ll bb = b * w;
  ll aa = (a - b);
  ll aac = w;
  for (auto& i : h) {
    ll c = i - bb;
    if (c > 0) {
      aac -= c / aa;
      aac -= (c % aa) != 0;
    }
  }
  return aac >= 0;
}


void Calc() {

  var(int, n);
  in, a, b;
  h = in.Array(n);

  ll l = 0, r = (int)1e11;

  while (r - l > 0) {
    ll mid = (l + r) / 2;
    if (solve(mid))r = mid;
    else l = mid + 1;
  }
  cout << (l) << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    int64_t C;
    cin >> N >> C;
    vector<int64_t> x(N+2), v(N+2);
    for(int i=1; i<=N; i++) {
        cin >> x[i] >> v[i];
    }

    x.back() = C;
    vector<int64_t> y(x.rbegin(), x.rend()), w(v.rbegin(), v.rend());
    partial_sum(v.begin(), v.end(), v.begin());
    partial_sum(w.begin(), w.end(), w.begin());

    for(int i=0; i<N+2; i++) {
        y[i] = C - y[i];
    }
    vector<int64_t> xm(N+2), ym(N+2);
    for(int i=1; i<=N; i++) {
        xm[i] = max(xm[i-1], v[i]-x[i]);
    }
    for(int i=1; i<=N; i++) {
        ym[i] = max(ym[i-1], w[i]-y[i]);
    }

    int64_t ans = -1;
    for(int i=0; i<=N; i++) {
        ans = max(ans, v[i] - 2*x[i] + ym[N-i]);
    }
    for(int i=0; i<=N; i++) {
        ans = max(ans, w[i] - 2*y[i] + xm[N-i]);
    }

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


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

string S, l, r;
int Q;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin >> S;
	cin >> Q;
	bool flag = true;
	for(int i = 0; i < Q; i++){
		int T;
		cin >> T;
		if(T == 1) flag = !flag;
		else{
			int F;
			char C;
			cin >> F >> C;
			if(flag){
				if(F == 1) l += C;
				else r += C;
			}else{
				if(F == 2) l += C;
				else r += C;
			}
		}
	}
	reverse(l.begin(), l.end());
	S = l + S + r;
	if(!flag) reverse(S.begin(), S.end());
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
	int N;
    int[] a;
    int[] b;
    int[] c;
	public static void main(String[] args) {
        (new Main()).run();
    }
    
    void run(){
        input();
        int[][] dp = new int[N+1][3];
        
        for(int i=1; i<=N; i++){
            dp[i][0] = Math.max(dp[i-1][1],dp[i-1][2]) + a[i];
            dp[i][1] = Math.max(dp[i-1][0],dp[i-1][2]) + b[i];
            dp[i][2] = Math.max(dp[i-1][0],dp[i-1][1]) + c[i];
        }
        System.out.println(Math.max(dp[N][0],Math.max(dp[N][1],dp[N][2])));
    }
	void input(){
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        a = new int[N+1];
        b = new int[N+1];
        c = new int[N+1];
        for(int i=1; i<=N; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
	}
}

Measured memory_bytes: 95376
#include<stdio.h>
int main()
{ 
  int d[1000]={0};
  int i=0,j=0,n=0,ans=0;
  scanf("%d",&n);
  ans=n;
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
  }  
  for(i=0;i<n;i++){
  	for(j=i+1;j<n;j++){
    	if(d[i]==d[j]){
         --ans;
          break;
        }
    }
  }
  printf("%d",ans);
    return 0;
  }


Measured memory_bytes: 1680