akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int n; vector<int> v;
int dp[3002][3002][2];
int solve(int l,int r,int p){
   if(l==r)return v[l];
   if(dp[l][r][p%2]!=-1e18)return dp[l][r][p%2];
   int ans=-1e18;
   ans=max(ans,v[l]-solve(l+1,r,p+1));
   ans=max(ans,v[r]-solve(l,r-1,p+1));
   dp[l][r][p%2]=ans;
   //cout<<ans<<"\n";
   return ans;
}
int32_t main(){
   cin>>n;
   rep(i,0,n+1)rep(j,0,n+1)dp[i][j][0]=-1e18,dp[i][j][1]=-1e18;
   rep(i,0,n){
      int t; cin>>t;
      v.pub(t);
   }
   cout<<solve(0,n-1,0)<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 144616
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li2(N)
B = li2(N)

A = sorted(A, key=lambda x:x[1])
B = sorted(B, key=lambda x:x[0])

flag = [0] * N

for i in range(N):
    ind = -1
    for j in range(N):
        if A[j][1] < B[i][1]:
            ind = j
    while ind >= 0:
        if not flag[ind] and A[ind][0] < B[i][0]:
            flag[ind] = 1
            break
        ind -= 1

#print(flag)
print(sum(flag))

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];

    if(n%2){
        sort(ALL(a));sort(ALL(b));
        ll ans=max(0ll,b[n/2]-a[n/2]+1);
        cout<<ans<<endl;
    }else{
        sort(ALL(a));sort(ALL(b));
        ll ans=max(0ll,1+(b[n/2]+b[n/2-1])-(a[n/2]+a[n/2-1]));
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 6348
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *
import queue

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N, M = In.ints()

if M==0:
    Out.int(1)
else:
    conns = [set() for i in range(N)]
    for i in range(M):
        A, B = In.ints()

        A-=1
        B-=1

        if B not in conns[A]:
            conns[A].add(B)
        if A not in conns[B]:
            conns[B].add(A)
    
    ans = 0
    seen = set()
    for i in range(N):        
        if len(conns[i])==0:            
            continue
        
        if i not in seen:
            seen.add(i)

            #dfs
            stck = deque([(i)])
            ct = 1
            while len(stck)>0:
                now = stck.popleft()
                
                for nex in conns[now]:
                    if nex not in seen:
                        ct+=1
                        seen.add(nex)
                        ans = max(ans, ct)
                        stck.append(nex)
                    

    Out.int(ans)
        




######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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 main(){

    int n, m;
    cin >> n >> m;
    int L, R;
    L = 0;
    R = INF;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        L = max(L, l);
        R = min(R, r);
    }
    if(R-L+1 > 0) cout << R-L+1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<cstdlib>
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<vector>
#define MAXN 1000
using namespace std;
typedef long long ll;
ll cnt;
char mats[300][300];
int main() {
	ios::sync_with_stdio(false);
	//freopen("../in", "r", stdin);
//	freopen("../out", "w", stdout);
	cin >> cnt;
	for (ll i = 0; i < cnt; i++) {
		cin >> mats[i];
		ll sum = 0;
		for (ll j = 0; mats[i][j] != '\0'; j++) {
			if (mats[i][j] == '1')
				sum++;
			mats[i][j] -= '0';
		}
	}
	ll ans=0;
	for(ll i=0;i<cnt;i++)
	{
		vector<ll>dis(cnt,-1);
		vector<ll>que(1,i);
		dis[i]=0;
		for(ll j=0;j<ll(que.size());j++)
		{
			for(ll k=0;k<cnt;k++)
			{
				if(mats[que[j]][k]&&dis[k]==-1)
				{
					dis[k]=dis[que[j]]+1;
					que.push_back(k);
				}
			}
		}
		for(ll j=0;j<cnt;j++)
			for(ll k=0;k<cnt;k++)
			{
				if(dis[j]==dis[k]&&mats[j][k])
					ans=-2;
			}
		if(ans==-2)
			break;
		ll max_dis=*max_element(dis.begin(),dis.end());
		ans=max(max_dis,ans);
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 512
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "number", long, "times");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto numbers = aryread();
    long[long] ary;
    foreach (e; numbers)
    {
        ary[e]++;
    }
    numbers.length -= numbers.sort().uniq.copy(numbers).length;
    long rm;
    foreach (e; numbers)
    {
        if(e > ary[e])
            rm += ary[e];
        else
            rm += ary[e] - e;
    }
    rm.writeln();
}

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

int main()
{
  int n, sum;

  sum = 0;
  for (int i = 0; i <= 3; i++){
    cin >> n;
    sum += n;
  }

  cout << sum / 60 << "\n" << sum % 60 << endl;

  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char s[1000];
    int a,b,i,c;
    while(~scanf("%s",s))
    {
        b=0;
        a=strlen(s);
        for(i=0;i<a;i++)
        {
            if(s[i]=='+')
                b=b+1;
            else
                b=b-1;
        }
        printf("%d\n",b);
    }
    return 0;
}


Measured memory_bytes: 128
//কী পেয়েছো তুমি, কী চেয়েছিলে তুমি.? হিসেবটা তোমার বড়ই গড়মিল...!!//
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
string ch="abcdefghijklmnopqrstuvwxyz";
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    map<int,int>mp;
    mp.clear();
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        mp[x]++;
    }
    for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
        if(mp[it->first]>1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}



Measured memory_bytes: 9600
n, m, _x, _y = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)

((_x + 1).._y).each do |z|
  if x.max < z && y.min >= z
    puts 'No War'
    exit
  end
end

puts 'War'


Measured memory_bytes: 1788
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:sum(x), reverse=True)
tk = 0
ak = 0
for i, (a, b) in enumerate(AB):
    if i % 2 == 0:
        tk += a
    else:
        ak += b
print(tk-ak)

Measured memory_bytes: 32224
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

char c[200010] ;

int main()
{
	int n ;
	scanf ("%d%s", &n, c) ;
	
	int i = 0 ;
	int j = n-1 ;
	int ans = 0 ;
	while (i < j)
	{
		while (c[i] == 'R') i++ ;
		while (c[j] == 'W') j-- ;
		if (i < j)
		{
			ans++ ;
			i++ ;
			j-- ;
		}
	}
	
	cout << ans << endl ;

	return 0 ;
}

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


namespace Test1 {

    


    class ClassMain {


        //size [n+1, n+1]
        public static int[,] map = new int[0, 0];
        //len = n+1
        public static int maxDepth = -1;




        public static void dfs(int y, int x, int depth) {
            if (map[y, x] == 0) { return; }
            map[y, x] = 0; depth++;
            maxDepth = Math.Max(depth, maxDepth);
            if (y > 0) { dfs(y - 1, x, depth); }
            if (y < map.GetLength(0) - 1) { dfs(y + 1, x, depth); }
            if (x > 0) { dfs(y, x-1, depth); }
            if (x < map.GetLength(1) - 1) { dfs(y, x+1, depth); }
            map[y, x] = 1;
        }


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = int.Parse(line);
                //int n = ints[0]; int k = ints[1];
                int m = int.Parse(Console.ReadLine());
                if (n == 0) { break; }

                map=new int[m,n];
                maxDepth = 0;
                for (int i = 0; i < m; i++) {
                    int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    for (int j = 0; j < n; j++) {
                        map[i, j] = ints[j];
                    }
                }
                for (int i = 0; i < m; i++) {
                    for (int j = 0; j < n; j++) {
                        if (map[i, j] == 0) { continue; }
                        dfs(i, j,0);
                    }
                }
                Console.WriteLine(maxDepth);

            }
            
        }

        
    }

    

    
}

Measured memory_bytes: 6216
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100100;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
int main(){
  ll K,N1,M1,N2,M2;
  cin  >> N1 >> M1 >> N2 >> M2 >> K;
  ll ans = N2 * 60 + M2 - N1 * 60 - M1  - K;
  cout << ans << endl;
  
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 1000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    string s;
    cin >> s;
    int m;
    m = stoi(s.substr(5,2));
    if(m>4){
        cout << "TBD" << endl;    
    }else{
        cout << "Heisei" << endl;
    }
} 

Measured memory_bytes: 256
#include <cstdio>
#define ll long long
ll gcd(ll a, ll b){
	while (b) b ^= a ^= b ^= a %= b;
	return a;
}
int main(){
	ll a, b;
	scanf("%lld %lld", &a, &b);
	ll g = gcd(a, b), c = 1;
	for (ll i = 2; i <= 1000000; i++){
		if (g % i == 0){
			c++;
			while (g % i == 0) g /= i;
			if (g == 1) break;
		}
	}
	if (g != 1) c++;
	printf("%lld\n", c);
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var b string
	fmt.Scan(&b)

	var ans string
	switch b {
	case "A":
		ans = "T"
	case "T":
		ans = "A"
	case "C":
		ans = "G"
	case "G":
		ans = "C"
	}

	fmt.Printf("%s\n", ans)
}


Measured memory_bytes: 512
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
int a,b,c,d,e,f,ans1,ans2;
double ans=-1;
bool equ(double x,double y){
	return fabs(x-y)<1e-9;
}
int main(){
	cin>>a>>b>>c>>d>>e>>f;
	a*=100,b*=100;
	for(int i=0;a*i<=f;i++){
		for(int j=0;a*i+b*j<=f;j++){
			if(i+j){
				for(int k=0;k*c+a*i+b*j<=f;k++){
					for(int l=0;l*d+k*c+a*i+b*j<=f;l++){
						int fm=l*d+k*c+a*i+b*j,fz=l*d+k*c;
						if((double)fz/fm>ans&&((double)fz/fm<=(double)e/(e+100)||equ((double)fz/fm,(double)e/(e+100)))){
							ans=(double)fz/fm;
							ans1=fm,ans2=fz;
							if(ans1==310){
								int x=1;
							}
						}
					}
				}
			}
		}
	}
	cout<<ans1<<" "<<ans2<<endl;
}

Measured memory_bytes: 256
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,m=0,k=0,x=0,res=0;
    cin>>n>>m;
    vector<int> v[m];
    for(int i=0;i<m;++i)
    {
        cin>>k;
        for(int j=0;j<k;++j)
        {
            cin>>x;
            --x;
            v[i].pb(x);
        }
    }
    int p[m];
    for(int i=0;i<m;++i)
        cin>>p[i];
    for(int i=0;i<(1<<n);++i)
    {
        bool flag=true;
        for(int j=0;j<m;++j)
        {
            int ct=0;
            for(auto x: v[j])
            {
                if((i>>x)&1)
                    ++ct;
            }
            if(p[j]!=(ct%2))
            {
                flag=false;break;
            }
        }
        if(flag)
            ++res;
    }
    cout<<res<<endl;
}

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

# aの倍数をbで割ったときに余りがcになればよい
first = a % b
if first == c:
  print("YES")
  exit()

count = 2
while True:
  amari = (count*a) % b
  if amari == first:
    print("NO")
    exit()
  if amari == c:
    print("YES")
    exit()
  else:
    count+=1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 n, a, b;
  cin >> n >> a >> b;
  vector<i64> h(n);
  i64 hmax = 0;
  REP(i, n) {
    cin >> h[i];
    hmax = max(hmax, h[i]);
  }

  i64 gap = a - b;
  auto check = [&](i64 cnt) -> bool {
    i64 acnt = 0;
    REP(i, n) {
      i64 rest = h[i] - b * cnt;
      if (rest <= 0) continue;
      acnt += (rest + gap - 1) / gap;
      if (acnt > cnt) return false;
    }
    return true;
  };

  i64 ng = -1, ok = hmax / b + 1;
  while (ok - ng > 1) {
    i64 mid = (ok + ng) / 2;
    if (check(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok << endl;
}

Measured memory_bytes: 3984
#include <stdio.h>
int main(void){
    
    
   
    int a;
    int b, r, tmp;
        
    
    while(1){
	
    int k=1;

	scanf("%d %d", &a, &b);
	if(a == 0 && b == 0) break;
    
    if(a<b){ 
    tmp = a; 
    a = b; 
    b = tmp; 
    }
    
   
    
    r = a % b; 

    while(r!=0){ 
    a = b; 
    b = r; 
    r = a % b;
    k++;
    } 
    
    printf("%d %d\n",b,k); 
    
    }
    
    return 0; 


} 



Measured memory_bytes: 2028
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 1012345678;
map<long long, int> d;
int n, cur, p[2209]; bool prime[2209]; long long a[100009];
int square_root(long long x) {
	int l = 0, r = 100009;
	while (r - l > 1) {
		int m = (l + r) >> 1;
		if (1LL * m * m >= x) r = m;
		else l = m;
	}
	return r;
}
int main() {
	for (int i = 2; i <= 2200; i++) prime[i] = true;
	for (int i = 2; i <= 2200; i++) {
		if (prime[i]) {
			for (int j = i * 2; j <= 2200; j += i) {
				prime[j] = false;
			}
		}
	}
	for (int i = 2; i <= 2200; i++) {
		if (prime[i]) p[cur++] = i;
	}
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j < cur; j++) {
			while (a[i] % (1LL * p[j] * p[j] * p[j]) == 0) {
				a[i] /= p[j];
				a[i] /= p[j];
				a[i] /= p[j];
			}
		}
		d[a[i]]++;
	}
	map<long long, int> d2 = d;
	int ret = 0;
	for (pair<long long, int> i : d) {
		if (i.first == 1) {
			ret++;
			continue;
		}
		long long x = i.first, inv = 1; int score = i.second;
		for (int j = 0; j < cur; j++) {
			if (x % p[j] == 0) {
				if (inv > inf) break;
				inv *= p[j];
				x /= p[j];
				if (x % p[j] == 0) {
					x /= p[j];
				}
				else if(inv <= inf) {
					inv *= p[j];
				}
				else break;
			}
		}
		int val = square_root(x);
		if (1LL * val * val == x) {
			x = 1;
			if(inv <= inf) inv *= val;
		}
		else {
			if (x >= inf) inv = inf;
			else {
				if (inv <= inf) inv *= x;
				if (inv <= inf) inv *= x;
			}
			x = 1;
		}
		if(d2[inv] == 0 || i.first < inv) ret += max(score, d2[inv]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 18816
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  string str;
  cin >> n >> a >> b >> str;
  int passed = 0, oversea = 0;
  for (auto i = 0; i < n; i++) {
    if (str[i] == 'a' && passed < a + b) {
      cout << "Yes" << endl;
      passed++;
    } else if (str[i] == 'b' && passed < a + b && oversea + 1 <= b) {
      cout << "Yes" << endl;
      passed++;
      oversea++;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define mod 1000000007
#define w while
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int,int>
#define pl pair<ll,ll>
long double PI=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	fr(i,1,n)
	cin>>a[i];
	int sum=0;
	sort(a+1,a+n+1);
	fr(i,1,k)
	sum+=a[i];
	cout<<sum;
    return 0;
}





Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a[5],k;
int a_min=INF,a_max=mINF;
REP(i,5) {
  cin >> a[i];
  a_min = min(a_min,a[i]);
  a_max = max(a_max,a[i]);
}
cin >> k;
if(a_max-a_min<=k) {
  cout << "Yay!" << endl;
} else {
  cout << ":(" << endl;
}
return 0;
}


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


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

int ans = 0;

if(k <= a){
    ans = k;
}
if(k > a && k <= b){
    ans = k;
}
if(k > b){
    ans = 2*a+b-k;
}

cout << ans << endl;



}



Measured memory_bytes: 3676
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		System.out.println(Main.calc(s.nextInt(), s.nextInt()));
	}

	public static int calc(int x, int a) {

		return (x<a)?0:10;
	}
}

Measured memory_bytes: 22100
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const n: number = +input[0];
const p: number[] = input[1].split(' ').map((x: string): number => +x);

let temp:number = 0;

for(let i = 0; i < n; i++){
    if(p[i] !== i+1){
        temp++;
    }
}

if(temp <= 2){
    console.log('YES');
}else{
    console.log('NO');
}

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

int main()
{

	ll n,m,a,b,sum=0;
	vector<pair<ll,ll>>v;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		v.push_back(make_pair(a,b));
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++)
	{
		if(m)
		{
			sum+=min(m,v[i].second)*v[i].first;
			m-=min(m,v[i].second);
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
  long int X;
  cin >> X;
  
  long int balance=100;
  int i=1;
  while(true){
    balance = static_cast<long int>(balance*1.01);
    if(balance>=X){
      cout << i << endl;
      break;
    }
    i++;
  }
}


Measured memory_bytes: 3636
#include <stdio.h>

int main (){
  int n, i, j=0;
  scanf("%d\n", &n);
  int A[n];
  for (i=0; i<n; i++) scanf("%d\n", &A[i]);
  for(i=0; i<n; i++){
    if (A[i]%2==0){
      if (A[i]%5!=0 && A[i]%3 != 0){
           printf("DENIED\n");
           break;
      }
      else j++;
    }
    else j++;

  }
  if (j == n){
    printf("APPROVED\n");
  }
  return 0;
}

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

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;
    rep(i, n) {
        for (int j = i+1; j < n; ++j) {
            int l = 0;
            rep(k, d) l += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            int length = sqrt((double)l);
            if (length * length == l) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Your code here!
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main(){
    let nums:Vec<i32> = read_vec();
    
    if (nums[0]>9) || (nums[1]>9) {
        println!("{}",-1)
    }
    else {
        println!("{}",nums[0]*nums[1])
    }
    
    
}




Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define eb emplace_back
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using D=long double;
using P=pair<ll,ll>;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a[32]={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};
	int k;cin>>k;--k;
	cout<<a[k]<<endl;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::collections::VecDeque;



fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn recur(x : u64) -> u64 {
    if x == 1 {return 1;}
    let xx = recur(x/2);
    return 1 + xx * 2;
}

fn main() {
    let x : u64 = get_one();
    println!("{}", recur(x));
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	int w,h,x,y;
	while(~scanf("%d%d%d%d",&w,&h,&x,&y))
	{
		double z1,z2;
		z1=w/2.0;
		z2=h/2.0;
		if(x==z1&&y==z2)
		printf("%lf %d\n",double(w)*double(h)/2,1);
		else
		printf("%lf %d\n",double(w)*double(h)/2,0);
	}
}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define pb push_back
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define ccM 1000000007
#define cfM 998244353;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main()
{   fastio;
    int n;
    cin>>n;
    map<string , int>mp;
    for(int i=0; i<n; i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size()<<endl;
}

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

using namespace std;
const int N=107;

int n, m, k, t;
int a[N]; 

int main() {
	scanf("%d %d", &n, &m);
	for(int i=1; i<=n; i++) {
		scanf("%d", &k); 
		for(int j=1; j<=k; j++) {
			scanf("%d", &t);
			a[t]++;
		}
	}
	int ans=0;
	for(int i=1; i<=m; i++) if (a[i]==n) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        sc.nextLine();
        int[] b = new int[a];
        for(int i = 0;i<a;i++){
            b[i] = sc.nextInt();
        }
        int go = b[0];
        int flag = 0;
        int count = 0;
        for(int i = 0;i<a;i++){
            ++count;
            if(go == 2){
                flag = 1;
                break;
            }
            go = b[go-1];
        }
        if(flag == 1){
            System.out.println(count);
        }else{
            System.out.println(-1);
        }
    }
}

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

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int N; cin >> N;
	int cnt[20][20];
	memset(cnt, 0, sizeof(cnt));
	int64_t ans = 0;
	for (int z = 0; z < N; z++) {
		string a; cin >> a;
		if (a.find('.') == string::npos) a += '.';
		int dot_ind = int(a.find('.'));
		while (int(a.size()) - dot_ind - 1 < 9) {
			a += '0';
		}
		assert(dot_ind == int(a.size()) - 9 - 1);
		a.erase(a.begin()+dot_ind);
		int64_t v = stoll(a);
		assert(v);
		int num_2 = -9;
		int num_5 = -9;
		for (; v % 2 == 0; v /= 2) num_2++;
		for (; v % 5 == 0; v /= 5) num_5++;
		num_2 = min(num_2, 9);
		num_5 = min(num_5, 9);

		for (int i = -num_2; i <= 9; i++) {
			for (int j = -num_5; j <= 9; j++) {
				ans += cnt[i+9][j+9];
			}
		}
		cnt[num_2+9][num_5+9]++;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
int main() {
	long long a,b,k;

	cin >>a>>b>>k;
	if (k>a){
		k-=a;
		a=0;
		if (k >b)b=0;
		else b=b-k;
	}
	else{
		a-=k;
	}
	cout << a<< " " << b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  long n,m,l;
  cin >> n >> m >> l;
  long a[n][m];
  long b[m][l];
  long c[n][l] ;
  //c[n][l] の初期化
  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      c[i][j] = 0;
    }
  }
   //行列a 受け取り
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  //行列b 受け取り
  for(int j = 0; j < m; j++){
    for(int k = 0; k < l; k++){
      cin >> b[j][k];
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      for(int k = 0; k < l; k++){
       c[i][k] += a[i][j] * b[j][k];
      }
    }
  }
  for(int i = 0; i < n; i++){
    for(int k = 0; k < l; k++){
      if(k != l-1)cout << c[i][k] << ' ';
      else cout << c[i][k] << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3292
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();
        int lose = 0;
        string ans = "YES";
        for(int i = 0; i < S.Length; i++)
        {
            if (S[i] == 'x')
            {
                lose++;
            }
        }
        if (lose > 7)
        {
            ans = "NO";
        }

        Console.WriteLine(ans);
    }

}



Measured memory_bytes: 11092
using System;

public class Answer {
    private static void Main(string[] args) {
        string input = Console.ReadLine();
        string output = GetAnswer(input);

        Console.WriteLine(output);
    }

    private static string GetAnswer(string input) {
        string output = "";
        int area = 0;
        int circumference = 0;

        int depth = int.Parse(input.Split(' ')[0]);
        int width = int.Parse(input.Split(' ')[1]);

        area = depth * width;
        circumference = (depth + width) * 2;

        output = $"{area} {circumference}";

        return output;
    }
}


Measured memory_bytes: 15976
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
    if( a=='H' && b=='H')
        printf("H");
    else if(a=='D' && b =='D')
        printf("H");
        else
            printf("D");

   return 0;
}


Measured memory_bytes: 128
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=190;
int n,m;
char c[maxn][maxn];
int valr[maxn][maxn][maxn],valc[maxn][maxn][maxn],sum[maxn][maxn];

bool valid(int x1,int y1,int x2,int y2){
	int tmp=sum[x2][y2]-(!x1?0:sum[x1-1][y2])-(!y1?0:sum[x2][y1-1])+((!x1||!y1)?0:sum[x1-1][y1-1]);
	return !tmp||(tmp==(x2-x1+1)*(y2-y1+1));
} 

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%d",&n,&m);
	rep(i,n){
		scanf("%s",c[i]);
		rep(j,m){
			sum[i][j]=c[i][j]=='#';
			sum[i][j]+=(!i?0:sum[i-1][j])+(!j?0:sum[i][j-1])-((!i||!j)?0:sum[i-1][j-1]);
		}
	}
	rep(r1,n)for(int r2=r1;r2<n;r2++){
		int c2=0;
		rep(c1,m){
			c2=max(c2,c1);
			while(c2<m&&valid(r1,c1,r2,c2))c2++;
			valr[r1][r2][c1]=c2-1;
		}
	} 
	rep(c1,m)for(int c2=c1;c2<m;c2++){
		int r2=0;
		rep(r1,n){
			r2=max(r2,r1);
			while(r2<n&&valid(r1,c1,r2,c2))r2++;
			valc[c1][c2][r1]=r2-1;
		}
	}
	if(valid(0,0,n-1,m-1)){
		puts("0");
		return 0;
	}
	for(int ans=1;;ans++){
		rep(r1,n)for(int r2=r1;r2<n;r2++){
			rep(c1,m){
				int &cur=valr[r1][r2][c1];
				if(cur+1<m)cur=valr[r1][r2][cur+1];
			}
		}
		rep(c1,m)for(int c2=c1;c2<m;c2++){
			rep(r1,n){
				int &cur=valc[c1][c2][r1];
				if(cur+1<n)cur=valc[c1][c2][cur+1];
			}
		}
		rep(c1,m)rep(r1,n){
			int r2=n-1;
			for(int c2=c1;c2<m;c2++){
				while(r2>=r1&&valr[r1][r2][c1]<c2)r2--;
				valc[c1][c2][r1]=max(valc[c1][c2][r1],r2);
			}
		}
		rep(r1,n)rep(c1,m){
			int c2=m-1;
			for(int r2=r1;r2<n;r2++){
				while(c2>=c1&&valc[c1][c2][r1]<r2)c2--;
				valr[r1][r2][c1]=max(valr[r1][r2][c1],c2);
			}
		}
//		rep(r1,n)for(int r2=r1;r2<n;r2++)rep(c1,m)cout<<r1<<" "<<r2<<" "<<c1<<" "<<valr[r1][r2][c1]<<endl;
//		rep(c1,m)for(int c2=c1;c2<m;c2++)rep(r1,n)cout<<c1<<" "<<c2<<" "<<r1<<" "<<valc[c1][c2][r1]<<endl; 
		if(valr[0][n-1][0]==m-1){
			printf("%d\n",ans);
			return 0;
		}
	}
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}



void func_to_create(){
    uint64_t N;
    cin >> N ;
    std:vector<uint64_t> left_bound;
    std::vector<uint64_t> right_bound;
    left_bound.reserve(N);
    right_bound.reserve(N);
    while(N--){
        uint64_t a, b;
        cin >> a >> b;
        //add it to vector
        left_bound.push_back(a);
        right_bound.push_back(b);
    }
    //sort for fast search
    std::sort(left_bound.begin(), left_bound.end());
    std::sort(right_bound.begin(), right_bound.end());
    N = left_bound.size();
    uint64_t start_point = left_bound[(N - 1)/2] + left_bound[N/2];
    uint64_t end_point = right_bound[(N-1) / 2] + right_bound[N/2];
    uint64_t ans;
    if(N % 2){
        ans = (end_point - start_point) / 2 + 1;
    }else{
        ans = end_point - start_point + 1;

    }
    cout <<  ans << endl;
    
}
int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 4;
    while(TEST_CASES--){
    #endif // DEBBUG

    func_to_create();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 6368
#include<cstdio>

using namespace std;

int nums[100001];
int availables[] = {6, 6*6, 6*6*6, 6*6*6*6, 6*6*6*6*6, 6*6*6*6*6*6,
                    9, 9*9, 9*9*9, 9*9*9*9, 9*9*9*9*9, 1};


int search(int i) {
    if(i == 0) return 0;
    if(nums[i]) {
        return nums[i];
    }
    int min = 100000;
    for(int x = 0; x < 12; ++x) {
        if(availables[x] <= i) {
            int t = search(i-availables[x]) + 1;
            if(t < min) min = t;
        }
    }
    nums[i] = min;
    return min;
}


int main() {
    int N;
    scanf("%d", &N);
    printf("%d\n", search(N));

    return 0;
}


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

int main(){
  int n;

  while(cin >> n ,n){
    int cnt = 0;
    while(n != 1){
      cnt++;
      if(n %2 == 0){
	n /= 2;
      }
      else{
	n *= 3;
	n++;
      }
    }
    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,k;
    int ans=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        ans=fmin(ans*2,ans+k);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 1e3+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const int MOD = 1e9+7;


vector<string> city;
map<string,set<pii>> mp; 
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		string x;
		cin>>x;
		int cost;
		scanf("%d",&cost);
		mp[x].insert(pii(-cost,i));
	}
	for(auto it = mp.begin();it!=mp.end();it++)
	{
		set<pii> H = it->second;
		for(auto it:H)
		{
			int ans = it.second;
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a, b, h;

    cin >> a >> b >> h;

    cout << ((a + b) * h) / 2 << endl;

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int a[2][n];
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    int ans[2][n];
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            if(i==0&&j==0){
                ans[i][j]=a[0][0];
            }else if(i==0){
                ans[i][j]=ans[0][j-1]+a[0][j];
            }else{
                if(ans[i-1][j]>=ans[i][j-1]){
                    ans[i][j]=ans[i-1][j]+a[i][j];
                }else if(i==1&&j==0){
                    ans[i][j]=a[0][0]+a[1][0];
                }else{
                    ans[i][j]=ans[i][j-1]+a[i][j];
                }
            }
        }
    }
    cout<<ans[1][n-1]<<endl;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
typedef struct{ll to;ll cost;} Graphs;
typedef V<V<Graphs>> AdjList;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
   
  int n;
  cin>>n;
  cinv(n,p);

  int ans=0;
  rep(i,n-2){
    VL a(3);
    a[0]=p[i];a[1]=p[i+1];a[2]=p[i+2];
    SORT(a);
    if(a[1]==p[i+1])ans++;
  }
  out(ans);
  


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll X;
	cin >> X;

	auto ans = X / 500 * 1000;
	X %= 500;
	ans += X / 5 * 5;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] X = new long[N+10];
    long[] copy = new long[N+10];
    for(int i =1;i<=N;i++){
      X[i] = sc.nextLong();
      copy[i] = X[i];
    }
    quickSort(X,1,N);
    long C1 = X[N/2];
    long C2 = X[N/2+1];

    for(int i =1;i<=N;i++){
      if(copy[i]<=C1){
        System.out.println(C2);
      }else if(copy[i]>=C2){
      System.out.println(C1);
      }
    }
    sc.close();
  }
  
 public static void quickSort(long[] array, int left, int right) {
        int curleft = left;
        int curright = right;
        long pivot = array[(curleft + curright) / 2];
        
        do {
            while (array[curleft] < pivot) {
                curleft++;
            }
            
            while (array[curright] > pivot) {
                curright--;
            }
            if (curleft <= curright) {
                swap (array, curleft++, curright--);
            }
        } while (curleft <= curright);
        
        if (left < curright) {
            quickSort(array, left, curright);
        }
        
        if (curleft < right) {
            quickSort(array, curleft, right);
        }
    }
    
    private static void swap (long[] array, int idx1, int idx2) {
        long tmp = array[idx1];
        array[idx1] = array[idx2];
        array[idx2] = tmp;
    }
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

/* debugging */
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int32_t main(){
    boost;

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt" , "r" , stdin); 
    // freopen("output.txt" , "w", stdout);
    // #endif
    
    //code
    int x , a;
    cin >> x >> a;
    cout << ((x < a ) ? 0 : 10);

    return 0;
}

Measured memory_bytes: 256