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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int a[3] = {0, };
	for(int i=0; i<2; i++) {
		int t;
		cin >> t;
		a[t-1] = 1;
	}
	for(int i=0; i<3; i++) {
		if(!a[i])
			cout << i+1;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
void CardGameforTwo() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int a = 0, b= 0;
	for (size_t i = 0; i < N; i++)
	{
		if (i % 2 == 0) {
			a += v[N - 1 - i];
		}
		else {
			b += v[N - 1 - i];
		}
	}
	cout << (a - b) << endl;
}

int main() {
	CardGameforTwo();
	return 0;
}

Measured memory_bytes: 256
right = input()
Q = int(input())
flag = 1
left = ""
for i in range(Q):
  q = input()
  if q == "1":
    flag = 1-flag
    continue
  m,f,c = q.split(" ")
  f = int(f)
  left += c*(1-flag)*(f-1)
  right += c*flag*(f-1)
  left += c*flag*(2-f)
  right += c*(1-flag)*(2-f)
if flag == 1:
  print(left[::-1]+right)
else:
  print(right[::-1]+left)

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

vector<vector<int>> v(100010);
ll mod = 1e9+7;
ll dp[100010][2];

void dfs(int p, int pre){
    ll ret1=1, ret2=1;
    for(auto i:v[p]){
        if(i!=pre){
            dfs(i,p);
            ll res1=0, res2=0;
            res1 = (dp[i][1] + dp[i][0]) % mod;
            res2 = dp[i][0];
            ret1 = (ret1 * res1) % mod;
            ret2 = (ret2 * res2) % mod;
        }
    }
    dp[p][0] = ret1;
    dp[p][1] = ret2;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n;
    cin>>n;
    int p = 0;
    for(int i=1;i<n;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        v[x].push_back(y);
        v[y].push_back(x);
        if(v[y].size()==1) p = y;
        if(v[x].size()==1) p = x;
    }
    dfs(p,-1);
    dfs(p,-1);
    ll ans = dp[p][0] + dp[p][1];
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 13440
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let s = readLine()!
    let t = readLine()!
    var counter = 0
    for (i, j) in zip(s, t) {
        if (i != j) {
            counter += 1
        }
    }
    print(counter)
}
main()


Measured memory_bytes: 13436
#include <stdio.h>
#define S 30

char s[S];


int main(void){
	int i,j;
	for(i=0;i<S-2;i++)
		scanf("%d",&j),s[j-1]=1;
	for(i=0;i<S;i++)
		if(!s[i])printf("%d\n",i+1);
	return 0;
}

Measured memory_bytes: 596
import math


if __name__ == "__main__":
    coords = list(map(float, input().split()))

    x1 = coords[0]
    y1 = coords[1]
    x2 = coords[2]
    y2 = coords[3]

    distance = math.hypot(abs(x1 - x2), abs(y1 - y2))

    print(distance)



Measured memory_bytes: 5640
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    int64_t n, m, k;
    cin >> n >> m >> k;
    vector<int64_t> a(n + 1, 0);
    vector<int64_t> b(m + 1, 0);

    rep(i, n)
    {
        int64_t aa;
        cin >> aa;
        a[i + 1] += a[i] + aa;
    }

    rep(i, m)
    {
        int64_t bb;
        cin >> bb;
        b[i + 1] += b[i] + bb;
    }
    int ans = 0;
    rep(i, n + 1)
    {
        auto rest = k - a[i];
        if(rest < 0) 
        {
            break;
        }
        auto tb = upper_bound(b.begin(), b.end(), rest);
        auto bcount = (int)(tb - b.begin()) - 1;
//        cout << "i: " << i << ", bcount: " << bcount << endl;
        ans = max(ans, i + bcount);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    ll s;
    cin >> s;
    ll x1 = 0, y1 = 0;
    ll x2 = 1e9, y2 = 1;
    ll x3,y3;
    if(s >= 1e9){
        y3 = (s+x2-1) / x2;
        x3 = abs(s - y3 * x2);
    }
    else
    {
        y3 = 0;
        x3 = s;
    }
    printf("%lld %lld %lld %lld %lld %lld", x1, y1, x2, y2, x3, y3);
}

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

int main(){
    ll n;
    cin >> n;
    ll a,b;
    vector<pair<ll,ll>> p;
    for(ll i=0;i<n;i++){
        cin >> a >> b;
        p.push_back(make_pair(b,a));
    }
    ll x,y,la=0,temp=0;
    sort(p.begin(),p.end());
    for(ll i=0;i<n;i++){
        x = p[i].first;
        y = p[i].second;
        temp=(x-la+temp)-y;
        la = x;
        if(temp<0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 6512
L, R = map(int, input().split())
MOD = 2019
l = L % MOD
r = R % MOD
ans = 2019

if l >= r or (R - L) >= 2019:
    ans = 0
else:
    for i in range(l, r):
        for j in range(l + 1, r + 1):
            if j <= i:
                continue
            else:
                ans = min(ans, i * j % MOD)

print(ans)


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

int main(){
  int n, k;
  cin >> n >> k;
  int ans = k;
  rep (i, n-1){
    ans *= (k-1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  cout << b / x - (a == 0 ? -1 : (a - 1) / x) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10

int main() {

	int n;
	cin >> n;
	int point[128];
	memset(point, 0, sizeof(point));
	for (int i = 0; i < n * (n - 1) / 2; ++i) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if (c == d) { point[a]++; point[b]++; }
		else if (c > d) { point[a] += 3; }
		else { point[b] += 3; }
	}

	for (int i = 1; i <= n; ++i) {
		int ans = 1;
		for (int i2 = 1; i2 <= n; ++i2) {
			if (point[i] < point[i2]) { ans++; }
		}
		cout << ans << endl;
	}

	return 0;
}

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

int c[33], s[444][33];
int sco(int t, const vector<int> &v) {
    int r = 0, l = 0, d = v.size();
    for(int i = 0; i < d; i++)
        if(v[i] == t)
            r += s[i][t] - c[t] * (i + 1 - l) * (i - l) / 2, l = i + 1;
    r -= c[t] * (d + 1 - l) * (d - l) / 2;
    return r;
}
int main() {
    auto ti = clock();
    int d;
    cin >> d;
    for(int i = 0; i < 26; i++)
        cin >> c[i];
    for(int i = 0; i < d; i++)
        for(int j = 0; j < 26; j++)
            cin >> s[i][j];
    vector<int> ss, tt;
    int M = -1e9;
    for(int a = 10; a < 16; a++) {
        for(int b = 0; b < 4; b++) {
            for(int z = 5; z < 16; z++) {
                int r = 0, l[33] = {};
                ss.clear();
                for(int i = 0; i < d; i++) {
                    auto m = 0.;
                    int t = 0;
                    for(int j = 0; j < 26; j++) {
                        double p = s[i][j];
                        p += c[j] * (i + 1 - l[j]) * .4 * a;
                        for(int k = 1; k < z; k++)
                            if(i + k < d)
                                p -= s[i + k][j] * (z - k) * .05 / z * b;
                        if(p > m)
                            m = p, t = j;
                    }
                    ss.push_back(t);
                    r -= c[t] * (i + 1 - l[t]) * (i - l[t]) / 2;
                    l[t] = i + 1;
                    r += s[i][t];
                }
                for(int j = 0; j < 26; j++)
                    r -= c[j] * (d + 1 - l[j]) * (d - l[j]) / 2;
                if(r > M)
                    M = r, tt.swap(ss);
            }
        }
    }
    random_device rd;
    mt19937 mt(rd());
    uniform_int_distribution<> rc(0, 25), r0(0, d - 1), r2(1, 6);
    pair<int, vector<int>> MM[32] = {};
    MM[0] = {M, tt};
    int cnt = 0, B = 1;
    for(int cn = 0;
        cn < 100 || (cn = 0, (clock() - ti + 0.) / CLOCKS_PER_SEC < 1.9);
        cn++, cnt++) {
        for(int b = 0; b < B; b++) {
            MM[b + B] = MM[b];
            auto &tt = MM[b].second, &uu = MM[b + B].second;
            if(rc(mt) < 12) {
                int x0 = r0(mt), xc = rc(mt);
                uu[x0] = xc;
                MM[b + B].first += sco(tt[x0], uu) + sco(xc, uu) -
                                   sco(tt[x0], tt) - sco(xc, tt);
                continue;
            }
            int x2 = r2(mt);
            uniform_int_distribution<> r1(0, d - 1 - x2);
            int x1 = r1(mt);
            x2 += x1;
            swap(uu[x1], uu[x2]);
            MM[b + B].first += sco(tt[x1], uu) + sco(tt[x2], uu) -
                               sco(tt[x1], tt) - sco(tt[x2], tt);
        }
        sort(MM, MM + B + B, greater<>());
        B = min(int(unique(MM, MM + B + B) - MM), 16);
    }
    for(int i = 0; i < 16; i++)
        cerr << MM[i].first << ' ';
    cerr << endl;
    tt = MM[0].second, M = MM[0].first;
    int S = 0;
    for(int j = 0; j < 26; j++)
        S += sco(j, tt);
    assert(S == M);
    for(int i : tt)
        cout << i + 1 << '\n';
    cerr << M << endl;
    cerr << cnt << endl;
    return 0;
}


Measured memory_bytes: 3764
from collections import deque

H, W, *S = open(0).read().split()
H, W, S = int(H), int(W), [list(s) for s in S]

white = sum(s.count(".") for s in S)

Q = deque([(0, 0, 1)])
while Q:
    h, w, count = Q.popleft()
    if (h, w) == (H - 1, W - 1):
        print(white - count)
        quit()

    for nh, nw in [(h, w + 1), (h, w - 1), (h + 1, w), (h - 1, w)]:
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == ".":
            S[nh][nw] = "visited"
            Q.append((nh, nw, count + 1))
print(-1)

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

template<typename T>
struct edge {
    int src, to;
    T cost;
};

template<typename T>
using Graph = vector<vector<edge<T>>>;

using State = string::const_iterator;



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

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    int H, W; cin >> H >> W;
    vector<string> S(H);
    map<char,int> dir;
    dir['R'] = 0;
    dir['U'] = 1;
    dir['L'] = 2;
    dir['D'] = 3;
    string dirs = "RULD";
    int sd, si, sj;
    int leaves = 0;
    REP(i, H) {
        cin >> S[i];
        REP(j, W) {
            if (dir.count(S[i][j])) {
                sd = dir[S[i][j]], si = i, sj = j;
                S[i][j] = '.';
            }
            if (S[i][j] == 'o') ++leaves;
        }
    }

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

    function<string(int,int,int,int,vector<string>&)> dfs = [&](int i, int j, int d, int res, vector<string>& s) {
        if (res == 0) return string();
        REP(k, 4) {
            if (k == (d + 2) % 4) continue;
            int ny = i, nx = j;
            while (0 <= ny and ny < H and
                   0 <= nx and nx < W and
                   s[ny][nx] == '.') {
                ny += dy[k], nx += dx[k];
            }
            if (ny < 0 or nx < 0 or H <= ny or W <= nx or s[ny][nx] != 'o') continue;
            s[ny][nx] = '.';
            string ret = dfs(ny, nx, k, res - 1, s);
            s[ny][nx] = 'o';
            if (ret != "#") return dirs[k] + ret;
        }
        return string("#");
    };

    cout << dfs(si, sj, sd, leaves, S) << endl;

    return 0;
}




Measured memory_bytes: 3240
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

bool isFavourite(long long int n,long long int factor){
	long long int m = factor-1;
	if(m==0)
		return false;
	if((n/m)*(m+1) == n)
		return true;
	else
		return false;
}

int main() {
	// your code goes here
	long long int n, i,ans;
	cin >>n;
	long long int sum = 0;
	for(i=1;i*i<=n;i++){

		if(n%i==0){
			if(n/i==i){
				// i is a factor
				if(isFavourite(n,i)){
					sum+=i-1;
				}
			}
			else{
				// i and n/i are factors
				if(isFavourite(n,i)){
					sum+=i-1;
				}
				if(isFavourite(n,n/i)){
					sum+=n/i - 1;
				}
			}
		}
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int X, Y, Z; cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, L = 1;
  cin >> N >> K;
 
  for (int i = 0; i < N; i++) {
    if (L * 2 >= L + K) L += K;
    else L *= 2;
  }
  cout << L << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int s,t;
ll comb[2010][2010],prec[2010][2010],prec2[2010][2010],ret=1;
ll choose(int len,int rem) {
	if (rem==0||rem==len) return 1;
	else {
		ll w=0;
		int emp=len-rem;
		int d=min(emp,rem-1);
//		rep(j,0,d+1) w=(w+(comb[rem-1][j])*(emp+1-j))%mod;
		w=(emp+1)*prec[rem-1][d]-prec2[rem-1][d];
		return w%mod;
	}
}
int main() {
	scanf("%d%d",&s,&t);
	comb[0][0]=1;
	prec[0][0]=1;
	prec2[0][0]=0;
	rep(i,1,t+1) {
		comb[i][0]=comb[i][i]=1;
		rep(j,1,i) {
			comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
			if (comb[i][j]>=mod) comb[i][j]-=mod;
		}
		prec[i][0]=1,prec2[i][0]=0;
		rep(j,1,i+1) {
			prec[i][j]=(prec[i][j-1]+comb[i][j])%mod;
			prec2[i][j]=(prec2[i][j-1]+comb[i][j]*j)%mod;
		}
	}
	rep(i,0,s) rep(j,1,t+1) {
		int len=(s-i),rem=(t-j);
		if (rem>len) continue;
//		printf("%d %d %d %d %lld\n",i,j,len,rem,choose(len,rem));
		ret=(ret+comb[t-1][j-1]*choose(len,rem))%mod;
	}
	if (ret<0) ret+=mod;
	printf("%lld\n",ret);
}


Measured memory_bytes: 93312
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B;
	//int max;

	cin >> A >> B;
	int max = A + B;

	int sub = A - B;
	if (sub > max)
	{
		max = sub;
	}

	int mat = A * B;
	if (mat > max)
	{
		max = mat;
	}

	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = 3.1415926535897932384626;
const int SIZE = 1 << 17;

int main() {
	int a, b, k[100005], l[100005], m[100005], mon = 0;
	cin >> a;
	for (int i = 0; i < a; ++i) { cin >> k[i]; mon += k[i]; }
	cin >> b;
	for (int i = 0; i < b; ++i) { cin >> l[i] >> m[i]; }
	for (int i = 0; i < b; ++i) {
		cout << mon - k[l[i] - 1] + m[i] << endl;
	}
}

Measured memory_bytes: 256
# square869120Contest #4
# B - Buildings are Colorful!
# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b
N, K = map(int, input().split())
*A, = map(int, input().split())

ans = float('inf')
for bit in range(2**N):
    cnt = 0
    for i in range(N):
        if bit >> i & 1:
            cnt += 1
    if cnt < K:
        continue

    cost = 0
    maxh = 0
    for i, a in enumerate(A):
        if bit >> i & 1 and maxh >= a:
            cost += maxh - a + 1
            maxh += 1
        elif maxh < a:
            maxh = a


    if cost < ans:
        ans = cost


print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll z = *x;
  *x = *y;
  *y = z;
}
void print(vector<ll> vec){
  ll length = (ll)vec.size();
  rep(i,length){
    if(i != 0){cout << " ";}
    cout << vec[i];
  }
  cout << endl;
}

int main(){
  ll n,k,q;
  cin >> n >> k >> q;
  vector<ll> a(q);
  vector<ll> score(n,k-q);
  rep(i,q) {
    cin >> a[i];
  }
  rep(i,q){
    score[a[i]-1]++;
  }
  rep(i,n){
    if(score[i] > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MAX_N = 2123456;

LL A[MAX_N] = {};
LL B[MAX_N] = {};
LL C[MAX_N] = {};

template<typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

LL solve(int k, string S){
    LL res = 0;
    int n = S.length();
    REP(i,n){
        if(S[i] == 'D'){
            res += B[i+k] - B[i] - C[i] * (A[i+k]-A[i]);
            dump(res)

        }
    }
    return res;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    string S; cin >> S;
    int Q; cin >> Q;
    VI k(Q); REP(i,Q) cin >> k[i];

    REP(i,N){
        if(S[i] == 'C') A[i+1] = A[i] + 1;
        else A[i+1] = A[i];
    }
    REP(i,N){
        if(S[i] == 'M') C[i+1] = C[i] + 1;
        else C[i+1] = C[i];
    }
    REP(i,N){
        if(S[i] == 'C'){
            B[i+1] = B[i] + C[i+1];
        }else{
            B[i+1] = B[i];
        }
    }

    FOR(i,N+1,MAX_N){
        B[i] = B[i-1];
        A[i] = A[i-1];
        C[i] = C[i-1];
    }


    //print_array(A,20);
    //print_array(B,20);
    //print_array(C,20);


    REP(i,Q){
        cout << solve(k[i], S) << endl;
    }

}


Measured memory_bytes: 52124
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
LL a,b;
int main()
{
	cin>>a>>b;
	if(a*500>=b)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int n;
int a[N];

bool stg()
{
    map<int, int> mp;
    vector<int> v;
    for (int i = 1; i <= n; ++i)
    {
        mp[a[i]]++;
    }
    if (mp.size() > 3)
    {
        return false;
    }
    if (mp.size() == 2)
    {
        if ((mp.begin())->first == 0)
        {
            if ((mp.begin())->second * 2 == (--mp.end())->second)
                return true;
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        int maxu = -1, maxi = 0;
        for (map<int, int>::iterator it = mp.begin(); it != mp.end(); ++it)
        {
            if (it->second > maxu)
            {
                maxu = it->second;
                maxi = it->first;
            }
        }
        a[i] = maxi;
        mp[a[i]]--;
    }
    for (int i = 1; i <= n; ++i)
    {
        if (i == 1)
        {
            if ((a[n] ^ a[i + 1]) != a[i])
                return false;
        }
        else if (i == n)
        {
            if ((a[1] ^ a[i - 1]) != a[i])
                return false;
        }
        else
        {
            if ((a[i - 1] ^ a[i + 1]) != a[i])
                return false;
        }
    }
    return true;
}

bool stg0()
{
    sort(a + 1, a + n + 1);
    do
    {
        bool z = true;
        for (int i = 1; i <= n; ++i)
        {
            if (i == 1)
            {
                if ((a[n] ^ a[i + 1]) != a[i])
                {
                    z = false;
                    break;
                }
            }
            else if (i == n)
            {
                if ((a[1] ^ a[i - 1]) != a[i])
                {
                    z = false;
                    break;
                }
            }
            else
            {
                if ((a[i - 1] ^ a[i + 1]) != a[i])
                {
                    z = false;
                    break;
                }
            }
        }
        if (z)
            return true;
    } while (a + 1, a + n + 1);
    return false;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    if (stg())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
    while (1)
    {
        n = 5;
        for (int i = 1; i <= n; ++i)
        {
            a[i] = (rand() % 16);
        }
        if (stg() != stg0())
            cout << "WA" << endl;
    }
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>

int main() {
	int n;
	std::cin >> n;
	double *v = new double[n];
	for (int i = 0; i < n; i++)std::cin >> v[i];
	std::sort(v, &v[n]);
	for (int i = 1; i < n; i++) {
		v[0] = (v[0] + v[i]) / 2;
	}
	printf("%lf\n", v[0]);
}

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

#define FOR(i, a, b) for(int i=(int)a; i < (int)b; ++i)
#define REP(i, n) FOR(i,0,n)
#define RFOR(i, a, b) for(int i=(int)b-1; i >= (int)a; --i)
#define RREP(i, n) RFOR(i,0,n)
#define IN(a,x,b) (a<=x && x < b)
template<class T> inline void chmax(T& a, const T& b){if(a<b) a = b;}
template<class T> inline void chmin(T& a, const T& b){if(a>b) a = b;}

using namespace std;
using ll = long long;
template<class T> using V = std::vector<T>;
template<class T> using VV = V<V<T>>;

string s;
int N;

signed main(){
  while(cin>>s>>N){
    if(s=="0"&&N==0)break;
    vector<int>a(21);
    a[0] = stoll(s);
    REP(i,20){
      s = to_string(a[i]);
      int sz = s.size();
      REP(i,N-sz)s='0'+s;
      sort(s.begin(),s.end());
      int mi = stoll(s);
      reverse(s.begin(),s.end());
      int ma = stoll(s);
      a[i+1] = ma - mi;
      //cout<<a[i+1]<<endl;
    }

    int flg = 1;
    FOR(i,0,21){
      FOR(j,0,i){
        if(a[i] == a[j]){
          cout<<j<<" "<<a[i]<<" "<<i-j<<endl;
          flg = 0;
        }
        if(flg == 0)break;
      }
      if(flg == 0)break;
    }
  }
  return 0;
}



Measured memory_bytes: 3144
#include <iostream>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)

int main() {
  string n;
  cin>>n;
  
  rep(i,0,3){
    if(n[i]=='7'){cout<<"Yes"<<endl;return 0;}
  }

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

Measured memory_bytes: 3628
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
	
		int N = Integer.parseInt(sc.next());
		//int K = Integer.parseInt(sc.next());
		//char[] c = sc.next().toCharArray();
		int MM = N%100;
		int YY = N/100;
		boolean YY_flag;
		boolean MM_flag;
		if(YY == 0 || (13<=YY && YY<= 99) ){
			YY_flag = true;//YY確定
		}else{
			YY_flag = false;
		}
		
		if(1<=MM && MM<=12){
			MM_flag = true;
		}else{
			MM_flag = false;//MM不確定
		}
		
		if(YY_flag){
			if(MM_flag){
				System.out.println("YYMM");
			}else{
				System.out.println("NA");
			}
		}else{
			if(MM_flag){
				System.out.println("AMBIGUOUS");
			}else{
				System.out.println("MMYY");
			}
		}
		
		
		sc.close();
	}
	
	
	
}

Measured memory_bytes: 23764
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<String> list = nextCharArray();
      int output = 0;
      for(int i = 0; i < list.size(); i++){
        output += (list.get(i).equals("+")) ? 1 : -1;
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33080
str = gets.chomp.split(' ').map(&:to_i)
if str[0] == str[1] && str[0] != str[2]
  puts "Yes"
elsif str[0] == str[2] && str[0] != str[1]
  puts "Yes"
elsif str[1] == str[2] && str[0] != str[1]
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;


void ABC157E()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	vector<set<int> > alp(26);
	for (int i = 0; i < N; ++i)
	{
		int x = S[i] - 'a';
		alp[x].insert(i+1);
	}

	int q;
	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		int x;
		cin >> x;
		if (x == 1)
		{
			int y; char z;
			cin >> y >> z;
			int p = S[y-1] - 'a';
			int q = z - 'a';
			alp[p].erase(y);
			alp[q].insert(y);
			S[y - 1] = z;
		}
		else
		{
			int y, z;
			cin >> y >> z;
			int sum = 0;
			for (int j = 0; j < 26; ++j)
			{
				auto p = alp[j].lower_bound(y);
				if (p != alp[j].cend() && *p <= z)
					++sum;
			}
			cout << sum << endl;
		}
	}

}

int main()
{
	ABC157E();
	return 0;
}


Measured memory_bytes: 24196
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int C, N, M;
    cin >> C >> N >> M;
    // dp[i] := size i で買える組み合わせの価値最大値
    vector<ll> dp(C + 1, 0);
    vector<int> s(N), p(N);
    for (int i = 0; i < N; i++)
    {
        cin >> s[i] >> p[i];
        for (int j = C; j >= s[i]; j--)
        {
            dp[j] = max(dp[j], dp[j - s[i]] + p[i]);
        }
    }
    for(int i=1;i<=C;i++){
        dp[i] = max(dp[i], dp[i-1]);
    }
    for(int i=1;i<=M;i++){
        cout<<dp[C/i]*i<<endl;
    }
}



Measured memory_bytes: 3288
#include<stdio.h>

void maxheap(int);
void swap(int,int);
int num;
int array[2000001];

int main(){

   int i;
  scanf("%d",&num);
  for(i = 1;i <= num;i++){
    scanf("%d",&array[i]);
  }
  for(i = num / 2;i >= 1;i--){
    maxheap(i);
  }
  for(i = 1;i <= num;i++){
    printf(" %d",array[i]);
  }
  printf("\n");
  return 0;
}

void maxheap(int i){
  int left = 0;
  int right = 0;
  int largest = 0;
  int change;

  left = 2 * i;
  right = 2 * i + 1;

  if(left <= num && array[left] > array[i]){
    largest = left;
  }
  else{
    largest = i;
  }
  if(right <= num && array[right] > array[largest]){
    largest = right;
  }
  if(largest != i){
    change=array[i];
    array[i]=array[largest];
    array[largest]=change;
    maxheap(largest);
  }
}



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

int main(){
    string S = ".", tmp;
    cin >> tmp;
    int N = tmp.size();
    S += tmp;
    for (int i=1;i<N;i++){
        if(S[i] == S[i+1]){ 
            cout << i << " " << i+1 << endl;
            return 0;
        } else if(i <= N-2 && S[i] == S[i+2]) {
            cout << i << " " << i+2 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
N,M=(int(i) for i in input().split())
a=[[int(i),1] for i in input().split()]

for i in range(M):
    b,c=(int(i) for i in input().split())
    a.append([c,b])
    

a=sorted(a,key=lambda x:x[0],reverse=True)
answer=0
i=0
n=0
while True:
    answer+=a[i][0]*a[i][1]
    i+=1
    n+=a[i-1][1]
    if n>=N:
        answer-=a[i-1][0]*(n-N)
        break
print(answer)

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

using namespace std;

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

uint64_t gcd(uint64_t a, uint64_t b){
  return b == 0 ? a : gcd(b, a % b);
}

int main(){
  uint64_t a, b;
  cin >> a >> b;
  uint64_t g = gcd(a, b);
  int r = 1;
  for(uint64_t n = 2; n * n <= g; ++n){
    if(g % n == 0){
      ++r;
      while(g % n == 0) g /= n;
    }
  }
  if(g != 1) ++r;
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 384
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
    
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  for(var i = 0, len = input.length - 1; i < len; i++){
    console.log(primeNumbers[input[i] - 0]);
  }
   
     
}
   
function calcPrimeNumbers(){
  var max = 999999;
  var primeNumbers = new Int8Array(max + 1);
   
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
       
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
   
  var primeNums = new Int32Array(max + 1);
   for(var i = 1; i <= max; i++){
    primeNums[i] += primeNums[i-1] + 1 - primeNumbers[i];
  }
     
  return primeNums;
}

Measured memory_bytes: 13640
#include <stdio.h>
#include <math.h>

int main(){
  int H,W,i,j,k;

  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0){
      break;
    }

    for(i = 0;i < H;i++){
      if(i == 0 || i == H - 1){

	for(k = 0;k < W;k++){
	  printf("#");
	}
	printf("\n");
	  }
      else{
	for(j = 0;j < W;j++){
	  if(j == 0 || j == W - 1){
	    printf("#");
	  }
	  else{
	    printf(".");
	  }
	}
	printf("\n");
      }
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 572
const lines=[];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
    const input = (lines[0] as string).split(" ");
    const a = +input[0];
    if (a == 25) {console.log("Christmas");} 
    if (a == 24) {console.log("Christmas Eve");} 
    if (a == 23) {console.log("Christmas Eve Eve");} 
    if (a == 22) {console.log("Christmas Eve Eve Eve");} 
});

Measured memory_bytes: 7500
import java.util.*;
import java.lang.*;
import java.io.*;

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

	int[] data = new int[3];
	int[] MAX = new int[3];
	int max = 0;
	int tmp = 0;
	Scanner sc = new Scanner (System.in);
		data[0]=sc.nextInt();
		data[1]=sc.nextInt();
		data[2]=sc.nextInt();

	MAX[0] = data[0]*10 + data[1] + data[2];
	MAX[1] = data[0] + data[1]*10 + data[2];
	MAX[2] = data[0] + data[1] + data[2]*10;

	for(int i = 0; i < MAX.length; i++)
		max = Math.max(max,MAX[i]);

		System.out.println(max);

  }

}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  VI r1(26, -1), r2(26, -1);
  bool ans = true;
  rep(i, s.size()) {
    int idx = s[i] - 'a';
    if(r1[idx] < 0) r1[idx] = (t[i] - 'a');
    else if(r1[idx] != t[i] - 'a') ans = false;
  }
  rep(i, t.size()) {
    int idx = t[i] - 'a';
    if(r2[idx] < 0) r2[idx] = (s[i] - 'a');
    else if(r2[idx] != s[i] - 'a') ans = false;
  }
  ans ? out("Yes") : out("No");
  return 0;
}


Measured memory_bytes: 916
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cstdlib>
#define ll long long
#define lowbit(x) (x&(-x))
using namespace std;

ll ans,n,k,h[200007];

bool cmp(ll a,ll b){
    return a>b;
}

int main(){
    scanf("%lld%lld",&n,&k);
    for (int i=1;i<=n;++i) scanf("%lld",&h[i]);
    sort(h+1,h+n+1,cmp);
    for (int i=k+1;i<=n;++i) ans+=h[i];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
n,a,b,c = map(int, input().split())
a = min(a, 4)
b = min(b, 4)
c = min(c, 4)

s = [input() for i in range(n)]

DP = [set() for i in range(n+1)]
DP[0].add((a,b,c))
for i in range(n):
    for x,y,z in DP[i]:
        if s[i] == "AB":
            nz = z

            nx = x+1
            ny = y-1
            if ny >= 0:
                DP[i+1].add((nx,ny,nz))
            nx = x-1
            ny = y+1
            if nx >= 0:
                DP[i+1].add((nx,ny,nz))
        elif s[i] == "BC":
            nx = x

            ny = y+1
            nz = z-1
            if nz >= 0:
                DP[i+1].add((nx,ny,nz))
            ny = y-1
            nz = z+1
            if ny >= 0:
                DP[i+1].add((nx,ny,nz))
        else:
            ny = y

            nz = z+1
            nx = x-1
            if nx>=0:
                DP[i+1].add((nx,ny,nz))
            nz = z-1
            nx = x+1
            if nz >=0:
                DP[i+1].add((nx,ny,nz))

if len(DP[-1]) == 0:
    print("No")
    exit()
ans = []
tmp = list(DP[-1])[0]
for i in range(n):
    x,y,z = tmp
    j = n-1-i
    if s[j] == "AB":
        nz = z

        nx = x+1
        ny = y-1
        if (nx,ny,nz) in DP[j]:
            tmp = (nx,ny,nz)
            ans.append("B")
            continue
        nx = x-1
        ny = y+1
        if (nx,ny,nz) in DP[j]:
            tmp = (nx,ny,nz)
            ans.append("A")
            continue
    elif s[j] == "BC":
        nx = x

        ny = y+1
        nz = z-1
        if (nx,ny,nz) in DP[j]:
            tmp = (nx,ny,nz)
            ans.append("C")
            continue
        ny = y-1
        nz = z+1
        if (nx,ny,nz) in DP[j]:
            tmp = (nx,ny,nz)
            ans.append("B")
            continue
    else:
        ny = y

        nz = z+1
        nx = x-1
        if (nx,ny,nz) in DP[j]:
            tmp = (nx,ny,nz)
            ans.append("A")
            continue
        nz = z-1
        nx = x+1
        if (nx,ny,nz) in DP[j]:
            tmp = (nx,ny,nz)
            ans.append("C")
            continue

ans = ans[::-1]
print("Yes")
print(*ans, sep="\n")


Measured memory_bytes: 378156
import java.util.*;
import java.io.*;
import java.math.*;

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

	void run() {
		Scanner sc = new Scanner();
		String s = sc.next();
		int n = s.length();
		long cntW = 0;
		for (int i = 0; i < n; ++i) {
			if (s.charAt(i) == 'W')
				++cntW;
		}
		if (cntW == 0) {
			System.out.println(0);
			return;
		}
		long ans = -cntW * (cntW - 1) / 2;
		for (int i = 0; i < n; ++i) {
			if (s.charAt(i) == 'W') {
				ans += i;
			}
		}
		System.out.println(ans);
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

}

class Scanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}
}


Measured memory_bytes: 24404
k = gets.to_i
x,y = gets.split.map(&:to_i)

sx = x < 0 ? -1 : 1
sy = y < 0 ? -1 : 1
x,y = x.abs,y.abs

isSwap = false
if x > y
  x,y = y,x
  isSwap = true
end

if k.even? && (x+y).odd?
  p -1
  exit
end

ans = []
if (x+y) < k && (x+y) % 2 == 1
  d = (k*3-(x+y))/2
  ans << [-(d/2),k-(d/2)]
  ans << [k-d,k-d]
  ans << [x,y]
elsif x+y == k
  ans << [x,y]
else
  n = ((x+y)/k.to_f).ceil
  if (x+y) < k
    n = 2
  elsif n*k % 2 != (x+y) % 2
    n += 1
  end
  a = (x+y-n*k)/2
  b = a+k
  ans << [a,b]
  while [a,b] != [x,y]
    if x-a < k
      b += k-(x-a)
      a = x
    elsif x != a
      a += k
    else
      b += k
    end
    ans << [a,b]
  end
end

p ans.length
ans.each do |x,y|
  x,y = y,x if isSwap
  puts "#{sx*x} #{sy*y}"
end


Measured memory_bytes: 18172
#include <stdio.h>
#include <iostream>
#include <time.h>
#include <math.h>
#include <map>
#include <algorithm>


using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int ans=0;
  for(int i=0; i<n; ++i){
    int h;
    cin>>h;
    if(h>=k) ++ans;
  }
  cout<<ans<<endl;
}

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

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            long S = Convert.ToInt64(Console.ReadLine());
            long xA = 0, yA = 0, xB, yB, xC, yC;
            xB = yC = Math.Sqrt(S)%1==0?(long)Math.Sqrt(S):(long)Math.Sqrt(S)+1;
            long t =xB * yC-S;
            if (t == 0)
            {
                xC = 0; yB = xB;
                Console.WriteLine(xA + " " + yA + " " + xB + " " + yB + " " + xC + " " + yC);
            }
            else
            {
                for (long i = (long)Math.Sqrt(t), l = 1; i >= 1; i--, l++)
                {
                    if (t % i == 0)
                    {
                        xC = i; yB = t / i;
                        Console.WriteLine(xA + " " + yA + " " + xB + " " + yB + " " + xC + " " + yC); return;
                    }
                    if (t % l == 0)
                    {
                        xC = l; yB = t / l;
                        Console.WriteLine(xA + " " + yA + " " + xB + " " + yB + " " + xC + " " + yC); return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

# define ll long long

int main()
{
	int n,k;
	cin >> n >>k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) { int a; cin >> a; h[i] = a; }
	vector<int> dp(n, 1000000);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
		for (int j = 2; j < min(i+1, k + 1); j++) {
			dp[i] = min(dp[i - j] + abs(h[i - j] - h[i]), dp[i]);
		}

	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 4048
#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    if(n>=100 && n<=111)
    printf("111\n");
    
    if(n>=112 && n<=222)
    printf("222\n");
    
    if(n>=223 && n<=333)
    printf("333\n");
    
    if(n>=334 && n<=444)
    printf("444\n");
    
    if(n>=445 && n<=555)
    printf("555\n");
    
    
    if(n>=556 && n<=666)
    printf("666\n");
    
    if(n>=667 && n<=777)
    printf("777\n");
    
    if(n>=778 && n<=888)
    printf("888\n");
    
    if(n>=889 && n<=999)
    printf("999\n");


return 0;


}

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

int main(void)
{
	long int i, j, index;
	long int n;
	long int sum;
	long int x[8];
	long int y[8];
	long int masu[8][8] = {{0}};
	double length = 0.0;
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld%ld", &x[i], &y[i]);
	}
	
	sum = 0;
	
	for(i = 0; i < n; i++) {
		for(j = 0; j < n; j++) {
			masu[i][j] = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
			length += sqrt(masu[i][j]);
		}
	}
	
	//length = sqrt(sum);
	
	length /= n;
	
	printf("%.8lf", length);
	
	return 0;
}


Measured memory_bytes: 128