akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, t, s1=0, s2=0, x, y, i;
  
  cin >> n;
  int w[n+1];
  for(i=1;i<=n;i++) {
    cin >> w[i];
    s2 += w[i];
  }
  s1 += w[1];
  s2 -= w[1];
    
  for(i=2;s2>=s1;i++) {
    s1 += w[i];
    s2 -= w[i];
  }
  x = s1 - s2;
  y = (s2 - s1) + w[i-1] * 2;
  if (x > y)
    cout <<  y << endl;
  else
    cout << x << endl;
  
  return 0;
}


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

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()

typedef long long tint;

int main(){
	int n, k; cin >> n >> k;
	vector<int> a (n);
	forn(i, n){
		cin >> a[i];
	}
	vector<int> dp (n, 1000000000);
	dp[1] = abs(a[1]-a[0]);
	dp[0] = 0;
	forsn(i, 2, n){
		forsn(j, 1, k+1){
			if(i-j < 0) continue;
			dp[i] = min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout << dp.back() << endl;
}


Measured memory_bytes: 1024
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    String s1 = sc.next();
    int n = s.length();
    
    if (s1.substring(0,n ).equals(s)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35744
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}


ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}*/

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    char c;
    cin >> c;
    cout << ('a' <= c && c <= 'z' ? 'a' : 'A') << endl;

    return 0;
}

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

using namespace std;

const int N = 1e6 + 5;
int n, a[N], cnt[N], dd[N], ans;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; ++i) {
        if(!dd[a[i]] && cnt[a[i]] == 1) ans++;
        for(int j = a[i]; j <= a[n]; j += a[i]) dd[j] = 1;
    }
    cout << ans << '\n';
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;
  vll chk(n, true);

  rep(i, k) {
    ll d;
    cin >> d;
    rep(j, d) { ll a;
      cin >> a;
      a--;
      chk[a] = false;
    }
  }

  ll ans = 0;
  rep(i, n) if (chk[i]) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#define P pair<int,int>
using namespace std;
bool cmp(const P& p, const P& q){
	if(p.first!=q.first) return p.first>q.first;
	return p.second<q.second;
}
int main() {
	int n ; cin >> n ;
	P a[20]; for(int i=0;i<n;i++) cin >> a[i].second >> a[i].first ;
	sort(a,a+n,cmp);
	cout << a[0].second << ' ' << a[0].first << '\n';
}

Measured memory_bytes: 1164
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define memset(v, h) memset((v), h, sizeof(v))
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll m[20][20];

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct node
{
    public: ll x;
    public: ll y;

    node(ll xx, ll yy)
    {
        x = xx;
        y = yy;
    }
};

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

    vector<ll> h;

    rep(i, a){
        ll p;
        cin >> p;
        h.push_back(p);
    }

    if(a <= b)
    {
        cout << 0 << endl;
        return 0;
    }

    std::sort(h.begin(), h.end());

    ll k = 0;

    rep(i, a - b)k += h[i];

    cout << k << endl;
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	while(n!=0) {
		if(n%10==9) {
			cout<<"Yes";
			break;
		} else
			n/=10;
	}
	if(n==0)
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int x,a,i=1;
    for(a=0;a<10000;i++,a++){
        scanf("%d",&x);
        if(x==0){
            break;
        }
        else{
            printf("Case %d: %d\n",i,x);
        }
    }
    return 0;
}

Measured memory_bytes: 596
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			StringBuilder sb = new StringBuilder();
			String input = input();

			if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			}

			int n = Integer.parseInt(input());

			for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			}

			list.add(sb.toString());

		}

		for (int j = 0; j < list.size(); j++) {

			System.out.println(list.get(j));

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26244
#include<iostream>
using namespace std;
int main(){
	
	int a,b,c,d,p,x=0,y=0;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>p;

	x=p*a;
	if(p<=c){
		y=b;
	}
	else if(p>=c){
		y=b+d*(p-c);
	}
	if(x>y){swap(x,y);}
	cout<<x<<endl;

return 0;
}


Measured memory_bytes: 3108
import sys, os
import collections

def solve(input_stream):
  n, q = [int(char) for char in input_stream.readline().strip().split()]
  target = input_stream.readline().strip()
  ans = []

  dp = [0 for i in range(len(target) + 1)]
  is_a = False
  for index, char in enumerate(target):
    dp[index + 1] = dp[index]
    if is_a:
      if char == "C":
        dp[index + 1] += 1
      is_a = False
    if char == "A":
      is_a = True
  for index in range(q):
    l, r = [int(char) for char in input_stream.readline().strip().split()]
    ans.append(str( dp[r] - dp[l] ))
  return ans  

if __name__ == "__main__":
    outputs = solve(sys.stdin)
    for line in outputs:
      print(line)

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

long long dp[90];

int main()
{
    dp[0] = 2;
    dp[1] = 1;
    int N;
    cin >> N;
    for(int i = 2;i <= N;i++)
    {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    cout << dp[N];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    int n,k;
    cin >> n >> k;
    vector<pair<ll,ll> > v;
    for(int i = 0; i < n; i++){
        ll x,y;
        cin >> x >> y;
        v.push_back(make_pair(x,y));
    }
    ll ans = 4e18;
    for(int xi = 0; xi < n; xi++){
        for(int xj = xi + 1; xj < n; xj++){
            for(int yi = 0; yi < n; yi++){
                for(int yj = yi + 1; yj < n; yj++){
                    ll minx,maxx,miny,maxy;
                    vector<ll> xlist;
                    vector<ll> ylist;

                    if(v[xi].first < v[xj].first){
                        minx = v[xi].first;
                        maxx = v[xj].first;
                    }else{
                        minx = v[xj].first;
                        maxx = v[xi].first;
                    }
                    if(v[yi].second < v[yj].second){
                        miny = v[yi].second;
                        maxy = v[yj].second;
                    }else{
                        miny = v[yj].second;
                        maxy = v[yi].second;                        
                    }
                    ll tmp = (maxx - minx) * (maxy - miny);
                    int cnt = 0;
                    bool ok = false;
                    for(int k = 0; k < n; k++){
                        if(minx <= v[k].first && v[k].first <= maxx && miny <= v[k].second && v[k].second <= maxy) cnt++;
                    }
                    if(k <= cnt) ok = true;
                    if(ok){
                        if(ans > tmp) ans = tmp;
                    }
                }
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String args[]) throws IOException {
		InputStreamReader re = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(re);
		
		int counter = 0;
		while (true) {
			int num = Integer.parseInt(br.readLine());
			
			if (num == 0) {
				break;
			}
			
			counter++;
			System.out.println("Case " + counter + ": " + num);
		}
	}
}

Measured memory_bytes: 31840
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector <int> d(N);
  for( int i=0;i<N;i++ )
    cin >> d[i];

  sort(d.begin(), d.end());

  int ans = 0;
  int prv = -1;
  for( int i=0;i<N;i++ )
    {
      if( d[i]>prv )
	ans++;
      prv = d[i];
    }
  cout << ans << endl;
}


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

void main() {
    auto S = readln.chomp;
    auto N = S.length.to!int;
    int ans = 0;

    for (int p = 0, q = N-1; p < q; ) {
        if (S[p] == S[q]) {
            p += 1;
            q -= 1;
        } else if (S[p] == 'x') {
            ans += 1;
            p += 1;
        } else if (S[q] == 'x') {
            ans += 1;
            q -= 1;
        } else {
            writeln(-1);
            return;
        }
    }

    ans.writeln;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;

int main()
{
    int  h,n;
    cin >>h>>n;
    vector<pair<int,int>>data(n+1);
    for(int i=0;i<n;i++){
        cin >>data[i].first>>data[i].second;
        //hp,b
    }
    vector<vector<int>>dp(n+1,vector<int>(h+3,INF));
    
    dp[0][0]=0LL;
    //n,hp-->b
    //n,hp=>hp+のときの最小地
    //i->INF(0,0==0)
    for(int N=1;N<=n;N++){
        for(int hp=0;hp<=h;hp++){
            chmin(dp[N][hp],dp[N-1][hp]);
            
                chmin(dp[N][hp], dp[N - 1][max(hp - data[N - 1].first,0)]+data[N-1].second);
                if (hp >= data[N - 1].first)
                {
                    chmin(dp[N][hp], dp[N][hp - data[N - 1].first] + data[N - 1].second);
            }
          //  cout<<dp[N][hp]<<" ";
        }
      //  cout<<endl;
    }

    cout << dp[n][h];
    
}


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

def ans() :

    # 整数の入力
    n = int(input())

    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]
    c = [int(x) for x in input().split()]

    ans = b[a[0] - 1]

    before = a[0] - 1
    for i in range(1, n):
        if a[i] - 1 == before + 1:
            ans += c[before]
        ans += b[a[i] - 1]
        before = a[i] - 1

    print(ans)


if __name__ == '__main__':
    ans()

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#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 ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int a[26];

int main(){
    string s;cin >> s;
    REP(i,s.size()){
        int num = s[i]-'a';
        a[num]++;
    }
    if(s.size()!=26){
        cout << s;
        REP(i,26){
            if(a[i]==0){
                COUT((char)('a'+i));
                break;
            }
        }
    }
    else{
        if(s=="zyxwvutsrqponmlkjihgfedcba")COUT(-1);
        else{
            string past = s;
            do{
                if(s>past){
                    for(int i=0;i<26;i++){
                        if(s[i]==past[i])cout << s[i];
                        else{
                            COUT(s[i]);
                            return 0;
                        }
                    }
                }
            }while(next_permutation(s.begin(),s.end()));
        }
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;

class bilist{
	long a[2000001];
	long L, R;
public:
	bilist(){ L = 0, R = -1; }
	inline long size(){
		return R - L + 1;
	}
	inline void insert(long x){
		a[++R] = x;
	}
	void deleteFirst(){
		while (L<R && a[R] == -1) --R;
		a[R--] = -1;
		while (L<R && a[R] == -1) --R;
	}
	void deleteLast(){
		while (L<R && a[L] == -1) ++L;
		a[L++] = -1;
		while (L<R && a[L] == -1) ++L;
	}
	void del(long x){
		long ite = R;
		for (; ite >= L; --ite){
			if (a[ite] == x){
				a[ite] = -1; return;
			}
		}
		if (ite < L) return;
	}
	void print(){
		bool Top = true;
		for (long i = R; i >= L; --i){
			if (a[i] == -1) continue;
			if (!Top) printf(" ");
			Top = false;
			printf("%ld",a[i]);
		}
		printf("\n");
	}
};

bilist blist;
int main(){
	long n; scanf("%ld", &n);
	while (n--){
		char tmp[20]; scanf("%s", &tmp);
		string a; a = tmp;
		if (a == "insert" || a == "delete"){
			long b; scanf("%ld", &b);
			if (a == "insert"){
				blist.insert(b);
			}
			else{
				blist.del(b);
			}
		}
		else if (a == "deleteFirst"){
			blist.deleteFirst();
		}
		else if (a == "deleteLast"){
			blist.deleteLast();
		}
		//blist.print();
	}
	blist.print();
}

Measured memory_bytes: 9424
using System;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');

        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);

        int tap = 1;
        int count = 0;

        while (true)
        {
            if (tap >= b)
                break;
            else
            {
                tap -= 1;
                tap += a;
                count++;
            }
        }

        Console.WriteLine(count);
;    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,M;
  cin >> N >> M;
  map<int,int> mp;
  rep(i,N) {
    int x;
    cin >> x;
    mp[x]++;
  }
  vi s(M,0),m(M,0);
  for(auto k:mp) {
    s[k.first%M]+=k.second&1;
    m[k.first%M]+=k.second/2;
  }
  int ans = s[0]/2+m[0];
  for(int a=1;a<M-a;a++) {
    int b = M-a;
    int as = s[a]+m[a]*2;
    int bs = s[b]+m[b]*2;
    int acc = min(as,bs);
    if(bs>as) {
      acc += min((bs-as)/2,m[b]);
    } else {
      acc += min((as-bs)/2,m[a]);
    }
    ans += acc;
  }
  if(M%2==0) {
    ans += s[M/2]/2+m[M/2];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
package main

import (
	"fmt"
)

func main() {
	var a int
	var b int
	var c int
	var x int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&x)

	res := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500 * i + 100 * j + 50 * k == x {
					res++;
				}
			}
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 512
S = list(input())
n = len(S)-1
ans = ''

for i in range(2 ** n):
    ope = [''] * n
    for j in range(n):
        if ((i >> j) & 1):
            ope[j] = '+'

    for x, y in zip(S, ope):
        ans += x+y
    ans += S[n] + '+'

print(eval(ans[:len(ans)-1]))

Measured memory_bytes: 4140
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	vector<int> tak,aok;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		tak.pb(x);
		aok.pb(y);
	}
	reverse( tak.begin(), tak.end() );
	reverse( aok.begin(), aok.end() );
	int ng = 0, ok = 1000000000000000009LL;
	while( ok - ng > 1 ){
		int mid = ( ng + ok ) / 2 ;
		int tmx = mid/(tak[0]+aok[0]) * tak[0];
		int amx = mid/(tak[0]+aok[0]) * aok[0];
		for(int i=1;i<n;i++){
			int bas = min( tmx/tak[i], amx/aok[i] );
			tmx = bas * tak[i];
			amx = bas * aok[i];
		}
		if( tmx > 0 && amx > 0 ){
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	cout<<ok<<endl;
	return 0;
}

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

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	vector<bool> isOK(N);
	int allcnt = 0, bcnt= 0;
	rep(i,N) {
		if(S[i] == 'a'){
			if(allcnt < A + B){
				cout << "Yes" << endl;
				allcnt++;
			}
			else cout << "No" << endl;
		}
		else if(S[i] == 'b') {
			if(allcnt < A+ B && bcnt < B) {
				cout << "Yes" << endl;
				allcnt++;
				bcnt++;
			}
			else cout << "No" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;



}










Measured memory_bytes: 3776
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
#define setzero(x) memset(x,0,sizeof(x))
  
using namespace std;
 
const int inf = 2e9+500;
const int N = 1e3+10;
const int bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9;
const ll p = 29;


int main(){

    FASTIO;
    PRECISION; 
    
    int n;
    cin>>n;

    vector<int>arr(n+1);

    for(int i=2;i<=n;i++){
        int temp;
        cin>>temp;
        arr[temp]++;
    }

    for(int i=1;i<=n;i++){
        cout<<arr[i]<<"\n";
    }
    

}

Measured memory_bytes: 3992
k['~~'];i,z;double s=1;c(int*a,int*b){z=*b-*a;}main(n){for(scanf("%d",&n);i<n;)scanf("%d",k+i++);for(qsort(k,n,4,c);i--&&s>=k[i];)s+=k[i];i=!printf("%.f\n",s);}

Measured memory_bytes: 748
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int f[4][5];
int main() {
	ll S;
	ll a, b, c, d;
	cin >> S;
	if (S == 1e18) {
		a = d = 1e9;
		b = c = 0;
	}
	else {
		a = d = (ll)sqrt(S) + 1;
		b = a * d - S, c = 1;
	}
	printf("0 0 %lld %lld %lld %lld\n", a, b, c, d);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 200005

// it's swapnil07 ;)

vector<int> adj[MAXN];
int val[MAXN] = {0};
int ans[MAXN];
bool vis[MAXN] = {false};

void dfs(int i, int v){
    v += val[i];
    ans[i] = v;
    vis[i] = true;
    for(auto j: adj[i]){
        if(!vis[j]){
            dfs(j, v);
        }
    }
}


signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int n, q; cin>>n>>q;
    For(i, 0, n-1){
        int a, b; cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    For(i, 0, q){
        int p, x; cin>>p>>x;
        val[p] += x;
    }
    dfs(1, 0);
    For(i, 1, n+1){
        cout<<ans[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 22656
/*  -*- coding: utf-8 -*-
 *
 * 3053.cc: 
 */

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

/* constant */

const int MAX_N = 100000;
const int M = 9;
const int W = 3;
const int INF = 1 << 30;

/* typedef */

/* global variables */

char s[MAX_N + 4];
int mvs[M][M], ds[M][M], ps[M];

/* subroutines */

inline int ps2i(int ps[]) {
  int sum = 0;
  for (int i = 0; i < M; i++) sum = sum * 10 + ps[i];
  return sum;
}

inline void pos2xy(int pos, int &x, int &y) { x = pos % W, y = pos / W; }
inline int xy2pos(int x, int y) { return y * W + x; }

inline int dist(int pi, int pj) {
  int xi, yi, xj, yj;
  pos2xy(pi, xi, yi), pos2xy(pj, xj, yj);
  return abs(xj - xi) + abs(yj - yi);
}

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  for (int i = 0, j = 1; j < n; i++, j++)
    if (s[i] != s[j]) {
      int di = s[i] - '1', dj = s[j] - '1';
      mvs[di][dj]++;
    }

  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) ds[i][j] = dist(i, j);
  for (int i = 0; i < M; i++) ps[i] = i;

  int mind = INF, minph = 0;

  do {
    //printf("%09d\n", ps2i(ps));
    int d = 0;
    for (int i = 0; i < M; i++)
      for (int j = 0; j < M; j++)
	d += mvs[ps[i]][ps[j]] * ds[i][j];

    if (mind > d)
      mind = d, minph = ps2i(ps);
    else if (mind == d) {
      int ph = ps2i(ps);
      if (minph > ph) minph = ph;
    }
  } while (next_permutation(ps, ps + M));
  //printf("%09d\n", minph);

  for (int y = 0, e = 100000000; y < W; y++) {
    for (int x = 0; x < W; x++, e /= 10)
      putchar('1' + (minph / e) % 10);
    putchar('\n');
  }
  return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5, OO=0x3f3f3f3f;
int h[N], ans[N];
int main()
{
    int n, k; cin >> n >> k;
    memset(ans, OO, sizeof ans);
    for (int i=0 ; i<n ; cin >> h[i++]);
    ans[0]=0;
    for (int i=1 ; i<n ; i++)
        for (int j=i-1 ; j>=max(0, i-k) ; j--)
            ans[i]=min(ans[i], abs(h[i]-h[j])+ans[j]);
    cout << ans[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 200005;
const int MOD = 1000000007;
const int LN = 21;

vector<int> g[MAXN];
ll depth[MAXN],u[MAXN],pa[LN][MAXN],qa[MAXN],qb[MAXN];
ll cnt[MAXN];

int LCA(int a,int b){
	if(depth[b] > depth[a]) swap(a,b);
	int diff = depth[a] - depth[b];
	
	for(int i=0;i<LN;i++) if(diff&(1<<i)) a = pa[i][a];
	
	if(a == b) return a;
	
	for(int i = LN-1;i>=0;i--)
		if(pa[i][a] != pa[i][b]){
			a = pa[i][a];
			b = pa[i][b];
		}
		
	return pa[0][a];	
}

int root(int a) { return u[a] == a ? a : u[a] = root(u[a]); }

void dfs(int a,int p){
	pa[0][a] = p;
	for(int i:g[a]) if(i != p) { depth[i] = depth[a] + 1; dfs(i,a); }
}

void dfs1(int a,int p){
	for(int i:g[a]) if(i != p){
		dfs1(i,a);
		if(cnt[i]&1){
			cout << "NO\n"; exit(0);
		}
		cnt[a] += cnt[i];
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,m; cin >> n >> m;
	for(int i=1;i<=n;i++) u[i] = i;
	for(int i=0;i<m;i++){
		cin >> qa[i] >> qb[i];
		if(root(qa[i]) != root(qb[i])){
			u[root(qa[i])] = root(qb[i]); 
			g[qa[i]].push_back(qb[i]);
			g[qb[i]].push_back(qa[i]);
		}
	}
	for(int i=1;i<=n;i++) if(depth[i] == 0){
		dfs(i,0);
	}
	//for(int i=2;i<=n;i++) if(depth[i] == 0){
	//	cout << "NO\n";
	//	return 0;
	//}
	for(int i=1;i<LN;i++){
		for(int j=1;j<=n;j++){
			pa[i][j] = pa[i-1][pa[i-1][j]];
		}
	}
	for(int i=0;i<m;i++){
		int l = LCA(qa[i],qb[i]);
		cnt[qa[i]]++; cnt[qb[i]]++; cnt[l] -= 2;
	}
	for(int i=1;i<=n;i++) if(depth[i] == 0)
		dfs1(i,0);
	cout << "YES\n";
	return 0;
}


Measured memory_bytes: 47488
#include <iostream>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;
int main(){
  int x,y;
  while(1){
    cin>>x>>y;
    if(x==0&&y==0) break;
    if(x<y)cout<<x<<' '<<y<<'\n';
    else cout<<y<<' '<<x<<'\n';
  }
  return 0;
}



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

int main() {
    
  int A,B;
  cin >>A>>B;
  int count=0;
  for(int i=A;i<=B;i++){
    int a=i/10000;
    int b=i%10000;
    int c=b/1000;
    int d=b%1000;
    int e=d/100;
    int f=d%100;
    int g=f/10;
    int h=f%10;
    if(a==h&&c==g){
      count++;
    }
  }
  cout<<count<<endl;
  

        
}


Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))
s=[0]*n
m=998244353
for i in d:
    s[i]+=1
if d[0]==0 and s[0]==1:
    c=1
    a=1
    for i in range(1,n):
        if s[i]!=0:
            c+=s[i]
            a=(a*pow(s[i-1],s[i],m))%m
        else:
            break
    if c==n:
        print(a%m)
    else:
        print(0)
else:
    print(0)   

Measured memory_bytes: 55092
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  int v[n+10];
  int count=0;
  rep(i,n-1){
    if(s[i]=='A' && s[i+1]=='C'){
      count++;
    }
    v[i]=count;
  }
  rep(i,q){
    int l,r;
    cin >> l >> r;
    l--; r--;
    int ans = v[r-1]-v[l-1];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x1 - (y2 - y1);
    y4 = y1 + (x2 - x1);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
ll mod=1000000007,N;
ll R(ll X){
  ll j=X,res=1,n=N;
  while(n>0){
    if(n&1)res=res*j%mod;
    j=j*j%mod;n>>=1;
  } 
  return res;
}
signed main(){
  cin>>N;ll ans=R(10)-2*R(9)+R(8);
  ans%=mod;if(ans<0)ans+=mod;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
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(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

LL dp[5001][5001];

int main() {
	int n;
	string s;
	cin >> n >> s;
	dp[0][0] = 1;
	REP(i, n) {
		REP(j, n) {
			// 0 or 1
			dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
			// backspace
			if (j == 0)dp[i + 1][0] = (dp[i + 1][0] + dp[i][0]) % MOD;
			else dp[i + 1][j - 1] = (dp[i + 1][j - 1] + dp[i][j] * 2) % MOD;
		}
	}
	cout << dp[n][s.length()] << endl;
	return 0;
}

Measured memory_bytes: 195584
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int p = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == 'p') {
                p++;
            }
        }
        System.out.println(s.length() / 2 - p);
    }

}


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

int main(){
  int N; cin>>N;
  vector<int> A;
  for(int i=0;i<N;i++){
    int a; cin>>a;
    A.push_back(a);
  }
  sort(A.begin(),A.end());
  int n = 0;
  int min=A[0];
  for(int i=0;;i++){
    sort(A.begin(),A.end());
    for(int j=n;j<N-1;j++){
      if(A[j]!=0){
        n=j;
        break;
      }
    }
    if(A[n]==0) break;
    if(A[n]<min) min=A[n];
    for(int j=n+1;j<N;j++) A[j]%=A[n];

    // cout<<endl;
    // for(auto a:A) cout<<a<<",";
    // cout<<endl;
  }
  cout<<min<<endl;
  return 0;
}

Measured memory_bytes: 892
N = gets.to_i
A = gets.split.map { |e|e.to_i  }
B = gets.split.map { |e|e.to_i  }

manhattan = 0.0
euclidian = 0.0
l3  = 0.0
chebyshev = 0.0
N.times do |i|
  diff = (A[i]-B[i]).abs
  manhattan += diff
  euclidian += (diff)**2
  l3 += diff**3
  chebyshev = diff if chebyshev < diff
end

puts manhattan,Math.sqrt(euclidian),(l3**(1/3.0)),chebyshev

Measured memory_bytes: 6192
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        UnionFind uf = new UnionFind(n);
        List<Integer>[] graph = new ArrayList[n];
        for(int i=0; i<n; i++){
            graph[i] = new ArrayList<>();
        }
        Map<Long,Boolean> block = new HashMap<>();
        
        for(int i=0; i<m; i++){
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            graph[a].add(b);
            graph[b].add(a);
            uf.unite(a,b);
        }
        
        int[] ans = new int[n];
        for(int i=0; i<n; i++){
            ans[i] = uf.size(i)-graph[i].size();
        }
        
        for(int i=0; i<k; i++){
            int c = Integer.parseInt(sc.next())-1;
            int d = Integer.parseInt(sc.next())-1;
            if(uf.same(c,d)){
                ans[c]--;
                ans[d]--;
            }
        }
        
        for(int i=0; i<n; i++){
            System.out.println(ans[i]-1);
        }
        
    }
}

class UnionFind{
    int n;
    int[] par;
    int[] size;
    
    public UnionFind(int n){
        this.n = n;
        par = new int[n];
        for(int i=0; i<n; i++){
            par[i] = i;
        }
        size = new int[n];
        Arrays.fill(size, 1);
    }
    
    public int find(int x){
        if(par[x] == x){
            return x;
        }else{
            par[x] = find(par[x]);
            return par[x];
        }
    }
    
    public boolean unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return false;
        
        if(size[x]<size[y]){
            int tmp = x;
            x = y;
            y = tmp;
        }
        size[x] += size[y];
        par[y] = x;
        return true;
    }
    
    public boolean same(int x, int y){
        return find(x)==find(y);
    }
    
    public int size(int x){
        return size[find(x)];
    }
    
    public int groupCount(){
        Set<Integer> s = new HashSet<>();
        for(int i=0; i<n; i++){
            s.add(this.find(i));
        }
        return s.size();
    }
}


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

void solve(){
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    string s;
    std::cin >> s;
    
    vector<vector<ll>> dp(n+1);
    dp[n] = {0};

    for (int i = n-1; i >= 0; i--) {
        ll v = a[i];
        for (auto e : dp[i+1]) {
            v = min(v,v^e);
        }
        if(v==0){
            dp[i] = dp[i+1];
        }else{
            if(s[i]=='0'){
                dp[i+1].push_back(v);
                sort(dp[i+1].rbegin(),dp[i+1].rend());
                for (auto e : dp[i+1]) {
                    dp[i].push_back(e);
                }
            }else{
                std::cout << 1 << std::endl;
                return;
            }    
        }
    }
    std::cout << 0 << std::endl;
}

int main() {
    int t;
    std::cin >> t;
    for (int iii = 0; iii < t; iii++) {
        solve();
    }
}


Measured memory_bytes: 3708
import bisect
N,M = map(int,input().split())
maxa = M//N
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
mdiv = sorted(make_divisors(M))
ans = mdiv[bisect.bisect_right(mdiv,maxa)-1]
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>

int main(void) {
  int n;
  scanf("%d",&n);
  char s[n+1],t[n+1];
  scanf("%s %s",s,t);
  for(int i = 0; i < n; i++) printf("%c%c",s[i],t[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
flag = True
ans = [-1] * n
for _ in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        flag = False
        break
    else:
        ans[s] = c
if n > 1 and ans[0] == 0:
        flag = False
if flag:
    if n == 1:
        if ans[0] == -1:
            print(0,end='')
        else:
            print(ans[0], end='')
    else:
        if ans[0] == -1:
            print(1, end='')
        else:
            print(ans[0], end='')
        for i in range(1, n):
            if ans[i] == -1:
                print(0, end='')
            else:
                print(ans[i], end='')
    print()
else:
    print(-1)

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

int dec(char text[]){
    int sum = 0;
    int i=0;

    while(text[i] != '\0'){
        if(text[i] >= 50 && text[i] <= 57){
            if((text[i+1]) == 'm'){
                sum += (1000 * ((text[i])-48));
                i++;
            }else if(text[i+1] == 'c'){
                sum += (100 * (text[i]-48));
                i++;
            }else if(text[i+1] == 'x'){
                sum += (10 * (text[i]-48));
                i++;
            }else{
                sum += (text[i])-48;
                i++;
            }
        }

        else{
            if(text[i] == 'm'){
                sum += 1000;
            }else if(text[i] == 'c'){
                sum += 100;
            }else if(text[i] == 'x'){
                sum += 10;
            }else{
                sum += 1;
            }
        }

        i++;
    }

    return sum;
}

int main(){

    int i,n;
    int a;
    int d;
    char input[2][10];
    char output[10];

    scanf("%d",&n);

    for(i=0;i<n;i++){
        a=0;
        d=1000;
        output[0]='\0';

        scanf("%s %s",input[0],input[1]);

        a = dec(input[0]);
        a += dec(input[1]);

        while(d){
            if(a/d >1){
                switch(d){
                    case 1000: sprintf(output,"%s%dm",output,a/d);  break;
                    case 100: sprintf(output,"%s%dc",output,a/d);  break;
                    case 10: sprintf(output,"%s%dx",output,a/d);  break;
                    case 1: sprintf(output,"%s%di",output,a/d);  break;
                }
            }else if(a/d == 1){
                switch(d){
                    case 1000: sprintf(output,"%sm",output);  break;
                    case 100: sprintf(output,"%sc",output);  break;
                    case 10: sprintf(output,"%sx",output);  break;
                    case 1: sprintf(output,"%si",output);  break;
                }
            }
            a %= d;
            d /= 10;
        }

        printf("%s\n",output);
           
    }



    return 0;
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n;
char k, s[2048];

bool cmp(const pair<string, int> &a, const pair<string, int> &b){
  if(a.S != b.S) return a.S > b.S;
  return a.F < b.F;
}

int main(){
  while(scanf("%d", &n) && n){
    vector<pair<string, int> >c;
    scanf("\n");
    rep(i, n){
      fgets(s, sizeof(s), stdin);
      s[strlen(s)-1] = '\0';
      char *tp;

      tp = strtok(s, " ");
      int p;
      string ss = string(tp);
      for(p = 0; p < c.size(); p++) if(c[p].F == ss){ c[p].S++; break;}
      if(p == c.size()) c.PB(MP(ss, 1));
      while(tp != NULL){
	tp = strtok(NULL, " ");
	if(tp == NULL) continue;
	ss = string(tp);
	for(p = 0; p < c.size(); p++) if(c[p].F == ss){ c[p].S++; break;}
	if(p == c.size()) c.PB(MP(ss, 1));
      }
    }
    
    scanf("%s", s);
    k = s[0];
    rep(i, c.size()) if(c[i].F[0] != k){ c.erase(c.begin()+i); i--;}
    sort(c.begin(), c.end(), cmp);
    if(c.size()) rep(i, 5<c.size()?5:c.size()) cout << (i?" ":"") << c[i].F;
    else printf("NA");
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <cmath>
#include <algorithm>

int main(){
	int past[1001],current[1001],tmp_code,tmp_date;
	char buf[30];

	for(int i=0; i < 1001; i++){
		past[i] = current[i] = 0;
	}

	while(true)
	{
		fgets(buf,30,stdin);
		if(buf[0] == '\n'){
			break;
		}
		tmp_code = 0;
		for(int i=0;buf[i] != ',';i++){
			tmp_code = 10*tmp_code + (buf[i] - '0');
		}
		past[tmp_code]++;
	}

	while(scanf("%d,%d",&tmp_code,&tmp_date)!=EOF){
		current[tmp_code]++;
	}

	for(int i = 0; i < 1001; i++){
		if(past[i] > 0 && current[i] > 0){
			printf("%d %d\n",i,past[i]+current[i]);
		}
	}

	return 0;
}



Measured memory_bytes: 2684
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;

int main() {
    ll h, w, ans;
    cin>>h>>w;
    
    if(h==1 || w ==1){
        ans = 1;
    }
    else{
        if((h*w)%2 == 0) ans = (h*w/2);
        
        else ans = (h*w/2) + 1;
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
X, Y = map(int, input().split())

sum = 0
if X == 1 and Y == 1:
    print("1000000")
    exit()

if X == 3:
    sum += 100000
elif X == 2:
    sum += 200000
elif X == 1:
    sum += 300000

if Y == 3:
    sum += 100000
elif Y == 2:
    sum += 200000
elif Y == 1:
    sum += 300000

print(sum)

Measured memory_bytes: 3064
import sys
import math

N, K = map(int, sys.stdin.readline().strip().split())
A = list(map(int, sys.stdin.readline().strip().split()))

left = 0  # 出来ない長さ
right = 10 ** 9 + 1  # 出来る長さ


def judge(length, num_cut):
    cut = 0
    for a in A:
        if a > length:
            cut += math.ceil(a / length) - 1

    if cut <= num_cut:
        return True

    return False


while right - left > 1:
    mid = (left + right) // 2
    # print(f'right: {right}, left: {left}, mid: {mid}')

    if judge(mid, K):
        right = mid
    else:
        left = mid

print(right)


Measured memory_bytes: 93980
s = str(input())
no = 0
while 1:
    for data in ["erase", "eraser", "dream", "dreamer"]:
        if s.endswith(data):
            s = s[: - len(data)]
        else:
            no += 1
    if not s:
        break
    if no == 4:
        print("NO")
        exit()
    else:
        no = 0
print("YES")


Measured memory_bytes: 9008
#include<iostream>
#include<string>
using namespace std;
int main(){
  string d;
  while(cin>>d){
    int joi=0,ioi=0,n=0,m=0;
    while(1){
      if(d.find("JOI",n)==-1) break;
      n = d.find("JOI",n);
      joi++;
      n+=2;
    }
    while(1){
      if(d.find("IOI",m)==-1) break;
      m = d.find("IOI",m);
      ioi++;
      m+=2;
    }
     cout << joi << endl << ioi << endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i =0;i<N;i++){
   cin >> vec.at(i); 
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
    for(int i = 0;i < N;i++){
//	cout << i << ":" << vec.at(i);
  }
//  cout << endl;
  int a = 0,b = 0;
  int i;
  for(i = 0;i < N;){
//     cout << i << ":" << vec.at(i) << endl;
     a += vec.at(i++);
    if(i < N){
//     cout << i << ":" << vec.at(i) << endl;
     b += vec.at(i++);
     }
  }
  cout << a - b << endl;
  
}




Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int MAX_M = 20;
int MAX_N = 20;

int main(void){
    int N, M, C;
    int A[MAX_N][MAX_M];
    int B[MAX_M];
    int answer = 0;

    cin >> N >> M >> C;
    
    rep(i, M){
        cin >> B[i];
    }

    rep(i, N){
        rep(j, M){
            cin >> A[i][j];
        }
    }

    rep(i, N){
        int cnt = C;
        rep(j, M){
            cnt += A[i][j] * B[j];
        }
        if (cnt > 0){
            answer ++;
        }
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
let binary_search x ary =
  let rec doit l r =
    if l > r then None
    else begin
      let m = (l + r) / 2 in
      if x = ary.(m) then Some x
      else if x < ary.(m) then doit l (m - 1)
      else doit (m + 1) r
    end
  in
  doit 0 (Array.length ary - 1)

let () =
  let _ = read_int () in
  let s = Array.of_list (List.map int_of_string (Str.split (Str.regexp_string " ") (read_line ()))) in
  let _ = read_int () in
  let t = List.map int_of_string (Str.split (Str.regexp_string " ") (read_line ())) in
  let rec doit cnt = function
    | [] -> cnt
    | hd :: tl -> begin
        match binary_search hd s with
        | None -> doit cnt tl
        | Some _ -> doit (cnt + 1) tl
      end
  in
  Printf.printf "%d\n" (doit 0 t)

Measured memory_bytes: 16224