akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String A = in.next();
			String B = in.next();
			String C = in.next();
			if(A.charAt(A.length() - 1) == B.charAt(0) && B.charAt(B.length() - 1) == C.charAt(0)) {
				out.println("YES");
			} else {
				out.println("NO");
			}
		}
	}
		
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

Measured memory_bytes: 21204
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.00000001
using namespace std;

struct Info{
	double r;
};

double*** dp;

void func(char buf[300]){

	double length;
	int tmp;

	int index;

	tmp = 0;
	for(index = 0;buf[index] != ' ' && buf[index] != '\0'; index++){
		tmp = 10*tmp + buf[index] - '0';
	}

	length = (double)tmp;

	Info info[15];
	int info_index = 0;

	while(buf[index] != '\0'){

		tmp = 0;
		for(++index;buf[index] != ' ' && buf[index] != '\0';index++){
			tmp = 10*tmp + buf[index] - '0';
		}
		info[info_index].r = (double)tmp;
		info_index++;
	}

	double sum = 0;

	for(int i = 0; i < info_index; i++){
		sum += info[i].r;
	}

	if(length > 2*sum+EPS){
		printf("OK\n");
		return;
	}

	double distance[info_index][info_index];

	for(int i = 0; i < info_index;i++){
		for(int k = 0; k < info_index; k++){
			if(i != k){
				distance[i][k] = sqrt((info[i].r+info[k].r)*(info[i].r+info[k].r)-(info[i].r-info[k].r)*(info[i].r-info[k].r)); //i??????k???
			}
		}
	}

	int limit = pow(2,info_index);


	double minimum = 4000.0;

	for(int start_town = 0; start_town < info_index;start_town++){

		for(int i = 0; i <= info_index; i++){
			for(int k = 0; k < info_index;k++){
				for(int p = 0; p < limit; p++)dp[i][k][p] = 3000.0;
			}
		}

		int next_state;

		next_state = pow(2,start_town);

		dp[0][start_town][next_state] = info[start_town].r;

		for(int i = 1; i <= info_index; i++){ //?????°????????????
			for(int k = 0; k < info_index; k++){ //???????????????
				for(int state = 0; state < limit; state++){ //??¶???????????????
					if(dp[i-1][k][state] < 2000.0){
						for(int a = 0; a < info_index; a++){
							if(state & (1 << a)){ //???a?????¢????????£???????????´???
								if(i == info_index && a == start_town && state == limit-1){
									dp[i][start_town][limit-1] = min(dp[i][start_town][limit-1],dp[i-1][k][state]+info[k].r);
								}
							}else{
								next_state = state + pow(2,a);
								dp[i][a][next_state] = min(dp[i][a][next_state],dp[i-1][k][state]+distance[k][a]);
							}
						}
					}
				}
			}
		}

		minimum = min(minimum,dp[info_index][start_town][limit-1]);

	}

	if(minimum < length || fabs(minimum-length) < EPS){
		printf("OK\n");
	}else{
		printf("NA\n");
	}

}

int main(){

	dp = new double**[13];

	for(int i = 0; i < 13; i++){
		dp[i] = new double*[12];
		for(int k = 0; k < 12; k++){
			dp[i][k] = new double[4096];
		}
	}


	char buf[300];
	int index;
	char ch;

	while(true){
		index = 0;
		ch = getchar();

		if(ch == '\n' || ch == '\0' || ch == EOF)break;
		//if(ch == EOF)break;

		while(ch != '\n' && ch != '\0' && ch != EOF){
			buf[index++] = ch;
			ch = getchar();
		}
		buf[index] = '\0';
		func(buf);
	}

	return 0;
}

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

int main(){
    int_fast64_t N;
    scanf("%lld", &N);
    set<int_fast64_t> s;
    int_fast64_t ans(0);
    for(int_fast64_t i = 0, a; i < N; ++i){
        scanf("%lld", &a);
        if(a > 3199){
            ++ans;
        }else{
            s.insert(a / 400);
        }
    }
    cout << max<int_fast64_t>(1, s.size()) << " " << ans + s.size() << endl;
    return 0;
}

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

const int mn=2e5+6;
int pos[mn],a[mn],n,k;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<=k;++i) {
		memset(pos,0,sizeof pos);
		for(int j=1;j<=n;++j) {
			pos[max(1,j-a[j])]++;
			pos[min(n+1,j+a[j]+1)]--;
		}
		for(int j=1;j<=n;++j) pos[j]+=pos[j-1],a[j]=pos[j];
		int c=0;
		for(int j=1;j<=n;++j) if(a[j]==n) c++;
		if(c==n) break;
	}
	for(int i=1;i<=n;++i) printf("%d ",a[i]);
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int a, b;
    cin >> a >> b;
    if(a > b) {
        cout << a - 1 << endl;
    } else {
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h <= 0:
        break
    h -= bi
    ans += 1
mod = (h + amax - 1) // amax
print(ans + mod if h > 0 else ans)


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;

    for (size_t i = 0; i < N-2; i++)
    {
        if(S.substr(i,3) == "ABC"){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
# ABC080 D - Recording
N,C = map(int,input().split())
T = [[0 for _ in range(C)] for j in range(100001)]
for i in range(N):
    s,t,c = map(int,input().split())
    for j in range(s-1,t):
        T[j][c-1] = 1
ans = 0
for i in range(100001):
    sumT = sum(T[i])
    if ans < sumT:
        ans = sumT
print(ans)

Measured memory_bytes: 40308
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin>>s;
  	int n;
  	n=s.size();
  	vector<char>vec1(0);
  	vector<char>vec2(0);
  	vector<char>vec3(0);
  	vector<char>vec4(0);
  	int count1=0;
      
  	for(int i=0;i<(n-1)/2;i++){
    	vec1.push_back(s[i]);
      	vec2.push_back(s[i]);
    }
  	reverse(vec2.begin(),vec2.end());
  	for(int i=0;i<vec1.size();i++){
    	if(vec1[i]!=vec2[i]){
        	break;
        }
      	count1 ++;
    }
  	int count2=0;
  	for(int i=((n+3)/2)-1;i<n;i++){
    	vec3.push_back(s[i]);
      	vec4.push_back(s[i]);
    }
  	reverse(vec4.begin(),vec4.end());
  	for(int i=0;i<vec3.size();i++){
    	if(vec1[i]!=vec2[i]){
        	break;
        }
      	count2 ++;
    }
  	int count3=0;
  	for(int i=0;i<vec3.size();i++){
    	if(vec1[i]!=vec3[i]){
        	break;
        }
      	count3 ++;
    }
  	if(count1==vec1.size()&&count2==vec1.size()&&count3==vec1.size()){
    	cout<<"Yes"<<endl;
    }
  	else{
    	cout<<"No"<<endl;
    }

}

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

#define pb push_back
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define clr(v) v.clear()
vector<ll>v;
pair<ll,ll>p;
map<ll,ll>mp;
set<ll>st;
deque<ll>dq;
priority_queue<ll>pq;
#define f(i,b) for(i=0;i<b;i++)
#define f1(i,b) for(i=1;i<=b;i++)
#define fr(i,b)for(i=b-1;i>=0;i--)
ll mn=INT_MAX,mx=INT_MIN;
ll n,m,tc,i,j,tmp,sum,cn,ans,res,pos,flag;

string s;


ll a[200007],b[200007];
int main()
{

   io;

cin>>n;
while(n>=1000)
{
    n-=1000;
}
cout<<(1000-n)%1000<<endl;

return 0;
}





Measured memory_bytes: 3644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  ll money = 1000;
  ll stock = 0;
  int start = 0;
  while (A[start] == A[start+1]) {
    if (start + 1 == N - 1) break;
    start++;
  }
  int before = A[start];
  if (before < A[start+1]) {
    stock += money/A[0];
    money %= A[0];
  }
  for (int i=start+1; i<N-1; i++) {
    if (before < A[i] && A[i] > A[i+1]) {
      money += stock*A[i];
      stock = 0;
    } else if (before > A[i] && A[i] < A[i+1]) {
      stock += money/A[i];
      money %= A[i];
    }
    if (A[i] != A[i+1]) before = A[i];
  }
  money += stock*A[N-1];
  cout << money << endl;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var rs = Enumerable.Range(0, h[1]).Select(i => read()).Select(r => new R { A = r[0], B = r[1], C = r[2] - h[2] }).ToArray();
		map = rs.GroupBy(r => r.A).ToDictionary(g => g.Key, g => g.ToArray());
		ups = new HashSet<int>();

		var cs = Enumerable.Repeat(long.MinValue, h[0] + 1).ToArray();
		cs[1] = 0;
		long c;
		for (var i = 0; i < h[0]; i++)
			foreach (var r in rs)
				if (cs[r.A] != long.MinValue && cs[r.B] < (c = cs[r.A] + r.C)) cs[r.B] = c;

		foreach (var r in rs)
		{
			if (ups.Contains(r.B) || cs[r.A] == long.MinValue || cs[r.B] >= cs[r.A] + r.C) continue;
			FindPath(r.B);
			if (ups.Contains(h[0])) { Console.WriteLine(-1); return; }
		}
		Console.WriteLine(Math.Max(cs[h[0]], 0));
	}

	static Dictionary<int, R[]> map;
	static HashSet<int> ups;

	static void FindPath(int p)
	{
		if (ups.Add(p) && map.ContainsKey(p)) foreach (var r in map[p]) FindPath(r.B);
	}
}

struct R
{
	public int A, B, C;
}


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

int main() {
  int N, K, num;
  cin >> N >> K;
  num = 1;
  for (int i=0; i < N; i++) {
    if (num < K) {
      num *= 2;
    }
    else {
      num += K;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

#define INF 1e+9
#define MAX_V 2000

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int dd[2000];

int main()
{
  int n, x, y;
  scanf("%d %d %d", &n, &x, &y);
  V = n;

  for (int i=0; i<n-1; ++i) {
      edge e = {i+1, 1};
      G[i].push_back(e);
      edge e2 = {i, 1};
      G[i+1].push_back(e2);
  }
  edge e = {y-1, 1};
  G[x-1].push_back(e);
  edge e2 = {x-1, 1};
  G[y-1].push_back(e2);

  for (int j = 0; j < n; j++) {
    dijkstra(j);
    for (int i = 0; i < n; ++i) {
        if(i != j && d[i] != INF)
            dd[d[i]]++;
            // cout << "0から" << i << "までのコスト: " << d[i] << endl;
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    printf("%d\n", dd[i]/2);
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define input_output freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)

using namespace std;

int main()
{
	//input_output;
	the_flash;
	string s, t;
	cin >> s >> t;
	int count = 0, len = s.length();
	
	for (int i = 0; i < len; i++)
	{
		if (s[i] != t[i])
			count++;
	}
	
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3780
x,y = map(int,input().split())
import fractions
g = fractions.gcd(x,y)
if x == y:
    print(-1)
elif y == 1:
    print(-1)
elif x > y and y == g:
    print(-1)
elif x < y:
    print(x)
elif x % y == 0:
    print(-1)
else:
    print(x)

Measured memory_bytes: 63980
#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 MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


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

  map<char, int> mp;
  REP(i,s.size()){
    mp[s[i]]++;
  }
  cout << (mp.size() == s.size() ? "yes" : "no") << endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
int main()
{
int N, p[100000], cnt = 0;
bool pc[100000];
cin >> N;
for(int i = 1; i <= N; i++) cin >> p[i];
for(int i = 1; i <= N; i++){
if(p[i] == i){
pc[i] = false;
}else{
pc[i] = true;
}
if(pc[i] == false) swap(p[i], p[i + 1]), cnt++;
}
cout << cnt << endl;
return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<iomanip>
#include <math.h>
#include<algorithm>
#include<vector>
using namespace std;

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

	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0) {
				if (a[i] % 5 != 0)count++;
			}
		}
		if (count > 0)break;
	}

	if (count == 0)cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}

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

int main(){
  int n;cin >> n;
  map<string,int> m;
  int cnt = 0;
  for(int i=0;i<n;i++){
    string s;cin >> s;
    m[s]++;
    if(m[s]==1) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 19224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int sum=1, a=1, b=1;
  
  for(int i=0; i<N; i++){
    a *= 2;
    b += K;
    if(a > b)
      sum = b;
    else
      sum = a;
    
    a=sum;
    b=sum;
  }
  cout << sum << endl;
}

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

tot = sum(A)
half = tot / 2
res = 0
s, t = A[0], sum(A[1:])
min_v = abs(s - t)

for a in A[1:-1]:

    s += a
    tmp = abs(tot - 2 * s)
    if tmp < min_v:
        min_v = tmp

print(min_v)


Measured memory_bytes: 24832
#include <stdio.h>
#include <iostream> 
using namespace std;
const int maxn=105;
int odd[maxn],even[maxn];
long long n;
int main(){
    int i,num=1;
    scanf("%lld",&n);n++;
    while(n>1){
        if(n&1)odd[++odd[0]]=num++,n--;
        else even[++even[0]]=num++,n/=2;
    }
    printf("%d\n",odd[0]+even[0]<<1);
    for(i=1;i<=odd[0];i++)printf("%d ",odd[i]);
    for(i=even[0];i>=1;i--)printf("%d ",even[i]);
    for(i=odd[0]+even[0];i>=1;i--)printf("%d ",i);
    return 0;
}

Measured memory_bytes: 256
import copy

def can_empty(A,y,x):
    A[y][x],A[y][x+1] = A[y][x+1],A[y][x]
    num = sum(W-a.count(".") for a in A)
    while 1:
        # Fall processing
        for w in xrange(W):
            seq = ("".join(A[h][w] for h in xrange(H))).replace(".","")
            seq += "."*(H-len(seq))
            for h in xrange(H):
                A[h][w] = seq[h]

        # Banish processing
        B = [[0]*W for _ in xrange(H)]
        for h in xrange(H):
            cnt = 1
            for w in xrange(1,W):
                if A[h][w] == A[h][w-1]: cnt += 1
                else:
                    if cnt >= n and A[h][w-1] != ".":
                        for wi in xrange(w-cnt,w): B[h][wi] = 1
                    cnt = 1
            if cnt >= n and A[h][W-1] != ".":
                for wi in xrange(W-cnt,W): B[h][wi] = 1
        for w in xrange(W):
            cnt = 1
            for h in xrange(1,H):
                if A[h][w] == A[h-1][w]: cnt += 1
                else:
                    if cnt >= n and A[h-1][w] != ".":
                        for hi in xrange(h-cnt,h): B[hi][w] = 1
                    cnt = 1
            if cnt >= n and A[H-1][w] != ".":
                for hi in xrange(H-cnt,H): B[hi][w] = 1

        banish = False
        for h in xrange(H):
            for w in xrange(W):
                if B[h][w]:
                    A[h][w] = "."
                    num -= 1
                    banish = True
        if not banish: return False
        if num == 0: return True
        

# Entry point
H,W,n = map(int,raw_input().split())
A = [list(raw_input()) for _ in xrange(H)][::-1]
goal = [["."]*W for _ in xrange(H)]
ans = False
for h in xrange(H):
    for w in xrange(W-1):
        if A[h][w] == A[h][w+1]: continue
        if can_empty(copy.deepcopy(A),h,w):
            ans = True
            break
    if ans: break
print "YES" if ans else "NO"

Measured memory_bytes: 4456
from collections import defaultdict

n = int(input())
S = []
d_list = []
strdict = {}

for i in range(n):
    s = input()
    S.append(s)
    if i == 0:
        for n in s:
            if n in strdict:
                strdict[n] += 1
            else:
                strdict[n] = 1
    else:
        d = defaultdict(int)
        for n in s:
            d[n] += 1
        for k in strdict:
            strdict[k] = min(strdict[k], d[k])

key = strdict.keys()
key = sorted(key)
ans = ''
for k in key:
    ans += k * strdict[k]
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N), B(N);
  rep(i, N) cin >> A[i] >> B[i];
  ll mx = 0;
  rep(i, N) if((K|A[i]) == K) mx += B[i];
  rep(k, 30) {
    if(K&1LL<<k) {
      ll tmp = ((K>>k)<<k)-1;
      ll tmpMx = 0;
      rep(i, N) if((tmp|A[i]) == tmp) tmpMx += B[i];
      mx = max(tmpMx, mx);
    }
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.io.*;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");
    int n = Integer.parseInt(in[0]);
    int k = Integer.parseInt(in[1]);

    br.close();

    System.out.println((n+1) / 2 >= k ? "YES" : "NO");
    
  }
}

Measured memory_bytes: 21076
#include <iostream>
#include <string>

using namespace std;

int main(){
	int N;
	bool flag = false;

	cin >> N;

	int div_num, dived_num, add_num;

	for(div_num = 1; div_num < 10; div_num++){
		dived_num = N / div_num;
		add_num = N % div_num;

		if((dived_num < 10) && (add_num == 0)){
			flag = true;
			break;
		}
	}

	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

C, Ci = [-1] * (N - 1) + [A[0]], N - 1


for i in range(1, N):
    bA = bisect.bisect_left(C, A[i])
    if bA == Ci:
        Ci -= 1
        C[Ci] = A[i]
    else:
        C[bA - 1] = A[i]

print(N - Ci)


Measured memory_bytes: 8732
N = int(input())
ans = 0
prior = 0
for i in range(N):
  a = int(input())
  if i == 0 and a != 0:
    ans = -1
    break
  if a == 0:
    prior = a
  elif a == 1:
    prior = a
    ans += 1
  elif a == prior + 1:
    ans += 1
    prior = a
  elif a <= prior:
    ans += a
    prior = a
  else:
    ans = -1
    break
print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
//#define double long double
using namespace std; const int N=2000010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int x,y;
signed main()
{
    x=read(), y=read();
    if(y&1ll) { puts("No"); return 0; }
    if(y>x*4 || y< x*2) { puts("No"); }
    else puts("Yes");
    return 0;
}

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

int	lcs(const string &X, const string &Y)
{
	int	len_X = X.size(), len_Y = Y.size();
	int	len_lcs[1001][1001] = {};
	for (int i = 0; i < len_X; ++i) {
		for (int j = 0; j < len_Y; ++j) {
			int	prev_X = len_lcs[i][j + 1];
			int	prev_Y = len_lcs[i + 1][j];
			int	prev = max(prev_X, prev_Y);	
			if (X.at(i) == Y.at(j)) {
				len_lcs[i + 1][j + 1] = max(len_lcs[i][j] + 1, prev);
			} else {
				len_lcs[i + 1][j + 1] = prev;
			}
		}
	}
	return len_lcs[len_X][len_Y];
}

int	main()
{
	int	q;
	cin >> q;
	string	X, Y;
	for (int i = 0; i < q; ++i) {
		cin >> X >> Y;
		cout << lcs(X, Y) << endl;
	}
}



Measured memory_bytes: 7096
#include <iostream>
#include <vector>
#define int long long
using namespace std;

int color[100000];
vector<int> G[100000];

bool dfs(int v){
	bool flag = true;
	for(int to : G[v]){
		if(color[to] != -1){
			if(color[to] == color[v]) flag = false;
			continue;
		}
		color[to] = (color[v] + 1) % 2;
		if(!dfs(to)) flag = false;
	}
	return flag;
}

signed main(){
	int n,m,one = 0,two = 0,point = 0;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i = 0;i < n;i++) color[i] = -1;
	for(int i = 0;i < n;i++){
		if(color[i] == -1){
			color[i] = 0;
			if(!G[i].size()) point++;
			else if(dfs(i)) two++;
			else one++;
		}
	}
	cout << one * (one + two * 2) + two * two * 2 + point * n * 2 - point * point << endl;
	return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

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

	int n, x, y;
	cin >> n >> x >> y;

	--x;
	--y;
	int* ans = new int[n];
	memset(ans, 0, sizeof(int)*n);
	rep(i, n - 1) {
		REP(j, i + 1, n) {
			int length = j - i;
			length = min(length, abs(x - i) + abs(j - y) + 1);

			++ans[length];
		}
	}

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

	return 0; 
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char c[5];
  scanf("%s",c);
  if(c[1]==c[2]){
    if(c[0]==c[1] || c[2]==c[3]){
      printf("Yes");
    }
    else printf("No");
  }
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
ans=1
if A.count(0) >= 1:
  print(0)
else:
  B=[i for i in A if i != 1]
  if len(B) >= 100:
    print("-1")
  else:
    for k in range(len(B)):
      ans=ans*B[k]
    if ans > 1000000000000000000:
      print("-1")
    else:
      print(ans)

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

int res = 0;
vector<int> colors;
vector<vector<pair<int,int>>> g;

void dfs(int v, int p, int pc) {
    int c = 0;
    for (auto e : g[v]) {
        if (e.first == p) {
            continue;
        }
        c++;
        if (pc == c) c++;
        colors[e.second] = c;
        dfs(e.first, v, c);
    }
    res = max(res,c);
}

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

    int n;
    cin >> n;

    colors.resize(n - 1);
    g.resize(n + 1);
    for(int i = 0; i < n - 1; i++){
        int a,b;
        cin >> a >> b;
        g[a].push_back({b,i});
        g[b].push_back({a,i});
    }
    dfs(1, -1, -1);
    cout << res << endl;
    for(int i = 0; i < n - 1; i++) {
        cout << colors[i] << endl;
    }
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

int main(){
    int N; cin >> N;
    vector<int> A(N+1), B(N);
    for(int i = 0; i < N+1; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    ll ans = 0;
    for(int i = 0; i < N; i++){
        if(A[i] < B[i]){
            B[i] -= A[i];
            ans += A[i];
            A[i] = 0;
            if(A[i+1] < B[i]){
                ans += A[i+1];
                A[i+1] = 0;
                
            }
            else {
                ans += B[i];
                A[i+1] -= B[i];
            }
        }
        else{
            ans += B[i];
            A[i] -= B[i];
        }
        //cout << A[i] << " " << A[i+1] << " " << B[i] << " "<<ans << endl;
    }
    cout << ans << endl;

}

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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int n;
   cin >> n;
   vector<int> v;
   for (int i = 0; i < n;i++) {
      int x;
      cin >> x;
      v.push_back(x);
   }

   for (int i = 0;  ; i++) {
      for (int j = 0; j < n; j++) {
         if (v[j] & 1) {
            cout << i << endl;
            return 0;
         }
         v[j] = (v[j] >> 1);
      }
   }



   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<tuple>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i=0;i<(int)n;i++)
#define REPS(i, n) for(int i=1;i<=(int)n;i++)
#define RREP(i, n) for(int i=n-1;i>=0;i--)
#define RREPS(i, n) for(int i=n;i>0;i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define pb push_back
#define eb emplace_back
#define endl '\n'
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int n;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	while(cin >> n, n){
		vi deg(n), p(n);
		vector<vector<pii>> g(n);
		REPS(i, n-1){
			cin >> p[i]; p[i]--;
			deg[p[i]] ++; deg[i] ++;
		}
		int ans = 0;
		REPS(i, n-1){
			int d; cin >> d;
			g[i].eb(p[i], d);
			g[p[i]].eb(i, d);
			if(deg[i] == 1 || deg[p[i]] == 1) ans += d;
			else ans += 3*d;
		}
		int ans2 = ans;
		REP(i, n)if(deg[i] != 1){
			queue<tuple<int, int, int>> q;
			q.emplace(i, 0, -1);
			while(!q.empty()){
				int u, d, p; tie(u, d, p) = q.front(); q.pop();
				if(deg[u] != 1) ans2 = min(ans2, ans - d);
				for(pii e : g[u])if(e.first != p)
					q.emplace(e.first, d + e.second, u);
			}
		}
		cout << ans2 << endl;
	}
}

Measured memory_bytes: 1292
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
using namespace std;

int main(void){
    int r=0, w, cnt=0;
    cin >> w;
    string s;
    cin >> s;
    w -= 1;
    while(r<w){
        if(s[r]=='R'){ r++; continue; }
        if(s[w]=='W'){ w--; continue; }
        cnt++;
        r++; w--;
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
using namespace std;
int main()
{
	int h,i,j,k,a, b,c,d, hiroshi, kenjiro, H, I, J, K;
	cin >> h;
	cin >> i;
	cin >> j;
	cin >> k; 
	cin >> a;
	cin >> b;
	cin >> c;
	d;
	H = (h / 10) * c;
	I = (i / 20) * d;
	J = (j/ 10) * c;
	K = (k / 20) * d;
	hiroshi = h*a + i*b + H + I;
	kenjiro = j*a + k*b + J + K;
	if (hiroshi > kenjiro)cout << "hiroshi" << endl;
	else if (hiroshi < kenjiro)cout << "kenjiro" << endl;
	else cout << "even" << endl;
	return 0;
}


Measured memory_bytes: 3104
import sys
input = sys.stdin.readline

# class UnionFind():
#     def __init__(self, n):
#         self.parents = [-1] * n

#     def find(self, x):
#         if self.parents[x] < 0:
#             return x
#         else:
#             self.parents[x] = self.find(self.parents[x])
#             return self.parents[x]

#     def union(self, x, y):
#         x = self.find(x)
#         y = self.find(y)

#         if x == y:
#             return

#         if self.parents[x] > self.parents[y]:
#             x, y = y, x

#         self.parents[x] += self.parents[y]
#         self.parents[y] = x

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

memo = [0 for i in range(n)]

for a, b in ab:
    memo[a-1] = max(memo[a-1], h[b-1])
    memo[b-1] = max(memo[b-1], h[a-1])

ans = 0
for memoi, hi in zip(memo, h):
    if hi > memoi:
        ans += 1

print(ans)



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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  if(n <= 999) cout << "ABC" << endl;
  else cout << "ABD" << endl; 

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int n ;
    cin>>n;
    int a[50][26+5] ,m[50+5];
    memset(a,0,sizeof(a));
    for(int i = 0 ; i < 26 ; i++)
    m[i] = 500;
    for(int i = 0 ;  i < n ;i++){
        char s[50+5];
        cin>>s; 
        for(int j = 0 ; j < strlen(s) ; j++){
            a[i][s[j]-'a']++;
        }
    }
   /* for(int i = 0 ; i < n ; i++){
    	for(int j = 0 ; j < 26 ; j++){
    		cout<<a[i][j];
		}
		cout<<endl;
	} */
    for(int i = 0 ; i < n ;i++ ){
        for(int j = 0 ; j < 26 ; j++){
            if(a[i][j]<m[j])
                m[j] = a[i][j];
        }
    }
    int sum = 0;
    for(int i = 0 ; i < 26 ;i++){
        if(m[i]>0){
        	//cout<<m[i];
        	sum++;
		}
            
    }
    //cout<<sum<<endl;
    if(sum==0){
    	cout<<endl;
	}
    else{
        for(int i = 0 ; i < 26 ;i++){
            for(int j = 0 ; j < m[i] ; j++){
                printf("%c",i+'a');
            }
        }
        cout<<endl;
    }
    return 0;
}


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


int main(){

  string w,ans;
  cin>>w;
  sort(w.begin(),w.end());
  ans = "Yes";
  int count = 1;
  if(w.size()==1){ans="No";}
  else{
  for(int i= 1;i<w.size();i++){
      if(w.at(i)==w.at(i-1)){
        count++;
        if(i==w.size()-1){
          if(count%2==1)ans="No";
        }
      }else{
        if(count%2==1){
          ans = "No";
          break;
        }
        count=1;
      }
  }
  }
  cout<<ans<<endl;

}


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

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

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll K;
    cin >> K;

    ll ans = 0;
    for (ll a = 1; a <= K; a++) {
        for (ll b = 1; b <= K; b++) {
            ll t = gcd(a, b);
            for (ll c = 1; c <= K; c++) {
                ans += gcd(t, c);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

map<ll, ll> prime_factor(ll n){
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++){
    while (n % i == 0){
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

bool is_prime(ll x){
    if(x<=1) return false;
    for(ll i = 2; i*i <= x; i++){
        if(x % i == 0) return false;
    }
    return true;
}

int main() {
  ll n;
  cin >> n;
  map<ll, ll> pf = prime_factor(n);
  int ans = 0;
  for (auto z : pf) {
    ll a = z.first, b = z.second;
    if (!is_prime(a)) continue;
    int cnt = 1;
    while (b > 0) {
      if (b < cnt) break;
      b -= cnt;
      cnt++;
      ans++;
    }
  } 
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;

//Five Variables
int main() {

	int x, ans;
	for (int i = 0;i<5; i++) {
		cin >> x;

		if (x == 0) {
			ans = i + 1;
		}

	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 3620
// In The Name Of Allah

#include <bits/stdc++.h>
using namespace std;

#define int long long

const int inf = 1e18;
const int maxx = 1e5 + 19;

int n, a[maxx], b[maxx], c[maxx];
int ans = 0, cnt = 0;

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = 0; i < n; i++)
        c[i] = a[i] - b[i];
    sort(c, c + n);
    for (int i = 0; i < n; i++)
        if (c[i] < 0)
            ans += c[i], cnt++;
    sort(c, c + n, greater<int>());
    for (int i = 0; i < n; i++) {
        if (ans < 0 && c[i] > 0)
            ans += c[i], cnt++;
        else
            break;
    }
    if (ans < 0)
        return cout << -1, 0;
    cout << cnt;
    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    cin.tie(0);
    ll a, b, k;
    cin >> a >> b >> k;
    
    ll x, y;

    if (k >= a)
    {
        x = 0;
        k -= a;
        if (k >= b)
            y = 0;
        else
            y = b - k;
        
    }
    else
    {
        x = a - k;
        y = b;
    }
    
    
    cout << x << " " << y << "\n";
}

Measured memory_bytes: 256
# include<iostream>
# include<cstdlib>
using namespace std;
int main(){
    int N;
    cin >> N;
    int res = N;
    for(int i = 0; i <= N; i++){
        int c = 0;
        int t = i;
        while(t > 0){
            c += t % 6;
            t /= 6;
        }
        t = N - i;
        while(t > 0){
            c += t % 9;
            t /= 9;
        }
        if(res > c){
            res = c;
            // 最悪1円N回払えばいい．resの初期値はN.
        }
    }
    cout << res << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<int>> data(30, vector<int>(30,0));
  rep(i,h)rep(j,w){ char c; cin >> c; data[i][j] = c-'0'; }

  ll ans=0;
  rep(x,h)rep(y,w){
    auto c = data;
    c[x][y] = 0;
    ll base = 0, res = 0;
    while(1){
      ll tmp = 0;
      rep(i,h){
        int st=0;
        rep(j,w+1){
          if(j==w || (j>0 && c[i][j-1]!=c[i][j])){
            if(j-st>=k){ for(int p=st; p<j; p++){ tmp+=c[i][p]; c[i][p]=0; } }
            st = j;
          }
        }
      }
      if(base!=0 && tmp==0) break;
      res += base*tmp;
      base = (base>0?base*2:1);

      rep(j,w){
        int pos = h-1;
        for(int i=h-1; i>=0; i--){
          if(c[i][j]!=0){
            c[pos][j] = c[i][j];
            if(pos!=i) c[i][j] = 0;
            pos--;
          }
        }
      }
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int A,B,C,K,count=0,operation;
	cin>>A>>B>>C;
	cin>>K;
	for(int i=0; i<K;i++){
		if(B<=A){
			B=2*B;
			count++;
		}else{break;}
		operation++;
	}
	for(int i=operation;i<K;i++){
		if(C<=B){
			C=2*C;
			count++;

		}else{
			break;
		}
	}
	if(A<B and B<C){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
 
using namespace std;
 
typedef pair<int,int> P;
typedef long long ll;

const int  SIZE = 200005;
const ll INF = 1e18 + 10;

struct Key {
  int cost;
  int m = 0;
  Key(int cost) : cost(cost) {}
};

int N, M;
int a, b, c;
ll dp[5005][5005];

int main() {
    cin >> N >> M;
    vector<Key> keys;
    rep(i,M) {
      cin >> a >> b;
      keys.emplace_back(a);
      rep(i,b) {
        cin >> c;
        c--;
        keys.back().m |= (1 << c);
      }
    }
    rep(i,5005) rep(j,5005) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,M+1) rep(j,1<<N) {
      if (dp[i][j] == INF) continue;
      dp[i + 1][j] = min(dp[i+1][j], dp[i][j]);
      dp[i+1][j | keys[i].m] = min(dp[i+1][j | keys[i].m], dp[i][j] + keys[i].cost);
    }
    if (dp[M][(1<<N)-1] == INF) {
      cout << -1 << endl;
      return 0;
    }
    cout << dp[M][(1<<N)-1] << endl;
}

Measured memory_bytes: 198892
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Linq;
using System.Numerics;
using System.Text.RegularExpressions;

class Program
{
    static long[] ReadLongs()
        => Console.ReadLine()
            .Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(s => long.Parse(s))
            .ToArray();

    static void Main(string[] args)
    {
        try
        {
            Console.ReadLine();
            var values = ReadLongs().ToList();
            values.Sort();
            if (values[0] == 0)
            {
                Console.WriteLine(0);
                return;
            }
            long result = 1;
            foreach (var val in values)
            {
                checked
                {
                    result *= val;
                }
                if (result > 1000000000000000000)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            Console.WriteLine(result);
            return;
        }
        catch
        {
            Console.WriteLine(-1);
            return;
        }
    }
}

Measured memory_bytes: 43504
#include<bits/stdc++.h>
using namespace std;
typedef deque<int>D;
int main(void){
	int q;
	int n,d,x;
	int i;
	D d1;
	cin>>q;
	for(i=0;i<q;i++){
		cin>>n;
		if(n==0){
			cin>>d;
			cin>>x;
			if(d==0){
				d1.push_front(x);
			}
			else{
				d1.push_back(x);
			}
		}
		else if(n==1){
			cin>>x;
			cout<<d1[x]<<endl;
		}
		else{
			cin>>d;
			if(d==0){
				d1.pop_front();
			}
			else{
				d1.pop_back();
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
long long int dp[2][3001][3001];
long long int v[2][3001][3001];
long long int n;
long long int a[3001];
long long int solve(long long int player,long long int s,long long int e)
{
 if(s>e)
 return 0;
 if(v[player][s][e]!=0)
 return dp[player][s][e];
 v[player][s][e]=1;
 if(player==0)
 return dp[player][s][e]=max(solve(1,s+1,e)+a[s],solve(1,s,e-1)+a[e]);
 else
 return dp[player][s][e]=min(solve(0,s+1,e)-a[s],solve(0,s,e-1)-a[e]);
}
int main()
{
    long long int i,j,k;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    cout<<solve(0,0,n-1);
}

Measured memory_bytes: 281088
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    string ans = "ABC";
    if (S == "ABC") ans = "ARC";
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    ll a;cin>>a;
    ll t=1;
    ll ans=0;
    while(a!=0){
        ans+=t;
        a/=2;
        t*=2;
    }
    
    cout<<ans;
    return 0;
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  int cnt=0;
  int cntt=0;
  while (c>0){
    c-=b;
    cnt++;
  }
  while (a>0){
    a-=d;
    cntt++;
  }
  if (cnt<=cntt) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 3640
using System;
using System.Linq;
using System.Collections.Generic;

public static class P {
    public static void Main() {
        int[]a=new int[5];
        for(int i=0;i<5;i++){
            a[i]=int.Parse(Console.ReadLine());
        }
        int sum=0;
        int max=0;
        for(int i=0;i<5;i++){
            int now=(a[i]+9)/10*10;
            sum+=now;
            max=Math.Max(max, now-a[i]);
        }
        Console.WriteLine(sum-max);
    }
}


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

int main() {
  string str;
  cin >> str;
  
  vector<char> vec1(str.size());
  vector<char> vec2(1);
  
  for (int i=0; i<str.size(); i++){
    vec1.at(i) = str.at(i);
  }
  
  bool kara = true;
  
  for (int i=0; i<str.size(); i++){
    if (kara){
      if (vec1.at(i)=='0' || vec1.at(i)=='1'){
        kara = false;
        vec2.at(0) = vec1.at(i);
        continue;
      }
    } 
    else{
      if(vec1.at(i)=='0' || vec1.at(i)=='1'){
        vec2.push_back(vec1.at(i));
      }
      else if (vec2.size()!=1) {
        vec2.pop_back();
      }
      else{
        kara = true;
      }
    }
  }
  
  for (int i=0; i<vec2.size(); i++){
    cout << vec2.at(i);
  }
  
  cout << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Map<Integer, Integer> map = new HashMap<>();

		for (int i = 1; i <= n; i++) {
			map.put(i, scanner.nextInt());
		}

		int tmp = 1;
		int ans = 0;
		for (int i = 1; i <= n + 1; i++) {
			ans++;
			tmp = map.get(tmp);
			if (tmp == 2) {
				break;
			}
			if (ans == n + 1) {
				ans = -1;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 67356
import math

tmp = input().split()
A = int(tmp[0])
B = int(tmp[1])
eight_list = []
ten_list = []
eight_min = math.ceil(A/0.08)
ten_min = math.ceil(B/0.10)
eight_list.append(eight_min)
ten_list.append(ten_min)

eight_min += 1
while(math.floor(eight_min*0.08)==A):
    eight_list.append(eight_min)
    eight_min += 1

ten_min += 1
while(math.floor(ten_min*0.10)==B):
    ten_list.append(ten_min)
    ten_min += 1

#print(eight_list)
#print(ten_list)
try:
    print(min(set(eight_list)&set(ten_list)))
except ValueError:
    print(-1)

Measured memory_bytes: 3064