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

int main(){
  int N;
  cin >>N;
  array<string,100> ar;
  cin >> ar[0];
  for(int i=1;i<N;i++){
    cin >> ar[i];
    if(ar[i-1][ar[i-1].size()-1] != ar[i][0]){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j <N;j++){
      if(ar[i] == ar[j]){
        cout << "No"<<endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;

    vector<char> list { 'A', 'C', 'G', 'T' };

    int maxSize = 0;
    int current = 0;

    for (int i = 0; i < s.size(); i++) {
        if (find(list.begin(), list.end(), s[i]) != list.end()) {
            current++;
        } else {
            maxSize = max(current, maxSize);
            current = 0;
        }
    }

    cout << max(current, maxSize);

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

def main():
  MAX = 3652425
  n, q = map(int, input().split())
  lst = [tuple(map(int, input().split())) for _ in range(n)]
  restore = [0] * (MAX + 10010)
  t0s = [0] * (MAX + 10010)
  t1s = [0] * (MAX + 10010)
  t2s = [0] * (MAX + 10010)
  t3s = [0] * (MAX + 10010)
  t1_cnt_save = defaultdict(int)
  t3_cnt_save = defaultdict(int)
  t1_cnt = 0
  t3_cnt = 0
  day = 0
  for i, line in enumerate(lst):
    w, t ,x = line
    while day < MAX and w > restore[day]:
      t0s[day + 1] += t0s[day]
      if day + 1 in t1_cnt_save: t1_cnt -= t1_cnt_save[day + 1]
      t1s[day + 1] += t1s[day] + t1_cnt
      if day + 1 in t3_cnt_save: t3_cnt -= t3_cnt_save[day + 1]
      t3s[day + 1] += t3s[day] + 2 * t3_cnt
      t2s[day + 1] += t2s[day] + t3s[day + 1]
      restore[day + 1] = restore[day] + 1 + t0s[day] + t1s[day] + t2s[day]
      day += 1
    
    if w <= restore[day]:
      print(day)
      if t == 0:
        t0s[day] += 1
        t0s[day + x] -= 1
      elif t == 1:
        t1_cnt += 1
        t1_cnt_save[day + x] += 1
        t1s[day] += 1
        t1s[day + x] -= x
      elif t == 2:
        t3_cnt += 1
        t3_cnt_save[day + x] += 1
        t3s[day] += 1
        t3s[day + x] -= x * 2 - 1
        t2s[day] += 1
        t2s[day + x] -= x ** 2
    else:print("Many years later")
  
  for _ in range(q):
    y = int(input())
    while day < y:
      t0s[day + 1] += t0s[day]
      t1_cnt -= t1_cnt_save[day + 1]
      t1s[day + 1] += t1s[day] + t1_cnt
      t3_cnt -= t3_cnt_save[day + 1]
      t3s[day + 1] += t3s[day] + 2 * t3_cnt
      t2s[day + 1] += t2s[day] + t3s[day + 1]
      restore[day + 1] = restore[day] + 1 + t0s[day] + t1s[day] + t2s[day]
      day += 1
    print(restore[y])

main() 


Measured memory_bytes: 868660
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      long sum = 0;
      int num = 0;
      Map<Integer,Integer> map = new HashMap<Integer,Integer>();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int i = 0;i < n;i++){
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(map.containsKey(a)){
          map.put(a,map.get(a)+b);
        }else{map.put(a,b);
        list.add(a);
        }
      }
      Collections.sort(list);
      for(int i = 0;i < list.size();i++){
      	int p = list.get(i);
        num += map.get(p);
        if(num < m)sum += (long)p*map.get(p);
        else {
          sum += (long)p*(map.get(p)-num+m);
          break;
        }
      }
      System.out.println(sum);
    }
}


Measured memory_bytes: 99472
import sys
import math
H,W=map(int, input().split())
Ch, Cw=map(int, input().split())
Dh, Dw=map(int, input().split())
maze=[]
for _ in range(H):
    RRR=(input().replace(".","0")).replace("#","1")
    maze.append(list(map(int, RRR)))
#print(maze)
dis=[[H**2*W**2 for _ in range(W+1)]for _ in range(H+1)]
Es=[[H**2*W**2 for _ in range(W+1)]for _ in range(H+1)]
start=(Ch,Cw,0)
goal=(Dh,Dw)
walk=[(1,0),(-1,0),(0,1),(0,-1)]
wap=[]
for i in range(-2,3):
    for j in range(-2,3):
        wap.append((i,j))
wap.remove((0,0))
for each in walk:
    wap.remove(each)
cand=[start]
dis[start[0]][start[1]]=0
flag=False
edge=[]
while len(cand)>0:
    #print(dis)
    place=cand.pop()
    hh,ww,cost=place
    if hh==Dh and ww==Dw:
        flag=True
    for each in walk:
        h1,w1=hh+each[0],ww+each[1]
        if h1>=1 and w1>=1 and h1<=H and w1<=W and maze[h1-1][w1-1]==0 and dis[h1][w1]>cost:
            dis[h1][w1]=cost
            cand.append((h1,w1,cost))
        elif h1>=1 and w1>=1 and h1<=H and w1<=W and maze[h1-1][w1-1]==1 and Es[hh][ww]>cost:
            Es[hh][ww]=cost
            edge.append((hh,ww,cost))
            #print(edge)
    if len(cand)==0:
        for place in edge:
            hh,ww,cost=place
            for each in wap:
                h1,w1=hh+each[0],ww+each[1]
                #print(h1,w1)
                if h1>=1 and w1>=1 and h1<=H and w1<=W and maze[h1-1][w1-1]==0 and dis[h1][w1]>cost+1:
                    dis[h1][w1]=cost+1
                    cand.append((h1,w1,cost+1))
        edge=[]
        #print(cand)
if flag:
    print(dis[Dh][Dw])
else:
    print(-1)


Measured memory_bytes: 109936
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#include <queue>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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

typedef pair<int, ll> P;

class D {
	int n, m, r;
	vector<vector<P>> g;
	vvll d;
	vi vis;
public:
	D()
	{
		cin >> n >> m >> r;

		g.resize(n + 1);
		d.resize(n + 1, vll(n + 1, LLMAX));
		vis.resize(r);

		REP(i, r)
		{
			cin >> vis[i];
		}
		sort(ALL(vis));

		REP(i, m)
		{
			int a, b, c;
			cin >> a >> b >> c;
			g[a].PB(MP(b,c));
			g[b].PB(MP(a,c));
		}

		REP(i, n + 1)
			sort(ALL(g[i]), [](const pii& left, const pii& right) { return left.second < right.second; });

	}

	void init()
	{
		REP(i, r)
		{
			int org = vis[i];
			vector<bool> done(n + 1, 0);
			priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;

			que.emplace(MP(0LL, org));

			while (!que.empty())
			{
				ll curd = que.top().first;
				int cur = que.top().second;
				que.pop();
				done[cur] = true;

				REP(j, SZ(g[cur]))
				{
					int nxt = g[cur][j].first;

					if (!done[nxt])
					{
						ll cst = g[cur][j].second;
						if (chmin(d[org][nxt], curd + cst))
							que.emplace(MP(d[org][nxt], nxt));
					}
				}
			}
		}

		//REP(i, n + 1)
		//{
		//	REP(j, n + 1)
		//		cout << d[i][j] << " ";

		//	cout << endl;
		//}

	}

	void solve()
	{
		init();

		ll ans = LLMAX;

		do
		{
			ll tmp = 0;

			REP(i, r - 1)
			{
				tmp += (ll)d[vis[i]][vis[i + 1]];
			}
			
			chmin(ans, tmp);

		} while (next_permutation(ALL(vis)));

		cout << ans << endl;

	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))
using namespace std;

typedef pair<int, int> pii;
typedef long long li;
typedef unsigned long long lu;
const int inf = ~0U >> 2;
const li infl = ~0LLU >> 2;

template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }

// ----------------------------------------

const int maxn = 185;

int n, m;
char arr[maxn][maxn + 1];

int f[maxn + 1][maxn + 1][maxn + 1];
int g[maxn + 1][maxn + 1][maxn + 1];
int f0[maxn + 1][maxn + 1][maxn + 1];

void Init(void) {
  for (int i = 0; i < n; ++i) {
    f[i][i + 1][m] = m;
    f[i][i + 1][m - 1] = m;
    for (int j = m - 2; j >= 0; --j) {
      f[i][i + 1][j] =
        (arr[i][j] == arr[i][j + 1]) ? f[i][i + 1][j + 1] : j + 1;
    }
  }
  for (int d = 2; d <= n; ++d) {
    for (int l = 0, r = d; r <= n; ++l, ++r) {
      f[l][r][m] = m;
      for (int j = m - 1; j >= 0; --j) {
        f[l][r][j] = (arr[l][j] == arr[l + 1][j]) ?
          min(f[l + 1][r][j], f[l][l + 1][j]) : j;
      }
    }
  }
}

void Advance(void) {
  COPYA(f, f0);
  for (int l = 0; l < n; ++l) {
    for (int r = l + 1; r <= n; ++r) {
      for (int j = 0; j <= m; ++j) {
        f[l][r][j] = f0[l][r][f0[l][r][j]];
      }
    }
  }

  // d = 2
  for (int l = 0; l + 2 <= n; ++l) {
    for (int j = 0; j <= m; ++j) {
      Max(f[l][l + 2][j], min(f0[l][l + 1][j], f0[l + 1][l + 2][j]));
      g[l][l + 2][j] = l + 1;
    }
  }

  for (int d = 3; d <= n; ++d) {
    for (int l = 0; l + d <= n; ++l) {
      int r = l + d;
      for (int j = 0; j <= m; ++j) {
        int L = max(g[l][r - 1][j], l + 1), R = min(g[l + 1][r][j], r - 1);
        assert(L <= R);
        int best = j, pos = L;
        for (int mid = L; mid <= R; ++mid) {
          int val = min(f0[l][mid][j], f0[mid][r][j]);
          if (val > best) {
            best = val;
            pos = mid;
          }
        }
        Max(f[l][r][j], best);
        g[l][r][j] = pos;
      }
    }
  }
}

int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", arr[i]);
  }
  Init();
  for (int ans = 0; ; ++ans) {
    if (f[0][n][0] == m) {
      printf("%d\n", ans);
      return 0;
    }
    Advance();
  }
}


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

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

f = factorize(n)
ans = 0
for i,j in f:
    ans += int((-1+pow(1+8*j,0.5))/2)
print(ans)

Measured memory_bytes: 9396
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()

def main():
    A, B, C, K = MI()
    l = [A, B, C]; s = 0; i = 0; j = [1, 0, -1]
    while K>0:
        if K>l[i]:
            s += l[i]*j[i]
            K -= l[i]
        else:
            s += K*j[i]
            break
        i += 1
    print(s)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9492
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int n;
int a[105];
bool flag = true;

int main() {

	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}

	rep(i, n) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				flag = false;
			}
		}
	}

	if (flag)cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;

	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#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>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	LL res = 0;
	int right = 0;
	int sum = 0;
	for (int left = 0; left < n; left++) {
		while (right < n && (sum ^ a[right]) == (sum + a[right])) {
			sum += a[right];
			++right;
		}
		res += right - left;
		if (left == right) {
			++right;
		}
		else {
			sum -= a[left];
		}
	}
	cout << res << endl;

	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  string s;
  cin>>s;
  vecll dp(n+1, 0);
  dp[0] = 1;
  REP(i,n) {
    vecll tmp(n+1, 0);
    REP(j,n+1) {
      if (j > 0) {
        tmp[j-1] += 2 * dp[j];
        tmp[j-1] %= MOD;
      } else {
        tmp[0] += dp[0];
        tmp[0] %= MOD;
      }
      if (j < n) {
        tmp[j+1] += dp[j];
        tmp[j+1] %= MOD;
      }
    }
    swap(dp, tmp);
  }
  cout<<dp[s.size()]<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

bool cmp(pair<long long int, long long int> a, pair<long long int, long long int> b) {
    if(a.second!=b.second) {
        return a.second > b.second;
    } else {
        return a.first < b.first;
    }
}

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

    vector<pair<long long int, long long int> > ev;
    vector<pair<long long int, long long int> > od;
    
    for(int i=0; i<n; i++) {
        long long int v;
        cin >> v;
        if(i%2) {
            if(od.size()==0) {
                od.push_back(make_pair(v, 1));
            } else {
                bool flod=true;
                for(int j=0; j<od.size(); j++) {
                    if(od[j].first==v) {
                        od[j].second++;
                        flod=false;
                    }
                }
                if(flod) {
                    od.push_back(make_pair(v, 1));
                }
            }
        } else {
            if(ev.size()==0) {
                ev.push_back(make_pair(v, 1));
            } else {
                bool flev=true;
                for(int j=0; j<ev.size(); j++) {
                    if(ev[j].first==v) {
                        ev[j].second++;
                        flev=false;
                    }
                }
                if(flev) {
                    ev.push_back(make_pair(v, 1));
                }
            }
        }
    }
    od.push_back(make_pair(0, 0));
    ev.push_back(make_pair(0, 0));

    sort(od.begin(), od.end(), cmp);
    sort(ev.begin(), ev.end(), cmp);

    if(od[0].first!=ev[0].first) {
        cout << n - od[0].second - ev[0].second << endl;
    } else {
        if(od[0].second+ev[1].second>ev[0].second+od[1].second) {
            cout << n - od[0].second - ev[1].second << endl;
        } else {
            cout << n - od[1].second - ev[0].second << endl;
        }
    }

    return 0;
    
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1000000007
using namespace std;

typedef long long ll;

ll dp[MAX][4];

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	#ifdef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	string str;

	cin>>str;

	dp[0][0] = 1;
	for(int i = 0; i < str.size(); i++){
		for(int j = 0; j < 4; j++){
			if(str[i] == '?')
				dp[i+1][j] = (dp[i+1][j] + (dp[i][j] * 3) % MOD) % MOD;
			else
				dp[i+1][j] = (dp[i+1][j] + dp[i][j]);
		}
		if(str[i] == 'A' || str[i] == '?')
			dp[i+1][1] = (dp[i+1][1] + dp[i][0]) % MOD;
		if(str[i] == 'B' || str[i] == '?')
			dp[i+1][2] = (dp[i+1][2] + dp[i][1]) % MOD;
		if(str[i] == 'C' || str[i] == '?')
			dp[i+1][3] = (dp[i+1][3] + dp[i][2]) % MOD;
	}

	cout<<dp[str.size()][3]<<endl;

	return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char c[101];
int main(){
	int r,l;
	cin>>r;
	cin>>c;
	if(r%2!=0){
		cout<<"No"<<endl;
		return 0;
	}
	else{
		l=strlen(c);
		for(int i=0;i<l/2;i++){
			if(c[i]!=c[i+l/2]){
				cout<<"No"<<endl;
				return 0;
			}
		}
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>

int n, x;

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

int main() {
	scanf("%d%d", &n, &x);
	int g = 0;
	for(int i=0;i<n;i++) {
		int v; scanf("%d", &v);
		g=gcd(g, labs(x-v));
	}
	printf("%d\n", g);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
#define REP(i,n) for (int i = 1; i<= (n); i++)
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
const long double PI = acos(-1);
using ll = long long;
using ld = long double;
using namespace std;

int main() {
    int a, p;
    cin >> a >> p;
    cout << floor((a*3 + p)/2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,ans=1;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		if(ans>k) ans+=k;
		else ans+=ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
countab,counta,countb,count=0,0,0,0
for i in range(N):
	s=input()
	if (s[0]=='B')&(s[-1]!='A'):
		countb+=1
	if (s[-1]=='A')&(s[0]!='B'):
		counta+=1
	if (s[0]=='B')&(s[-1]=='A'):
		count+=1
	countab+=s.count('AB')
if count==0: print(min(counta,countb)+countab)
elif counta+countb==0: print(count-1+countab)
else: print(min(counta,countb)+countab+count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;
typedef int64_t LL;

LL calc(int n, LL x) {
	vector<LL> level, pati;
	LL lastv = 1, lastp = 1;
	level.push_back(1);
	pati.push_back(1);
	for (int i = 1; i <= n; ++i) {
		level.push_back(3 + lastv * 2);
		pati.push_back(1 + lastp * 2);
		lastv = 3 + lastv * 2;
		lastp = 1 + lastp * 2;
	}
	LL sum = 0;
	for (int i = n; i >= 0; i--) {
		if (x == 0) {
			break;
		}
		else if (x == 1) {
			if (i == 0)
				sum++;
			break;
		}
		else if (x <= level[i] / 2) {
			x--;
		}
		else if (x <= (level[i] + 1) / 2) {
			sum++;
			if (i > 0)
				sum += pati[i - 1];
			break;
		}
		else if (x <= level[i] - 2) {
			sum += pati[i - 1] + 1;
			x -= level[i - 1] + 2;
		}
		else {
			sum += pati[i];
			break;
		}
	}
	return sum;
}

int main() {
	int n;
	LL x;
	cin >> n >> x;
	cout << calc(n, x) << endl;
	/*
	for (int x = 0; x <= 13; ++x) {
		LL sum = calc(n, x);
		cout << x << " " << sum << endl;
	}*/
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b;
  scanf("%d %d",&a,&b);

  if (a < b)
    printf("a < b\n");
  else if (b < a)
    printf("a > b\n");
  else if (a == b)
    printf("a == b\n");

  return 0;

}


Measured memory_bytes: 2140
N = gets.to_i
X = gets.split.map(&:to_i)

sorted = X.sort.reverse
m_index = (N-1)/2
m1 = sorted[m_index]
m2 = sorted[m_index+1]

X.each do |x|
  if x < m1
    puts m1
  else
    puts m2
  end
end


Measured memory_bytes: 24932
import bisect

n=int(input())
p=[int(x)-1 for x in input().split()]

p2=sorted(enumerate(p), key=lambda x:x[1], reverse=True)  

ans=0
s=[-1,-1,n,n]
for i,(idx,p) in enumerate(p2):
  t=bisect.bisect_left(s,idx)
  s.insert(t,idx)
  l1=s[t-1]
  l2=s[t-2]
  r1=s[t+1]
  r2=s[t+2]
  ans+=(p+1)*((idx-l1)*(r2-r1)+(r1-idx)*(l1-l2))
              
print(ans)


Measured memory_bytes: 24720
#include <cstring>
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
const int MAX_N = 16;
int n;
int t[MAX_N][MAX_N + 1];
int dp[1 << MAX_N];

int solve() {
	memset(dp, 0x7f, sizeof(dp));
	dp[0] = 0;
	for (int i = 0; i < (1 << n); i++) {
		if (dp[i] == 0x7f7f7f7f) continue;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) continue;
			int mincost = t[j][0];
			for (int k = 0; k < n; k++) {
				if (!(i & (1 << k))) continue;
				mincost = min(mincost, t[j][k + 1]);
			}
			int cleared = i | (1 << j);
			dp[cleared] = min(dp[cleared], dp[i] + mincost);
		}
	}
	return dp[(1 << n) - 1];
}

int main () {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= n; j++) {
				cin >> t[i][j];
			}
		}
		cout << solve() << endl;
	}
	return 0;
}

Measured memory_bytes: 1424
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N,M;
  cin>>N>>M;
  vector<int>s(M),c(M);
  for(int i=0;i<M;i++){
    cin>>s[i]>>c[i];
    s[i]--;
  }
  vector<int>t(N);
  if(N>1){t[0]=1;}
  vector<bool>use(N,false);
  for(int i=0;i<M;i++){
    if(N>1&&s[i]==0&&c[i]==0){cout<<-1<<endl;return 0;}
    if(use[s[i]]&&t[s[i]]!=c[i]){cout<<-1<<endl;return 0;}
    t[s[i]]=c[i];
    use[s[i]]=true;
  }
  for(int i=0;i<N;i++){
    cout<<t[i];
  }cout<<endl;

  return 0;
}

Measured memory_bytes: 3616
// B - Bounding
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 0, p = 0;
	for (int i = 0; i < n; i++) {
		if (p + a[i] > x) break;
		p += a[i];
		ans = i + 2;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    W, H, x, y = map(int, input().split())
    if 2*x == W:
        Fx = True
    else:
        Fx = False
    if 2*y == H:
        Fy = True
    else:
        Fy = False
    if Fx and Fy:
        way = 1
    else:
        way = 0
    area = H*W/2
    # print(area," ", way)
    print(area, way)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  3005
string s1,s2;
ll dp[N][N];
pair<ll,ll> par[N][N];
ll f(ll i,ll j)
{
	if(i<0||j<0)return 0;
	if(dp[i][j]!=-1)return dp[i][j];
	else
	{
		ll ans;
		if(s1[i]==s2[j])
		{
			ans=1+f(i-1,j-1);
			par[i][j]=mp(i-1,j-1);
		}
		else
		{
			ll ans1=f(i-1,j),ans2=f(i,j-1);
			if(ans1>ans2)
			{
				ans=ans1;
				par[i][j]=mp(i-1,j);
			}
			else
			{
				ans=ans2;
				par[i][j]=mp(i,j-1);
			}
		}

		return dp[i][j]=ans;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		memset(dp,-1,sizeof dp);
		cin>>s1>>s2;
		ll num=f(sz(s1)-1,sz(s2)-1);

		ll i=sz(s1)-1,j=sz(s2)-1;
		string ans;
		

		//cout<<"num="<<num<<" "; cout<<par[0][0].F<<" "<<par[0][0].S<<"\n"; return 0;
		while(i>=0&&j>=0)
		{
			ll pari=par[i][j].F,parj=par[i][j].S;
			if(s1[i]==s2[j])ans+=s1[i];
			//cout<<"i="<<i<<"j="<<j<<"\n"
			i=pari,j=parj;
		}

		reverse(all(ans));
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 212224
#include <stdio.h>

int main(void) {
    int n, p, i, ban;
    int plr[50], wan;
    scanf("%d%d",&n, &p);
    while(n || p) {
        wan = p;
        for(i = 0; i < n; i++) {
            plr[i] = 0;
        }
        ban = 0;
        while(1) {
            if(wan) {
                plr[ban]++;
                wan--;
            } else if(plr[ban] == p) {
                break;
            } else {
                wan = plr[ban];
                plr[ban] = 0;
            }
            ban = (ban + 1) % n;
        }
        printf("%d\n",ban);
        scanf("%d%d",&n, &p);
    }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(void){
    ll a,b,c,d,e,f;
    scanf("%lld%lld%lld",&a,&b,&c);

    ll count = 0;

    while(count < 300000000){
        if(a % 2 || b % 2 || c % 2){
            printf("%lld\n",count);
            return 0;
        }
        count++;

        d = a / 2;e = b / 2;f = c / 2;
        a = e + f;b = f + d;c = d + e;
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n;
  cin>>n;
  int x[n];
  for(int i=0;i<n;i++) cin>>x[i];
  int l;
  cin>>l;
  vector<int> db[31];
  for(int i=0;i<31;i++) db[i].resize(n);
  for(int i=0,j=0;i<n;i++){
    while(j+1<n&&x[j+1]<=x[i]+l) j++;
    db[0][i]=j;
  }
  for(int j=0;j<31-1;j++)
    for(int i=0;i<n;i++)
      db[j+1][i]=db[j][db[j][i]];
  function<int(int,int)> calc=[&](int a,int b){
    if(b<=a) return 0;
    for(int j=0;j<40;j++){
      if(b<=db[j+1][a])
	return calc(db[j][a],b)+(1<<j);
    }
  };
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b) swap(a,b);
    cout<<calc(a,b)<<endl;
  }
  return 0;
}


Measured memory_bytes: 13312
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b;
    cin >> a >> b;
    int n = stoi(a + b);
    bool check = false;
    REP(i, 320){
        int tmp = i*i;
        if(n == tmp) check = true;
    }
    check ? cout << "Yes" << endl: cout << "No" << endl;

}



Measured memory_bytes: 256
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let s : String = get_one();
    let n = s.len();
    let s_ind = s.chars().collect::<Vec<char>>();
    println!("{}{}{}", s_ind[0], n-2, s_ind[n-1]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ll N; cin >> N;
  std::deque<ui> res{};

  while(N)
  {
    if(N % 2)
    {
      res.push_front(1);
      N -= 1;
    }
    else
    {
      res.push_front(0);
    }
    if(N > 0)
    {
      N = -(N / 2);
    }
    else
    {
      N = (-N / 2);
    }
  }

  if(res.empty())
  {
    cout << '0' << CRLF;
  }
  else
  {
    for(auto it = res.begin(); it != res.end(); ++it)
    {
      cout << *it;
    }
    cout << CRLF;
  }
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();
		int[] ary = getAryMl(breader);
		int maxdf = ary[1] - ary[0] ;
		for( int i = 0 ; i < ary.length ; i++ ) {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		}
		System.out.println(maxdf);
		
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

}

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

int main(){
    int N;
    cin>>N;
    vector<pair<int,int>> dic(N);

    for(int i=0; i<N; i++){
        int a,b;
        cin>>a>>b;
        dic[i].first = b;
        dic[i].second = a;
    }

    sort(dic.begin(),dic.end());

    int sum = 0;
    bool flag = true;

    for(int i=0; i<N; i++){
        sum += dic[i].second;
        if(sum > dic[i].first) {
            flag = false;
            break;
        }
    }

    cout<<(flag ? "Yes" : "No")<<endl;


    return 0;
}

Measured memory_bytes: 1792
a = list(input())
b = list(input())

a.sort()
b.sort(reverse=True)
f = [int(len(b)), int(len(a))]
e = min(f)
for i in range(int(e)):
    c =[a[i],b[i]]
    d = sorted(c)
    if i != int(e)-1:
        if a[i] == b[i]:
            continue
        elif c != d:
            print("No")
            break
        else:
            print("Yes")
            break
    if i == int(e)-1:
        if a[i] == b[i]:
            if int(len(a)) >= int(len(b)):
                print("No")
            else:
                print("Yes")
        elif c != d:
            print("No")
            break
        else:
            print("Yes")
            break


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 1000100
//#define NIL -1

int main() {
    string s;
    string t;
    vector<vector<LL>> idx_list(26);
    int tmp_num;
    LL idx=0;
    LL ans=0;

    cin >> s;
    cin >> t;

    for(int i=0; i<s.size(); i++){
        tmp_num = s[i] - 'a';
        idx_list[tmp_num].push_back(i);
    }

    for(int i=0; i<t.size(); i++){
        tmp_num = t[i] - 'a';
        int cand_idx=-1;
        if(idx_list[tmp_num].size()==0){
            ans=-2;
            break;
        }
        auto itr = lower_bound(idx_list[tmp_num].begin(), idx_list[tmp_num].end(), idx+1);
        if(i==0){
            itr = lower_bound(idx_list[tmp_num].begin(), idx_list[tmp_num].end(), idx);                
        }
        if(itr!=idx_list[tmp_num].end()){
            int dist = distance(idx_list[tmp_num].begin(), itr);
            //cout << "dist " << idx_list[tmp_num][dist] << endl; 
            ans=ans+idx_list[tmp_num][dist]-idx;
            idx=idx_list[tmp_num][dist];
        }else{
            ans=ans+idx_list[tmp_num][0]+s.size()-idx;
            idx=idx_list[tmp_num][0];
        }
        //cout << ans << " " << idx << endl;
    }
    ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1724
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
        a=0
        for i in range(1,n-1):
             for j in range(i+1,n):
                 for k in range(j+1,n+1):
                    if i+j+k==x:
                         a+=1
        print(a)


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

int main() {
  int n;
  cin >> n;
  int m = 2 * n;
  string s;
  string t;
  cin >> s >> t;
  for(int i=0;i<m;i++) {
    if(i%2==0) cout << s[i/2];
    else cout << t[i/2];
  }
  cout << endl;
}

Measured memory_bytes: 256
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define sz(x) (int) x.size()
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<str> vstr;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 7;

int sub[N];

int32_t main() {
  FAST_IO;
  int n;
  cin >> n;
  rep(i, n - 1) {
    int x;
    cin >> x;
    sub[x]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << sub[i] << '\n';
  }
  rtn 0;
}


Measured memory_bytes: 5168
SA=input()
SB=input()
SC=input()

A=[a for a in SA]
B=[b for b in SB]
C=[c for c in SC]
count=0
whole=A+B+C
na=len(A)
nb=len(B)+1
nc=len(C)+1

if A[0]=='a':
    del whole[0]
    number=0
    na-=1
elif A[0]=='b':
    del whole[0]
    number=na-1
    nb-=1
else:
    del whole[0]
    number=na+nb-2
    nc-=1

while na>0 and nb>0 and nc>0:
    if whole[number]=='a':
        del whole[number]
        number=0
        na-=1
    elif whole[number]=='b':
        del whole[number]
        number=na-1
        nb-=1
    else:
        del whole[number]
        number=na+nb-2
        nc-=1

if na==0:
    print('A')
elif nb==0:
    print('B')
else:
    print('C')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

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

  if (n >= 2 && m >= 2) {
    cout << (n-2) * (m-2) << endl;
  } else if (n == 1 && m == 1) {
    cout << 1 << endl;
  } else if (n == 1 && m > 1) {
    cout << m - 2 << endl;
  } else if (m == 1 && n > 1) {
    cout << n - 2 << endl;
  }
  return 0;
}

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

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

    sort(s.begin(), s.end());    
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    loop {
        let v = read_vec::<u32>();
        let n = v[0];
        let x = v[1];
        if n == 0 && x == 0 { break; }

        if x < 6 {
            println!("0");
            continue;
        }

        let mut count = 0;
        for i in 1..n - 1 {
            for j in i + 1..n {
                for k in j + 1..n + 1 {
                    if i + j + k == x {
                        count += 1;
                    }
                }
            }
        }
        println!("{}", count);
    }
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

vector<char> g[2];
void solve(){
    string s;cin>>s;
    bool flip=0;
    ll q;cin>>q;
    rep(i,q){
        ll qq;cin>>qq;
        if(qq==1){
            flip=1-flip;
        }else{
            ll f;cin>>f;
            f--;
            char c;cin>>c;
            g[(f+flip)%2].push_back(c);
        }
    }
    string s1;
    for(char c:g[0])s1+=c;
    reverse(all(s1));

    string s2;
    for(char c:g[1])s2+=c;

    s=s1+s+s2;
    if(flip){
        reverse(all(s));
    }
    cout<<s<<endl;
}

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


Measured memory_bytes: 1476
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int main()
{
	int n, s;

	while(cin >> n >> s && (n || s))
	{
		vint num(10);
		rep(i, 10)
			num[i] = i;

		vector<bool> par(10, 0);

		REP(i, 10-n, 10)
			par[i] = 1;

		int res = 0;
		do
		{
			int buf = 0;
			rep(i, 10)
				buf += i * par[i];
			
			res += buf == s;


		}while(next_permutation(ALL(par)));

		cout << res << endl;
	}
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    int cnt = 0, key = 0;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }

    while(true){
        if(key == 1){
            cout  << cnt;
            break;
        }
        if(cnt >= n){
            cout << -1;
            break;
        }
        cnt++;
        key = a[key];
    }
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n,k;
  cin >> n>>k;
  
  if(n<=k) {
  cout << 0 << endl;
  return 0;
  }
  
  vector<ll> p(n);
  rep(i,n){
  cin>>p[i];
  }
  
  sort(all(p));
  
  ll ans = 0;
  rep(i,n-k) {
  ans+=p[i];
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define PI 3.14159265;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ld a,b,x;
    cin>>a>>b>>x;
    ld g;
    if(2*x >= a*a*b)
    g=(a*a*a)/((a*a*b-x)*(ld)2);
    else g=(2*x)/(a*b*b);
        
   // cout<<g<<endl;
    ld p=atan(g);
  //  cout<<p<<endl;
    p=(p*(ld)180)/PI;
   // cout<<p<<endl;
    cout<<fixed<<setprecision(10);
    cout<<((ld)90-p);
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

char S[SIZE];

int main(){

	scanf("%s",S);

	int ans = 0;
	for(int i = 1; S[i] != '\0'; i++){
		if(S[i] != S[i-1]){

			ans++;
		}
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 384