akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
#define INF 1e9
using ll = int64_t;
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;
}
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define MAX_NUM 1000

void Main() {
  //自動整形防止用コメント
  string s;
  cin >> s;

  while (!s.empty())
  {
    s.erase(s.end() - 1);

    string left_str, right_str;
    rep(i, s.size()/2)
    {
      left_str += s[i];
    }
    repf(i, s.size() / 2, s.size())
    {
      right_str += s[i];
    }

    if (left_str == right_str)
    {
      std::cout << s.size() << std::endl;
      return;
    }
  }
  
  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
///***Bismillahir Rahmanir Rahim***///
///*********************************///
///******Ashraful Haque Toni********///
///********Dept. of CSE,JnU*********///
///email:ashrafulhaquetoni@gmail.com///
///*******contact:01640690531*******///
///*********************************///


#include<bits/stdc++.h>

using namespace std;

#define         ash               ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         pb                push_back
#define         mp                make_pair
#define         I1(n)             cin>>n
#define         I2(m,n)           cin>>m>>n;
#define         I3(m,n,o)         cin>>m>>n>>o;
#define         sc(n)             scanf("%d",&n);
#define         scl(n)            scanf("%I64d",&n);
#define         sc2(m,n)          scanf("%d%d",&m,&n);
#define         sc2l(m,n)         scanf("%I64d%I64d",&m,&n);
#define         pf                printf
#define         f(i,n)            for(ll i=0;i<(n);i++)
#define         f1(i,n)           for(ll i=1;i<=(n);i++)
#define         ar_input(a,n)     f(i,n)cin>>a[i];
#define         ve_input(v,n)     f(i,n){ll m;cin>>m,v.pb(m);}
#define         Max               INT_MAX
#define         Min               INT_MIN
#define         pi                acos(-1.0)
#define         Mem(a,val)        memset(a,val,sizeof(a));
#define         asort(a,n)        sort(a,a+n)
#define         vsort(v)          sort(v.begin(),v.end())
#define         fr(i,s,e)         for(ll i=s;i<=e;i++)
#define         ff                first
#define         ss                second
#define         vec               vector<ll>
#define         pai               pair<ll,ll>
#define         Map               map<ll,ll>
#define         mod               1000000007
#define         ll                long long
#define         PC(i)             cout<<"Case "<<i<<": ";


                               ///template function///

///ll GCD(ll a,ll b){if(a<0) a*=-1;if(b<0) b*=-1;if(a<b)swap(a,b);if(b==1) return 1;if(!b) return a;if(!(a%b)) return b;else return GCD(b,a%b);}
///ll LCM(ll a,ll b){ll x=GCD(a,b);return (a/x)*b;}
///ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
///ll modinverse(ll n){return bigmod(n,mod-2)%mod;}
///ll num_coprime(ll n){ll ans=n;for(ll i=2;i*i<=n; i++){if(n%i==0){while(n%i==0)n/=i;ans-=ans/i;}}if(n>1)ans-=ans/n;return ans;}
///set<ll>s;void divisors(ll n){f1(i,sqrt(n))if(n%i==0){s.insert(i);s.insert(n/i);}}
///ll mod_inverse(ll a,ll m){ll mm=m,y=0,x=1;while(a>1){ll q=a/m;ll t=m;m=a%m;a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=mm;return x;}


///*********************************************start***********************************************///







int main()
{
    //freopen("1014.txt","r",stdin);

    ash;
    ll a,b;
    I2(a,b);
    if((a+b)%2==0){
        cout<<(a+b)/2<<endl;
    }
    else{
        cout<<"IMPOSSIBLE\n";

    }





    return 0;
}

///**********************************************end*************************************************///


Measured memory_bytes: 256
#辞書型でリトライ
N,K = map(int, input().split(' '))
A = input().split(' ')

dic = {}
for a in range(len(A)):
    tmp = A[a]
    if not tmp in dic:
        dic[tmp] = 1
    else:
        dic[tmp] += 1

values = sorted(dic.values())
ans = 0
if len(values)<=K:
    pass
else:
    tmp = len(values)-K
    values = values[:tmp]
    ans = sum(values)

print(ans)

Measured memory_bytes: 39296
n, a, b = map(int, input().split())
mod = 10**9+7
total = pow(2, n, mod) - 1

def choose(n, r):
    res = 1
    fac = 1
    for i in range(r):
        res *= n-i
        res %= mod
        fac *= i+1
        fac %= mod
    return res*pow(fac, mod-2, mod)%mod

for i in [a, b]:
    total -= choose(n, i)

print(total%mod)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	static int maxResult(int[] prices) {
		int[] table = new int[prices.length];

		int max = prices[1] - prices[0];
		for(int i = 1; i < table.length; i++) {
			int optionOne = prices[i] - prices[i-1];
			int optionTwo = prices[i] - prices[i-1] + table[i-1];
			table[i] = Math.max(optionOne, optionTwo);
			
			if(table[i] > max) {
				max = table[i];
			}
		}
		return max;
	

	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n;
		n = in.nextInt();
		int[] prices = new int[n];
		for(int i = 0; i < n; i++) {
			prices[i] = in.nextInt();
		}
		System.out.println(maxResult(prices));
		in.close();
	}
}


Measured memory_bytes: 101264
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
typedef array<LL,3> A;


vector<A> ps[50];
LL cs[50];
LL ds[50];
LL dist[50][2501];
const LL inf=1LL<<60;
const LL U=2500;
int main(){
	LL N,M,S;
	cin >> N >> M >> S;
	S=min(S,U);
	for(int i=0;i<M;i++){
		int u,v,a,b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		ps[u].push_back(A{{v,a,b}});
		ps[v].push_back(A{{u,a,b}});
	}
	for(int i=0;i<N;i++){
		cin >> cs[i] >> ds[i];
	}
	priority_queue<A,vector<A>,greater<A> > pq;
	for(int i=0;i<N;i++){
		for(int j=0;j<2501;j++){
			dist[i][j]=inf;
		}
	}
	dist[0][S]=0;
	pq.push(A{{0,0,S}});
	while(pq.size()){
		auto t=pq.top();
		pq.pop();
		LL d=t[0];
		LL v=t[1];
		LL c=t[2];
		if(dist[v][c]<d){
			continue;
		}
		//cerr << d << ", " << v << ", " << c << endl;
		for(auto p:ps[v]){
			LL d2=d+p[2];
			LL c2=c-p[1];
			LL v2=p[0];
			if(c2>=0&&dist[v2][c2]>d2){
				dist[v2][c2]=d2;
				pq.push(A{{d2,v2,c2}});
			}
		}
		{
			LL c2=min(c+cs[v],U);
			LL d2=d+ds[v];
			if(dist[v][c2]>d2){
				dist[v][c2]=d2;
				pq.push(A{{d2,v,c2}});
			}
		}
	}
	for(int i=1;i<N;i++){
		LL r=inf;
		for(int j=0;j<=2500;j++){
			r=min(r,dist[i][j]);
		}
		cout << r << endl;
	}

    return 0;
}


Measured memory_bytes: 6860
#include<iostream>
int main(){
  int u,k,C,V,A[1000][1000],D[1000][1000],n;
  std::cin >> n;
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j] = 200001;
  for(int i=0;i<n;i++){ 
    std::cin >> u >> k;
    for(int j=0;j<k;j++){
      std::cin >> V >> C;
      D[u][V] = C;
    } 
  }
  for(int i=0;i<n;i++)D[i][i] = 0;
  for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j]= std::min(D[i][j],D[i][k] + D[k][j]);
  for(int i=0;i<n;i++)std::cout << i << " " << D[0][i] << std::endl;
  return 0;
}

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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define FF(i,x,n,y) for(int i=x;i>=n;i-=y)
#define fa(x,y) for(auto x:y)

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int a,b;
    cin>>a>>b;
    if(a<b) cout<<"0";
    else cout<<"10";
    return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int mod=1000000007;
int f[42][1<<18],n,x,y,z,i,j,k,lim,tmp;
signed main()
{
	cin>>n>>x>>y>>z;
	tmp=(1<<(x+y+z-1));
	tmp|=(1<<(y+z-1));
	tmp|=(1<<(z-1));
	lim=(1<<(x+y+z))-1;
	f[0][0]=1;
	for(i=1;i<=n;i++){
		for(j=0;j<=lim;j++){
			if(f[i-1][j]==0) continue;
			for(k=1;k<=10;k++){
				int now=((j<<k)|(1<<(k-1)));
				now&=lim;
				if((now&tmp)!=tmp) f[i][now]=(f[i][now]+f[i-1][j])%mod;
			}
		}
	}
	int ans=1;
	for(i=1;i<=n;i++) ans=ans*10%mod;
	for(i=0;i<=lim;i++) ans=(ans-f[n][i]+mod)%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 82176
#include <algorithm>
#include <climits>
#include <cstdio>

using namespace std;

typedef struct Card {
  char suite[2];
  int num;
} Card;

int partition(Card A[], int p, int r) {
  Card x = A[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j].num <= x.num) {
      i++;
      // printf("swap A[%d]=%d & A[%d]=%d\n", i, A[i], j, A[j]);
      swap(A[i], A[j]);
    }
  }
  // printf("swap A[%d]=%d & A[%d]=%d\n", i + 1, A[i + 1], r, A[r]);
  swap(A[i + 1], A[r]);
  return i + 1;
}

void quickSort(Card A[], int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

void merge(Card A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  Card L[n1 + 1];
  Card R[n2 + 1];
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1].num = INT_MAX;
  R[n2].num = INT_MAX;
  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    if (L[i].num <= R[j].num) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(Card A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  Card A[n], B[n];
  for (int i = 0; i < n; i++) {
    scanf("%s %d", A[i].suite, &A[i].num);
    B[i] = A[i];
    // printf("%s %d\n", A[i].suite, A[i].num);
  }

  quickSort(A, 0, n - 1);
  mergeSort(B, 0, n);

  // for (int i = 0; i < n; i++) {
  //   printf("%s %d\n", B[i].suite, B[i].num);
  // }

  bool stable = true;
  for (int i = 0; i < n; i++) {
    if (!(A[i].num == B[i].num && A[i].suite[0] == B[i].suite[0])) {
      // printf("i=%d, A[i]=%s,%d, B[i]=%s,%d\n", i, A[i].suite, A[i].num, B[i].suite, B[i].num);
      printf("Not stable\n");
      stable = false;
      break;
    }
  }
  if (stable) {
    printf("Stable\n");
  }
  for (int i = 0; i < n; i++) {
    printf("%s %d\n", A[i].suite, A[i].num);
  }
}


Measured memory_bytes: 4912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int dp1[1000010],dp2[1000010];

int main() {
    vector<int> c,d;
    int x=1;
    while((x*(x+1)*(x+2))/6<1000010){
        int y=(x*(x+1)*(x+2))/6;
        c.push_back(y);
        if(y%2==1) d.push_back(y);
        x++;
    }

    //rep(i,10) cout<<d[i]<<endl;
    
    rep(i,1000010){
        dp1[i]=INF;
        dp2[i]=INF;
    }
    dp1[0]=0;
    dp2[0]=0;
    rep(i,1000010){
        rep(j,c.size()){
            if(i+c[j]<1000010) dp1[i+c[j]]=min(dp1[i+c[j]],dp1[i]+1);
        }

        rep(j,d.size()){
            if(i+d[j]<1000010) dp2[i+d[j]]=min(dp2[i+d[j]],dp2[i]+1);
        }
    }

    while(1){
        int n;
        cin>>n;
        if(n==0) break;
        cout<<dp1[n]<<" "<<dp2[n]<<endl;
    }

    return 0;
}




Measured memory_bytes: 10808
n, m = [int(i) for i in input().split()]
b = [0] * (n+1)
b[0],b[1]=1,1
c = [0]*(n+1)
a = [int(input()) for _ in range(m)]
for i in a:
    c[i] = 1
    b[i]=0
for i in range(2, n+1):
    if c[i] == 0:
        b[i] = b[i - 1] + b[i - 2]
print(b[-1]%(10**9+7))


Measured memory_bytes: 460788
#include <bits/stdc++.h>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 2e5+5;
const int MOD = 1e9+7;
int dp[MAXN],ix[26+3][MAXN],ocr[26+3];
int main(int argc ,char const *argv[])
{
  #ifdef noob
  freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
  #endif  
  string str;
  cin>>str;
  int n = str.size();
  for (int i = 0; i < 26; ++i)
  {
    ocr[i] = n;
  }
  for (int i = n-1; i >=0; i--)
  {
    ocr[str[i]-'a'] = i;
    for (int j = 0; j < 26; ++j)
    {
      ix[j][i] = ocr[j];
    }
    dp[i] = MOD;
  }


  dp[n] = 1;
  for (int i = n-1; i > -1; --i)
    for (int j = 0; j < 26; ++j)
      dp[i] = min(dp[i],dp[ix[j][i]+1]+1);

  for (int i = 0; dp[0]; --dp[0])
  {
    for (int j = 0; j < 26; ++j)
    {
      if(dp[i]==dp[ix[j][i]+1]+1)
      {
        printf("%c",j+'a');
        i = ix[j][i]+1;
        break;
      }
    }
  }

  cout<<endl;

  return 0; 
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    int h;
    int ret = 0;
    for(int i=0;i<n;i++){
        cin >> h;
        if(h >= k) ret++;
    }
    cout << ret << endl;
}

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const ll mod=1e9+7;
int main()
{
    cin.tie( 0 );
    ios::sync_with_stdio( false );
	
	int s;
	cin>>s;

	string ans="Good";
	REP(i,3){
		int a=s%10;
		s/=10;
		int b=s%10;
		if(a==b)ans="Bad";
	}

	cout << ans << endl;
    return 0;
}

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

#define PB push_back

int main(){
    int N,x;
    cin >> N >> x;
    vector<int> a(N);
    rep(i,N){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i=0;i<N;i++){
        x -= a.at(i);
        if(x == 0){
            ans++;
            break;
        }else if(x < 0){      
            break;
        }else{
            ans++;
            if(i == N-1){
               break;
            }
        }
    }
    if(x > 0 && ans == N){
        ans --;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
L = [0] * n
m = float('inf')
for i in range(n):
    L[i] = int(input())
    if L[i] % 10 != 0:
        m = min(m, L[i])
ans = sum(L)
if ans % 10 == 0:
    ans -= m
    if ans < 0:
        print(0)
        exit()
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto i = (m).begin(); i != (m).end(); ++i)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

ll pow_(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = (x * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return x;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N;
  vector<ll> A;
  cin >> N;
  if (N == 3 || N == 5 || N == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>){
  var (a,b) = readLine()!!.split(" ").map(String::toInt)
  var count = 0
  for(i in a..b){
    var arr = i.toString().toCharArray()
    if(arr[0]==arr[4] && arr[1]==arr[3]){
      count++
    }
  }
  println(count)
}

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

int main(){
  ll h, w; cin >> h >> w;
  if(h==1 || w==1){
    cout << 1 << endl;
    return 0;
  }
  ll H = h/2, W = w/2;
  if(h%2!=0) ++H; if(w%2!=0) ++W;
  ll sum = H*W + (h-H)*(w-W);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int t[n + 1], x[n + 1], y[n + 1];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  bool flag = true;
  for (int i = 0; i < n; i++) {
    // cout << abs(x[i] - x[i + 1]) << endl;
    // cout << abs(y[i] - y[i + 1]) << endl;
    if (!(((t[i + 1] - t[i] - (abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]))) %
               2 ==
           0) &&
          (t[i + 1] - t[i]) >= (abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1])))) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    result = (B - A) // 2
else:
    result = min(A + ((B - A) - 1) // 2, N - B + 1 + (N - (A + (N - B + 1))) // 2)

print(result)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 300
#define X 998244353
#define Inc(x,y) ((x+=(y))>=X&&(x-=X))
int n,m,a[N+5],f[N+5][N+5][N+5];char s[N+5];
int main()
{
	RI i,j,k,cnt=1;for(scanf("%s",s+1),n=strlen(s+1),i=1;i<=n;++i) s[i]^'0'?++a[cnt]:++cnt;
	RI p;scanf("%d",&m),m=min(n,m),f[0][0][0]=1;
	for(i=0;i^cnt;++i) for(j=0;j<=m;++j) for(k=0;k<=m;++k) if(f[i][j][k])
	{
		Inc(f[i+1][j][k],f[i][j][k]);
		for(p=m-j;p;--p) Inc(f[i+1][j+p][k+p],f[i][j][k]);
		for(p=min(a[i+1],k);p;--p) Inc(f[i+1][j][k-p],f[i][j][k]);
	}
	RI t=0;for(i=0;i<=m;++i) Inc(t,f[cnt][i][0]);return printf("%d\n",t),0;
}

Measured memory_bytes: 58140
use bigint;
($N,$M)=split / /,<>;
foreach (1..$N){
    ($x,$y)=split / /,<>;
    $A{$x}+=$y;
}
# $v =0;chomp($M);
for my $k (sort {$a <=> $b} keys %A) {
    # print "$v $M $k $A{$k}\n";
    if ($M>=$A{$k}){
        $v+=$k*$A{$k};
        $M-=$A{$k};
    } else{
        $v+=$k*$M;
        last;
    }
}
print$v;

Measured memory_bytes: 27392
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

int main() {
  ll x,y,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1e9,Min=1e9+1;
  string s,t,u;
  bool ok = false;
  cin >> s;
  x = s.size();
  while(x>0){
    cout <<'x';
    x--;
  }
 

  

  return 0;
}

Measured memory_bytes: 256
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, p = map(int, input().split())
a = [(int(i) % 2) for i in input().split()]
e_num = a.count(0)
o_num = a.count(1)
all_pattern = 2 ** n
o_p = 2 ** (e_num)
o_pattern = o_p
if o_num >= 2:
    for i in range(2, o_num + 1, 2):
        o_pattern += (combinations_count(o_num, i) * o_p)
e_pattern = all_pattern - o_pattern
if p == 1:
    print(e_pattern)
else:
    print(o_pattern)

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];

    ll cnt = 0;
    if(x < a[0]){
        cnt += a[0] - x;
        a[0] -= a[0] - x;
    }
    for(int i = 0; i < N-1; i++){
        if(x < a[i] + a[i+1]){
            ll tmp = abs(x - a[i] - a[i+1]);
            a[i+1] -= tmp;
            cnt += tmp;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

#define FOR1(n) for(int i=0;i<n;i++)
#define FOR2(j, n) for(int j=0;j<n;j++)
#define FOR3(i, m, n) for(int i=m;i<=n;i++)
#define ALL(c) c.begin(), c.end()
#define SCANF(x) scanf("%lld", &x)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define MAX_N 300000

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

/*
逆順ソート sort(ALL(vec), greater<ll>());
ペア定義 P pair = make_pair(100, 200);
集合find set.find(item);
小さい順に取り出したい優先度付きキュー
priority_queue<int, vector<int>, greater<int> > que;
配列の最大要素 *std::max_element(ALL(vec))
*/

int par[MAX_N];  //親
int depth[MAX_N]; //深さ
ll size[MAX_N]; //最小でいられる区間数

//初期化
void init(int n){
    FOR1(n){
        par[i] = i;
        depth[i] = 0;
        size[i] = 1;
    }
}

//根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合の併合
ll unite(int x, int y){
    x = find(x);
    y = find(y);
    ll tmp_ans  = size[x] * size[y];
    if(x == y) return 0;
    
    if(depth[x] < depth[y]){
        par[x] = y;
        size[y] += size[x];
    }else{
        par[y] = x;
        size[x] += size[y];
        if(depth[x] == depth[y]) depth[x]++;
    }
    
    return tmp_ans;
}

//同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}

signed main(){
	int n;
	scanf("%d", &n);
	int a[n];
	map<int, int> mp;
	FOR1(n){
		scanf("%lld", &a[i]);
		mp[a[i]] = i;
	}
	ll ans = 0;
	init(n);
	for(int i=n;i>=1;i--){
		int j = mp[i];
		if(j > 0 && a[j-1] > i){
			ans += unite(j, j-1) * i;
		}
		if(j < n-1 && a[j+1] > i){
			ans += unite(j, j+1) * i;
		}
		ans += i;
		
	}
	printf("%lld\n", ans);
}

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

public class Main {
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		public long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}

	static final FS sc = new FS();
	static final PrintWriter out = new PrintWriter(System.out);
	static final int mod = 1000000007;

	public static void main(String[] args) {
		solve();
		out.close();
	}

	static void solve() {
		int x = sc.nextInt();
		int y = sc.nextInt();
		int add = x + y;
		int sub = x - y;
		int into = x * y;
		if (add >= sub && add >= into) {
			out.println(add);
		}
		else if (sub >= add && sub >= into) {
			out.println(sub);
		}
		else {
			out.println(into);
		}
		

	}

}


Measured memory_bytes: 32728
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>A(n);
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  if(A[n/2]==A[n/2-1]){
    cout<<0<<endl;
    return 0;
  }
  cout<<(A[n/2]-A[n/2-1])<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    LL K;cin>>K;
    int N=50;

    LL big=K/50;
    LL mod=K%50;

    LL ans[50];
    REP(i,N){
        ans[i]=N+big-1;
    }
    REP(i,N-mod){
        ans[i]-=mod;
    }
    REP(i,mod){
        ans[N-mod+i]+=N+1-mod;
    }
    cout<<N<<endl;
    REP(i,N){
        if(i==N-1)cout<<ans[i]<<endl;
        else cout<<ans[i]<<" ";
    }

    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(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int cnt = 0;
	REP(i, n) {
		int a;
		cin >> a;
		if (a % 2 == 1)cnt++;
	}
	if (cnt % 2 == 1)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var L = Console.ReadLine().Split().Select(s => int.Parse(s)).OrderByDescending(x => x).ToArray();
            bool answer = L[0] < L.Skip(1).Sum();
            Console.WriteLine(answer ? "Yes" : "No");
        }
    }
}

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

#define fi first
#define se second
#define pb push_back

typedef long long LL;
typedef long double LD;

const LL INF = (1LL << 60);

typedef pair<LL,int> PLL;
bool bellman_ford(int n, vector<PLL> adjList[], int source, vector<LL>& dist);

int main() {

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

  vector<PLL> adjList[1005];

  int n, m, r;
  cin >> n >> m >> r;

  for (int i = 0; i < m; i++) {
    int s, t; LL d;
    cin >> s >> t >> d;

    adjList[s].push_back({d, t});
  }

  vector<LL> dist;
  bool has_negative_cycle = bellman_ford(n, adjList, r, dist);

  if (has_negative_cycle) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for (int i = 0; i < n; i++) {
      if (dist[i] == INF)
        cout << "INF" << endl;
      else
        cout << dist[i] << endl;
    }
  }

  return 0;
}

/*
 * @param n: number of nodes from 0 to n-1
 * @param adjList: adjacency list representation of the graph
 * @param source: source for shortest path
 * 
 * @return dist[i]: shortest distance from source to node i, INF if unreachable
 * 
 * tested on: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_B
 */
bool bellman_ford(int n, vector<PLL> adjList[], int source, vector<LL>& dist) {
  dist.assign(n, INF); dist[source] = 0;
  for (int i = 0; i < n - 1; i++) 
    for (int u = 0; u < n; u++) 
      if (dist[u] != INF) 
        for (PLL v : adjList[u]) 
          dist[v.se] = min(dist[v.se], dist[u] + v.fi);

  bool has_negative_cycle = false;
  for (int u = 0; u < n; u++) 
    for (PLL v : adjList[u]) 
      if (dist[u] != INF && dist[v.se] > dist[u] + v.fi) 
        has_negative_cycle = true;

  return has_negative_cycle;
}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll n,a,b,i;
    cin>>n;
    cout<<(n+1)/2;
}

Measured memory_bytes: 256
#include <stdio.h>
const int MAX_V = 1000000; // 100???????????????????f???????¢\????°???¬?????
int prime[MAX_V+1];
int main() {
	int k,i,max,min,n; // 1????????f???????C0????????f????????????????????¢
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1; // 2???????£????f????????????°??????¨
	}
	for(i = 2; i*i <= MAX_V; i++) {
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0; // ???f??????2???{???????£????{?????????f????????????????????¢
			}
		}
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = n;i > 0;i--){
			if(prime[i] && prime[i-2]){
				max = i;
				min = max -2;
				//printf("%d %d\n",i-2,i);
				break;
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

Measured memory_bytes: 4932
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

import math
items = [a, b, c, d, e]
min_item = min(items)
min_idx = items.index(min_item)
n_times = math.ceil(n / min_item)
print(len(items) + n_times - 1)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  string cur(n, '-');

  function<void(int, int)> generate = [&](int i, int lim) {
    if (i == n) {
      cout << cur << '\n';
      return;
    }
    for (int c = 0; c <= lim; c++) {
      cur[i] = 'a' + c;
      generate(i + 1, max(lim, c + 1));
    }
  };
  generate(0, 0);

  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

using int64 = long long;

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

int main(){
    int A, B;
    cin >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
}


Measured memory_bytes: 256
x, n = map(int, input().split())
l = list(map(int, input().split()))

sa = 0


while(True):
  if x - sa not in l:
    ans = x - sa
    break
    
  elif x +sa not in l:
    ans = x + sa
    break
  else:
    sa +=1
print(ans)

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

int main(){
    int R,G,B,N,ball,count=0;
    scanf("%d %d %d %d",&R,&G,&B,&N);
    ball=N;
    for(int r=0;r<=ball/R;r++){
        ball-=R*r;
        for(int g=0;g<=ball/G;g++){
            ball-=G*g;
            if(ball==0||ball%B==0) count++;
            ball+=G*g;
        }
        ball+=R*r;
    }
    printf("%d",count);

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.text.Segment;

public class Main {

	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final long N = sc.nextLong();
			final long K = sc.nextLong();
			
			long value = 1;
			for(int i = 0; i < N; i++){
				if(value + K <= value * 2){
					value += K;
				}else{
					value *= 2;
				}
			}
			
			System.out.println(value);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<climits>

using namespace std;

long long int arr[100001];
long long int store[100001];

long long int find(long long int n, long long int k)
{
	if(store[n]!=-1)
	{
		return store[n];
	}
	else
	{
		long long int min1 = INT_MAX, cost = 0,i;
		for(i=1;n-i>0 && i<=k;++i)
		{
			cost = abs(arr[n] - arr[n-i]) + find(n-i,k);
			if(cost<min1)
			{
				min1 = cost;
			}
		}
		store[n] = min1;
		return store[n];
	}
}

int main()
{
	long long int n,i,k;
	cin>>n>>k;
	for(i=1;i<=n;++i)
	{
		cin>>arr[i];
	}
	store[1] = 0;
	for(i=2;i<100001;++i)
	{
		store[i] = -1;
	}
	cout<<find(n,k)<<endl;
	return 0;
}

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

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

int n,k;
int cnt=0;
int ans=0;
string s;

int main(){
    cin >> n>>k;
    cin >> s;

    rep(i,s.size()-1){
        if(s[i]==s[i+1])ans++;
    }

    if(s[0]=='R')s='L'+s;
    else s='R'+s;

    if(s[(int)s.size()-1]=='R')s=s+'L';
    else s=s+'R';

    rep(i,s.size()-1){
        if(s[i]!=s[i+1])cnt++;
    }

    while(cnt>1&&k>0){
        ans+=2;
        cnt-=2;
        k--;
    }

    if(cnt==0){
        ans-=2;
    }else if(cnt==1){
        ans-=1;
    }

    cout << ans<<endl;

    return 0;
}


Measured memory_bytes: 3752
N,R = map(int,input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

print(len(Base_10_to_n(N, R)))


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

string s,t;
int i,j,sama;
bool anagram;

int main(){
    sama=0;
    cin>>s;
    cin>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    anagram=false;
    for(i=0;i<s.length();i++){
        for(j=0;j<t.length();j++){
            if(s[i]<t[j]){anagram=true;}
            else if(s[i]==t[j]){sama++;}
        }
    }
    if(sama==s.length()*t.length()&&(s.length()<t.length())){anagram=true;}
    if(anagram){printf("Yes\n");}
    else{printf("No\n");}
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,cou=0,i;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if((c % i) == 0)cou++;
  }
  printf("%d\n",cou);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 200005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
 vector<int> vi[maxii];
 vector<int>::iterator child;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];


int main()
{
   cin>>arr[0]>>arr[1]>>arr[2];
   sort(arr,arr+3);
   if(arr[0]+arr[1]==arr[2])
   {
       printf("Yes\n");
   }
   else cout<<"No";

}






Measured memory_bytes: 8280
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()
	if s <= "2019/04/30" {
		fmt.Fprintln(wr, "Heisei")
	} else {
		fmt.Fprintln(wr, "TBD")
	}

}


Measured memory_bytes: 1776
using System;
using System.Collections;
using System.Collections.Generic;
 
class Test
{
   public static void Main(string[] args)
   {
       List<int> prices = new List<int>();
       string[] strs = Console.ReadLine().Split(' ');
       foreach(var one in strs)
       {
           prices.Add(int.Parse(one));
       }
       prices.Sort();
       
       Console.WriteLine((prices[0] + prices[1]).ToString());
   }
}

Measured memory_bytes: 11220
S = input()
T = input()
k = {}
o = {}
res = "Yes"
for i in range(len(S)):
    if S[i] in k:
        if k[S[i]] != T[i]:
            res = "No"
            break
    else:
        k[S[i]] = T[i]
        
for i in range(len(T)):
    if T[i] in o:
        if o[T[i]] != S[i]:
            res = "No"
            break
    else:
        o[T[i]] = S[i]
    
print(res)

Measured memory_bytes: 3632
class SegmentTree
  def initialize(size, default:)
    n = 1
    while n < size
      n *= 2
    end
    @size = n
    @default = default
    @data = Array.new(n * 2 - 1, default)
  end

  # 0-origin
  def update(k, a)
    k += @size - 1
    @data[k] = a
    while k > 0
      k = (k - 1) / 2
      @data[k] = merge(@data[k * 2 + 1], @data[k * 2 + 2])
    end
    nil
  end

  # [a, b)
  # 0-origin
  def query(a, b)
    execute_query(a, b, 0, 0, @size)
  end

  private

  def execute_query(a, b, k, l, r)
    return @default if r <= a || b <= l
    return @data[k] if a <= l && r <= b
    vl = execute_query(a, b, k * 2 + 1, l, (l + r) / 2)
    vr = execute_query(a, b, k * 2 + 2, (l + r) / 2, r)
    merge(vl, vr)
  end

  def merge(a, b)
    a >= b ? a : b
  end
end

N, T = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

st = SegmentTree.new(
  N,
  default: -1
)
as.each.with_index do |a, i|
  st.update(i, a)
end
table = Hash.new { 0 }
(0...N).each do |i|
  a = as[i]
  b = st.query(i, N)
  c = b - a
  table[c] += 1 if c > 0
end
n = table.keys.max
ans = table[n]
puts ans


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

const LL N=2e5+5;

LL n,T,b[N],ans,f[N],tot1,tot2;

struct node{
	LL x;
	LL y;
}a[N];

bool mycmp(node x,node y){
	return x.x*(y.y+1)>y.x*(x.y+1);
}

int main(){
	scanf("%lld%lld",&n,&T);
	for (int i=1;i<=n;i++){
		LL x,y;
		scanf("%lld%lld",&x,&y);
		if (x==0) b[++tot2]=y+1;
		else a[++tot1]={x,y};
	}
	sort(a+1,a+tot1+1,mycmp);
	sort(b+1,b+tot2+1);
	for (int i=1;i<=35;i++) f[i]=T+1;
	for (int i=1;i<=tot1;i++)
		for (int j=35;j>=1;j--)
			f[j]=min(f[j],(f[j-1]+1)*(a[i].x+1)+a[i].y);
	for (int i=1;i<=tot2;i++) b[i]+=b[i-1];
	for (int i=0;i<=35;i++){
		if (f[i]>T) continue;
		LL x=0;
		if (tot2) x=upper_bound(b+1,b+tot2+1,T-f[i])-(b+1);
		ans=max(ans,i+x);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6916