akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  int k, x;
  cin >> k >> x;
  int tmp = x - k + 1;
  int tmp_2 = x + k - 1;
  for(int i = tmp; i <= tmp_2; i++) {
    cout << i << " ";
  }
  cout << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;

int main() {
    int n, x;
    string command;
    list<int> v;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> command;
        if (command[0] == 'i') {
            cin >> x;
            v.push_front(x);
        } else if (command[6] == 'L') {
            v.pop_back();
        } else if (command[6] == 'F') {
            v.pop_front();
        } else if (command[0] == 'd') {
            cin >> x;
            for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
                if (*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }

    int i = 0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (i++) cout << " ";
        cout << *it;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 34296
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
string s;
ll n,q;
vector<ll> k;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>s>>q;
    for (int i = 0; i < q; i++)
    {
        ll temp;
        cin >> temp;
        k.push_back(temp);
    }
    vector<ll> dp(n+1,0);//i文字まであったdのかず
    vector<ll> dp1(n+1,0);//dm
    vector<ll> dpm(n+1,0);
   //vector<ll> dp2(n+1,0);//dmc
   ll count=0;
   ll count1=0;
    rep(i,n){
        if(s[i]=='D'){
            count++;
        }
        if(s[i]=='M')count1++;
            dpm[i]=count1;
            dp[i]=count;
    }
    for(int i=1;i<n;i++){
        if(s[i]=='M'){
            dp1[i]=dp[i-1]+dp1[i-1];
        }
        else{
            dp1[i]=dp1[i-1];
        }
    }
    /*
    for(int i=2;i<n;i++){
        if(s[i]=='C'){
            dp2[i]=dp1[i]+dp2[i-1];
        }
        else{
            dp2[i]=dp2[i-1];
        }
    }
    */
    //debug(dp);
    //debug(dp1);
    //debug(dpm);
    rep(i,q){
        vector<ll> dp2(n+1,0);//dmc
        for(ll j=0;j<n;j++){
            ll ktemp=min(k[i]-1,j);
            dp2[j]=dp1[j]-dp1[j-ktemp];
            if(j-k[i]+1>=0){
                //cout<<j<<" "<<dp[j-ktemp]*(dpm[j]-dpm[j-ktemp])<<"\n";
            dp2[j]-=dp[j-ktemp]*(dpm[j]-dpm[j-ktemp]);
            }
        }
        //debug(dp2);
        ll res=0;
        for(int j=1;j<n;j++){
            if(s[j]=='C'){
                res+=dp2[j-1];
            }
        }
        cout<<res<<"\n";
    }
}


Measured memory_bytes: 32668
a = input()
a = a[::-1]
b = ['maerd','remaerd','esare','resare']
flag = 0
while flag >= 0:
    flag = 0
    if a[:5] == b[0]:
        a = a[5:]
    elif a[:5]==b[2]:
        a = a[5:]
    elif a[:7] == b[1]:
        a = a[7:]
    elif a[:6] == b[3]:
        a = a[6:]
    elif a == '':
        print('YES')
        break
    else:
        flag = -1
        print('NO')


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 99999999;

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

typedef long long ll;

using namespace std;



/*
class LightSwitchingPuzzle
{
public:
	int minFlips(string s)
	{

	}
}
*/


int main()
{
	int s[5][3];
	char shop[5] = {'A', 'B', 'C', 'D', 'E'};
	
	while (cin >> s[0][0] >> s[0][1])
	{
		if (s[0][0] == 0 && s[0][1] == 0) break;
		
		for (int i=1; i<5; i++)
		{
			cin >> s[i][0] >> s[i][1];
		}
		
		REP(5)
		{
			s[i][2] = s[i][0] + s[i][1];
		}
		
		int index = 0;
		int max = s[0][2];
		
		for (int i=1; i<5; i++)
		{
			if (max < s[i][2])
			{
				max = s[i][2];
				index = i;
			}
		}
		
		cout << shop[index] << " " << max << endl;
		
		/*
		//テスト出力
		REP(5)
		{
			cout << s[i][2] << " ";
		}
		cout << endl;
		*/
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
int main(void){
 char N[10];
  long long x;
  long long total=0;
  int check=1;
 while(fgets(N,10,stdin)!=NULL){
    x=atol(N);
   total+=x;
   if(total>27000000000000){
     total-=27000000000000;
   }
 }
  if(total%9==0){
   printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1672
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,m;
char s[505][505];
int main()
{
	getii(n,m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			s[i][j]=getreal();
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(j!=m&&(j==1||i%2==0||s[i][j]=='#'))putchar('#');
			else putchar('.');
		}
		puts("");
	}
	puts("");
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(j!=1&&(j==m||i%2==1||s[i][j]=='#'))putchar('#');
			else putchar('.');
		}
		puts("");
	}
	
	return 0;
}


Measured memory_bytes: 1024
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
      	int L = int.Parse(input[0]);
		int R = int.Parse(input[1]);
     	int min_mod = int.MaxValue;

      	if (L / 2019 != R / 2019)
            {
                Console.WriteLine(0);
                return;
            }	
      
      	L %= 2019;
      	R %= 2019;
      	
      	for(int i = L; i <= R; i++){
          for(int j = i+1; j <= R; j++){
            min_mod = Math.Min(min_mod, (i*j) % 2019);
          }
        }
      
      	Console.WriteLine("{0}",min_mod);
	}
}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var ans = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i.ToString().Length % 2 != 0)
                    ans++;
            }
            Println(ans);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11220
import fractions
import itertools
import math

# nの約数をすべて求める
def make_divisors(n):
    divisors = set()
    #for i in range(1, int(n**0.5)+1):
    for i in itertools.takewhile(lambda i: i**2<=n, itertools.count(1)):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    
    return divisors

# 素因数分解
# 素因数とその指数をペアにして配列で返す
def factorize(n):
    # 素因数の候補
    # i=2,...,floor(sqrt(n)) つまりi**2<=nになるまで
    remainder = n
    ret = set()
    for i in itertools.takewhile(lambda i: i**2<=n, itertools.count(2)):
        # 現在の余りをiで割れるだけ割る
        if remainder % i:
            continue
        else:
            # 割れるなら，割れる回数と余りを求める
            p = 0
            while remainder % i == 0:
                remainder //= i
                p += 1

            ret.add((i,p))

    # 2以上の余りが残っていれば，追加
    if remainder > 1: ret.add((remainder,1))

    return ret
        
    
A,B = map(int,input().split())

# 答えの集合は1or素数で構成されるとして良い (a*b,a>1,b>1となる要素があれば，aも公約数だから，a*bをaに置き換えても最適解になるから)
# つまり，A,Bをそれぞれ素因数分解し，共通の素因数の数を数えればよい
# これは，gcd(A,B)の素因数の数と同じ
gcd = fractions.gcd(A,B)
divs = factorize(gcd)
print(len(divs) + 1) # + 1は"1"の数

Measured memory_bytes: 5076
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int n;
vector<pair<double,double> > p;
bool comp(pair<double,double> &a,pair<double,double> &b){
  return atan2(a.second,a.first) < atan2(b.second,b.first);
}
int main()
{
  cin >> n;
  p.resize(n);
  rep(i,n) cin >> p[i].first >> p[i].second;

  sort(p.begin(),p.end(),comp);

  double res = 0;

  rep(i,n) rep(j,n){
    double x=0,y=0;
    if(i<=j){
      for(int k=i;k<=j;++k){
	x += p[k].first;
	y += p[k].second;
	res = max(res,fabs(sqrt(x*x+y*y)));
      }
    }
    else{
      for(int k=i;k<=n-1;++k){
	x += p[k].first;
	y += p[k].second;
	res = max(res,fabs(sqrt(x*x+y*y)));	
      }
      for(int k=0;k<=j;++k){
	x += p[k].first;
	y += p[k].second;
	res = max(res,fabs(sqrt(x*x+y*y)));
      }
    }
  }

  printf("%.10f\n",res);
  
  return 0;
}


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

using namespace std;

const int MAXN=3100;

struct elem{
	long long int first;
	long long int second;
};

elem dp[MAXN][MAXN];
long long int A[MAXN];
int N;
void calcDP(){
	for(int i=0;i<N;i++)
		dp[i][i].first=A[i];
	for(int offset=1;offset<N;offset++){
		for(int i=0;i+offset<N;i++){
			if((A[i]+dp[i+1][i+offset].second-dp[i+1][i+offset].first)>A[offset+i]+dp[i][i+offset-1].second-dp[i][i+offset-1].first)
				dp[i][i+offset].first=A[i]+dp[i+1][i+offset].second,dp[i][i+offset].second=dp[i+1][i+offset].first;
			else
				dp[i][i+offset].first=A[offset+i]+dp[i][i+offset-1].second,dp[i][i+offset].second=dp[i][i+offset-1].first;
		}
	}
}
int main(){
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>A[i];
	calcDP();
	cout<<dp[0][N-1].first-dp[0][N-1].second;
}

Measured memory_bytes: 145664
from collections import deque

num = int(input())
list = deque([])

for i in range(num):
        command = input().split()
        if command[0] == "insert":
                list.insert(0, command[1])
        elif command[0] == "delete":
                if command[1] in list:
                        list.remove(command[1])
        elif command[0] == "deleteFirst":
                list.popleft()
        elif command[0] == "deleteLast":
                list.pop()

print(" ".join(list))


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

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int t;
  scanf("%d", &t);
  while(t--){
    int gx, gy, p, f[16][16] = {}, b[16][16] = {}, x1, y1, x2, y2;
    scanf("%d%d%d", &gx, &gy, &p);
    rep(i, p){
      scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
      b[max(y1, y2)][max(x1, x2)] += (x1 == x2)?1:2;
    }
    f[0][0] = 1;
    REP(i, 1, gx+1)  f[0][i] = (b[0][i]==0?f[0][i-1]:0);
    REP(i, 1, gy+1)  f[i][0] = (b[i][0]==0?f[i-1][0]:0);

    REP(i, 1, gy+1) REP(j, 1, gx+1){
      if(b[i][j] == 0) f[i][j] = f[i-1][j] + f[i][j-1];
      else if(b[i][j] == 1) f[i][j] = f[i][j-1];
      else if(b[i][j] == 2) f[i][j] = f[i-1][j];
      else if(b[i][j] == 3) f[i][j] = 0;
    }
    if(f[gy][gx]) printf("%d\n", f[gy][gx]); else puts("Miserable Hokusai!");
  }
  return 0;
}

Measured memory_bytes: 1196
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  FOR(i, 1, 10){
    FOR(j, 1, 10){
      cout << i << "x" << j << "=" << i * j << endl;
    }
  }
	return 0;
}



Measured memory_bytes: 3076
N=int(input())
data=list(map(int,input().split()))
ans="APPROVED"
for i in range(N):
    mo2=data[i]%2
    mo6=data[i]%6
    mo10=data[i]%10
    if mo2==0:
        if mo6==0 or mo10==0:
            ans="APPROVED"

        else:
            ans="DENIED"
            break
    else:
        continue
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>

int main(void)
{
  int n;
  char buf[1026];
  int count=0;
  int tmp;

  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%s",buf);
    for(int j=0;buf[j]!='\0';j++){
      if(buf[j]=='\n')continue;
      
      if(buf[j]!='0'){
	tmp = buf[j]-'0';
	count++;
      }
      else{
	if(count==0){continue;}
	switch(tmp){
	case 1:
	  if(count%5==1)printf(".");
	  if(count%5==2)printf(",");
	  if(count%5==3)printf("!");
	  if(count%5==4)printf("?");
	  if(count%5==0)printf(" ");
	  break;
	case 2:
	  if(count%3==1)printf("a");
	  if(count%3==2)printf("b");
	  if(count%3==0)printf("c");
	  break;
	case 3:
	  if(count%3==1)printf("d");
	  if(count%3==2)printf("e");
	  if(count%3==0)printf("f");
	  break;
	case 4:
	  if(count%3==1)printf("g");
	  if(count%3==2)printf("h");
	  if(count%3==0)printf("i");
	  break;
	case 5:
	  if(count%3==1)printf("j");
	  if(count%3==2)printf("k");
	  if(count%3==0)printf("l");
	  break;
	case 6:
	  if(count%3==1)printf("m");
	  if(count%3==2)printf("n");
	  if(count%3==0)printf("o");
	  break;
	case 7:
	  if(count%4==1)printf("p");
	  if(count%4==2)printf("q");
	  if(count%4==3)printf("r");
	  if(count%4==0)printf("s");
	  break;
	case 8:
	  if(count%3==1)printf("t");
	  if(count%3==2)printf("u");
	  if(count%3==0)printf("v");
	  break;
	case 9:
	  if(count%4==1)printf("w");
	  if(count%4==2)printf("x");
	  if(count%4==3)printf("y");
	  if(count%4==0)printf("z");
	  break;
	}
	count=0;
      }
    }
    printf("\n");
  }
      
  return 0;
}

Measured memory_bytes: 1164
# -*- coding: utf-8 -*-
n = input()
x = list(map(int, input().split()))

cnt = 0

while True:
    s = sum(list(map(lambda elem: elem % 2, x)))
    if s != 0:
        break
    cnt += 1
    x = list(map(lambda elem: elem // 2, x))

print(cnt)


Measured memory_bytes: 2940
n = int(input())
a = list(int(i) for i in input().split()) 
#2倍数か4倍数か判定する
a2n = 0
a4n = 0
for i in range(n):
 if a[i]%2 == 0:
  if a[i]%4 == 0:
   a4n += 1
  else:
   a2n += 1
#print (a4n)
#print (a2n)
if n > 2 and a4n >0:
 pos = 2 * a4n +1 + 2*(a2n//2)
elif n >= 2 and a4n == 0:
 pos = 2*(a2n//2)


if n <= pos:
 ans ='Yes'
else:
 ans = 'No'

print(ans)

Measured memory_bytes: 14228
import java.util.Scanner;


 public class Main{
	public static void main(String[] args){
		int max = 10, temp;
		int mountain[] = new int[max];
		Scanner sc = new Scanner(System.in);
		for(int i = 0; i < max; i++) mountain[i] = sc.nextInt();
		for(int i = 0; i < max; i++){
			for(int j = max-1; j > i; j--){
				if(mountain[j-1] > mountain[j]){
					temp = mountain[j-1];
					mountain[j-1] = mountain[j];
					mountain[j] = temp;
				}
			}
		}
		for(int i = max-1; i >= max-3; i--) System.out.println(mountain[i]);
	}
}

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

int main(){
    int N, sum = 0;
    cin >> N;
    vector<int> A(N), B(N), C(N-1);
    
    rep(i, N){
        cin >> A.at(i);
    }
    
    rep(i, N)
    {
        cin >> B.at(i);
    }

    rep(i, N-1)
    {
        cin >> C.at(i);
    }

    rep(i,N){
        sum += B.at(A.at(i) - 1);
        if(i < N - 1){
            if(A.at(i+1) - A.at(i) == 1){
                sum += C.at(A.at(i)-1);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


	
int main(void){
    ll A,B,V,W,T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if(A<B){
        A+=V*T;
        B+=W*T;
        if(A>=B){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }else{
        A-=V*T;
        B-=W*T;
        if(A<=B){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    
    return 0;
}



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

template <typename T>
class BIT {
  int n;
  vector<T> bit;
public:
  BIT(int _n) {
    n = _n;
    bit = vector<T>(n+1,(T)0);
  }
  T sum(int i) {
    T s = 0;
    while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
  }
  void add(int i, T x) {
    while(i <= n){
    bit[i] += x;
    i += i & -i;
    }
  }
};

int main(){
  ll n;
  cin >> n;
  ll a[n+1];
  rep(i,n) cin >> a[i+1];
  ll l = 0, r = INF;
  while(r - l > 1) {
    ll m = (l + r) / 2;
    vector<ll> s(n+1,0);
    BIT<ll> bit(3*n);
    bit.add(2*n,1);
    ll num = 0;
    for(ll i = 1; i <= n; i++) {
      s[i] = s[i-1];
      if(a[i] >= m) s[i]++;
      else s[i]--;
      ll k = s[i] + 2*n;
      num += bit.sum(k);
      bit.add(k,1);
    }
    if(num >= (n*(n+1)/2 +1)/2) l = m;
    else r = m;
  }
  cout << l << endl;
}


Measured memory_bytes: 4296
from collections import deque

N,q = map(int,input().split())
stack = deque()
#lst = list(map(int, [input() for i in range(N)]))
stack.extend(list(input().split() for i in range(N)))
cnt = 0
endtime = deque()
while True:
    if len(stack) == 0:
        break
    x = stack.popleft()
    x[1] = int(x[1])
    if x[1] <= q:
        cnt += x[1]
        endtime.append([x[0],cnt])
    else:
        cnt += q
        x[1] -= q
        stack.append(x)


#print(" ".join(map(str,endtime)))
for i in endtime:
    print("{} {}".format(i[0],i[1]))


Measured memory_bytes: 19192
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;
ll a,b,p,q,r;
ll judge(ld x){
    ld res=(x-a)*q;
    res+=(x-b)*r;
    ld temp=p*b;
    return temp<=res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b>>p>>q>>r;
    ld Min=b;
    ld Max=1e9;
    rep(i,100){
        ld Half=(Min+Max)/2;
        if(judge(Half)){
            Max=Half;
        }else{
            Min=Half;
        }
    }
    cout<<setprecision(10)<<Min<<endl;
}



Measured memory_bytes: 3308
n=int(input())
a=sorted(list(map(int,input().split())))
c=[0]*8
k=n
for i in range(n):
    for j in range(8):
        if 400*j<=a[i]<400*(j+1):
            c[j]=1
            break
    else:
        k=i
        break


d=c.count(1)
if d==0:
    print(1, end=" ")
else:
    print(d, end=" ")

print(d+(n-k))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  int b[n];
  
  if(n%2==0){
    for(int i=0;i<n;i+=2){
      b[n/2+i/2]=a[i];
    }
    for(int i=1;i<n;i+=2){
      b[n/2-(i+1)/2]=a[i];
    }
  }else{
    for(int i=0;i<n;i+=2){
      b[n/2-i/2]=a[i];
    }
    for(int i=1;i<n;i+=2){
      b[n/2+(i+1)/2]=a[i];
    }
  }
  REP(i,n){
    cout<<b[i]<<' ';
  }
  return 0;
}


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

int n;
ll damage[1005];
ll cost[1005];

ll memo[1005][10005];

ll dp(int i, int h){
	if (memo[i][h] != -1) return memo[i][h];

	ll ans = 1'000'000'000;

	if (damage[i] >= h) {ans = min(ans, cost[i]);}
	else { ans = min(ans, cost[i] + dp(i, h-damage[i]));}
	if (i < (n-1)) ans = min(ans, dp(i+1,h));

	memo[i][h] = ans;
	return ans;

}

int main(){
	memset(memo, -1, sizeof memo);
	int h;
	cin >> h >> n;
	for (int i = 0; i < n; i++){ cin >> damage[i] >> cost[i]; }
	cout << dp(0,h) << endl;
}



Measured memory_bytes: 82644
N,L = map(int,input().split())
A = list(map(int,input().split()))

untiable = False
lastknot = None

for i in range(N-1):
    if A[i]+A[i+1] >= L:
        untiable = True
        lastknot = i+1
        break

if untiable:
    ans = [i for i in range(1,lastknot)] + [i for i in range(lastknot+1,N)[::-1]] + [lastknot]
    print('Possible')
    print('\n'.join(map(str,ans)))
    
else:
    print('Impossible')

Measured memory_bytes: 17892
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <float.h>
using namespace std;

#define N 3

string s[3];

int main()
{
	string ans;
 
	for( int i = 0; i < 3; i++ ) {
		cin >> s[i];
	}

	ans.push_back(s[0][0]);
	ans.push_back(s[1][1]);
	ans.push_back(s[2][2]);

	cout << ans << endl;
 
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
sm = sum(a)
dp = 1
for i in range(N): dp |= (dp << a[i])
#print(dp)
x = 1 << ((sm + 1) // 2)
for i in range((sm + 1) // 2 + 1):
  if dp & x:
    print((sm + 1) // 2 + i)
    break
  x <<= 1

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

int main(void){
  int A,B;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  A=atoi(p);
  p=strtok(NULL," \n");
  B=atoi(p);
  
  if(A>12){
    printf("%d\n",B);
  }
  if(A<13 && A>5){
    printf("%d\n",B/2);
  }
  if(A<6){
    printf("0\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main()
{
    //c_p_c();
    int x;
    string s;
    cin>>x>>s;

    if(x<3200)
        cout<<"red\n";
    else
        cout<<s<<'\n';
    return 0;
}

Measured memory_bytes: 256
N = int(input())
hhh = list(map(int, input().split()))
flag = True
for i in range(N - 1):
    if hhh[i] < hhh[i + 1]:
        flag = True
    elif hhh[i] == hhh[i + 1]:
        pass
    elif (hhh[i] == hhh[i + 1] + 1) and flag:
        flag = False
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 20432
#include<bits/stdc++.h>
#define MAX 100005
#define NIL -1
using namespace std;

struct Node {int p,l,r;};

Node T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].p<<", ";
    cout<<"depth = "<<D[u]<<", ";
    if(T[u].p == NIL) cout<<"root, ";
    else if(T[u].l == NIL) cout<<"leaf, ";
    else cout<<"internal node, ";
    cout<<"[";
    for(i=0,c=T[u].l; c!=NIL; i++,c=T[c].r){
        if(i) cout<<", ";
        cout<<c;
    }
    cout<<"]"<<endl;
    return ;
}

int rec(int u,int p){
    D[u] = p;
    if(T[u].r != NIL) rec(T[u].r, p);
    if(T[u].l != NIL) rec(T[u].l, p + 1);
    
}

int main(){
    int d,v,c,l,r;
    cin>>n;
    for(int i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
    
    for(int i=0;i<n;i++){
        cin>>v>>d;
        for(int j=0;j<d;j++){
            cin>>c;
            if(j==0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for(int i=0;i<n;i++){
        if(T[i].p == NIL) r=i;
    }
    rec(r,0);
    
    for(int i=0;i<n;i++) print(i);
    
    return 0;
}



Measured memory_bytes: 7684
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#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--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
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;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    ll n,a,b,ans;
    cin>>n>>a>>b;
    ans=n/(a+b)*a;
    n%=(a+b);
    if(n>=a)ans+=a;
    else ans+=n;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
  
public class Main {
    private static final String CRLF = System.lineSeparator();
    public void exec() throws IOException {
    	SimpleInputUtil in = new SimpleInputUtil();
        PrintWriter out = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        int n = in.readInt();
        int[] A = in.readIntArray(new int[n]);
        int cnt = shellSort(A,sb);
        sb.append(cnt).append(CRLF);
        intArrayToString1Line1Num(A,sb);
        out.print(sb.toString());
        out.flush();
    }
    
    private int insertionSort(int[] A, int g) {
    	int cnt=0;
    	int n = A.length;
    	for(int i=g; i<n; i++) {
    		int v = A[i];
    		int j = i - g;
    		while ( j >= 0 && A[j] > v ) {
    			A[j+g] = A[j];
    			j = j - g;
    			cnt++;
    		}
    		A[j+g] = v;
    	}
    	return cnt;
    }
    
    private int[] shellSortSub(int[] A, StringBuilder sb) {
    	int mInit=100; 
    	int[] G = new int[mInit];
    	G[0] = A.length/2;
    	int m = 0;
    	while(G[m]>1) {
    		m++;
    		G[m] = G[m-1]/2;
    	}
    	m++;
    	sb.append(m).append(CRLF);
    	int[] Gsub = Arrays.copyOf(G, m);
    	intArrayToString1LineAllNum(Gsub,sb);
    	return Gsub;
    }
    
    private int shellSort(int[] A,StringBuilder sb) {
    	int cnt=0;
    	int[] G = shellSortSub(A,sb);
    	for(int i=0; i<G.length; i++) {
    		cnt += insertionSort(A, G[i]);
    	}
    	return cnt;
    }
    
    private void intArrayToString1LineAllNum(int[] sorted, StringBuilder sb) {
        for(int i=0; i<sorted.length; i++) {
            if(i>0) sb.append(" ");
        	sb.append(sorted[i]);
        }
        sb.append(CRLF);
    }
    
    private void intArrayToString1Line1Num(int[] sorted, StringBuilder sb) {
        for(int i=0; i<sorted.length; i++) {
            sb.append(sorted[i]).append(CRLF);
        }
    }
     
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
    
}

class SimpleInputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public int readInt() throws NumberFormatException, IOException{
    	return Integer.parseInt(br.readLine());
    }
    public int[] readIntArray(int[] a) throws NumberFormatException, IOException{
        int i=0;
        while(i<a.length) {
            for(String s: br.readLine().split(" ")){
            	if(i<a.length) {
                    a[i++] = Integer.parseInt(s);
            	}
            }
        }
        return a;
    }
    
}

Measured memory_bytes: 144236
import Data.List
 
max :: [(Int,String)] -> (Int,String)
max [] = (0,"")
max ((l,w):ls) =
        let (sl,sw) = Main.max ls
        in
                if l > sl
                then (l,w)
                else (sl,sw)
 
merge :: [(Int,String)] -> [(Int,String)]
merge [] = []
merge (x:[]) = [x]
merge ((l,w):xs@((xl,xw):xss)) =
        if w == xw
        then Main.merge ((l+xl,w):(Main.merge xss))
        else ((l,w):(Main.merge xs))
 
ans1 x = 
    let s@(sc:sx) = sort x
        i = zip (repeat 1) s
        (ml,mw) = Main.max $ Main.merge i
    in
        mw
 
ans2 s =
    let l = map (\w -> (length w, w) ) s
        (ml,mw) = Main.max l
    in
        mw
 
ans :: [String] -> (String,String)
ans s =
    let a1 = ans1 s
        a2 = ans2 s
    in
        (a1,a2)
 
main = do
    l <- getLine
    let i = words l
        (a1,a2) = ans i
    putStrLn $ a1 ++ " " ++ a2
 

Measured memory_bytes: 3592
import java.util.*;
import java.io.*;

public class Main{
    static int INFTY = Integer.MAX_VALUE;
        
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.nextLine());
    //    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    //    try{
    //        int n = Integer.parseInt(br.readLine());

            //「探索済み集合V」に頂点を一つずつ入れていく
            int[] color = new int[n];   //0:未探索, -1:探索中(周辺), +1:全域木に追加済
            int[][] M = new int[n][n];
            int[] d = new int[n];       //Vからの最短距離
            int[] p =new int[n];       //親(一意に定まる)を記録
            for (int i=0;i<n;i++){
                d[i]=INFTY;
            }
            p[0] =-1;
            d[0]=0;

            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    M[i][j]=sc.nextInt();
                }
            }

            int u=0;        //Vに追加する頂点
            while(true){
                int mincost=INFTY;
                for(int i=0;i<n;i++){
                    if (color[i]!=1 && d[i]<mincost){
                        mincost=d[i];
                        u=i;                            //Vから一番近い頂点を選択
                    }
                }
                if (mincost==INFTY){                    //すべて探索済みだったら終了
                    break;
                }
                color[u]=1;                             //uを探索済みにする

                for(int i=0;i<n;i++){
                    if(color[i]!=1&&M[u][i]!=-1){       //uと結ばれている頂点について、d[]が更新できるなら更新し、親をuとする
                        if(M[u][i]<d[i]){
                            d[i]=M[u][i];
                            p[i]=u;
                            //color[i]=-1;　            ←本には載ってたけどこれいらなくない？
                        }
                    }
                }
            }
            int ans=0;
            for(int i=0;i<n;i++){
                ans+=d[i];
            }
            System.out.println(ans);
        // } catch (IOException e) {
        //     e.printStackTrace();
        // }

        
    }
    
}


    


Measured memory_bytes: 41116
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int inf=1000000007;


int main(){
  ll n;
  cin >> n;
  vector<char> a;
  while(n!=0){
    int val=n%26;
    if(val==0) val+=26;
    a.push_back(val+96);
    n/=26;
    if(val==26) n--;
  }
  int cnt=a.size();
  for(int i=cnt-1; i>=0; i--){
    cout << a[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3632
from collections import defaultdict
n=int(input())
arr=[]
for _ in range(n):
    dd=defaultdict(int)
    line=list(input())
    for c in line:
        dd[c]+=1
    arr.append(dd)

#print(arr)

for c in list('abcdefghijklmnopqrstuvwxyz'):
    minc=51
    for i in range(n):
        minc=min(arr[i][c],minc)
    print(c*minc,end='')
print('')


Measured memory_bytes: 3316
#!/usr/bin/python3

import sys
from collections import defaultdict


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


def psum(pair):
    if pair == 'AB':
        return a + b
    elif pair == 'AC':
        return a + c
    elif pair == 'BC':
        return b + c

def select(pair, npair):
    global a, b, c
    added = None
    if pair == 'AB':
        if a < b:
            a += 1
            b -= 1
            added = 'A'
        elif a > b:
            a -= 1
            b += 1
            added = 'B'            
        else:
            # a == b
            if a + b == 2 and c == 0 and npair:
                if npair == 'AB':
                    a += 1
                    b -= 1
                    added = 'A'
                elif npair == 'AC':
                    a += 1
                    b -= 1
                    added = 'A'                    
                elif npair == 'BC':
                    a -= 1
                    b += 1
                    added = 'B'                    
            else:
                a += 1
                b -= 1
                added = 'A'
            
    elif pair == 'AC':
        if a < c:
            a += 1
            c -= 1
            added = 'A'
        elif a > c:
            a -= 1
            c += 1
            added = 'C'            
        else:
            # a == c
            if a + c == 2 and b == 0 and npair:
                if npair == 'AB':
                    a += 1
                    c -= 1
                    added = 'A'                    
                elif npair == 'AC':
                    a += 1
                    c -= 1
                    added = 'A'                    
                elif npair == 'BC':
                    a -= 1
                    c += 1
                    added = 'C'
            else:
                a += 1
                c -= 1
                added = 'A'                
        
    elif pair == 'BC':
        if b < c:
            b += 1
            c -= 1
            added = 'B'            
        elif b > c:
            b -= 1
            c += 1
            added = 'C'            
        else:
            # b == c
            if b + c == 2 and a == 0 and npair:
                if npair == 'AB':
                    b += 1
                    c -= 1
                    added = 'B'                    
                elif npair == 'AC':
                    b -= 1
                    c += 1
                    added = 'C'                    
                elif npair == 'BC':
                    b += 1
                    c -= 1
                    added = 'B'
            else:
                b += 1
                c -= 1
                added = 'B'
    return added

    
ans = []
if a + b + c == 0:
    print('No')
    exit()
else:
    for i, s in enumerate(ss):
        if psum(s) == 0:
            print('No')
            exit()
        else:
            ns = None
            if i < len(ss) - 1:
                ns = ss[i + 1]
            ans.append(select(s, ns))

        
print('Yes')
for l in ans:
    print(l)


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


void solve(long long N, std::vector<std::string> S){
    set<string> s;
    for (string e: S) {
        s.insert(e);
    }
    cout << s.size() << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

string s;

int solve();

int main() {
  cin >> s;

  cout << solve() << endl;
  return 0;
}

int solve() {
  int g = 0, p = 0, ans = 0;
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == 'g') {
      if(g > p) {
        ++ans;
        ++p;
      }
      else
        ++g;
    }
    else {
      if(g > p)
        ++p;
      else {
        ++g;
        --ans;
      }
    }
  }
  return ans;
}

Measured memory_bytes: 512
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  string s;
  cin>>s;
  
  ll a=0;
  rep(i,s.size()){
    a+=s[i]-'0';
  }
  
  if(a%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}

Measured memory_bytes: 3748
n,m,k = map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
if sum(al)+sum(bl)<=k:
  print(n+m)
  exit()
ans = 0
used = 0
indexa = indexb = -1
for i in range(n):
  if used+al[i] <= k:
    used += al[i]
    indexa=i
    ans += 1
  else:
    break
for i in range(m):
  if used+bl[i] <= k:
    used += bl[i]
    indexb = i
    ans+=1
  else:
    break

tmp = ans
for i in range(indexa,-1,-1):
  used -= al[i]
  tmp -= 1
  while indexb<m-1 and bl[indexb+1]+used <=k:
    used += bl[indexb+1]
    indexb += 1
    tmp += 1
  ans = max(tmp,ans)
print(ans)

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

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n;
    scan(n);
    auto p = readln.split.to!(int[]).map!(i => i - 1).array;
    auto q = readln.split.to!(int[]).map!(i => i - 1).array;

    int a, b;

    auto pms = iota(n).permutations.map!(pm => pm.array).array.sort();

    foreach (i, perm; pms.enumerate) {
        debug {
            writeln(perm);
        }
        if (p.equal(perm)) a = i.to!int;
        if (q.equal(perm)) b = i.to!int;
    }

    auto ans = abs(a - b);
    writeln(ans);
}














void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4348
M=[0,1,-1,0,0,1,1,2,3,3,4,4]
def L(y,m):
  if m<=2: y-=1
  return y/4-y/100+y/400+M[m-1]

while 1:
  a,b,c,d,e,f=x=map(int,raw_input().split(" "))
  if any([i<0 for i in x]): break
  ans=(d-a)*365+(e-b)*30+f-c+L(d,e)-L(a,b)
  print ans

Measured memory_bytes: 4220
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define RANGE(i, x, n) for(int i = x; i < n; ++i)

using namespace std;

typedef long long ll;
const int INF = 0x3f3f3f3f;

int main()
{
    ll N;
    cin >> N;
    int ans = INF;
    RANGE(i, 1, sqrt(N) + 1) {
        if(N % i == 0) {
            ll y = N / i;
            ans = min(ans, max((int)to_string(y).size(), (int)to_string(i).size()));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  string s;
  cin >> s;
  
  int ans = 7;

  rep(i,3) {
    if(s[i]=='o') ans++;
  }
  
  cout << ans*100 << endl;
  
}



Measured memory_bytes: 256