akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    // A B C D
    val list = nextIntList()
    // hp
    var tH = list[0]
    var aH = list[2]
    // attack
    val tA = list[1]
    val aA = list[3]


    val stop = true
    var res = ""
    while(stop){
        // t->a
        aH = j(tA,aH)
        if(aH < 1){
            res = "Yes"
            break
        }
        tH = j(aA,tH)
        if(tH < 1){
            res = "No"
            break
        }
    }
    println(res)
}
fun nextIntList() = next().split(" ").map{ it.toInt() }
fun next() = readLine()!!


fun j(a:Int, h:Int):Int{
    return h-a
}


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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll f(ll x){
    if(x==0) return 0;
    ll pop=0;
    ll copy=x;
    while(copy>0){
        if(copy%2==1) pop++;
        copy/=2;
    }
    x%=pop;
    return f(x)+1;
}

int main() {
    ll n;
    cin >> n;
    string X;
    cin >> X;
    vector<ll>x(n);
    ll k=0;
    ll popcount = 0;
    for(auto h:X){
        x[k]=h-'0';
      	if(x[k]==1) popcount++;
        k++;
    }
    ll pop_plu=popcount+1;
    ll pop_min=popcount-1;
    ll x_plu=0;
    ll x_min=0;
    for(ll i=0;i<n;i++){
        if(x[i]==1){
            x_plu+=modpow(2,n-i-1,pop_plu);
          	if(pop_min>0){
            	x_min+=modpow(2,n-i-1,pop_min);
            }
        }
    }

    if(popcount==0){
      for(int i=0;i<n;i++){
        cout << 1 << endl;
      }
      return 0;
    }

    if(popcount==1){
        for(int i=0;i<n;i++){
            if(X[n-1]=='1'&&i!=n-1){
                cout << 2 << endl;
            }
            else if(X[n-1]=='1'&&i==n-1){
                cout << 0 << endl;
            }
            else{
                if(X[i]=='1'){
                    cout << 0 << endl;
                }
                else if(i==n-1){
                    cout << 2 << endl;
                }
                else{
                  cout << 1 << endl;
                }
            }
        }
        return 0;
    }
    ll copy_plu=x_plu;
    ll copy_min=x_min;
  	vector<ll>ans(n,0);
    for(ll i=0;i<n;i++){
        if(x[i]==1){
            x_min-=modpow(2,n-i-1,pop_min);
            x_min+=pop_min;
            x_min%=pop_min;
          	ans[i]+=f(x_min)+1;
            x_min=copy_min;
        }
        else {
            x_plu+=modpow(2,n-i-1,pop_plu);
            x_plu%=pop_plu;
          	ans[i]+=f(x_plu)+1;
            x_plu=copy_plu;
        }
    }
 	for(int i=0;i<n;i++){
    	cout << ans[i] << endl;
  	}
}

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

using namespace std;

#define MAX 1000000

int main(void){

  int n,count = 0,num = 0;

  while(cin >> n){

    vector<int>array(MAX,0);

    if(n == 1){
      count = 0;
      cout << count << endl;
    }

    if(n == 2){
      count = 1;
      cout << count << endl;
    }

    if(n == 3){
      count = 2;
      cout << count << endl;
    }

    if(n > 3){
      count = 2;
      num = 0;
      array[num++] = 2; 
      array[num++] = 3; 


      for(int i = 5; i <= n ; i+=2){
        int flag = 0;
        for(int j = 0; array[j] * array[j] <= i;j++){
          if(i % array[j] == 0){
            flag = 1;
            break;
          }
        }
        if(!flag){
          array[num++] = i;
          count++;
        }
      }
      cout << count << endl;
      count = 0;
      num = 0;
    }
  }

  return 0;
}

Measured memory_bytes: 6904
import java.util.Scanner;

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

		char[] c = st.toCharArray();
		long[] x = new long[st.length()];
		int kosu = Renzoku(c, x);
		int moto, saki;
		moto = 0;
		saki = kosu - 1;
		if (c[0] == '.') {
			moto = 1;

		}
		if (c[n - 1] == '#') {
			saki--;
		}

		long min = 0;
		long ans = 0;

		for (int j = moto + 1; j <= saki; j = j + 2) {
			ans += x[j];

		}
		min = ans;
		for (int j = moto + 2; j <= saki+2; j = j + 2) {
			ans = ans - x[j - 1] + x[j - 2];
			if (ans < min) {
				min = ans;
			}
		}

		System.out.println(min);

	}

	public static int Renzoku(char c[], long x[]) {

		int mode = 0;
		int val = 0;

		for (int i = 0; i <= c.length - 2; i++) {
			if ((c[i] == c[i + 1]) && i != c.length - 2) {
				val++;
			} else {
				if ((c[i] == c[i + 1]) && i == c.length - 2) {
					val++;
				}
				val++;
				x[mode] = val;
				mode++;

				if ((c[i] != c[i + 1]) && i == c.length - 2) {
					x[mode] = 1;
					mode++;
				}

				val = 0;
			}

		}
		return mode;

	}
}

Measured memory_bytes: 29772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main() {
   string S;
   cin>>S;
   int ans=0, now=0;
   for(int i=0;i<3;i++){
       if(S[i]=='R') now++;
       else now=0;
       ans=max(ans,now);
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3568
n = int(input())
s = input()
left = []
right = [0 for i in range(n)]
br = 0
for i in range(n):
    if s[i] == "#":
        br += 1
    left.append(br)
br = 0
for i in range(n):
    if s[n - i - 1] == ".":
        br += 1
    right[n - i - 1] = br
p = []
for i in range(n - 1):
    p.append(left[i] + right[i + 1])
p.append(left[n - 1])
p.append(right[0])
print(min(p))


Measured memory_bytes: 20968
input = STDIN.gets.split(' ').map(&:to_i)
a = STDIN.gets.split(' ').map(&:to_i)

n = input[0]
x = input[1]

ret = 0

size = a.size
(n-1).times do |i|
  l = a[i]
  r = a[i+1]
  next if a[i]+a[i+1] <= x
  diff = (a[i]+a[i+1]) - x
  if a[i] > x
    ret += diff
    a[i], a[i+1] = x, 0
  else
    a[i+1] = x-a[i]
    ret += diff
  end
end
STDOUT.puts ret

Measured memory_bytes: 8588
s=input()
if s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4)
elif s=='THU':
    print(3)
elif s=='FRI':
    print(2)
elif s=='SAT':
    print(1)

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef std::pair<int, int> int_pair;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {

	string s,a,b,c;
	cin >> s;
	a = s[6];
	b = s[5];
	if (stoi(a) > 4) {
		cout << "TBD" << endl;
	}
	else if(stoi(b) == 1){
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}

}


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

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto E = new Tuple!(int, int, long, int)[](M);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        E[i] = tuple(s[0]-1, s[1]-1, s[2].to!long, i);
    }

    E.sort!"a[2] < b[2]";
    auto uf = new UnionFind(N);
    auto mst_edge = new bool[](M);
    auto safe_edge = new bool[](M);
    long mst_cost = 0;
    auto mst = new Tuple!(int, long, int)[][](N);
    auto mst_depth = new int[](N);
    auto mst_parent = new Tuple!(int, long, int)[](N);

    foreach (e; E) {
        if (uf.find(e[0]) != uf.find(e[1])) {
            uf.unite(e[0], e[1]);
            mst_cost += e[2];
            mst_edge[e[3]] = safe_edge[e[3]] = true;
            mst[e[0]] ~= tuple(e[1], e[2], e[3]);
            mst[e[1]] ~= tuple(e[0], e[2], e[3]);
        }
    }


    void dfs(int n, int p, long c, int ei, int d) {
        mst_parent[n] = tuple(p, c, ei);
        mst_depth[n] = d;
        foreach (e; mst[n]) {
            if (e[0] == p) continue;
            dfs(e[0], n, e[1], e[2], d+1);
        }
    }

    dfs(0, -1, 0, -1, 0);


    void solve(int u, int v, long c, int ei) {
        if (mst_depth[u] < mst_depth[v]) {
            swap(u, v);
        }
        while (mst_depth[u] > mst_depth[v]) {
            if (mst_parent[u][1] == c) {
                safe_edge[mst_parent[u][2]] = false;
            }
            u = mst_parent[u][0];
        }
        while (u != v) {
            if (mst_parent[u][1] == c) {
                safe_edge[mst_parent[u][2]] = false;
            }
            u = mst_parent[u][0];
            if (mst_parent[v][1] == c) {
                safe_edge[mst_parent[v][2]] = false;
            }
            v = mst_parent[v][0];
        }
    }

    foreach (e; E) {
        if (mst_edge[e[3]]) continue;
        solve(e[0], e[1], e[2], e[3]);
    }

    writeln(safe_edge.sum, " ", E.filter!(e => safe_edge[e[3]]).map!(e => e[2]).sum);
}


class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}



Measured memory_bytes: 4584
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define maxn 101000

char s[maxn];
int main()
{
	int len,a,b,i;
	scanf("%s",s+1);
	len=strlen(s+1);
	a=b=-1;
	for (i=2;i<=len;i++)
	{
		if (s[i]==s[i-1]) 
		{
			a=i-1;b=i;
			break;
		}else if (i>2 && s[i]==s[i-2])
		{
			a=i-2;b=i;
			break;
		}
	}
	printf("%d %d\n",a,b);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    string str;
    cin >> str;
    rep(i,str.size()){
        cout << str[i];
        if(i==3)
            cout << ' ';
    }
    cout << endl;
    return 0;
}


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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);

            bool[] s = new bool[13];
            bool[] h = new bool[13];
            bool[] c = new bool[13];
            bool[] d = new bool[13];

            

            for (int i = 0; i < n; ++i)
            {
                string[] Array = Console.ReadLine().Split(' ');         //????????????card[0]????????°??????card[1]?????\?????????
                int[] card = new int[2];
                card[1] = int.Parse(Array[1]);
                
                if (Array[0] == "S")
                {
                    s[card[1]-1] = true;
                }
                else if (Array[0] == "H")
                {
                    h[card[1] - 1] = true;
                }
                else if (Array[0] == "C")
                {
                    c[card[1] - 1] = true;
                }
                else
                {
                    d[card[1] - 1] = true;
                }

            }
            for (int i = 0; i < 13; ++i )
            {
                if (s[i] == false)
                {
                    Console.WriteLine("S {0}",i+1);
                }
            }
            for (int i =0; i < 13; ++i)
            {
                if (h[i] == false)
                {
                    Console.WriteLine("H {0}",i+1);
                }
            }
            for (int i = 0; i < 13; ++i)
            {
                if (c[i] == false)
                {
                    Console.WriteLine("C {0}",i+1);
                }
            }
            for (int i = 0; i < 13; ++i)
            {
                if (d[i] == false)
                {
                    Console.WriteLine("D {0}",i+1);
                }
            }
                

           
             
        }
    }
}

Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5+9;
int s[ N ], l[ N ], r[ N ];

int main( void ) {
    ios::sync_with_stdio( false );
    int n;
    cin >> n;
    for( int i = 1; i <= n; ++i ) cin >> s[ i ];
    l[ 0 ] = 0;
    l[ 1 ] = s[ 1 ];
    for( int i = 2; i < n; ++i ) l[ i ] = __gcd( s[ i ], l[ i - 1 ] );
    r[ n + 1 ] = 0;
    r[ n ] = s[ n ];
    for( int i = n - 1; i >= 0; --i ) r[ i ] = __gcd( s[ i ], r[ i + 1 ] );
    int ans = 0;
    for( int i = 1; i <= n; ++i ) {
        ans = max( __gcd( l[ i - 1 ], r[ i + 1 ] ), ans );
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    ll N;
    cin >> N;
    vll a(N), s(N);
    rep(i, N)
    {
        cin >> a[i];
        if (i > 0)
            s[i] = s[i - 1] + a[i];
        else
        {
            s[0] = a[0];
        }
    }
    ll min = LONG_LONG_MAX;
    rep(i, N - 1)
    {
        if (min > abs(s[N - 1] - 2 * s[i]))
        {
            min = abs(s[N - 1] - 2 * s[i]);
        }
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 3328
import math
n, p = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
odd = 0; even = 0
for item in a:
    if item % 2 == 0:
        even += 1
    else:
        odd += 1
if p == 0:
    ans = 1
    for i in range(1, odd // 2 + 1):
        ans += math.factorial(odd) // math.factorial(i*2) // math.factorial(odd - i * 2)
    print(pow(2,even) * ans)
elif p == 1:
    ans = 0
    for i in range(odd // 2):
        ans += math.factorial(odd) // math.factorial(i*2 + 1) // math.factorial(odd - (i * 2 + 1))
    print(pow(2,even) * ans)

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

int main(){
	int n; cin >> n;
  	n%=10;
  	if(n==3){cout << "bon" << endl;   }
  	else if(n==0 || n==1 || n==6 || n==8){cout << "pon" << endl;}
  	else{cout << "hon" << endl;}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int m = 1000000007; 

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	ll n; cin >> n;
	string st;

	while (n > 0) {
		int d = n % 26;
		n = n / 26;
		if (d == 0)
			st += 'z', n--;

		else
			st += 'a' + d-1;
		// cout << d << endl;

	}
	reverse(st.begin(), st.end());
	cout << st;
}




Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
       
        ArrayList<String> sList = new ArrayList<>();
      
		for (int i = 0; i < n; i++) {
          String s = sc.next();
          String[] chars = s.split("");
          Arrays.sort(chars);
          String master = "";
          for (String part : chars) {
            master += part;
          }
          sList.add(master);
        }
        Collections.sort(sList);
       
        long ans = 0;
        while (sList.size() > 1) {
          String sample = sList.get(0);
          sList.remove(0);
          long count = 0;
          while(sList.get(0).equals(sample)) {
            ans++;
            count++;
            sList.remove(0);
            if (count > 1) {
            ans += count - 1;
            }
            if (sList.size() == 0) {
              break;
            }
          }
        }      
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 101976
#include<cstdio>
#include<algorithm>
using namespace std;
struct Edge {
	int a, b, c;
}E[100];
int cnt;
void Solve(int cur, int L) {
	if (cur == 2) {
		int i;
		for (i = 0; i < L; i++) {
			E[cnt++] = { 1,2,i };
		}
		return;
	}
	Solve(cur - 1, L / 2);
	if (L & 1) {
		E[cnt++] = { 1,cur,L - 1 };
	}
	E[cnt++] = { cur - 1,cur,0 };
	E[cnt++] = { cur - 1,cur,L/2 };
}
int main() {
	int n, i;
	scanf("%d", &n);
	for (i = 0;; i++) {
		if ((1 << i) > n)break;
	}
	Solve(i,n);
	printf("%d %d\n", i,cnt);
	for (i = 0; i < cnt; i++)printf("%d %d %d\n", E[i].a, E[i].b, E[i].c);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

int main() {
	int n, i, a, c[333333], ans[333333],count=0,p,p2,sum;
	cin >> n;
	for (i = 0; i <= n; i++)
		c[i] = 0;
	for (i = 0; i < n; i++) {
		cin >> a;
		c[a]++;
	}
	vector<int> v;
	for (i = 0; i <= n; i++) {
		if (c[i] > 0) {
			v.push_back(c[i]);
			count++;
		}
	}
	v.push_back(0);
	sort(v.begin(), v.end());
	for (i = 1; i <= n; i++)
		ans[i] = 0;
	p = count+1;
	p2 = 1;
	sum = n;
	for (i = n; i > 0; i--) {
		while (v[p - 1] > i) {
			p--;
			sum -= v[p] - i;
		}
		while (sum / p2 >= i) {
			ans[p2] = i;
			p2++;
		}
		sum -= count + 1 - p;
	}
	for (i = 1; i <= n; i++)
		cout << ans[i] << endl;
}


Measured memory_bytes: 4336
import sys
sys.setrecursionlimit(10000)
input = sys.stdin.readline

def f(v, vs):
    kminmax = 0
    r = 0
    rkoma = 0
    fff = 0
    ffmx = 0
    for u in d[v]:
        if u in vs:
            continue
        vs.add(u)
        k1, koma, ff = f(u, vs)
        if k1 > kminmax:
            kminmax = k1
            ffmx = ff
        kminmax = max(kminmax, k1)
        rkoma += koma
        fff += ff
    if kminmax > fff - ffmx:
        r1 = kminmax+ffmx-fff
    else:
        r1 = fff % 2
    rkoma += km[v]
#    print(v, r1 + rkoma, rkoma, fff + rkoma)
    return r1 + rkoma, rkoma, fff + rkoma

N = int(input())
km = [0] + [int(i) for i in str(input().strip())]
d = [set() for _ in range(N+1)]
for _ in range(N-1):
    x, y = map(int, input().split())
    d[x].add(y)
    d[y].add(x)

r = 10**10
#print(f(4, {4}))
for i in range(N):
    a, c, fff = f(i+1, {i+1})
#    print(i, a, c)
    if a == c:
        r = min(r, (fff-c)//2)
print(r if r != 10**10 else -1)


Measured memory_bytes: 216068
def main():
     def root(x):
          path=[]
          while x!=P[x]:
               path.append(x)
               x=P[x]
          for i in path:
               P[i]=x
          return x
     
     def is_same_set(x,y):
          return root(x)==root(y)
     
     def unite(x,y):
          P[root(x)]=root(y)
     
     n,q=map(int,input().split())
     P=[i for i in range(n)]
     for i in range(q):
          q,a,b=map(int,input().split())
          if q==0:
               unite(a,b)
          else:
               if is_same_set(a,b):
                    print(1)
               else:
                    print(0)
     
if __name__=='__main__':
     main()


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

int main() {
  int N, T;
  cin >> N >> T;
  int mn = 1001;
  for ( int i = 0; i < N; i++ ) {
    int c, t;
    cin >> c >> t;
    mn = ( t <= T && c < mn ) ? c : mn;
  }
  if ( mn != 1001 ) {
    cout << mn << endl;
  } else {
    cout << "TLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import deque

s = deque(input())

cnt = 0
while len(s) > 1:
  a,b = s[0],s[-1]
  if a == b:
    s.pop()
    s.popleft()
  elif a == 'x':
    cnt += 1
    s.popleft()
  elif b == 'x':
    cnt += 1
    s.pop()
  else:
    break
else:
  print(cnt)
  exit()

print(-1)

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

int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;

    if ( a < b && b < c ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3084
dp = {}

n, W = map(int, input().split())

value = []
weight = []

for w in range(0, W+1):
    dp[(0, w)] = 0

for i in range(n):
    s = list(map(int, input().split()))

    value.append(s[0])
    weight.append(s[1])

for i in range(n):
    for w in range(0, W+1):

        if w >= weight[i]:
            dp[(i+1, w)] = max(dp[(i, w - weight[i])] + value[i], dp[(i, w)])
        else:
            dp[(i+1, w)] = dp[(i, w)]

print(dp[(n, W)])



Measured memory_bytes: 170604
n, m = map(int, input().split())

from collections import defaultdict
d = defaultdict(list)
for _ in range(m):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

from itertools import permutations
C = permutations(range(2, n+1))
C = list(map(lambda x: [1]+list(x), C))

ans = 0
for c in C:
    for i in range(n-1):
        if c[i+1] not in d[c[i]]:
            break
    else:
        ans += 1
print(ans)

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

bool IsMultiplicationTable(int N){
    bool Multiplication_flg=false;
    for(int i=1;i<10;i++){
        if(N%i==0 && N/i<10){
           Multiplication_flg=true;
           break;
        }
    }
    return Multiplication_flg;
}

int main(){
    int N; cin >> N;
    if(IsMultiplicationTable(N)==true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
    dic.setdefault(a, 0)
    dic[a] += 1
ans = 0
for k, v in dic.items():
    if k == v:
        continue
    if k > v:
        ans += v
    else:
        ans += (v - k)
print(ans)

Measured memory_bytes: 68264
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := getInt(), getInt()
	l := make([]int, N)
	for i := 0; i < N; i++ {
		l[i] = getInt()
	}
	sort.Ints(l)
	ans := 0
	for i := 1; i <= K; i++ {
		ans += l[N-i]
	}

	out(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S;
    cin >> S;

    long long ans=0;
    int N=S.size()-1;

    for(int bit=0;bit < (1<<N);bit++){
        string w=S;
        long long sum=0;
        for(int i=0;i<N;i++){
            if(bit & (1<<i)){
                sum+=stoll(w.substr(N-i));
                w=w.substr(0,N-i);
            }
        }
        sum+=stoll(w);
        ans+=sum;
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define md 1000000007
int main()
{
    int n; cin >> n;
    char s[100000]; cin >> s; ll d = strlen(s);
    for(int i = 0; i < d;i++)
    {
        if(s[i] + n <= 'Z')
        {
            s[i] = s[i] + n;
        }
       else  if(s[i] + n >'Z')
        {
            s[i] = s[i] - 26;
            s[i] = s[i] + n;
        }

    }
    cout << s ;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vi X(N); REP(i, N) cin >> X[i];
    
    vi Y = X;
    sort(Y.begin(), Y.end());

    vi ans;
    REP(i, N) {
        if (X[i] < Y[N / 2]) ans.push_back(Y[N / 2]);
        else ans.push_back(Y[N / 2 - 1]);
    }

    for(int i : ans) cout << i << endl;

    return 0;
}

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

using namespace std;

#define MAX 10000

int par[MAX], rank[MAX];

void initUnionFind(int N){
  for(int i = 0 ; i < N ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }
  return par[x] = find(par[x]);
}

void unite(int x, int y){
  x = find(x);
  y = find(y);

  if(x == y) return;

  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]){
      ++rank[x];
    }
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int main(){
  int n, q, a, b ,c;

  cin >> n >> q; initUnionFind(n);
  for(int i = 0 ; i < q ; i++){
    cin >> a >> b >> c;
    if(a == 0){
      unite(b, c);
    }else{
      cout << (same(b,c) ? 1 : 0) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1236
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    int t = stdIn.nextInt();

    int ans = 0;
    for(int i=1; i*a <= t; i++) {
      ans += b;
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m,q;
	cin>>n>>m>>q;
	vs tmp(m,"");
	rep(i,n)rep(j,m){
		char c;cin>>c;
		tmp[j]=c+tmp[j];
	}
//	rep(i,m)cout<<in[i]<<endl;
	bool h=false;
	rep(x,m-1)rep(y,n){
		vs in=tmp;
		swap(in[x][y],in[x+1][y]);
		rep(i,m){
			string t="";
			rep(j,n)if(in[i][j]!='.')t+=in[i][j];
			while(t.size()!=n)t+=".";
			in[i]=t;
		}
		while(1){
			vvi to(m,vi(n));
			rep(i,m)rep(j,n-1)if(in[i][j]!='.'){
				int t=j;
				while(t+1<n&&in[i][t]==in[i][t+1])t++;
				if(t-j+1>=q)loop(k,j,t+1)to[i][k]=true;
				j=t;
			}
			rep(i,n)rep(j,m-1)if(in[j][i]!='.'){
				int t=j;
				while(t+1<m&&in[t][i]==in[t+1][i])t++;
				if(t-j+1>=q)loop(k,j,t+1)to[k][i]=true;
				j=t;
			}
			bool he=false;
			rep(i,m){
				string t="";
				rep(j,n)if(!to[i][j])t+=in[i][j];
				while(t.size()!=n)t+=".";
				if(in[i]!=t)he=true;
				in[i]=t;
			}
			if(!he)break;
		}
		bool H=true;
		rep(i,m)rep(j,n)if(in[i][j]!='.')H=false;
		if(H)h=true;
	}
	if(h)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

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

Measured memory_bytes: 256
/*
 *  Author :: Kattu37
 */

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

#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortallr(x) sort(allr(x))
#define PI 3.1415926535897932384626
#define mod 1000000007

typedef pair<int, int>  pii;
typedef pair<ll, ll>  pll;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pll>   vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;

void solve()
{
	int n;
	cin >> n;
	string c;
	cin >> c;

	int cr = 0;
	for (int i = 0; i < c.size(); i++)
	{
		if (c[i] == 'R')
			cr++;
	}
	int p = cr;
	for (int i = 0; i < cr; i++)
	{
		if (c[i] == 'R')
			p--;
	}

	cout << p << "\n";
}

int main(void)
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}


Measured memory_bytes: 3768
n = int(input())
ans = 0

if n <= 9:
    ans = n

elif 10 <= n <= 99:
    ans = 9

elif 100 <= n <= 999:
    ans = n - 90

elif 1000 <= n <= 9999:
    ans = 909

elif 10000 <= n <= 99999:
    ans = n - 9090

elif 100000 <= n <= 999999:
    ans = 90909

print(ans)


Measured memory_bytes: 2940
//Problem Y

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl "\n"
 
int main ()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #define int ll
  
  char a;
  cin >> a;
  if (a >= 'A' and a <= 'Z') cout << "A" << endl;
  else cout << "a" << endl;

  
  return 0;
  
}


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

int main()
{
    int x, y;
    cin >> x >> y;
    if(y % 2 == 0 || y % 4 == 0)
    {
        if(2*x <= y && y <= 4*x)
            cout << "Yes\n";
        else
            cout << "No\n"; 
    }
    else
    {
        cout << "No\n";
    }
    
    return 0; 
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
    string S;
    cin >> S;
    bool c = false, f = false;
    REP(i, S.length()){
        if(S.at(i) == 'C') c = true;
        if(c && S.at(i) == 'F') f = true;
    }
if(c && f) yes;
else no;
}



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

int main() {
	int a,b;
  	cin >> a >> b;
  
  	int ans = a * b;
  	 if(ans % 2 == 0) {
       cout << "Even" << endl;
     }else {
		cout << "Odd" << endl;
     }
}

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int n; cin >> n;
    int a[n], b = 1e9;
    forn(i,n) cin >> a[i];
    forsn(p,1,101){
        int s = 0;
        forn(i,n){
            int x = a[i]-p;
            s += x*x;
        }
        b = min(b,s);
    }
    cout << b << endl;
    return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    if(N%10 == 7){
        cout << YES << endl;
        return;
    }
    N /=10;
    if(N%10 == 7){
        cout << YES << endl;
        return;
    }
     N /= 10;
    
    if(N%10 == 7){
        cout << YES << endl;
        return;
    }
    cout << NO << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N =2000+10;
const int mod=1e9+7;
#define P pair<int, int>

int main()
{
    int n;
    cin>>n;
    int flag=0;
    for(int i=1;i<=9;i++)
    {
        if(n%i==0&&(n/i>=1&&n/i<=9))
            flag=1;
    }
    if(flag)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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

int main(){
  string S,T;
  cin>>S>>T;
  int N=S.size();
  for(int i=0;i<N;i++){
    bool bo=false;
    for(int j=0;j<N;j++){
      if(S[(j+i)%N]!=T[j]){
        bo=true;
        break;
      }
    }
    if(bo)
      continue;
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
void solve(int k){
	if (k==0)  re;
	if (k%26==0)  solve(k/26-1),cout<<'z';
	else  solve(k/26),cout<<char(k%26+'a'-1);
}
signed main()
{
	int n;
	cin>>n;
	solve(n);
	re 0;
}

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

int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

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

    vector<vector <int> > x(n, vector<int>(d));

    REP(i, n){
        REP(j, d){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i <= n; ++i){
        for(int j = i + 1; j < n; ++j){
            int all = 0;
            for(int k = 0; k < d; ++k){
                int diff = abs(x[i][k] - x[j][k]);
                all += diff * diff;
            }

            bool flag = false;
            for(int k = 0; k <= all; ++k){
                if(k * k == all){
                    flag = true;
                }
            }
            if(flag) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};


int main() {

	int n,m,x;
	int c[13],a[13][13];
	cin>>n>>m>>x;
	rep(i,n){
		cin>>c[i];
		rep(j,m)cin>>a[j][i];
	}

	ll ans=INF;
	rep(s,1<<n){
		ll cost=0;
		int t=0;
		int d[13]={};
		rep(i,n){
			if(s>>i&1){
				cost+=c[i];
				rep(j,m)d[j]+=a[j][i];
			}
		}
		rep(i,m){
			if(d[i]>=x)t++;
		}
		if(t==m)ans=min(ans,cost);
	}
	if(ans==INF)cout<<"-1"<<endl;
	else cout<<ans<<endl;

	return 0;
}


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

const int N = (int)1e6+7;
const int INF = (int)1e9+17;
const int mod = 998244353;

typedef long long ll;

int n;
int d[N];


inline int mul(int x, int y) {
    return 1ll * x * y % mod;
}

inline int binpow(int x, int y) {
    int ret = 1;
    while (y > 0) {
        if (y % 2 == 1) ret = mul(ret, x);
        x = mul(x, x);
        y /= 2;
    }
    return ret;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n;
    map<int,int> cnt;
    for(int i = 0; i < n; ++i) {
        cin >> d[i];
        ++cnt[d[i]];
    }
    if (d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    if (cnt[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    int mx = *max_element(d, d+n);
    for(int depth = 1; depth <= mx; ++depth) {
        if (!cnt.count(depth)) {
            cout << 0 << endl;
            return 0;
        }
        ans = mul(ans, binpow(cnt[depth - 1], cnt[depth]));
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    int n, m;
    long long k;
    cin >> n >> m >> k;
    long long asum = 0;
    vector<long long> a;
    vector<long long> b;
    long long book;
    for (int i = 0; i < n; i++){ 
        cin >> book;
        asum += book;
        a.push_back(asum);
    }
    long long bsum = 0;
    for (int i = 0; i < m; i++) {
        cin >> book;
        bsum += book;
        b.push_back(bsum);
    }
    int j = m - 1;
    while (j >= 0 && b[j] > k) {
        j--;
    }
    int sol = j + 1; 
    for (int i = 0; i < n; i++) {
        while (j >= 0 && a[i] + b[j] > k) {
            j--;
        }
        if (i + j + 2 > sol && a[i] <= k){
            sol = i + j + 2;
        }
    }
    cout << sol << endl;
}

Measured memory_bytes: 7960
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, k;

int main() {
	cin >> n >> k;
	int now = 1;
	rep(i, n) {
		now = min(now + k, 2 * now);
	}
	cout << now << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

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

    int V[N], C[N], ans=0, i;

    for (i=0; i<N; i++){
        scanf("%d", &V[i]);
    }
    for (i=0; i<N; i++){
        scanf("%d", &C[i]);
    }

    for (i=0; i<N; i++){
        if (V[i] >= C[i]){
            ans+=(V[i] - C[i]);
        }
    }


    printf("%d",  ans);

    return 0;
}

Measured memory_bytes: 128
s=0
A=int(input())
B=int(input())
C=int(input())
X=int(input())
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i+100*j+50*k==X:
        s+=1
print(s)

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

int main()
{
	int T;
	cin >> T;
	while (T--) {
		ll A, B, C, D;
		cin >> A >> B >> C >> D;
		bool ok = A >= B && D >= B;
		ll g = __gcd(B, D);
		ll tmp = C / g * g + A % g;
		while (tmp <= C) tmp += g;
		if (tmp < B) {
			ok = false;
		}
		puts(ok ? "Yes" : "No");
	}
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/agc041/tasks/agc041_a
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	if(a % 2 == b % 2) {
		cout << abs(b - a) / 2 << endl;
		return 0;
	}
	long long dist = abs(b - a);
	long long must = min({a - 1, b - 1, n - a, n - b});
	cout << must + 1 + (dist - 1) / 2 << endl;
}
	
	// 1    a=3  b=6        10
	
	// dist = 3
	// must = 2
	
	// 2 (1, 4)
	// 1 (1, 3)
	// 1


Measured memory_bytes: 256
using System;
class aoj
{
    
    static void Main()
    {
        int[] s = new int[50000];
        int o = 0;
        for (;;) 
        {
            string a = Console.ReadLine();  
            if (a == "0")
            {
                break;
            }
            int b = int.Parse(a);
            int u = o;
            int m = 0;
            int[] l = new int[b];
            int[,] c = new int[b,2];
           
            
            for (int i = 0; i < b; i++)
            {
                string d = Console.ReadLine();
                string []e = d.Split(' ');
                int f = 0, g = 0;
                f = int.Parse(e[1]);
                g = int.Parse(e[2]);        
                c[i, 0] = int.Parse(e[0]);
                c[i, 1] = f * g;
            }
            for(int i = 0; i < b; i++)
            {
                for(int j = 0; j <= i; j++)
                {
                    if (c[i, 0] == c[j, 0])
                    {
                        if (i!= j)
                        {
                            c[i, 1] += c[j, 1];
                        } 
                        if (c[i, 1] >= 1000000)
                        {
                            l[m] = c[i,0];
                            m++;
                            goto stop;
                        }
                    }
                    
                }
                stop:;
            }
            int n = m;
            bool[] h = new bool[m];
            for (int i = 0; i < m; i++)
            {
                h[i] = true;
            }
            for(int i = 0; i < m; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    if (l[i] == l[j]&&h[i])
                    {
                        h[i]=false;
                        
                        n--;
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (h[i])
                {
                    s[o] = l[i];
                    o++;
                }
            }
            if (o == u)
            {
                s[o] = -1;
                o++;
            }
        }
        for(int i = 0; i < o; i++)
        {
            if (s[i] == -1)
            {
                Console.WriteLine("NA");
            }
            else
            {
                Console.WriteLine(s[i]);
            }
        }
    }
}

Measured memory_bytes: 9312
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    double N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    double ki = 0;
    for(int i = 1; i <= N; i++) {
        if(i % 2 != 0) {
            ki++;
        }
    }

    double ans = ki / N;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main(int argc, char const *argv[]) {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll c, s, f;
    vector<ll> cList;
    vector<P> intervalList;
    while(cin >> c >> s >> f){
        cList.pb(c);
        intervalList.eb(s, f);
    }
    REP(i, cList.size()){
        ll t{0};
        t += cList[i];
        t += intervalList[i].first;
        for(ll i1 = i + 1; i1 < cList.size(); ++i1){
            if(t < intervalList[i1].first) t = (intervalList[i1].first + cList[i1]);
            else if(((t - intervalList[i1].first) % intervalList[i1].second) == 0) t += cList[i1];
            else t += (intervalList[i1].second - (t - intervalList[i1].first) % intervalList[i1].second + cList[i1]);
        }
        cout << t << endl;
    }
    cout << "0" << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

value = 0
for i in range(N):
    if V[i] - C[i] > 0:
        value += V[i] - C[i]

print(value)


Measured memory_bytes: 9116