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

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'


int main() {
    int n;
    cin >> n;
    vi a(n+1);
    rep1(i, n){
        cin >> a[i];
    }

    vi b(n+1);

    rrep1(i, n){
        int p = n / i;
        int x = 0;
        REP(j, 1, p+1){
            x += b[i*j];
            x %= 2;
        }
        if(x != a[i])
            b[i]++;
    }

    int sum = 0;
    rep1(i,n){
        if(b[i] == 1)
            sum += 1;
    }
    cout << sum << endl;
    
    bool flag = 0;
    rep1(i,n){
        if(b[i] == 1){
            flag = 1;
            cout << i << ' ';
        }
    }
    if(flag)
        cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
using ll=long long;

int main(){
  int N; cin>>N;
  int A[N]; REP(i,N) cin>>A[i];
  vector<ll> v={-1};
  REP(i,N) {
    auto itr=lower_bound(ALL(v),A[i]);
    if(itr==v.begin()) v.insert(v.begin(),A[i]);
    else *--itr=A[i];
  }
  cout<<v.size()<<endl;
}

Measured memory_bytes: 4632
x = int(input())
dp = [False] * max(106, x + 1)
for i in range(100, 106):
    dp[i] = True
for i in range(106, x + 1):
    dp[i] = any(dp[i - j] for j in range(100, 106))
print(1 if dp[x] else 0)

Measured memory_bytes: 3828
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std ;
int main(){
    int a,b,c,i,n;
    int d;
    int arr[500];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    int j,k;
    j = arr[2]-arr[1];
    k = arr[2]-arr[0];
    n = 0;
    //cout<<j<<' '<<k<<endl;
        n = n + j/2;
        if(j%2==0){
            j=0;
        }
        else{
            j=1;
        }
        n = n + k/2;
        if(k%2==0){
            k=0;
        }
        else{
            k=1;
        }
    //cout<<n<<endl;
    if(k==0&&j==0){
        cout<<n;
    }
    else if(k==1&&j==1){
        cout<<n+1;
    }
    else{
        cout<<n+2;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> p(n*n), cost(n*n, 0);
    vector<bool> sit(n*n, true);
    for(int i=0;i<n*n;++i) {
        cin >> p[i];
        --p[i];
    }
    for(int i=0;i<n*n;++i) {
        int y = i/n, x = i % n;
        cost[i] = min({y, n-1-y, x, n-1-x});
    }

    int ans = 0LL;
    for(int i=0;i<n*n;++i) {
        ans += cost[p[i]];
        
        queue<int> que;
        que.push(p[i]);
        sit[p[i]] = false;
        while(!que.empty()) {
            int j = que.front(); que.pop();
            int y = j/n, x = j % n;
            for(int k=0;k<4;++k) {
                int yy = y + dyx[k][0], xx = x + dyx[k][1];
                if(0 <= yy && yy < n && 0 <= xx && xx < n && cost[yy * n + xx] > cost[y * n + x] + int(sit[y * n + x])) {
                    cost[yy * n + xx] = cost[y * n + x] + int(sit[y * n + x]);
                    que.push(yy * n + xx);
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5292
#include <iostream>
#include <stack>
#include <sstream>
#include <cctype>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cfloat>
#include <cmath>
using namespace std;

int main() {
  string str;
  double a, b;

  while( getline(cin, str) ) {
    stack<double> st;
    stringstream ss(str);
    string s;

    a = atof( s.c_str() );
    st.push( a );
    while( ss >> s ) {
      if( s.size() > 1 ||isdigit( s[0] ) ) {
	a = atof( s.c_str() );
	st.push( a );
      }
      else if( s == "+" ) {
	a = st.top(); st.pop();
	b = st.top(); st.pop();
	st.push( b+a );
      }
      else if( s == "-") {
	a = st.top(); st.pop();
	b = st.top(); st.pop();
	st.push( b-a );
      }
      else if( s == "*" ) {
	a = st.top(); st.pop();
	b = st.top(); st.pop();
	st.push( b*a );
      }
      else if( s == "/" ) {
	a = st.top(); st.pop();
	b = st.top(); st.pop();
	if( a == 0 ) exit(EXIT_FAILURE);
	st.push( b/a );
      }
    }
    printf("%.6lf\n", st.top());
  }
  
  return 0;
}

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

int main() {
    int N, T, i, c, t, ans;
    int cmin = 1001;
    cin >> N;
    cin >> T;


    for (i=0; i<N; i++){
        cin >> c;
        cin >> t;
        if (t <= T && c < cmin) cmin = c;
    }

    if (cmin==1001) cout << "TLE";
    else cout << cmin << '\n';
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

int base(v32 arr, v32 lol)
{
	int ans = 1e9;
	do
	{
		int tmp = abs(arr[0] - lol[0]) + abs(arr[1] - lol[1]) + abs(arr[2] - lol[2]);
		ans = min(ans, tmp);
	} while (next_permutation(lol.begin(), lol.end()));
	return ans;
}
void solve(int tc)
{
	int n;
	v32 arr(3, 0);
	cin >> n >> arr[0] >> arr[1] >> arr[2];
	v32 lol(n, 0);
	for (int i = 0; i < n; i++)
		cin >> lol[i];
	int ans = 1e9;
	for (int i = 1; i < (1 << n); i++)
	{
		for (int j = 1; j < (1 << n); j++)
		{
			if ((i & j))
				continue;
			for (int k = 1; k < (1 << n); k++)
			{
				if ((i & k) || (j & k))
					continue;
				v32 work(3, 0);
				int cost = -30;
				for (int l = 0; l < n; l++)
				{
					int t = (1 << l);
					if (i & t)
						work[0] += lol[l], cost += 10;
					if (j & t)
						work[1] += lol[l], cost += 10;
					if (k & t)
						work[2] += lol[l], cost += 10;
				}
				cost += base(work, arr);
				ans = min(ans, cost);
				db(i, j, k, ans);
			}
		}
	}
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 256
N = gets.to_i
T , A = gets.split.map!{|i| i.to_i}
H = gets.split.map!{|i| T - (i.to_i) * 0.006}
min = 10 ** 4
k = 0

N.times do |i|
    if min > (A - H[i]).abs
        min = (A - H[i]).abs
        k = i + 1
    end
end

puts k

Measured memory_bytes: 1788
package main

import (
        "bufio"
        "fmt"
        "os"
        "sort"
        "strconv"
        "strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
type Pair struct {
        p, y int
}

func main() {
        line := nextLine()

        spl := strSprit(line)
        N := parseInt(spl[0])
        M := parseInt(spl[1])

        indexes := make(map[Pair]int, M)
        years := make([][]int, N+1)
        for i := 0; i <= N; i++ {
                years[i] = []int{}
        }

        for i := 1; i <= M; i++ {
                s := intSprit(nextLine())
                years[s[0]] = append(years[s[0]], s[1])
                p := Pair{s[0], s[1]}
                indexes[p] = i
        }

        for i := 0; i <= N; i++ {
                sort.Ints(years[i])
        }

        ans := make([]string, M+1)

        for i := 1; i <= N; i++ {
                y := years[i]
                for idx, val := range y {
                        tp := Pair{i, val}
                        ai := indexes[tp]
                        ans[ai] = fmt.Sprintf("%06d%06d", i, idx+1)
                }
        }
        for i := 1; i <= M; i++ {
                fmt.Println(ans[i])
        }

}

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

using namespace std;
#define N_ 101000
int Deg[N_], Q[N_], head, tail, n, m, D[N_];
vector<int>E[N_];
int main() {
	int i, a, b;
	scanf("%d%d", &n,&m);
	for (i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		Deg[b]++;
	}
	for (i = 1; i <= n; i++) {
		if (!Deg[i])Q[++tail] = i;
	}
	int res = 0;
	while (head < tail) {
		int x = Q[++head];
		res = max(res, D[x]);
		for(int y=0;y<E[x].size();y++) {
			Deg[E[x][y]]--;
			D[E[x][y]] = max(D[E[x][y]], D[x] + 1);
			if (!Deg[E[x][y]])Q[++tail] = E[x][y];
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 6912
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    string ans = "No";
    if (s[0] == s[1] && s[1] == s[2]) {
        ans = "Yes";
    }
    if (s[1] == s[2] && s[2] == s[3]) {
        ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())

a=[]
b=[]
for i in range(N):
    a0,b0=map(int,input().split())
    a.append(a0)
    b.append(b0)

c=[]
d=[]
for i in range(M):
    c0,d0=map(int,input().split())
    c.append(c0)
    d.append(d0)

for i in range(N):
    l0=abs(a[i]-c[0])+abs(b[i]-d[0])
    ans=1
    for j in range(1,M):
        l=abs(a[i]-c[j])+abs(b[i]-d[j])
        if l0>l:
            l0=l
            ans=j+1
    
    print(ans)

Measured memory_bytes: 9128
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const N = lines[0] - 0
const L = lines[1].split(' ').map(Number)

const seq = (n, m) => {
    const ss = []
    const s = []
    let v = 0
    while (v !== undefined) {
        if (s.length === n) {
            ss.push([...s])
            s.pop()
        } else if (v >= m) {
            v = s.pop()
        } else {
            v++
            s.push(v)
        }
    }
    return ss
}

const s = seq(3, N)

let count = 0
for (let i = 0; i < s.length; i++) {
    const t = [L[s[i][0] - 1], L[s[i][1] - 1], L[s[i][2] - 1]]
    if (t[0] === t[1] || t[0] === t[2] || t[1] === t[2]) {
        continue
    }
    const l = Math.max(...t)
    const o = t.reduce((a, b) => a + b) - l
    if (l < o) {
        count++
    }
}

console.log(count)

Measured memory_bytes: 65592
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int x;
    cin >> x;

    for(int i = -1000; i <= 1000; ++i){
        for(int j = -1000; j <= 1000; ++j){
            if(i * i * i * i * i - j * j * j * j * j == x){
                return cout << i << ' ' << j << '\n', 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 1e5 + 5 ;
using namespace std ;
int X, Y, Z, n, top, q[N] ; ll sum, f[N] ;
struct poi { int x, y, z ; } a[N] ;
bool cmp(poi a, poi b) { return a.x - a.y < b.x - b.y ; }
void push(int x) { sum -= x ; q[top ++] = x, push_heap(q, q + top) ; }
void pop() { sum += q[0] ; pop_heap(q, q + top), -- top ; }
int main() {
	scanf("%d%d%d", &X, &Y, &Z) ;
	n = X + Y + Z ;
	rep(i, 1, n) scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z) ;
	sort(a + 1, a + n + 1, cmp) ;
	sum = 0 , top = 0 ;
	rep(i, 1, Y) sum += a[i].z, push(a[i].z - a[i].y) ; f[Y] = sum ;
	rep(i, Y + 1, n - X) {
		sum += a[i].z ;
		push(a[i].z - a[i].y), pop(), f[i] = sum ;
	}
	sum = 0, top = 0 ;
	for (int i = n ; i > n - X ; -- i) sum += a[i].z, push(a[i].z - a[i].x) ; f[n - X] += sum ;
	for (int i = n - X ; i > Y ; -- i) {
		sum += a[i].z ;
		push(a[i].z - a[i].x), pop(), f[i - 1] += sum ;
	}
	ll ans = 0 ;
	rep(i, 1, n) ans = max(ans, f[i]) ;
	printf("%lld\n", ans) ;
	return 0 ;
}

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


int main() {
    int a,b;
    cin >> a >> b;
    if((a*b)%2)cout << "Odd\n";
    else cout << "Even\n";
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

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

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

    string a, b;
    cin >> a >> b;
    int n = a.size();
    if(a == b) {
        cout << 0 << endl;
        return 0;
    }
    if(count(ALL(b), '1') == 0) {
        cout << -1 << endl;
        return 0;
    }

    int l[2009]{}, r[2009]{};
    {
        int i = 0;
        while(b[i] == '0')
            i++;
        rep(j, n) {
            if(b[(i + j) % n] != '1')
                l[(i + j) % n] = l[(i + j - 1 + n) % n] + 1;
        }
    }
    {
        int i = n - 1;
        while(b[i] == '0')
            i--;
        FORR(j, n) {
            if(b[(i + j) % n] != '1') r[(i + j) % n] = r[(i + j + 1) % n] + 1;
        }
    }

    vector<int> vec[2009];
    int res = 1 << 30;
    rep(d, n) {
        fill(ALL(vec), vector<int>());
        int cnt = 0;
        rep(i, n) if(a[i] != b[(i + d) % n]) {
            cnt++;
            if(r[i] > d) vec[l[i]].push_back(r[(i + d) % n]);
        }
        int mx = 0;
        FORR(i, n) {
            chmin<int>(res, cnt + (i + mx) * 2 + d);
            for(int &x : vec[i])
                chmax(mx, x);
        }

        fill(ALL(vec), vector<int>());
        cnt = 0;
        rep(i, n) if(a[i] != b[(i - d + n) % n]) {
            cnt++;
            if(l[i] > d) vec[r[i]].push_back(l[(i - d + n) % n]);
        }
        mx = 0;
        FORR(i, n) {
            chmin<int>(res, cnt + (i + mx) * 2 + d);
            for(int &x : vec[i])
                chmax(mx, x);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a[21],n,b[51],c[51],i,d=0;
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
cin>>b[i];
for(i=0;i<(n-1);i++)
cin>>c[i];

for(i=0;i<n;i++)
d+=b[i];
for(i=0;i<(n-1);i++)
{
	if(a[i+1]==(a[i]+1))
d+=c[a[i]-1];
}
cout<<d;
return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main(){
  string s,t,u;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  cin >> u;
  if(u == s) cout << --a << " "<< b << endl;
  else if(u == t) cout << a << " " << --b << endl;
  else cout << a << " " << b << endl;
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n,k,sum=0,count=0;
  while(true){
    cin>>n;
    if(n==0) break;
    else{
      for(int i=0;i<n;i++){
	cin>>k;
	if(k>1){
	  count++;
	  sum++;
	}
	else if(k>=1) sum++;
      }
      if(count==0){
	cout<<"NA"<<'\n';
	sum=0;
	count=0;
      }
      else{
	cout<<sum+1<<'\n';
	sum=0;
	count=0;
      }
    }
  }
  return(0);
}



Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define FOR(i, n, m) for (int i = (n); i < (m); ++i)

const int MOD = 1000000007;

ll comb[51][51];

void init() {
  REP (n, 51) REP (k, n+1) {
    if (k==0 || k==n) comb[n][k] = 1;
    else comb[n][k] = comb[n-1][k-1]+comb[n-1][k];
  }
}

int N, A, B;
vi V;

int main() {

  init();
  cin >> N >> A >> B;
  V = vi(N);
  REP (i, N) cin >> V[i];
  sort(V.rbegin(), V.rend());

  ll sum = 0;
  REP (i, A) sum += V[i];
  cout << fixed << setprecision(8) << 1.0*sum/A << endl;

  ll X = V[A-1];

  int c1 = 0;
  REPR (i, A) {
    if (V[i] == X) c1++;
    else break;
  }
  int c2 = 0;
  FOR (i, A, N) {
    if (V[i] == X) c2++;
    else break;
  }

  ll p = 0;

  if (V[0] != X) {
    p = comb[c1+c2][c1];
  } else {
    FOR (k, A, min(B, A+c2)+1) {
      p += comb[c1+c2][k];
    }
  }

  cout << p << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, m, x, y, p[100009], par[100009];
int root(int v) {
	if (v == par[v]) return v;
	return par[v] = root(par[v]);
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> p[i]; --p[i];
		par[i] = i;
	}
	for (int i = 0; i < m; ++i) {
		cin >> x >> y; --x, --y;
		par[root(x)] = root(y);
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (root(i) == root(p[i])) ++cnt;
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 1024
// you should probably see at the bottom ..
#include<bits/stdc++.h>

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(1e6 + 10)
#define ff first
#define ss second

using namespace std;

vector<int> noCnt(N), prCnt(N);

void solve() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        noCnt[a]++;
    }
    int hasOne = 0, hasAll = 0;
    int got = 0;

    bitset<N> b;
    for (int i = 2; i < N; i++) {
        if (!b[i]) {
            for (int j = i; j < N; j += i) {
                if (noCnt[j])
                    prCnt[i] += noCnt[j];
                b[j] = true;
            }
        }

        if (prCnt[i]) {
            got++;
            if (prCnt[i] == 1) hasOne++;
            if (prCnt[i] == n) hasAll++;
        }
    }

    if (hasOne == got) cout << "pairwise coprime" << endl;
    else if (!hasAll) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;

}

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
    int t_c = 1;
//    cin >> t_c;
    while (t_c--)
        solve();
}

/*
 * COME ON DUDE .... DONT GET UP UNTIL U GET THE SOLUTION
 * GIVING UP NOT GONNA HELP .. JUST GET YOUR ASS TO WORK ALREADY ..
 * AND FOR FUCKING SAKE ... DONT PANIC !!
*/


Measured memory_bytes: 19048
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d1, d2, d3;
  cin >> n;
  d1 = n % 10;
  d2 = (n / 10) % 10;
  d3 = (n / 100) % 10;
  if (d1 == 7) {
    cout << "Yes" << endl;
  }
  else if (d2 == 7) {
    cout << "Yes" << endl;
  }
  else if (d3 == 7) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, k = MAP()
t = n // k
ans = min(abs(n - k * t), abs(n - k * (t + 1)))
print(ans)

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

using namespace std;
int main()
{
	char b;
	cin >> b;
	if (b == 'A')cout << "T" << endl;
	if (b == 'C')cout << "G" << endl;
	if (b == 'G')cout << "C" << endl;
	if (b == 'T')cout << "A" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    bool flag = 0;
    for (ll i = 0; i < s.size(); i += 2)
    {
        if (s[i] != 'h' || s[i + 1] != 'i')
        {
            flag = 1;
        }
    }
    if (flag)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort()
l = [0] * A[-1]
for i in range(N):
    l[A[i] - 1] += 1
for i in range(N):
    if l[A[i] - 1] > 1:
        l[A[i] - 1] = 0
    elif l[A[i] - 1] == 0:
        continue
    temp = A[i]
    while True:
        temp += A[i]
        if temp > A[-1]:
            break
        l[temp - 1] = 0
print(sum(l))

Measured memory_bytes: 32096
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int mx = a + b;
  int r = 0;
  int bc = b;
  for (auto &c: s){
    if (c == 'b') bc--;
    if (r < mx){
      if (c == 'a') r++, cout << "Yes" << endl;
      else if (c == 'b' and bc >= 0) r++, cout << "Yes" << endl;
      else cout << "No\n";
    } else {
      cout << "No\n";
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

Measured memory_bytes: 848
program main
implicit none
integer :: i
integer :: yymm, mmyy

yymm = 1
mmyy = 1
read(*,*) i
if(i/100 >12 .or. i/100 <1 ) then
   mmyy = 0
end if
if( mod(i,100) == 0 .or. mod(i,100) >12 ) then
   yymm = 0
end if

if( mmyy == 1 ) then
   if ( yymm == 1 ) then
      write(*,*) 'AMBIGUOUS'
   else
      write(*,*) 'MMYY'
   end if
else
   if ( yymm == 1 ) then
      write(*,*) 'YYMM'
   else
      write(*,*) 'NA'
   end if
end if



end program main


Measured memory_bytes: 640
N,K = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]

INF = 10**9
dp = [INF] * N
dp[0] = 0

for i in range(0, N - 1):
    for k in range(0, min(i + 1, K)):
        if dp[i + 1] > dp[i - k] + abs(H[i + 1] - H[i - k]):
            dp[i + 1] = dp[i - k] + abs(H[i + 1] - H[i - k])


print(dp[N - 1])

Measured memory_bytes: 52576
//Om Sree Sai Ram
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
vector<int> dp;



int main() 
{
  
 // cout<<" Hello world"<<endl;   
  int n;
  cin>>n;
  vector<int> dp(3);
  for(int i=0;i<n;i++)
  {
    vector<int> p(3);
    for(int j=0;j<3;j++)
    {
      cin>>p[j];
    }

    vector<int> new_dp(3);
    for(int j=0;j<3;j++)
    {
      for(int k=0;k<3;k++)
      {
        if(j!=k)
        {
          new_dp[j] = max(dp[k]+p[j],new_dp[j]);
        }
      }
    }
    dp = new_dp;
  }
  cout<<max({dp[0],dp[1],dp[2]})<<endl;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> vec(N);
	int ans = 0;
	for(int i = 0; i < N; i++){
		cin >> vec.at(i);
		ans += vec.at(i) - 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){

    vector<long long>v(3);
    long long k;
    cin >> v[0] >> v[1] >> v[2] >> k;

    if(k % 2 == 0){
        cout << v[0] - v[1] << endl;
    }
    else{
        cout << -v[0] + v[1] << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;

    ll n; cin >> n;
    set<string> st;
    
    rep(i,0,n){
        string s; cin >> s;
        st.insert(s);
    }
    //消すときはerase()

    cout << st.size() << endl;
    return 0;
}


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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.length() - 1] == b[0] and b[b.length() - 1] == c[0]){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let mut S = rl().chars().collect::<Vec<_>>();

    S.sort();
    let ok = S[0] == S[1] && S[1] != S[2] && S[2] == S[3];
    println!("{}", if ok { "Yes" } else { "No" })
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

string S, T;

vector<int> findStart(string S, char t)
{
  vector<int> result;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '?' || S[i] == t) result.push_back(i);
  }
  return result;
}

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

  int idx = inf;
  vector<int> starts = findStart(S, T[0]);
  for (auto start : starts) {
    int cnt = 0;
    for (int i = start; i < min(start + T.size(), S.size()); i++) {
      if (S[i] != T[cnt] && S[i] != '?') break;
      cnt++;
    }
    if (cnt == T.size()) idx = start;
  }

  // idx なければ復元不可
  if (idx == inf) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  int ti = 0;
  for (int i = 0; i < T.size(); i++) {
    S[idx + i] = T[ti++];
  }

  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '?') S[i] = 'a';
  }

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

N = int(input())

S1 = []
S2 = []
for n in range(N):
    s = int(input())
    if s % 10 == 0:
        S1.append(s)
    else:
        S2.append(s)

if len(S2) == 0:
    print(0)
else:
    ans = sum(S2)
    if ans % 10 == 0:
        S2.sort()
        ans -= S2[0]
    ans += sum(S1)
    print(ans)


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

int main(){

	long double xa, ya, xb, yb, xc, yc, xd, yd;

	while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd){
		if ((yb-ya)*(yd-yc) + (xd-xc)*(xb-xa) == 0)
		{
			cout <<"YES"<< endl;
		}
		else
		{
			cout <<"NO"<< endl;
		}

	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> a(n); rep(i, n) cin >> a[i];
	
	ll x = 0;
	rep(i, n) {
		if (i % 2) x -= a[i];
		else x += a[i];
	}

	vector<int> ans(n);
	ans[0] = x / 2;
	rep(i, n - 1) {
		ans[i + 1] = a[i] - ans[i];
	}
	rep(i, n) printf("%d ", ans[i] * 2);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2048
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll a, b, k;
  scanf("%lld%lld%lld", &a, &b, &k);
  if (b - a < k * 2)
  {
    for (int i = a; i <= b; i++)
    {
      printf("%d\n", i);
    }
  }
  else
  {
    for (int i = 0; i < k; i++)
    {
      printf("%lld\n", a + i);
    }
    for (int i = k; i; i--)
    {
      printf("%lld\n", b - i + 1);
    }
  }
  return 0;
}

Measured memory_bytes: 128
#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

#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

#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

int playerNumber(char a){
    if(a == 'a') return 0;
    else if(a == 'b') return 1;
    else return 2;
}

int main(){
    int p[3] = {0}, t = 0;
    string s[3];
    rep(i,3) cin >> s[i];

    while(true){
        if(s[t].size() == p[t]) break;
        p[t]++;
        t = playerNumber(s[t][p[t] - 1]);
    }

    if(t == 0) cout << 'A' << endl;
    else if(t == 1) cout << 'B' << endl;
    else cout << 'C' << endl;
}



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

bool dp[90][90][14000];

int main(){ 
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h+1, vector<int>(w+1)), b(h+1, vector<int>(w+1));
  rep(i,h) rep(j,w) cin >> a[i][j];
  rep(i,h) rep(j,w) cin >> b[i][j];
  dp[0][0][6800+a[0][0]-b[0][0]] = true;
  dp[0][0][6800+b[0][0]-a[0][0]] = true;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      for (int k = 0; k <= 12800; k++) {
        if (dp[i][j][k]) {
          dp[i][j+1][k+a[i][j+1]-b[i][j+1]] = true;
          dp[i][j+1][k+b[i][j+1]-a[i][j+1]] = true;

          dp[i+1][j][k+a[i+1][j]-b[i+1][j]] = true;
          dp[i+1][j][k+b[i+1][j]-a[i+1][j]] = true;
        }
      }
    }
  }
  int res = 1e9;
  for (int k = 0; k < 13000; k++) {
    if (dp[h-1][w-1][k]) res = min(res, abs(k - 6800));
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 99968
#include<bits/stdc++.h>
using namespace std;
int main(){
  string n;
  queue<char> qi;
  while(cin >> n,n!="0"){
    int a=0;
    for(int j=0;j<n.size();j++)
      qi.push(n[j]);
    for(int i=0;i<n.size();i++){
      int b=0;
      b=qi.front();
      qi.pop();
      a+=(b-'0');
    }
    cout<<a<<endl;
  }
  return 0;
}

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

#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end();
#define sz(x) (int)(x).size()
#define FOR_(i, a, b, s) \
  for (int i = (a); (s) > 0 ? i < (b) : i > (b); i += (s))
#define FOR1(n) FOR_(i, 0, n, 1)
#define FOR2(i, n) FOR_(i, 0, n, 1)
#define FOR3(i, a, b) FOR_(i, a, b, 1)
#define GET5(_1, _2, _3, _4, _5, ...) _5
#define FOR(...) GET5(__VA_ARGS__, FOR_, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define each(x, a) for (auto&& x : a)

using namespace std;

using ll = long long;
using ld = long double;
template <typename A>
using vt = vector<A>;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void()
#endif

constexpr int MX = 200005;
constexpr int INF = 1000000202;
constexpr ll LINF = 1000000000000000202LL;
constexpr ll MOD = 1000000007;  // 998244353;
constexpr ld PI = 3.1415926535897932384626433832795029L;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int ans;
  if (s == "RRR")
    ans = 3;
  else if (s == "RRS" || s == "SRR")
    ans = 2;
  else if (s == "SSS")
    ans = 0;
  else
    ans = 1;
  cout << ans;
  return 0;
}


Measured memory_bytes: 3652
#include <cassert>

#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>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// 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>
#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>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,0,n)cin>>v[i];
    v.erase(unique(v.begin(),v.end()),v.end());
    rep(i,0,v.size()){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}



/*
1 2 3 4 5

6
*/



Measured memory_bytes: 3100