akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int GCD(int,int);

int main(void){
  
  int a,b;
  
  scanf("%d%d",&a,&b);
  
  printf("%d\n",GCD(a,b));
  
  return 0;
}

int GCD(int a, int b){
  
  int r;
  
  while(b!=0){
    
    r=b;
    b=a%b;
    a=r;

  }
  return a;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >>n;
  
  vector<int>a(n+2,0);
  for(int i=1; i<=n; i++){
    cin >>a[i];
  }
  
  vector<int>b(n+2,0);
  b[1]=a[1];
  for(int j=2; j<=n; j++){
    b[j]=__gcd(b[j-1],a[j]);
  }
  
  vector<int>c(n+2,0);
  c[n]=a[n];
  for(int k=n-1; k>0; k--){
    c[k]=__gcd(c[k+1],a[k]);
  }

  int answer=0;
  for(int m=1; m<=n; m++){
    if(__gcd(b[m-1],c[m+1])>answer){
      answer=__gcd(b[m-1],c[m+1]);
    }
  }
  cout <<answer <<endl;  
}


Measured memory_bytes: 1536
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string gotiusa;
    while(cin>>gotiusa){
        int joi=0; int ioi=0;
        for(int i=0; i<gotiusa.size()-2;i++){
            if(gotiusa[i]!='J')continue;
            else{
                if(gotiusa[i+1]=='O'&&gotiusa[i+2]=='I')joi++;
            }
        }
        for(int i=0; i<gotiusa.size()-2;i++){
            if(gotiusa[i]!='I')continue;
            if(gotiusa[i+1]=='O'&&gotiusa[i+2]=='I')
                ioi++;
        }
        cout<<joi<<endl;
        cout<<ioi<<endl;
    }
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

typedef long long ll;

ll n, m;
deque < int > q;

void yap(ll n){
	if(n == 1)
		return;
	if(n%2){
		yap(n - 1);
		q.push_back(++m);
	}else{
		yap(n/2);
		q.push_front(++m);
	}
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	yap(n + 1);
	printf("%lld\n", m+m);
	while(!q.empty()){
		printf("%d ", q.back());
		q.pop_back();
	}
	for(int i = 1; i <= m; i++)
		printf("%d ", i);
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    ans = ''
    for i in range(1, 20):
        if n <= 26**i:
            n -= 1
            for j in range(i):
                ans += chr((n % 26) + ord('a'))
                n //= 26
            print(ans[::-1])
            return
        else:
            n -= 26**i

if __name__ == '__main__':
    main()

Measured memory_bytes: 9224
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;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 FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int n;
	scanf("%d",&n);
	int ans = 0;
	int v[20], c[20];
	REP(i, n) {
		scanf("%d", &v[i]);
	}
	REP(i, n) {
		scanf("%d", &c[i]);
	}
	REP(i, n) {
		if (v[i] > c[i])ans += v[i] - c[i];
	}
	PRINTD(ans);
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n-1);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    for(int i=0;i<n-1;i++) cin >> c[i];
    int ans = 0;
    for(int i=0;i<n;i++){
        ans += b[a[i]-1];
        if(a[i+1]-a[i] == 1){
            ans += c[a[i]-1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	Int len = S.size();
	vector<vector<mint>> dp(len+1, vector<mint>(4));
	dp[0][0] = 1;

	for (Int i = 0; i < len; i++) {
		//i文字目を選択する場合
		if (S[i]=='A') {
			dp[i + 1][1] += dp[i][0];
		}
		else if (S[i]=='B') {
			dp[i + 1][2] += dp[i][1];
		}
		else if (S[i]=='C') {
			dp[i + 1][3] += dp[i][2];
		}
		else {//S[i]が?の時
			for (Int j = 0; j < 3; j++) {
				dp[i + 1][j + 1] += dp[i][j];
			}
		}

		//i文字目を選択しない場合
		if (S[i]=='?') {
			for (Int j = 0; j < 4; j++) {
				dp[i + 1][j] += dp[i][j] * 3;
			}
		}
		else {
			for (Int j = 0; j < 4; j++) {
				dp[i + 1][j] += dp[i][j];
			}
		}
	}

	cout << dp[len][3] << "\n";

}


Measured memory_bytes: 7376
#include <stdio.h>

int linearSearch(int A[], int n, int key) {
	int i;
	int cnt = 0;
	for (i = 0; i < n; i++) {
		if (A[i] == key) return 1;
	}
	return 0;
}

int main() {
	int i;
	int n, q;
	int S[10005], T[505];
	int ans = 0;

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

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &T[i]);
		if (linearSearch(S, n, T[i]) == 1) ans++;
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 2088
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>

using namespace std;

long long a[200010];
map<long long,int> _map;

int main()
{
    int n,k;scanf("%d%d",&n,&k);
    a[0]=0;
    for (int i=1;i<=n;++i) scanf("%lld",&a[i]);
    for (int i=1;i<=n;++i) a[i]+=a[i-1],a[i]%=k;
    for (int i=1;i<=n;++i){
        a[i]-=i;
        a[i]%=k;while(a[i]<0) a[i]+=k;
        a[i]%=k;
    }
    _map[0]=1;
    long long ans=0;
    for (int i=1;i<=n;++i){
        if (i>=k){
            long long tmp=a[i-k];
            _map[tmp]-=1;
        }

        long long tmp=a[i];
        ans+=_map[tmp];
        //printf("%lld %d\n",tmp,_map[tmp]);
        _map[tmp]+=1;

    }
    printf("%lld\n",ans);
}






Measured memory_bytes: 14336
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

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

LL a[300];

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n;
	//printf("%lld\n",gcd(12,8));
	while(~scanf("%d",&n)){
		for(int i = 1 ; i <= n ; i++){
			scanf("%lld",&a[i]);
		}
		LL sum = a[1];
		for(int i = 2 ; i <= n ; i++){
			sum = a[i]*((sum)/gcd(sum , a[i]));
		}
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    if 0 < int(S[:2]) <= 12 and 0 < int(S[2:]) <= 12:
        return "AMBIGUOUS"
    elif (int(S[:2]) > 12 or int(S[:2]) == 0) and 12 >= int(S[2:]) > 0:
        return "YYMM"
    elif 0 < int(S[:2]) <= 12 and (12 < int(S[2:]) or int(S[2:]) == 0):
        return "MMYY"
    else:
        return "NA"


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
fun main(args: Array<String>) {
    codefestival2016qualab()
}

fun codefestival2016qualab() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toInt() }

    val answer = aList.withIndex().map {
        if (it.index + 1 == aList[it.value - 1]) 1 else 0
    }.sum() / 2

    println(answer)
}


Measured memory_bytes: 53304
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
    int n;
    cin>>n;
    if(n==25)
    {
        cout<<"Christmas"<<endl;
    }
    else if(n==24)
    {
        cout<<"Christmas Eve"<<endl;
    }
    else if(n==23)
    {
        cout<<"Christmas Eve Eve"<<endl;
    }
    else if(n==22)
    {
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
        
	return 0;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll INF = 1e9;
const ll LINF = ll(1e18);
const ll MOD = 1000000007;
const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll modp, modm;
string s;
ll mpow(ll x, ll n, ll M)
{ //x^n(mod M)
    ll ans = 1;
    while (n != 0)
    {
        if (n & 1)
            ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}
ll calc(ll m)
{
    ll res = 0;
    while (m)
    {
        ll popc = __builtin_popcount(m);
        m %= popc;
        res++;
    }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n >> s;
    ll countt = 0;
    rep(i, n)
    {
        if (s[i] == '1')
            countt++;
    }
    ll count = countt;
    countt++;
    modp = 0;
    if (countt != 0)
    {
        rep(i, n)
        {
            modp *= 2;
            if (s[i] == '1')
                modp++;
            modp %= countt;
        }
    }
    countt -= 2;
    modm = 0;
    if (countt != 0)
    {
        rep(i, n)
        {
            modm *= 2;
            if (s[i] == '1')
                modm++;
            modm %= countt;
        }
    }
    countt++;
    for (ll i = 0; i < n; i++)
    {
        if (s[i] == '0')
        {
            s[i] = '1';
            count++;
        }
        else
        {
            s[i] = '0';
            count--;
        }
        ll m;
        if (count == 0)
        {
            cout << 0 << "\n";
        }
        else
        {
            if (count > countt)
            {
                m = modp;
                m += mpow(2, n - 1 - i, count);
                m %= count;
            }
            else
            {
                m = modm;
                m -= mpow(2, n - 1 - i, count);
                m += count;
                m %= count;
            }
            //cout<<m<<"\n";
            cout << calc(m) + 1 << "\n";
        }
        if (s[i] == '0')
        {
            s[i] = '1';
            count++;
        }
        else
        {
            s[i] = '0';
            count--;
        }
    }
}


Measured memory_bytes: 3720
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr LL kInf = 1e18;

string S;
int L;

int main() {
  cin >> S;
  L = S.size();
  vector<vector<LL>> dp(L + 1, vector<LL>(4));
  dp[0][0] = 1;
  for (int i = 0; i < L; ++i) {
    for (int j = 0; j < 4; ++j) {
      if (S[i] != '?') dp[i + 1][j] = dp[i][j];
      else             dp[i + 1][j] = dp[i][j] * 3;
      dp[i + 1][j] %= kMod;
    }

    if (S[i] == 'A' || S[i] == '?') dp[i + 1][1] += dp[i][0];
    if (S[i] == 'B' || S[i] == '?') dp[i + 1][2] += dp[i][1];
    if (S[i] == 'C' || S[i] == '?') dp[i + 1][3] += dp[i][2];

    for (int j = 0; j < 4; ++j) {
      dp[i + 1][j] %= kMod;
    }
  }
  cout << dp[L][3] << endl;
}


Measured memory_bytes: 7424
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>
using namespace std;

#define all(c) c.begin(),c.end()
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i,0,n)
#define MAX(x, y)  ((x > y)? x : y);
#define MIN(x, y)  ((x < y)? x : y);
#define dump(x)  cout << #x" = " << x << endl;
#define debug(x) cout << #x" = " << x << " (" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
typedef vector<int> vi;

int main() {
	int n, ans = 0;
	cin >> n;
	vector<int> vi(2 * n);

	REP(i, 2 * n) {
		cin >> vi[i];
	}

	sort(vi.begin(), vi.end());

	REP(i, n) {
		ans += vi[i * 2];
	}

	cout << ans << endl;

	// REP(i, 2 * n) cout << vi[i] << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import itertools

INF = 1001001001

def resolve():
  n = int(input())
  p = list(map(int, input().split()))
  q = list(map(int, input().split()))
  arr = []
  for i in range(1, n+1):
    arr.append(i)

  x = itertools.permutations(arr, n)

  a = 0
  b = 0
  for i, y in enumerate(x):
    if (p == list(y)):
      a = i + 1
    if (q == list(y)):
      b = i + 1

  print(abs(a - b))
resolve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N = 100 + 5;

int main(){
	int k;
	cin >> k;
	string s;
	cin >> s;
	int len = s.length();
	if(len <= k)
		cout << s << endl;
	else{
		for(int i = 0; i < k; i++)
			cout << s[i];
		cout << "..." << endl;
	}
		
    return 0;
} 

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
  int i,j,k,n,u,v,a,min;
  int M[100][100],d[100],p[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=1000000;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&a);
      M[u][v]=a;
    }
  }
  for(i=0;i<n;i++){
    d[i]=1000000;
    p[i]=0;
  }
  d[0]=0;
  p[0]=2;
  while(1){
    min=1000000;
    u=-1;
    for(i=0;i<n;i++){
    if(min > d[i] && p[i] != 1){
      u=i;
      min=d[i];
    }
  }
  if(u==-1){
    break;
  }
  p[u]=1;
  for(i=0;i<n;i++){
    if(p[i] != 1 && M[u][i] != 1000000){
      if(d[i] > d[u]+M[u][i]){
        d[i]=d[u]+M[u][i];
        p[i]=2;
      }
    }
  }
}
for(i=0;i<n;i++){
  if(d[i]==1000000){
  printf("%d -1\n",i);
}
else{
  printf("%d %d\n",i,d[i]);
}
}
return 0;
}



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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 128

int r[N];

int main()
{
    canhazfast();

    int n, k, m, cur = 0;

    cin >> n >> k;
    retif(k > (n-1)*(n-2)/2) cout << "-1\n", 0;
    for (int i = 1; i <= n; ++i) r[i] = i-1;
    m = n*(n-1)/2;
    for (int i = n; i > 0; --i) {
        while (cur < k && r[i] > 1) {
            ++cur;
            --m;
            --r[i];
        }
    }
    cout << m << '\n';
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= r[i]; ++j) cout << i << ' ' << j << '\n';
    }

    return 0;
}


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


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    vector<vector<int>> g(N);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int root = 0;
    auto dfs = [&](auto f, int v, int p) -> int {
        if (SZ(g[v]) == 1 && v != root) { return A[v]; }

        int sc = 0;
        int mxc = 0;
        FORE(w, g[v]) {
            if (w == p) continue;
            int c = f(f, w, v);
            sc += c;
            chmax(mxc, c);
        }
        int T = 2 * A[v] - sc;
        if (T < 0) {
            cout << "NO" << endl;
            exit(0);
        }
        chmax(mxc, T);
        if (mxc > (sc + T) / 2) {
            cout << "NO" << endl;
            exit(0);
        }
        return T;
    };
    while (SZ(g[root]) > 1) root++;
    dfs(dfs, root, -1);
    cout << "YES" << endl;
    return (0^_^0);
}



Measured memory_bytes: 12288
fun main(args: Array<String>) {
    abc000X()
}

fun abc000X() {
    val n = readLine()!!.toInt()

    var ans = 0
    for (i in 1..n) {
        if (i.toString().length % 2 == 1) {
            ans++
        }
    }
    println(ans)
}


Measured memory_bytes: 36496
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

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

    for (int i = 0; i < q; i++) {
        ll a, b, ans;
        scanf("%lld %lld", &a, &b);
        if (a > b) { swap(a, b); }

        if (a == b || abs(a - b) == 1) {
            ans = 2 * a - 2;
        } else {
            ll sq = (ll)ceil(sqrt(a*b)) - 1;
            if (sq * (sq + 1) < a * b) {
                ans = 2 * sq - 1;
            } else {
                ans = 2 * sq - 2;
            }
        }
        printf("%lld\n", ans);
    }

    return 0;
}

Measured memory_bytes: 128
import sys, os

def f():
    args = list(map(int,input().split()))
    if len(args) > 1:
        return args
    return args[0]

if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,k  = f()
    A = f()

    A = [0] + A
    last = [-1] * (n+1)

    last[1] = 0
    cur= 1

    pos = -1
    cycle = -1

    if k < n:
        for i in range(k):
            cur = A[cur]
        print(cur)
    else:
        for i in range(n):
            nxt = A[cur]
            if  i == n-1:
                pos = nxt
                cycle = n-1 - last[nxt]
            last[nxt] = i
            cur = nxt
            

        steps = (k - n)%cycle
        cur = pos
        for i in range(steps):
            cur = A[cur]
        print(cur)

solve()

Measured memory_bytes: 32308
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI L(N),R(N);
  rep(i,N) cin>>L[i]>>R[i];
  vector<P> LR,RL;
  rep(i,N){
    LR.push_back(make_pair(L[i],R[i]));
    RL.push_back(make_pair(R[i],L[i]));
  }
  int B=0,C=0;
  rep(i,N){
    int E=R[i]-L[i]+1;
    if(B<E){
      C=i;
      B=R[i]-L[i]+1;
    }
  }
  sort(all(LR));
  sort(all(RL));
  VI RR(N),RR2(N);
  RR[0]=LR[0].second;
  RR2[N-1]=LR[N-1].second;
  rep(i,N) if(i) RR[i]=min(RR[i-1],LR[i].second);
  rep(i,N) if(i) RR2[N-1-i]=min(RR2[N-i],LR[N-1-i].second);
  ll ans=B+max(0,RL[0].first-LR[N-1].first+1);
  rep(i,N-1){
    ll A=0;
    A+=max(0,RR[i]-LR[i].first+1);
    A+=max(0,RR2[i+1]-LR[N-1].first+1);
    if(A>ans) ans=A;
  }
  VI LL(N),LL2(N);
  LL[N-1]=RL[N-1].second;
  LL2[0]=RL[0].second;
  rep(i,N) if(i) LL[N-1-i]=max(LL[N-i],RL[N-1-i].second);
  rep(i,N) if(i) LL2[i]=max(LL2[i-1],RL[i].second);
  rep(i,N-1){
    ll A=0;
    A+=max(0,RL[N-1-i].first-LL[i]+1);
    A+=max(0,RL[0].first-LL2[N-2-i]+1);
    if(A>ans) ans=A;
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 4204
N = int(input())
L = list(map(int, input().split()))

ans=0

for i in range(N-2):
  if L[i] < L[i+1] and  L[i+1] < L[i+2]:
    ans +=1 
  if L[i] > L[i+1] and  L[i+1] > L[i+2]:
    ans +=1 
  else:
    pass

print(ans)

Measured memory_bytes: 3060
N = int(input())
A_lst = list(map(int, input().split()))
B_lst = list(map(int, input().split()))

ans = 0

for i in range(N-1, -1, -1):
    if A_lst[i+1] >= B_lst[i]:
        ans += B_lst[i]
        A_lst[i+1] -= B_lst[i]
        B_lst[i] = 0
    else:
        ans += A_lst[i+1]
        B_lst[i] -= A_lst[i+1]
        A_lst[i+1] = 0

#    print("i=",i)
#    print(A_lst)
#    print(B_lst)
    
    if A_lst[i] >= B_lst[i]:
        ans += B_lst[i]
        A_lst[i] -= B_lst[i]
        B_lst[i] = 0
    else:
        ans += A_lst[i]
        B_lst[i] -= A_lst[i]
        A_lst[i] = 0

#    print("i=",i)
#    print(A_lst)
#    print(B_lst)
#    print()




print(ans)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int ans=0,ct=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R') ct++;
        else
        {
            ans=max(ans,ct);
            ct=0;
        }
    }
    ans=max(ans,ct);
    cout<<ans<<'\n';
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int N, E, W, S;
  N=E=S=W=0;
  
  for(int i=0; i<s.size(); i++){
    if(s.at(i)=='N')N=1;
    if(s.at(i)=='W')W=1;
    if(s.at(i)=='E')E=1;
    if(s.at(i)=='S')S=1;
  }
  
  if(S==N && W==E)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;
typedef long long Int;
Int dp[52][52][52];
Int a[52], b[52];
Int res;
bool oks[52][52];

int main(){
	Int n;

	for(Int i = 0;i <= 51;i++){
		for(Int j = 0;j <= 51;j++){
			for(Int k = 0;k <= 51;k++){
				if(i == j)dp[i][j][k] = 1;
				if(k == 0)continue;
				dp[i][j][k] |= dp[i][j][k-1];
				dp[i][j][k] |= dp[i%k][j][k];
			}
		}
	}
	cin >> n;
	for(Int i = 0;i < n;i++){
		cin >> a[i];
		oks[i][a[i]] = true;
	}
	for(Int i = 0;i < n;i++)cin >> b[i];
	for(Int k = 51;k >= 1;k--){
		Int ok = 0;
		
		for(Int i = 0;i < n;i++){
			Int notok = 1;
			for(Int j = 0;j <= 51;j++){
				if(oks[i][j] && dp[j][b[i]][k-1])notok = 0;
			}
			if(notok == 1)ok = 1;
		}
		if(ok){
			for(Int i = 0;i < n;i++){
				for(Int j = 0;j < k;j++){
					for(Int l = j;l <= 51;l += k){
						oks[i][j] |= oks[i][l];
					}
				}
			}
		}
		if(k == 51 && ok){
			cout << -1 << endl;
			return 0;
		}
		res += ok << k;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2040
fun main(args: Array<String>) {
    readLine()!!
    val xs = readLine()!!.split(" ").map(String::toInt)
    println(xs.map(::div2Count).min())
}

fun div2Count(n: Int): Int {
    var count = 0
    var nn = n

    while (nn % 2 == 0) {
        count++
        nn /= 2
    }
    return count
}



Measured memory_bytes: 37868
package main

import "fmt"

func main() {

	var N,K,Q int
	fmt.Scan(&N,&K,&Q)

	//nums := make([]int, Q)
	ans := make([]int, N)

	for i:= 0 ; i < Q ; i++ {
		var person int
		fmt.Scan(&person)

		ans[person - 1]++
	}

	for i:= 0 ; i < N ; i++ {
		if 1 <= K - Q + ans[i] {
			fmt.Println("Yes")
		}else {
			fmt.Println("No")
		}
	}

	
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
#define PB push_back
typedef pair<int,int> PII;
#define FF first
#define SS second

const int N = 100000 + 5;

vector<int> G[N];
bitset<N> visited;
int sum1=0, sum2=0;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;cin>>n;
	for(int i=0;i<n-1;i++){
		int u, v;cin>>u>>v;
		G[u].PB(v);
		G[v].PB(u);
	}
	queue<PII> BFS;
	BFS.push({1,1});BFS.push({n,2});
	visited[1]=1;visited[n]=1;
	while(!BFS.empty()){
		int cur=BFS.front().FF;
		int id=BFS.front().SS;
		BFS.pop();
		for(auto i:G[cur]){
			if(!visited[i]){
				visited[i]=1;
				BFS.push({i, id});
				if(id==1) sum1++;
				else sum2++;
			}
		}
	}
	cout<<((sum1>sum2)?"Fennec":"Snuke")<<'\n';
	return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<bits/stdc++.h>
#define int double
#define vi vector<int>
#define vvi vector<vi>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define start() int t;cin>>t;while(t--) 
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
using namespace std;
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0), cin.tie(0); } }_;
 
int32_t main()
{
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int hrs=(h2-h1)*60;
    int mins=m2-m1;
    int total=hrs+mins-k;
    if(total>=0)cout<<total<<endl;
    else cout<<0<<endl;
    // cout<<total/k<<endl;
    return 0;
}

Measured memory_bytes: 3768
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	string s;
	cin>>s;
	print("ABC"+s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=6005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    map<char,int> MA;
    MA['y']=1;
    MA['u']=1;
    MA['i']=1;
    MA['o']=1;
    MA['p']=1;
    MA['j']=1;
    MA['k']=1;
    MA['l']=1;
    MA['h']=1;
    MA['n']=1;
    MA['m']=1;
    
    while(1){
        string S;cin>>S;
        if(S[0]=='#') break;
        int cnt=0;
        
        for(int i=1;i<S.size();i++){
            if(MA[S[i-1]]+MA[S[i]]==1) cnt++;
        }
        
        cout<<cnt<<endl;
    }
}



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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define ll unsigned long long
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const int Maxn = (int)1e5 + 1;
const ld pi = acos(-1);
const int mod = (int)1e9 + 7;
const int inf = (int)1e18;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A)
{
    fr(i, 0, (int)A.size()) out << A[i] << " ";
    return out;
}

template <class T>
ostream &operator<<(ostream &out, deque<T> &dq)
{
    while (!dq.empty())
    {
        out << dq.front() << " ";
        dq.pop_front();
    }
    return out;
}

int32_t main()
{
    IOS deque<char> dq;
    string p;
    cin >> p;
    for (auto x : p)
    {
        dq.push_back(x);
    }
    bool flag = true;
    int k;
    cin >> k;
    while (k--)
    {
        int n;
        cin >> n;
        if (n == 1)
        {
            flag = !flag;
        }
        else
        {
            char x, y;
            cin >> x >> y;
            if (flag)
            {
                if (x != '1')
                {
                    dq.push_back(y);
                }
                else
                {
                    dq.push_front(y);
                }
            }
            else
            {
                if (x != '1')
                {
                    dq.push_front(y);
                }
                else
                {
                    dq.push_back(y);
                }
            }
        }
    }
    // cout << dq << "ok" << endl;
    string s;
    if (!flag)
    {
        while (!dq.empty())
        {
            s += dq.back();
            dq.pop_back();
        }
    }
    else
    {
        while (!dq.empty())
        {
            s += dq.front();
            dq.pop_front();
        }
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 4276
use proconio::input;

fn gcd(n: u64, m: u64) -> u64 {
    if n < m {
        gcd(m, n)
    } else if m == 0 {
        n
    } else {
        gcd(m, n % m)
    }
}

fn main() {
    input! {
        n: usize,
        k: u64,
        a: [u64; n],
    };
    let mut ltall = true;
    for &a_i in a.iter() {
        if a_i == k {
            println!("POSSIBLE");
            return;
        } else if a_i > k {
            ltall = false;
        }
    }
    if ltall {
        println!("IMPOSSIBLE");
        return;
    }
    let mut x = a[0];
    for &a_i in a.iter().skip(1) {
        x = gcd(x, a_i);
    }
    println!("{}", if k % x == 0 { "POSSIBLE" } else { "IMPOSSIBLE" });
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    int ans = 0;
    int min = 0;
    rep(i, S.length()) {
        if(S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T') {
            min++;
            ans = max(ans, min);
        } else {
            min = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int[] A;
    static int[] B;

    public static void main(String[] args) {
        FastScanner fc = new FastScanner(System.in);
        N = fc.nextInt();
        A = fc.nextIntArray(N);
        B = fc.nextIntArray(N);
        System.out.println(solve() ? "Yes" : "No");
    }

    static boolean solve() {
        long x = 0;
        long y = 0;
        for (int i = 0; i < N; i++) {
            if( A[i] > B[i] ) {
                x += A[i] - B[i];

            } else if( A[i] < B[i] ) {
                int diff = B[i] - A[i];
                y += (B[i] - A[i]) / 2;
            }
        }
        return x <= y;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

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

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

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

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


Measured memory_bytes: 25940
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	N := sc.NextInt64()
	a := make([]int64, 5)
	var ans int64
	for i := 0; i < 5; i++ {
		a[i] = sc.NextInt64()
		ans = max64(ans, (a[i]+N-1)/a[i])
	}
	fmt.Println(ans + 4)
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt64() int64 {
	i, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


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

using namespace std;


int main()
{

	unsigned long long n;
	unsigned long long count = 1;
	cin >> n;
	vector <unsigned long long> people(5);
	for (int i = 0; i < 5; i++) cin >> people[i];
	unsigned long long answer = 0;
	unsigned long long katamari = 0;
	unsigned long long t = 0;

	t = (n - 1) / people[0] + 1;
	answer = t;
	katamari = people[0];

	for (int i = 1; i < 5; i++) {
		if (people[i] >= katamari) {
			answer++;
		}
		else {
			answer += (n - (t-1) * people[i] - 1) / people[i] + 1;
			katamari = people[i];
			t = (n - 1) / people[i] + 1;
		}
	}
	cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {
	int H, W, K;
	boolean[][] cells;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		H = Integer.parseInt(tokens[0]);
		W = Integer.parseInt(tokens[1]);
		K = Integer.parseInt(tokens[2]);
		this.cells = new boolean[H][W];
		for (int h = 0; h < H; ++h) {
			String line = in.readLine();
			for (int w = 0; w < W; ++w) {
				char c = line.charAt(w);
				cells[h][w] = c == '0' ? false : true;
			}
		}

	}

	void addRow(int[] prevs, boolean[] row) {
		for (int i = 0; i < prevs.length; ++i) {
			if (row[i]) {
				prevs[i]++;
			}
		}
	}

	List<int[]> splitRow(int index) {
		Deque<int[]> deque = new ArrayDeque<>();
		deque.addLast(new int[W]);
		Arrays.fill(deque.getLast(), 0);
		addRow(deque.getLast(), cells[0]);
		for (int i = 1; i < H; ++i) {
			if ((index & 1) > 0) {
				// 新しいrowをたす
				deque.addLast(new int[W]);
				Arrays.fill(deque.getLast(), 0);
			}
			addRow(deque.getLast(), cells[i]);
			index >>= 1;
		}
		List<int[]> list = new ArrayList<>(deque.size());
		while (!deque.isEmpty()) {
			list.add(deque.pollFirst());
		}

		return list;
	}

	int splitCol(List<int[]> rows) {
		int[] whites = new int[rows.size()];
		Arrays.fill(whites, 0);
		int count = 0;
		for (int w = 0; w < W; ++w) {
			boolean cond = false;
			for (int h = 0; h < rows.size(); ++h) {
				int addVal = rows.get(h)[w];
				if (addVal > K) {
					// 不可能
					return -1;
				}
				whites[h] += rows.get(h)[w];
				if (whites[h] > K) {
					cond = true;
				}
			}
			if (cond) {
				++count;
				for (int h = 0; h < rows.size(); ++h) {
					whites[h] = rows.get(h)[w];
				}
			}
		}
		return count;
	}

	int calc(int index) {
		List<int[]> rows = splitRow(index);
		int splitCount = rows.size() - 1;
		int v = splitCol(rows);
		if (v < 0) {
			return Integer.MAX_VALUE / 2;
		} else {
			return splitCount + v;
		}
	}

	void calc() {
		int count = Integer.MAX_VALUE / 2;
		int maxIndex = (int) Math.pow(2, H - 1);
		for (int index = 0; index < maxIndex; ++index) {
			count = Math.min(count, calc(index));
		}
		System.out.println(count);

	}

	void showResult() {
	}

}

Measured memory_bytes: 31828
#include <bits/stdc++.h>
using namespace std;
int n,a[105],x,y,he = 0;
int main()
{
	scanf("%d",&n);
	for (int i = 1; i <= n; i++)
		{
			scanf("%d",&a[i]);
			he+=a[i];
		}
	scanf("%d",&n);
	for (int i = 1; i <= n; i++)
		{
			scanf("%d%d",&x,&y);
			printf("%d\n",he-a[x]+y);
			}
	//可能和题解有些像，但绝没抄袭！			
	return 0;
}

Measured memory_bytes: 256
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//以下、素集合と木は同じものを表す
class UnionFind {
public:
    vector<ll> parent; //parent[i]はiの親
    vector<ll> siz; //素集合のサイズを表す配列(1で初期化)
    map<ll,vector<ll>> group;//素集合ごとに管理する連想配列(keyはそれぞれの素集合の親、valueはその素集合の要素の配列)

    //コンストラクタ
    UnionFind(ll n):parent(n),siz(n,1){ 
        //全ての要素の根が自身であるとして初期化
        for(ll i=0;i<n;i++){parent[i]=i;}
    }

    //データxの属する木の根を取得(経路圧縮も行う)
    ll root(ll x){
        if(parent[x]==x) return x;
        return parent[x]=root(parent[x]);//代入式の値は代入した変数の値なので、経路圧縮できる
    }

    //xとyの木を併合
    void unite(ll x,ll y){
        ll rx=root(x);//xの根
        ll ry=root(y);//yの根
        if(rx==ry) return;//同じ木にある時
        //小さい集合を大きい集合へと併合(ry→rxへ併合)
        if(siz[rx]<siz[ry]) swap(rx,ry);
        siz[rx]+=siz[ry];
        parent[ry]=rx;//xとyが同じ木にない時はyの根ryをxの根rxにつける
    }

    //xとyが属する木が同じかを判定
    bool same(ll x,ll y){
        ll rx=root(x);
        ll ry=root(y);
        return rx==ry;
    }

    //xの素集合のサイズを取得
    ll size(ll x){
        return siz[root(x)];
    }

    //素集合をそれぞれグループ化
    void grouping(ll n){
        //経路圧縮を先に行う
        REP(i,n)root(i);
        //mapで管理する(デフォルト構築を利用)
        REP(i,n)group[parent[i]].PB(i);
    }
};

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll n,m;cin>>n>>m;
    UnionFind uf(n);
    REP(i,m){
        ll a,b;cin>>a>>b;
        uf.unite(a-1,b-1);
    }
    uf.grouping(n);
    ll ans=0;
    REP(i,n){
        ans=max(ans,uf.siz[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 28112
function Main(input){
	input = input.split("\n").map(Number);
	var now = 1;
	for(var i=0;i<input[0];i++){
		if(now>=input[1]) now += input[1];
		else now *= 2;
	}
	console.log(now)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064