akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+eps)

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

  string s;
  cin >> s;

  int n = s.size();

  int dp[19][n];
  REP(i, n){
    dp[0][i] = i;
  }
  REP(i, n){
    if( s[i]=='R' ) dp[1][i] = i+1;
    else            dp[1][i] = i-1;
  }

  REP1(j, 17){
    REP(i, n){
      dp[ j+1 ][i] = dp[ j ][ dp[j][i] ];
    }
  }

  vint ans(n);
  REP(i, n){
    ans[ dp[ 18 ][i] ]++;
  }

  REP(i ,n){
    cout << ans[i] << " ";
  }

  return 0;
}


Measured memory_bytes: 8528
import scala.io.Source.stdin

object Main extends App {
  def gcd(m:Long,n:Long):Long = if(n==0) m else gcd(n, m % n)

  for(s <- stdin.getLines.map(_.split(" ").map(_.toLong))) {
        val g = gcd(s(0),s(1))
        println(g + " " + (s(0)/g)*s(1))
  }
}

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

int main()
{
  int K;
  cin >> K;
  string str;
  cin >> str;

  int num = str.length();

  if (num <= K)
  {
    cout << str << endl;
  }
  else
  {
    char str2[K + 3];

    for (int i = 0; i < K; i++)
    {
      str2[i] = str[i];
    }

    for (int i = K; i < (K + 3); i++)
    {
      str2[i] = '.';
    }

    for (int i = 0; i < (K + 3); i++)
    {
      cout << str2[i];
    }

    cout << ' ' << endl;
  }
}

Measured memory_bytes: 3628
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int a, b;
const int maxN = 105;
int d[maxN][maxN];
bool ok[maxN][maxN];
int val[maxN][maxN];
int vert[maxN][maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> a >> b;
    for (int i = 1; i <= a; i++) {
        for (int j = 1; j <= b; j++) {
            cin >> d[i][j];
        }
    }
    int sz = 1;
    for (int cnt1 = 0; cnt1 < 100; cnt1++) {
        for (int cnt2 = 0; cnt2 < 100; cnt2++) {
            vert[cnt1][cnt2] = sz++;
            int at_least_t = 0;
            for (int j = 1; j <= a; j++) {
                for (int k = 1; k <= b; k++) {
                    at_least_t = max(at_least_t, d[j][k] - j * cnt1 - k * cnt2);
                }
            }
            val[cnt1][cnt2] = at_least_t;
            for (int j = 1; j <= a; j++) {
                for (int k = 1; k <= b; k++) {
                    int p = at_least_t + j * cnt1 + k * cnt2;
                    assert(p >= d[j][k]);
                    if (p == d[j][k]) ok[j][k] = true;
                }
            }
        }
    }
    for (int j = 1; j <= a; j++) {
        for (int k = 1; k <= b; k++) {
            if (!ok[j][k]) {
                cout << "Impossible";
                return 0;
            }
        }
    }
    cout << "Possible" << '\n';
    vector < pair < pair < int, int >, int > > edges;
    int T = sz;
    for (int i = 0; i < maxN; i++) {
        if (i + 1 < maxN) edges.emplace_back(make_pair(i + 1, i + 2), -1);
        if (i + 1 < maxN) edges.emplace_back(make_pair(maxN + i + 1, maxN + i + 2), -2);
        for (int j = 0; j < maxN; j++) {
            edges.emplace_back(make_pair(i + 1, maxN + (maxN - j - 1) + 1), val[i][j]);
        }
    }
    cout << 2 * maxN << " " << edges.size() << '\n';
    for (auto it : edges) {
        cout << it.first.first << " " << it.first.second << " ";
        if (it.second == -1) cout << 'X' << '\n';
        else if (it.second == -2) cout << 'Y' << '\n';
        else cout << it.second << '\n';
    }
    cout << 1 << " " << maxN + maxN  << '\n';
    return 0;
}

Measured memory_bytes: 704
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll ai, ao, at, aj, al, as, az;
    cin >> ai >> ao >> at >> aj >> al >> as >> az;

    ll r = ai % 2 + aj % 2 + al % 2;
    ll ans = ao + ai + aj + al;
    if (r == 3 || (ai > 1 && aj > 1 && al > 1)) {
        ans -= min(r, 3-r);
    } else {
        ans -= r;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main(void){
    string s, t;
    cin >> s;
    t = "s";
    std::string str1 = s;
    std::string str2 = "s";
 
    int result = str1.compare(s.length()-1, 1, str2);
    if(result == 0) {
        cout << str1 + "es";
    } else {
        cout << str1 + "s";
    }
}


Measured memory_bytes: 3636
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 10;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	if (*ci == '-') ci++;
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (72 - dig >> 3);
	return tmp;
}


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


	ll N = getint(), D = getint();
	D = D * D;

	int kotae = 0;
	rep(i, N) {
		ll X = getint(), Y = getint();
		kotae += (D >= X * X + Y * Y);
	}
	printf("%lld\n", kotae);


	Would you please return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    int a, b;
    cin >> a >> b;

    // 処理
    // 出力
    cout << (a + b) % 24 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}

int main(void) {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector <int> x(N + 1), y(M + 1);
    x[0] = X;
    y[0] = Y;
    for (int i = 1; i <= N; i++) cin >> x[i];
    for (int i = 1; i <= M; i++) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    if (x[N] < y[0]) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 3600
s = input()
t = set(map(chr, range(ord('a'), ord('z')+1))) - set(s)
if t:
    print(s + min(t))
else:
    u = {s[-1]}
    for i in range(len(s)-1)[::-1]:
        x = [c for c in u if s[i]<c]
        if x:
            print(s[:i] + min(x))
            break
        u.add(s[i])
    else:
        print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
class binary_indexed_tree {
  public:
    int n;
    vector<int> tree;
    binary_indexed_tree (int size) {
      n = size;
      tree.resize(n, 0);
    }
    int get (int x) {
      int ret = 0;
      for (; x >= 0; x &= x + 1, x--){
        ret += tree[x];
      }
      return ret;
    }
    void add (int x) {
      for (; x < n; x |= x + 1) {
        tree[x]++;
      }
    }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int lb = 0;
  int ub = 1e9 + 1;
  while (ub - lb > 1) {
    int md = (lb + ub) >> 1;
    long long inv = 0;
    binary_indexed_tree bit(2 * n + 1);
    int crr = n;
    bit.add(crr);
    for (int i = 0; i < n; i++) {
      if (a[i] >= md) {
        crr++;
      } else {
        crr--;
      }
      inv += bit.get(crr);
      bit.add(crr);
    }
    if (inv * 2 >= (long long) n * (n + 1) / 2) {
      lb = md;
    } else {
      ub = md;
    }
  }
  cout << lb << '\n';
  return 0;
}

Measured memory_bytes: 1420
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
struct edge{
    int to,cap,cost,rev;
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};
 
const int INF=1001001001;
const int MAX_V=500;
int S=MAX_V-2,T=MAX_V-1;
vector<edge>G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];
 
void init(){
    rep(i,MAX_V)G[i].clear();
}
void add_edge(int from,int to,int cap,int cost){
    G[from].pb(edge(to,cap,cost,G[to].size()));
    G[to].pb(edge(from,0,-cost,G[from].size()-1));
}
 
int min_cost_flow(int s,int t,int f){
    int res=0;
    while(f>0){
        fill_n(dist,MAX_V,INF);
        dist[s]=0;
        bool update=true;
        while(update){
            update=false;
            rep(v,MAX_V){
                if(dist[v]==INF)continue;
                rep(i,G[v].size()){
                    edge &e=G[v][i];
                    if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
                        dist[e.to]=dist[v]+e.cost;
                        prevv[e.to]=v;
                        preve[e.to]=i;
                        update=true;
                    }
                }
            }
        }
 
        if(dist[t]==INF)return -1;
 
        int d=f;
        for(int v=t;v!=s;v=prevv[v]){
            chmin(d,G[prevv[v]][preve[v]].cap);
        }
 
        f-=d;
        res+=d*dist[t];
        for(int v=t;v!=s;v=prevv[v]){
            edge &e=G[prevv[v]][preve[v]];
            e.cap-=d;
            G[v][e.rev].cap+=d;
        }
    }
 
    return res;
}
 
int A,B,K;
string a[200],b[200];
signed main(){
    cin>>A>>B>>K;
    rep(i,A)cin>>a[i];
    rep(i,B)cin>>b[i];
 
    int lb=0,ub=300;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
 
        init();
        rep(i,A)add_edge(S,i,1,0);
        rep(i,B)add_edge(i+A,T,1,0);
        rep(i,A)rep(j,B){
            int cnt=0;
            if(a[i][j]=='1')cnt++;
            if(b[j][i]=='1')cnt++;
            add_edge(i,j+A,1,cnt);
        }
 
        int tmp=min_cost_flow(S,T,mid);
        if(tmp==-1||tmp>K)ub=mid;
        else lb=mid;
    }
    cout<<lb<<endl;
    return 0;
}

Measured memory_bytes: 6496
#include <stdio.h>
int size[3],a[12],s[3];
bool dfs(int now){
    if(now>=12)return true;
    else{
        for(int i=0;i<3;i++)if(s[i]==-1){
            size[i]=1;
            s[i]=a[now];
            if(dfs(now+1))return true;
            s[i]=-1;
            size[i]=0;
        }
        else if(s[i]==a[now]&&size[i]<5){
            size[i]++;
            if(dfs(now+1))return true;
            size[i]--;
        }
        return false;
    }
}
int main(){
    for(int i=0;i<3;i++)s[i]=-1;
    for(int i=0;i<12;i++)scanf("%d",&a[i]);
    if(dfs(0))printf("yes\n");
    else printf("no\n");
}


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

using namespace std;

//#define MD 100010

int main(){
    int n,m,x,l=0,r=0;
    cin>>n>>m>>x;
    vector<int> a(m);
    for(int i=0;i<m;i++){
        cin>>a[i];
        if(a[i]<x){
            l++;
        }else if(a[i]>x){
            r++;
        }
    }
    
    int ans=min(l,r);
    
    cout<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long int a,b,c,d,n,m;
    while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d))
    {
        n=a*b;
        m=c*d;
        if(n>m)
        {
            printf("%lld\n",n);
        }
        else
        {
            printf("%lld\n",m);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
#define int long long

void solve() {
	int n; cin >> n;
    for(int k = 1; k <= 50000; ++k) {
        double p = floor((double)k * 1.08);
        if(p == (double)n) {
            cout << k << endl;
            return;
        }
    }
    cout << ":(" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    s = input()
    ans = []
    for c in s:
        if c == '0':
            ans.append('0')
        elif c == '1':
            ans.append('1')
        elif c == 'B':
            del ans[-1:]
    ans = ''.join(ans)
    print(ans)

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

int main()
{
  string S;
  cin >> S;
  deque<char> dq;
  for (int i = 0; i < (int)(S.size()); i++)
  {
    dq.push_back(S.at(i));
  }
  int64_t Q, t, f;
  char c;
  cin >> Q;
  bool reversed = false;
  for (int i = 0; i < Q; i++)
  {
    cin >> t;
    if (t == 1)
    {
      reversed = !reversed;
    }
    else
    {
      cin >> f >> c;
      if (f == 1 && !reversed || f == 2 && reversed)
      {
        dq.push_front(c);
      }
      else
      {
        dq.push_back(c);
      }
    }
  }
  if (reversed)
  {
    reverse(dq.begin(), dq.end());
  }
  while (dq.size())
  {
    cout << dq.front();
    dq.pop_front();
  }
  cout << endl;
}


Measured memory_bytes: 4028
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
type Pi = (i32, i32);
fn pri<T: std::fmt::Display>(x: T) {
    println!("{}", x);
}

fn main() {
    input!{
        s: chars,
    }
    let mut s = s; let n = s.len();
    s.reverse();
    let mut ans = true;
    let mut i = 0;
    while i < n {
        if i+4 < n && s[i..i+5] == ['e','s','a','r','e'] {
            i += 5;
        } else if i+4 < n && s[i..i+5] == ['m','a','e','r','d'] {
            i += 5;
        } else if i+5 < n && s[i..i+6] == ['r','e','s','a','r','e'] {
            i += 6;
        } else if i+6 < n && s[i..i+7] == ['r','e','m','a','e','r','d'] {
            i += 7;
        } else {
            ans = false; break;
        }
    }
    pri(if ans {"YES"} else {"NO"});
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

  map<int, int> amap;

  for (int i = 0; i < n; i++)
  {
    long long a;
    cin >> a;
    amap[a]++;
    if (amap[a] > 1)
    {
      cout << "NO" << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 9600
# def dfs(y, x):
#     if gridgraph[y+1][x] == "#" and y+1 != H:
#         visited[y+1][x] = True
#         dfs(y+1, x)
#     elif gridgraph[y][x+1] == "#" and x+1 != W:
#         visited[y][x+1] = True
#         dfs(y, x+1)
#     elif y == H-1 and x == W-1:
#         return

from collections import deque

H, W = map(int, input().split())
gridgraph = [input() for _ in range(H)]
# 移動経路を右or下のみに限定して，目的地に着いたかどうか判定する, 幅優先探索で右と下が同時に#なら終わりという制約でもいいかも
q = deque()
q.append([0, 0])
visited = [[False]*W for _ in range(H)]
adjacents = [[1, 0], [0, 1]]
while len(q):
    ny, nx = q.popleft()
    # print(ny, nx)
    visited[ny][nx] = True
    if (ny+1 != H and gridgraph[ny+1][nx] == "#") and (nx+1 != W and gridgraph[ny][nx+1] == "#"):
        break
    if (ny+1 != H and gridgraph[ny+1][nx] != "#") and (nx+1 != W and gridgraph[ny][nx+1] != "#"):
        break
    for dy, dx in adjacents:
        if ny+dy == H or nx+dx == W:
            continue
        if gridgraph[ny+dy][nx+dx] == "#":
            q.append([ny+dy, nx+dx])
ans = True
for i in range(H):
    for j in range(W):
        if visited[i][j] == False and gridgraph[i][j] == "#":
            ans = False

if ny == H-1 and nx == W-1 and ans:
    print("Possible")
else:
    print("Impossible")


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

using namespace std;

int main() {
	string S;
	while( cin >> S ) {
		if( S == "0" ) {
			break;
		}
		long long int ans = 0;
		vector<vector<long long int>>dp( S.length(), vector < long long int >( 2 ) );
		for( size_t i = 0; i < S.length(); i++ ) {
			if( i ) {
				dp[i] = dp[i - 1];
			}
			if( i % 2 ) {
				dp[i][0] += S[i] - '0';
			} else {
				dp[i][1] -= S[i] - '0';
			}
		}
		for( size_t i = 0; i < S.length(); i++ ) {
			dp[i][0] += dp[i][1];
			dp[i][0] %= 11;
			dp[i][0] += 11;
			dp[i][0] %= 11;
		}
		vector<long long int>X( 11 );
		X[0]++;
		for( size_t i = 0; i < S.length(); i++ ) {
			ans += X[dp[i][0]];
			if( !( i < S.length() - 1 && S[i + 1] == '0' ) ) {
				X[dp[i][0]]++;
			}
		}

		cout << ans << endl;
	}
}

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

int main(){
    int a,b,c,d,e,f,g,h,i;
    cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
    
    bool ans = true;
    if(a+e!=b+d) ans = false;
    if(b+f!=c+e) ans = false;
    if(d+h!=e+g) ans = false;
    if(e+i!=f+h) ans = false;
    
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No" << endl;
    
    return 0;
}


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

using namespace std;

int main(void){
  	int N, K, Q;
	cin >> N >> K >> Q;

    vector<int> A(Q), B(N, K-Q);

    for(int i = 0; i < Q; i++){
        cin >> A[i];
        B[A[i]-1]++;
    }

    for(int i = 0; i < N; i++){
        if(B[i] > 0){
            cout << "Yes" << endl;
            continue;
        }

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


Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
int main()
{
    int n;
    std::cin>>n;
    double ans=0;
    for(int i=0;i<n;i++){
        double tmp;
        std::cin>>tmp;
        ans += 1.0/tmp; 
    }
    std::cout<<1.0/ans<<std::endl;
}

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

int main(){
	int n; char d[102];
	while(scanf("%d",&n),n){
		scanf("%s",d);
		int data[10],b=0; for(int i=0;i<10;i++) data[i]=0;
		for(int i=0;i<100;i++){
			int c=i%n;
			if(d[i]=='M'){ data[c]++;}
			if(d[i]=='S'){ b+=data[c]+1; data[c]=0;}
			if(d[i]=='L'){ data[c]+=b+1; b=0;}
		}
		sort(data,data+n);
		for(int i=0;i<n;i++) printf("%d ",data[i]);
		printf("%d\n",b);
	}
}

Measured memory_bytes: 1212
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=a%10;
		a/=10;
		int c=a%10;
		a/=10;
		int d=a%10;
		a/=10;
		int e=a%10;
		if(b==c&&c==d||c==d&&d==e) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
//#include <stiusd.h>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c,N;
    int x[101],y[101],h[101];
    //bool allZero = true;
    cin>> N ;
    for(int i=1;i<=N;i++){
        cin>>x[i]>>y[i]>>h[i];
        //if(allZero && h[i]!=0)allZero=false;
    }
    int Ax,Ay,Ah;
    
    for(int j=0;j<=100;j++){
        for(int i=0;i<=100;i++){
            bool ok=true;
            //int k=1;
            int temh = -1;
            for(int k=1; temh == -1 ;k++){
                if( h[k] != 0 ) temh=abs(x[k]-i)+abs(y[k]-j)+h[k];
            }
            //if(temh<1)continue;
            for(int k=1;k<=N;k++){
                int kh=abs(x[k]-i)+abs(y[k]-j)+h[k];
                if( h[k] != 0 ){
                    if(kh != temh){
                        ok=false;
                        break;
                    }
                } else {
                    if(kh < temh){
                        ok=false;
                        break;
                    }                    
                }
            }
            //cout<< i << "," << j << "," << temh <<endl;
            if(ok){
                Ax=i;Ay=j;Ah=temh;
                goto OUT;
            }
        }
    }
    //cout<<"err"<<endl;

    OUT:
    cout<< Ax << " " << Ay << " " << Ah <<endl;
    return 0;
}

Measured memory_bytes: 256
a, b, _, c, d, _, _ = map(int, input().split())

print(a//2*2 + (1 if a>0 and b>0 and c>0 and a%2 + c%2 + d%2 == 2 else 0) + (3 if a%2 + c%2 + d%2 == 3 else 0) +b+c//2*2+d//2*2)


Measured memory_bytes: 39760
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const LL maxn = 1e5+10;

int n, a[maxn];
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];

    bool flag = true;
    int tag = 1;
    a[0] = 1<<30;
    while(flag){
        tag = 0;
        for(int i = 1; i <= n; i++)
            if(a[i]<a[tag] && a[i]!=0)
                tag = i;

        for(int i = 1; i <= n; i++)
            if(i != tag && a[i]!=0)
                a[i] %= a[tag];
        flag = false;
        for(int i = 1; i <= n; i++)
            if(a[i]>0 && i!=tag)
                flag = true;
    }
    cout << a[tag] << endl;
	return 0;
}



Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
using System.Text;
class Simple {
    private string s;
    void Solve() {
        //input
        s = io.String;
        //cal
        var win = 0;
        var los = 0;
        var pNum = 0;
        var gNum = 0;        
        Func <bool> availableP = () => pNum + 1 <= gNum;
        Func <int,bool>  isG=(index)=> s[index] == 'g';
        Func <int, bool> drawableWithG = (index) => isG(index);
        Func <int, bool> drawableWithP = (index) => !isG(index) && availableP();
        Func <int, bool> winable = (index) => availableP() && isG(index);
        for(int i = 0; i < s.Length; ++i) {
            if(winable(i)) {
                win++;
                pNum++;
            } else if(drawableWithG(i)) {
                gNum++;
            } else if(drawableWithP(i)) {
                pNum++;
            } else {
                los++;
                gNum++;
            }
        }
        //ret
        Console.WriteLine(win - los);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] {' '};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if(BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13108
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[]$) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int[] x=new int[n];
        int[] y=new int[n];
        int[] h=new int[n];
        for (int i = 0; i < n; i++) {
            x[i]=sc.nextInt();
            y[i]=sc.nextInt();
            h[i]=sc.nextInt();
        }
        for(int i=0;i<n;i++) {
                for (int j = 0; j < 101; j++) {
                    for (int k = 0; k < 101; k++) {
                        int H = h[i] + abs(x[i] - j) + abs(y[i] - k);
                        int judge = 0;
                        for (int l = 0; l < n; l++) {
                            if ( h[l]==max(0, H - abs(x[l] - j) - abs(y[l] - k))) judge++;
                        }
                        if (judge == n) {
                            out.println(j + " " + k + " " + H);
                            exit(0);
                        }
                    }
            }
        }
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <vector>

#include <string>
#include <limits.h>
#include <set>
#define ll long
#define MAX 1e9
using namespace std;
typedef long long lli;
int main(){
    ios_base::sync_with_stdio(false);

    int K;
    int a, b;
    cin>>K;
    cin>>a>>b;
    int flag = 0;
    for(int i = a; i<=b; i++)
    {
    	if(i%K==0)
    	{
    		flag=1;
    		break;
    	}
    }
    if(flag==0)
    	cout<<"NG\n";
    else
    	cout<<"OK\n";
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include "stdio.h"
#include "stdlib.h"
#include "string.h"

using namespace std;

struct Node{
  int key;
  Node* prev;
  Node* next;
};

Node* nil;

void init(){
  nil = (Node*)malloc(sizeof(Node));
  nil->prev = nil;
  nil->next = nil;
}

void insert(int key){
  Node* x = (Node*)malloc(sizeof(Node));
  x->key = key; 

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil; 
}

Node* listSearch(int key){
  Node* cur = nil->next;
  while(cur != nil && cur->key !=key){
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node* t){
  if(t == nil){
  }else{
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
  }
}
void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void printList(){
  Node* cur = nil->next;

  int cnt = 0;
  while(1){
    if(cur == nil) break;

    if(cnt>0){
      printf(" ");
    }
    printf("%d", cur->key);
    cur = cur->next;
    cnt = cnt + 1;
  }
  printf("\n");
}


int main(void){
  
  int N;
  scanf("%d", &N);

  char s[20];
  int key;

  init();
  
  for(int i=0;i<N;i++){
    scanf("%s%d", s, &key);

    if(s[0] == 'i'){
      insert(key);
    }else if(s[0] == 'd'){
    
      if(strlen(s) > 6){
        if(s[6] == 'F'){
          deleteFirst();
        }else if(s[6] == 'L'){
          deleteLast();
        }else{}
    }else{
      deleteKey(key);
    }
   }else{}
  }
  
  printList();

  return 0;
}


Measured memory_bytes: 34364
#include <stdio.h>

int main(void)
{
	int a,b;
	char op;
	int i;

	for (i = 0; 1; i++)
	{
		scanf("%d %c %d",&a,&op,&b);

		if (op == '?')
		{
			break;
		}else if (op == '+')
		{
			printf("%d\n",a+b);

		}else if (op == '-')
		{
			printf("%d\n",a-b);

		}else if (op == '/')
		{
			printf("%d\n",a/b);
		}else if (op == '*')
		{
			printf("%d\n",a*b);
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int INF = 10000000;
ll n;
int main(void){
    ll x, y;
    cin >> x >> y;
    if (x%y == 0) cout << -1 << endl;
    else cout << x*(y - 1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
    int cnt,cnt2;
    int i;
    int cnt3 = 0;
    char snake[201];
    scanf("%d",&cnt);
    while(cnt3 != cnt){
        scanf("%s",snake);
        if(strlen(snake)<2 || snake[0]!='>') {
            printf("NA\n");
        }
        else if(snake[1]=='\'') {
            cnt2=0;
            i=2;
            while(snake[i]=='=') {
                i++;
                cnt2++;
            }
            if(snake[i]!='#' || cnt2<=0){
                printf("NA\n");
            }
            else {
                i++;
                while(snake[i]=='=') {
                    i++;
                    cnt2--;
                }
                if(cnt2!=0){
                    printf("NA\n");
                }
                else if(snake[i]!='~' || snake[i+1]!=0){
                    printf("NA\n");
                }
                else{
                    printf("A\n");
                }
            }
        }
        else if(snake[1]=='^') {
            i=2;
            while(snake[i]=='Q' && snake[i+1]=='='){
                i+=2;
            }
            if(i==2){
                printf("NA\n");
            }
            else if(snake[i]!='~' || snake[i+1]!='~' || snake[i+2]!=0){
                printf("NA\n");
            }
            else{
                printf("B\n");
            }
        }
        else{
            printf("NA\n");
        }
        cnt3++;
    }
    return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	ll m;
	cin >> n >> m;
	ll ans;
	for (int i = m / n; i >= 1; i--) {
		if (m%i == 0) {
			if (m / i >= n) {
				ans = i;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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; }
using namespace std;

int main() {
    char s[5];
    cin >> s;
    sort(s, s+4);
    if ((s[0]==s[1]) && s[1]!=s[2] && s[2]==s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int c = 0;
  cin >> s;
  if (s[0] == '1') c++;
  if (s[1] == '1') c++;
  if (s[2] == '1') c++;
  cout << c << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
long long int gcd(long long int a,long long int b)
{
	long long int c=1;
	while(c!=0)
	{
		c=a%b;
		a=b;
		b=c;
	}
	return a;
}
int main()
{
	long long int n,a[105]={0},i,j=1,d,c;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        c=gcd(j,a[i]);
        j=a[i]/c*j;
    }
	if(d<=1000000000000000000)
		printf("%lld\n",j);
	else
		return 0;

	return 0;
}

Measured memory_bytes: 128
import sys

N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    if A[i]%2 == 0:
        if not((A[i]%3 == 0) or (A[i]%5 == 0)):
            print('DENIED')
            sys.exit()

print('APPROVED')

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


// 入力 
int N,M;

//iとjがつながっているか
bool brg(int i,int j,vector<int> edge[]){
                  return  (find(edge[i].begin(), edge[i].end(), j) != edge[i].end());
}

int rec(int bit, int v,vector<int> edge[])
{
    int res=0;

   //初期値
    if (bit == (1<<v)) {
        return 1;
    }

    // bit の v を除いたもの
    int prev_bit = bit & ~(1<<v);

    for (int u = 0; u < N; ++u) {
        if (!(prev_bit & (1<<u))) continue; // u が prev_bit になかったらダメ

            res +=rec(prev_bit, u,edge) *brg(u,v,edge);
    }

    return res;
}




int main()
{
    // 入力
    cin >> N>>M;
    vector<int> edge[N];

    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x].push_back(y);
        edge[y].push_back(x);              
    }


    cout << rec((1<<N)-1, 0 ,edge)<< endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int N,K;
  scanf("%d%d\n",&N,&K );
  if (N % K == 0)
  {
    printf("%d\n",0 );
  }
  else
  {
    printf("%d\n",1 );
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
  
int preOrder[40],inOrder[40];
 
void solve(int ,int );
  
int main(){

  int i,n;
  
  scanf("%d",&n);

  for(i = 0;i < n;i ++)
    {
      scanf("%d",&preOrder[i]);
    }
  
  for(i = 0;i < n;i ++)
    {
      scanf("%d",&inOrder[i]);
    }

  solve(0,n-1);

  printf("\n");

  return 0;
}


void solve(int l,int r){

  int i;
  static int p=0;

  if(l>r)return;

  if(l == r){
    
    if(inOrder[l] == preOrder[0])
      {
	printf("%d",inOrder[l]);
      }else{
      printf("%d ",inOrder[l]);
    } 

    p++;
    
    return;
  }

  int x = preOrder[p];

  p ++;

  for(i = l;i <= r;i ++)
    {
      if(inOrder[i]==x) break;
    }
  
  solve(l,i-1);
  solve(i+1,r);
    
  if(x == preOrder[0])printf("%d",x);

  else printf("%d ",x);
}

Measured memory_bytes: 600
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])
c = 0
if 0 < a <= 12:
    c += 10
if 0 < b <= 12:
    c += 1
if c == 11:
    print("AMBIGUOUS")
elif c == 10:
    print("MMYY")
elif c == 1:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
//#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
//#include <cmath>

using namespace std;


int main(void) {
	int K;
	string S;
	cin >> K;
	cin >> S;


	if (S.length() <= K) {
		cout << S << endl;
	}
	else {
		cout << S.substr(0, K) << "..." <<endl;
	}

#ifdef _DBG_
	int A;
	cin >> A;
#endif

	return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; Next(a); return a; }
  template<class A, class B>void Next(pair<A, B>& a) { cin >> a.first >> a.second; }
  template<class A>void Next(A& a) { cin >> a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) (*this), i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;
/*---------------------------------------------------------------------*/


void Calc() {

  auto s = in.Array<string>(3);
  for (auto& i : s) {
    reverse(all(i));
  }
  int now = 0;
  for (;;) {
    if (s[now].size() == 0) {
      cout << ((char)(now + 'A')) << endl;
      return;
    }
    int next = s[now].back() - 'a';
    s[now].pop_back();

    now = next;
  }

}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	balls := scanIntSlice(n)
	nums := map[int]int{}
	for _, n := range balls {
		nums[n]++
	}
	all := 0
	for _, c := range nums {
		all += c * (c - 1) / 2
	}
	for k := 0; k < n; k++ {
		fmt.Printf("%d\n", all-nums[balls[k]]+1)
	}
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> v[5005];

int n, x[5005], dp[5005];
ll other[5005];
//x[i] : i번 점과 같은 색을 가진 것들의 가중치 합 (부트리에서)
//other[i] : i번 점과 다른 색을 가진 것들의 가중치 합 (부트리에서)
//"어떤색"을 칠해야 한다는 구애를 받지 않아도 된다. (얼마든지 색 전부 뒤집으면 반전되서)
void dfs(int now) {
	if (v[now].empty()) {
		other[now] = 0;
		return;
	}
	for (int i = 0; i < v[now].size(); i++)dfs(v[now][i]);
	ll sum = 0;
	memset(dp, 0, sizeof(dp));
	dp[0] = 1;
	for (int i = 0; i < v[now].size(); i++) {
		int nxt = v[now][i];
		sum += x[nxt] + other[nxt];//내 부트리에 있는 가중치들 합
		for (int j = x[now]; j >= 0; j--) {
			//특정 색깔의 합으로 가능한 수치들
			//x[now]이하에서 찾는 이유는 나중에 dp[t]=1인 t에 얼마 더해서 x[now]만큼 만들어줄 수 있기 때문
			dp[j] = ((j - x[nxt] >= 0 ? dp[j - x[nxt]] : 0) | (j - other[nxt] >= 0 ? dp[j - other[nxt]] : 0));
		}
	}
	for (int i = x[now]; i >= 0; i--) {
		if (dp[i]) {//내 점엔 x[now] - i를 칠하게 됨
			if (sum - i >= 0) {//나와 다른 색을 가진 점들의 합이 유효해야 함
				other[now] = sum - i;
				return;
			}
		}
	}
	puts("IMPOSSIBLE"); exit(0);
}
int main() {
	scanf("%d", &n);
	for (int p, i = 2; i <= n; i++) {
		scanf("%d", &p); v[p].push_back(i);
	}
	for (int i = 1; i <= n; i++)scanf("%d", &x[i]);
	dfs(1);
	puts("POSSIBLE");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll x){
	for(ll i=0;i<40;i++){
		if((1ll<<i)<=x&&x<(1ll<<(i+1))){
			return (1ll<<(i+1));
		}
	}
}
int main() {
	ll n,a[214514];
	map<ll,ll>mp;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	sort(a,a+n);
	ll ans=0;
	for(int i=n-1;i>=0;i--){
		ll x=f(a[i]);
		if(mp[x-a[i]]&&mp[a[i]]){
			if(x==2*a[i]){
				if(mp[a[i]]>=2){
					mp[a[i]]-=2;
					ans++;
				}
			}else{
				mp[a[i]]--;
				mp[x-a[i]]--;
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 26752
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e5 + 5, mod = (int) 0;
int d[13], have[30];
int main() {
	int n;
	cin >> n;
	for (int j = 0; j < n; ++j) {
		int x;
		cin >> x;
		d[x]++;
	}
	int res = 0;
	for (int mask = 0; mask < (1 << 13); ++mask) {
		memset(have, 0, sizeof have);
		for (int j = 0; j < 13; ++j) if (d[j]) {
			if (d[j] > 1) {
				have[12 - j] += 1;
				have[12 + j] += d[j] - 1;
			} else {
				if (mask >> j & 1) have[12 - j]++;
				else have[12 + j]++;
			}
		}
		have[12]++;
		int mn = 12;
		for (int x = 0; x < 25; ++x) if (have[x] > 1) mn = 0;
		for (int x = 0; x < 25; ++x)
			for (int y = 0; y < 25; ++y)
				if (have[x] && have[y] && x != y)
					mn = min(mn, min(24 - abs(x - y), abs(x - y) % 24));
		res = max(res, mn);
	}
	cout << res << endl;
}




Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
for i in range(0,(n-1)//2):
    s -= 2*a[2*i+1]
b = []
b.append(s)
for i in range(0,n-1):
    b.append(2*a[i]-b[i])

print(" ".join(map(str,b)))

Measured memory_bytes: 19144