akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	
	private static BufferedReader br;
	private static StringTokenizer tokenizer;
	public static String next() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null)
                throw new IOException();
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    } 
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    } 
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    } 
    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    
	public static void main(String[] args) throws IOException {		
		
		br = new BufferedReader(new InputStreamReader(System.in));
		int h = nextInt();
		int n = nextInt();
		while(n-->0) {
			h -= nextInt();
		}
		if(h>0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}






















Measured memory_bytes: 32396
#include <algorithm>
#include <iostream>
#include <cstdint>

int main() {
  int N;
  std::cin >> N;
  std::int64_t sum = 0;
  int max = 0;
  for (int i = 0; i < N; ++i) {
    int A;
    std::cin >> A;
    sum += std::max(0, max - A);
    max = std::max(max, A);
  }
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ll = long long;
using ii = pair<ll, ll>;

int32_t main(){
	ios::sync_with_stdio(0);
	int n, x, t;
	cin >> n >> x >> t;
	int tot = 0;
	int ans = 0;
	while(tot<n){
		ans += t;
		tot += x;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3648
#include<stdio.h>

int main(void){
	int a, b, op;
	while(1){
		scanf("%d", &a);
		getchar();
		op = getchar();
		scanf("%d", &b);
		if(op == '?') break;
		if(op == '+') printf("%d\n", a+b);
		else if(op == '-') printf("%d\n", a-b);
		else if(op == '*') printf("%d\n", a*b);
		else if(op == '/') printf("%d\n", a/b);
	}
	return 0;
}


Measured memory_bytes: 2052
A = [0] * 5

A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())

maximum = 0
for i in range(5):
  tmp = (A[i] // 10 + 1) * 10 - A[i]
  if tmp == 10:
    tmp = 0
  else:
    A[i] = (A[i] // 10 + 1) * 10
  if tmp > maximum:
    maximum = tmp
    
print(sum(A) - maximum)


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

int main(){
	int n,t;
	cin >> n >> t;
	vector<pair<int,int>> d;
	int a,b;
	rep(i,n){
		cin >> a >> b;
		d.push_back(make_pair(a,b));
	}
	sort(d.begin(),d.end());
	vector<vector<int>> dp1(n+10, vector<int>(t+10));
	for(int i(1);i<=n;++i){
		for(int j(0);j<=t;++j){
			if(t >= d[i-1].first && j - d[i-1].first >= 0){
				dp1[i][j] = max(dp1[i-1][j-d[i-1].first] + d[i-1].second, dp1[i-1][j]);
			}else{
				dp1[i][j] = dp1[i-1][j];
			}
		}
	}
	vector<vector<int>> dp2(n+10, vector<int>(t+10));
	for(int i(n);i>=0;--i){
		for(int j(0);j<=t;++j){
			if(i+1 < n && t >= d[i+1].first && j - d[i+1].first >= 0){
				dp2[i][j] = max(dp2[i+1][j-d[i+1].first] + d[i+1].second, dp2[i+1][j]);
			}else{
				dp2[i][j] = dp2[i+1][j];
			}
		}
	}
	int ans = 0;
	for(int i(1);i<=n;++i){
		for(int j(0);j<=t-1;++j){
			ans = max(ans,dp1[i-1][j] + dp2[i+1][t-j-1] + d[i-1].second);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 71296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] alp = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
				'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
		Main main = new Main();

		if (s.length() % 2 == 0) {
			for (int i = 0; i < alp.length; i++) {
				if (main.strCount(s,alp[i]) % 2 == 1) {
					System.out.println("No");
					break;
				}
				if (i==alp.length - 1) {
					System.out.println("Yes");
				}
			}
		}else {
			System.out.println("No");
		}


	}

	public int strCount(String s,char target) {
		int con=0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == target) {
				con++;
			}
		}
		return con;
	}
}




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

using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n];
	int s=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s^=a[i];
	}
	for(int i=0;i<n;i++){
		cout<<(a[i]^s)<<" ";
	}
}



Measured memory_bytes: 4400
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		ArrayList<Integer> h = new ArrayList<>();

		for (int i=0; i<n; i++){
			h.add(Integer.parseInt(sc.next()));
		}

		int[] dp = new int[n];

		dp[1] = Math.abs(h.get(1) - h.get(0));

		for (int i=2; i<n; i++){
			dp[i] = Math.min(Math.abs(h.get(i) - h.get(i-1)) + dp[i-1], Math.abs(h.get(i) - h.get(i-2)) + dp[i-2]);
		}
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 47684
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

struct Magic
{
    ll a;
    ll b;
};


int main(){

    ll H, N;
    cin >> H >> N;

    vector<Magic> v(N);
    for(int i = 0; i < N; i++) cin >> v[i].a >> v[i].b;

    ll INF = 10000000000; 
    vector<ll> dp(H + 1, INF);

    dp[0] = 0;
    for(ll h = 0; h <= H; h++){
        for(int i = 0; i < N; i++){
            if( h - v[i].a >= 0){
                dp[h] = min( dp[h] , dp[h - v[i].a] + v[i].b );
            }
            else{
                dp[h] = min( dp[h], v[i].b  );
            }
        }
    }

    //for(int i = 0; i <= H; i++) cout << dp[i] << " ";
    //cout << endl;

    cout << dp[H] << endl;

}

Measured memory_bytes: 896
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int ary[10005];
int main() {
    int n;
    int m = 0;
    scanf("%d", &n);

    for (int x = 1; x * x <= n; x++) {
        for (int y = 1; y * y <= n; y++) {
            for (int z = 1; z * z <= n; z++) {
                m = x * x + y * y + z * z + z * x + x * y + y * z;
				if (m <= 10000)
				{
                ary[m]++;
				}
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        printf("%d\n", ary[i]);
    }
    return 0;
}

Measured memory_bytes: 1640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int compare_int(const void *a, const void *b)
{
    return *(long long*)a - *(long long*)b;
}

int min_comp(int min, int a)
{

}
int max_comp(int max, int a)
{
  if(max>a)    return max;
  else    return a;
}


int main()
{
  int N;
  char S[4]={};
  
//  long long N[101]={};
  int i,j;
  int cont=0;
//    int k=0;

  scanf("%s", &S);
//  printf("%c\n", S);
  for(i=0;i<3;i++){
   if(S[i] == 'o') cont++;    
  }
  printf("%d\n", (700 + (100 * cont)));
 
  //  else printf("No\n"); 
return 0;
}


Measured memory_bytes: 128
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a_min = min(A)
b_min = min(B)
ans = a_min + b_min
for _ in range(m):
  x, y, c = map(int, input().split())
  cost = A[x-1] + B[y-1] - c
  if ans > cost:
    ans = cost
print(ans)

Measured memory_bytes: 18736
N = int(input())

M = []

for _ in range(N):
    s, t = input().split()
    M.append((s, int(t)))

X = input()

res = sum(map(lambda m: m[1], M))

for m in M:
    res -= m[1]
    if X == m[0]:
        break

print(res)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int K = scanner.nextInt();

        for (int i = 0; i < K; i++) {
            if (A >= B)
                B = B *2;
            else if (B >= C){
                C = C*2;
            }
        }
        
        if (A < B && B < C){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


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

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi l(n), r(n);
    l[0] = a[0], r[n-1] = a[n-1];
    for (int i=0,j=n-1; i<n-1; ++i,--j) {
        l[i+1] = gcd(l[i], a[i+1]);
        r[j-1] = gcd(r[j], a[j-1]);
    }
    int ans = 0;
    for (int i=0; i<n; ++i) {
        int tmp;
        if (i==0) tmp = r[i+1];
        else if (i==n-1) tmp = l[i-1];
        else tmp = gcd(l[i-1], r[i+1]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
from math import sqrt, floor
A = int(input())
if A < 105:
  print("0")
  exit(0)

Q = 105
ans = 0

while Q <= A and Q <= 200: 
  cnt = 0
  i = 1
  while i <= sqrt(Q):
    if Q % i == 0:
      cnt += 1
    i += 2
    
  #print(Q,cnt)
  if cnt == 4:
    ans += 1
  Q += 2

print(ans)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}



int main(){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  
  cout << max({a*c,a*d,b*c,b*d}) << endl;
  
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define INF LLONG_MAX
typedef long long ll;
struct Point{int x,y,id;};
bool linkx(Point &p1,Point &p2){
	return p1.y==p2.y ? p1.x<p2.x : p1.y<p2.y;
}
bool linky(Point &p1,Point &p2){
	return p1.x==p2.x ? p1.y<p2.y : p1.x<p2.x;
}
typedef pair<ll,int> edge;//cost,id(<2K+2)

int main(void){
	int M,N,K,X,Y;
	cin>>M>>N>>K;
	vector<edge> g[2*(K+1)];
	vector<Point> vp(K+1);
	vector<ll> dp(2*(K+1));
	rep(i,K){
		cin>>X>>Y;
		vp[i]={X,Y,i};
	}
	vp[K]={M,N,K};

	//switch
	rep(i,K){
		g[vp[i].id*2].push_back({1,vp[i].id*2+1});
		g[vp[i].id*2+1].push_back({1,vp[i].id*2});
	}

	//linkx
	sort(all(vp),linkx);
	rep(i,K){
		if(vp[i].y==vp[i+1].y){
			Point p1=vp[i],p2=vp[i+1];
			int cost=abs(p1.x-p2.x);
			g[p1.id*2].push_back({cost,p2.id*2});
			g[p2.id*2].push_back({cost,p1.id*2});
		}
	}

	//linky
	sort(all(vp),linky);
	rep(i,K){
		if(vp[i].x==vp[i+1].x){
			Point p1=vp[i],p2=vp[i+1];
			int cost=abs(p1.y-p2.y);
			g[p1.id*2+1].push_back({cost,p2.id*2+1});
			g[p2.id*2+1].push_back({cost,p1.id*2+1});
		}
	}

	rep(i,2*(K+1))dp[i]=INF;
	priority_queue<edge,vector<edge>,greater<edge>> q;
	if(vp[0].x==1){
		dp[vp[0].id*2+1]=vp[0].y-1;
		q.push({dp[vp[0].id*2+1],vp[0].id*2+1});
	}
	
	while(q.size()){
		edge u=q.top(); q.pop();
		int id=u.second;
		if(id>=2*K){
			cout<<u.first<<endl;
			return 0;
		}
		if(dp[id] < u.first)continue;
		for(auto to:g[id]){
			if(dp[to.second] > dp[id]+to.first){
				dp[to.second] = dp[id]+to.first;
				q.push({dp[to.second],to.second});
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 51872
#include <iostream>
#include <algorithm>

using namespace std;

typedef pair<long, long> P;

int main(){
    long N, M;
    P C[100000];
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        long A, B;
        cin >> A >> B;
        C[i] = P(A, B);
    }
    sort(C, C+N);
    long ans = 0;
    long cnt = 0;
    for(int i = 0; i < N; i++){
        if(M-cnt > C[i].second) {
            cnt += C[i].second;
            ans += C[i].second*C[i].first;
        }else{
            ans += (M-cnt)*C[i].first;
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s;
	cin >> s;
	int n = int(s.size());
	if(n == 2 && s[0] == s[1]) return cout << 1 << ' ' << 2 << '\n', 0; 
	for(int i = 0; i < n - 2; ++i){
		string ac = s.substr(i, 3);
		if(ac[0] == ac[1] || ac[0] == ac[2] || ac[1] == ac[2]){
			return cout << i + 1 << ' ' << i + 3 << '\n', 0;
		}
	}
	cout << -1 << ' ' << -1 << '\n';
	return 0;
}

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

int main()
{
    string s1,s2,i,j;
    cin>>s1>>s2;
    string s3=s2;
    s3.erase(s3.end()-1);
    if(s2.size()>s1.size()){
        if(s1==s3)
            cout<<"Yes";
        else
            cout<<"No";
    }
    else
        cout<<"No";
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L = A + B;
  int R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  } else if (L == R) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

int main(){
    int N,M,r,q,t,n,m,s,i,j,k;
    while(1){
        scanf("%d",&N);
        scanf("%d",&M);
        if(!N && !M){break;}
        scanf("%d",&r);
        vector< vector<int> > datas(N);
        for(i=0;i<r;i++){
            scanf("%d",&t);
            scanf("%d",&n);
            scanf("%d",&m);
            scanf("%d",&s);
            datas[n-1].push_back(t+10000*m);
        }
        int ts,te,mm;
        scanf("%d",&q);
        for(k=0;k<q;k++){
            scanf("%d",&ts);
            scanf("%d",&te);
            scanf("%d",&mm);

            vector<int> cd;
            for(i=0;i<N;i++){
                for(auto itr=datas[i].begin();itr!=datas[i].end();itr++){
                    if(*itr/10000==mm){cd.push_back(*itr%10000);}
                }
            }
            set<int> bset;
            for(i=0;i!=cd.size();i+=2){
                for(j=cd[i];j<=cd[i+1];j++){
                    bset.insert(j);
                }
            }
            int cnt=0,bf=0;
            for(auto itr=bset.begin();itr!=bset.end();++itr){
                if(ts<=*itr&&te>=*itr){
                    if(*itr-bf==1){
                        cnt++;
                    }
                    bf=*itr;
                }
            }
            printf("%d\n",cnt);
        }
    }
    return 0;
}



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

int main ()
{
    int A, B, C;
    scanf(" %d %d %d", &A, &B, &C);

    if(A==B && A!=C && B!=C)
        printf("Yes");
    else if(A==C && A!=B && C!=B)
        printf("Yes");
    else if(B==C && B!=A && C!=A)
        printf("Yes");
    else if(A==B && B==C && A==C)
        printf("No");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define slowanddetermined ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long
using namespace std;


int32_t main()
{

    long long n;
    cin>>n;

    long long ans=(n/500)*1000;
    long long rem=n-ans/2;
    rem=(rem/5)*5;
    ans+=rem;
    cout<<ans;




    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=(int)2e5+5;
char str[MAXN];
int mark[MAXN],dp[(1<<26)+10];
int main()
{
	int n;
	scanf("%s",str+1);
	n=strlen(str+1);
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;i++){
		mark[i]=(mark[i-1]^(1<<(str[i]-'a')));
		for(int j=0;j<26;j++){
			if(dp[mark[i]^(1<<j)]==-1)continue;
			int tmp=dp[mark[i]^(1<<j)]+1;
			if(dp[mark[i]]==-1||dp[mark[i]]>tmp)dp[mark[i]]=tmp;
		}
	}
	dp[0]=1;
	printf("%d\n",dp[mark[n]]);
	return 0;
}

Measured memory_bytes: 263424
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    string s,t;
    cin >> s;
    rep0(i, s.size()){
        if(s[i] != 'x')t += s[i];
    }
    rep0(i, t.size() / 2){
        if(t[i] != t[t.size() - i - 1]){
            pf(-1);
            return 0;
        }
    }
    ll l = 0,r = s.size() - 1,ans = 0;
    while (l < r) {
        if(s[l] != s[r]){
            ++ans;
            if(s[l] == 'x')++l;
            else if(s[r] == 'x')--r;
        }else{
            ++l;
            --r;
        }
    }
    pf(ans);
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	if (s.size() == 2 && s[0] == s[1]) {
		cout << "1 2" << endl;
		return 0;
	}
	int ans = -1;
	for (int i = 0; i < s.size()-2; i++) {
		if (s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2]) {
			ans = i+1;
			break;
		}
	}
	if (ans == -1) cout << "-1 -1" << endl;
	else cout << ans << ' ' << ans+2 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
const int N=1<<19;
int a[N];
vector <int> f[N],v[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void build(int o,int c,int s) {
    f[o].resize(c),v[o].resize(c);
    for(int i=0;i<c;i++) f[o][i]=a[s|i];
    for(int i=0;i<c;i++)
	for(int j=1;j<c;j<<=1)
	    if(i&j) f[o][i]=max(f[o][i],f[o][i^j]);
    if(c==1) return;
    build(o<<1,c>>1,s),build(o<<1|1,c>>1,s|c>>1);
}
inline int solve(int x,int y,int d) {
    int c=1<<d;
    if(!d) return 0;
    if(v[x][y]) return v[x][y];
    int l=x<<1,r=x<<1|1;--d;
    if(y>>d&1) {
	int k=y^1<<d;
	v[x][y]=max(solve(l,(c>>1)-1,d),max(solve(r,k,d),f[l][k]+f[r][k]));
	for(int i=0;i<d;i++) {
	    if(y>>i&1) {
		k^=1<<i;
		v[x][y]=max(v[x][y],f[l][k]+f[r][k]);
	    }
	    k^=1<<i;
	}
    }
    else v[x][y]=solve(l,y,d);
    return v[x][y];
}
int main() {
    int n;
    cin>>n;
    for(int i=0;i<1<<n;i++) a[i]=gi();
    build(1,1<<n,0);
    for(int i=1;i<1<<n;i++)
	printf("%d\n",solve(1,i,n));
    return 0;
}

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

using namespace std;

int main(){

    char s[10];
    vector<char> nova_s;

    cin >> s;
    for(int i=0;i<strlen(s);i++){
        if(s[i]=='0'){
            nova_s.push_back('0');
        }
        if(s[i]=='1'){
           nova_s.push_back('1');
        }
        if((s[i]=='B')&&(!nova_s.empty())){
            nova_s.pop_back();
        }
    }
    int tam = nova_s.size();
    for(int j=0;j<tam;j++){
        cout << nova_s.at(j);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    int n, l;
    cin >> n >> l;
    vi a(n);
    forn(i, n) cin >> a[i];
    forn(i, n - 1){
        if (a[i] + a[i + 1] >= l){
            cout << "Possible\n";
            forn(j, i){
                cout << j + 1 << '\n';
            }
            for (int j = n - 2; j > i; --j){
                cout << j + 1 << '\n';
            }
            cout << i + 1 << '\n';
            return;
        }
    }
    cout << "Impossible\n";
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 2e5 + 100;
char str[maxn];
int a[maxn];
int dp[(1<<26)];

void print(int x)
{
    while(x){
        cout<<x%2;
        x/=2;
    }
    cout<<endl;
}

int main()
{
    cin>>str;
    int L = strlen(str), ans = 0;
    for(int i = 0; i < L; i++){
        ans ^= (1<<(str[i] - 'a'));
        a[i] = ans;
    }
/*    for(int i = 0;i<L;i++){
        cout<<a[i]<<"  -> ";
        print(a[i]);
    }
*/

    memset(dp, 1, sizeof(dp));
    for(int i = 0; i < L; i++){
        int ok = 0;
        for(int j = 0; j < 26; j++) if(a[i] == 0 || (a[i]^(1<<j)) == 0) { dp[a[i]] = 1; ok = 1; break; }
        //cout<<a[i]<<" "<<dp[a[i]]<<endl;
        if(ok) continue;
        for(int j = 0; j < 26; j++)
            dp[a[i]] = min(dp[a[i]^(1<<j)]+1, dp[a[i]]);
    }
    cout<<dp[a[L-1]]<<endl;
    return 0;
}


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

using ll = long long;
const ll INF = 1e18;

const int MAXN = 1.1e5;
const int MAXM = 1.1e5;

int N, M, V;

vector<pair<int, int>> adj[MAXN];
ll dist[MAXN];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> N >> M;
	for (int i = 0; i+1 < N; i++) {
		adj[i+1].emplace_back(i, 0);
	}
	for (int i = 0; i < M; i++) {
		int l, r, c; cin >> l >> r >> c; l--, r--;
		adj[l].emplace_back(r, c);
	}

	for (int i = 0; i < N; i++) {
		dist[i] = INF;
	}
	dist[0] = 0;
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
	pq.emplace(0, 0);
	while (!pq.empty()) {
		ll d; int cur; tie(d, cur) = pq.top();
		pq.pop();
		if (d != dist[cur]) continue;
		for (auto it : adj[cur]) {
			int nxt = it.first;
			ll nd = it.second + d;
			if (nd < dist[nxt]) {
				dist[nxt] = nd;
				pq.emplace(nd, nxt);
			}
		}
	}

	ll ans = dist[N-1];
	if (ans == INF) {
		ans = -1;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 8824
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int odp = 0;
    for (int i = 1; i <= n; ++i)
    {
        int j = n - i;
        if (i != j && i < j)
            ++odp;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <cmath>
#include <tuple>
using namespace std;
#define fio ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N,M,K;
char inp[300005];
int cnta,cntb;
int main(){
	scanf("%s",inp+1);
	N=strlen(inp+1);
	for(int i=1;i<=N;i++){
		if(inp[i]=='0') cnta++;
		else cntb++;
	}
	printf("%d",min(cnta,cntb)*2);

}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int i, j;
	
	for (i = 1; i <= 9; i++){
		for (j = 1; j <= 9; j++){
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<stdio.h>
signed main(){
    int N,K,i,j,x[1001];
    int min,temp;
    scanf("%d %d",&N,&K);
    for(i=0;i<N;i++){
        scanf("%d ",&x[i]);
    }
    for(i=0;i<N;i++){
        min=i;
        for(j=i+1;j<N;j++){
            if(x[j]<x[min]){
                min=j;
            }
        }
        if(min !=i){
            temp=x[i];
            x[i]=x[min];
            x[min]=temp;
        }
    }
    min=0;
    for(i=0;i<K;i++){
        min +=x[i];
    }
    printf("%d\n",min);
    return(0);
}

Measured memory_bytes: 1712
//二次元幾何ライブラリ
#include <iostream>
#include <cstdio>
#include <complex>
#include <map>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define MC make_pair
#define ML make_pair 
#define X real()
#define Y imag()
typedef double D;
typedef bool B;
typedef complex<D> P;   //点
typedef complex<D> V;   //ベクトル
typedef pair<P,P>  L;   //直線
typedef pair<P,D>  C;   //円
typedef vector<P>  Pol; //多角形

//変数名定義
const D INF = 1e100;
const D EPS = 1e-12;
const D PI = acos(-1);

template<class T> bool operator==(T a, T b){return abs(a - b )< EPS;}
template<class T> int sig(T r) {return (r==0||r==-0) ? 0 : r > 0 ? 1 : -1;}

P p3,p4;
int num;

// ベクトルaの絶対値を求める
// D Length = abs(a);

// 2点a,b間の距離を求める
// D Distance = abs(a-b); 

// 内積 (Inner Product) : a・b = |a||b|cosθ 1
D IP(V a, V b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}

// 外積 (Exterior Product) : |a×b| = |a||b|sinθ 2
D EP(V a, V b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

// 点の進行方向について 3
int ccw(P a, P b, P c) {              //点aと点bが与えられた問いに
  b -= a; c -= a;
  if (EP(b, c) > 0)   return +1;      // counter clockwise
  if (EP(b, c) < 0)   return -1;      // clockwise
  if (IP(b, c) < 0)     return +2;    // c--a--b on line
  if (norm(b) < norm(c)) return -2;   // a--b--c on line
  return 0;                           // a--c--b on line  aとbの線分判定はこれ
}

// 2直線の垂直判定 : a⊥b <=> IP(a, b) = 0 4needs1
B IsVecular(L l1, L l2) {
	return IP(l1.first-l1.second, l2.first-l2.second)==0.0;
}

// 2直線の平行判定 : a//b <=> EP(a, b) = 0 5needs2
B IsParallel(L l1, L l2) {
	return abs(EP(l1.first-l1.second, l2.first-l2.second))<EPS;
}


//example : v1 = V(5.0,-3.0) p1=P(0.0,4.0)
int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		P points[4];
		for(int j=0;j<4;j++)
			cin >> points[j].X >> points[j].Y;
		L l1,l2;
		l1=ML(points[0],points[1]);
		l2=ML(points[2],points[3]);
		if(IsParallel(l1,l2))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

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

int main(){
 int i,s=0,vec_a=0,N=0;
  cin >>N;
  vector<int> vec(N);
  for(i=0;i<N;i++){
    cin >> vec.at(i);
  }
  
  while(1){
   for(i=0;i<N;i++){
    if(vec.at(i) % 2 != 0) {
     cout << s << endl;
     return 0;
    } else 
       vec.at(i) /= 2; 
   }
   s++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	string s,a="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int n,p;
    cin>>n>>s;
if(n==0){
	cout<<s; return 0;
}
    for (int i = 0; i < SZ(s); ++i)
    	{
    		 p=s[i]-'A';
    		 p+=n;
    		 cout<<a[p%26];
    	}	

   return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(int argc, char const *argv[]) {
    long long n, min=INF, cnt=0, p;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> p;
        if(chmin(min, p)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}




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

using namespace std;

int main(){
	int a, b;
  	scanf("%d %d", &a, &b);
  	if (1 <= a && a <= 9 && 1 <=b && b <= 9) {
    	printf("%d\n", a * b);
    } else {
    	printf("-1\n");
    }
  	return 0;
}

Measured memory_bytes: 256
n = int(input())
AL = list(map(int,input().split()))
BL = list(map(int,input().split()))
ans = 0
for i in range(n):
    if BL[i] <= AL[i]:
        ans += BL[i]
    elif BL[i] > AL[i] and BL[i] <= AL[i]+AL[i+1]:
        ans += BL[i]
        AL[i+1] = AL[i+1] - BL[i] + AL[i]
    else:
        ans += AL[i]+AL[i+1]
        AL[i+1] = 0
print(ans)

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

int main()
{
    int a,b,c,x;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&x);
    int i,j,k;
    int type=0;
    for(i=0;i<=a;i++)
    {
        for(j=0;j<=b;j++)
        {
            for(k=0;k<=c;k++)
            {
                if(i*500+j*100+k*50==x)
                    type++;
            }
        }
    }
    printf("%d",type);
    return 0;
}


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

int main() {

  int a,b,c,d,e,f;

  cin >> a ;
  cout<<"Christmas";
  for(int i=0;i<999;i++){
  if(a==25){
    break;
  }
          else{
            a++;
            cout<<" "<<"Eve";
          }
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main(void){
  int N;
  cin>>N;
  int ans,mnum,M;
  int mans=0;
  for(int i=1;i<=N;i++){ ans=0; M=i;
      for(int j=1;j<=N;j++){
          if(M%2==0) { M=M/2; ans++;}
          else if(ans>=mans) {mans=ans; mnum=i;}
      }
  }
  cout<<mnum;
  return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)2e5 + 5;
using namespace std;


int main()
{
	int n; cin >> n;
	if(n < 1200) puts("ABC");
	else if(n >= 1200 && n < 2800) puts("ARC");
	else puts("AGC");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   int x, y;
   cin >> x >> y;
   int a[] = {0,
              1,
              3,
              1,
              2,
              1,
              2,
              1,
              1,
              2,
              1,
              2,
              1};

   cout << (a[x] == a[y] ? "Yes" : "No") << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue>
#include <set> 
#include <stack>
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

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

  if(a < 3200) cout << "red" << endl;
  else cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)
using WG = map<int,map<int,ll>>; // weighted graph

void dijkstra(int s, WG& g, vector<ll>& dist) {
  vector<bool> visited(dist.size());
  fill(dist.begin(),dist.end(),1e15);
  using P = pair<ll,int>;
  priority_queue<P,vector<P>, greater<P>> pq;
  dist[s]=0;
  //visited[s]=true;
  pq.push(make_pair(0LL,s));
  while(!pq.empty()) {
    int v;
    ll d;
    tie(d,v)=pq.top();
    pq.pop();
    if(visited[v]) continue;
    visited[v]=true;
    for(auto& uw : g[v]) {
      int u;
      ll w;
      tie(u,w)=uw;
      if(visited[u]) continue;
      if(d+w<dist[u]) {
        dist[u]=d+w;
        pq.push(make_pair(dist[u],u));
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,m,s,t;
  cin>>n>>m>>s>>t;
  vector<ll> YD(n+1);
  vector<ll> SD(n+1);
  WG YG;
  WG SG;
  rep(__i,m) {
    int u,v;
    ll a,b;
    cin>>u>>v>>a>>b;
    YG[u][v]=a;
    YG[v][u]=a;
    SG[u][v]=b;
    SG[v][u]=b;
  }
  dijkstra(s,YG,YD);
  dijkstra(t,SG,SD);
  ll a=0;
  const ll y=1e15;
  vector<ll> ans(n);
  revrep(i,n) {
    a=max(a,y-(YD[i+1]+SD[i+1]));
    ans[i]=a;
//    cout << a << endl;
  }
  rep(i,n) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 48000
#include <iostream>
#include <string>
#include <set>
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
#include <cmath>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;
typedef pair<double, P> E;

struct UnionFind
{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

llint n;
double x[105], y[105], z[105], r[105];
vector<E> vec;
UnionFind uf(105);

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		
		for(int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> z[i] >> r[i];
		
		vec.clear();
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				if(i >= j) continue;
				double dist = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) + (z[i]-z[j])*(z[i]-z[j])) - (r[i]+r[j]);
				vec.push_back(E(max(0.0, dist), P(i, j)));
			}
		}
		sort(vec.begin(), vec.end());
		
		uf.init();
		double ans = 0, w; llint u, v;
		for(int i = 0; i < vec.size(); i++){
			w = vec[i].first, u = vec[i].second.first, v = vec[i].second.second;
			if(uf.same(u, v)) continue;
			uf.unite(u, v);
			ans += w;
		}
		printf("%.3f\n", ans);
	}
	
	return 0;
}


Measured memory_bytes: 3212
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define mod (int)1000000007
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
signed main() {
	int a, b;
	cin >> a >> b;
	REP(i,1500){
		if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#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 pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[2][101];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[0][i];
    rep(i,n) cin>>a[1][i];
    int mx=0;
    rep(i,n){
        int sum=0;
        rep(j,n){
            if(i>=j) sum+=a[0][j];
            if(i<=j) sum+=a[1][j]; 
        }
        mx=max(sum,mx);
    }
    cout<<mx<<endl;
    return 0;
}

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

int main() {
  int a, b; cin >> a >> b;
  int n = stoi(to_string(a) + to_string(b));
  int rt = sqrt(n);
  cout << (rt*rt == n ? "Yes" : "No") << endl;
  return 0;
}


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


#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'

int main()

{
    optimize();
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5  &&  b== 7 && c==5  ) cout<<"YES";
    else if(a==5  &&  b== 5 && c==7  ) cout<<"YES";
    else if(a==7  &&  b== 5 && c==5  ) cout<<"YES";
    else cout<<"NO";










    return 0;
}



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

int main()
{
    string s,s1="ABC",s2="ARC";
    cin >> s;
    if(s==s1)
    {
        cout << "ARC" << endl;
    }
    else if(s==s2)
    {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3632
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b = int(input())

print(a[b-1])

Measured memory_bytes: 38332
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  string s;
  cin >> n;
  cin >> s;
  int red = 0;
  int blue = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') red++; else blue++;
  }
  string result = (red > blue) ? "Yes" : "No";
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  string s;
  cin>>s;
  int l=s.size();
  vector<int> R(l,0);
  int cou_r=0;
  rep(i,l){
    if(s[i]=='L'){
      if(cou_r==0) continue;
      R[i]+=cou_r/2;
      R[i-1]+=cou_r-cou_r/2;
      cou_r=0;
    }
    else cou_r++;
  }
  vector<int> L(l,0);
  int cou_l=0;
  rep(i,l){
    int j=l-i-1;
    if(s[j]=='R'){
      if(cou_l==0) continue;
      L[j]+=cou_l/2;
      L[j+1]+=cou_l-cou_l/2;
      cou_l=0;
    }
    else cou_l++;
  }
  
  rep(i,l){
    if(i!=l-1) cout<<R[i]+L[i]<<" ";
    else cout<<R[i]+L[i]<<endl;
  }
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<int> v[101010];
priority_queue<int> ret[101010];
int ans[101010];

int dfs(int x,int p){
    ret[x].push(0);
    for(auto to:v[x]){
        if(to==p)continue;
        ret[x].push(dfs(to,x));
    }
    return ret[x].top()+1;
}

void dfs2(int x,int p){
    int res=ret[x].top();
    if(p!=-1){
        int y=ret[p].top();
        ret[p].pop();
        if(y!=res+1)ret[x].push(y+1);
        else ret[x].push(ret[p].top()+1);
        ret[p].push(y);
    }
    for(auto to:v[x]){
        if(to==p)continue;
        dfs2(to,x);
    }
    ans[x]=ret[x].top();
}

int main(){
    int n;
    cin>>n;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        --a;--b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(0,-1);
    dfs2(0,-1);
    rep(i,n)cout<<2*(n-1)-ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 26104
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    # inputs
    x = int(input().strip())

    # a,b > 0
    for a in range(0,2000):
        for b in range(0,a+1):
            if a**5 - b**5 ==x:
                print(a,b)
                return

    # a >0 and b < 0
    for a in range(0,100):
        for b in range(-100,1):
            if a**5 - b**5 == x:
                print(a,b)
                return


if __name__ == '__main__':
    main()

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<>();
		String result= "YES";
		int a;
		for(int i=0;i<n;i++) {
			a = sc.nextInt();
			if(map.containsKey(a)) {
				result = "NO";
				break;
			}else {
				map.put(a, 1);
			}
		}
		
		System.out.println(result);		
	}

}


Measured memory_bytes: 98496
#include <stdio.h>

int main(void)
{
	int i;
	for(i = 1;i <10;i++)
	{
		int k;
		for(k = 1;k < 10;k++)
		{
			printf("%dx%d=%d\n",i,k,i*k);
		}
	}
//	getchar();
	return 0;
}

Measured memory_bytes: 520
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>

using namespace std;
typedef long long ll;

char S[100010] = {};
ll ans = 0, num = 0;

int main() {
	cin >> S;
	for (int i = 0; i <= 100000; i++) {
		if (S[i] == NULL) {
			num = i;
			break;
		}
		if (i % 2 == 0 && S[i] == '0')ans++;
		if (i % 2 == 1 && S[i] == '1')ans++;
	}
	cout << min(ans, num - ans) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
    int E = A + B;
    int F = C + D;
  if (E > F) {
    cout << "Left"<< endl;
  }
  if (E == F) {
    cout << "Balanced"<< endl;
  }
  if (E < F) {
    cout << "Right"<< endl;
  }
}

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
  #define DFUNC(fname, ...) fname(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFUNC(fname, ...)
#endif

ll r,D,x0;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> r >> D >> x0;

  ll x = x0;
  for (ll i = 1; i <= 10; i++) {
    x = r * x - D;
    cout << x << endl;
  }

  return 0;
}



Measured memory_bytes: 256
/*
 * ITP1_1_D.c
 *
 *  Created on: 2017/05/11
 *      Author: sl2-user
 */
#include<stdio.h>

int main(void){

	int a , b;
        scanf("%d %d" , &a , &b);
	if(a>b){printf("a > b\n");}else if(a<b){printf("a < b\n");}else{printf("a == b\n");}

return 0;
}

Measured memory_bytes: 2688