akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	if (N < 1200) {
		cout << "ABC\n";
		return 0;
	}
	if (N < 2800) {
		cout << "ARC\n";
		return 0;
	}
	cout << "AGC\n";
	return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()

x = A + B
cnt = 0
bcnt = 0
for s in S:
    if cnt >= x:
        print("No")
        continue
    if s == "a":
        cnt += 1
        print("Yes")
    elif s == "b":
        if bcnt < B:
            cnt += 1
            bcnt += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 210, M_MAX = N_MAX*(N_MAX-1)/2, R_MAX = 8;
const int INF = 1e8;
int V,E,R;
int G[N_MAX][N_MAX];

void warshall_floyd(){
  rep(w,V)rep(v,V)rep(u,V) 
    G[v][u] = min(G[v][u],G[v][w] + G[w][u]);
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> V >> E >> R;
  vector<int> r(R);
  rep(i,R){
    cin >> r[i]; --r[i];
  }

  rep(v,V)rep(u,V) G[v][u] = (v==u) ? 0:INF;

  rep(i,E){
    int f,t,c; cin >> f >> t >> c; --f;--t;
    G[f][t] = G[t][f] = c; 
  }

  warshall_floyd();

  ll res = INF;
  sort(all(r));
  do{
    ll route = 0;
    rep(i,R-1) route += G[r[i]][r[i+1]];
    res = min(res,route);
  }while(next_permutation(all(r)));

  cout << res << endl;
  return 0;
}


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

int main() {
	int n, k, s;
	cin >> n >> k >> s;
	if (s < 100000000) {
		for (int i = 0; i < k; i++)
			cout << s << " ";
		for (int i = k; i < n; i++)
			cout << (s + 1) << " ";
		cout << endl;
	}
	else {
		for (int i = 0; i < k; i++)
			cout << s << " ";
		for (int i = k; i < n; i++)
			cout << 1 << " ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int w,h,x,y,r;
        w = scan.nextInt(); h=scan.nextInt(); x=scan.nextInt(); y=scan.nextInt(); r=scan.nextInt();
          int rxLeft = x-r;
        int rxRight = x+r;
        int ryTop = y+r;
        int ryBot = y-r;
          if ((w >= rxRight) &&(h>=ryTop) && rxLeft >=0 && ryBot >=0) {       
           System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26332
#include <bits/stdc++.h>
using namespace std;
int field[10][10],cnt;
int main(){
	int h,w,k;
	int ans=0;
	cin>>h>>w>>k;
	for (int i=0;i<h;i++)
		for (int j=0;j<w;j++){
			char temp;
			cin>>temp;
			if (temp=='.') field[i][j]=0;
			if (temp=='#') field[i][j]=1;
		}
	for (int i=0;i<1<<h;i++)
		for (int j=0;j<1<<w;j++){
			cnt=0;
			for (int a=0;a<h;a++)
				for (int b=0;b<w;b++){
					cnt+=field[a][b]*(i>>a&1&&j>>b&1);
				}
			if (cnt==k) ans++;
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
long long a,b;
int main(){
    std::cin>>a>>b;
    if(a*b<=0){
        std::cout<<"Zero";
        return 0;
    }
    else if(a>0&&b>0){
        std::cout<<"Positive";
        return 0;
    }
    else {
        if((b-a)%2==0){
            std::cout<<"Negative";
        }
        else std::cout<<"Positive";
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
N = int(input())
arr = sorted([int(i) for i in input().split()])
ok = True
b = {}
for i in range(N):
    if arr[i] not in b:
        b[arr[i]] = 1
    else:
        b[arr[i]] += 1
if N%2 :
    if b[0] != 1:
        ok = False
    for i in range(1,(N-1)//2+1):
        if ok== False:
            break
        if 2*i not in b or b[2*i]!= 2:
            ok = False
else:
    for i in range(1,N//2+1):
        if 2*i-1 not in b or b[2*i-1] != 2:
            ok = False
            break

if ok :
    print(2**(N//2)%(10**9+7))
else:
    print(0)

Measured memory_bytes: 14420
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
const int N=1e6+7;
ll n,m,k,t,ans;

int main(){
    fast;
    string s;
    cin>>s;
    n=sz(s);
    int i=0;
    while(i<n){
        if(s[i]=='S') k++;
        else if(s[i-1]=='S'&&s[i]=='T'){
            while(k>0&&s[i]=='T'){
                ans--;k--;i++;
            }
            continue;
        }
        ans++;
        //cout<<ans<<endl;
        i++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 720
def abc(x):
  if x=="a":
    return 0
  elif x=="b":
    return 1
  else:
    return 2
  
a=[[abc(i) for i in list(input())] for j in range(3)]
n=[0,-1,-1]
t=0
while True:
  t=a[t][n[t]]
  n[t]+=1
  if len(a[t])<=n[t]:
    print(["A","B","C"][t])
    break

  


Measured memory_bytes: 3064
M, D = map(int, input().split())
ans = 0
for m in range(1, M+1):
    for d in range(22, D+1):
        d_10, d_1 = divmod(d, 10)
        if d_10 > 1 and d_1 > 1 and d_10*d_1==m:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FI first
#define SE second
using namespace std;

int x[5],k;
int main(){
	bool bisa =1 ;
	for(int i =0;i<5;i++){
		scanf("%d",&x[i]);
	}
	scanf("%d",&k);
	for(int i =0;i<5;i++){
		for(int j =0;j<i;j++){
			if(abs(x[i]-x[j])>k) bisa =0;
		}
	}
	if(!bisa) printf(":(\n");
	else printf("Yay!\n");
	return 0;
}		

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var e = xArray("[]",n);
  var ans = k;
  for(var i = 0; i < n-1; i++){
    var a = o.a()-1, b = o.a()-1;
    e[a].push(b);
    e[b].push(a);
  }
  var q = [], q2 = [0], d = 1;
  var m = xArray(0,n);
  m[0] = 1;
  while(q2.length){
    q = q2;
    var q2 = [];
    while(q.length){
      var v = q.pop();
      var z = 0;
      if(d > 1)z = 1;
      for(var i = 0; i < e[v].length-z; i++){
        ans *= k-d-i;
        ans %= mod;
      }
      for(var V of e[v]){
        if(m[V])continue;
        q2.push(V);
        m[V] = 1;
      }
    }
    if(d < 2)d++;
  }
  return 0+ans;
}

Measured memory_bytes: 76116
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  long long int S_NUM, C_NUM;
  cin >> S_NUM >> C_NUM;
  
  // Sの数だけsccパターンを作る
  // SがN個あったら、Cは２N個必要
  // C_NUM < 2N のときは (C_NUM / 2)個作れる  
  if(2 * S_NUM > C_NUM) {
    cout << C_NUM / 2 << endl;
  } else {
    cout << S_NUM + (C_NUM - 2 * S_NUM) / 4 << endl;
  }
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, minv = INFLL; cin >> n;
    rep(i, 5){
        ll in; cin >> in;
        chmin(minv, in);
    }
    cout << (ll)ceil(1.0*n/minv)+4 << endl;
}

Measured memory_bytes: 256
//2020-05-27

#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
long long int minCost = LONG_LONG_MAX;

vector<vector<int>> v;
vector<int> minAlg;

int n,m,x;

void gettem(vector<int> algs, long long paid, int bk){

    if (bk == n){
        if (paid < minCost){
            
//            for (int i=0;i<algs.size();i++){
//                cout << algs[i] << " ";
//            }
//            cout << endl;
            
            for (int i=0;i<algs.size();i++){
                if (algs[i] < x){
                    return;
                }
            }
            minCost = paid;
            return;
        }
        return;
    }
    
    gettem(algs, paid, bk+1);
    
    if (true){//paid + v[bk][0] <= x){
        
        vector<int>  nAlgs = algs;
        for (int i=0;i<algs.size();i++){
            nAlgs[i] += v[bk][i+1];
        }
        gettem(nAlgs, paid + v[bk][0],bk+1);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n >> m >> x;
    
    v.resize(n);
    for (int i=0;i<n;i++){
        v[i].resize(m+1);

        //cout << i << ":" << v[i].size() << endl;
        
        cin >> v[i][0];
        
        for (int j=1;j<m+1;j++){
            cin >> v[i][j];
        }
    }
    
    vector<int> zAlgs(m);
    gettem(zAlgs,0,0);
    
    if (minCost == LONG_LONG_MAX){
        cout << "-1";
        return 0;
    }
    cout << minCost;
    return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,k,q;
int a[100010],d[100010]={0};


void solve(){
    cin >> n >> k >> q;
    rep(i,q){
        cin >> a[q];
        d[a[q]-1]+=1;
    }
    rep(i,n){
        if (k-q+d[i]>0) cout << "Yes" << endl;
        else cout << "No" << endl; 
    }
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int X;

int main(){
  cin >> X;
  int ans = 1;
  rep(b,2,X){
    int now = b * b;
    if(now > X) continue;
    while(now * b <= X) now *= b;
    ans = max(ans,now);
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef int64_t in;
using namespace std;
#define INF 1000000007


int main() {
    int n,k;
    cin >> n >> k;
    if(k==1){
        cout << "0" << endl;
    }else{
        cout << n - k << endl;
    }
}

Measured memory_bytes: 256
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){
    return ((n + d -1) / d);
}
/*
inline double Sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
*/
// }}}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> t(n);
    rep(i,n){
        cin >> t[i];
    }
    int m;
    cin >> m;
    rep(i,m){
        int p,x;
        int sum = 0;
        cin >> p >> x;
        rep(j,n){
            int T = t[j];
            if(j + 1 == p) T = x;
            sum += T;
        }
        cout << sum << '\n';
    }
    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll pow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	string s;
	cin >> s;
	int n = SZ(s);
	int dp[MAX][13];
	FILL(dp, 0);
	dp[0][0] = 1;
	REP(i, n){
		REP(j, 13){
			if (s[i] == '?'){
				REP(k, 10){
					dp[i + 1][(10 * j + k) % 13] = (dp[i + 1][(10 * j + k) % 13] % MOD + dp[i][j] % MOD) % MOD;
				}
			}
			else{
				dp[i + 1][(10 * j + ((int)s[i] - '0')) % 13] = (dp[i + 1][(10 * j + ((int)s[i] - '0')) % 13] % MOD + dp[i][j] % MOD) % MOD;
			}
		}
	}
	cout << dp[n][5] << endl;
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

Measured memory_bytes: 5584
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){

	int n;

	while(cin>>n){
	    if(n==0)break;
        int a=0;
        for(;;){
            if(n>=5)a+=n/5,n/=5;
            else break;
        }
        cout<<a<<endl;

	}


	return 0;
}

Measured memory_bytes: 1160
import sys
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
H = []
H += [H.append(XYH[i][2]) for i in range(n)]
f = H.count(0) == n-1

for i in range(102):# Cx
  for j in range(102): #Cy
    height = -100
    flg = True
    for k in range(n):
      x,y,h= XYH[k][0], XYH[k][1], XYH[k][2]
      if h <= 0:
        continue
      elif f:
        print(x,y,h)
        sys.exit()
      if height != -100:
        th = 0 if h <= 0 else max(0, h + abs(x-i) + abs(y-j))
        if height == th:
          continue
        else:
          flg = False
          break
      else:
        height = 0 if h <= 0 else max(0, h + abs(x-i) + abs(y-j))
        #height = max(0, h + abs(x-i) + abs(y-j))
        continue
    if flg and height > 0:
      print(i, j, height)
      sys.exit()


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;


int main(){
  ll ans = 0;
  ll pow10 = 1e13;
  ll many9 = pow10-1;
  ll p10=1;
  repeat(i,10){
    ll low=i==0?0:-1,high=10;
    while(high-low>1){
      ll mid = (high+low)/2;
      ll a = ans*10+mid;
      cout << "? "<< a*pow10+many9 << endl;
      char in;
      cin >> in;
      if(in == 'Y'){
        high = mid;
      }else{
        low = mid;
      }
    }
    if(high==0){
      cout << "? "<<ans+1 << endl;
      char in;
      cin >> in;
      if((in == 'Y')^(ans+1==p10)){
        break;
      }
    }
    ans = ans*10+high;
    pow10 /=10;
    many9 /=10;
    p10 *= 10;
  }
  cout << "! " << ans << endl;
  return 0;
}


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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

int a[1001][1001]={0};
int dp[1001][1001]={0};

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
        
	int r,c;
	cin>>r>>c;
	dp[0][1]=1;
	for(int i=1;i<=r;i++){
		for(int j=1;j<=c;j++){
			char temp;
			cin>>temp;
			if(temp=='#'){
				a[i][j]=1;
			}
			dp[i][j]=0;
		}
	}
	for(int i=1;i<=r;i++){
		for(int j=1;j<=c;j++){
			if(a[i][j]==0)
			   dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
		}
	}
	cout<<dp[r][c]<<endl;


	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
LL mass[10000000];
int main(){
    CIN(N);
    V<LL> vec;
    REP(a,N){
        LL b;cin >> b;
        vec.pb(b);
    }
    for(LL a = 1;a < N+1;a++){
        mass[a]=mass[a-1]+vec.at(a-1);
    }
    map<LL,LL> mp;
    for(LL a = 0;a < N+1;a++){
        if(mp.find(mass[a])==mp.end()){
            mp[mass[a]]=1;
        }else{
            mp[mass[a]]++;
        }
 //       cout<<" "<<mass[a];
    }
   // cout<<endl;
    LL ans = 0;
    for(auto p:mp){
        if(p.second==1)continue;
        if(p.second==2){
            ans++;
            continue;
        }
        LL W = p.second;

        ans+= (W*(W-1))/2;
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 15856
#include <bits/stdc++.h>
using namespace std;
const int INF=100000000;
int main()
{
  int n;cin>>n;
  vector<int>p(n),q(n);
  for(int i=0;i<n;i++)cin>>p[i];
  for(int i=0;i<n;i++)cin>>q[i];
  vector<int>a(n);
  for(int i=0;i<n;i++)a[i]=i+1;
  map<vector<int>,int>mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  int ans=abs(mp[p]-mp[q]);

  cout<<ans<<endl;
}

Measured memory_bytes: 5376
n=input()
S=[raw_input() for i in xrange(n)]
Sset=map(set, S)
U=set.intersection(*Sset)

r=""
for u in U:
    c=[s.count(u) for s in S]
#    print c,u
    r+=u*(min(c))

print "".join(sorted(list(r)))


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

int WhichColor(int rate)
{
	if (rate >= 1 && rate <= 399)
		return 1;
	if (rate >= 400 && rate <= 799)
		return 2;
	if (rate >= 800 && rate <= 1199)
		return 3;
	if (rate >= 1200 && rate <= 1599)
		return 4;
	if (rate >= 1600 && rate <= 1999)
		return 5;
	if (rate >= 2000 && rate <= 2399)
		return 6;
	if (rate >= 2400 && rate <= 2799)
		return 7;
	if (rate >= 2800 && rate <= 3199)
		return 8;
	else
		return 0;
}

int main()
{
	set<int> s;
	int N;
	while (cin >> N)
	{
		s.clear();
		int a, k = 0;
		for (int i = 1; i <= N; i++)
		{
			cin >> a;
			int color = WhichColor(a);
			if (color == 0)
				k++;
			s.insert(color);
		}
		int min = s.size();
		int max = min;
		if (k > 0)
		{
			if (min > 1)
				min -= 1;
			max += k - 1;
		}
		cout << min << " " << max << endl;
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int a[100010],dp[100010],n,k;
void solve(){
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    fill(dp,dp+100005,1000000001);
    dp[1]=0;
    for(int i=1;i<=n;i++)
      	for(int j=1;j<=k;j++)
            dp[i+j]=min(abs(a[i+j]-a[i])+dp[i],dp[i+j]);
    cout<<dp[n];
}
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen("FORM MAU.inp","r",stdin);
    //freopen("FORM MAU.out","w",stdout);

    //srand(time(0));

    //int t;cin>>t;while(t--)
    //cout << setprecision(2) <<fixed;
    solve();
}


Measured memory_bytes: 1024
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

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

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }

//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    cins(s);
    vector<int> Lidx;   // from left, next L after some R
    vector<int> Ridx;  // from left, next R after some L
    int ri=s.size()-1;
    for(int i=1; i<s.size(); i++, ri--) {
        if(s[i]!=s[i-1]) {
            if(s[i]=='L')
                Lidx.push_back(i);
        }
        if(s[ri]!=s[ri-1]) {
            if(s[ri-1]=='R')
                Ridx.push_back(ri-1);
        }
    }

    vi ans(s.size());

    for(int i=0; i<s.size(); i++) {
        if(s[i]=='L') { // find next R
            auto it=upper_bound(Ridx.begin(), Ridx.end(), i, greater<int>());
            int j=*it;
            int cnteven=(i-j)&1;
            assert(s[j]=='R');
            if(!cnteven) {
                ans[j]++;
            } else {
                ans[j+1]++;
            }
        } else {
            auto it=upper_bound(Lidx.begin(), Lidx.end(), i);
            int j=*it;
            int cnteven=(j-i)&1;
            assert(s[j]=='L');
            if(!cnteven) {
                ans[j]++;
            } else {
                ans[j-1]++;
            }
        }
    }
    for(int i=0; i<ans.size(); i++)
        cout<<ans[i]<<" ";
    cout<<endl;

}



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

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

int main() {
	string div[4]={"dream","dreamer","erase","eraser"};
	string s;
	cin>>s;
	
	reverse(s.begin(),s.end());
	rep(i,4) reverse(div[i].begin(),div[i].end());
	bool can=true;
	for(int i=0;i<s.size();){
		bool k=false;
		for(int j=0;j<4;++j){
			string d=div[j];
			if(d==s.substr(i,d.size())){
				k=true;
				i+=d.size();
			}
		}
		if(!k){
			can=false;
			break;
		}
	}
	if(can) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int main() {
    ios::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];

    }
    sort(all(v));

    int res = INF;
    for(int i = K - 1; i < N; ++i) {
        res = min(res, v[i] - v[i - K + 1]);

    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Data.Array.IO


main = do
  [n,p] <- map read . words <$> getLine :: IO [Int]
  as <- map ((`mod` 2) . read) . words <$> getLine :: IO [Int]

  dp <- newArray ((0,0),(n,2)) 0 :: IO (IOArray (Int,Int) Integer)

  writeArray dp (0,0) 1
  forM_ (zip [1..n] as) $ \(i,a) -> do
    if even a then do
      writeArray dp (i,0) =<< (*2) <$> readArray dp (i-1,0)
      writeArray dp (i,1) =<< (*2) <$> readArray dp (i-1,1)
      else do
      writeArray dp (i,0) =<< (+) <$> readArray dp (i-1,0) <*> readArray dp (i-1,1)
      writeArray dp (i,1) =<< (+) <$> readArray dp (i-1,0) <*> readArray dp (i-1,1)

  print =<< readArray dp (n,p)


Measured memory_bytes: 764
import sys
def input(): return sys.stdin.readline().strip()
N,M,K = map(int,input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

def print_l(l):
    print(' '.join(map(str, l)))

uni = UnionFind(N)
friends = []

for _ in range(M):
    a,b = l_in()
    uni.union(a-1, b-1)
    friends.append((a-1, b-1))

blocks = []

for _ in range(K):
    c,d = l_in()
    blocks.append((c-1, d-1))

res = [uni.size(i)-1 for i in range(N)]

for a,b in friends:
    res[a] -= 1
    res[b] -= 1

for c,d in blocks:
    if uni.same(c, d):
        res[c] -= 1
        res[d] -= 1

print_l(res)


Measured memory_bytes: 44900
#include <iostream>
#include <string>

using namespace std;

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

  string A, B;
  cin >> A >> B;
  if(A.length() == B.length()){
	for(int i=0; i<A.length(); i++){
	  if(A.at(i) == B.at(i)){
		continue;
	  }
	  if(A.at(i) < B.at(i)){
		cout << "LESS" << endl;
	  }else{
		cout << "GREATER" << endl;
	  }
	  return 0;
	}
	cout << "EQUAL" << endl;
  }else if(A.length() < B.length()){
	cout << "LESS" << endl;
  }else if(A.length() > B.length()){
	cout << "GREATER" << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
//  RAKSHIT KADAM
 #include <bits/stdc++.h>
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
 #warning !!!check the size of arrayss!!!
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define newMOD  998244353
 #define MAX 300006
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define INF 2000000000000000005

 #define vi vector<ll>
#define pi 3.1415926535897932384626433832795
#define Endl endl
#define lb lower_bound
#define ub upper_bound
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
 //ddfdsfdfs

//ll modInverse(int a, int m){ return power(a, m-2, m);} // if a and m are relativelyprime
vector < pair<ll ,pair<ll,ll> > >v[55];
ll c[55],d[55];
multiset<pair<ll ,pair<ll,ll> > >ms;
ll dp[53][2506];
void solve()
{
    ll n,m,s;cin>>n>>m>>s;
    s=min(s,2500LL);
    for(ll i=1;i<=m;i++)
    {
    ll u,w,x,y;
        cin>>u>>w>>x>>y;
        v[u].pb(mp(w,mp(x,y)));
        v[w].pb(mp(u,mp(x,y)));
    }
    for(ll i=1;i<=n;i++)cin>>c[i]>>d[i];
    memset(dp,-1,sizeof dp);
    pair<ll ,pair<ll ,ll> >p;
    // PUSHING STYLE - TIME,NODE ,SILVER
    ms.insert(mp(0,mp(1,s)));
    while(!ms.empty())
    {
        p= (*ms.begin());
        ms.erase(p);
        ll time=p.x;
        ll node = p.y.x;
        ll silver = p.y.y;
        if(dp[node][silver]!=-1)continue;
        dp[node][silver]=time;
        
        if(silver+c[node]<=2500){ms.insert(mp(time+d[node],mp(node,silver+c[node])));}
        for(auto it:v[node])
        {
            if(silver>=it.y.x && dp[it.x][silver-it.y.x]==-1)
            {
                ms.insert(mp(time+it.y.y,mp(it.x,silver-it.y.x)));
            }
        }
    }
    for(ll i=2;i<=n;i++)
    {
        ll ans=INF;
        for(ll j=0;j<=2500;j++)
        {
            if(dp[i][j]!=-1)
            {
                ans=min(ans,dp[i][j]);
            }
        }cout<<ans<<endl;
      
    }
}
signed main()
{
 
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

  //  time;
 solve();
    return 0;
}


Measured memory_bytes: 15052
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    ll ans = 0;
    int mx = 0;
    for (auto i : A) {
        mx = max(mx,i);
        ans += mx - i;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    int n;cin>>n;
    vector<int> A(n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    int res=0;
    for(int i=0;i<n;++i)
    {
        //sameを抜ける
        while(i+1<n && A[i]==A[i+1])++i;

        //単調非減少
        if(i+1<n && A[i]<A[i+1])
        {
            while(i+1<n && A[i]<=A[i+1])++i;
        }
        //単調非増加
        else if(i+1<n && A[i]>A[i+1])
        {
            while(i+1<n && A[i]>=A[i+1]) ++i;
        }
        ++res;
    }

    cout<<res<<"\n";

}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int N;
        static long H;
        static List<Tuple<long, string>> c = new List<Tuple<long, string>>(2 * N);


        public static void Input()
        {
            var cin = new Solve();

            var input = cin.SplitReader();
            N = input[0];
            H = input[1];

            for(var i = 0; i < N; i++)
            {
                var ab = cin.SplitReaderL();
                c.Add(new Tuple<long, string>(ab[0], "a"));
                c.Add(new Tuple<long, string>(ab[1], "b"));
            }
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            c.Sort();
            c.Reverse();
            List<long> ans = new List<long>();
            long th = 0;
            for (var i = 0; i < 2 * N; i++) 
            {
                if (c[i].Item2 == "b")
                {
                    th++;
                    H -= c[i].Item1;
                    if (H <= 0) {
                        ans.Add(th);
                        break; }
                }
                else
                {
                    ans.Add(th + ((H + c[i].Item1 - 1) / c[i].Item1));
                }
                //Console.WriteLine($"{H} {th}");
            }

            Console.WriteLine(ans.Min());
            //Console.Out.Flush();
        }

        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    
}



Measured memory_bytes: 34452
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	string s;
	cin >> s;
	
	bool flag = false;
	REP(i, SZ(s)) {
		REP(j, SZ(s)) {
			string t = s;
			if (t.erase(i, j - i) == "keyence")flag = true;
			//cout << t.erase(i, j-i) << endl;
		}
	}
	puts(flag ? "YES" : "NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
inline ll read() {
	ll kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
inline void write(ll xx){
	if(xx < 0){putchar('-');xx=-xx;}
	if(xx > 9)write(xx/10);
	putchar(xx%10+'0');
	return;
}
ll n,a[3];
char s[100005][5];
vector<char> res;
int flag;
int cnt;
int main(){
	n = read();
	a[0] = read();
	a[1] = read();
	a[2] = read();
	for(int i = 1;i <= n;i++){
		scanf("%s",s[i]);
	}
	for(int i = 1;i <= n;i++){
		if(a[s[i][0] - 'A'] < a[s[i][1] - 'A']){
			a[s[i][0] - 'A']++;
			a[s[i][1] - 'A']--;
			res.push_back(s[i][0]);
		}else if(a[s[i][0] - 'A'] > a[s[i][1] - 'A']){
			a[s[i][0] - 'A']--;
			a[s[i][1] - 'A']++;
			res.push_back(s[i][1]);
		}else{
			if(s[i + 1][0] == s[i][0] || s[i + 1][1] == s[i][0]){
				a[s[i][0] - 'A']++;
				a[s[i][1] - 'A']--;
				res.push_back(s[i][0]);
			}else{
				a[s[i][0] - 'A']--;
				a[s[i][1] - 'A']++;
				res.push_back(s[i][1]);
			}
		}
		if(a[0] < 0 || a[1] < 0 || a[2] < 0){
			flag = 1;
			break;
		}
	}
	if(!flag){
		printf("Yes\n");
		for(int i = 0;i < res.size();i++){
			printf("%c\n",res[i]);
		}
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 3884
#include <iostream>
 
using namespace std;
 
int main(void) {
  int N, temp;
  int max = 0;
  int sum = 0;
  
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> temp;
    sum += temp;
    if(max < temp) {
      max = temp;
    }
  }
  
  sum -= max;
  if(sum > max)
    cout << "Yes";
  else
    cout << "No";

  return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
   
int n[26] = {0};
char m[1300];
int i, z;
   
while(1){
   
if(scanf("%s",&m) == EOF)
break;
   
i = 0;
while(1){
if(m[i] == '\0')
break;
   
if('a' <= m[i] && m[i] <= 'z')
n[ m[i] - 'a']++;
   
if('A' <= m[i] && m[i] <= 'Z')
n[ m[i] - 'A']++;
   
i++;
}
}
   
for(i = 0; i < 26; i++){
z = i + 'a';
printf("%c : %d\n", z, n[i]);
}
   
return 0;
}

Measured memory_bytes: 544
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n,m;
  while(cin>>m>>n,n||m){
    vector<vector<int> >in(n,vector<int>(m));
    vector<vector<int> >dp(n+1,vector<int>(m));
    rep(i,n)rep(j,m)cin>>in[i][j];
    rep(i,m)if(in[0][i]==0)dp[0][i]=1;
    loop(i,1,n+1){
      rep(j,m){
	if(i<n&&in[i][j]==1)continue;
	else if(i!=n){
	  if(j!=0&&in[i-1][j-1]==0&&in[i][j]!=2)dp[i][j]+=dp[i-1][j-1];
	  if(in[i-1][j]==0)dp[i][j]+=dp[i-1][j];
	  if(j!=m&&in[i-1][j+1]==0&&in[i][j]!=2)dp[i][j]+=dp[i-1][j+1];
	  if(i!=1&&in[i-2][j]==2)dp[i][j]+=dp[i-2][j];
	}else if(i-2>=0&&in[i-2][j]==2)dp[i][j]+=dp[i-2][j];
      }      
    }
    int sum=0;
    //rep(i,n+1){rep(j,m)printf(" %2d",dp[i][j]);puts("");}
    loop(i,n-1,n+1)rep(j,m)sum+=dp[i][j];
    cout<<sum<<endl;
  }
}

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

int f(int n){
	if(n%2 == 0) return n/2;
	else return 3*n+1;
}

int main(){
	int s; cin >> s;
	vector<int> v(1000000);
	int a = s, m = 1;

	v[a] = 1;
	while(1){
		int tmp = a;
		m++;
		a = f(a);
		if(v[a] == 1) break;
		v[a] = 1;
	}

	cout << m << endl;

	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int A, B;
    cin >> A >> B;
    
    p(A*B);
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3644
using System;
class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d;
            
            string[] str1 = Console.ReadLine().Split(' ');
            a = int.Parse(str1[0]);
            b = int.Parse(str1[1]);

            string[] str2 = Console.ReadLine().Split(' ');
            c = int.Parse(str2[0]);
            d = int.Parse(str2[1]);

            Console.WriteLine((a-c) * (b-d));           
        }  
    }

Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>
#define M 10000

int C[M + 1];
int n;

void CountingSort(unsigned short *A, unsigned short *B, int k){
  int i,j,max = 0;

  for(i = 0; i <= n; i++){
    if(A[i] > max) max = A[i];
  }
  k = max;
  for(i = 0; i <= k; i++){
    C[i] = 0;
  }
  
  for(j = 1; j <= n; j++){
    C[A[j]]++;
  }

  for(i = 1; i <= k; i++){
    C[i] = C[i] + C[i - 1];
  }

  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

}



int main(){
  int i;
  unsigned short *A, *B;
  
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n + 1);
  B = malloc(sizeof(short)*n + 1);

  for(i = 1; i <= n; i++){
    scanf("%hd",&A[i]);
  }

  CountingSort(A,B,n);
  for(i = 1; i <= n; i++){
    if(i == n) printf("%d\n",B[i]);
    else printf("%d ",B[i]);
  }
  return 0;
}



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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7'|| s[2] == '7')
        cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e18;
int main()
{
    int a,b,c;
    long long k;
    scanf("%d%d%d%lld",&a,&b,&c,&k);
    long long ans;
    if(k&1)
    {
        ans=abs(b-a);
        if(ans>maxn)
            printf("Unfair\n");
        else
            printf("%lld\n",(long long)b-a);
    }
    else
    {
        ans=abs(b-a);
        if(ans>maxn)
            printf("Unfair\n");
        else
            printf("%lld\n",(long long)a-b);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    for (int i = 1;; i++) {
        if (s == 4 || s == 2 || s == 1) {
            cout << i + 3 << endl;
            break;
        }
        s = s % 2 == 0 ? s / 2 : s * 3 + 1;
    }

    return 0;
}

Measured memory_bytes: 256