akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <cstdlib>

using namespace std;

int main(){

    //スペース区切りでの整数
    int x, a, b;
    cin >> x >> a >> b;
    
    //比較
    a = x - a;
    b = x - b;
    
    //出力
    if(abs(b) > abs(a)){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<usize>();
    let mut ans = 0;
    for mut a in v {
        while a % 2 == 0 {
            ans += 1;
            a /= 2;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int main()
{
	int x=io::F(),y=io::F();
	if(x%y==0)puts("-1");
		else printf("%d\n",x);
	return 0;
}



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

int main() {
	long long n, m, a[100009][3], maxn = -(1LL << 60);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++)cin >> a[i][j];
	}
	for (int i = 0; i < 8; i++) {
		vector<long long> vec;
		for (int j = 1; j <= n; j++) {
			long long sum = 0;
			for (int k = 0; k < 3; k++) {
				if ((i / (1 << k)) % 2 == 0)sum += a[j][k];
				else sum -= a[j][k];
			}
			vec.push_back(sum);
		}
		sort(vec.begin(), vec.end());
		reverse(vec.begin(), vec.end());
		long long ans = 0;
		for (int j = 0; j < m; j++) ans += vec[j];
		maxn = max(maxn, ans);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main() {
    int k;
     string s;
    cin>>k>>s;
    if (s.length()>k) 
	{
        for(int i=0;i<k;i++)
        {
        	cout<<s[i];
		}
		cout<<"..."<<endl;
    }
    else
    {
    	cout<<s<<endl;
	}
     
    return 0;
}

Measured memory_bytes: 3036
use proconio::input;

fn main() {
    input! {
        p: (i32, i32),
    };
    let n = p.0;
    let y = p.1;
    for a in 0..n+1 {
        for b in 0..n+1 {
            let c = n - a - b;
            if c < 0 {
                continue;
            }
            if y == 10000 * a + 5000 * b + 1000 * c {
                println!("{} {} {}", a, b, c);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}


Measured memory_bytes: 2120
#include <stdio.h>

int main(void) {
    char s[5];
    int i = 0;
    int f = 0;

    scanf("%s", s);

    while(i < 4) {
        if (s[i] == s[i+1]) {
            printf("Bad\n");
            f++;
            break;
        }
        i++;
    }

    if (i == 4 && f == 0)
        printf("Good\n");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int cnt[15][1005]; string s[15];

int main(){
    int h,w,k; cin >> h >> w >> k;
    rep(i,h) cin >> s[i];
    int ans = 1e9;

    rep(bit, (1 << (h-1))){
        int d = 0;
        vector<int> id(h);
        rep(i,h){
            id[i] = d;
            if((bit >> i) & 1) d++;
        }
        d++;

        rep(i,d){
            rep(j,w){
                cnt[i][j] = 0;
            }
        }
        rep(i,h){
            rep(j,w){
                cnt[id[i]][j] += (s[i][j] - '0');
            }
        }

        int tmp = d-1;
        vector<int> sum(d);

        auto check = [&](int l){
            rep(i,d) sum[i] += cnt[i][l];
            rep(i,d) {
                if(sum[i] > k) return false;
            }
            return true;
        };

        rep(i,w){
            if(!check(i)){
                sum = vector<int> (d);
                tmp++;
                if(!check(i)){
                    tmp = 1e9;
                    break;
                }
            }
        }

        chmin(ans, tmp);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-24
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    int A[100][10];
    int P[100][11];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 11; ++j) {
            cin >> P[i][j];
        }
    }

    int ans = -1e9;
    for (int i = 1; i < 1024; ++i) {

        // パターンiの各店舗との同時営業日を数える
        int bit = 0;
        int tmp[100] = {};
        while((i >> bit) > 0){
            if (i >> bit & 1){
                for (int j = 0; j < N; ++j) {
                    if (A[j][bit] == 1) tmp[j]++;
                }
            }
            bit++;
        }

        // 各店舗との同時営業日の数によって利益を加算
        int tmp_sum = 0;
        for (int j = 0; j < N; ++j) {
            tmp_sum += P[j][tmp[j]];
        }
        ans = max(tmp_sum,ans);
    }


    cout << ans << "\n";


    return 0;
}



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

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,m,l,r,i,lmax=0,rmin;
	cin>>n>>m;
	rmin=n+100;
	for(i=1;i<=m;i++)
	{
		cin>>l>>r;
		if(l>lmax) lmax=l;
		if(r<rmin) rmin=r;
		
	}
	if(lmax>rmin) cout<<'0'<<endl;
	else cout<<rmin-lmax+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	int A[200];

	int i;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	int cnt;
	int cnt_before = 50000;

	for (i = 0; i < N; i++) {
		cnt = 0;

		while (1) {
			if (A[i] % 2==0) {
				if (cnt == cnt_before)
					break;
				cnt++;
				A[i] /= 2;
			}
			else {
				cnt_before = cnt;
				break;
			}
		}

		if (cnt_before == 0)
			break;
	}

	if (cnt_before == 50000)
		cnt_before = 0;
	printf("%d\n", cnt_before);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  int answer=0;
  
  for(int i=0; i<N; i++){
    if(i%2==0 && a.at(i)%2==1) answer++;
  }
  
  cout << answer << endl;
}


Measured memory_bytes: 3548
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef unsigned long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
map<vector<int>,int> me;
vector<int> c[514];
lint co[514][514];
int cal(vector<int> a){
	if(a[0]==a[1] && a[1]==a[2] && a[2]==a[3]) return 4;
	if(a[0]==a[2] && a[1]==a[3]) return 2;return 1;
}
vector<int> ca2(vector<int> v){
	vector<int> ret=v;
	rep(j,4){
		int d=v[0];v[0]=v[1];v[1]=v[2];v[2]=v[3];v[3]=d;
		ret=min(ret,v);
	}
	return ret;
}
lint zyo(lint a,int b){
	lint ret=1;
	rep(i,b) ret*=a;return ret;
}
int main()
{
	rep(i,510){
		co[i][0]=1;
		rep(j,8) co[i][j+1]=co[i][j]*(i-j);
	}
	int n;lint out=0;
	cin>>n;
	rep(i,n){
		vector<int> v(4,0);
		rep(j,4) cin>>v[j];c[i]=ca2(v);
		rep(j,4){
			int d=v[0];v[0]=v[1];v[1]=v[2];v[2]=v[3];v[3]=d;
			c[i]=min(c[i],v);
		}
		me[c[i]]++;
	}
	//rep(i,n){rep(j,4) cout<<c[i][j]<<' ';cout<<endl;}
	rep(i,n) REP(j,i+1,n){
		me[c[i]]--;me[c[j]]--;
		vector<int> a=c[i],b=c[j];swap(b[0],b[2]);
		rep(k,4){
			map<vector<int>,int> m;
			rep(l,4){
				//m[vector<int>{a[l],a[(l+3)%4,b[(l+3)%4],b[l]]}]++;
				vector<int> v;v.pb(a[l]);v.pb(a[(l+3)%4]);v.pb(b[(l+3)%4]);v.pb(b[l]);
				m[ca2(v)]++;
			}
			lint t=1;
			map<vector<int>,int>::iterator it=m.begin();
			while(it!=m.end()){
				if(i==0 && j==4){
					//rep(l,4) cout<<(*it).fi[l]<<' ';cout<<endl;
				}
				t*=co[me[(*it).fi]][(*it).se];
				//cout<<me[(*it).fi]<<endl;
				t*=zyo(cal((*it).fi),(*it).se);
				it++;
			}
			//cout<<t<<endl;
			out+=t;
			int d=b[0];b[0]=b[1];b[1]=b[2];b[2]=b[3];b[3]=d;
		}
		me[c[i]]++;me[c[j]]++;
	}
	out/=3;
	cout<<out<<endl;
}


Measured memory_bytes: 141952
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define pli pair<long long , int>
#define pil pair<int ,long long>
#define pi acos(-1)
#define pb push_back
#define mkp make_pair
#define all(a) a.begin(), a.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;

    long double arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }

    long double ans=0 ;

    for(int i=0;i<n;i++){
        long double temp=1;
        for(int j=0;j<n;j++){
            if(i==j)continue;
            temp*=arr[j];
        }
        //cout<<ans<<endl;
        ans+=temp;
    }
    if(ans==0)ans=1;
    long double mul=1;
    for(int i=0;i<n;i++){
        mul*=arr[i];
    }

    //cout<<m<<" "<<a<<endl;
    cout<<fixed<<setprecision(6)<<mul/ans<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include<vector>

using namespace std;

const int MAX = 510000;
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;
}


vector<pair<long long, long long>> prime_factor(long long m) {
  vector<pair<long long, long long>> a;
  for(long long i = 2; i*i<= m; i++) {
    long long c = 0;
    while(m % i == 0) {
      c++;
      m /= i;
    }
    if(c>0) {
      a.push_back(make_pair(i, c));
    }
  }
  if(m != 1) {
    a.push_back(make_pair(m, 1));
  }
  return a;
}

long long factorization(long long n, long long m) {
  COMinit();
  vector<pair<long long, long long>> ans = prime_factor(m);
  /*
  for(auto iter = ans.begin(); iter != ans.end(); ++iter) {
    cout << iter->first << " "  << iter->second << endl;
  }
  */
  long long acc = 1;
  for(auto iter = ans.begin(); iter != ans.end(); ++iter) {
    pair<long long, long long> item = *iter;
    acc *= COM(item.second+(n-1), item.second) % MOD;
    acc %= MOD;
  }
  // n-1 + 指数 
  return acc;
}
int main() {
  long long n, m;
  cin >> n;
  cin >> m;
  cout << factorization(n, m);
  return 0;
}

Measured memory_bytes: 12160
#include <stdio.h>

int main(void)
{
    int a;
    int b;
    int c;
    int ans;
    
    scanf("%d %d %d",&a,&b,&c);
    
    ans = a + b + c;
    
    if(ans>=22){
        printf("bust");
    }
    else{
        printf("win");
    }
    
    return 0;
}

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

#define PB push_back
#define SZ(c) int((c).size())
#define CONTAINS(c, x) ((c).find(x) != (c).end())
#define REP(i, n) for(int i=1; i<=n; i++)
#define WAIT cout<<flush, system("PAUSE");
using namespace std;
typedef long long ll;
const int MOD = 924844033;
const int MAX = 2100;

int N, K, sz;
bool used[MAX][2];
vector<int> A;
int path[MAX][MAX];
ll dp[2][MAX], F[MAX], sol;

void inc(ll &x, ll y){
	x = (x+y) % MOD;
	x += MOD;
	x %= MOD;
}
void DFS(int n, int l){
	sz++;
	used[n][l] = true;
	if (n+K <= N && !used[n+K][1-l]) DFS(n+K, 1-l);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	F[0]=1;
	REP(I, MAX-1) F[I] = (F[I-1]*I) % MOD; 
	cin >> N >> K;
	
	// see permutation as a bipartite graph!!!
	REP(I, N) REP(K, 2) 
		if (!used[I][K-1]){
			sz = 0;
			DFS(I, K-1);
			A.PB(sz - 1);
		}
	//for(auto x: A) cout << x << " "; cout << endl;
	
	path[0][0] = 1;
	path[1][0] = path[1][1] = 1;
	REP(I, MAX-1) if (I>=2){
		path[I][0] = 1;
		REP(K, I) path[I][K] = (path[I-1][K] + path[I-2][K-1]) % MOD;
	}
	
	int p = 0, c = 1;
	dp[c][0] = 1;
	for(auto x: A){ // at first didn't noticed this was N * (A_0 + A_1 + .. ) <= N*2*N
		swap(p, c);
		memset(dp[c], 0, sizeof(dp[c]));
		
		for(int curr=0; curr <= x; curr++)
		for(int prv=0; prv <= N; prv++){
			inc( dp[c][curr+prv], dp[p][prv] * 1ll * path[x][curr] );
		}
	}
	
	for(int bad=0; bad<=N; bad++)
		if (bad&1) inc(sol, -dp[c][bad] * F[N-bad]);
		else       inc(sol, +dp[c][bad] * F[N-bad]);
		
	cout << sol << endl;
}

















Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
typedef string::const_iterator state;

string str;
string A,B;

string conv(string &S,int bit){
    string ret=S;
    for(int i=0;i<S.size();i++){
        if('a'<=S[i]&&'k'>=S[i]){
            ret[i]=((bit>>(S[i]-'a')&1)?'1':'0');
        }
    }
    return ret;
}
int expression(state &);

int number(state &b){
    int ret=0;
    while(isdigit(*b)){
        ret=ret*10+*b-'0';
        b++;
    }
    return ret;
}

int fact(state &b){
    int ret;
    if(*b=='('){
        b++;
        ret=expression(b);
        b++;
    }
    else{
        ret=number(b);
    }
    return ret;
}

int latte(state &b){
    if(*b=='-'){
        b++;
        return 1-latte(b);
    }
    else return fact(b);
}

int expression(state &b){
    int ret=latte(b);
    while(true){
        if(*b=='+'){
            b++;
            ret=max(ret,latte(b));
        }
        else if(*b=='*'){
            b++;
            ret=min(ret,latte(b));
        }
        else if(*b=='-'){
            b++;b++;
            ret=(ret<=latte(b)?1:0);
        }
        else break;
    }
    return ret;
}

void solve(){
    for(int i=0;i<str.size();i++){
        if(str[i]=='T')str[i]='1';
        if(str[i]=='F')str[i]='0';
    }

    int idx=str.find('=');
    A=str.substr(0,idx);
    B=str.substr(idx+1,str.size()-idx-1);
    A+="=";B+="=";

    for(int i=0;i<(1<<11);i++){
        string a=conv(A,i),b=conv(B,i);
        state sa=a.begin(),sb=b.begin();
        if(expression(sa)!=expression(sb)){
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;
}

int main(){
    while(cin>>str,str!="#")solve();
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define birth <<
#define day endl
#define rollman 0
#define to ;return
using namespace std;
typedef int otaku;

otaku main(){
  otaku roll[4],man[2];
  for(otaku i=0;i<4;i++)cin>>roll[i];
  for(otaku i=0;i<2;i++)cin>>man[i];
 
  sort(roll,roll+4);
  sort(man,man+2);
  otaku Happy=0;
  for(otaku i=3;i>=1;i--) Happy+=roll[i];
  Happy+=man[1];
  cout << 
    Happy birth day to rollman;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

vector<vector<ll>> dp(405, vector<ll>(405, -1));
vector<ll> a(405);

ll ttl(ll x, ll y) {
	ll rv = 0;
	rep(i, x, y + 1) rv += a[i];
	return rv;
}

ll f(ll x, ll y) {
	if (x == y) return 0;
	if (x > y) { assert(false); }

	if (dp[x][y] != -1) return dp[x][y];

	if (x + 1 == y) {
		dp[x][y] = a[x] + a[y];
	} else {
		dp[x][y] = 0x3f3f3f3f3f3f3f3fll;
		ll dd = ttl(x, y);
		rep(i, x, y) {
			chmin(dp[x][y], f(x, i) + f(i + 1, y) + dd);
		} 
	}

	return f(x, y);
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	rep(i, 0, n) read(a[i]);
	die(f(0, n - 1));
}


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

#define endl '\n'

int N, f, MAX;
vector<int> G[200005];

void dfs(int cur, int par, int len) {
    if(len > MAX) {
        MAX = len;
        f = cur;
    }
    for(int i=0; i<G[cur].size(); i++) {
        int nxt = G[cur][i]; if(nxt == par) continue;
        dfs(nxt, cur, len+1);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> N;
    for(int i=1; i<N; i++) {
        int a, b; cin >> a >> b;
        G[a].push_back(b); G[b].push_back(a);
    }
    dfs(1, 0, 1);
    MAX = 0;
    dfs(f, 0, 1);
    if((MAX - 2) % 3 == 0) cout << "Second";
    else cout << "First";
}


Measured memory_bytes: 23680
#include<iostream>
using namespace std;
int p,q,a,n,an;
void dfs(int d,int s,int t,int j){
  if(d>n||s*q>p*t)return;
  if(s*q==p*t){an++;return;}
  for(int i=j;t*i<=a;i++){
    dfs(d+1,s*i+t,t*i,i);
  }
}

int main(){
  while(cin>>p>>q>>a>>n&&n){
    an=0;
    dfs(0,0,1,1);
    cout<<an<<endl;
  }
  return 0;
}

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

int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   int n;
   cin >> n;
   vector <int> a(n);
   for (auto &i: a)
      cin >> i;
   ll money = 1000;
   for (int i = 0; i < n - 1; i++) {
      ll stocks = 0;
      if (a[i] < a[i + 1])
         stocks = money / a[i];
      money += stocks * (a[i + 1] - a[i]);
   }
   cout << money << '\n';

   return 0;
}

Measured memory_bytes: 3636
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {

  case class Rotation(run: Dice => Dice){
    def apply(d: Dice): Dice = run(d)
    def compose(other: Rotation): Rotation = Rotation(run compose other.run)
  }

  object Rotation {
    def id = Rotation(d => d)
    def north = Rotation(d => Dice(List(1,5,2,3,0,4).map(d.pip)))
    def east = Rotation(d => Dice(List(3,1,0,5,4,2).map(d.pip)))
    def ccw = Rotation(d => Dice(List(0,3,1,4,2,5).map(d.pip)))

    final def axial(rotation: Rotation): Seq[Rotation] =
      for(i <- 0 to 3) yield List.fill(i)(rotation).fold(id)(_ compose _)

    def enumerateTop(): Seq[Rotation] =
      for(i <- 1 to 6) yield ((0 to i).map(j => if(j % 2 == 0) north else east)).fold(id)(_ compose _)

    def enumerate: Seq[Rotation] = enumerateTop().flatMap(e => axial(ccw).map(e compose _))
  }

  case class Dice(pip: List[Int]){
    lazy val all: Seq[Dice] = Rotation.enumerate.map(_.run(Dice(pip)))
    def ===(that: Dice): Boolean = pip.corresponds(that.pip)(_ == _)
    def ==(that: Dice): Boolean = all.exists(_ === that)
  }

  def main(args: Array[String]): Unit = {
    val pip = readLine.split(" ").map(_.toInt).toList
    val all: Seq[Dice] = Rotation.enumerate.map(_.run(Dice(pip)))
    val Array(n,_*) = readLine.split(" ").map(_.toInt)

    for(i <- 1 to n){
      val Array(a,b,_*) = readLine.split(" ").map(_.toInt)
      println(all.filter(d => d.pip(0)==a && d.pip(1)==b)(0).pip(2))
    }
  }

}

Measured memory_bytes: 44516
#include <iostream>
using namespace std;
int main(){
  int A,B,C;

  cin >> A >> B >> C;
  int Day=0;

  while(C>0){
    Day+=1;
    if(Day%7==0){
      C=C-A;
      C=C-B;
    }
    else{
      C=C-A;
    }
  }

  cout << Day << "\n";
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

int main() {
    ll r, D, x;
    cin >> r >> D >> x;
    for (int i = 1; i <= 10; i++) {
        cout << r * x - D << endl;
        x = r * x - D;
    }
    return 0;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN             PIC X(30).
01 N              PIC 9(10).
01 M              PIC 9(10).
01 zs             PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO N M.
  COMPUTE zs = N * (N - 1) / 2 + M * (M - 1) / 2.
  DISPLAY zs.
  STOP RUN.


Measured memory_bytes: 636
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

// https://snuke.hatenablog.com/entry/2014/12/03/214243
// input  aaabaaaab
// output 921034210
int Zargorithm( int n, const int* S, int* A ) {
    A[0] = n;
    int i = 1, j = 0;
    while (i < n) {
        while (i+j < n && S[j] == S[i+j]) ++j;
        A[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < n && k+A[k] < j) A[i+k] = A[k], ++k;
        i += k; j -= k;
    }
    return 0;
}

char strS[500005];
char strT[500005];
char str[1500005];

int main(int argc, char* argv[])
{
    scanf("%s", strS);
    scanf("%s", strT);
    int nS=strlen(strS);
    int nT=strlen(strT);

    vector<int> flag(nS);
    int i;
    {
        strcpy( str, strT);
        for(i=nT; i<nT+nS+nT; i++) {
            str[i]=strS[(i-nT)%nS];
        }
        str[nT+nS+nT]='\0';
        int n=strlen(str);
        assert(nT+nS+nT==n);

        vector<int> S(n), A(n);
        for(i=0; i<n; i++) {
            S[i]=str[i]-'a';
        }
        Zargorithm( n, &S[0], &A[0]);
        for(i=0; i<nS; i++) {
            if(A[i+nT]>=nT) {
                flag[i]=-1;
            }
        }
    }

    int cnt = 0;
    while(1) {
        int cntprev = cnt;
        int i;
        for(i=0; i<nS; i++) {
            int curr=i;           
            while(flag[curr]>=0) {
                int next=(curr-(nT%nS)+nS)%nS;
                if(flag[next]>=0) break;
                flag[next]=flag[curr]+1;
                cnt++;
                curr=next;
            }
        }
        break;
    }

    int max=-1;
    for(i=0; i<nS; i++) {
        if(flag[i]==-1) {
            printf("-1\n"); return 0;
        }
        max=MAX(max, flag[i]);
    }
    printf("%d\n", max);

    return 0;
}


Measured memory_bytes: 16384
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   int cnt = 2;
   ll lbb = 2;
   ll lb = 1;
   ll luk = 0;
   if(n==0){
      luk = 2;
   }else if(n==1){
      luk = 1;
   }else{
   while(cnt<=n){
      luk = lbb + lb;
      lbb = lb;
      lb = luk;
      cnt++;
   }
   }

   cout << luk << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll q1, b, c1, c2, q2;
    while(cin >> q1, q1){
        cin >> b >> c1 >> c2 >> q2;
        [&](){
            for (ll i = q2; i >= 1; --i) {
                if(b-c1*i < 0) continue;
                ll j = (b-c1*i)/c2;
                if(q1 <= i+j){
                    cout << i << " " << j << "\n";
                    return;
                }
            }
            puts("NA");
        }();
    }
    return 0;
}


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

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


void solve()
{  
    int n;
    cin>>n;
    
    unordered_map<int,int>m;
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                long long int val=i*i+j*j+k*k+i*j+i*k+j*k;
                m[val]++;
            }
        }
    }
    
    for(int i=1;i<=n;i++)
    {
        cout<<m[i]<<endl;
    }
}


int main()
 {  fast();
    solve();
	return 0;
}

Measured memory_bytes: 5016
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define X first
#define Y second
#define pb push_back
const int N=100000;
int n,m;
pair<int,int> a[N+1]; 
vector<pair<int,int> > nei[N+2];
int vis[N+1];
int dp[N+2];
vector<int> ans;
void dfs(int x){
	vis[x]=true;
	for(int i=0;i<nei[x].size();i++){
		int y=nei[x][i].X,z=nei[x][i].Y;
		if(vis[y])continue;
		dfs(y);
		if(dp[y])dp[y]=false,dp[x]^=1,ans.pb(z);
	}
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i].X,&a[i].Y);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)dp[i]=a[i].Y^a[i-1].Y;
	for(int i=1;i<=m;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		int l0=lower_bound(a+1,a+n+1,mp(l,0))-a,r0=upper_bound(a+1,a+n+1,mp(r,1))-a;
//		cout<<l0<<","<<r0<<"\n";
		nei[l0].pb(mp(r0,i));nei[r0].pb(mp(l0,i));
	}
	for(int i=n+1;i;i--)if(!vis[i])
		if(dfs(i),i<=n&&dp[i])return puts("-1"),0;
	sort(ans.begin(),ans.end());
	cout<<ans.size()<<"\n";
	for(int i=0;i<ans.size();i++)printf("%d ",ans[i]);
	return 0;
}
/*1
3 4
5 1
10 1
8 0
1 10
4 5
6 7
8 9
*/
/*2
4 2
2 0
3 1
5 1
7 0
1 4
4 7
*/
/*3
3 2
5 0
10 0
8 0
6 9
66 99
*/
/*4
12 20
536130100 1
150049660 1
79245447 1
132551741 0
89484841 1
328129089 0
623467741 0
248785745 0
421631475 0
498966877 0
43768791 1
112237273 0
21499042 142460201
58176487 384985131
88563042 144788076
120198276 497115965
134867387 563350571
211946499 458996604
233934566 297258009
335674184 555985828
414601661 520203502
101135608 501051309
90972258 300372385
255474956 630621190
436210625 517850028
145652401 192476406
377607297 520655694
244404406 304034433
112237273 359737255
392593015 463983307
150586788 504362212
54772353 83124235
*/

Measured memory_bytes: 15484
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
int N;

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

    cin >> N;
    vector<pair <int, int> > X(N);
    rep(i, N)cin >> X[i].second >> X[i].first;
    
    sort(X.begin(), X.end());
    int now = 0;
    rep(i, N){
        if(X[i].first < X[i].second + now){
            cout << "No" <<endl;
            return 0;
        }
        now += X[i].second;
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
a,b=map(int,input().split())

c1= (a-b)/2
c2= (b-a)/2

if abs(a-(a-c1))==abs(b-(a-c1)) and c1.is_integer():
    print(int(a-c1))
elif abs(a-(b-c2))==abs(b-(b-c2)) and c2.is_integer():
    print(int(b-c2))
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 3e3 + 5, M = 50 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
int n;
ld p[N], memo[N][N];
ld solve(int i = 0, int heads = 0)
{
    if(i == n && heads > int(n / 2))
        return 1.0;
    else if(i == n)
        return 0.0;
    ld &ret = memo[i][heads];
    if(ret != -1.0)
        return ret;
    ret = 0.0;
    ret = solve(i + 1, heads + 1) * p[i] + solve(i + 1, heads) * (1.0 - p[i]);
    return ret;
}
int main()
{
    MuhammedAly
    cin >> n;
    for(int i = 0 ; i < N ; i++)
        for(int j = 0 ; j < N ; j++)
            memo[i][j] = -1.0;
    for(int i = 0 ; i < n ; i++)
        cin >> p[i];
    cout << fixed << setprecision(9) << solve();
    return 0;
}

Measured memory_bytes: 141696
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ABuyingSweets {
public:
	void solve(istream& in, ostream& out) {
        int x,a,b;
        in >> x >> a >> b;
        out << (x - a) % b << endl;
 	}
};

int main() {
	ABuyingSweets solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int prev,curr,sum=0;
    cin >> prev;
    curr = prev;
    while(n != 1){
        cin >> curr;
        if(prev > curr){
            sum += prev - curr;
        }
        prev = curr;
        n--;
    }
    sum += curr;
    cout << sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int h, w; cin >> h >> w;
    rep(i, h) {
        rep(j, w) {
            string s; cin >> s;
            if(s == "snuke") {
                cout << (char)('A' + j) << i + 1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int n,a[50] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    scanf("%d",&n);
    printf("%d",a[n-1]);
    return 0;
}

Measured memory_bytes: 128
import java.util.*
import java.lang.Math.*

val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1e9.toLong()+7
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)


fun bsCntLte(A: LongArray, X: Long, includeEqual: Boolean = false): Int {
    return bsIdxLte(A,X, includeEqual) + 1
}
fun bsIdxLte(A: LongArray, X: Long, includeEqual:Boolean = false): Int {
    val N = A.size
    if (N == 0) return -1
    val xLess: (Long)->Boolean = if (includeEqual) {
        { Y:Long -> X < Y }
    } else {
        { Y:Long -> X <= Y }
    }
    if (xLess(A[0])) return -1
    var l = 0; var r = N
    while (l < r - 1) {
        val m = (l + r) / 2
        if (xLess(A[m])) {
            r = m
        } else {
            l = m
        }
    }
    return l
}


fun solve(S: LongArray, T: LongArray, X: LongArray): LongArray {
    val Q = X.size
    val res = LongArray(Q){0L}

    for (q in 0 until Q) {
        val x = X[q]
        val cntS = bsCntLte(S, x)
        val cntT = bsCntLte(T, x)

        val lS = if (cntS>0) S[cntS-1] else null
        val rS = if (S.size - cntS>0) S[cntS] else null
        val lT = if (cntT>0) T[cntT-1] else null
        val rT = if (T.size - cntT>0) T[cntT] else null

        var move = LINF
        if (lS != null && lT != null) {
            val dist = max(abs(lS - x), abs(lT - x))
            move = min(move, dist)
        }
        if (rS != null && rT != null) {
            val dist = max(abs(rS - x), abs(rT - x))
            move = min(move, dist)
        }
        if (lS != null && rT != null) {
            val dist = min(abs(lS - x)*2 + abs(rT - x),  abs(rT - x)*2 + abs(lS - x))
            move = min(move, dist)
        }
        if (rS != null && lT != null) {
            val dist = min(abs(rS - x)*2 + abs(lT - x),  abs(lT - x)*2 + abs(rS - x))
            move = min(move, dist)
        }

        res[q] = move
    }

    return res
}


fun main(args: Array<String>) {
    val (A,B,Q) = readIntArray()
    val S = LongArray(A)
    val T = LongArray(B)
    val X = LongArray(Q)
    for (i in 0 until A) {
        S[i] = readLong()
    }
    for (i in 0 until B) {
        T[i] = readLong()
    }
    for (i in 0 until Q) {
        X[i] = readLong()
    }

    val ans = solve(S,T,X)

    for (a in ans) {
        println(a)
    }
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}


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

int main(){
  ll N,M,ans;
  cin>>N>>M;
  if(2*N<M){
    ans = N;
    ans+=(M-2*N)/4;
  }else if(2*N>M){
    ans = M/2;
  }else{
    ans = N;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    let ds = reada int |> Array.sort
    let a = ds.[(n-1)/2]
    let b = ds.[n/2]
    printfn "%i" (b - a)
    0

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

int main()
{
  int H,N ;
  cin>>H>>N ;
  vector<int>A(N) ;
  for(int i=0;i<N;i++) cin>>A.at(i) ;
  
  int sum=0 ;
  for(int i=0;i<N;i++) sum+=A.at(i) ;
  
  if(sum>=H) cout<<"Yes"<<endl ;
  else cout<<"No"<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 640
#include<stdio.h>
const int N = 15;
int main()
{
	int a[N] = {0};
	for(int i = 0; i < 10; i++)
	{
		scanf("%d", &a[i]);
	}
	for(int i = 0; i < 10; i++)
	{
		for(int j = i; j < 10; j++)
		{
			if (a[i] < a[j])
			{
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	for(int i = 0;i < 3;i++)
	{
		printf("%d\n", a[i]);
	}
	return 0;
} 


Measured memory_bytes: 2748
from collections import defaultdict
N, M = map(int, input().split())
D = defaultdict(int)
for i in range(N):
    A, B = map(int, input().split())
    D[A] += B

ans = 0
for i in sorted(D.keys()):
    if M > D[i]:
        ans += i * D[i]
        M -= D[i]
    else:
        ans += i * M
        M -= M
    if M <= 0:
        break
print(ans)


Measured memory_bytes: 18140
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    d=set()
    for _ in range(n):
        o,w=input().split()
        if o=="insert":d.add(w)
        else:
            if w in d:
                print("yes")
            else:
                print("no")

main()



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

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))

K = input_one_number()
A,B = input_multiple_number()


if (A // K == B // K and A % K != 0):
	print("NG")
else:
	print("OK")



Measured memory_bytes: 9168
#include <stdio.h>

#define N 10

int main(void){
    int c1,c2,c3;
    int cnt;
     
    while (scanf("%d %d %d", &c1,&c2,&c3)!=EOF){
        cnt=0;
        for (int i=1; i<=N; i++){
            if (i!=c1 && i!=c2 && i!=c3){
                if (c1+c2+i <= 20) cnt++;
            }
        }
        printf(cnt>3 ? "YES\n" : "NO\n");
    }
    return 0;
}

Measured memory_bytes: 1008
from collections import*
n,*v=map(int,open(0).read().split())
a=Counter(v[::2]).most_common()
b=Counter(v[1::2]).most_common()
if a[0][0]==b[0][0]:
    if len(a)>1and len(b)>1:
        print(min(n-a[0][1]-b[1][1],n-a[1][1]-b[0][1]))
    elif len(a)>1:
        print(n-a[1][1]-b[0][1])
    elif len(b)>1:
        print(n-a[0][1]-b[1][1])
    else:
        print(n//2)
else:
    print(n-a[0][1]-b[0][1])

Measured memory_bytes: 20520
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007


int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin>>n>>m;
	vector<pair<bool, int>> vec(n+1, {false, 0});
	int ac = 0, wa = 0;
	while(m--){
		int sayi; string s; cin>>sayi>>s;
		if(vec[sayi].first == 0){
			if(s == "WA"){
				vec[sayi].second++;
			}else if(s == "AC"){
				ac++;
				wa += vec[sayi].second;
				vec[sayi].first = 1;
			}
		}
	}
	cout<<ac<<" "<<wa;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <queue>
#include <stack>

using namespace std;
int main()
{
    map<string, int> Vote_Num;
    int N;
    int max = 1;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string vote;
        cin >> vote;

        if (Vote_Num.count(vote))
        {
            int num = Vote_Num[vote] + 1;
            if (num > max)
            {
                max = num;
            }
            Vote_Num[vote] = num;
        }
        else
        {
            Vote_Num[vote] = 1;
        }
    }
    map<string, int>::iterator it;
    for (it = Vote_Num.begin(); it != Vote_Num.end();it++){
        if (it->second==max){
            cout << it->first<<endl;
        }
    }

}

Measured memory_bytes: 25216
const N=parse(Int,readline())
const X=Int[]
const Y=Int[]
function init()
	for i=1:N
		x,y=map(x->parse(Int,x),split(readline()))
		push!(X,x)
		push!(Y,y)
	end
end
cx=cy=cr=0
function norm(x1,y1,x2,y2)
	return (x1-x2)^2+(y1-y2)^2
end
function ok(id)
	return norm(X[id],Y[id],cx,cy)<cr+1e-10
end
function make(ia,ib)
	global cx=(X[ia]+X[ib])/2
	global cy=(Y[ia]+Y[ib])/2
	global cr=norm(X[ia],Y[ia],cx,cy)
end
function main()
	init()
	make(1,2)
	for i=3:N
		if ok(i)
			continue
		end
		make(1,i)
		for j=2:i-1
			if ok(j)
				continue
			end
			make(i,j)
			for k=1:j-1
				if ok(k)
					continue
				end
				A=norm(X[j],Y[j],X[k],Y[k])
				B=norm(X[k],Y[k],X[i],Y[i])
				C=norm(X[i],Y[i],X[j],Y[j])
				S=(X[j]-X[i])*(Y[k]-Y[i])-(X[k]-X[i])*(Y[j]-Y[i])
				S=4*S^2
				global cx=(A*(B+C-A)*X[i]+B*(C+A-B)*X[j]+C*(A+B-C)*X[k])/S
				global cy=(A*(B+C-A)*Y[i]+B*(C+A-B)*Y[j]+C*(A+B-C)*Y[k])/S
				global cr=norm(X[i],Y[i],cx,cy)
			end
		end
	end
	println(cr^.5)
end
main()

Measured memory_bytes: 113856
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); // サイコロの面の数
        int K = sc.nextInt(); // 目標点

        double sum = 0;
        for (int n = 1; n <= N; n++) {
            if (K/n == 0) {
                sum += 1;
                continue;
            }
            double count = Math.log((double)K/n) / Math.log(2);
            if (!isInteger(count)) {
                count = Math.floor(count) + 1;
            }
            sum += Math.pow((double)1/2, count);
        }
        System.out.print(sum/N);
    }

    // 整数かどうかを調べる。
    boolean isInteger (double number) {
        return (number == Math.floor(number));
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 21576
#include<stdio.h>
int main(void)
{
	int n,m,i,x,flg=0;
	scanf("%d %d",&n,&m);
	x=n*m;
	for(i=1;i<=3;i++) if(x*i%2!=0) flg=1;
	if(flg==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();

		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		int A = sc.nextInt();
		int B = sc.nextInt();

		if (A % 3 == 0) {
			System.out.println("Possible");
		} else if (B % 3 == 0) {
			System.out.println("Possible");
		} else if ((A + B) % 3 == 0) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;

namespace AOJ2
{
    class Program
    {


        static void Main(string[] args)
        {
            List<string> resultList = new List<string>();

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                string[] inputArray = input.Split(' ');

                int date = SetDate(inputArray);

                if (date <= 18680907)
                {
                    resultList.Add("pre-meiji");
                }
                else if (date <= 19120729)
                {
                    resultList.Add(string.Format("meiji {0} {1} {2}", (date - 18680000) / 10000 + 1, inputArray[1], inputArray[2]));
                }
                else if (date <= 19261224)
                {
                    resultList.Add(string.Format("taisho {0} {1} {2}", (date - 19120000) / 10000 + 1, inputArray[1], inputArray[2]));
                }
                else if (date <= 19890107)
                {
                    resultList.Add(string.Format("showa {0} {1} {2}", (date - 19260000) / 10000 + 1, inputArray[1], inputArray[2]));
                }
                else
                {
                    resultList.Add(string.Format("heisei {0} {1} {2}", (date - 19890000) / 10000 + 1, inputArray[1], inputArray[2]));
                }
            }

            foreach (string s in resultList)
            {
                Console.WriteLine(s);
            }


        }

        static int SetDate(string[] array)
        {
            string date;
            date = array[0];

            if (array[1].Length == 1)
            {
                date += "0" + array[1];
            }
            else
            {
                date += array[1];
            }

            if (array[2].Length == 1)
            {
                date += "0" + array[2];
            }
            else
            {
                date += array[2];
            }

            return int.Parse(date);

        }


    }
}

Measured memory_bytes: 5708