akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a <= b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int dp[114514];
signed main() {
    rep(i, 114514) dp[i] = inf;
    int n;cin >> n;
    vi h(n);
    rep(i, n)cin >> h[i];
    dp[0] = 0;
    rep1(i, n) {
        if(i==1) dp[i] = abs(h[1]-h[0]);
        else {
            chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
            chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4840
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static class V {
		int i, t;
		V(int i, int t) {
			this.i = i; this.t = t;
		}
	}
	int[] xx, pq, ip; int cnt;
	boolean lt(int i, int j) {
		return xx[i] < xx[j];
	}
	int p2(int p) {
		return (p *= 2) > cnt ? 0 : p < cnt && lt(ip[p + 1], ip[p]) ? p + 1 : p;
	}
	void pq_up(int i) {
		int j, p, q;
		for (p = pq[i]; (q = p / 2) > 0 && lt(i, j = ip[q]); p = q)
			ip[pq[j] = p] = j;
		ip[pq[i] = p] = i;
	}
	void pq_dn(int i) {
		int j, p, q;
		for (p = pq[i]; (q = p2(p)) > 0 && lt(j = ip[q], i); p = q)
			ip[pq[j] = p] = j;
		ip[pq[i] = p] = i;
	}
	void pq_add(int i) {
		pq[i] = ++cnt; pq_up(i);
	}
	void pq_remove(int i) {
		int j = ip[cnt--];
		if (j != i) {
			pq[j] = pq[i]; pq_up(j); pq_dn(j);
		}
		pq[i] = 0;
	}
	void main() {
		int n = sc.nextInt();
		int q = sc.nextInt();
		int m = n * 2 + q;
		V[] vv = new V[m];
		m = 0;
		int[] ll = new int[n];
		int[] rr = new int[n];
		xx = new int[n];
		for (int i = 0; i < n; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int x = sc.nextInt();
			ll[i] = s - x;
			rr[i] = t - x;
			xx[i] = x;
			vv[m++] = new V(i, 0);
			vv[m++] = new V(i, 1);
		}
		int[] dd = new int[q];
		int[] yy = new int[q];
		for (int h = 0; h < q; h++) {
			dd[h] = sc.nextInt();
			vv[m++] = new V(h, 2);
		}
		Arrays.sort(vv, (u, v) -> {
			int ux = u.t == 2 ? dd[u.i] : u.t == 0 ? rr[u.i] : ll[u.i];
			int vx = v.t == 2 ? dd[v.i] : v.t == 0 ? rr[v.i] : ll[v.i];
			return ux != vx ? ux - vx : u.t - v.t;
		});
		pq = new int[n]; ip = new int[1 + n];
		for (int h = 0; h < m; h++) {
			V v = vv[h];
			if (v.t == 0)
				pq_remove(v.i);
			else if (v.t == 1)
				pq_add(v.i);
			else
				yy[v.i] = cnt > 0 ? xx[ip[1]] : -1;
		}
		for (int h = 0; h < q; h++)
			println(yy[h]);
	}
}


Measured memory_bytes: 82500
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define pld pair <ld, ld>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
#define cld complex <double>

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6 + 100;
const ll mod = 1e9 + 7;

ll n, m, k, t;

int main() {
    pyshnapyshnakaa
    ll q, w, e, a, b, c;
    cin >> n;
    string s;
    cin >> s;
    map <ll, ll> C;
    for (q = 0; q < s.length(); q++) {
        C[s[q]]++;
    }
    ll ans = 1;
    for (auto p : C) {
        ans *= (p.second + 1);
        ans %= mod;
    }
    cout << (ans - 1 + mod) % mod;
    return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

#define MAX 256

int main(void){
	
	int n;

	scanf("%d", &n);

	int i = 1, k = 0, x;

	while (i <= n){
		k = 0;
		x = i;
		if (i % 3 == 0)k = 1;
		if (x % 10 == 3)k = 1;
		while (x > 10){
			x = x / 10;
			if (x % 10 == 3)k = 1;
		}
		if (k == 1){
			printf(" %d", i);
		}
		i++;
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 3184
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashMap;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int H = in.nextInt();
    int W = in.nextInt();

    char[][] inputImage = new char[H][W];
    for (int i = 0; i < H; i++) {
      String tmp = in.next();
      for (int j = 0; j < W; j++) {
        inputImage[i][j] = tmp.charAt(j);
      }
    }

    char[][] outputImage = new char[H * 2][W];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        outputImage[2 * i][j] = inputImage[i][j];
        outputImage[2 * i + 1][j] = inputImage[i][j];
      }
    }

    for (int i = 0; i < 2 * H; i++) {
      for (int j = 0; j < W; j++) {
        System.out.print(outputImage[i][j]);
      }
      System.out.println("");
    }


  }
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int n;
    cin >> n;
    cout << 180 * (n - 2) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

H, W, M = map(int, input().split())

bomb_h = [0] * H
bomb_w = [0] * W
bomb = set()
for i in range(M):
    h, w = map(int, input().split())
    bomb_h[h-1] += 1
    bomb_w[w-1] += 1
    bomb.add((h-1, w-1))

max_h = max(bomb_h)
max_w = max(bomb_w)

h_indices = []
for i in range(H):
    if bomb_h[i] == max_h:
        h_indices.append(i)

w_indices = []
for i in range(W):
    if bomb_w[i] == max_w:
        w_indices.append(i)

ans = max_w + max_h - 1
for h in h_indices:
    for w in w_indices:
        if (h, w) not in bomb:
            ans += 1
            print(ans)
            exit()

if ans == -1:
    ans = 0

print(ans)


Measured memory_bytes: 158896
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define inf (1LL<<61)
#define int long long
typedef long long ll;
#define ld long double
#define N 301 

struct data{
    int s,w,v;
}a[1000];
bool comp(struct data &s1,struct data &s2)
{
    return s1.w + s1.s < s2.w + s2.s;
}
int dp[2][20001];
int32_t main()
{
    IOS;

    int n;
    cin>>n;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i].w >> a[i].s >> a[i].v;
    }
    sort(a,a+n,comp);
    
    memset(dp,0,sizeof(dp));
    for(int i = 0;i < n;i++)
    {
        int cur = i & 1;
        int prev = !cur;
        for(int j = 0 ;j < 20001;j++)
        {
            dp[cur][j] = dp[prev][j];
        }
        for(int  j = 0;j < 20001;j++)
        {
            if(a[i].s >= j)
            {
                if(a[i].w + j < 20001)
                    dp[cur][a[i].w + j] = max(dp[cur][a[i].w + j],dp[prev][j] + a[i].v);
            }
        }
    }
    int ans = 0;
    for(int i = 0;i < 20001;i++)
        ans = max(ans,max(dp[0][i],dp[1][i]));
    cout << ans;
}

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

int main()
{
	ll N,Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector<ll> counter(N);
	ll cnt(0);
	counter[0] = 0;
	for(int i(0);i<N-1;++i){
		if(S[i] == 'A' && S[i+1] == 'C'){
			cnt++;
		}
		counter[i+1] = cnt;
	}
	ll l(0),r(0),ans(0);
	for(int i(0);i<Q;++i){
		cin >> l >> r;
		ans = counter[r-1] - counter[l-1];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1e9
typedef pair<int,int> pii;
 
int N,C[4][4];
pii stamp[16];
 
inline int stp(int x,int y,int px,int py,int c,int S){
    for(int i = max(0,py) ; i < min(py+y,4) ; i++){
	for(int j = max(0,px) ; j < min(px+x,4) ; j++){
	    int b = i*4+j;
	    if(C[i][j] == c){
		if((S >> b) & 1) continue;
		S |= (1<<b);
	    }else{
		if((S >> b) & 1){
		    S -= (1<<b);
		}
	    }
	}
    }
    return S;
}
 
int solve(){
    queue<int> Q;
    Q.push(0);
    int dist[1<<16];
    fill(dist,dist+(1<<16),INF);
    dist[0] = 0;
 
    while(!Q.empty()){
	int S = Q.front(); Q.pop();
	if(S == (1<<16)-1){
	    return dist[S];
	}
	for(int i = 0 ; i < N ; i++){
	    pii p = stamp[i];
	    int x = p.second, y = p.first;
	    for(int j = 0 ; j < 3 ; j++){
		for(int px = -x+1 ; px < 4 ; px++){
		    for(int py = -y+1 ; py < 4 ; py++){
			int nS = stp(x,y,px,py,j,S);
			if(dist[S]+1 < dist[nS]){
			    dist[nS] = dist[S] + 1;
			    Q.push(nS);
			}
		    }
		} 
	    }
	}
    }
    return -1;
}
 
int change(char ch){
    if(ch == 'R') return 0;
    if(ch == 'B') return 1;
    return 2;
}
 
int main(){
    cin >> N;
    for(int i = 0 ; i < N ; i++){
	cin >> stamp[i].first >> stamp[i].second;
    }
    char in;
    for(int i = 0 ; i < 4 ; i++){
	for(int j = 0 ; j < 4 ; j++){
	    cin >> in;
	    C[i][j] = change(in);
	}    
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 3496
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();

        int total = 0;

        for (int i = 1; i <= a; i++) {
            if (String.valueOf(i).length() % 2 == 1) total++;
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 28372
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int inf = 0x7f7f7f;
//const int maxn = ;

int main() {
//ios::sync_with_stdio(false);
#ifdef LOCAL
freopen("lll.in", "r", stdin);
//freopen(".out", "w", stdout);
#endif
	int t;
	cin >> t;
	while(t--) {
		int a;
		int lt = -1, rt = -1;
		bool flag = true;
		for(int i = 1; i <= 10; i++) {
			cin >> a;
			if(!flag) continue;
			if(a > lt && a > rt) {
				if(a - lt <= a - rt)
					lt = a;
				else
					rt = a;
			} else if(a > lt && a <= rt) {
				lt = a;
			} else if(a <= lt && a > rt) {
				rt = a;
			} else {
				flag = false;
			}
		}

		if(flag) 
			printf("YES\n");
		else 
			printf("NO\n");
	}
}




Measured memory_bytes: 3088
#include<iostream>
#define yes(n) std::cout << ((n) ? "Yes" : "No") << std::endl
int main()
{
    char s[4];
    std::cin >> s[0] >> s[1] >> s[2];
    if((s[0] == s[1]&&s[1]!=s[2]) || (s[0] == s[2]&&s[1]!=s[2])
    || (s[2] == s[1]&&s[1]!=s[0]))
    {
        yes(true);
    }
    else
    {
        yes(false);
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>
using pii = std::pair<double, int>;

typedef struct edge{
  int from, to;
  double dist;
}edge;

typedef struct obj{
  int x, y;
}obj;

double dist(obj a, obj b){
  double i = (a.x - b.x), j = (a.y - b.y);
  return std::sqrt(i*i + j*j);
}

void solve(int s, int t, std::vector<std::vector<edge> > &G){
  int n = G.size();
  std::vector<int> ans(n, -1);  std::vector<double> d(n, 1e9);
  std::priority_queue<pii, std::vector<pii>, std::greater<pii>> que;
  que.push(pii(0, s));
  d[s] = 0;
  while(not que.empty()){
    int v = que.top().second;
    double c = que.top().first;
    que.pop();
    for (int i = 0; i < G[v].size(); i++) {
      int u = G[v][i].to;
      if(d[u] > c + G[v][i].dist){
        d[u] = c + G[v][i].dist;
        que.push(pii(d[u], u));
        ans[u] = v;
      }
    }
  }
  if(ans[t] == -1){
    std::cout << "NA" << std::endl;
    return;
  }
  std::vector<int> real_ans;
  real_ans.push_back(t);
  while(ans[t] != -1) {
    real_ans.push_back(ans[t]);
    t = ans[t];
  }
  for (int i = 0; i < real_ans.size(); i++) {
    std::cout << real_ans[real_ans.size() - i - 1] + 1;
    if(i == real_ans.size() - 1)std::cout << std::endl;
    else std::cout << " ";
  }
}
           

int main(){
  int n, m;
  while(std::cin >> n){
    if(n == 0) break;
    std::vector<std::vector<edge> > G(n);
    std::vector<obj> p(n);
    for (int i = 0; i < n; i++) {
      int b, x, y;
      std::cin >> b >> x >> y;
      p[--b] = obj{x, y};
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        // std::cout << "i:" << i << " j:" << j << " " << dist(p[i], p[j]) << std::endl;
        if(dist(p[i], p[j]) <= 50.){
          // std::cout << "hoge" << std::endl;
          G[i].push_back(edge{i, j, dist(p[i], p[j])});
          G[j].push_back(edge{j, i, dist(p[i], p[j])});
        }
      }
    }
    std::cin >> m;
    for (int i = 0; i < m; i++) {
      int s, t;
      std::cin >> s >> t;
      solve(--s, --t, G);
      // std::cout << "s:" << s << " t:" << t << std::endl;
    }
  }
  return 0;
}



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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < K; i++) {
        vector<int> data(N, 0);
        for (int i = 0; i < N; i++) {
            if (i - A.at(i) >= 0) {
                data.at(i - A.at(i))++;
            }
            else {
                data.at(0)++;
            }
            if (i + A.at(i) + 1 < N) {
                data.at(i + A.at(i) + 1)--;
            }
        }
        for (int i = 1; i < N; i++) {
            data.at(i) += data.at(i - 1);
        }
        bool alln = true;
        for (int i = 0; i < N; i++) {
            if (data.at(i) != N) {
                alln = false;
                break;
            }
        }
        if (alln) {
            cout << N;
            for (int i = 1; i < N; i++) {
                cout << " " << N;
            }
            cout << endl;
            return 0;
        }
        A = data;
    }
    cout << A.at(0);
    for (int i = 1; i < N; i++) {
        cout << " " << A.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 4832
#include<iostream>
using namespace std;
int main() {
	char S[11];
	char T[11];
	char U[11];
	int A, B;
	cin >> S >> T >> A >> B >> U;
	if (strcmp(S,U) == 0) {
		A -= 1;
	}
	else {
		B -= 1;
	}
	cout << A <<" "<< B << endl;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean flg = true;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ((i % 2 == 1 && c == 'R') || (i % 2 == 0 && c == 'L')) {
                flg = false;
                break;
            }
        }

        if (flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-10;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;cin>>s;
    int n=s.size();
    int k;cin>>k;
    string t=s;
    reverse(t.begin(),t.end());
    int dp[n+1][n+1][k+1];
    memset(dp,0,sizeof dp);
    rep(i,0,n){
        rep(j,0,n){
            rep(l,0,k+1){
                if(s[i]==t[j]){
                    Max(dp[i+1][j+1][l],dp[i][j][l]+1);
                }
                else{
                    Max(dp[i+1][j+1][l],max(dp[i][j+1][l],dp[i+1][j][l]));
                    if(l<k)Max(dp[i+1][j+1][l+1],dp[i][j][l]+1);
                }
            }
        }
    }
    int ans=0;
    rep(i,0,n+1){
        rep(j,0,n+1){
            if(i+j>n)break;
            rep(l,0,k+1){
                if(i+j==n)Max(ans,dp[i][j][l]*2);
                else Max(ans,dp[i][j][l]*2+1);
            }
        }
    }
    cout<<ans<<endl;
}






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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

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

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

int main(){
    int N; cin >> N;
    vector<ll> t( N );
    REP( i, N ) cin >> t[i];

    REP( i, N - 1 ){
        t[i + 1] = lcm( t[i], t[i + 1] );
    }

    cout << t[N - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  ll d, a;
  cin >> n;
  cin >> d >> a;
  vector<pair<ll, ll>> xh(n);
  REP(i, n) {
    ll x, h;
    cin >> x >> h;
    xh[i] = make_pair(x, h);
  }
  sort(ALL(xh));
  vl imos(n + 1, 0LL);
  ll ans = 0;
  ll cur = 0;
  REP(i, n) {
    cur += imos[i];
    ll res = xh[i].second - cur;
    if (res > 0) {
      ll po = (res + a - 1) / a;
      ans += po;
      auto idx =
          upper_bound(ALL(xh), make_pair(xh[i].first + 2 * d, (ll)1e9 + 1)) -
          xh.begin();
      imos[idx] -= po * a;
      cur += po * a;
    }
    // cout << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
N, M = map(int, input().split())
s = [None] * M
c = [None] * M
for i in range(M):
  s[i],c[i] = map(int, input().split())

flag = False
if N == 1:
  tmp = 0
else:
  tmp = 10**(N-1)

for i in range(tmp, 10**N):
  count = 0
  for j in range(M):
    if str(i)[s[j]-1] != str(c[j]):
      break
    else:
      count += 1
  if count == M:
    flag = True
    print(i)
    break
if not flag:
  print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
int main() {
    int n;
    scanf("%d", &n);
    vector<ll> a(n);
    rep(i, n) scanf("%lld", &a[i]);
    deque<ll> ans;
    int temp = 1;
    if(n % 2) temp = 0; //nが奇数なら0、偶数なら1
    rep(i, n) {
        if(i % 2 == temp) ans.push_front(a[i]); //偶奇が一致してたら
        else ans.push_back(a[i]);
    }
    rep(i, n) printf("%lld ", ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 6412
import itertools


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return (i for i in range(n + 1) if is_prime[i])


P = set(primes(10 ** 5))
L = [0] * 10 ** 5
for i in range(1, 10 ** 5, 2):
    if i in P and (i + 1) // 2 in P:
        L[(i + 1) // 2] = 1

L = tuple(itertools.accumulate(L))
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(L[(r + 1) // 2] - L[l // 2])


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    ll N, W; cin >> N >> W;
    vector<ll> w, w1, w2, w3;
    ll stdw, tmpv; cin >> stdw >> tmpv;
    w.push_back(tmpv);

    rep(i, N-1){
        ll tw, tv; cin >> tw >> tv;
        if(tw==stdw) w.push_back(tv);
        if(tw==stdw+1) w1.push_back(tv);
        if(tw==stdw+2) w2.push_back(tv);
        if(tw==stdw+3) w3.push_back(tv);
    }
    sort(w.rbegin(), w.rend());
    sort(w1.rbegin(), w1.rend());
    sort(w2.rbegin(), w2.rend());
    sort(w3.rbegin(), w3.rend());

    ll ans=0;
    rep(i, w.size()+1) rep(j, w1.size()+1) rep(k, w2.size()+1) rep(l, w3.size()+1){
        ll tmpval=0;
        rep(m, i) tmpval+=w[m];
        rep(m, j) tmpval+=w1[m];
        rep(m, k) tmpval+=w2[m];
        rep(m, l) tmpval+=w3[m];
        if( i*stdw + j*(stdw+1) + k*(stdw+2) + l*(stdw+3) <= W ) chmax(ans, tmpval);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    string s;
    cin>>s;
    int n=s.len;
    if((s[0]==s[n-1])^((n&1))) cout<<"First";
    else cout<<"Second";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;

    vector <int> ss, tt;

    // rep(i, s.size()){
    //     ss.emplace_back(s[i] - 'a');
    // }
    // rep(i, t.size()){
    //     tt.emplace_back(t[i] - 'a');
    // }

    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    rep(i, min(s.size(), t.size())){
        if(s[i] == t[i]){
            continue;
        }else if(s[i] < t[i]){
            cout << "Yes" << endl;
            return 0;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    if(s.size()<t.size()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
  auto A = vector<int>(3*3);
  for(auto& a : A) {
    cin >> a;
  }
  auto X = vector<bool>(3*3, false);
  int N;
  cin >> N;
  for(int i=0; i<N; i++) {
    int b;
    cin >> b;
    for(int j=0; j<9; j++) {
      if (A[j] == b) {
        X[j] = true;
      }
    }
  }
  bool res =
     ((X[0] && X[1] && X[2]) ||
      (X[3] && X[4] && X[5]) ||
      (X[6] && X[7] && X[8]) ||
      (X[0] && X[3] && X[6]) ||
      (X[1] && X[4] && X[7]) ||
      (X[2] && X[5] && X[8]) ||
      (X[0] && X[4] && X[8]) ||
      (X[2] && X[4] && X[6]));
  cout << ((res) ? "Yes" : "No") << endl;
  
  return 0;  
}


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

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> V(N), C(N);

    for (int i = 0; i < N; i++)
    {
        std::cin >> V[i];
    }

    for (int i = 0; i < N; i++)
    {
        std::cin >> C[i];
    }
    std::vector<int> sub(N);
    for (int i = 0; i < N; i++)
    {
        sub[i] = V[i] - C[i];
    }

    std::sort(sub.begin(), sub.end(), [](int a, int b) { return a > b; });

    int ans=0;
    for (int i = 0; i < N; ++i)
    {
        if (sub[i] > 0)
        {
            ans += sub[i];
        }
        else break;
    }
    std::cout << ans << std::endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,ans,m;
int main(){
	scanf("%lld%lld",&n,&m);
	m=2*m+1;
    printf("%lld",(n+m-1)/m);
}

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

int main()
{
	int i = 0;
	while( 1 ) {
		int x;
		cin >> x;
		if( x == 0 ) {
			break;
		}
		i++;
		cout << "Case " << i << ": " << x << endl;
	}
}



Measured memory_bytes: 3020
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

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

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const int N1 = 1e6 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

int ar[2*N],as[N1],cnt[N1];
set<int>st;
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    ///cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        int n,mx=0;
        cin>>n;
        for(int i=1; i<=n; ++i)cin>>ar[i];
        sort(ar+1,ar+n+1);
        for(int i=1; i<=n; ++i) {
            as[ar[i]]=ar[i];
            mx=max(mx,ar[i]);
            cnt[ar[i]]++;
        }
        for(int i=1; i<=n; ++i) {
            if(as[ar[i]]==ar[i]) {
                for(int j=ar[i]; j<=mx; j+=ar[i]) {
                    if(ar[i]!=j) {
                        as[j]=ar[i];
                    }
                }
            }
        }
        int ans=0;
        for(int i=1; i<=n; ++i) {
            if(as[ar[i]]==ar[i]&&cnt[ar[i]]==1)ans++;
        }

            cout<<ans<<endl;

    }
    return 0;
}



Measured memory_bytes: 12208
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long n = in.nextLong();
            long x = in.nextLong();
            out.println(3 * (n - Numbers.gcd(n, x)));
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }

    static class Numbers {
        public static long gcd(long a, long b) {
            return a % b == 0 ? b : gcd(b, a % b);
        }

    }
}



Measured memory_bytes: 22612
#include <iostream>

using namespace std;

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

  char c;
  int cnt_a = 0;
  int cnt_b = 0;
  while (cin >> c) {
    if (c == 'a') {
      if (cnt_a + cnt_b < a + b) {
        cout << "Yes" << endl;
        ++cnt_a;
      } else {
        cout << "No" << endl;
      }
    } else if (c == 'b') {
      if ((cnt_a + cnt_b < a + b) && (cnt_b < b)) {
        cout << "Yes" << endl;
      ++cnt_b;
      }
      else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    string s; cin >> s;
    bool r = 0, l = 0;
    int count, ans = 0;
    REP(i, n){
        count = 0;
        for(char c = 'a'; c <= 'z'; c++){
            r = l = false;
            REP(j, i){
                if(s[j] == c) l = true;
            }
            FOR(j, i, n){
                if(s[j] == c) r = true;
            }
            if(l and r) count++;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int X = scan.nextInt();
        int Y = scan.nextInt();

        int ans =Integer.MAX_VALUE;
        for(int i=0;i<=Math.max(2*X,2*Y);++i){
            ans = Math.min(ans, i*C + Math.max(0,X-i/2)*A + Math.max(0,Y-i/2)*B);
        }
        System.out.println(ans);


    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
typedef struct pair<int,int> P;
int p[1001]={};
int x[1001]={};
int y[1001]={};

int dp[9][(1<<8)]={};
vector<int> v;
int n,m,s;
int d[201][201];
int r[201]={};


//int calc(int s1,int d1){
//	if(dp[s1][d1]>0)return dp[s1][d1];
//	if(d1==(1<<s1))return 0;
//	int d2=d1-(1<<s1);
//	dp[s1][d1]=200000001;
//	for(int i=0;i<s;++i){
//		int k=(1<<i);
//		if((d2&k)==k)dp[s1][d1]=min(dp[s1][d1],d[r[s1]][r[i]]+calc(i,d2));
//	}
//	return dp[s1][d1];
//}
int main() {
	int n;

	cin>>n;
	ll a[100001]={};

	ll b=0;
	ll c=0;
	int b2=0;
	ll b3=0;

	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;++i){
		if(b3<a[i]){
			if(b2>1){
				c=b;
				b=b3;
				if(b2>3)c=b;
			}
			b3=a[i];
			b2=1;
		}else{
			b2++;
		}
	}
	if(b2>1){
		c=b;
		b=b3;
	}
	if(b2>3)c=b;
	cout<<b*c<<endl;
	return 0;
}


Measured memory_bytes: 1024
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Bulletin Board
 */

#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 */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", (n - h + 1) * (n - w + 1));
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())
dic={}
sum=0
for i in range(N):
    s=list(input())
    s.sort()
    s = "".join(s)
    if s in dic:
        sum+=dic[s]
        dic[s]+=1
    else:
        dic[s]=1
print(sum)

Measured memory_bytes: 57820
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  char c = s.back();
  string ans;
  if(c=='3'){
    ans = "bon";
  }else if(c=='0'||c=='1'||c=='6'||c=='8'){
    ans = "pon";
  }else{
    ans = "hon";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  string A;
  cin >> A;
  map<char, ll> z;
  for (int i=0; i<(int)A.size(); i++) {
    if (z.count(A[i])) z[A[i]]++;
    else z[A[i]] = 1;
  }
  ll num = 0;
  for (auto p: z) {
    auto value = p.second;
    num += value*(value-1)/2;
  }
  cout << (ll)A.size()*(A.size()-1)/2-num+1 << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    string sa,sb,sc;
    cin >> sa >> sb >> sc;

    queue<char> a,b,c;
    for(int i=0;i<max(sa.size(),max(sb.size(),sc.size()));i++){
        if(i<sa.size())
            a.push(sa[i]);
        if(i<sb.size())
            b.push(sb[i]);
        if(i<sc.size())
            c.push(sc[i]);
    }

    char winner,turn=a.front();
    a.pop();
    while(1){
        if(turn=='a'){
            if(a.size()==0){
                winner='A';
                break;
            }
            turn=a.front();
            a.pop();
            continue;
        }else if(turn=='b'){
            if(b.size()==0){
                winner='B';
                break;
            }
            turn=b.front();
            b.pop();
            continue;
        }else{
            if(c.size()==0){
                winner='C';
                break;
            }
            turn=c.front();
            c.pop();
            continue;
        }
    }

    cout << winner << endl;

    return 0;
}


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

int main(){
    char s[6];
    int num[2] = {};
    for(int i = 0;i < 6;i++){
        cin >> s[i];
        num[(s[i]-'0')] += 1;
    }
    cout << num[1] << endl; 
}

Measured memory_bytes: 256
// ABC101C - Minimization

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	int ans;
	ans = ((N - K) + (K - 2))/ (K - 1) + 1;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
def myprint(a,b):
    for i in range(1,7):
        if(a//10**i==0):
            keta_a=i
            break
    for i in range(1,7):
        if(b//10**i==0):
            keta_b=i
            break
    
    print("{}{}{}{}".format("0"*(6-keta_a),a,"0"*(6-keta_b),b))


n,m=map(int,input().split())
data=[{} for i in range(n+1)]
out=[[0,0] for i in range(m)]
for i in range(m):
    p,y=map(int,input().split())
    data[p][i]=y



for i in range(1,n+1):
    tmp=sorted(data[i].items(),key=lambda x:x[1])
    num=1
    for k in tmp:
        out[k[0]][0]=i
        out[k[0]][1]=num
        num+=1

for o in out:
    myprint(o[0],o[1])

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

using namespace std;
typedef long long unsigned int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int x; cin >> x;
    int a; cin >> a;
    int ans;
    if (x < a){
        ans = 0;
    } else {
        ans = 10;
    }
    cout << ans << endl;
    return 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

ld calc(ll v) {
  ll sum = 0;
  ll tmp = v;
  while (tmp) {
    sum += tmp % 10;
    tmp /= 10;
  }
  return (ld)v / (ld)sum;
}

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

  ll k;
  cin >> k;

  const ld eps = 1e-16;

  vll ans;
  ans.push_back(1e15 - 1);
  ld mn = calc(1e15 - 1);
  ll v = 1e15 - 1;
  while (v) {
    ll keta = 1;
    while (keta * 100000 < v) {
      keta *= 10;
    }
    v -= keta;
    if (v == 0)
      break;
    ld c = calc(v);
    if (c <= mn + eps) {
      mn = c;
      ans.push_back(v);
    }
  }

  reverse(all(ans));
  rep(i, k) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

using namespace std;

int main()
{
	int N;
	int M;
	vector<int> A;

	cin >> N;
	cin >> M;

	int num;
	for (int i = 0; i < M; i++)
	{
		cin >> num;
		A.push_back(num);
	}

	int count = 0;
	for (int x : A)
	{
		count += x;
	}

	int ans = N - count;
	
	if (ans >= 0)
	{
		cout << ans;
	}
	else
	{
		cout << -1;
	}
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	string s;
	cin >> n >> s;
	vll l(n+1),r(n+1);
	rep(i,n){
		if(s[i]=='#') l[i+1]=1;
		if(s[n-i-1]=='.') r[n-i-1]++;
		r[n-i-1]+=r[n-i];
		l[i+1]+=l[i];
	}
	ll ans=INF;
	rep(i,n){
		chmin(ans,l[i]+r[i+1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3844