akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	while(cin >> n >> m, n|m) {
		cin.ignore();
		vector<string> v(1000);
		map<string, string> ma;
		REP(i, n) {
			string s;
			getline(cin, s);
			int cnt = 0;
			while(s[cnt] == ' ')
				cnt++;
			s = s.substr(cnt);
			if(!cnt)
				ma[s] = "";
			else
				ma[s] = v[cnt-1];
			v[cnt] = s;
		}
		REP(i, m) {
			string in1, in2, in3;
			cin >> in1;
			cin >> in2 >> in2 >> in2;
			cin >> in3 >> in3;
			in3.erase(in3.end() - 1);
			bool ans = false;
			if(in2 == "child" && ma[in1] == in3)
				ans = true;
			else if(in2 == "parent" && ma[in3] == in1)
				ans = true;
			else if(in2 == "sibling" && ma[in1] == ma[in3])
				ans = true;
			else if(in2 == "descendant") {
				string s = ma[in1];
				while(s != "") {
					if(s == in3)
						ans = true;
					s = ma[s];
				}
			}
			else if(in2 == "ancestor") {
				string s = ma[in3];
				while(s != "") {
					if(s == in1)
						ans = true;
					s = ma[s];
				}
			}
			if(ans)
				cout << "True" << endl;
			else
				cout << "False" << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1344
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n = load()
A = load_list()

if n == len(set(A)):
    print('YES')
else:
    print('NO')

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef pair<int, int> Pii;

int main() {
    int n,d,x;
    cin >> n >> d >> x;
    int p[d][n];
    rep(d)repp(j, n) cin >> p[i][j];

    map<int, int> dp;
    int diff = INT_MIN;
    rep(d+1){
        if(diff > 0) x += diff;

        if(i == d-1) break;
        dp.clear();
        dp[0] = 0;
        diff = INT_MIN;

        repp(j, n){
            for(auto itr=dp.begin();itr!=dp.end();++itr){
                int pp = itr->first;
                dp[pp] = max(dp[pp], dp[pp]);
                if(pp + p[i][j] > x) continue;
                dp[pp + p[i][j]] = max(dp[pp], dp[pp] + (p[i+1][j] - p[i][j]));
                diff = max({diff,dp[pp], dp[pp+p[i][j]]});
            }
        }
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 4232
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int k,q;
	ll d[5001];
	scan(k>>q);
	rep(i,k) scan(d[i]);
	rep(i,q){
		ll n,x,m;
		scan(n>>x>>m);
		x%=m;
		ll dmod[5001];
		ll dmodsum=0;
		rep(j,k){
			dmod[j]=d[j]%m;
			if(dmod[j]==0) dmod[j]=m;
		}
		ll plusnumsho=(n-1)/k,amarii=(n-1)%k;
		rep(j,k){
			dmodsum+=dmod[j]*(plusnumsho+(j<amarii));
		}
		ll plussho=dmodsum/m,plusamari=dmodsum%m;
		ll loopnum=plussho+(x>(x+plusamari)%m);
		ll ans=n-1-loopnum;
		//rep(j,k) printf("%d ",dmod[j]);
		//kaigyo;
		prin(ans);
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<cstdlib>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-10;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
char s[maxn];
int num[maxn];
void solve(){
	int n;scd(n);
    scanf("%s",s+1);
    int now=0;
    for(int i=n;i;i--){
    	num[i]=now;
    	if(s[i]=='R')now++;
	}
	if(!now){
		printf("0");
		return ;
	}
	int ans=now;
	now=0;
	rep1(i,n){
		if(s[i]=='W')now++;
		else {
			if(now<=num[i])
				ans=min(ans,num[i]);
		}
	}ac;
}
int main(){
	//freopen("D://data.txt","r",stdin);
	//freopen("D://out.txt","w",stdout);
    solve();
    return 0;
}

Measured memory_bytes: 4216
from collections import defaultdict,deque
import math
def main():
    alph = "abcdefghijklmnopqrstuvwxyz"
    s = input()

    for i in range(26):
        if(s.count(alph[i])==0):
            print(alph[i])
            exit()
    print("None")

if __name__ == '__main__':
    main()


Measured memory_bytes: 67516
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
long long ans=1;
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		if(ans<k)ans+=ans;
		else ans+=k;
	}
	cout<<ans;
return 0;
}


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

int w[2], a[2], t;
long long ans, p[2][MX];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> w[0] >> w[1];
    rep(i,2){
        rep(j,w[i]) cin >> p[i][j];
        p[i][w[i]] = 1e9;
        sort(p[i],p[i]+w[i]);
    }
    while(a[0] + a[1] < w[0] + w[1]){
        t = p[0][a[0]] > p[1][a[1]];
        ans += p[t][a[t]++] * (w[!t]+1 - a[!t]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

struct cir {
	int x;
	int y;
	int r;
	unsigned char c;
	vector<unsigned char> top;
};
int bit_sum(int a) {
	int res = 0;
	REP(i, 32)
		if ((a >> i) & 1)
			res++;
	return res;
}
int main() {
	int n;
	while (cin >> n, n)
	{
		vector<cir> en(n);
		REP(i, n) {
			cin >> en[i].x >> en[i].y >> en[i].r >> en[i].c;
			for (int j = 0;j < i;j++)
				if ((en[j].x - en[i].x)*(en[j].x - en[i].x) + (en[j].y - en[i].y)*(en[j].y - en[i].y) < (en[i].r + en[j].r)*(en[i].r + en[j].r))
					en[i].top.push_back(j);
		}
		int ans = 0;
		set<int> dp;
		queue<int> Q;
		int start = 0;
		REP(i, n) {
			start *= 2;
			start++;
		}
		dp.insert(start);
		Q.push(start);
		while (!Q.empty()) {
			int q = Q.front();Q.pop();
			ans = max(ans, n - bit_sum(q));
			REP(i, n) {
				if (((q >> i) & 1)) {
					bool clear = true;
					REP(j, en[i].top.size()) {
						if ((q >> en[i].top[j]) & 1)
							clear = false;
					}
					if (!clear)
						continue;
					FOR(j, i + 1, n) {
						if (((q >> j) & 1)&&en[i].c==en[j].c) {
							bool clear = true;
							REP(k, en[j].top.size()) {
								if ((q >> en[j].top[k]) & 1)
									clear = false;
							}
							if (!clear)
								continue;
							if (dp.find((q ^ (1 << i)) ^ (1 << j)) == dp.end()) {
								Q.push((q ^ (1 << i)) ^ (1 << j));
								dp.insert((q ^ (1 << i)) ^ (1 << j));
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 52248
/*
 *
 *   author     : amit kumar
 *   date    	: june 5 2019
 * 
 */

#include <bits/stdc++.h>

//#define fast_input_output
//#define more_than_one_testcase // comment it

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto solution_function( void ) ->void {

    // your solution goes here 

    int n , q;

    cin>>n>>q;

    string s;

    cin>>s;

    vi k(n+1);
    k[0]=0;
    for(int i=1; i<n; ++i){
        if(s[i]=='C' and s[i-1]=='A')
            k[i]=k[i-1]+1;
        else
            k[i]=k[i-1];
    }
    rep(q){
        int left , right;

        cin>>left>>right;

        cout<<k[right-1] - k[left-1]<<endl;
    }

        

    return ;
}




int main(void){
#ifdef fast_input_output
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef my_local_project
    freopen("cin","r",stdin);
    freopen("cout","w",stdout);
#endif
    int testcase = 1;


#ifdef more_than_one_testcase
    cin>>testcase;
#endif
    
    while(testcase--){
        solution_function();
    }

#ifdef my_local_project
    cout<<"time : "<<1.0*(double)clock()/clocks_per_sec<<endl;
#endif
    return 0;
}

Measured memory_bytes: 1408
import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range, std.functional;
 
void main() {
    auto tmp = readln.split.to!(int[]);
    writeln(abs(tmp[0] - tmp[1]) < abs(tmp[0] - tmp[2]) ? "A" : "B");
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	scan := newScanner()
	x := scan.nextInt()
	y := scan.nextInt()

	ans := math.MaxInt64
	if x <= y {
		ans = min(ans, y-x)
	}
	if -x <= y {
		ans = min(ans, y+x+1)
	}
	if x <= -y {
		ans = min(ans, -y-x+1)
	}
	if -x <= -y {
		ans = min(ans, -y+x+2)
	}
	fmt.Println(ans)
}

func zero(a int) int {
	if a == 0 {
		return 0
	} else if a > 0 {
		return 1
	} else {
		return -1
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func s(a [3]int, f func(int, int) int) int {
	r := a[0]
	for i := 1; i < len(a); i++ {
		r = f(r, a[i])
	}
	return r
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}

func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;

struct node{
  int cost;
  int c;
  int now;
  node(int C,int cc,int n):cost(C),c(cc),now(n){}
  bool operator >(const node &e) const{
    return cost > e.cost;
  }
};

int main()
{
  int c,n,m,s,d;

  for(;cin>>c>>n>>m>>s>>d,c;)
    {
      int edge[n][n];
      bool close[c+1][n];
      memset(edge,-1,sizeof(edge));
      memset(close,false,sizeof(close));      
      for(int i=0;i<m;i++)
	{
	  int a,b,f;
	  cin>>a>>b>>f;
	  a--;
	  b--;
	  edge[a][b]=f;
	  edge[b][a]=f;
	}
      s--;
      d--;
      priority_queue<node,vector<node>,greater<node> >qu;
      qu.push(node(0,c,s));
      while(!qu.empty())
	{
	  node tmp = qu.top();
	  //	  cout<<tmp.now<<" "<<tmp.cost<<" "<<tmp.c<<endl;
	  qu.pop();
	  if(close[tmp.c][tmp.now])
	    continue;
	  close[tmp.c][tmp.now]=true;
	  if(tmp.now==d)
	    {
	      cout<<tmp.cost<<endl;
	      break;
	    }
	  for(int i=0;i<n;i++)
	    {
	      if(edge[tmp.now][i]!=-1)
		{
		  if(!close[tmp.c][i])
		    qu.push(node(edge[tmp.now][i]+tmp.cost,tmp.c,i));
		  if(tmp.c>0 && !close[tmp.c-1][i])
		    qu.push(node(edge[tmp.now][i]/2+tmp.cost,tmp.c-1,i));
		}
	    }
	}
    }

}

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

int main(){
  int n;
  int m;
  cin >> n;
  cin >> m;
  vector<int> a(m);
  vector<int> b(m);
  for(int i = 0;i<m;i++){
    cin >> a.at(i) >> b.at(i);
  }
  
  int result = 0;
  queue<int> que;
  vector<int> grouping(n);
  for(int k=0;k<m;k++){
    int groupcnt = 0;
    que.empty();
    for(int i=0;i<n;i++){
      grouping.at(i) = -1;
    }
    
    for(int i = 0;i<n;i++){
      if(grouping.at(i) == -1){
        que.push(i);
        grouping.at(i) = groupcnt;
        while(!que.empty()){ //1
          int target = que.front();
          que.pop();
          for(int j=0;j<m;j++){ //2
            if(a.at(j)-1 == target && j != k){ //3
              if(grouping.at(b.at(j)-1) == -1){ //4
                que.push(b.at(j)-1);
                grouping.at(b.at(j)-1) = groupcnt;
              } //4
            }else if(b.at(j)-1 == target && j != k){ //3
              if(grouping.at(a.at(j)-1) == -1){ //4
                que.push(a.at(j)-1);
                grouping.at(a.at(j)-1) = groupcnt;
              } // 4
            } //3
          } //2
        } //1
        groupcnt++;
        //cout << "###" << endl;
      }  
      
    }
    if(groupcnt != 1){
      result++;
    }
  }
  cout << result << endl;
}
  
        
          
                   
    
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
void no(){cout<<"No"<<endl;exit(0);}
signed main(){
  Int a,b;
  string s;
  cin>>a>>b>>s;
  if(s[a]!='-') no();
  for(Int i=0;i<a+b+1;i++){
    if(i==a) continue;
    if(!isdigit(s[i])) no();
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{  int n,i,a[10]={0};
   cin>>n;if(n/10==9){cout<<"Yes";return 0;} 
   for(i=1;i<=n;i++)
   {  a[i]=n%10;
       n=n/10;
       if(n<=0)break;if(a[i]==9){cout<<"Yes";return 0;}
   }cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N, Y;
	cin >> N >> Y;

	bool flag = false;
	for (int a = 0; a <= N; a++) {
		for (int b = 0; b <= N; b++) {
			int c = N - (a + b);
			if (c < 0)
				continue;
			int sum = (10000 * a) + (5000 * b) + (1000 * c);
			if (sum == Y) {
				cout << a << " " << b << " " << c << endl;
				flag = true;
				break;
			}
		}
		if (flag)
			break;
	}

	if (!flag)
		cout << "-1 -1 -1" << endl;

	return 0;
}

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

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

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

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==(b+c) || b==(a+c) || c==(b+a)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
double dp[301][301][301];
using namespace std;

void setdp()
{
    for(int i=0;i<301;i++)
    {
        for(int j=0;j<301;j++)
        {
            for(int k=0;k<301;k++)
            {
                dp[i][j][k]=-1;
            }
        }
    }
}
double solve(int x, int y, int z,int& n)
{
    if(x<0 || y<0 || z<0)
    {
        return 0;
    }
    if(x==0 && y==0 && z==0)
    {
        return 0;
    }
    if(dp[x][y][z]>-0.9)
    {
        return dp[x][y][z];
    }
    double exp = n + x*solve(x-1,y,z,n)+y*solve(x+1,y-1,z,n)+z*solve(x,y+1,z-1,n);
    return dp[x][y][z] = exp/(x+y+z);
}
int main() {
    int n;
    cin>>n;
    int one=0,two=0,three=0;
    setdp();
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(x==1)
        {
            one++;
        }
        else if(x==2)
        {
            two++;
        }
        else{
            three++;
        }
    }
    cout<<fixed<<setprecision(10)<<solve(one,two,three,n);
}


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

int run(unsigned long int *r, int no, int n){
    int c = 0;
    for(int i = no; i < n; ++i){
        int d = r[i] % 10;
        for(int j = -1; j <=1; ++j){
            if(d+j <= 9 && d+j >= 0){
                r[n+c] = r[i]*10 + d+j;
                c++;
            }
        }
    }
    return n+c;
}

int main(){
    int k;
    scanf("%d",&k);
    unsigned long int r[k*10] = {1,2,3,4,5,6,7,8,9};
    int n = 9;
    int no = 0, p = 0;
    while(true){
        if(n >= k){
            cout << r[k-1] << endl;
            break;
        }
        int p = n;
        n = run(r, no, n);
        no = p;
    }
    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

int main() {
    int n,m;
    cin>>n>>m;

    int cntac=0,cntwa=0;
    vector<int>wa(n+1,0);
    vector<bool>jdg(n+1,false);

    rep(i,m){
        int p;
        string s;
        cin>>p>>s;

        if(jdg[p]==false){
            if(s=="AC"){
            cntac++;
            cntwa+=wa[p];
            jdg[p]=true;
            }
            else {
                wa[p]++;
            }
        }
    }

    cout<<cntac<<" "<<cntwa<<endl;

}


Measured memory_bytes: 640
from math import log10
m, d = map(int, input().split())
ans = 0
for month in range(1, m + 1):
    for date in range(1, d + 1):
        str_date = str(date)
        tmp = 1
        for char in str_date:
            if int(char) < 2 or len(str(date)) < 2:
                break
            tmp*= int(char)
        else:
            if tmp == month:

                ans += 1
print(ans)


Measured memory_bytes: 3060
using System;
using System.Linq;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] data = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            Sort s = new Sort(data);
            s.S_Three();
            s.Show();
        }
    }
    class Sort
    {
        int[] num;
        public Sort(int[] num) { this.num = num; }
        public void S_Three()
        {
            int cmp;
            for(int i = 0; i < num.Length - 1; i++)
            {
                for (int j = num.Length - 1; j > i; j--)
                {
                    if (num[j - 1] > num[j])
                    {
                        cmp = num[j - 1];
                        num[j - 1] = num[j];
                        num[j] = cmp;
                    }
                } 
            }
                      
        }
        public void Show()
        {
            int i = 1;
            foreach(int n in num)
            {
                Console.Write(n);
                if (i == num.Length) Console.WriteLine();
                else Console.Write(" ");
                i++;
            }
        }
    }
}

Measured memory_bytes: 9592
#include <iostream>

using namespace std;

typedef long long ll;

int il(ll a)
{
    int odp = 0;
    while (a != 0)
    {
        ++odp;
        a /= 10;
    }
    return odp;
}

int f(ll a, ll b)
{
    return max(il(a), il(b));
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n;
    cin >> n;
    int odp = 1e9;
    for (ll i = 1; i * i <= n; ++i)
        if (n % i == 0)
            odp = min(odp, f(i, n / i));
    cout << odp;
    return 0;
}


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

using namespace std;
#define endl "\n"
#define FILEIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define LL long long 
#define mod 1000000007LL
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
//#define p push
#define I insert
#define bg begin()
#define ed end()
#define sz size()
#define all(v) v.begin(),v.end()
typedef vector<LL> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef map<LL ,LL > mii;
//typedef priority_queue<int> pq;
typedef queue<int>que;
typedef stack<int>stk;
#define Inf 100000005LL
#define f first
#define s second






int main()
{
	LL n;
	
	cin>>n;
	LL sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0 || i%5==0)
		   continue;
        sum+=i;
	}
	cout<<sum<<endl;


}

Measured memory_bytes: 3636
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
typedef vector<int> vi;

int main() {
    int n,i;
    cin >> n;
    long long mod = 1000000007;
    vi a(n);
    long long sum =0,ans =0;
    f(i,0,n)
    {
        cin >> a[i];
        sum += a[i];
    }
    i=0;
    int j=0;
    f(i,0,n-1)
    {
        sum = (sum -a[i]);
        ans += ((sum%mod)*(a[i]%mod))%mod;
        ans %= mod;
    }
    cout << ans << endl;

   return 0;
}


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

int main() {
	string s,t;
	cin >> s;
	cin >> t;
	vector<int>ss, ts;
	for (size_t i = 0; i < s.length(); i++)ss.push_back(s.at(i) - 97);
	for (size_t i = 0; i < t.length(); i++)ts.push_back(t.at(i) - 97);
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	int l = min(ss.size(), ts.size());
	for (size_t i = 0; i < l; i++) {
		if (s.at(i) < t.at(i)) {
			cout << "Yes" << endl;
			return 0;
		}
		else if (s.at(i) > t.at(i)) {
			cout << "No" << endl;
			return 0;
		}
	}
	if (ss.size() < ts.size())cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(void){
    ll n;
    cin >> n;
    vector<ll> A(n);
    for(auto& it : A) cin >> it;
    
    vector<ll> a = A;
    ll total = 0;
    ll ans1 = 0;
    for(ll i=0;i<n;i++){
        if(total > 0){
            if(total + a[i] >= 0) {
                ans1 += abs(-total-1 - a[i]);
                a[i] = -total-1;
            }
        } else {
            if(total + a[i] <= 0) {
                ans1 += abs(-total+1  - a[i]);
                a[i] = -total+1;
            }
        }
        total += a[i];
    }

    a = A;
    total = 0;
    ll ans2 = 0;
    for(ll i=0;i<n;i++){
        if(total >= 0){
            if(total + a[i] >= 0) {
                ans2 += abs(-total-1 - a[i]);
                a[i] = -total-1;
            }
        } else {
            if(total + a[i] <= 0) {
                ans2 += abs(-total+1  - a[i]);
                a[i] = -total+1;
            }
        }
        total += a[i];
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}

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

bool isUruu(int y){
  if(y%4 == 0){
    if(y%100 == 0){
      if(y%400 == 0)return true;
      return false;
    }
    return true;
  }
  return false;
}

int main(){
  int a, b;
  bool first = false;
  while(std::cin >> a >> b, a){
    if(first)std::cout << std::endl;
    first = true;
    bool flag = false;
    for (int i = a; i <= b; i++) {
      if(isUruu(i)){
        std::cout << i << std::endl;
        flag = true;
      }
    }
    if(flag == false)std::cout << "NA" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <cctype>
#include <algorithm>
#include <cstdio>
typedef long long int64;
using namespace std;
inline int read(int f = 1, int x = 0, char ch = '-')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x; 
}
const int N = 1e5+5;
int n, m, s[N];
int64 t;
int main()
{
    n = read();
    for(int i = n; i; --i) s[i] = read(), t += s[i]; s[n+1] = s[1];
    if(t%(n*(n+1ll)/2)) return puts("NO"), 0;
    m = t/(n*(n+1ll)/2); 
    for(int i = n; i; --i) if((m+s[i+1]-s[i])%n||m+s[i+1]-s[i] < 0) return puts("NO"), 0;
    puts("YES");
    return 0;
}
/*
2
99998 1
*/

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
  int i,t=0,f=0;
  char s[10];
  scanf("%s",s);
  for(i=0;i<3;i++){
    if(s[i]=='R'&&f==0){
    t++;
    }
      else if(s[i]=='S'&&t>0){
        f=1;
    }
  }
  printf("%d\n",t);
  return 0;
}

Measured memory_bytes: 1724
n = int(input())

if n == 1:
    print('0')
    exit()

c = [tuple(int(x) for x in input().split()) for _ in range(n - 1)]

c.append((0,0,1))

ans = [0 for _ in range(n)]

ans[n - 1] = 0

for i in range(n - 2, -1, -1):
    temp = c[i][0] + c[i][1]
    if temp <= c[i + 1][1]:
        ans[i] = 0 + ans[i + 1]
    else:
        for j in range(i + 1, n - 1):
            if c[j][1] >= temp:
                temp = c[j][1] + c[j][0]
            else:
                d = (temp - c[j][1]) // c[j][2]
                if ((temp - c[j][1]) % c[j][2]) != 0:
                    d += 1
                temp = c[j][1] + c[j][2] * d + c[j][0]
        ans[i] = temp

for x in ans:
    print(x)







Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        solve();
    }

    void solve() {
        if (n % f(n) == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    int f(int n) {
        int ret = 0;
        while (n > 0) {
            ret += n % 10;
            n /= 10;
        }
        return ret;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        
        int[] a = new int[M], b = new int[M];
        Set<Integer> land1 = new HashSet<>(), landN = new HashSet<>();
        
        for(int i = 0; i < M; i++) {
            a[i] = scanner.nextInt();
            b[i] = scanner.nextInt();
            
            if(a[i] == 1) {
                land1.add(b[i]);
            }
            if(b[i] == N) {
                landN.add(a[i]);
            }
        }
        boolean result = (land1.stream().filter(landN::contains).count() != 0);
        
        System.out.println(result ? "POSSIBLE" : "IMPOSSIBLE");
    }
}

Measured memory_bytes: 119196
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
//lg=ab
ll lcm(ll a,ll b){
 return a/(__gcd(a,b))*b; 
}

int main(){cout<<fixed<<setprecision(20);
		   ll n;
           cin>>n;
           vin t(n),a(n);
           rep(i,0,n)cin>>t[i]>>a[i];
           ll ao=a[0],ta=t[0];
           rep(i,1,n){
            //両方持ち数以上になるまで、繰り返し足す 
            ll time_a=0;
             if(ao>a[i]){
              time_a=(ao+a[i]-1)/a[i];
             }
            ll time_b=0;
             if(ta>t[i]){
              time_b=(ta+t[i]-1)/t[i];
             }
             ll k=max(time_a,time_b);
             if(k==0)k++;
             ao+=k*a[i]-ao;
             ta+=k*t[i]-ta;
             //cout<<ta<<" "<<ao<<endl;
           }
           cout<<ao+ta<<endl;
}

Measured memory_bytes: 3568
n = int(input())
p = [int(i) for i in input().split()]
ans = 0

for i in range(n):
  if i == 0 or i == n-1:
    continue
  
  x = p[i-1:i+2]
  y = sorted(x)

  if y[1] == p[i]:
    ans +=1
    
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int a;
  a=s.size();
  int i,j;
  for(i=0;i<a;i++){
    if(s.at(i)=='A'){
      break;
    }
  }
  for(j=a-1;j>=0;j--){
    if(s.at(j)=='Z'){
      break;
    }
  }
  cout << j-i+1 << endl;}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0 ;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(x) x.begin(),x.end()
#define REVERSE(x) reverse(x.begin(),x.end())
#define SORT(x,n) sort(x,x)
#define P pair<int,int>
typedef long long LL;
const int INF=1000000007;
using namespace std;
int gcd(int a,int b){
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}

int main(){
int N;
cin>>N;
vector<int> water(N+1);
vector<int> rain(N+1);
for(int i=1;i<=N;i++){
    cin>>water[i];
}
for(int i=1;i<=N;i++){
    if(i%2==1){
        rain[1]+=water[i];
    }
    else{
        rain[1]-=water[i];
    }
}
rain[1]=rain[1]/2;
for(int i=2;i<=N;i++){
    rain[i]=water[i-1]-rain[i-1];
}
for(int i=1;i<=N;i++){
    cout<<rain[i]*2<<' ';
}
}

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

int main(){
  int n,ans=3;
  char color;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>color;
    if(color=='Y'){
      ans=4;
    }
  }
  if(ans==3){
    cout<<"Three"<<endl;
  }else{
    cout<<"Four"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;



int bills[3] = {10000, 5000, 1000};

int main() {
    int N, Y;
    cin >> N >> Y;


    rep(i, N+1) {
        rep(j, N+1) {
            int k = N-(j+i);
            if(k<0) continue;
            if(bills[0]*i+bills[1]*j+bills[2]*k==Y) {
                print(i, j, k);
                return 0;
            }
        }
    }

    print(-1, -1, -1);


    return 0;
}

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

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

  if (s.at(2) == s.at(3))
  {
    if (s.at(4) == s.at(5))
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
  else
  {
    cout << "No" << endl;
  }
}

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

using namespace std;
typedef long long ll;

int main(){
ll n;
cin>>n;
ll sum = 0;

vector<ll> v(n);

for(int i = 0 ; i < n ; i++) cin>>v[i];

for(int i = 0 ; i < n ; i++){
  for(int j = i+1; j < n ; j++){
    sum += v[i]*v[j];
  }
}
cout<<sum<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    ll N,X;
    cin>>N>>X;
    ll t,bef;
    REP(i,N){
        cin>>t;
        t=abs(t-X);
        if(i>0){
            bef=gcd(bef,t);
        }else bef=t;
    }
    
    
    cout<<fixed<<setprecision(10)<<bef;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

a = list(map(int,input().split()))

b = list(map(int,input().split()))

score = 0

for i in range(n):
  if a[i] >= b[i]:
    score += b[i]
  elif a[i] < b[i]:
    if a[i+1] >= b[i] - a[i]:
      score += b[i]
      a[i+1] -= b[i] - a[i]
    elif a[i+1] < b[i] - a[i]:
      score += a[i] + a[i + 1]
      a[i+1] = 0
      
print(score)

Measured memory_bytes: 19004
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
    string cards['e'];
    cin>>cards['a']>>cards['b']>>cards['c'];
    //cout<<cards['a']<<endl<<cards['b']<<endl<<cards['c']<<endl;
    char current='a';
    int head['e'];
    head['a']=head['b']=head['c']=0;
    while(1){
        if(head[current]==cards[current].size()){
            break;
        }
        char temp=cards[current][head[current]];
        head[current]++;
        current=temp;
    }
    cout<<char(current-'a'+'A')<<endl;
    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

char c[MAXN];

void solve(){
	scanf("%s", &c[0]);
	int n = strlen(c);
	ll ans = 0ll, cur = 0ll;
	REP(i, 0, n) {
		if (c[i] == 'B') {
			cur++;
		} else {
			ans += cur;
		}
	}
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

signed main()
{
  int N; cin>>N;
  vector<int> a(N+1);
  for(int i=1;i<=N;i++){
    cin>>a[i];
  }
  
  vector<int> cnt(N+1);
  for(int i=N;i>=1;i--){
    int c=0;
    for(int j=i*2;j<=N;j+=i){
      c+=cnt[j];
    }
    if(a[i]!=c%2){
      cnt[i]++;
    }
  }

  int M=0;
  for(int i=1;i<=N;i++){
    M+=cnt[i];
  }
  cout<<M<<endl;
  for(int i=1;i<=N;i++){
    if(cnt[i]==1) cout<<i<<' ';
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 3968
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;


vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}


int main(void){
    ll n;
    cin >>n;
    vector<ll> input(n);
    map<ll, ll> inputmap;
    REP(i,n){
        cin >> input[i];
        inputmap[input[i]]++;
    }

    ll cnt = n;
    REP(i,n){
        if(inputmap[input[i]] > 1){
            cnt--;
            continue;
        }
        const auto &res =enum_divisors(input[i]);

        for(auto x: res){
            if(x == input[i]){continue;}
            if(inputmap.find(x) != inputmap.end()){ 
                cnt--;
                break;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 16792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG
 
int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}
 
int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}
 
void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}
 
void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}
 
void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}
 
void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}
 
 
 
int main() {
  int N;
  cin >> N;
  if(N==1){
    cout << "Hello World";
  }
  else{
    int A,B;
    cin >> A >> B;
    cout << A+B;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

vector<string> split(const string& str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buf;
  while (getline(ss, buf, sep)) {
    v.push_back(buf);
  }
  return v;
}

int main()
{
  // ABC119_A
  string S; cin >> S;
  vector<string> res(split(S, '/'));

  if (stoi(res[1]) > 4) cout << "TBD";
  else cout << "Heisei" << endl;

  return 0;
}

Measured memory_bytes: 256