akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {
	Map<Integer, Long>[] tree;
	boolean[] result;

	Main(int N, List<String> lines) {
		this.tree = new Map[N];
		this.result = new boolean[N];
		Arrays.fill(this.result, true);
		for (int i = 0; i < N; ++i) {
			this.tree[i] = new HashMap<>();
		}
		for (String line : lines) {
			String[] tokens = line.split(" ");
			int u = Integer.parseInt(tokens[0]);
			int v = Integer.parseInt(tokens[1]);
			long w = Long.parseLong(tokens[2]);
			this.tree[u - 1].put(v - 1, w);
			this.tree[v - 1].put(u - 1, w);
		}
		calc(0);
	}

	void calc(int nodeIndex) {
		boolean color = result[nodeIndex];
		for (Integer key : this.tree[nodeIndex].keySet()) {
			long w = this.tree[nodeIndex].get(key);
			if (w % 2 == 0) {
				this.result[key] = color;
			} else {
				this.result[key] = !color;
			}
			this.tree[key].remove(nodeIndex);
			calc(key);
		}
	}

	void show() {
		for (int i = 0; i < result.length; ++i) {
			if (result[i]) {
				System.out.println("1");
			} else {
				System.out.println("0");
			}
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		List<String> lines = new ArrayList<>(N);
		for (int i = 0; i < N - 1; ++i) {
			lines.add(in.readLine());
		}
		in.close();
		Main ins = new Main(N, lines);
		ins.show();
	}
}

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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

int main() {
    int a[9];
    rep(0, 9) cin >> a[i];

    int n, b;
    bool found[9];
    memset(found, false, sizeof(found));
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> b;
        for (int j = 0; j < 9; j++) {
            if (a[j] == b) found[j] = true;
        }
    }

    bool bingo = false;
    for (int i = 0; i < 9; i += 3) {
        if (found[i] && found[i+1] && found[i+2]) {
            bingo = true;
            break;
        }
    }

    if (!bingo) {
        for (int i = 0; i < 3; i++) {
            if (found[i] && found[i+3] && found[i+6]) {
                bingo = true;
                break;
            }
        }
    }

    if (!bingo) {
        if (found[0] && found[4] && found[8]) {
            bingo = true;
        }

        if (found[2] && found[4] && found[6]) {
            bingo = true;
        }
    }

    cout << (bingo ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
n,k=gets.split.map &:to_i
h=gets.split.map &:to_i
dp=Array.new(n,0)
1.upto(n-1) do |i|
  min=Float::INFINITY
  min2=Float::INFINITY
  if i < k
    0.upto(i-1) do |j|
      can=dp[j]+(h[i]-h[j]).abs
      if can < min
        min=can
      end
    end
    dp[i]=min
  else
    1.upto(k) do |l|
      can2=dp[i-l]+(h[i]-h[i-l]).abs
      if can2 < min2
        min2=can2     
      end
    end
    dp[i]=min2
  end
end

puts dp.last

Measured memory_bytes: 8844
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100000;

ll N, K;
ll x[MAX_N];

int main(){
  cin >> N >> K;
  REP(i, N) cin >> x[i];

  ll l = 0, m = 0, r = 0;
  REP(i, N) {
    if(x[i] < 0) {
      l++;
    } else if (x[i] == 0) {
      m++;
    } else {
      r++;
    }
  }

  ll ans = INFi;
  REP(i, l) {
    if(K > m + l - i && N - K >= i) {
      ans = min(ans, -x[i] + 2 * x[K + i - 1]);
      // cout << "x[i]: " << x[i] << ", x[K + i - 1]:" << x[K + i - 1] << endl;
    } else if (K == m + l - i) {
      ans = min(ans, -x[i]);
      // cout << "x[i]: " << x[i] << endl;
    }
  }
  REP(i, r) {
    if(K > m + r - i && N - K >= i) {
      ans = min(ans, x[N - 1 - i] - 2 * x[N - i - K]);
      // cout << "x[N - 1 - i]: " << x[N - 1 - i] << ", x[N - i - K]:" << x[N - i - K] << endl;
    } else if (K == m + r - i) {
      ans = min(ans, x[N - 1 - i]);
      // cout << "x[N - 1 - i]: " << x[N - 1 - i] << endl;
    }
  }

  if(ans == INFi) cout << 0 << endl;
  else cout << ans << endl;



  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define P(r) do{for(auto i:r){cout<<i<<' ';}cout<<'\n';}while(0)
int main()
{
    int K, S; cin >> K >> S;
    int cnt = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (0 <= z && z <= K) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import combinations

def solve(N, M, K):
    #A = [(n, m) for n in range(N) for m in range(M)]
    r = 0
    for x in range(N):
        r += x * (N - x) * M * M
    for y in range(M):
        r += y * (M - y) * N * N
    return r

def main():
    N, M, K = map(int, input().split())
    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]
    mod = 10 ** 9 + 7
    for i in range(2, N * M):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)
    t = solve(N, M, 2)
    for k in range(2, K):
        t = t * (N * M - k) * inverse[k - 1] % mod
    print(t)

main()


Measured memory_bytes: 80880
//abc167_b.cpp
//Sun May 10 20:56:12 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

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

	int ans = 0;
	if (k<=a){
		ans = k;
	}else if (k<=a+b){
		ans = a;
	}else {
		ans = a-(k-a-b);
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main() {
  int N,K;
  cin >> N >> K;
  double ans =0;
  for (int i =1; i<=N; i++) {
    int a =i;
    int b =0;
    while (a < K) {
      a *= 2;
      b++;
    }
    ans += pow(1.0 / 2,b) / N;
  }
  cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 4292
# -*- coding: utf-8 -*-
from collections import Counter

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]
#-----

cnt = Counter(S_list)

for s in ["AC", "WA" ,"TLE" ,"RE"]:
    if s in cnt:
        print( s, "x", cnt[s] )
    else:
        print( s, "x", 0 )


Measured memory_bytes: 16544
N=int(input())
h=list(map(int,input().split()))

c=[0]*N
c[1]=abs(h[1]-h[0])
for i in range(2,N):
  c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1]))
print(c[-1])

Measured memory_bytes: 13900
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Yes[2] = {"No", "Yes"};
string YES[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    n = (n + 1) / 2;
    cout << YES[n >= k];
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2e5 + 20 , mod = 1e9 + 7 ;
int n , m , a , b , ans , fac[N] ;

void pre () {
	fac[0] = 1 ;
	for (int i = 1 ; i < N ; i ++) fac[i] = 1ll * fac[i - 1] * i % mod ;
}

inline int pw (int a , int b) {
	int res = 1 ;
	while (b) {
		if (b & 1) res = 1ll * res * a % mod ;
		a = 1ll * a * a % mod ;
		b >>= 1 ;
	}
	return res ;
}

inline int Comb (int n , int k) {
	if (k < 0 || k > n) return 0 ;
	return 1ll * fac[n] * pw(fac[k] , mod - 2) % mod * pw(fac[n - k] , mod - 2) % mod ;
}

inline int func (int x , int y) { return Comb(x + y , x) ; }

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

	pre() ;

	cin >> n >> m >> a >> b ;

	ans = func(n - 1 , m - 1) ;

	for (int i = 0 ; i < b ; i ++) {
		// (n - a , i)
		int tmp = 1ll * func(n - a - 1 , i) * func((n - 1) - (n - a) , (m - 1) - i) % mod ; 
		ans = (ans + mod - tmp) % mod ;
	}

	cout << ans << '\n' ;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  ll count=0;
  cin>>A>>B>>C>>K;
  if(A>K) cout<<count+K<<endl;
  if(A<=K && K<=A+B) cout<<count+A<<endl;
  if(A+B<K) cout<<count+A-(K-A-B)<<endl;
  
}
  

Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;
const long long MX=1e6*4+10;
long long dp[MX];
long long a[100000];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	long long n,m;
	cin>>n>>m;
	for(long long i=0;i<m;i++)cin>>a[i];
	for(long long i=0;i<=n;i++){
		dp[i]=1;
	}
	sort(a,a+m);
	for(long long i=0;i<m-1;i++){
		if(a[i]+1==a[i+1]){
			cout<<0<<endl;
			return 0;
		}
	}
	int cnt=0;
	if(a[cnt]==1)dp[1]=0;
	if(a[cnt]==1)cnt=1;
	for(long long i=2;i<=n;i++){
		if(cnt<m&&i==a[cnt]){
			dp[i]=0;
			cnt++;
			continue;
		}
		dp[i]=(dp[i-1]+dp[i-2])%1000000007;
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, k;
  cin >> n >> k;
  vector<vector<ll>> a(2, vector<ll>(n + 1, 0));
  REP(i, n) { cin >> a[0][i]; }

  REP(i, k) {
    ll ci = i % 2, ni = !ci;
    bool sat = true;
    REP(j, n) {
      a[ni][max(0LL, j - a[ci][j])] += 1;
      a[ni][min(n - 1, j + a[ci][j]) + 1] += -1;
    }

    REP(j, n - 1) { a[ni][j + 1] += a[ni][j]; }

    REP(j, n) {
      if (a[ni][j] != n) {
        sat = false;
      }
    }

    REP(j, n) { a[ci][j] = 0; }

    if (sat) {
      REP(j, n) { cout << n << " \n"[j == n - 1]; }
      return 0;
    }
  }

  REP(j, n) { cout << a[k % 2][j] << " \n"[j == n - 1]; }
}

Measured memory_bytes: 8008
N = STDIN.gets.chomp.to_i
T, A = STDIN.gets.chomp.split(" ").map(&:to_i)
Hs = STDIN.gets.chomp.split(" ").map(&:to_i)

puts (1..N).zip(Hs).map{|index, h| [index, T - h * 0.006]}.map{|index, t| [index, (A - t).abs]}.min{|a, b| a[1] <=> b[1]}.first



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

#define reps(i,j,n) for(int i = (j) ; i < (int)(n) ; ++i)    
#define rep(i,n) reps(i,0,n)  
#define each(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)  
  
#define all(v) (v).begin(), (v).end()  
#define pb(x) push_back(x)  
#define sz(x) (int)((x).size())  
#define UNQ(s) {sort(ALL(s));(s).erase(unique(ALL(s)),(s).end());}   
#define fr first  
#define sc second  
  
typedef pair< int , int > Pi;  
typedef pair< int , Pi > Pii;

  
typedef long long int64;  
const int INF = 1 << 30;  
  
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is>>a.first>>a.second; }  
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os<<a.first<<" "<<a.second; }  
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ rep(i,sz(vc)) is >> vc[i]; return is;}  
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ rep(i,sz(vc)) os << vc[i] << endl; return os; }  

int main(){
  int N;
  while(cin >> N, N){
    vector< int > a(N), b(N), cnt(N, 0);
    cin >> a;
    cin >> b;
    sort( a.rbegin(), a.rend());
    sort( b.rbegin(), b.rend());

    int s = 0, t = 0;
    while(t < a.size() && s < b.size()){
      while( a[t] > b[s] && t < a.size()) t++;
      if( t < a.size() && b[s] >= a[t]){ //負ける可能性がある
        cnt[t]++;
        t++, s++;
      }
    }

    for(int i = 1 ; i < N ; i++ ){
      cnt[i] += cnt[i-1];
    }

    int ret = -1;
    for(int i = 1; i < N; i++){
      if(i - cnt[i - 1] >= (i + 2) / 2){
        ret = i;
        break;
      }
    }
    if(~ret) cout << ret << endl;
    else cout << "NA" << endl;
  }
}

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

int dfs(int n, vector<vector<int> >& adj){
	if((int)adj[n].size() == 0) return n;
	int ret=0;
	for(int i=0; i<(int)adj[n].size(); i++){
		ret = max(ret, dfs(adj[n][i], adj));
	}
	adj[n].clear();
	return ret;
}

int main(){
	int n,m;
	cin >> n >> m;
	
	vector<vector<int> > rest(n+1);
	for(int i=0; i<m; i++){
		int c,d;
		cin >> c >> d;
		rest[c].push_back(d);
	}
	vector<int> c,d;
	for(int i=1; i<=n; i++){
		int top = dfs(i, rest);
		if(top != i){
			c.push_back(i);
			d.push_back(top);
		}
	}
	c.push_back(n+1);
	d.push_back(n+1);
	
	int ans = 0;
	int s=c[0], e=d[0];
	for(int i=1; i<(int)c.size(); i++){
		if(c[i] <= e){
			e = max(e, d[i]);
		}else{
			ans += e-s;
			s = c[i];
			e = d[i];
		}
	}
	ans = n +1 +ans*2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int k;
    int a,b;
    cin>>k;
    cin>>a>>b;
    
    int ct=0;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            ct=1;
            break;
        }
    }
    
    if(ct==0) cout<<"NG"<<endl;
}


Measured memory_bytes: 3636
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


ans = 0
K = int(input())
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(a, b, c)

print(ans)


Measured memory_bytes: 69752
MOD = 10 ** 9 + 7

n, k = map(int, input().split())

ans = 0
for i in range(k, n + 2):
    cnt = i * (n + n - i + 2) // 2 - i * i // 2 + 1
    ans += cnt
    ans %= MOD
print(ans)

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

int main(){
    char str[21];
    char output[21];
    int count;
    int i;

    gets(str);
    str[20]='\0';
    count=strlen(str);
    
    for(i=0;i<count;i++){
        output[i] = str[count-1-i];
    }
    output[count]='\0';
    printf("%s\n",output);
        
    return 0;
}

Measured memory_bytes: 524
#include<iostream>

using namespace std;

const int MAX_N=1e2+3;
const int MAX_V=1e5+3;

const long long INF=1e18+3;

long long dp[MAX_N][MAX_V];

long long w[MAX_N],v[MAX_N];

int main(){
  int N,W;
  cin>>N>>W;
  for(int i=1;i<=N;i++){
    cin>>w[i]>>v[i];
  }
  for(int i=0;i<MAX_N;i++)for(int j=0;j<MAX_V;j++)dp[i][j]=INF;
  for(int i=0;i<MAX_N;i++)dp[i][0]=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<MAX_V;j++){
      if(j>=v[i])dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
      else dp[i][j]=dp[i-1][j];
    }
  }
  int ans=0;
  for(int i=0;i<MAX_V;i++){
    if(dp[N][i]<=W)ans=i;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 80768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
ll K,A[200000],L,R;
int main() 
{
	cin>>N>>K;
	for(int i=0;i<N;i++) 
	{
		cin>>A[i];
	}
	sort(A,A+N);
	L=-1e18;
	R=1e18;
	while(L+1!=R) 
	{
		ll M=(L+R)/2;
		ll cnt=0;
		for(int i=0;i<N;i++) 
		{
			if(A[i]<0) 
			{
				int l,r;
				l=i;
				r=N;
				while(l+1!=r) 
				{
					int m=(l+r)/2;
					if(A[i]*A[m]<=M) 
					{
						r=m;
					}
					else 
					{
						l=m;
					}
				}
				cnt+=N-r;
			}
			else 
			{
				int l,r;
				l=i;
				r=N;
				while (l+1!=r) 
				{
					int m=(l+r)/2;
					if(A[i]*A[m]<=M) 
					{
						l=m;
					}
					else 
					{
						r=m;
					}
				}
				cnt+=l-i;
			}
		}
		if(cnt<K)
		L=M;
		else 
		R=M;
	}
	cout<<R<<endl;
}



Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var answer = 0.0
    for (i in 0 until n) {
        val (value, currency) = readLine()!!.split(" ")
        answer += if (currency == "JPY") value.toDouble() else value.toDouble() * 380000.0
    }
    println(answer)
}



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

int main(){
	int N;
	cin >> N;
	int ans(0),cnt(0);
	ll prev,now;
	cin >> prev;
	for(int i(1);i<N;++i){
		cin >> now;
		if(prev >= now){
			cnt++;
		}else{
			cnt=0;
		}
		ans = max(cnt,ans);
		prev = now;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> dp(k + 1), a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= k; i++) {
    bool win = false;
    for (int j = 0; j < n; j++) {
      int to = i - a[j];
      if (to < 0) continue;
      win |= !dp[to];
    }
    dp[i] = win;
  }
  puts(dp[k] ? "First" : "Second");
  return 0;	
}

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

void judgePrime(int n, vector<bool>& isNotPrime)
{
	for (auto i = 0; i <= n; ++i)
	{
		isNotPrime.push_back(false);
	}
	isNotPrime[0] = true;
	isNotPrime[1] = true;

	for (auto i = 2; i <= n; ++i)
	{
		if (!isNotPrime[i])
		{
			for (auto j = i * 2ll; j <= n; j += i)
			{
				isNotPrime[(int)j] = true;
			}
		}
	}
}

int main()
{
	auto maxVal = (int)1e5;
	vector<bool> isNotPrime(maxVal + 1);
	judgePrime(maxVal, isNotPrime);

	vector<int> sum(maxVal + 1);
	for (auto i = 1; i <= maxVal; ++i)
	{
		sum[i] = sum[i - 1];
		if (i % 2 > 0
			&& isNotPrime[i] == false
			&& isNotPrime[(i + 1) / 2] == false)
		{
			++sum[i];
		}
	}

	vector<int> ans;
	int Q;
	cin >> Q;
	for (auto i = 0; i < Q; ++i)
	{
		int l, r;
		cin >> l >> r;
		ans.push_back(sum[r] - sum[l - 1]);
	}

	for (auto i = 0; i < Q; ++i)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1540
fn getline() -> String{
	let mut __ret=String::new();
	std::io::stdin().read_line(&mut __ret).ok();
	return __ret;
}

fn main() {
    let line = getline();

    let vec: Vec<&str> = line.split_whitespace().collect();
    let a:i32  = vec[0].parse().unwrap_or(0);
    let b:i32  = vec[1].parse().unwrap_or(0);
    let c:i32  = vec[2].parse().unwrap_or(0);

    let ans = std::cmp::min(b / a, c);

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
int main(){
int n;
scanf("%d",&n);
int *d=malloc(n*sizeof(int));
int m=0;
for(int i=0;i<n;i++){
scanf("%d",d+i);
m+=d[i];
}
int x=0;
for(int i=0;i<n-1;i++){
int c=d[i];
m-=c;
x+=c*m;
}
printf("%d",x);
return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		System.out.printf("%.6f\n", (double)a * b / 3.305785);
	}
}

Measured memory_bytes: 17328
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    ll i,j,k,l,n,m;
    cin>>n>>m;
    ll ar[n+1],fl[n+1];
    for(i=1;i<=n;i++){
        cin>>ar[i];
        fl[i]=1;
    }

    ll a,b;
    for(i=1;i<=m;i++){
        cin>>a>>b;
        if(ar[a]>=ar[b]) fl[b]=0;
        if(ar[b]>=ar[a]) fl[a]=0;
    }

    ll an=0;
    for(i=1;i<=n;i++){
        if(fl[i]==1){
            // cout<<i<<endl;
            an++;
        }
    }
    cout<<an;
    return 0;
}

Measured memory_bytes: 5216
class UnionFind:
    def __init__(self, n):
        self.nodes = n
        self.parents = [i for i in range(n)]
        self.sizes = [1] * n
        self.rank = [0] * n

    def find(self, i): # どの集合に属しているか（根ノードの番号）
        if self.parents[i] == i:
            return i
        else:
            self.parents[i] = self.find(self.parents[i]) # 経路圧縮
            return self.parents[i]

    def unite(self, i, j): # 二つの集合を併合
        pi = self.find(i)
        pj = self.find(j)
        if pi != pj:
            if self.rank[pi] < self.rank[pj]:
                self.sizes[pj] += self.sizes[pi]
                self.parents[pi] = pj
            else:
                self.sizes[pi] += self.sizes[pj]
                self.parents[pj] = pi
                if self.rank[pi] == self.rank[pj]:
                    self.rank[pi] += 1
    def same(self, i, j): # 同じ集合に属するかを判定
        return self.find(i)==self.find(j)

    def get_parents(self): # 根ノードの一覧を取得
        for n in range(self.nodes): # findで経路圧縮する
            self.find(n)
        return self.parents

adj = []
N, M = map(int,input().split())
for m in range(M):
    a,b = map(int,input().split())
    adj.append([a-1,b-1])

ans = 0
for i in range(M): # 取り除く辺番号
    uf = UnionFind(N)
    for j in range(M):
        if (i==j): # 辺を追加しない（取り除く）
            continue
        uf.unite(*adj[j])
    
    if len(set(uf.get_parents()))!=1: # 複数の集合にわかれているか確認
        ans += 1
print (ans)

Measured memory_bytes: 9184
import functools


def main():
    n = int(input())
    A = [int(a) for a in input().split()]
    c = len([a for a in A if a%2 ==0])
    print(pow(3,n)-pow(2,c))

    # total = functools.reduce(lambda a, b: a * (2 if b % 2 == 1 else 1),A)
    # print(pow(3 ,len(A)-1)*total)
    # # print(123)
    # b = [int(a) for a in input().split(" ")]
    # print(b)
    # [input() for a in range(3)]


if __name__ == "__main__":
    main()


Measured memory_bytes: 4196
#include<bits/stdc++.h>
#define int long long
using namespace std;
int ar[1000] ;
int32_t main()
{
    int n,ans=1000000000000 ; cin>>n ;
    for(int i = 0 ; i < n ; i++) cin>>ar[i] ;
    for(int i = -100 ; i <= 100 ; i++)
    {
        int as=0 ;
        for(int j = 0 ; j < n ; j++) as+=(ar[j]-i)*(ar[j]-i) ; ans=min(ans,as) ;
    }
    cout<<ans<<endl ;
}


Measured memory_bytes: 3628
import math

def calc(x):
  res = 0
  while x > 0:
    x //= 10
    res += 1
  return res

N = int(input())
ans = 20
for A in range(1, int(math.sqrt(N))+1):
  if N % A != 0:
    continue
  B = N // A
  ans = max(calc(A), calc(B))
print(ans)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int sz = 2e5 + 1;

int n;
vector<int> g[sz];
ll ans = 0;

void dfs(int v, int pred) {
	for (int to : g[v]) {
		if (to ^ pred) {
			ll l = min(v, to) + 1;
			ll r = max(v, to) + 1;
			ans -= l * (n - r + 1);
			dfs(to, v);
		}
	}
}

void solve() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (ll i = 1; i <= n; i++)
		ans += i * (n - i + 1);
	dfs(0, -1);
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << endl;
	}
}


Measured memory_bytes: 23828
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll dp[101][100010], v[100010], w[100010], W, INF=1e15;
//dp[i][j] = minimo peso para formar exactamente j con los primeros i elementos

ll solve(ll pos, ll V){
  if(pos < 0) return V==0?0:INF;
  ll &r = dp[pos][V];
  if(r >= 0) return r;
  r = min(INF,solve(pos-1,V));
  if(v[pos] <= V) r = min(r, w[pos]+solve(pos-1,V-v[pos]));
  return r;
}

int main(){FIN;
  memset(dp,-1,sizeof(dp));
  ll n,W;
  cin >> n >> W;
  fore(i,0,n) cin >> w[i] >> v[i];
  for(int i = 100000; i >= 0; i--){
    if(solve(n-1,i) <= W){
      cout << i << "\n";
      return 0;
    }
  }
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define lPair pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,A,B,C;
int L[10];
int Com(int n,int a,int b,int c){
    if(n == N){
        if(min(a,min(b,c)) == 0) return MM;
        else return abs(A-a)+abs(B-b)+abs(C-c);
    }
    int ans = MM;
    ans = min(ans, Com(n+1,a,b,c));
    ans = min(ans, Com(n+1,a+L[n],b,c) + (a > 0 ? 10:0));
    ans = min(ans, Com(n+1,a,b+L[n],c) + (b > 0 ? 10:0));
    ans = min(ans, Com(n+1,a,b,c+L[n]) + (c > 0 ? 10:0));
    return ans;
}
int main(){
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }
    cout << Com(0,0,0,0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int A,B;
  cin>>A;
  cin>>B;
  if (B%2==0 && A>=0 &&A<=100 && B>=2&&B<=1000 ){
    if (A>=13){
        cout <<B;
    }
    else if (A>=6 && A<=12){
        cout<<0.5*B;
    }
    else{
        cout <<0;
    }
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3)){
    cout<<"Bad"<<endl;
  }
  else cout<<"Good"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  ll sum = 0;
  rep(i, s.size()) {
    sum += (s[i]-'0');
  }
  cout << (sum%9 ? "No" : "Yes") << endk;
  return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	ll n,k;
	cin>>n>>k;
	if(n*500>=k)
		cout<<"Yes";
	else
		cout<<"No";
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
	}
    
    let n = get!();
    let mut ans = 0;
    for i in 1..n+1 {
    	if i % 2 == 0 {
        	continue;
        }
        let mut c = 0;
        for j in 1..i+1 {
        	if i % j == 0 {
            	c += 1;
            }
        }
        if c == 8 {
        	// println!("{}", i);
        	ans += 1;
        }
    }
    
    println!("{}", ans);
    
}

Measured memory_bytes: 4352
N,M =map(int,input().split())
left = 0
right = 10**5 + 1
for i in range(M):
    l,r = map(int,input().split())
    left = max(l,left)
    right = min(r,right)
ans = right - left + 1
if(right - left < 0):
    ans = 0
print(ans)

Measured memory_bytes: 44120
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>

using namespace std;



int main() {
	int i, j, k;
	int n;

	cin >> n;

	for (i = 0; i < 100; i++) {
		for (j = 0; j < 100; j++) {
			int sum = i * 4 + j * 7;
			if (sum == n) {
				cout << "Yes" << endl;
				getchar();
				getchar();
				return 0;
			}
		}
	}

	cout << "No" << endl;




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
long long int MOD = 1000000007;
/*
cin >> n;
vi a(n);
rep(i,n)cin>>a[i];
*/
int n;
bool used[350];
int main(){
	int N;
	cin>> N;
	vector<ll> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	//a.pb(a[N-1]);
	ll now=0;
	int ans=0;
	for(int i=0;i<N-1;i++){
	ll M=a[i+1];
		now+=a[i];
		if(M>2*now){
			ans=i+1;
		}
	}
	cout<<N-ans<<endl;
}

Measured memory_bytes: 1024
// ボール: 区別なし, 箱：区別なし, 入れ方: 制限なし
// 分割数
// P(n, k) = P(n, k - 1) + P(n - k, k)
#include <iostream>
using namespace std;
const int MOD = 1000000007;
const long long MAXN = 1010;
long long P[MAXN][MAXN] = {};

void pertition_init() {
  for(int k = 0; k < MAXN; k++) P[0][k] = 1;
  for(int n = 1; n < MAXN; n++) {
    for(int k = 1; k < MAXN; k++) {
      P[n][k] += P[n][k - 1] + (n - k >= 0 ? P[n - k][k] : 0);
      P[n][k] %= MOD;
    }
  }
}

int main() {
  
  pertition_init();
  int n, k; cin >> n >> k;
  cout << P[n][k] << endl;
  return 0;
}



Measured memory_bytes: 11076
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;

static const double pi = 3.14159265358979323846;

int main(){
  int N, M, a[200000], b[200000];
  cin >> N >> M;
  for(int i=0; i<M; ++i) scanf("%d %d",&a[i],&b[i]);
  string s = "IMPOSSIBLE";

  vector<int> v;

  for(int i=0; i<M ; ++i){
    if(a[i] == 1){
      v.push_back(b[i]);
    }
  }

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

  for(int i=0; i<M; ++i){
    if(b[i] == N){
      if(std::binary_search(v.begin(), v.end(), a[i])){
        s = "POSSIBLE";
        break;
      }
    }
  }


  cout << s << endl;

  return 0;
}


Measured memory_bytes: 2428
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

const double PI = 3.1415926535897932384626433832795;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  REP(i, n) {
    ans = min(ans * 2, ans + k);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------


struct UnionFind{
	std::vector<int> data;
	
	UnionFind(int n){
		data.assign(n, -1);
	}
	
	void unite(int x, int y){
		x = find(x); y = find(y);
		if(x == y) return;
		if(data[x] > data[y]) std::swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}
	
	int find(int k){
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}

	int size(int k) {
		return -data[find(k)];
	}

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

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

    cin>>n>>m;
    rep(i,m)cin>>a[i]>>b[i],a[i]--,b[i]--;
    rep(i,m){
        UnionFind uf(100);
        rep(j,m){
            if(i==j)continue;
            uf.unite(a[j],b[j]);
        }
        rep(j,n){
            if(uf.find(0)!=uf.find(j)){
                ans++;
                break;
            }
        }
    }
    Cout(ans);
    return 0;
}


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

const ll INF = 1LL << 60;

int main() {
    ll A, B, C;
    cin >> A >> B >> C;

    // if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
    //     cout << 0 << endl;
    //     return 0;
    // }

    for (int i = 0; i <= 10000000; i++) {
        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
            cout << i << endl;
            return 0;
        }

        ll prev_A = A, prev_B = B, prev_C = C;
        A = prev_B / 2 + prev_C / 2;
        B = prev_A / 2 + prev_C / 2;
        C = prev_A / 2 + prev_B / 2;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

dp = [[float("INF")]*w for i in range(h)]
if l[0][0] == ".":
    dp[0][0] = 0
else:
    dp[0][0] = 1

for i in range(h):
    for j in range(w):
        a = dp[i-1][j]
        b = dp[i][j-1] 
        if l[i-1][j] == "." and l[i][j] == "#":
            a += 1
        if l[i][j-1] == "." and l[i][j] == "#":
            b += 1
        dp[i][j] = min(a,b,dp[i][j])
print(dp[-1][-1])
         
            

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

const double PI = 3.141592653589;
int main(){
	double r, S, L;
	scanf("%lf", &r);
	S = PI * r * r;
	L = 2 * PI * r;
	printf("%.6lf %.6lf\n", S, L);
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
struct sstr{
  string s;
  sstr(){}
  sstr(string s):s(s){}
  
  bool operator<(const sstr& a)const{
    return s.size()!=a.s.size() ? s.size() < a.s.size() : s < a.s;
  }

  bool operator==(const sstr& a)const{
    return s==a.s;
  }
};
vector<sstr> v;

void solve(string x,int y){

  //cout << x << ":" << y << endl;
  v.push_back(sstr(x));
  if(y>=25) return;
  string n=x;
  for(int i=0;i<x.size();i++){
    if(x[i]=='y'-y) {
      n=x;
      n[i]++; 
      solve(n,y+1);
      return;
    }else if(x[i]=='y'-(y+1)){
      n=x;
      n[i]++;
      solve(n,y+2);
    }
  }
  solve(x,y+1);
}
typedef pair<string,int> P;
map<P,string> m;

string check(string s,int d){
  int i,j,k;
  for(i=1;i<26;i++){
    for(j=0;j<s.size();j++){
      if(s[j]=='a'+i){
	s[j]--;
	break;
      }
    }
  }
  return s;
}
int main(){
  string s;
  while(cin>>s,s!="#"){
    v.clear();m.clear();
    solve(s,0);
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    //cout << v.size() << endl;
    int n = v.size();
    bool d[n];
    fill(d,d+n,false);
    for(int i=0;i<v.size();i++){
      if(check(v[i].s , 0 )!=s){
	//v.erase(v.begin()+i);
	//i--;
	d[i]=true;
	n--;
      }
    }
    cout << n << endl;
    if(n<=10){
      for(int i=0;i<v.size();i++){
	if(!d[i])
	  cout << v[i].s << endl;
      }
    }else{
      int k=0,j=0;
      for(int i=0;k<5;i++){
	if(!d[i]){
	  cout << v[i].s << endl;
	  k++;
	}
      }
      k=0;j=v.size();
      while(k<5){
	j--;
	if(!d[j]){
	  k++;
	}
      }
      for(int i=j;i<v.size();i++){
	if(!d[i])
	cout << v[i].s << endl;
      }
    }
  }
  return 0;
}

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

string S;

int main() {
    
    cin >> S;

    if (S[1] == 'R') cout << "ABC" << endl;
    else cout << "ARC" << endl;

    return 0;
}


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

a.sort()

max_l=0
for i in range(n-1):
  if(a[i+1]-a[i] > max_l):
    max_l=a[i+1]-a[i]
if(a[0]+(k-a[n-1]) > max_l):
  max_l=a[0]+(k-a[n-1])

print(k-max_l)

Measured memory_bytes: 26420
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long int;
int gcd(int a,int b){
    if(a%b==0) return b;
    else return gcd(b,a%b);
}

int main(){
    long long int n,x;
    cin>>n>>x;
    vector<long long int>a(n);
    rep(i,n){
        long long int b;
        cin>>b;
        a[i]=abs(b-x);
    }
    sort(a.begin(),a.end());
    long long int ans=a[0];
    rep(i,n){
        ans=gcd(ans,a[i]);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector<bool> Cost(100000, true);

int main()
{
  int64_t N, K, k;
  cin >> N >> K;
  for (int i = 0; i < K; i++)
  {
    cin >> k;
    for (int n = 0; n < 100000; n++)
    {
      if (n >= 10000 && n / 10000 == k)
        Cost.at(n) = false;
      else if (n >= 1000 && (n % 10000) / 1000 == k)
        Cost.at(n) = false;
      else if (n >= 100 & (n % 1000) / 100 == k)
        Cost.at(n) = false;
      else if (n >= 10 && (n % 100) / 10 == k)
        Cost.at(n) = false;
      else if (n % 10 == k)
        Cost.at(n) = false;
    }
  }
  for (int i = N; i < 100000; i++)
  {
    if (Cost.at(i))
    {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>

using namespace std;
#define PI 3.14159265359
#define ll long long int


int main()
{
    ll N;
    cin >> N;
    ll X[N];
    for(int i = 0; i < N; i++){
        cin >> X[i];
    }

    ll ans = 90000000;
    sort(X, X + N);

    for(int i = X[0]; i <= X[N - 1]; i++){
        ll P = 0;
        for(int j = 0; j < N; j++){
            P += pow(i - X[j], 2);
        }
        ans = min(ans, P);
    }

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

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

int main(){
  int N;
  int A[100];
  int key,i,j;
  
  cin >> N;

  for (i=0;i<N;i++)
    cin >> A[i];
  for (i=0;i<N;i++){
    cout << A[i];
    if (i<N-1)cout << " ";
  }
  cout << endl;
  for (i=1;i<N;i++){
    key=A[i];
    j=i-1;
    while (j>=0 && A[j]>key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;
    for (j=0;j<N;j++){
      cout << A[j];
      if (j<N-1)cout << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 3096
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

long long dp[65][3501];

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

	for (int t = 0; t < N; t++)
	{
		for (int i = t + 1; i >= 0; i--)
		{
			for (int j = 0; j <= 50 * i; j++)
			{
				dp[i + 1][j + x[t]] += dp[i][j];
			}
		}
	}


	long long ans = 0;
	for (int i = 1; i <= N; i++)
	{
		ans += dp[i][i*A];
	}
	cout << ans << endl;
}

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

int main()
{
    int N, L; cin >> N >> L;
    int Sum, sum;
    sum = 0;
    if(L >= 0) {
        for(int i = 1; i < N; ++i) {
            sum = sum + L + i;
        }
    }
    else if(L >= 1 - N) {
        for(int i = 0; i < N; ++i) {
            sum = sum + L + i;
        }
    }
    else {
        for(int i = 0; i < N - 1; ++i) {
            sum = sum + L + i;
        }
    }
    cout << sum << "\n";

    return 0;
}


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main(){

	ll a, b,c;
	cin >> a >> b;
	c = a*b;
	if (c % 2 == 0) pr("Even");
	else pr("Odd");

	//system("pause");
	return 0;
}

Measured memory_bytes: 256