akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

// Description: ????????????
// Verifyed: various problem 
const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
const P O=0.0L;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P p;R c;};

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline int sdot(P o,P a,P b){return sgn(dot(o,a,b));}
inline int sdet(P o,P a,P b){return sgn(det(o,a,b));}

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/(l.t-l.s)); return (1-u)*l.s+u*l.t;}

//reflection verify AOJ CGL_1_B
P refl(L l,P p){return 2.0L*proj(l,p)-p;}

// CCW verify AOJ CGL_1_C
enum CCW{ LEFT = 1,RIGHT = 2,BACK = 4,FRONT = 8,ON = 16};
inline int ccw(P o,P a, P b) {
	a-=o,b-=o,o-=o;
	if(sdet(o,a,b) > 0) return LEFT;    // counter clockwise
	if(sdet(o,a,b) < 0) return RIGHT;   // clockwise
	if(sdot(o,a,b) < 0) return BACK;    // b--base--a on line
	if(sgn(norm(a)-norm(b)) < 0) return FRONT;   // base--a--b on line
	return ON; // base--b--a on line  semnet determination betwenn a and b 
}

istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

int main(void){
	P a,b,p;
	int n;
	cin >> a >> b >> n;
	rep(i,n){
		cin >> p;
		int res=ccw(a,b,p);
		if(res==LEFT) cout << "COUNTER_CLOCKWISE" << endl;
		if(res==RIGHT) cout << "CLOCKWISE" << endl;
		if(res==BACK) cout << "ONLINE_BACK" << endl;
		if(res==FRONT) cout << "ONLINE_FRONT" << endl;
		if(res==ON) cout << "ON_SEGMENT" << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int a, b; cin>>a>>b;
    cout<<a * b<<endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int x=1;x<=n;++x){
        int cnt=0;
        for(int i=1;i<=x;++i){
            if(((i*i)+1+1+i+1+i)>x) break;
            for(int j=1;j<=x;++j){
                if(((i*i)+(j*j)+1+(i*j)+j+i)>x) break;
                for(int k=1;k<=x;++k){
                    if(((i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i))>x) break;
                    if(((i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i))==x) ++cnt;
                }
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}

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

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a >= k) {
        cout << k << endl;
        return 0;
    } else if(a + b >= k) {
        cout << a << endl;
        return 0;
    } else {
        cout << a - (k - a - b) << endl;
        return 0;
    }
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int T = sc.nextInt();
		int a = N/X;
		sc.close();
		if(N%X==0) {
			System.out.println(T*a);
		}else {
			System.out.println(T*(a+1));
		}

	}

}

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

int main() {
  string A;
  cin>>A;
  if(A.at(0)==A.at(1)&&A.at(2)==A.at(3)&&A.at(0)!=A.at(2)){
    cout<<"Yes"<< endl;
    return 0;
  }
  if(A.at(0)==A.at(2)&&A.at(1)==A.at(3)&&A.at(0)!=A.at(1)){
    cout<<"Yes"<< endl;
    return 0;
  }
  if(A.at(0)==A.at(3)&&A.at(1)==A.at(2)&&A.at(0)!=A.at(1)){
    cout<<"Yes"<< endl;
    return 0;
  }
  else{
    cout<< "No"<< endl;
  }
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = IS()
    if '9' in set(n):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    typedef long double ld;

    ld a, b, x;
    cin >> a >> b >> x;


    ld ng = 90, ok = 0;
    ld eps = 1e-12;
    REP(i, 50) {
       ld mid = (ok + ng) / 2;

       ld t = tan(mid * M_PI / 180);
       if (x / a / a - a * t / 2 > eps) {
           if (x / a / a + a * t / 2 > b + eps) ng = mid;
           else ok = mid;
       } else {
           if (sqrt(2 * x * t / a) > b + eps) ng = mid;
           else ok = mid;
       }

       debug(ng, ok);
    }

    print(ok);
    
}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
#define l_ength size
using ll = long long;
const int mod = 1000000007;
const ll infll = (1ll<<60);
using namespace std;

const int white = 0;
const int black = 1;
const int bound = 100010;

vector<int> graph[bound];
vector<int> graph_d[bound];
bool bscht[bound];

void direct( int p ){
	bscht[p] = true;
	for( auto next : graph[p] ){
		if( bscht[next] ) continue;
		graph_d[p].push_back(next);
		direct(next);
	}
}

ll memo[bound][2];
bool bknnt[bound][2];

ll dfs( int p, int c ){
	if( bknnt[p][c] ) return memo[p][c];
	bknnt[p][c] = true;
	ll prd = 1;
	for( auto next : graph_d[p] ){
		if( c == white ){
			prd *= ( dfs(next, white)+dfs(next, black) ) % mod;
			prd %= mod;
		} else {
			prd *= dfs(next, white);
			prd %= mod;
		}
	}
	return memo[p][c] = prd;
}

int main(){
	int n; cin >> n;
	for( int i = 0; i < n-1; ++i ){
		int x, y; cin >> x >> y; --x; --y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	direct(0);
	cout << (dfs(0, white)+dfs(0, black))%mod << endl;
}

Measured memory_bytes: 21376
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    string s; cin >> s;
    string ans = "No";
    if (s[0] == s[1] && s[1] == s[2])
        ans = "Yes";
    if (s[1] == s[2] && s[2] == s[3])
        ans = "Yes";
    cout << ans << endl;
}


Measured memory_bytes: 3516
//Tuvshee
 
#include<iomanip>
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
using namespace std;
#define I int
#define D double
#define F float
#define C char
#define S string
#define B bool
#define L long long
#define rep(n) for(int i=0;i<n;i++)
#define reps(m,n,c) for(int c=m;c<n;c++)
#define repd(m,n,j) for(int j=n;j>m;j--)
#define whL while
#define eL endl
#define oR ||
#define anD &&
#define rtn return
#define pause system("PAUSE")
#define Max 300
#define max(m,n) ((n<m)?m:n)
#define min(m,n) ((n>m)?m:n)
 
int main()
{
	D r;
	cin>>r;
	cout<<setprecision(6)<<fixed<<M_PI*r*r<<' '<<2*M_PI*r<<eL;
	rtn 0;
}

Measured memory_bytes: 1284
h, w = gets.split.map(&:to_i)
ss = h.times.map { gets.chomp }

h.times do |i|
  ans = Array.new(w, 0)

  w.times do |j|
    if ss[i][j] == "#"
      ans[j] = ss[i][j]
      next
    end

    l = j - 1 < 0 ? j : j - 1
    r = j + 1 > w ? j : j + 1

    if i - 1 >= 0
      ans[j] += ss[i - 1][l..r].count("#")
    end

    ans[j] += ss[i][l..r].count("#")

    if i + 1 <= h - 1
      ans[j] += ss[i + 1][l..r].count("#")
    end
  end

  puts ans.join
end


Measured memory_bytes: 1788
# N個の整数の列 A1,…,ANが与えられます。
# これらの逆数の総和の逆数 1/(1/A1+…+1/AN)を求めてください。

# 入力は以下の形式で標準入力から与えられる。
# n
n = gets.chomp.to_i
# a1 a2 … an
a = gets.chomp.split(" ").map(&:to_i)

# 1 / (1/a1 + … + 1/an) の値を表す小数 (または整数) を出力せよ。
if n == 1
  puts a[0]
else
  pre_v = 0
  is_same = true
  a.each_with_index do |v, idx|
    pre_v = v if idx == 0
    is_same = false if pre_v != v
  end
  
  if is_same
    p (pre_v.to_f/a.size.to_f)
  else
    a = a.map {|v| 1 / v.to_f }
    total = 0
    a.each {|e| total += e }
    p (1.0/total)
  end
end


Measured memory_bytes: 1788
#include<stdio.h>
#define MAX 100000
int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i){ return 2*i+1;}

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);

  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H) printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2040
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
    // 整数の入力
    double a[n];
  double A=0;
  for(int i = 0; i < n; i++) {
   cin >> a[i];
    A += 1.0 / a[i];
  }
   cout << 1.0 / A << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug puts("&&&&&&&&")
#define read(x) scanf("%lld",&x)
using namespace std;
typedef long long LL;
const int maxn=1e6+5;
const int maxx=1e10+2;
LL a[maxn];
LL b[maxn];
LL n;
map<LL,int>ma;
LL sqr(LL a) {
    return a*a;
}
int main() {
    while(cin>>n) {
        ma.clear();
        for(LL i=1;i<=n;i++) {
            LL t;
            cin>>t;
            for(LL j=2;j*j*j<=t;j++) {
                while(t%(j*j*j)==0) {
                    t/=(j*j*j);
                }
            }
            ma[t]++;a[i]=t;
            LL ans=1;
            for(LL j=2;j*j*j<=t;j++) {
                if(t%j==0) {
                    if(t%(j*j)==0) {
                        ans*=j;
                    }
                    else {
                        ans*=(j*j);
                    }
                }
                 while(t%j==0) {
                        t/=j;
                }
            }
            if (sqr((LL)sqrt(t))==t) ans*=(LL)sqrt(t);
            else ans*=t*t;
            b[i]=ans;
        }
        LL ans1=0;
        if(ma[1]){
            ans1++;
            ma[1]=0;}
        for(int i=1;i<=n;i++) {
            ans1+=max(ma[a[i]],ma[b[i]]);
            ma[a[i]]=ma[b[i]]=0;
        }
        cout<<ans1<<endl;
    }
    return 0;
}


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

using namespace std;

int main(){

	int n, m=0;
	double ans=1.0;

	cin>> n;

	for(int i=1;i<=n;i++){
		if(i%2==1) m++;
	}

	ans*=m;
	ans/=n;

	cout<< ans << endl;

}

Measured memory_bytes: 256
nn, mm = gets.split.map(&:to_i)
ss=[]
ss_size=[]
mm.times do
  arr = gets.split.map(&:to_i)
  ss_size << arr.shift
  ss << arr
end
pp = gets.split.map(&:to_i)

cnt = 0
# 全パターン
0.upto(2**nn-1) do |n|
  pattern = "%0#{nn}d" % n.to_s(2)
  can = true
  # 全電球でチェック
  0.upto(mm-1) do |i|
    ons = ss[i]
    res = pp[i]
    on_cnt = 0
    ons.each do |on_num|
      on_cnt+=1 if pattern[on_num-1]=="1"
    end
    unless on_cnt%2 == res
      can = false
      break
    end
  end
  if can
    cnt+=1
  end
end

puts cnt

Measured memory_bytes: 1788
def is_prime(n: int) -> bool:
    for i in range(2, n):
        if n % i == 0:
            return False
    return True


def smallest_prime_above_n(n: int) -> int:
    prime_candidate = n
    while True:
        if is_prime(prime_candidate):
            return prime_candidate
        prime_candidate += 1


X = int(input())
print(smallest_prime_above_n(X))


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


vector<ll> enum_div(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

int main(void) {
    
    ll n;
    cin>>n;
    vll v=enum_div(n);
    int ans=INF;
    rep(i,v.size()){
        int da=floor(log10(v[i]))+1;
        int db=floor(log10(n/v[i]))+1;
        ans=min(ans,max(da,db));
    }
    fin(ans);
}


Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

void dfs(int v, int s, vector<int> &side, bool &ok, int &count0, int &count1,
         vector<vector<int>> &adj) {
  if (side[v] != -1) {
    if (side[v] != s)
      ok = false;
    return;
  }
  side[v] = s;
  if (s == 0) ++count0;
  else ++count1;
  for (int u : adj[v])
    dfs(u, s ^ 1, side, ok, count0, count1, adj);
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<vector<bool>> comp_adj(n, vector<bool>(n, false));
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b), --a, --b;
    comp_adj[a][b] = true;
    comp_adj[b][a] = true;
  }
  vector<vector<int>> adj(n);
  for (int a = 0; a < n; ++a)
    for (int b = 0; b < n; ++b)
      if (a != b && comp_adj[a][b] == false)
        adj[a].push_back(b);
  vector<int> side(n, -1);
  bool ok = true;
  vector<bool> possible(n + 1, false);
  possible[0] = true;
  for (int i = 0; i < n; ++i)
    if (side[i] == -1) {
      int count0 = 0, count1 = 0;
      dfs(i, 0, side, ok, count0, count1, adj);
      vector<bool> new_possible(n + 1, false);
      for (int c = n; c >= 0; c--)
        if (possible[c]) {
          new_possible[c + count0] = true;
          new_possible[c + count1] = true;
        }
      possible = new_possible;
    }

  if (!ok) printf("-1\n");
  else {
    int result = INT_MAX;
    for (int c = 0; c <= n; ++c)
      if (possible[c])
        result = min(result, c * (c - 1) / 2 + (n - c) * (n - c - 1) / 2);
    printf("%d\n", result);
  }

  return 0;
}


Measured memory_bytes: 3200
x = gets.chomp
a = 0
b = 0
for n in 0..1
  if x[n, 1] == x[n + 1, 1]
    a = a + 1
  end
end
for n in 1..2
  if x[n, 1] == x[n + 1, 1]
    b = b + 1
  end
end
if a == 2 or b == 2
  puts "Yes"
  exit
end
puts "No"


Measured memory_bytes: 1788
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int N, K; cin >> N >> K;

    int sum = 0;
    for (int i = 0; i < N; ++i) {
        int tmp; cin >> tmp;
        sum = sum + min(tmp, K - tmp) * 2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""



"""
import sys


def solve(N, restaurants):
    restaurants.sort(key=lambda x: [x[0], -x[1]])
    return [r[2] for r in restaurants]


def main(args):
    N = int(input())
    restaurants = []
    for i in range(N):
        s, p = input().split()
        p = int(p)
        restaurants.append([s, p, i+1])
    ans = solve(N, restaurants)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val (h, w, k) = readLine()!!.split(' ').map { it.toInt() }
    val map = Array<String>(h) {""}

    repeat(h) {
        val s = readLine()!!
        map[it] = s
    }

    var answer = 0
    fun chk(delH: BooleanArray, delW:BooleanArray) {
        var cnt = 0
        for (i in 0 until h) {
            for (j in 0 until w) {
                if (map[i][j] == '#' && !delH[i] && delW[j]) cnt++
            }
        }
        if (cnt == k) answer++
    }

    val delListH = BooleanArray(h) { false }
    val delListW = BooleanArray(w) { false }

    fun createW(d:Int) {
        arrayOf(true,false).forEach {
            delListW[d] = it
            if (d+1 == w) {
                chk(delListH, delListW)
            } else {
                createW(d+1)
            }
        }
    }

    fun createH(d:Int) {
        arrayOf(true,false).forEach {
            delListH[d] = it
            if (d+1 == h) {
                createW(0)
            } else {
                createH(d+1)
            }
        }
    }

    createH(0)
    println(answer)
}


Measured memory_bytes: 36712
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()
ans = 1
a_array = na()
overflow = 0
for a in a_array:
    if a == 0:
        ans = 0
        break
    if not overflow:
        ans = ans * a
        if ans > 10 ** 18:
            overflow = 1
            ans = -1

print(ans)


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pii pair<int, int>
#define vii vector<pii>
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vd vector<double>
#define vvi vector< vector<int> >
#define vvii vector< vector< pii > >
#define ld long double
#define mapii map<int, int>
#define mapsi map<string, int>
#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define INF  LLONG_MAX
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define pie  acos(-1)
#define mod(n,m) ((n % m + m) % m)
#define eps (1e-8)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'
#define output freopen("output.txt", "w", stdout)
#define mp(x, y, z) {x, {y, z}}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int arr[8];
    reset(arr, 0);
    int cnt = 0;
    rep(i, 0, n)
    {
        int x;
        cin >> x;
        if (x <= 399) arr[0]++;
        else if (x <= 799) arr[1]++;
        else if (x <= 1199) arr[2]++;
        else if (x <= 1599) arr[3]++;
        else if (x <= 1999) arr[4]++;
        else if (x <= 2399) arr[5]++;
        else if (x <= 2799) arr[6]++;
        else if (x <= 3199) arr[7]++;
        else cnt++;
    }
    int hoba = 0;
    rep(i, 0, 8) hoba += (arr[i] ? 1 : 0);
    cout << max(1, hoba) << " " << hoba + cnt;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sub[300000];

int main()
{
    int i,n,m;
    cin >> n;
    for (i = 1 ; i <n;i++)
    {
        cin >> m;
        sub[m]++;
    }
    for (i = 1 ; i<=n ;i++)
    {
        cout<<sub[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    while(cin >> n){
        vi dp(3);
        REP(i, n) {
            vi nxt(3);
            REP(j, 3) {
                int x;
                cin >> x;
                REP(k, 3) {
                    if(j != k) {
                        chmax(nxt[j], dp[k] + x);
                    }
                }
            }
            swap(dp, nxt);
        }
        cout << *max_element(ALL(dp)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	ll x, y;
	cin >> x >> y;
	ll res = 0;
	for (; x <= y; x *= 2) ++res;
	cout << res << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    string S;cin>>S;
    if(S=="SAT"){
        cout<<1<<endl;
    }
        if(S=="FRI"){
        cout<<2<<endl;
    }    if(S=="THU"){
        cout<<3<<endl;
    }    if(S=="WED"){
        cout<<4<<endl;
    }    if(S=="TUE"){
        cout<<5<<endl;
    }    if(S=="MON"){
        cout<<6<<endl;
    }
        if(S=="SUN"){
        cout<<7<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

int next_prime = 2;

bool isPrime(int a){
    int limit = sqrt(a);
    for(int i = 2; i <= limit; i++){
        if(a % i == 0) return false;
    }
    next_prime = a;
    return true;
}

int main(){
    int x;
    cin >> x;
    int number = x;

    if(x % 2 == 0){
        if(number != 2){
            number++;
        }
        while(1){
            if(isPrime(number)){
                cout << next_prime << endl;
                return 0;
            }
            number += 2;
        }
    }else{
        while(1){
            if(isPrime(number)){
                cout << next_prime << endl;
                return 0;
            }
            number += 2;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n, m; cin >> n >> m;
    vector<string> p(m);
    vector<tuple<int, int, int>> py(m);
    rep(i, m){
        string x; 
        int z;
        cin >> x >> z;

        p.at(i) = x;
        py.at(i) = make_tuple(stoi(x), z, i);
    }

    vector<pair<string, int>> a(m);
    rep(i, m){
        string tmp;
        for(int j=0; j<6-p.at(i).size(); j++){
           tmp += "0";
        }
        tmp += p.at(i);
        a.at(i).second = i;
        a.at(i).first = tmp;

    } 

    sort(py.begin(), py.end());
    int step = 1;
    vector<pair<int, string>> b(m);
    b.at(0) = make_pair(get<2>(py.at(0)), "000001");
    rep(i, m-1){
        if(get<0>(py.at(i+1)) == get<0>(py.at(i))){
            step++;
            string tmp = to_string(step);
            string tmp2;
            for(int j=0; j<6-tmp.size(); j++){
               tmp2 += "0";
            }
            tmp2 += tmp;
            b.at(i+1) = make_pair(get<2>(py.at(i+1)), tmp2);
        }
        else{
            step = 1;
            b.at(i+1) = make_pair(get<2>(py.at(i+1)), "000001");
        }
    }

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

    vector<pair<int, string>> d(m);
    rep(i, m){
        d.at(i).first = a.at(i).second;
        d.at(i).second = a.at(i).first;
    }
    sort(d.begin(), d.end());
    rep(i, m){
        d.at(i).second += b.at(i).second;
        cout << d.at(i).second << endl;
    }


    return 0;
}


Measured memory_bytes: 28416
from collections import deque


n = int(input())
es = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    es[u].append((v, w))
    es[v].append((u, w))
clr = [None]*n
clr[0] = 0
dq = deque()
dq.append(0)
while dq:
    v = dq.popleft()
    for nv, w in es[v]:
        if clr[nv] is not None:
            continue
        clr[nv] = (clr[v] + w)%2
        dq.append(nv)
print(*clr, sep='\n')

Measured memory_bytes: 40724
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
6 4 3
---+/
/+---test
12 3 7
---+/

void main(string[] args) {
  int A, B, C;
  readf(" %d %d %d ", &A, &B, &C);
  max(C - (A-B), 0).writeln;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}
		long add = 0;
		for (int i = n - 1; i >= 0; i--) {
			if ((a[i] + add) % b[i] == 0) {

			} else if (b[i] >= a[i] + add) {
				add += b[i] - (a[i] + add);
			} else {
				long bai = (a[i] + add) / b[i] + 1;
				add += b[i] * bai - (a[i] + add);
			}
		}
		System.out.println(add);
	}
}

Measured memory_bytes: 91488
#include<stdio.h>
#include <limits.h>
#include<stdlib.h> 
 
#define WHITE 0
#define BLACK 1
#define MAX 100
#define N -1

int main(){
  
  int d[MAX];
  int w[MAX][MAX];
  int color[MAX];
 
  int n, i, j, min, u, v, p, q, x;
   
  scanf("%d", &n);
   
  for(i = 0;i < n;i++)
    for(j = 0;j < n;j++)
      w[i][j] = N;
   
  for(i = 0;i < n;i++){
    scanf("%d",&x);
    scanf("%d",&q);
     
    for(j = 0;j < q;j++){
      scanf("%d",&v);
      scanf("%d",&p);
       
      w[x][v] = p;
    }
  }
   
   
  for(i = 0;i < n;i++){
    d[i] = INT_MAX;
    color[i] = WHITE;
  }
   
  d[0] = 0;
   
  while(1){
    min = INT_MAX;
 
    for(i = 0;i < n;i++){
      if(d[i] < min && color[i] == WHITE){
	min = d[i];
	u = i;
      }
    }
     
    if(min == INT_MAX) break;
    color[u] = BLACK;
     
    for(v = 0;v < n;v++){
      if(w[u][v] == N) continue;
      if(d[v] > w[u][v] + d[u]) d[v] = w[u][v] + d[u];
    }
  }
   
  for(i = 0;i < n;i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;
 
}

Measured memory_bytes: 640
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        static double n=sc.nextInt();
        static double m=sc.nextInt();
        static double d=sc.nextInt();
        
        
        
        
        
        public static void main(String[]args){
                double x=2/n;
                double y=2*d;
                double z=n*n;
                double yy=y/z;
                if(d!=0){
                System.out.println((x-yy)*(m-1));}
                else{
                        System.out.println((x-yy)*(m-1)/2);

                }

                
                
                

        }
        
        
        

		
	
}


Measured memory_bytes: 21716
import java.util.*;
import java.math.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int k = sc.nextInt();
    int n = s.length();
    char[] a = s.toCharArray();
    int[][][] f = new int[n + 1][k + 1][2];
    f[0][0][0] = 1;
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < k + 1; ++j) {
        for(int m = 0; m < 2; ++m) {
          int cur = a[i] - '0';
          for(int nl = 0; nl < 10; ++nl) {
            int ni = i, nj = j, nm = m;
            if(nl != 0) ++nj;
            if(nj > k) continue;
            if(m == 0) {
              if(nl > cur) continue;
              if(nl < cur) nm = 1;
            }
            f[ni + 1][nj][nm] += f[i][j][m];
          }
        }
      }
    }
    System.out.println(f[n][k][1] + f[n][k][0]);
  }
}


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

#define ll long long
int main()
{
    ll int a,b,k;
    cin >> a >> b >> k;

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

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

using namespace std;

int main() {

    int a, b, k;

    cin >> a >> b >> k;
    int count = 0;
    int max_d = max(a, b);
    vector <int> ans(max_d);
    for (int i = 1; i <= max_d; i++) {
        if (a % i == 0 && b % i == 0) {
            ans[count] = i;
            count = count + 1;
        }
    }
    cout << ans[count - k] << endl;
   return 0;
}

Measured memory_bytes: 256
a={chr(i) for i in range(ord("a"),ord("a")+26)}
s=input()
n=len(s)
if n<26:
  print(s+sorted(a-set(s))[0])
else:
  for i in range(2,27):
    if s[-i]<s[-i+1]:
      break
    if i==26:
      print(-1)
      exit()
  for j in sorted(s[-i+1:]):
    if j>s[-i]:break
  print(s[:-i]+j)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int
main()
{
	char x[1000];
	int xi;
	int xlen;
	int sum;	
	for (;;)
	{
		scanf("%s", x);

		if (strcmp(x, "0") == 0)
			break;

		sum = 0;
		xlen = strlen(x);
		for (xi = 0; xi < xlen; xi++)
		{
			sum += x[xi] - '0';
		}
		printf("%d\n", sum);
	}

	return 0;
}

Measured memory_bytes: 536
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		List<int>[] arr=new List<int>[n+1];
		int[] h=new int[n+1],z=new int[2];
		for(int i=1;i<=n;i++){arr[i]=new List<int>();}
		for(int i=1;i<n;i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			arr[q[0]].Add(q[1]);
			arr[q[1]].Add(q[0]);
			h[i]=-1;
		}
		List<int>[] li=new List<int>[2];
		li[0]=new List<int>();
		li[1]=new List<int>();
		li[0].Add(1);
		li[1].Add(n);
		h[1]=0;h[n]=1;
		z[0]=1;z[1]=1;
		int t=0;
		while(li[t].Count>0){
			int k=li[t].Count;
			while(k>0){
				for(int i=0;i<arr[li[t][0]].Count;i++){
					if(h[arr[li[t][0]][i]]==-1){
						li[t].Add(arr[li[t][0]][i]);
						h[arr[li[t][0]][i]]=t;
						z[t]++;
					}
				}
				li[t].RemoveAt(0);
				k--;
			}
			if(li[t^1].Count>0){t^=1;}
		}
		Console.WriteLine("{0}",z[0]>z[1]?"Fennec":"Snuke");
	}
}

Measured memory_bytes: 29092
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, Q = map(int, input().split())
    S = input()

    ac_count = [0]
    ac = 0
    for i in range(1, N):
        if S[i - 1:i + 1] == "AC":
            ac += 1
        ac_count.append(ac)

    result = []

    for _ in range(Q):
        left, right = map(int, input().split())
        result.append(ac_count[right - 1] - ac_count[left - 1])

    print(*result, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 11844
n = int(input())
a = list(map(int, input().split()))

m = max(a)
ans = [0] * n
z = 1
while True:
  b = False
  for i in range(n):
    if a[i] & z:
      b = not b
  for i in range(n):
    if not b:
      if a[i] & z:
        ans[i] |= z
    else:
      if not (a[i] & z):
        ans[i] |= z

  z <<= 1
  if z > m:
    break

print(' '.join([str(x) for x in ans]))

Measured memory_bytes: 41808
import sys
import numpy as np

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = int(input())
MOD = 10 ** 9 + 7

# 階乗、Combinationコンビネーション(numpyを使う)
def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L ** 0.5 + 1)
    arr = np.resize(arr, Lsq ** 2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n - 1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n - 1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD - 2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


U = 10 ** 4
fact, fact_inv = make_fact(U * 2 + 10, MOD)
fact, fact_inv = fact.tolist(), fact_inv.tolist()


def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod


N = S // 3

if S <= 2:
    print(0)
    exit()

ans = 0
for i in range(1, N + 1):
    P = S - 3 * i
    if P < 0:
        break

    ans += mod_comb_k(P + i - 1, i - 1, MOD)
    ans %= MOD

print(ans)


Measured memory_bytes: 29024
#include<stdio.h>

int main(){
	int a,b,c;
	int hasil=0;
	
	scanf("%d %d %d",&a,&b,&c);
	

	if(a<=b && a<=c){
		if(b<=c){
			printf("%d",a+b);
		}
		else if(c<=b){
			printf("%d",a+c);
		}
	}

	
	else if(b<=a && b<=c){
		if(a<=c){
			printf("%d",b+a);
		}
		else if(c<=a){
			printf("%d",b+c);
		}
	}
	
	
	else if(c<=b && c<=a){
		if(a<=b){
			printf("%d",c+a);
		}
		 else if(b<=a){
			printf("%d",c+b);
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
 
vector<vector<ll>> multiply(vector<vector<ll>> A,vector<vector<ll>> B){
    int n = A.size();
    vector<vector<ll>> C(n,vector<ll>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int x=0;x<n;x++){
                C[i][j] = (C[i][j] + A[i][x]*B[x][j]) % mod;    
            } 
        }
    }
    return C;
}
 
vector<vector<ll>> power(vector<vector<ll>>& matrix,ll exp){
    if(exp==1){
        return matrix;
    }
    vector<vector<ll>> result = power(matrix,exp/2);
    if(exp&1){
        return multiply(multiply(matrix,result),result);
    }
    else{
        return multiply(result,result);
    }
}
 
ll totalPaths(vector<vector<ll>>& adj,ll k,int n){
    vector<vector<ll> > ak = power(adj,k);
    ll ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans = (ans + ak[i][j]) % mod;
        }
    }
    return ans;
}
 
int main(){
    int n;
    ll k;
    cin>>n>>k;
    vector<vector<ll> > adj(n,vector<ll>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>adj[i][j];
        }
    }
    cout<<totalPaths(adj,k,n);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define db double
#define ui unsigned int
#define ll long long
#define ull unsiged ll
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l)for(int i=r;i>=l;i--)
#define pb push_back
#define pp pop_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1e9+7
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define inf  INT_MAX
#define lnf LLONG_MAX
#define mii map<int,int>
#define mll map<ll,ll>
#define mil map<int,ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)```
using namespace std;
const int MX = 2e5 + 7;
ll modulo(ll num, ll MOD = mod) { return ((num%MOD) + MOD) % MOD; }
ll power(ll b, ll e, ll MOD = mod) { ll ans = 1; while (e) { if (e&1) ans = (ans*b) % MOD; b = (b*b) % MOD; e /= 2; } return ans; }
ll inv(ll num, ll MOD = mod) { return power(modulo(num), MOD - 2, MOD); }
ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a%b)); }
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int t,n,m;
	ll res;
	ll a,b;
	cin>>res;
	ll k=sqrt(res);
	rep(i,1,k)
	{
	  if(res%i==0)
      a=i,b=res/i;
	}
	cout<<a+b-2<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	map<string, int>mp;
	rep(i, 0, N) {
		string s; cin >> s;
		mp[s]++;
	}
	cout << mp.size() << "\n";

	return 0;
}

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

int main(){
    string S, T;
    cin >> S >> T;

    if(S.size()+1==T.size()){
        int flag=0;
        rep(i, S.size()){
            if(S[i]!=T[i]) flag=1; 
        }
        if(flag==0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3600
import sys
import collections
import heapq
import math

Edge = collections.namedtuple('Edge', ['s', 't', 'cost'])
    
V, E = map(int, sys.stdin.readline().split())
edges = collections.defaultdict(list)
for line in sys.stdin:
    e = Edge(*map(int, line.split()))
    edges[e.s].append(e)
    edges[e.t].append(Edge(e.t, e.s, e.cost))

heap = [(e.cost, e) for e in edges[0]]
heapq.heapify(heap)
nodes = {0}
min_cost = 0
while heap:
    _, edge = heapq.heappop(heap)
    if edge.t not in nodes:
        nodes.add(edge.t)
        for e in edges[edge.t]:
            heapq.heappush(heap, (e.cost, e))
        min_cost += edge.cost
print(min_cost)


Measured memory_bytes: 47068
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        List<Integer> rs = new ArrayList<>();
        List<Integer> rt = new ArrayList<>();
        for (int i = 0; i < 26; i++) {
            rs.add(-1);
            rt.add(-1);
        }

        boolean ok = true;
        for (int i = 0; i < s.length(); i++) {
            int s_i = s.charAt(i) - 'a';
            int t_i = t.charAt(i) - 'a';
            if (rs.get(s_i) >= 0) {
                if (rs.get(s_i) != t_i) {
                    ok = false;
                    break;
                }
            }
            if (rt.get(t_i) >= 0) {
                if (rt.get(t_i) != s_i) {
                    ok = false;
                    break;
                }
            }
            if (rs.get(s_i) < 0) {
                rs.set(s_i, t_i);
            }
            if (rt.get(t_i) < 0) {
                rt.set(t_i, s_i);
            }
        }

        if (ok) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


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

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

  int flag_p = 0,flag_w = 0,flag_g = 0,flag_y = 0;
  string si;
  
  for (int i = 0; i < N; i++) {
    cin >> si;
	if (si == "Y"){
      flag_y = 1;
      break;
    }
  }
/*    if (si == "P") {
      flag_p = 1;
    }
    else if (si == "W") {
      flag_w = 1;
    }
    else if (si == "G") {
      flag_g = 1;
    }
    else flag_y = 1;
  }
*/
  if (flag_y == 1){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;    
  }
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int A, B, C, N;

	scanf("%d %d %d", &A, &B, &C);

	N = A - B;

	if (C - N < 0) {
		printf("%d\n", 0);
	}
	else {
		printf("%d\n", C - N);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>

int isprime(int x){
	int a, i;
	if(x == 2){
		return 1;
	}else if(x < 2 || x%2 == 0){
		return 0;
	}
	i = 3;
	while(i <= sqrt(x)){
		if(x%i == 0){
			return 0;
		}
		i = i + 2;
	}
	return 1;
}

int main(void){
	int a;
	int b=0, n, i;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &a);
		if(isprime(a) == 1){
			b++;
		}
	}
	printf("%d\n", b);
	return 0;
}

Measured memory_bytes: 596
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import itertools
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
r = I()
g = I()
print(2*g-r)
"""

#B
n = I()
k = I()
ans = 1
for i in range(n):
    ans = min(ans * 2, ans + k)
print(ans)

Measured memory_bytes: 38384