akhauriyash/Code-Regression huggingface dataset:
SA=[ord(i)-ord('a') for i in list(input())]
SB=[ord(i)-ord('a') for i in list(input())]
SC=[ord(i)-ord('a') for i in list(input())]
S=[SA, SB, SC]
N=[[0,len(SA)],[0,len(SB)],[0,len(SC)]]
P=['A','B','C']
p=0
while N[p][0]!=N[p][1]:
  n=S[p][N[p][0]]
  N[p][0]+=1
  p=n
print(P[p])


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N, M, K; cin >> N >> M >> K;
	int ok = 0;
	FOR(n, 0, N + 1) {
		FOR(m, 0, M + 1) {
			LL a = M * n + N * m - 2*n * m;
			if (a == K)ok = 1;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int h = 0;
		int m = 0;
		int s = 0;

		s = sc.nextInt();

		h = s / 3600;
		s = s % 3600;
		m = s / 60;
		s = s % 60;

		System.out.println(h + ":" +  m  + ":" + s);
	}

}

Measured memory_bytes: 26224
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
    cout<<fixed;
}
int main(){
    init();

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

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

    for(int i=0;i<Q;i++){
        ll l,r;cin>>l>>r;
        auto itr1=lower_bound(A.begin(),A.end(),l);
        auto itr2=upper_bound(A.begin(),A.end(),r);
        cout<<itr2-itr1<<endl;
    }
    
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;

vector<bool> issafe; // issafe[v] := v が壊れていないかどうか

int main() {
  int N,M;
    cin >> N >> M;
    issafe.assign(N+1, true);
    for (int i = 0; i < M; ++i) {
        int a; cin >> a;
        issafe[a] = false; // a 段目は壊れてる
    }

    // DP テーブル
    vector<int> dp(N+1, 0); // 各段について 0 で初期化しておく

    // 初期条件
    dp[0] = 1;
    if (issafe[1]) dp[1] = 1;

    // ループ
    for (int n = 2; n <= N; ++n) {
        if (issafe[n-1]) dp[n] += dp[n-1]; // n-1 段目が安全なら
        if (issafe[n-2]) dp[n] += dp[n-2]; // n-2 段目が安全なら
        dp[n] %= MOD; // 1000000007 で割る
    }
    cout << dp[N] << endl;
}


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

int main() {
    string S;
    int64_t K;
    cin >> K >> S;
    if(K >= S.size()){
        cout << S << endl;
    }else{
        string str_1 = S.substr(0, K);
        cout << str_1+"..." << endl;
    }
}


Measured memory_bytes: 3628
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int L;
  rd(L);
  struct E {
    int from, to, cost;
  }

  E[] edges;
  int f(int K) {
    if (K == 2) {
      edges ~= E(1, 2, 0);
      edges ~= E(1, 2, 1);
      return 2;
    }
    if (K & 1) {
      auto last = f(K - 1);
      edges ~= E(1, last, K - 1);
      return last;
    } else {
      auto last = f(K / 2);
      foreach (ref e; edges) {
        e.cost *= 2;
      }
      edges ~= E(last, last + 1, 0);
      edges ~= E(last, last + 1, 1);
      return last + 1;
    }
  }

  auto n = f(L);
  writeln(n, " ", edges.length);
  foreach (e; edges) {
    writeln(e.from, " ", e.to, " ", e.cost);
  }
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 256
/*
到所有点距离和最大的一定是叶节点，
而如果i,j相连，一定满足a_j=a_i+2*sz_i-n。
由于做到i的时候i的儿子都做过了，那j一定是i的父亲
然后我们发现还有一个a_i没利用，而这也是所有a_i的最小值 
我们只要判断一下它是不是重心就行了
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100002;
int a[N],fa[N],id[N],i,sz[N],n,x;
map<int,int>mp;
bool cmp(int x,int y){return a[x]>a[y];}
signed main(){
	scanf("%lld",&n);
	for (i=1;i<=n;i++) scanf("%lld",&a[i]),id[i]=i,mp[a[i]]=i,sz[i]=1;
	sort(id+1,id+n+1,cmp);
	for (i=1;i<n;i++){
		x=id[i];
		fa[x]=mp[a[x]+2*sz[x]-n];
		if (!fa[x]) return puts("-1"),0;
		sz[fa[x]]+=sz[x];
	}
	for (i=1;i<n;i++) a[id[n]]-=sz[id[i]];
	if (a[id[n]]) return puts("-1"),0;
	for (i=1;i<n;i++) printf("%lld %lld\n",id[i],fa[id[i]]);
}

Measured memory_bytes: 10752
#include<stdio.h>
#include<stack>
using namespace std;
int n;
int tmp;
stack<int> a;
int main(){
    scanf("%d",&n);
    if(n==0) printf("0");
    else while(n!=0){
        if(n<0){
            if(n%2==0){
                a.push(n%(-2));
                n=n/(-2);
            }
            else{
                a.push(n%(-2)+2);
                n=n/(-2)+1;
            }
        }
        else{
            a.push(n%(-2));
            n=n/(-2);
        }
    }
    while(!a.empty()){
        printf("%d",a.top());
        a.pop();
    }
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

vector<vector<ll>> to(10000),from(10000);

bool table[10000]={},fable[10000]={};

void tdfs(ll a){
    table[a]=true;
    for(int i=0;i<to[a].size();i++){
        if(!table[to[a][i]]){tdfs(to[a][i]);}
    }
}

void fdfs(ll a){
    fable[a]=true;
    for(int i=0;i<from[a].size();i++){
        if(!fable[from[a][i]]){fdfs(from[a][i]);}
    }
}



int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> e;
    for(int i=0;i<m;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--; b--;
        to[a].push_back(b);
        from[b].push_back(a);
        e.push_back({a,b,-1*c});
    }
    vector<ll> v(n,E);
    v[0]=0;
    for(int i=0;i<n+10;i++){
        for(int t=0;t<e.size();t++){
            vector<ll> E=e[t];
            v[E[1]]=min(v[E[1]],v[E[0]]+E[2]);
        }
    }
    tdfs(0);
    fdfs(n-1);
    bool inf=false;
    for(int i=0;i<n+100;i++){
        for(int t=0;t<e.size();t++){
            vector<ll> E=e[t];
            if(v[E[1]]>v[E[0]]+E[2] && table[E[1]] && fable[E[1]]){inf=true;}
            v[E[1]]=min(v[E[1]],v[E[0]]+E[2]);
        }
    }
    if(inf){cout<<"inf"<<endl;}
    else{cout<<-1*v[n-1]<<endl;}
    
    
    
    
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] card = new int[2*n];
		for(int i=1;i<=2*n;i++) card[i-1] = i;
		for(int i=0;i<m;i++){
			int k = sc.nextInt();
			if(k == 0){
				int[] tcard = new int[2*n];
				for(int j=0;j<n;j++){
					tcard[2*j] = card[j];
					tcard[2*j + 1] = card[j+n];
				}
				card = tcard;
			}
			else{
				int[] tcard = new int[2*n];
				for(int j=0;j<k;j++) tcard[j+2*n-k] = card[j];
				for(int j=0;j<2*n-k;j++) tcard[j] = card[j+k];
				card = tcard;
			}
		}
		for(int i=0;i<2*n;i++) System.out.println(card[i]);
	}
}

Measured memory_bytes: 24296
//--- pB ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		long n = Long.parseLong(reader.ns());
		long a = Long.parseLong(reader.ns());
		long b = Long.parseLong(reader.ns());

		long turns = n / (a+b);
		long res = turns * a;

		long left = n - turns * (a + b);
		long left_blue = Math.min(a, left);

		res += left_blue;

		System.out.println(res);

		return;
	}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 23380
#include<stdio.h>
long long int digsum(long long int n)
{
  long long int i=0;
  while(n!=0)
  {
    i+=(n%10);
    n/=10;
  }
  return i;
}
int main()
{

  long long int n;
  scanf("%lld",&n);
  if(n%digsum(n)==0) printf("Yes\n");
  else printf("No\n");
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 200000;
ll mod = INF;

double p[maxn];
double ans=0;
double sum[maxn+1];
int n,k;

int main(){
    cin >> n>>k;
    rep(i,n)cin >> p[i];

    rep(i,n){
        sum[i+1]=sum[i]+(double)(1+p[i])/2.0;
    }

    for(int i=1;i<=n-k+1;i++){
        ans=max(ans,sum[i+k-1]-sum[i-1]);
    }
    cout << fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6840
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace aizu1
{
    public class Solution
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            int[] w = new int[n];
            int maxWeight = 1;
            int left = 0;
            int right = 0;

            for(int i=0;i<n;i++)
            {
                w[i] = int.Parse(Console.ReadLine());
                right += w[i];
                maxWeight = maxWeight > w[i] ? maxWeight : w[i];
            }

            if (k >= n) left = maxWeight;
            else
            {
               while(left<=right)
                {
                    int mid = (left + right)/2;
                    int j = 0;

                    for(int i=0;i<k;i++)
                    {
                        int tmp = 0;
                        while(j<n&& (tmp += w[j]) <= mid)
                        {
                            j++;
                        }
                    }

                    if (j == n)  right = mid - 1; 
                    else left = mid + 1;
                }
            }

            Console.WriteLine(left);
            
        }
    }
}

Measured memory_bytes: 9792
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int r = a;
    if (b > r) {
        r = b;
    }
    if (c > r) {
        r = c;
    }

    int ans = 1;
    if (a != r) {
        ans *= a;
    }
    if (b != r) {
        ans *= b;
    }
    if (c != r) {
        ans *= c;
    }

    ans /= 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, D;
    cin >> N >> D;
    cout << N / (1 + 2 * D) + (N % (1 + 2 * D) == 0 ? 0 : 1) << endl;
    return 0;
}


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

int main() {
  int N;
  std::cin >> N;

  if (N < 3) {
    std::cout << "0\n";
    return 0;
  }

  std::vector<long> lengths(N);
  for (auto& l : lengths) {
    std::cin >> l;
  }
  std::sort(lengths.begin(), lengths.end());

  long cnt = 0;
  long total_cnt = 0;

  for (auto it1 = lengths.begin(); (it1 + 2) != lengths.end(); ++it1) {
    for (auto it2 = it1 + 1; (it2 + 1) != lengths.end(); ++it2) {
      for (auto it3 = it2 + 1; it3 != lengths.end(); ++it3) {
        if (*it1 != *it2 && *it2 != *it3 && *it1 != *it3
            && (*it3 < (*it1 + *it2))) {
          ++cnt;
        }
        ++total_cnt;
      }
    }
  }

  std::cerr << total_cnt << '\n';
  std::cout << cnt << '\n';
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			
			String s = sc.next();
			
			String sr = s.replaceAll("ABC", "");
			
			int count = (n - sr.length()) / 3;
			
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 35716
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

string s, t = "ACGT";

int main() {
	cin >> s;
	
	int ma = 0, c = 0;
	inc(i, SI(s)) {
		if(t.find(s.substr(i, 1)) != -1) { c++; setmax(ma, c); } else { c = 0; }
	}
	
	cout << ma << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m, s; scanf("%d%d%d", &n, &m, &s);
	std::vector<int> a(m), b(m), c(m), d(m), x(n), y(n);
	std::vector<std::vector<int>> g(n);
	for(int i = 0; i < m; i++) {
		scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
		a[i]--; b[i]--;

		g[a[i]].push_back(i);
		g[b[i]].push_back(i);
	}
	for(int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);

	auto dp = make_v<i64>(n, 5001);
	for(int i = 0; i < (int)dp.size(); i++) for(int j = 0; j < (int)dp[i].size(); j++) dp[i][j] = 1LL << 60; dp[0][std::min(5000, s)] = 0;

	using P = std::tuple<i64, int, int>;
	std::priority_queue<P, std::vector<P>, std::greater<P>> qu; qu.push({0, 0, std::min(5000, s)});
	while(!qu.empty()) {
		auto [from, v, now] = qu.top(); qu.pop();
		if(dp[v][now] < from) continue;

		{
			int idx = std::min(5000, now + x[v]);
			i64 nxt = from + y[v];
			if(dp[v][idx] > nxt) qu.push({dp[v][idx] = nxt, v, idx});
		}

		for(int id: g[v]) {
			if(now - c[id] < 0) continue;
			int to = a[id] ^ b[id] ^ v;
			int idx = now - c[id];
			i64 nxt = from + d[id];

			if(dp[to][idx] <= nxt) continue;
			qu.push({dp[to][idx] = nxt, to, idx});
		}
	}

	for(int i = 1; i < n; i++) printf("%lld\n", *std::min_element(begin(dp[i]), end(dp[i])));
	return 0;
}


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

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  for(int i=1;i<=n;i++){
    string s=to_string(i);
    int m=s.size();
    int cnt=0;
    for(int j=0;j<m;j++){
      cnt+=s[j]-'0';
    }
    if(cnt>=a&&cnt<=b) ans+=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
h = []
for i in range(x):
    for j in range(y):
        if(i*j>k): break
        for l in range(z):
            if(i*j*l>k): break
            h.append(a[i] + b[j] +c[l])
h.sort(reverse = True)
for i in range(k):
    print(h[i])

Measured memory_bytes: 112344
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

fib_list = [-1 for _ in range(100)]


def fib(n):
    if n == 0 or n == 1:
        return 1
    else:
        if fib_list[n] != -1:
            return fib_list[n]
        else:
            fib_list[n] = fib(n - 1) + fib(n - 2)
        return fib_list[n]


print(fib(int(input())))



Measured memory_bytes: 6896
#E
N=int(input())
x=[0 for i in range(N)]
y=[0 for i in range(N)]

Cx=[0 for i in range(N)]
Cy=[0 for i in range(N)]

for i in range(N):
    x[i],y[i]=map(int,input().split())
    Cx[i]=x[i]+y[i]
    Cy[i]=x[i]-y[i]
    
ans=max(max(Cx)-min(Cx),max(Cy)-min(Cy))
print(ans)

Measured memory_bytes: 98928
#include<stdio.h>

int main(){

int x,y;

//while(scanf("%d %d",&x,&y)!=EOF){

for(int i=0;i<4;i++){
scanf("%d %d",&x,&y);

int t=0;
switch(x){
case 1:
t=6000;break;

case 2:
t=4000;break;

case 3:
t=3000;break;

case 4:
t=2000;break;
}

printf("%d\n",t*y);
}
return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;

void solve() {
    string s; cin >> s; 
    int q; cin >> q;
    string beginning = "", end = "";
    bool flipped = false;
    int t, f;
    char c;
    while (q--) {
        cin >> t;
        if (t == 1) flipped = !flipped;
        else {
            cin >> f >> c;
            if (!flipped) {
                if (f == 1) beginning.push_back(c);
                else end.push_back(c);
            }
            else {
                if (f == 1) end.push_back(c);
                else beginning.push_back(c);
            }
        }
    }
    if (!flipped) {
        reverse(beginning.begin(), beginning.end());
        cout << beginning << s << end;
    }
    else {
        s += end;
        reverse(s.begin(), s.end());
        cout << s << beginning;
    }
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N , K; cin >> N >> K;
  vector<ll> a(N); rep(i,N) cin >> a[i];

  rep(loop , K){
    vector<ll> b(N + 1);
    rep(i,N) b[max( (ll)0 , i - a[i])]++;
    rep(i,N) b[min(N , i + a[i] + 1)]--;
    rep(i,N) b[i + 1] += b[i];
    if(a == b) break;
    a = b;
  }
  rep(i,N) cout << a[i] << " "; cout << endl;
}


Measured memory_bytes: 7928
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf (ll)2e18
#define EPS 1e-12
#define mod 1000000007LL
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	int k;
	cin >> k;
	int a, b;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK";
			return;
		}
	}
	cout << "NG";
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	fore(t, 0, q)
	{
		solve();
		cout << '\n';
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int mn = a[0];
    int mx = a[n-1];
    if(mn == mx){
        cout << 0 << endl; 
        return 0;
    }
    ll ans = 1e9;
    for(int i = mn; i <= mx; ++i){
        ll temp = 0;
        rep(j,n){
            ll d = abs(i-a[j]);
            d*=d;
            temp+=d;
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

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

#define int int64_t
#define pb push_back
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first.first
#define sec first.second
#define ter second
#define MAXN 100001
#define mod 1000000007

signed main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int ans = a / b;
  if (a % b)
    ans++;
  cout << ans * c << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
using namespace std;
int main(){
    for(int i=0;i<9;i++){
        string str;
        cin>>str;
        int before,after;
        cin>>before>>after;
        cout<<str<<" "<<before+after<<" "<<before*200+after*300<<endl;
    }
    return 0;
}


Measured memory_bytes: 3164
N = int(input())
A = list(map(int,input().split()))
A.sort()
if A[0] == 0:
    print(0)
    exit()

ans = 1
check = 10 ** 18

for i in range(N-1,-1,-1):
    ans *= A[i]
    if ans > check:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 21648
N, M = map(int, input().split())
tmp = []
ans = 0
for _ in range(N):
    tmp.append(list(map(int, input().split())))
tmp.sort()
i = 0
while M > 0:
    ans += tmp[i][0] * min(M,tmp[i][1])
    M -= tmp[i][1]
    i += 1
print(ans)

Measured memory_bytes: 27760
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, K, A):
    tree = SegmentTree(300_300)
    for a in A:
        p = tree.query(max(0, a - K), min(300_300, a + K + 1))
        tree.modify(a, p + 1)
    print(tree.query_all())

class SegmentTree:
    __slots__ = ('__n', '__d', '__f', '__e')

    def __init__(self, n=None, f=max, identity_factory=int, initial_values=None):
        assert(n or initial_values)
        size = n if n else len(initial_values)
        d = [identity_factory() for _ in range(2 * size + 1)]
        self.__n, self.__d, self.__f, self.__e = size, d, f, identity_factory
        if initial_values:
            for i, v in enumerate(initial_values): d[size + i] = v
            for i in range(size - 1, 0, -1): d[i] = f(d[i << 1], d[i << 1 | 1])

    def get_val(self, index):
        return self.__d[index + self.__n]

    def set_val(self, index, new_value):
        i, d, f = index + self.__n, self.__d, self.__f
        if d[i] == new_value: return
        d[i], i = new_value, i >> 1
        while i: d[i], i = f(d[i << 1], d[i << 1 | 1]), i >> 1

    def modify(self, index, value):
        self.set_val(index, self.__f(self.__d[index + self.__n], value))

    def query(self, from_inclusive, to_exclusive):
        ans = self.__e()
        if to_exclusive <= from_inclusive: return ans
        l, r, d, f = from_inclusive + self.__n, to_exclusive + self.__n, self.__d, self.__f
        while l < r:
            if l & 1: ans, l = f(ans, d[l]), l + 1
            if r & 1: ans, r = f(d[r - 1], ans), r - 1
            l, r = l >> 1, r >> 1
        return ans

    def query_all(self):
        return self.query(0, self.__n)

    def bisect_left(self, func):
        '''func()がFalseになるもっとも左のindexを探す
        '''
        i, j, n, f, d, v = self.__n, self.__n + self.__n, self.__n, self.__f, self.__d, self.__e()
        while i < j:
            if i & 1:
                nv = f(v, d[i])
                if not func(nv): break
                v, i = nv, i + 1
            i, j = i >> 1, j >> 1
        while i < n:
            nv = f(v, d[i << 1])
            if func(nv): v, i = nv, i << 1 | 1
            else: i = i << 1
        return i - n

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(input()) for _ in range(N)]
    main(N, K, A)


Measured memory_bytes: 122732
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1145&lang=jp
// http://algoogle.hadrori.jp/aoj/1145/
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

string s;
int n, cur = 0;

//今見ているところの数字を取得
int number()
{
	int ret = 0;
	while(isdigit(s[cur]))
	{
		ret = ret * 10 + s[cur++] - '0';
	}
	return ret;
}

int dfs(int sum) // sumはこれまで見た文字数
{
	if (cur == s.length()) // 最後まで来た
	{
		return 0;
	}
	if (s[cur] == '(') // 左カッコ
	{
		cur++; // 中に入る
		return dfs(sum);
	}
	if (s[cur] == ')') // 右カッコ
	{
		cur++; // 外に出る
		return 0;
	}
	if(isalpha(s[cur])) // 潜りきった
	{
		if (sum == n)
		{
			throw s[cur];
		}
		cur++;
		return 1 + dfs(sum + 1); // １文字先に
	}

	// 見ている文字は数字

	int m = number();
	int l; // 数字の後に来る文字の文字数
	int head = cur;

	// 数字の次にアルファベットなら
	if (isalpha(s[cur]))
	{
		l = 1;
		cur++;
	}
	else // それ以外（カッコ）なら
	{
		l = dfs(sum);
	}

	// 今見ている数字倍した後の範囲内にあるなら
	if (l * m + sum > n)
	{
		cur = head;
		n = (n - sum) % l; // これまで見ていた文字数(sum)分を消す
		dfs(0); // sumだけ消したので 0 で再探索
	}

	// 今見ている範囲内にはない
	return l * m + dfs(sum + l * m);	

}

char solve(){
	cur = 0;
	try{ dfs(0); }
	catch(char e){ return e;}
	return '0';
}

int main(){
	while(cin >> s >> n, s!="0") cout << solve() << endl;
	return 0;
}






Measured memory_bytes: 3152
n, k = gets.split.map(&:to_i )
sunukes = Array.new(n.to_i, 0)
k.times do
  d = gets.to_i
  a = gets.split.map(&:to_i).each do |i|
    i -= 1
    sunukes[i] += 1
  end
end

puts sunukes.filter { |s| s == 0 }.length


Measured memory_bytes: 14388
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

vector<vector<ll>> f(100000);

class UnionFind{
    public:
        vector<ll> uni;
        UnionFind(ll s) : uni(s, -1) { }

       //頂点aが所属するグループを調べる
        ll root(ll a)
        {
            if (uni[a] < 0) return a;
            return uni[a] = root(uni[a]);
        }

        //頂点aと頂点bを繋ぐ。もともと同じグループの時falseを返す
        bool connect(ll a, ll b)
        {
            a = root(a);
            b = root(b);
            if (a == b) return false;

            if (uni[a] > uni[b])
            {
                a ^= b;
                b ^= a;
                a ^= b;
            }

            uni[a] = uni[a] + uni[b];
            uni[b] = a;
            return true;
        }

        //頂点a,bが同じグループであるかを調べる
        bool isConnect(ll a, ll b)
        {
            return root(a) == root(b);
        }

        //頂点aを含むグループの頂点数を調べる
        ll size(ll a)
        {
            return -uni[root(a)];
        }
};

int main(int argc, char const *argv[])
{
    ll n,m,k;
    cin>>n>>m>>k;

    UnionFind u(n);

    for (ll i = 0; i < m; i++)
    {
        //
        ll a, b;
        cin >> a >> b;
        u.connect(a - 1, b - 1);
        f[a-1].push_back(b-1);
        f[b-1].push_back(a-1);
        
            }

    for (ll i = 0; i < k; i++)
    {
        ll c, d;
        cin >> c >> d;
        f[c-1].push_back(d-1);
        f[d-1].push_back(c-1);
    }
    
    for (ll i = 0; i < n; i++)
    {
        ll ans = u.size(i);
        if(!f[i].empty())
        {
            for (auto p : f[i])
            {
                if(u.isConnect(i, p)){
                    ans--;
                }   
            }
        }
        if(i != 0){
            cout<< ' ';
        }
        cout << ans - 1;
    }  
    cout << endl;
}

Measured memory_bytes: 10368
while True:
    a,b,c = input().split(" ")
    a = int(a)
    c = int(c)

    if b == "+":
        print(a+c)

    elif b == "-":
        print(a-c)

    elif b == "*":
        print(a*c)

    elif b == "/":
        print(a//c)

    else:
        break


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

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    int odd, two, four;
    foreach (a; A) {
        if (a % 2 == 1) odd += 1;
        else if (a % 4 == 0) four += 1;
        else two += 1;
    }

    int mode = 0;
    foreach (i; 0..N) {
        if (mode == 0) {
            if (odd > 0) odd -= 1, mode = 4;
            else if (two > 0) two -= 1, mode = 2;
            else four -= 1, mode = 0;
        } else if (mode == 2) {
            if (two > 0) two -= 1, mode = 2;
            else if (four > 0) four -= 1, mode = 0;
            else {writeln("No"); return;}
        } else if (mode == 4) {
            if (four > 0) four -= 1, mode = 0;
            else {writeln("No"); return;}
        }
    }

    writeln("Yes");
}


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

int main(){
   int num[5];
   int M1 = -2147483647, M2 = -2147483647, M3= -2147483647 , M4= -2147483647 , M5 = -2147483647;
   int I1 = 0, I2 = 0, I3= 0 , I4= 0 , I5 = 0 ;
   cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4] ;

   for(int i=0 ; i < 5; i++){
      if(M1 < num[i]) {
          M1 = num[i];
          I1 = i;
       }
    }

    for(int i=0 ; i < 5; i++){
        if(i == I1 ) continue;
        if(M2 < num[i]) {
           M2 = num[i];
           I2 = i;
        }
     }

for(int i=0 ; i < 5; i++){
if(i == I1 || i == I2 ) continue;
if(M3 < num[i]) {
M3 = num[i];
I3 = i;
}
}

for(int i=0 ; i < 5; i++){
if( i == I1 || i == I2 || i == I3 ) continue;
if(M4 < num[i]) {
M4 = num[i];
I4 = i;
}
}

for(int i=0 ; i < 5; i++){
if( i == I1 || i == I2 || i == I3 || i == I4 ) continue;
if(M5 < num[i]) {
M5 = num[i];
I5 = i;
}
}

cout << M1 << " " << M2 << " " << M3 << " " << M4 << " " << M5 << endl;

return 0 ;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;j++j) {}

int main(void) {
  int N;cin>>N;
  map<string,vector<pair<int,int>>> M;
  string s;
  int p;
  REP(i,N) {
    cin>>s>>p;
    M[s].push_back(make_pair(p,i+1));
  }

  for(auto m:M) {
    vector<pair<int,int>> v = m.second;
    sort(v.begin(),v.end(),greater<pair<int,int>>());
    REP(i,v.size()) {
      pr(v[i].second);
    }
  }
  return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int S, W;
	
	cin>>S>>W;
	
	if(W >= S) cout<<"unsafe"<<endl;
	else {
		cout<<"safe"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n;
 cin>>n;
 vector<ll> a(n);
 for(ll i=0;i<n;i++)cin>>a[i];
 ll cnt = 0;
 for(ll i=0;i<n;i+=2)if( a[i]%2 == 1 ) cnt++;
 cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3572
N,W = map(int, input().split())
w = [0]*N
v = [0]*N
for n in range(N):
    w[n],v[n] = map(int, input().split())

dp = [[0]*(W+1) for i in range(N)] 

for i in range(N):
    for wt in range(1,W+1):
        if wt >= w[i]:
            dp[i][wt] = max(dp[i][wt],dp[i-1][wt-w[i]] + v[i])
        dp[i][wt] = max(dp[i][wt],dp[i-1][wt])

print(max(dp[N-1]))

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

#define MAX_N 100001

int N, M, H[MAX_N], ans = 0;
vector<int> E[MAX_N];

void solve(){
    for(int i = 1; i <= N; i++){
        bool sw = true;
        set<int> C;
        while(!E[i].empty()){
            int a = *(E[i].end() - 1); E[i].pop_back();
            if(H[i] <= H[a] && C.find(a) == C.end()) {
                sw = false;
                C.insert(a);
            }
        }
        if(sw) ans++;
    }
    cout << ans << endl;
} 

int main(){
    cin >> N >> M;
    for(int i = 1; i <= N; i++) {
        cin >> H[i];
    }
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        E[a].push_back(b); E[b].push_back(a);
    }
    solve();
    return 0;
}

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

public class Main {
	private static void solve(){
	//Implement solution here.
		int n = ni();
		int a = ni();
		int b = ni();
		int both = Math.min(a, b);
		int single = Math.max(0, -(n - a - b));
		System.out.println(both + " " + single);
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 20820
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

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

	ll axor = 0;
	ll aor = 0;
	for(int i=0; i<N; i++){
		axor = axor^A[i];
		aor = aor|A[i];
	}

	vector<bool> yet(61);
	ll mask = 0;
	for(int k=0; k<61; k++){
		yet[k] = ((axor>>k)&1)==0 && ((aor>>k)&1)>0;
		if(((axor>>k)&1)==0){
			mask |= aor&(1LL<<k);
		}
	}

	vector<ll> b(N);
	for(int i=0; i<N; i++) b[i] = A[i]&mask;

	int p=0;
	for(int k=60; k>=0; k--){
		int j=-1;
		for(int i=p; i<N; i++){
			if((b[i]>>k)&1){
				j=i;
				break;
			}
		}
		if(j<0) continue;
		for(int i=0; i<N; i++){
			if(i==j) continue;
			if((b[i]>>k)&1) b[i] ^= b[j];
		}
		swap(b[j], b[p++]);
	}

	ll y = 0;
	for(int i=0; i<N; i++) y ^= b[i];
	debug(b);
	debug(any{axor, aor, mask, y});

	ll red = axor|y;
	cout << dec << red + (axor^red) << endl;

	return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int w, h, x, y;

int main()
{
    scanf("%d%d%d%d", &w, &h, &x, &y);
    printf("%.6f %d\n", (double)w * h * 0.5, (x * 2 == w && y * 2 == h));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 10;
int a[N][N];
int main(){
    int n;
    for(int i=1;i<=3;++i){
        for(int j=1;j<=3;++j){
            cin >> a[i][j];
        }
    }
    cin >> n;
    int b;
    for(int i=1;i<=n;++i){
        cin >> b;
        for (int i = 1; i <= 3; ++i)
        {
            for (int j = 1; j <= 3; ++j)
            {
                if(a[i][j] == b){
                    a[i][j] = 0;
                }
            }
        }
    }
    int ok = 0;
    n = 3;
    for(int i=1;i<=n;++i){
        int sum  = 0;
        for(int j=1;j<=n;++j){
            sum += a[i][j];
        }
        if(sum == 0){
            ok = 1;
            break;
        }
        sum = 0;
        for (int j = 1; j <= n; ++j)
        {
            sum += a[j][i];
        }
        if (sum == 0)
        {
            ok = 1;
            break;
        }
    }
    int sum = 0;
    for(int i=1;i<=3;++i){
        sum += a[i][i];
    }
    if(sum ==0){
        ok = 1;
    }
    sum = 0;
    for (int i = 1; i <= 3; ++i)
    {
        sum += a[i][3-i+1];
    }
    if (sum == 0)
    {
        ok = 1;
    }
    if(ok)  cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int T = in.nextInt();
		int[] c = new int[n];
		int[] t = new int[n];
		int minIdx = 0;
		int min = Integer.MAX_VALUE;
		for(int i=0;i<n;i++) {
			c[i] = in.nextInt();
			t[i] = in.nextInt();
			if(t[i]<=T && c[i]<min) {
				min = c[i];
				minIdx = i;
			}
		}
		if(min>1000) {
			System.out.println("TLE");
		}else {
			System.out.println(min);
		}

	}

}


Measured memory_bytes: 25172
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
int main() {
	constexpr long long int MOD = 1000000007;
	int n; std::cin >> n;
	std::vector<int> statement(n), count_called(n + 1, 0); for (auto& a : statement) std::cin >> a;
	long long int result = 1;
	count_called[0] = 3;
	for (auto a : statement) {
		result = result * count_called[a] % MOD;
		count_called[a]--;
		count_called[a + 1]++;
	}
	std::cout << result << '\n';
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main(){
	int ans=0;
	int n;
	cin>>n;
	int l,r;
	for(int i=0;i<n;i++){
		cin>>l>>r;
		ans+=r-l+1;
	}
	
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N;
  string S;
  cin>>N>>S;
  for(int i=0;i<S.size();i++){
    for(int j=0;j<N;j++){
      if(S.at(i)=='Z'){
        S.at(i)='A';
      }
      else{
        S.at(i)=(char)(S.at(i) + 1);
      }
    }
  }
  cout<<S<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double n = sc.nextDouble();
		double t = 1.08;
		double x = n/t;
		x = Math.ceil(x);
		if(Math.floor(x*t) == n) {
			System.out.println((int)x);
		}else {
			System.out.println(":(");
		}

		sc.close();
	}
}

Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	for(ll k = 2; k * (k - 1) / 2 <= n; k++) {
		if(k * (k - 1) / 2 == n) {
			cout << "Yes" << endl;
			cout << k << endl;
			vector<vector<ll>> s(k);
			ll pos = 1;
			for(ll i = 0; i < k; i++) {
				for(ll j = i + 1; j < k; j++) {
					s[i].pb(pos);
					s[j].pb(pos);
					pos++;
				}
			}
			REP(i,k) {
				cout << s[i].size() << " ";
				DUMP(s[i]);
			}
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int64_t cash = 1000;
  int64_t stock = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > a[i + 1]) {
      if (stock > 0) {
        cash += stock * a[i];
        stock = 0;
      }
      continue;
    }
    if (stock == 0) {
      stock = cash / a[i];
      cash -= stock * a[i];
    }
  }
  cout << cash << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<vector<int>> v = vector<vector<int>>(n, vector<int>(n - 1));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n - 1; j++) {
            cin >> v[i][j];
        }
    }
    
    int day[1000] = {0};
    int now = 0;
    while(1) {
        bool flag[1000] = {false};
        bool finish = true;
        bool flag2 = true;
        for(int i = 0; i < n; i++) {
            if(day[i] >= n - 1 || flag[i]) continue;
            
            if(day[i] < n - 1) {
                finish = false;
            }
            
            int partner = v[i][day[i]];
            if(v[partner - 1][day[partner - 1]] == i + 1 && !flag[partner - 1]) {
                day[i]++;
                day[partner - 1]++;
                flag[i] = true;
                flag[partner - 1] = true;
                
                flag2 = false;
            }
        }
        
        if(finish) {
            cout << now << endl;
            return 0;
        }
        now++;
        
        if(flag2) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 6272
import heapq
N, K = map(int, input().split())
H = list(map(int, input().split()))

if K>len(H):
    print("0")
else:
    heap=[]
    for item in H:
        item=item*(-1)
        heapq.heappush(heap, item)

    for _ in range(K):
        heapq.heappop(heap)

    H2 = list(map(lambda x: x * (-1), list(heap)))
    # print(H2)
    H2 = sum(H2)
    print(H2)


Measured memory_bytes: 29096
s = input()
n = len(s)
ans = 'Yes'
for i in range(n):
    if i % 2 == 0 and s[i] == 'L':
        ans = 'No'
        break
    elif i % 2 == 1 and s[i] == 'R':
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    long long int N ;
    cin >> N ;
    long long int L ;
    L = N ;
    int M ;
    M = (int)log10( (double)N ) + 1;//桁数の出力
    int a[M] ;
    int ans = 0;
    
    for(int i = 0; i < M ; i++ ){
        a[i] = N % 10;
        N = N / 10 ;
        ans += a[i];
    }
    if(L%ans==0){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }


    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        for(int i=1;i<=10000;i++){
            int x=sc.nextInt();
            if(x==0){
                break;
            }
            System.out.printf("Case %d: %d\n",i,x);
            
        }
    }
}



Measured memory_bytes: 62532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

const int N = 2*1e5+5;

ll a[N];

int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    ll ans = 0;
    for(int i = 1; i<n; i++){
        if(a[i-1] > a[i]){
            ans += (a[i-1] - a[i]);
            a[i] = a[i-1];
        }
    }

    cout <<ans <<endl;

    return 0;
}


Measured memory_bytes: 5172
s=input()
t=input()
l=[]
m=[]
for i in range(len(s)):
    l.append(s[i])
    m.append(t[i])
l.sort()
m.sort()
li=[1]
mi=[1]
i=1
while i<len(s):
    if l[i]==l[i-1]:
        li[-1]+=1
    else:
        li.append(1)
    if m[i]==m[i-1]:
        mi[-1]+=1
    else:
        mi.append(1)
    i+=1
li.sort()
mi.sort()
print("Yes" if li==mi else "No")
        

Measured memory_bytes: 7532