akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
 
 
 
int main(void){
	int N;
	ll a[300001],L[300001],R[300001],ans=LLONG_MIN;
	priority_queue<int, vector<int>, greater<int> > left;
	priority_queue <ll> right;
	cin>>N;
	reg(i,1,N){
		cin>>a[i];
		L[N]+=a[i];
		left.push(a[i]);
	}
	reg(i,N+1,N*2){
		cin>>a[i];
	}
	reg(i,N*2+1,N*3){
		cin>>a[i];
		R[2*N+1]+=a[i];
		right.push(a[i]);
	}
	reg(k,N+1,2*N){
		if(left.top()<a[k]){
			L[k]=L[k-1]+a[k]-left.top();
			left.push(a[k]);
			left.pop();
		}else{
			L[k]=L[k-1];
		}
	}
	ireg(k,N+1,2*N){
		if(right.top()>a[k]){
			R[k]=R[k+1]+a[k]-right.top();
			right.push(a[k]);
			right.pop();
		}else{
			R[k]=R[k+1];
		}
	}
	reg(k,N,2*N){
		if(ans<L[k]-R[k+1])ans=L[k]-R[k+1];
	}
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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


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



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

    // isTaroWin[i]: K = i のときTaroが勝つかどうか
    vector<bool> isTaroWin(K+1, false);
    for( int i = 0; i <= K; ++i ){
        for( int j = 0; j < N; ++j ){
            if( i-a[j] >= 0 and isTaroWin[i-a[j]] == false ) isTaroWin[i] = true;
        }
    }
    if( isTaroWin[K] ) cout << "First"  << endl;
    else               cout << "Second" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace AOJ.Volume2
{
    public class InterestRates
    {
        public static int Main()
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }
                int y = int.Parse(Console.ReadLine());

                int ans = 0;
                double amount = 0;
                for(int i = 0; i < n; i++)
                {
                    var input = Console.ReadLine().Split(' ');
                    int rate = int.Parse(input[1]);
                    double tmp_amount;
                    if(input[2] == "1")
                    {
                        // ??????
                        double tmp = y * rate / 100.0;
                        tmp_amount = 1 + tmp;
                    }
                    else
                    {
                        // ??????
                        double tmp = 1 + rate / 100.0;
                        tmp_amount = Math.Pow(tmp, y);
                    }
                    if (tmp_amount > amount)
                    {
                        amount = tmp_amount;
                        ans = int.Parse(input[0]);
                    }
                }

                Console.WriteLine(ans);
            }
            return 0;
        }
    }
}

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

int main(void) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((abs(a-c) <= d) || ((abs(a-b) <= d) && (abs(b-c) <= d))) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

const int max_n = 200500;
int d = 1;

ll t[max_n << 2];

void update(int i, ll x, int tl = 0, int tr = d - 1, int v = 1) {
    if (tl == tr) {
        t[v] = x;
        return;
    }
    int tm = (tl + tr) >> 1;
    if (i <= tm) update(i, x, tl, tm, v << 1);
    else update(i, x, tm + 1, tr, v << 1 | 1);
    t[v] = max(t[v << 1], t[v << 1 | 1]);
}

ll get(int l, int r, int tl = 0, int tr = d - 1, int v = 1) {
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) >> 1;
    ll ans = 0;
    if (l <= tm) {
        ans = max(ans, get(l, min(r, tm), tl, tm, v << 1));
    }
    if (r > tm) {
        ans = max(ans, get(max(l, tm + 1), r, tm + 1, tr, v << 1 | 1));
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    cout.precision(20); cout << fixed;
    int n;
    cin >> n;
    while (d <= n) d <<= 1;
    vector<ll> h(n), a(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        update(h[i], get(0, h[i] - 1) + a[i]);
    }
    cout << get(0, n);
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

const int INF = 1001001001;
const double EPS = 0.000000001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void solve() {
  int n;
  cin >> n;
  vi32 x(n), y(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
  }
  rep(i, n) {
    vector<double> angles;
    rep(j, n) if (i != j) {
      angles.push_back(atan2(y[j] - y[i], x[j] - x[i]));
    }
    sort(all(angles));
    double ma = 0;
    rep(j, sz(angles) - 1) {
      amax(ma, angles[j + 1] - angles[j]);
    }
    amax(ma, angles[0] + 2 * M_PI - angles.back());
    double ans = (ma > M_PI ? (ma - M_PI) / 2 / M_PI : 0.0);
    cout << ans << endl;
  }
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int K, A, B;
    cin>>K>>A>>B;
    int d = 0;
    while(1){
        d += K;
        if(d < A) continue;
        else if (A<=d && d <=B) cout << "OK" << endl;
        else cout << "NG" << endl;
        break;
    }
}

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

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

	unsigned short int h[100] = {};
	for (int i = 0; i < n; ++i){
		cin >> h[i];
	}

	unsigned short int r = 0, k[100] = {};
	for (int i = 0; i < n ; ++i){
		if (k[i] == h[i]){
			continue;
		}
		for (int x = i; ; ++x){
			if(k[x] == h[x]){
				r++;
				i = -1;
				break;
			}
			k[x]++;
		}
	}

	cout << r << endl;
	return 0;
}


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

using namespace std;

class Calc {
    long long a;
public:
    void Decomp(long long n);
    vector<long long> prime;
};

void Calc::Decomp(long long n) {
    a = 2;
    while(n >= a * a) {
        if(n % a == 0) {
            long long b = n/a;
            prime.push_back(a+b);
        }
        a++;
    }
    prime.push_back(n+1);
    sort(prime.begin(),prime.end());
    cout << prime[0] - 2 << endl;
}

int main(void) {
    long long n; cin >> n;
    Calc calc;
    calc.Decomp(n);
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll atack(ll x){
  if(x == 1){
    return 1;
  }else{
    ll t = atack(x/2);
    return t*2 + 1;
  }
}

int main(){
   int H,N;
   cin >> H >> N;
   vector<ll> A(N),B(N);
   rep(i,N)cin >> A[i] >> B[i];
   vector<vector<ll>> dp(N+1,vector<ll> (H+1));
   rep(i,N+1)dp[i][0] = 0;
   rep(i,H+1)dp[0][i] = INFL;
   dp[0][0] = 0;

   for(int i = 1;i <= N;i++){
     for(int j = 1;j <= H;j++){
       dp[i][j] = (j-1+A[i-1])/A[i-1];
       dp[i][j] *= B[i-1];
     }
   }
/*
   rep(i,N+1){
     rep(j,H+1){
       cout << dp[i][j] << " ";
     }
     cout << endl;
   }
*/
   for(int i = 1;i <= N;i++){
     for(int j = 1;j <= H;j++){
        if(dp[i][j] > dp[i-1][j])dp[i][j] = dp[i-1][j];
/*
        for(int k = 0;k <= j/A[i-1];k++){
          if(dp[i][j] > dp[i-1][j-k*A[i-1]]  + B[i-1]*k)dp[i][j] = dp[i-1][j-k*A[i-1]]  + B[i-1]*k;
        }
*/
        ll jj = j-A[i-1];
        if(dp[i][j] > dp[i-1][jj] + B[i-1]){
          dp[i][j] = dp[i-1][jj] + B[i-1];
        }
        if(dp[i][j] > dp[i][jj] + B[i-1])dp[i][j] = dp[i][jj] + B[i-1];
/*

        ll jj = j-A[i-1];
        while(jj >= 0){
          if(jj >= 0){
            if(dp[i][j] > dp[i-1][jj] + B[i-1]){
              dp[i][j] = dp[i-1][jj] + B[i-1];

          }
          jj -= A[i-1];
        }


      }
      */
     }
   }
/*
   for(int i = 1;i <= N;i++){
     for(int j = 1;j <= H;j++){
       cout << dp[i][j] << " ";
     }
     cout << endl;
   }
*/

   cout << dp[N][H] << endl;
}


Measured memory_bytes: 81616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

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

int main(){
  int N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  vector<ll> f(N), b(N);
  f[0] = v[0];
  b[N-1] = v[N-1];
  REP(i,1,N){
    f[i] = gcd(f[i-1], v[i]);
    b[N-1-i] = gcd(b[N-i], v[N-i-1]);
  }

  ll ret = 0;
  rep(i,N){
    ll tmp = 0;
    if(i==0){
      tmp = b[1];
    }else if(i==N-1){
      tmp = f[N-2];
    }else{
      tmp = gcd(f[i-1], b[i+1]);
    }
    
    ret = max(ret, tmp);
  }

  cout << ret << endl;
  
  return 0;
}


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

using namespace std;

int k, s, x, y, ans;

int main(){
  cin >> k >> s;
  for(int x = 0;x <= k;x++){
    for(int y = 0;y <= k;y++){
      int z = s - x - y;
      if(0 <= z && z <= k)ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 504
#pragma GCC target("popcnt")
#include <cctype>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <array>
#include <initializer_list>
#include <random>
#include <regex>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;

int a[11];

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

    long long ans = 1;
    for (int i = 1; i <= n; i++) ans *= 3;

    long long ans2 = 1;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] % 2 == 0) ans2 *= 2;
    }
    
    cout << ans - ans2 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout << max({a,b,c})*9 + a + b + c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
using namespace std;

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

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    double a,b, c, d, e, f, x,y;
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF)
    {
        y=(a*f-c*d)/(a*e-d*b);
        x=(c-b*y)/a;
        printf("%.3f %.3f\n",x,y);
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll X[100100];
ll V[100100];
ll RS[100100];
ll LS[100100];
ll MRS[100100];
ll MLS[100100];
int main(){
    ll N, C;
    cin >> N >> C;
    REP(i, N){
        ll x, v;
        cin >> x >> v;
        X[i] = x;
        V[i] = v;
    }

    RS[0] = V[0] - X[0];
    MRS[0] = RS[0];
    for(int i = 1; i < N; i++){
        RS[i] = RS[i-1] + V[i] - (X[i] - X[i-1]);
        MRS[i] = max(MRS[i-1], RS[i]);
    }

    LS[N-1] = V[N-1] - (C-X[N-1]);
    MLS[N-1] = LS[N-1];
    for(int i = N-2; i >= 0; i--){
        LS[i] = LS[i+1] + V[i] + (X[i] - X[i+1]);
        MLS[i] = max(MLS[i+1], LS[i]);
    }

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ll num = 0;
        num += MRS[i];
        if(i != N-1){
            num -= X[i];
            num += MLS[i+1];
        }
        ans = max(ans, num);
    }

    for(int i = N-1; i >= 0; i--){
        ll num = 0;
        num += MLS[i];
        if(i != 0){
            num -= C - X[i];
            num += MRS[i-1];
        }
        ans = max(ans, num);
    }


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


Measured memory_bytes: 4992
/*
 *  Author :: Kattu37
 */
 
#include<bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define PI 3.14159265358979
 
typedef long long ll;
 
 
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
 
	ll n;
	cin >> n;
 
	ll x;
	ll mul = 1;
	bool ctr = 1;
 
	for (int i = 0; i < n; i++)
	{
 
		if (ctr == 0)
		{
			cin >> x;
			if (x == 0)
			{
				mul = 0;
				ctr = 1;
				break;
			}
			continue;
		}
 
		cin >> x;
 
		if (x > 1000000000000000000/mul )
		{
			ctr = 0;
		}
		mul *= x;
 
		//cout << mul << " ";
	}
 
	if (ctr)
		cout << mul << "\n";
	else cout << -1 << "\n";
 
 
	return 0;
}

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

int main() {
  char A;
  cin >> A;
  if(A-'Z'<=0) cout << 'A' << endl;
  else cout << 'a' << endl;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

const int DPMAX = 100009;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> a(m+1);
    rp(i, 0, m) scanf("%d", &a.at(i));
    a.at(m) = -1;
    int pointer = 0;
    vector<ll> dp(DPMAX, 0ll);
    dp.at(0) = 1ll;
    rp(i, 1, n+1) {
        if(a.at(pointer) != i) {
            dp.at(i) += dp.at(i-1);
            if(i > 1) dp.at(i) += dp.at(i-2);
            dp.at(i) %= mod;
        } else pointer ++;
    }
    printf("%lld", dp.at(n));
    return 0;

} 

Measured memory_bytes: 1408
import java.util.Scanner;

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

        int ans = 0;
        if (X <= 599) {
            ans = 8;
        } else if (600 <= X && X <= 799) {
            ans = 7;
        } else if (800 <= X && X <= 999) {
            ans = 6;
        } else if (1000 <= X && X <= 1199) {
            ans = 5;
        } else if (1200 <= X && X <= 1399) {
            ans = 4;
        } else if (1400 <= X && X <= 1599) {
            ans = 3;
        } else if (1600 <= X && X <= 1799) {
            ans = 2;
        } else if (1800 <= X) {
            ans = 1;
        }


        System.out.println(ans);
    }
}


Measured memory_bytes: 27052
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <iostream>
#include <set>

using namespace std;

int main() {
    int dp[100][2] = {};
    int n, a[100] = {};

    scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    dp[0][0] = 0;
    dp[0][1] = 1;

    for (int i = 1; i < n; ++i) {
        if (a[i - 1] == a[i]) {
            dp[i][0] = dp[i-1][1];
            dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + 1;
        } else {
            dp[i][0] = min(dp[i-1][0], dp[i-1][1]);
            dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + 1;
        }
    }

    printf("%d\n", min(dp[n-1][0], dp[n-1][1]));

    return 0;
}

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

namespace AtCoder
{
    class Abc165E
    {
        public static void Main()
        {
            var nm = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var n = nm[0];
            var m = nm[1];

            int count = 0;

            int a = 1;
            int b = m;
            while (a < b)
            {
                Console.WriteLine($"{a} {b}");
                a++;
                b--;
                count++;
            }

            a = m + 1;
            b = 2 * m + 1;
            while (a < b)
            {
                Console.WriteLine($"{a} {b}");
                a++;
                b--;
                count++;
            }
        }
    }
}


Measured memory_bytes: 36428
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF (int)(1e9 + 5)
#define MOD (int)(1e9) 

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, k; cin >> n >> k;
    ll mod = n % k;
    cout << min(mod, k-mod) << '\n';
    return 0;
}

Measured memory_bytes: 3564
n = int(input())

unit = 10
cnt = 0
flg = 1

for i in range(1,n+1):
    if i//unit < 1:
        if flg==1:
            cnt+=1
    else:
        unit*=10
        flg^=1
        if flg==1:
            cnt+=1

print(cnt)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int sum = t;
    REP(i, n-1){
        sum += min(a[i+1] - a[i], t);
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024
def main():
    A, B, K = map(int, input().split())

    a_set = set([a for a in range(1, A+1) if A % a == 0])
    b_set = set([b for b in range(1, B+1) if B % b == 0])

    ab = list(a_set & b_set)
    ans = sorted(ab, reverse=True)[K-1]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())
dic = {}
 
for i in range(N):
    s = list(input())
    s.sort()
    key = str(s)
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1
 
ans = 0
for value in dic.values():
    ans += value*(value-1) / 2
print(int(ans))

Measured memory_bytes: 21988
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by Santa on 2016/10/16.
 */
public class Main {

    static int N;
    static long A;
    static long B;
    static long C;
    static int[] map;



    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int[] s = new int[3];


        s[0] = scanner.nextInt();
        s[1] = scanner.nextInt();
        s[2] = scanner.nextInt();
        int k = scanner.nextInt();


        Arrays.sort(s);

        for (int i = 0; i < k; i++) {
            s[2] *= 2;
        }

        System.out.println(s[0] + s[1] + s[2]);



    }

}



Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main(void){
   int N;
   cin>>N;
   int P[N];
   for(int i=0;i<N;i++){
       cin>>P[i];
   }
   int count=0;
   for(int i=1;i<=N;i++){
       if(P[i-1]!=i){
           count++;
       }
   }
   if(count==2 or count==0){
       cout<<"YES"<<endl;
   }
   else{
       cout<<"NO"<<endl;
   }
}


Measured memory_bytes: 256
import numpy as np

# 初期値を入力

N = int(input())

T, A = map(int, input().split())

# H = [int(x) for x in input().split()]
H = list(map(int, input().split()))

# メインプログラム

Dummy = 100000
Answer = 0

for i in range(N):

    Temperture = T - 0.006*H[i]
    Dis = abs(A - Temperture)

    if Dummy > Dis:
        Answer = i
        Dummy = Dis

print(int(Answer + 1) )


Measured memory_bytes: 12500
n = gets.chomp.to_i
h = Hash.new(0)

gets.chomp.split.map(&:to_i).each {|i| h[i]+=1}

count = []
h.each do |k, v|
    count << v if v > 1
end

c1 = 0
c2 = 0
count.each do |i|
    if i > 2
        c1 += (i - 1) / 2
        c2 += 1 if i % 2 == 0
    else
        c2 += 1
    end
end

c3 = (c2 + 1) / 2

puts n - (c1 + c3) * 2

Measured memory_bytes: 15108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,k,n) for(int i = k; i <= n; i++) 
#define per(i,k,n) for(int i = k; i >= n; i--)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii; 
typedef vector<ii> vii;
typedef vector<char> vchar;
typedef vector<int> vi;
#define ff first
#define ss second

#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"


   //=\/=\/=\/=\/=\/=\/=\/=\/=\/=\        Jai Hind Dosto        /=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\
  //=\/=\/=\/=\                    ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿                             /=\/=\/=\/=\\
 //=\/=\/=\/=\                                                                               /=\/=\/=\/=\\
//=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\



int modPow(int a, int b);           

                
void solve(){
    int n,x ;
    cin >> x >> n ;
    set<int> a;
    rep(i,0,n){
        int temp; cin >> temp;
        a.insert(temp);
    }
    int ans = x;
    int pos =0, neg = 0;
    while(true){
        if(a.count(ans-neg)){
            neg++;
        }
        else{
            ans = ans-neg;
            break;
        }
        if(a.count(ans + pos)){
            pos++;
        }else{
            ans += pos;
            break;
        }
    }
    cout << ans << endl;
    
}






signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(6);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
   // int test=1; cin >> test; while(test--)
    solve();
}

int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}




Measured memory_bytes: 3652
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <iostream>
#include <set>
#include <cstdio>

typedef long long ll;

using namespace std;

const int mod = 10;

int myPow(int b, ll e){
  int ret = 1;
  while(e){
    if(e & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    e >>= 1;
  }
  return ret;
}

int main(){
  ll n, m, k; cin >> n >> m >> k; n %= mod;
  vector<int> dp(10, -1);
  int len = 0;
  int pos = 0;
  for(int i = 0; ; i++){
    const int t = myPow(n, 1ll + m * i);
    if(dp[t] == -1) dp[t] = i;
    else{
      len = i - dp[t];
      pos = t;
      break;
    }
  }

  ll ans = 0;
  REP(i,10){
    if(dp[i] != -1 && dp[i] <= k){
      if(dp[i] < dp[pos]){ ans += i; }
      else{ ans += (ll)i * ((k - dp[i] + len - 1) / len); }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1192
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  string s;
  cin >> N >> s;
  vector<int> A(N);
  for (int i = 0; i < N; ++i)
    A[i] = s[i] - '1';
  bool fl = false;
  if (count(A.begin(), A.end(), 1)) {
    for (int i = 0; i < N; ++i)
      A[i] %= 2;
  } else {
    fl = true;
    for (int i = 0; i < N; ++i)
      A[i] /= 2;
  }
  bool ans = 0;
  for (int i = 0; i < N; ++i)
    if ((N - 1 - i) == ((N - 1) ^ i))
      ans ^= A[i];
  cout << (ans * (1 + fl)) << '\n';

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

int main() {
	int x,y;
	cin >> x >> y;
	if (x == 2) {
		cout << "No" << endl;
	}
	else if (x == 4 || x == 6 || x == 9 || x == 11) {
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define N 23
int n;
int ara[N][N];
ll dp[1<<23];
int Set(int n,int pos){
    return n | (1<<pos);
}
bool Check(int n,int pos){
    return (bool)(n & (1<<pos));
}
ll solve(int mask)
{
    if(mask==(1<<n)-1) return 1;
    if(dp[mask]!=-1) return dp[mask];
    dp[mask]=0;
    int j=0;
    for(int i=0;i<n;i++) if(Check(mask,i)) j++;
    for(int i=0;i<n;i++)
    {
        if(ara[i][j] && !Check(mask,i)) dp[mask]=(dp[mask]+solve(Set(mask,i)))%mod;
    }
    return dp[mask];
}
int main()
{
    fastio;
    cin>>n;
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>ara[i][j];
    memset(dp,-1,sizeof dp);
    cout<<solve(0)<<endl;
}


Measured memory_bytes: 69164
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
int main() {
  int N[5]; // 変数の宣言
  rep(i,5) cin >> N[i]; // 標準入力

  rep(i,5){
    if(N[i] == 0){
      cout << i+1 << endl;
    }
  }
}



Measured memory_bytes: 3620
def main():
    n,m=map(int,input().split())
    l=-1
    r=10**5+1
    for _ in range(m):
        l2,r2=map(int,input().split())
        l=max(l,l2)
        r=min(r,r2)
    print(max(0, min(r,n)-l+1))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int> >
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;


int main(){
    int n; cin >> n;
    vector<vector<pair<int,int>>> edge;
    vector<bool> visited(n+1,false);
    vector<bool> wb(n+1, false);
    
    rep(i,n) edge.emplace_back();
    rep(i,n-1){
        int a,b,c; cin >> a >> b >> c;
        edge[a].emplace_back(b,c);
        edge[b].emplace_back(a,c);
    }

    queue<int> bfs;

    bfs.push(1);
    while(!bfs.empty()){
        int tmp = bfs.front();
        visited[tmp] = true;
        bfs.pop();
        rep(i,edge[tmp].size()){
            int next = edge[tmp][i].first;
            if(!visited[next]) bfs.push(next);

            if(edge[tmp][i].second %2 == 0){
                wb[next] = wb[tmp];
            }else{
                wb[next] = !wb[tmp];
            }
        }
    }

    rep1(i,n) cout << wb[i] << endl;
    
}

Measured memory_bytes: 6512
# coding: utf-8
# hello worldと表示する
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
ans=3**n
cons=1
lis=LI()
for i in range(n):
    if lis[i]%2==0:
        cons*=2
print(ans-cons)
        
    
    


Measured memory_bytes: 9416
#include<bits/stdc++.h>
using namespace std;
const int N = 100 + 5;
int n;
bool p[N][N];
int main()
{
	cin>>n;
	memset(p,1,sizeof(p));
	if (n & 1)
		for (int i = 1;i < n; ++i)
			p[i][n - i] = 0;
	else for (int i = 1;i <= n; ++i)
			p[i][n + 1 - i] = 0;
	int cnt = 0;
	for (int i = 1;i <= n; ++i)
		for (int j = 1;j < i; ++j)
			if (p[i][j]) ++cnt;
	printf("%d\n",cnt);
	for (int i = 1;i <= n; ++i)
		for (int j = 1;j < i; ++j)
			if (p[i][j]) printf("%d %d\n",i,j);
}

Measured memory_bytes: 256
import sys
import math
#from queue import *
#import random
#sys.setrecursionlimit(int(1e6))
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

x=input()

if x[0]==x[1]==x[2] and x[0]=='R':
	print(3)
elif x[0]==x[1] and x[0]=='R':
	print(2)
elif x[1]==x[2] and x[1]=='R':
	print(2)
elif x[0]=='R' or x[1]=='R' or x[2]=='R':
	print(1)
else:
	print(0)


Measured memory_bytes: 9156
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
town = [[] for _ in range(N)]
for i in range(Q):
    place, year = map(int, input().split())
    town[place-1].append([year,i])

# print(town)

ans = []
k = 0
for item in town:
    index = k
    # index = town.index(item)
    # print(item)
    item.sort()
    index = str(index+1)
    while len(index) < 6:
        index = '0' + index
    for i in range(len(item)):
        num = str(i+1)
        while len(num) < 6:
            num = '0' + num
        xxx = index + num
        ans.append([item[i][1],xxx])
    k += 1

ans.sort()
for item in ans:
    print(item[1])


Measured memory_bytes: 88624
#include <cstdio>
#include <vector>
#include <iostream>

using namespace std;

#define fail return puts("No") , 0
#define tru return puts("Yes") , 0

int n , m , u , v , ans = 0;

const int N = 1e5 + 5;

int vi[N];

vector <int> e[N];

int f1 , f2;

void dfs(int x){
	vi[x] = 1;
	for(auto y : e[x]){
		if(vi[y] == 2){
			if(f1)
				f2 = y;
			else
				f1 = y;
		}
		else
			if(!vi[y])
				dfs(y);
	}
}

int main(){
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		cin >> u >> v;
		e[u].push_back(v) , e[v].push_back(u);
	}
	int maxx = 0 , k = 0;
	for(int i = 1; i <= n; i++){
		if(e[i].size() & 1)
			fail;
	 	if(e[i].size() > maxx)
	 		maxx = e[i].size() , k = 1;
	 	else
	 		k += (maxx == e[i].size());
	}
	if(maxx >= 6)
		tru;
	if(maxx == 2 || k == 1)
		fail;
	if(k > 2)
		tru;
	for(int i = 1; i <= n; i++)
		if(e[i].size() == 4)
			vi[i] = 2; 
	for(int i = 1; i <= n; i++)
		if(!vi[i])
			f1 = f2 = 0 , dfs(i) , ans += f1 == f2;
	if(ans)
		tru;
	fail;
} 

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

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int min = 1e9+1;
    int count = 0;
    multiset<int, greater<int>> nums;
    int a;
    cin >> a;
    nums.insert(a);
    count++;
    for(int i = 1; i < N; i++)
    {
        cin >> a;
        auto coloredIte = nums.upper_bound(a);
        if(coloredIte == nums.end()){
            count++;
        }else{
            nums.erase(coloredIte);
        }
        nums.insert(a);
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int diff = b - a;

		int alen = 0;
		for (int i = 1; i < diff; i++) {
			alen += i;
		}

		int ans = alen - a;

		System.out.println(ans);

	}

}

Measured memory_bytes: 21844
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];


    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 0 && !(a[i] % 3 == 0 || a[i] % 5 == 0)){
            cout << "DENIED" << endl;
            return 0;
        }
    }

    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    int ans = 1;
    rep(i, n)
    {
        ans = min(2 * ans, ans + k);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/// --- In the name of ALLAH --- ///


//#include <cmath>
#include<bits/stdc++.h>
//#include<iostream>
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<double, double>   pdd;
typedef pair<ll, ll>           pll;
typedef vector<pii>            vii;
typedef vector<pll>            vll;
typedef double                 dl;

#define endl                   '\n'
#define PB                     push_back
#define F                      first
#define S                      second
#define all(a)                 (a).begin(),(a).end()
#define rall(a)                (a).rbegin(),(a).rend()
#define sz(x)                  (ll)x.size()
#define wt                     ll t; cin>>t; while(t--)
#define input(a,n)             for(int i=0;i<n;i++) cin>>a[i];

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define mod 10000007
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

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


const ll mx=1e9;




 main()
{
    optimize();
int n,m,c,i,j,p=0,k=0;
vi v;
cin>>n>>m>>c;
int a[n+1][m+1],b[m+1];
for(i=1;i<=m;i++)
    cin>>b[i];
for(i=1;i<=n;i++)
{
    for(j=1;j<=m;j++)
    {
        cin>>a[i][j];
        p=p+(a[i][j]*b[j]);
    }
    v.PB(p+c);
    p=0;
}
for(auto u:v)
{
    if(u>0)
        k++;
}
cout<<k<<endl;



    return 0;
}






























































































Measured memory_bytes: 3612
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
ll evaluate(VV &S,ll d,V &prev,V &C,ll j){
    
    ll temp = 0;
    temp+=S[d][j];
    rep(k, 26) {
        if (j == k) {
            continue;
        }
        temp -= C[k] * (d - prev[k]);
    }
    return temp;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll d;
    cin >> d;
    V C(26);
    rep(i, 26) cin >> C[i];
    VV S(d, V(26));
    rep(i, d) { rep(j, 26) cin >> S[i][j]; }
    ll width=350;
    vector<tuple<ll,V,V>> vec;
    V temp;
    rep(i,26)temp.push_back(-1);
    V temp2;
    vec.push_back({0,temp,temp2});
    rep3(i,0,d){
        priority_queue<tuple<ll, V, V>> q;
        for(auto j:vec){
            ll score=get<0>(j);
            V prev=get<1>(j);
            V history=get<2>(j);
            rep(k,26){
                ll value=evaluate(S,i,prev,C,k);
              ll prev2=prev[k];
                
                prev[k]=i;
                history.push_back(k);
                q.push({score+value,prev,history});
                history.pop_back();
              prev[k]=prev2;
            }
        }
        vec={};
        for(ll j=0;j<width&&!q.empty();j++){
            vec.push_back(q.top());
            q.pop();
        }
    }
    for(auto i:get<2>(vec[0])){
        cout<<i+1<<endl;
    }
}


Measured memory_bytes: 34400
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

// k=3
// 7 2 3 8 1 4 5 6 9
//     1 1 1
//         1 1 1
//             1 1 1
// 
// 1 1 1
// (9-1)/2= 4

signed main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,0,n)
        cin>>a[i];
    ll ans= (n-1 +k-2)/(k-1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		int temp = a / 2;
		int temp2 = a % 2 ? a / 2 + 1 : a / 2;
		printf("%d\n",temp * temp2);
	}
	return 0;
 } 


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t=0,x=0,y=0,f=0;
    cin>>n;
    for(int i=0,tt,tx,ty;i<n;i++)
    {
        cin>>tt>>tx>>ty;
        if((abs(tx-x)+abs(ty-y))%2!=(tt-t)%2||abs(tx-x)+abs(ty-y)>(tt-t))
            f=1;
        t=tt,x=tx,y=ty;
    }
    if(!f)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int A[100][100],b[100];
    int i,j,n,m;
    int d,sum=0;
    
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    
    for(j=0;j<m;j++){
        scanf("%d",&b[j]);
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            d=A[i][j]*b[j];
            sum=sum+d;
        }
        printf("%d\n",sum);
        sum=0;
    }
    return 0;
}



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

using namespace std;

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

int sim = 0;
if(s[2]==s[3]) sim++;
if(s[4]==s[5]) sim++;
  
if(sim == 2)cout << "Yes";
else cout << "No";

return 0;

}


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

int direction[5] = {0,-1,0,1,0};

int main(){
	int n;
	while(cin >> n,n){
		vector<pair<int,int>> v;
		v.push_back(make_pair(0,0));
		for(int i=1;i<n;i++){
			int n,d;
			cin >> n >> d;
			pair<int,int> x = v[n];
			v.push_back(make_pair(x.first + direction[d+1], x.second + direction[d]));
		}
		int minx=0,miny=0;
		int maxx=0,maxy=0;
		for(int i=0;i<v.size();i++){
			minx = min(minx,v[i].first);
			miny = min(miny,v[i].second);
			maxx = max(maxx,v[i].first);
			maxy = max(maxy,v[i].second);
		}
		cout << maxx-minx+1 << " " << maxy-miny+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3124