akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

void same (int d, const string &left, int l, int r);
// r - l is even
void different (int d, const string &left, int l, int r) {
  if (20 == d) return;
  int c = (l + r) / 2;
  cout << c << endl << flush;
  string center;
  cin >> center;
  if ("Vacant" == center) return;

  if (left == center)
    if (0 == (c - l) % 2) different(d+1, center, c, r);
    else same(d+1, left, l, c);
  else
    if (0 == (c - l) % 2) different(d+1, left, l, c);
    else same(d+1, center, c, r);
}

// r - l is odd
void same (int d, const string &left, int l, int r) {
  if (20 == d) return;
  int c = (l + r) / 2;
  cout << c << endl << flush;
  string center;
  cin >> center;
  if ("Vacant" == center) return;

  if (left == center)
    if (0 == (c - l) % 2) same(d+1, center, c, r);
    else same(d+1, left, l, c);
  else
    if (0 == (c - l) % 2) different(d+1, left, l, c);
    else different(d+1, center, c, r);
}

int main () {
  int n;
  cin >> n;
  string left;
  cout << 0 << endl << flush;
  cin >> left;
  if ("Vacant" == left) return 0;

  same(1, left, 0, n);
  return 0;
}


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

int main() {
	int N, D, X;
	cin >> N >> D >> X;
	int sum_choco = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		sum_choco += (1 + (D - 1) / tmp);
	}

	cout << sum_choco + X << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i;
  cin>>n>>k;
  int a[n],dp[n]={0};
  for(i=0;i<n;i++)
    cin>>a[i];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(i=2;i<n;i++){
    int sum=abs(a[i]-a[i-1])+dp[i-1];
  for(int j=i-2;j>=max(i-k,0);j--){
  	sum=min(sum,abs(a[i]-a[j])+dp[j]);
  }
    dp[i]=sum;
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

rest = x
i = 0
cnt = 0

while rest > 0 :
    if rest < a[i] :
        break
    rest -= a[i]
    i += 1
    if (i == N) :
        if (rest == 0) :
            cnt += 1
        break
    cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }


int main() {
	int n,m;
	cin >> n >> m;
	vector<int> l(m);
	vector<int> r(m);
	REP(i, m) {
		cin >> l[i] >> r[i];
	}
	int ml=l[0], mr=r[0];
	REP(i, m) {
		chmax(ml, l[i]);
		chmin(mr, r[i]);
	}
	put(max(0, mr - ml+1));
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int N, x;
	int a = 0;
	scanf("%d", &N);
	for (int i = 0; i < 25; i++)
	{
		for (int j = 0; j < 100; j++) {
			x = (4 * i) + (7 * j);
			if(N==x)
			{
				a++;
			}
		}
	}
	if (a > 0) {
		printf("Yes");
	}
	else
	{
		printf("No");
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int m[1000][1000];

int dir[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
struct Point {
    int y, x;
};
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int H, W;
    cin >> H >> W;
    queue<Point> x;
    for(int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for(int j = 0; j < W; j++) {
            m[i][j] = (S[j] == '#');
            if(m[i][j]) {
                x.push({i, j});
            }
        }
    }
    int ans;
    for(ans = 0; !x.empty(); ans++) {
        int N = x.size();
        for (int i = 0; i < N; i++) {
            for (int d = 0; d < 4; d++) {
                auto next = x.front();
                next.y += dir[d][0], next.x += dir[d][1];
                if (next.y < 0 || H <= next.y || next.x < 0 || W <= next.x || m[next.y][next.x]) {
                    continue;
                }
                m[next.y][next.x] = 1;
                x.push(next);
            }
            x.pop();
        }
    }
    cout << --ans << endl;
    return 0;
}

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

/*
問題文
12月30日のM時から次の年になるまでは何時間か、求めてください。

制約
1≦M≦23
入力は全て整数
*/
int main() {
  int m = 0;
  int hours = 0;

  cin >> m;
  if(m < 1 || 23 < m){
    return 1;
  }
  hours = 24 - m + 24;
  cout << hours << endl;
  return 0;
}


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

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

using namespace std;
using lint=long long;

template<class T>
class network{
	struct edge{
		int to,rev;
		T capa,flow;
		edge(int to,int rev,const T& capa,const T& flow):to(to),rev(rev),capa(capa),flow(flow){}
	};

	int s,t;
	vector<vector<edge>> G;

	vector<int> layer,now;

	bool make_layer(){
		int n=G.size();
		rep(u,n) layer[u]=(u==s?0:-1);

		queue<int> Q; Q.emplace(s);
		while(!Q.empty()){
			int u=Q.front(); Q.pop();
			for(const edge& e:G[u]) if(layer[e.to]==-1 && e.capa-e.flow>0) {
				layer[e.to]=layer[u]+1;
				if(e.to==t) return true;
				Q.emplace(e.to);
			}
		}
		return false;
	}

	T augment(int u,const T& water){
		if(u==t) return water;

		for(int& i=now[u];i<G[u].size();i++){
			edge& e=G[u][i];
			if(layer[e.to]>layer[u] && e.capa-e.flow>0){
				T w=augment(e.to,min(water,e.capa-e.flow));
				if(w>0){
					e.flow+=w;
					G[e.to][e.rev].flow-=w;
					return w;
				}
			}
		}
		return 0;
	}

public:
	network(int n,int s,int t):s(s),t(t),G(n){}

	void add_directed_edge(int u,int v,const T& capa){
		G[u].emplace_back(v,G[v].size()  ,capa,0);
		G[v].emplace_back(u,G[u].size()-1,   0,0);
	}

	void add_undirected_edge(int u,int v,const T& capa){
		G[u].emplace_back(v,G[v].size()  ,capa,0);
		G[v].emplace_back(u,G[u].size()-1,capa,0);
	}

	T maximum_flow(){
		int n=G.size();
		layer.resize(n);

		T res=0;
		while(make_layer()){
			now.assign(n,0);
			for(T water=1;water>0;res+=water) water=augment(s,numeric_limits<T>::max());
		}
		return res;
	}
};

const long long INF=1LL<<61;

int main(){
	int n; scanf("%d",&n);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	lint res=0;
	int s=0,t=n+1; // s 側 : 残す, t 側 : 壊す
	network<lint> G(n+2,s,t);
	rep(i,n){
		int x=i+1;
		if(a[i]>=0){
			res+=a[i];
			G.add_directed_edge(s,x,0);
			G.add_directed_edge(x,t,a[i]);
		}
		else{
			G.add_directed_edge(s,x,-a[i]);
			G.add_directed_edge(x,t,0);
		}

		for(int y=2*x;y<=n;y+=x){
			G.add_directed_edge(x,y,INF);
		}
	}

	printf("%lld\n",res-G.maximum_flow());

	return 0;
}


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

int main(){
  int n,tmp;
  vector<int> v;
  while(cin >> n,n){
    v.resize(n); for(int i=0;i<n;i++)cin >> v[i];
    
    int cnt = 0;
    for(;cnt<=10000;cnt++){
      bool f = true;
      for(int i=0;i<v.size();i++)
	if(v[i]!=i+1){ f=false; break; }
      if(f)break;

      v.push_back(v.size());
      for(int i=0;i<v.size()-1;i++)v[i]--;
      for(int i=0;i<v.size();i++){
	if(!v[i]){
	  v.erase(v.begin()+i); i--;
	}
      }
    }

    if(cnt==10001)cout << -1 << endl;
    else cout << cnt << endl;
  }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   int t;
   //cin>>t;
   
  t=1;
  while(t--)
   {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,c,min1=10000000000000,max2=-100;
   cin>>n;
    cout<<(1000*(n/500)+(5*((n%500)/5)));
  	
   }
   
 return 0;
}


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

int main()
{
    long long i, x = 0, ans = 0;
    string s;
    cin >> s;

    for(i = 0; i < s.size(); i++)
    {
        if(s[i] == 'B')
            x++;
        else
            ans += x;
    }

    cout << ans;
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll f(ll i){
	ll ret=0;
	while(i!=0){
		ret+=i%10;
		i/=10;
	}
	return ret;
}

int main(){
  ll k;cin>>k;
  string digit="";
  set<ll> s;
  rep(i,15){
  	FOR(i,1,300){
  		s.insert(stol(to_string(i)+(digit)));
  	}
  	digit+="9";
  }
  ll cnt=0;
  bool flg=true;
  reps(x,s){
  	flg=true;
  	reps(y,s){
  		if(y>x){
  			if(double(y)/f(y)<double(x)/f(x)){
  				flg=false;
  			}
  		}
  	}
  	if(flg){
  		cout<<x<<endl;
  		cnt++;
  		if(cnt==k){
  			return 0;
  		}
  	}
  }
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

signed main(){
    int n;cin>>n;
    int a=0;
    rep(i,n){
        int b;cin>>b;a=gcd(a,b);
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    res = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            ab = l[i] + l[j]
            x = bisect_left(l, ab)
            res += x - (j + 1)
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 42332
#include <stdio.h>
int main(void){
    int n;
    scanf("%d", &n);
    int a[n];
    int x;
    for(int i=1; i<=n; i++){
        scanf("%d", &x);
        a[x-1]=i;
    }

    for(int i=0; i<n; i++){
        printf("%d ", a[i]);
    }

}

Measured memory_bytes: 1152
#include <iostream>
#include <set>

using namespace std;

#define forsn(i,s,n) for(int i=(s); i<(int)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define F first
#define S second

typedef long long int tint;

tint answer[50];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	tint K; cin >> K;
	
	forn(i,50) answer[i] = i;
	
	int cur = 49;
	while (K % 50) {
		answer[cur--]++;
		K--;
	}
	
	forn(i,50) answer[i] += (K / 50);
	
	cout << 50 << "\n";
	forn(i, 50) cout << answer[i] << " \n"[i == 49];
	
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){

    int D, G;
    cin >> D >> G;
    int p[D], c[D];
    for(int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }

    int min_cnt = INF;

    for(int bit = 0; bit < (1 << D); bit++){

        int sum = 0;
        int cnt = 0;
        for(int  i = D; i >= 0; i--){
            if(bit & (1 << i)){
                // cout << bitset<8>(bit) << endl; 

                for(int j = 1; j <= p[i]; j++){
                    sum += 100 * (i+1);
                    cnt++;
                    if(j == p[i]){
                        sum += c[i];
                    }

                    if(sum >= G){
                        min_cnt = min(min_cnt, cnt);
                    }
                    // cout << sum << ":" << cnt << endl;
                }

            }
        }
    }

    cout << min_cnt << endl;

    return 0;
}

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

int main(){
	int S;
	int f,s;
	scanf("%d",&S);
	f=(int)(S/100);
	s=(int)(S%100);
	if(1<=f&&f<=12){
		if(1<=s&&s<=12){
			printf("AMBIGUOUS\n");
		}
		else printf("MMYY\n");
		return 0;
	}
	if(1<=s&&s<=12){
		printf("YYMM\n");
		return 0;
	}
	printf("NA\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int n, i, j, k, cnt, a, b, c, tmp;
    scanf("%d", &n);
    int arr[n];
    for (i=0; i<n; i++) scanf("%d", &arr[i]);
    sort(arr, arr+n);
    cnt=0;
    for (i=0; i<n-2; i++) {
        a=arr[i];
        for (j=i+1; j<n-1; j++) {
            b=arr[j];
            if (a!=b) {
                tmp=a+b;
                for (k=j+1; k<n; k++) {
                    if (arr[k]>=tmp) break;
                    if (arr[k]!=b) cnt++;
                }
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 3848
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<stdio.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<iomanip>
#define MAX 100001
#define ll long long int
#define eps 1e-7
using namespace std;

string str;
int main(){
  ios::sync_with_stdio(false);
  cin>>str;

  int n = str.size()-1;
  int s = 1<<n;
  long long int ans = 0;
  for(int i=0;i<s;i++){
    long long int num = 0;
    for(int j=0;j<n+1;j++){
      num = num*10 + str[j]-'0';
      if( 1<<j & i ){
        ans+=num;
        num = 0;
      }
    }
    ans+=num;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  
  if((a+b)%2==0){
    cout << (a+b)/2 << endl;
  }
  else{
    cout << (a+b+1)/2 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 2*100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
using namespace std;




int main()
{
	fast;
	ll n;
	cin>>n;
	ll dp[n+1]={0};	
	ll i;
	ll j;
	for(i=1;i<=n;i++)
	{
		for(j=1;j*i<=n;j++)
		{
			dp[i*j]++;
		}
	}
	ll ans=0;
	for(i=1;i<=n;i++)
	{
		ans+=i*dp[i];
	}
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair



int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll k = 1; k <= sqrt(n) + 10; k++) {
    if (n % k == 0) {
      ll m = n / k - 1;
      if (k < m) {
        ans += m;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,A[50];
int solve(int i,int m){
  if(m==0) return 1;
  if(i>=n) return 0;
  int res=solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

int main(){
  int q,M,i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()


int main(){

    ll N, M, X;
    cin >> N >> M >> X;

    vector<ll> v(M);
    for(int i = 0; i < M; i++){
        cin >> v[i];
    }
    
    auto it = lower_bound(all(v), X) - v.begin();
    cout << min((ll)it, (ll)(v.size()-it) ) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int getv(int n)
{
	int s=0;
	for (int i=1;i<=n;i++){
		s+=i;
	}
	return s;
}
int main(int argc, char* argv[])
{
	int a,b;
	cin>>a>>b;
	vector<int> vals;
	int i;
	for (i=1;i<=999;i++){
		vals.push_back(getv(i));
	}
	for (i=0;i<998;i++){
		if (vals[i]-a>=0 && vals[i+1]-b>=0 && vals[i]-a==vals[i+1]-b){
			cout<<vals[i]-a<<endl;
			return 0;
		}
	}
	return 0;
}

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

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

    int arr[n];
    int mn = INT_MAX;
    for(int i=0;i<n;++i)
    {
        cin >> arr[i];
        mn = max(mn,arr[i]);
    }

    bool dp[k+1];
    for(int i=0;i<=k;++i){
        dp[i]=false;
    }
    for(int i=0;i<=k;++i)
    {
        for(int j=0;j<n;++j){
            if(i>=arr[j]) {
                bool myans = dp[i-arr[j]];
                if(!myans) dp[i]=true;
            }
        }
    }
    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define f first
#define s second

using namespace std;

typedef long long ll;

ostream& operator << (ostream &os, vector <ll> &v) {
    for (ll i : v)
        os << i << " ";
    os << "\n";
    return os;
}

const ll MAXN = 101;
const ll MAXSZ = 1e5 + 1;

ll dp[MAXSZ][MAXN];

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n, maxsz;
    cin >> n >> maxsz;
    vector <ll> c(n + 1), w(n + 1);
    for (ll i = 1; i <= n; ++i)
        cin >> w[i] >> c[i];
    for (ll cur_w = 1; cur_w <= maxsz; ++cur_w)
        for (ll i = 1; i <= n; ++i)
            if (cur_w >= w[i])
                dp[cur_w][i] = max(dp[cur_w][i - 1], dp[cur_w - w[i]][i - 1] + c[i]);
            else
                dp[cur_w][i] = dp[cur_w][i - 1];
    cout << dp[maxsz][n] << "\n";
//    for (ll i = 0; i <= n; ++i)
//        for (ll j = 0; j <= maxsz; ++j)
//            cout << dp[j][i] << " \n"[j == maxsz];
    return 0;
}


Measured memory_bytes: 79232
int main(void){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a<b&&a<c)
 {
  A(a, b, c);
 }else if(b<c)
 {
  B(a, b, c);
 }else
 {
  C(a, b, c);
 }
return 0;
}

int A(int a, int b, int c){
if(b<c)
 {
  printf("%d %d %d\n",a,b,c);
 }else
 {
  printf("%d %d %d\n",a,c,b);
 }
return 0;
}

int B(int a, int b, int c){
if(a<c)
 {
  printf("%d %d %d\n",b,a,c);
 }else
 {
  printf("%d %d %d\n",b,c,a);
 }
return 0;
}

int C(int a, int b, int c){
if(a<b)
 {
  printf("%d %d %d\n",c,a,b);
 }else
 {
  printf("%d %d %d\n",c,b,a);
 }
return 0;
}

Measured memory_bytes: 1812
#include <iostream>

using namespace std;

int main()
{
	int R;
	cin >> R;
	if (R < 1200) {
		cout << "ABC" << endl;
	}
	else if (R < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
}


Measured memory_bytes: 768
using System;

class program
{
    public static void Main()
    {
        var length = int.Parse(Console.ReadLine());
        // S,H,C,D

        bool[,] cards = new bool[4, 13];
        

        for (int i = 0; i < length; i++)
        {
            var query = Console.ReadLine().Split(' ');
            cards[assignCard(query[0]), int.Parse(query[1]) - 1] = true;
        }

        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 13; k++)
            {
                if (!cards[j, k])
                {
                    Console.WriteLine("{0} {1}", reassignCard(j), k + 1);
                }
            }
        }
    }

    public static int assignCard(string sign)
    {
        switch (sign)
        {
            case "S":
                return 0;
            case "H":
                return 1;
            case "C":
                return 2;
            case "D":
                return 3;
        }

        return -1;
    }

    public static string reassignCard(int num)
    {
        switch (num)
        {
            case 0:
                return "S";
            case 1:
                return "H";
            case 2:
                return "C";
            case 3:
                return "D";
        }

        return "E";
    }
}

Measured memory_bytes: 5756
#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);

    string in; cin >> in;
    int n = in.size();
    vi a(n); rep(i, n) a[i] = in[i] - '0';

    int res = inf;
    rep(_, 2){
        int cur = 0;
        int pre = _;

        rep(i, n){
            if(a[i] != pre){
                cur++;
            }
            pre ^= 1;
        }

        chmin(res, cur);
    }

    cout << res << endl;

    return 0;
}


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

bool binarySearch(int* A, int n, int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right)/2;
    if (A[mid] == key) {
      return true;
    } else if (key < A[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return false;
}

int main() {
  int A[100000];
  int n, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }

  int q;
  int t;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (binarySearch(A, n, t))
      sum++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3472
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		sc.Scan()
		m[sc.Text()]++
	}
	fmt.Printf("AC x %d\n", m["AC"])
	fmt.Printf("WA x %d\n", m["WA"])
	fmt.Printf("TLE x %d\n", m["TLE"])
	fmt.Printf("RE x %d\n", m["RE"])
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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


Measured memory_bytes: 2140
N, M = gets.strip.split.map(&:to_i)
a = gets.strip.split.map(&:to_i).sort

# ds: distances
ds = Array.new(M - 1){0}

(M - 1).times { |i| ds[i] = a[i + 1] - a[i] } 
puts N < M ? ds.sort.reverse[(N - 1)..-1].inject(:+) : 0


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    string s[h]; int a[h-1][w];
    for (int i = 0; i < h; i++) cin >> s[i];
    for (int i = 0; i < h-1; i++) {
        a[i][w-1] = 1;
        for (int j = w-2; j >= 0; j--) {
            if ((s[i][j] == s[i+1][j]) ^ (s[i][j+1] != s[i+1][j+1])) {
                a[i][j] = a[i][j+1] + 1;
            } else {
                a[i][j] = 1;
            }
        }
    }
    int ans = max(h, w);
    for (int j = 0; j < w; j++) {
        vector<pair<int, int>> v;
        for (int i = 0; i < h-1; i++) {
            v.emplace_back(a[i][j], i);
        } 
        sort(v.begin(), v.end());
        set<int> s; s.emplace(-1), s.emplace(h-1);
        for (auto &iter: v) {
            auto x = iter.second;
            auto it = s.lower_bound(x);
            int p = *it;
            int q = *(--it);
            ans = max(ans, iter.first * (p - q));
            s.emplace(x);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 22272
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[200005];
bool flag[1000005];
int cnt[1000005];

int main(void){
	scanf("%d",&n);
	int ans=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(!flag[a[i]]){
			if(cnt[a[i]]<=1)ans++;
			for(int j=a[i];j<=1000000;j+=a[i]){
				flag[j]=true;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

int main(){
  map<string, int> ma, mb;
  array<string, 100> strs;
  int n,m;
  cin>>n;
  for(int i=0;i<n;i++){
    string str;
    cin>>str;
    ma[str]++;
    strs[i]=str;
  }

  cin>>m;
  for(int i=0;i<m;i++){
    string str;
    cin>>str;
    mb[str]++;
  }

  int result = 0;
  for(int i=0;i<n;i++){
    if(result<ma[strs[i]]-mb[strs[i]]){
      result = ma[strs[i]]-mb[strs[i]];
    }
  }
  cout<<result;

  return 0;
}


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

int main(){
    //a,bの入力
    int a,b;
    cin >> a >> b;

    //偶奇の判定
    if((a*b)%2==0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
    
}

Measured memory_bytes: 256
//use itertools::Itertools;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        s: chars,
        t: chars
    }

    let mut ans = true;

    for i in 0..s.len() {
        if s[i] != t[i] {
            ans = false;
        }
    }

    if ans {
        if s.len() + 1 != t.len() {
            ans = false;
        }
    }

    println!("{}", if ans { "Yes" } else { "No" });
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


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

int main(){
  vector<vector<char> > v;
  vector<char> mv;

  mv.push_back(' ');mv.push_back('.');mv.push_back(',');mv.push_back('!');mv.push_back('?');
  v.push_back(mv);
  mv.clear();

  mv.push_back('c');mv.push_back('a');mv.push_back('b');
  v.push_back(mv);
  mv.clear();

  mv.push_back('f');mv.push_back('d');mv.push_back('e');
  v.push_back(mv);
  mv.clear();

  mv.push_back('i');mv.push_back('g');mv.push_back('h');
  v.push_back(mv);
  mv.clear();

  mv.push_back('l');mv.push_back('j');mv.push_back('k');
  v.push_back(mv);
  mv.clear();

  mv.push_back('o');mv.push_back('m');mv.push_back('n');
  v.push_back(mv);
  mv.clear();

  mv.push_back('s');mv.push_back('p');mv.push_back('q');mv.push_back('r');
  v.push_back(mv);
  mv.clear();

  mv.push_back('v');mv.push_back('t');mv.push_back('u');
  v.push_back(mv);
  mv.clear();

  mv.push_back('z');mv.push_back('w');mv.push_back('x');mv.push_back('y');
  v.push_back(mv);
  mv.clear();

  string s;
  int a,i,cou,n,cou2,b;
  cin >>b;
  for(int j=0;j<b;j++){ // 入力
    cin>>s;
    a=s.size();
    //cout <<a<< ' ';//////////////////
    i=0;
    cou2=0;
    while(i<a){//改行まで
      cou=0;
      n=0;
      while(s[i]!='0'&&i<a){//０まで
	if(n!=s[i]-'0')cou=0;
	n=s[i]-'0';
	i++;
	cou++;
      }
      i++;
      //cout <<n<< cou<< ' ';/////////////////
      if(cou!=0&&i<=a){
	if(n==8||n==2||n==3||n==4||n==5||n==6)cou=cou%3;
	else if(n==7||n==9)cou=cou%4;
	else if(n==1)cou=cou%5;

	cout<<v[n-1][cou];
	cou2++;
      }
    }
    if(cou2!=0)cout<<endl;
  }
  return 0;
}

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

int H, W, N;
int sr, sc;
string S, T;

int Get(int pos, char ch, char lef, char rig)
{
    if (ch == lef) return pos - 1;
    if (ch == rig) return pos + 1;
    return pos;
}

bool Hold(char lef, char rig, int lim, int L, int R, int p, int i)
{
    if (p < 1 || p > lim) return false;
    else if (p < L || p > R) {
        int fix = Get(p, T[i], lef, rig);
        if (fix < L || fix > R) return false;
        return true;
    }
    return true;
}

bool Solve(char lef, char rig, int lim, int cur)
{
    int L = 1, R = lim;
    for (int i = N - 1; i >= 0; i--) {
        int L2 = L, R2 = R;
        if (!Hold(lef, rig, lim, L, R, L, i) ||
            S[i] == lef && !Hold(lef, rig, lim, L, R, L - 1, i))
            L2 = L + 1;
        else if (!Hold(lef, rig, lim, L, R, L - 1, i) ||
                 S[i] == lef && !Hold(lef, rig, lim, L, R, L - 2, i))
            L2 = L;
        else L2 = L - 1;
        if (!Hold(lef, rig, lim, L, R, R, i) ||
            S[i] == rig && !Hold(lef, rig, lim, L, R, R + 1, i))
            R2 = R - 1;
        else if (!Hold(lef, rig, lim, L, R, R + 1, i) ||
                 S[i] == rig && !Hold(lef, rig, lim, L, R, R + 2, i))
            R2 = R;
        else R2 = R + 1;
        L = L2, R = R2;
    }
    return L <= cur && cur <= R;
}

int main()
{
    scanf("%d %d %d", &H, &W, &N);
    scanf("%d %d", &sr, &sc);
    cin >> S >> T;
    printf("%s\n", (Solve('L', 'R', W, sc) && Solve('U', 'D', H, sr))? "YES": "NO");
    return 0;
}


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

int main(){
    int N,M,a,b;
    cin >> N >> M;
    vector<int> vec(N);
    for(int i=0;i<M;i++){
        cin >> a >> b;
        vec[a-1]++;
        vec[b-1]++;
    }
    for(int i=0;i<N;i++){
        cout << vec[i] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	int n; cin >> n;
	while(n--) {
		string s; cin >> s;
		sort(all(s));
		int vmin = toInt(s);
		sort(s.rbegin(), s.rend());
		int vmax = toInt(s);
		cout << vmax - vmin << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int dice[6] = { 1, 2, 3, 4, 5, 6 };
void roll(string order)
{
	int tmp;
	if (order == "North")
	{
		tmp = dice[0];
		dice[0] = dice[1];
		dice[1] = dice[5];
		dice[5] = dice[4];
		dice[4] = tmp;
	}
	if (order == "West")
	{
		tmp = dice[0];
		dice[0] = dice[2];
		dice[2] = dice[5];
		dice[5] = dice[3];
		dice[3] = tmp;
	}
	if (order == "South")
	{
		tmp = dice[0];
		dice[0] = dice[4];
		dice[4] = dice[5];
		dice[5] = dice[1];
		dice[1] = tmp;
	}
	if (order == "East")
	{
		tmp = dice[0];
		dice[0] = dice[3];
		dice[3] = dice[5];
		dice[5] = dice[2];
		dice[2] = tmp;
	}
	if (order == "Left")
	{
		tmp = dice[1];
		dice[1] = dice[3];
		dice[3] = dice[4];
		dice[4] = dice[2];
		dice[2] = tmp;
	}
	if (order == "Right")
	{
		tmp = dice[1];
		dice[1] = dice[2];
		dice[2] = dice[4];
		dice[4] = dice[3];
		dice[3] = tmp;
	}
}

int main()
{
	int n;
	while (cin >> n, n)
	{
		for (int i = 0; i < 6; i++) dice[i] = i + 1;

		string order;
		int ans = 1;
		for (int i = 0; i < n; i++)
		{
			cin >> order;
			roll(order);
			ans += dice[0];
		}
		cout << ans << endl;
	}

	return 0;
}

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

int main(){
    ll n;
    cin >>n;
    vector<ll> cons(4);
    rep(i,4)cons[i] = 0;
    rep(i,n){
        string ch;
        cin >> ch;
        if (ch[0] == 'A'){
            cons[0]++;
        }else if(ch[0] == 'W'){
            cons[1]++;
        }else if(ch[0] == 'T'){
            cons[2]++;
        }else if(ch[0] == 'R'){
            cons[3]++;
        }
    }
    cout << "AC x " << cons[0] <<endl;
    cout << "WA x " << cons[1] <<endl;
    cout << "TLE x " << cons[2] <<endl;
    cout << "RE x " << cons[3] <<endl;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int m=p[0];
  int cnt=1;
  for(int i=1;i<n;i++){
    if(m>p[i]){
      cnt++;
      m=p[i];
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
A, B, C, D = map(int, input().split())

def solve(A,B,C,D):
    dx,dy = C-A,D-B
    x,y = C-dy,D+dx
    ans = [x,y]
    x,y = x-dx,y-dy
    ans += [x,y]
    return ans
print(*solve(A,B,C,D),sep=' ')

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

typedef long long ll;

int main(void){
    int n;
    ll h, w; cin >> n >> h >> w;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ll a, b; cin >> a >> b;
        if (h <= a && w <= b) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int x=0,t=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			x=a[i]*a[j];
            t+=x;
		}
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define ff first
#define ss second
#define int long long
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"


const int N = 5e5 + 5;
const int M = 1e9 + 7;
int mod(int m){
   m%=M;
   return (m+M)%M;
}

int power(int x,int y) {
   int res = 1;
   x = mod(x);
   while (y > 0) {
      if (y & 1)
         res =mod(res*x);
      y = y>>1;
      x = mod(x*x);
   }
   return mod(res);
}

int f[N],invf[N];
void fact(){
   f[0]=f[1]=1;
   for(int i=2;i<N;i++)
      f[i]=mod(f[i-1]*i);

   invf[N-1]=power(f[N-1],M-2);
   for(int i=N-1;i>0;i--)
      invf[i-1]=mod(invf[i]*i);

}

int nCr(int n,int r) {
   if(r>n)
      return 0;
   int ans = f[n];
   ans = mod(ans*invf[n-r]);
   ans = mod(ans*invf[r]);
   return ans;
}

int nPr(int n,int r) {
   if(r>n)
      return 0;
   int ans = f[n];
   ans = mod(ans*invf[n-r]);
   return ans;
}

int32_t main() {
	boost;
	fact();
	int n, m, k;
	cin >> n >> m >> k;

	int d = 0;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			int tt = i*(i+1)/2;
			tt *= m;
			d += i*i*m - tt;
			tt = j*(j + 1)/2;
			tt *= n;
			d += j*j*n - tt;
		}
	}
	d = mod(d);
	int ans = mod(nCr(n*m-2,k-2)*d);
	cout<<ans<<endl;	
}

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

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

    for (int i = k; i < n; i++)
        if (v[i] > v[i - k])
            cout << "Yes\n";
        else
            cout << "No\n";

    return 0;
}

//      *   *  *****  *   *  *   *   ****  ****    ****     **    **
//     *   *  *      **  *  *   *  *      *   *  *        * *   * *
//    *****  *****  * * *  *   *  *      ****   *       *  *     *
//   *   *      *  *  **  *   *  *      *  *   *       *****    *
//  *   *  *****  *   *   ***    ****  *   *    ****     *   *****

//      *****  *****  *   *  *      *****  *   *  *****  *****
//        *   *   *  *   *  *        *    **  *    *    *   *
//       *   *   *  *****  *        *    * * *    *    *****
//   *  *   *   *    *    *        *    *  **    *    *
//  ****   *****    *    *****  *****  *   *    *    *


Measured memory_bytes: 3984
#include <iostream>
#include <vector>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define endl "\n" // TODO: remove
#define int long long

const int N = (int)(1e6) + 322;
const int inf = (int)(2e18);
const int mod = (int)(1e9) + 7; // check modulo

int a[N];

void solve() {
    int n; cin >> n;
    int cur = 1000;
    int stocks = 0;
    for(int i = 1; i <= n; ++i) cin >> a[i];

    for(int i = 1; i <= n; ++i) {
//        cout << stocks << ' ' << cur << endl;
        if (a[i] < a[i + 1]) {
            int b = cur / a[i];
            stocks += b;
            cur -= b * a[i];
        }else {
            cur += a[i] * stocks;
            stocks = 0;
        }
    }
    cout << cur;
}

signed main () {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("travel_restrictions_input.txt", "r", stdin);
//    freopen("A.out", "w", stdout);
//    int test; cin >> test;
//    for(int t = 1; t <= test; ++t) {
//        cout << "Case #" << t << ":" << endl;
        solve();
//    }
    return 0;
}



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

int main(void){
   int A[3];
   for(int i=0;i<3;i++){
       cin>>A[i];
   }
   sort(A,A+3);
   int ans=A[2]-A[1];
   A[0]=A[0]+ans;
   if((A[2]-A[0])%2==0) ans+=(A[2]-A[0])/2;
   else ans+=(A[2]-A[0]+1)/2+1;
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
#abc076 C
from copy import deepcopy
s = list(input())
t = list(input())
ls = len(s)
lt = len(t)

rev_s = s[::-1]
rev_t = t[::-1]

for x in range(ls-lt+1):
    if rev_s[x:x+lt] == ["?"] * lt:
        for y in range(lt):
            rev_s[x+y] = rev_t[y]
        ns = rev_s[::-1]
        S = "".join(ns)
        ans = S.replace("?", "a")
        print(ans)
        exit()


for i in range(lt):
    for j in range(i, ls):
        if rev_t[i] == rev_s[j]:
            flag = True
            t_temp = deepcopy(rev_t)
            s_temp = deepcopy(rev_s)
            for k in range(-i, lt-i):
                if j+k >= ls or j+k < 0:
                    flag = False
                    break
                elif t_temp[i+k] == s_temp[j+k]:
                    pass
                elif s_temp[j+k] == "?":
                    s_temp[j+k] = t_temp[i+k]
                elif t_temp[i+k] != s_temp[j+k]:
                    flag = False
                    break
            if flag:
                ns = s_temp[::-1]
                S = "".join(ns)
                ans = S.replace("?", "a")
                print(ans)
                exit()

print("UNRESTORABLE")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    int k, a, b;
    cin >> k >> a >> b;

    for(int i = a; i <= b; ++i){
        if(i%k == 0){
            cout << "OK\n";
            return 0;
        }
    }

    cout << "NG\n";
}

Measured memory_bytes: 3584
n, m = map(int, input().split())
t = []

g = 0
if n == 1:
    print(len(input().split()) - 1)
    exit()

for i in range(n):
    t.append(input().split())

for i in sorted(t, reverse = True)[0][1:]:
    c = 0
    for j in sorted(t, reverse = True)[1:]:
        
        if j[1:].count(i) == 1:
            c += 1

        if c == n - 1:
            g += 1

print(g)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define eps 1e-8
int n,k,a[200005];
int main()
{  long long int t;
   cin>>t;
   string ans;
   while(t)
   {  long long num=t%26;
      if(num==0)num=25,t--;
      else num--;
      ans.push_back(num+'a');
      t=t/26;
   } 
   for(int i=ans.size()-1;i>=0;i--)cout<<ans[i];

}

Measured memory_bytes: 3620
n = input()[::-1]
cnt = 0
flag = 0
for i in range(len(n)-1):
    if int(n[i])+flag < 5:
        cnt += int(n[i])+flag
        flag = 0
    elif int(n[i])+flag > 5:
        cnt += (10-int(n[i])-flag)
        flag = 1
    else:
        if int(n[i+1]) >= 5:
            cnt += (10 - int(n[i])-flag)
            flag = 1
        else:
            cnt += (int(n[i]) + flag)
            flag = 0
if int(n[-1])+flag > 5:
    cnt += (11 - int(n[-1])-flag)
else:
    cnt += int(n[-1])+flag
print(cnt)


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

int main() {
  int a, b, c, x, y, price = 0;
  scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
  price = min(a*x + b*y, 2*c*max(x, y));
  int z = x < y? b: a;
  price = min(price, 2*c*min(x, y) + z*abs(x - y));
  printf("%d", price);
}

Measured memory_bytes: 3764