akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>
#include <stack>
#include <vector>
using namespace std;


const int mod=1e9+7;
const int maxn=1e6+10;
#define mem(a,b) memset(a,b,sizeof(a))
#define uLL unsigned long long

map<uLL,uLL> mp;
vector<int> g[maxn];

uLL d[maxn];
uLL ans;
int n;

int head[maxn],cntroad;
struct Edge {
    Edge(int V = 0,int N = 0):v(V),Next(N) {}
    int v,Next;
}road[maxn<<1];
void addedge(int u,int v) {road[cntroad] = Edge(v,head[u]); head[u] = cntroad++;}
void dfs(int u,int fa)
{
    d[u]=1;
    for(int i = head[u]; i != -1; i = road[i].Next)
    {
        int v=road[i].v;
        if(v==fa)continue;
        dfs(v,u);
        d[u]+=d[v]*mod;
    }
    mp[d[u]]++;
}
int main()
{
    while(~scanf("%d",&n))
    {
        mem(head,-1);
        cntroad = 0;
        mp.clear();
        ans=0;
        for(int i=1;i<n;i++)
        {
            int u,v;
            scanf("%d%d",&u,&v);
            addedge(u,v);
            addedge(v,u);
        }

        dfs(1,0);
        for(map<uLL,uLL>::iterator it=mp.begin(); it!=mp.end(); it++)
            ans+=(uLL)it->second*(it->second-1)/2;
        cout << ans;printf("\n");
    }
    return 0;
}



Measured memory_bytes: 61048
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<map>
#include<queue>
#include<functional>
using namespace std;

const int MAX = 100;
const int INF = 1000;

int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			char n;
			cin >> n;
			if (i == j)cout << n;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var sum=0;
var cnt=0;

Arr.forEach(function(v){
var arr=v.split(",").map(Number);
sum+=arr[0]*arr[1];
cnt+=arr[1];
});

console.log(sum);
console.log(Math.round(cnt/Arr.length));

Measured memory_bytes: 7648
//A.cpp
#include <iostream>
#include <string>
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  string S[H];
  for(int i = 0; i < H; i++) cin >> S[i];
  cout << string(W+2,'#') << endl;
  for(int i = 0; i < H; i++){
    cout << '#' << S[i] << '#' << endl;
  }
  cout << string(W+2,'#') << endl;
  return 0;

}


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

int main() {
  int n; cin >> n;
  vector<int> h(n+1,0); for(int i = 0;i < n;i++) { cin >> h[i]; }

  int ans = 0;
  while(true) {

    int check = 1;
    for(int i = 0;i < n;i++) {
      if(h[i] > 0) {
        if(h[i+1] == 0) { ans++; }
        h[i]--;
        check *= 0;
      }
    }

    if(check == 1) { break; }
  }

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

Measured memory_bytes: 256
A,B,M=[int(x) for x in input().rstrip().split()]
a=[int(x) for x in input().rstrip().split()]
b=[int(x) for x in input().rstrip().split()]
a_min=min(a)
b_min=min(b)

ans=a_min+b_min
for i in range(M):
    x,y,c=[int(x) for x in input().rstrip().split()]
    now=a[x-1]+b[y-1]-c
    if now<ans:
        ans=now
print(ans)






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

vector<int>G[200005];
vector<bool>vis(200005);

int dfs(int s){

    vis[s] = 1;

    int count = 1;
    for (auto k : G[s])
        if (!vis[k])
            count+=dfs(k);

    return count;
}

int32_t main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
////////////////////////////////

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

    for (int i=0;i<=n;i++)G[i].clear(),vis[i]=0;

    for (int i=0;i<m;i++){
        int from,to;
        cin >> from >> to;

        G[from].push_back(to);
        G[to].push_back(from);
    }

    vector<int>ans;
    ans.push_back(0);

    for (int i=1;i<=n;i++){
        if (!vis[i])
            ans.push_back(dfs(i));
    }

    cout<< *max_element(ans.begin(),ans.end());

}


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

int main(){
  vector<int> time(3);
  for (int i = 0; i < 3; i++){
    cin >> time.at(i);
  }
  sort(time.begin(), time.end());
  cout << time.at(0) + time.at(1) << endl;
}

Measured memory_bytes: 3628
a = [ list(map(int,input().split())) for i in range(3)]    # 二重リスト（配列）に標準入力　
n = int(input())                                           # 標準入力（整数）
d = [[0 for i in range(3)] for j in range(3)]              # 要素が全て0の３×３の二重リスト（配列）

for k in range(n):              #  n回繰り返す
    b = int(input())            #　標準入力（整数）
    for i in range(3):          
        for j in range(3):
            if a[i][j] == b:    #  aに、bと同じ数字があるか見る
                d[i][j] = 1     #　あれば、対応するdに1を代入

ans = 'No'                      #  最初はNoと仮定
count = 0

# 横でビンゴしているか確認
for i in range(3):
    if ans == 'Yes':            # もしYesだったら
        break;                  # ループを抜ける
    count = 0
    for j in range(3):
        count += d[i][j]
        if count == 3:          
            ans = 'Yes'         #  3つ１があればビンゴ

# 縦でビンゴしているか確認
for i in range(3):
    if ans == 'Yes':
        break;
    count = 0
    for j in range(3):
        count += d[j][i]
    if count == 3:
        ans = 'Yes'             #  3つ１があればビンゴ


# 左上から右下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][i]
    if count == 3:
        ans = 'Yes'             #  3つ１があればビンゴ

#右上から左下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][2 - i]
    if count == 3:              #  3つ１があればビンゴ
        ans = 'Yes'
            

print(ans)

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        string S;
        cin >>S;
        int A=0;
        Rep0(i, S.size()) {
                A +=S.at(i)-'0';
                A %=9;
        }
        if (0==A)
                cout <<"Yes" <<endl;
        else
                cout <<"No" <<endl;
        return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;


int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);

int x,y;
cin>>x>>y;
if(y%2==1){cout<<"No";}
else{
    if((y-2*x)/2<0||(4*x-y)/2<0){cout<<"No";}
    else{cout<<"Yes";}
}

return 0;

}


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

using f64 = double;
using i64 = long long;

int main() {
#ifdef HOME
	freopen("abc86b.in", "r", stdin);
	freopen("abc86b.out", "w", stdout);
#endif
	string a, b, r;
	i64 num(0);

	cin >> a >> b;

	r = a + b;
	for (auto i: r)
		num = num * 10 + i - '0';

	cout << (i64(sqrt(num)) * i64(sqrt(num)) == num ? "Yes" : "No") << endl;

	return 0; }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[200000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	int maxA = 0;
	int ans = 0;
	rep(i, n) {
		maxA = max(maxA, a[i]);
		ans += maxA - a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
ll n, k, a[100000];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n) cin >> a[i];
  sort(a, a+n);
  ll g = a[0];
  FOR(i, 1, n) g = gcd(g, a[i]);
  if(k > a[n-1] || k % g){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << "POSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
const int MAX_N=100000,MAX_Q=100000;

int main(){
    int n,k,q;
    cin>>n>>k>>q;
    int a,p[MAX_N]={};
    for(int i=0;i<q;i++){
        cin>>a;
        p[a-1]++;
    }
    for(int i=0;i<n;i++){
        if(p[i]>q-k) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>

using namespace std;

#define limit int(1e5 + 1)
int arr[ limit ][ 3 ];
int answer[ limit ][ 3 ];

int found_answer(int n) {
	for(int i = 0; i < 3; i++) {
		answer[ 0 ][ i ] = arr[ 0 ][ i ];
	}

	for(int i = 1; i < n; i++) {
		answer[ i ][ 1 ] = max(answer[ i ][ 1 ], answer[ i - 1 ][ 0 ] + arr[ i ][ 1 ]);
		answer[ i ][ 2 ] = max(answer[ i ][ 2 ], answer[ i - 1 ][ 0 ] + arr[ i ][ 2 ]);

		answer[ i ][ 0 ] = max(answer[ i ][ 0 ], answer[ i - 1 ][ 1 ] + arr[ i ][ 0 ]);
		answer[ i ][ 2 ] = max(answer[ i ][ 2 ], answer[ i - 1 ][ 1 ] + arr[ i ][ 2 ]);

		answer[ i ][ 0 ] = max(answer[ i ][ 0 ], answer[ i - 1 ][ 2 ] + arr[ i ][ 0 ]);
		answer[ i ][ 1 ] = max(answer[ i ][ 1 ], answer[ i - 1 ][ 2 ] + arr[ i ][ 1 ]);

	}

	return max(answer[ n - 1 ][ 0 ], max(answer[ n - 1 ][ 1 ], answer[ n - 1 ][ 2 ]));
}

int main() {
	int n;
	scanf("%i", &n);

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

	printf("%i", found_answer(n));
}

Measured memory_bytes: 2560
k, s = gets.split.map(&:to_i)
array = []
(0..k).each do |x|
  (0..k).each do |y|
    z = s - x - y
    if z < 0
      break
    else
      array << [x, y, z] if z <= k
    end
  end
end
puts array.size


Measured memory_bytes: 239996
#include <stdio.h>

int func(int i, int m);

int n, A[10000] = {0};

int main(void) {
  
  int m[500] = {0}, q, i;
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  
  scanf("%d", &q);
  
  for (i = 0; i < q; i++) {
    scanf("%d", &m[i]);
  }
  
  for (i = 0; i < q; i++) {
    if (func(0,m[i]) == 1) {
      printf("yes\n");
    } else printf("no\n");
  }
  
  return 0;
}

int func(int i, int m) {
  int ans;
  
  if (m == 0) {
    return 1;
  }
  if (i >= n) {
    return 0;
  }
  
  ans = func(i + 1, m) || func(i + 1, m - A[i]);
  
  return ans;
  
}

Measured memory_bytes: 584
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  char b;
  cin >> b;

  if (b == 'A') {
    cout << 'T' << endl;
  }
  if (b == 'T') {
    cout << 'A' << endl;
  }
  if (b == 'G') {
    cout << 'C' << endl;
  }
  if (b == 'C') {
    cout << 'G' << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import heapq

def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**10]*n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

################################
N,X,Y = map(int,input().split())
n = N
w = N

edge = tuple([] for i in range(n))
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    if i == 0:
        edge[i].append([1,i+1])
    elif i == w-1:
        edge[i].append([1,i-1])
    else:
        edge[i].append([1,i+1])
        edge[i].append([1,i-1])
edge[X-1].append([1,Y-1])
edge[Y-1].append([1,X-1])

ans = [0]*(N+1)
tmp = []
for i in range(N):
    tmp.append(dijkstra_heap(i,edge)[i+1:])

for i in range(N):
    for j in tmp[i]:
        ans[j] += 1

for i in range(1,N):
    print(ans[i])


Measured memory_bytes: 76636
n=int(input())
a=list(map(int,input().split()))
#+-+-
ans=0
s=0
for i in range(n):
    f=i%2
    s+=a[i]
    if f==0:
        if s<=0:
            ans+=-s+1
            s=1
    else:
        if s>=0:
            ans+=1+s
            s=-1
#-+-+
anss=0
s=0
for i in range(n):
    f=i%2
    s+=a[i]
    if f==1:
        if s<=0:
            anss+=-s+1
            s=1
    else:
        if s>=0:
            anss+=1+s
            s=-1
print(min(ans,anss))



Measured memory_bytes: 85244
a, b = map(int, input().split())

x = 0

ans = -1

while x <= 2000:
    x_a = int(0.08*x)
    x_b = int(0.10*x)

    if x_a == a and x_b == b:
        ans = x
        break

    x += 1

print(int(ans))


Measured memory_bytes: 2940
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;
		
		if(N%X!=0) {
			System.out.println(T*(a+1));
		}else {
			System.out.println(T*a);
		}
	}

}

Measured memory_bytes: 35840
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
	using namespace std;
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	bool ans = C <= A + B;
	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
"use strict";
function main(input) {
    let line = input.split(/\r?\n/g);
    let arr = line[0].split(" ");
    const N = parseInt(arr[0]), M = parseInt(arr[1]);
    console.log(((N * (N - 1) / 2) | 0) + ((M * (M - 1) / 2) | 0));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 20808
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
      	int nam[] = new int[a];
      	int nam2[] = new int[a-1];
      
      for(int i = 0;i < a-1;i++){
      nam2[i] = in.nextInt();
      }
      
      nam[0] = nam2[0];
      nam[a-1] = nam2[a-2];
      long sum = 0;
      
      for(int i = 1;i < a-1;i++){
      	nam[i] = Math.min(nam2[i],nam2[i-1]);
      }
      for(int i = 0;i < a;i++){
      sum += nam[i];
      }
      System.out.print(sum);
      
	}
}

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

int main(void){
    ll n, x, cnt = 0;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    for (int i=0; i<n; i++){
        if ((i<n-1 && a[i]<=x) || (i==n-1 && a[i]==x)){
            x -= a[i];
            cnt++;
        } else{
            break;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    string s; cin >> s;
    int ans = 1;
    if (s=="SSS") ans = 0;
    if (s=="SRR" || s=="RRS") ans = 2;
    if (s=="RRR") ans = 3;
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll a[2005];
int main(){
	int n;
	cin>>n;
	a[3]=1;
	for(int i=4;i<=n;i++){
		a[i]=(a[i-1]+a[i-3])%mod;
		a[i]=(a[i]+mod)%mod;
	}
	cout<<a[n]<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

vec snuke;
int k;

int f(lint n) {
    int res = 0;

    while (n > 0) {
        res += (n%10);
        n /= 10;
    }

    return res;
}

long double g(lint n) {
    return (long double)n / f(n);
}

void build() {
    lint base = 1;
    lint suffix = 0;

    for (int i = 0; i < 15; i++) {
        for (int j = 0; j < 300; j++) {
            if (i == 0 && j == 0) continue;
            snuke.push_back(suffix + base * j);
        }
        suffix += base * 9;
        base *= 10;
    }
}

int main() {
    cin >> k;

    build();

    sort(all(snuke));
    snuke.erase(unique(all(snuke)), snuke.end());

    int v = snuke.size();

    for (int i = 0; i < v; i++) {
        for (int j = i+1; j < v; j++) {
            if (g(snuke[i]) > g(snuke[j])) {
                snuke[i] = -1;
                break;
            }
        }
    }
    
    rep(i, k) {
        if (snuke[i] != -1) cout << snuke[i] << endl;
        else k++;
    }
    return 0;
}

Measured memory_bytes: 384
#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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string x;
    int flag=0;
    cin>>x;

    for(int i=0; i<3; i++)
    {
        if(x.at(i) == '7')
        {
            flag++;
        }
    }

    if(flag > 0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else
    {
        cout<<"No"<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 3656
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<chrono>
#include<unordered_map>
#include<random>
#include<complex> 
using namespace std;
typedef complex<long double> point;
#define EPS 1e-9 
#define OO 1e9
#define X real()
#define Y imag()
#define vec(a,b) ((b)-(a)) 
#define polar(r,t) ((r)*exp(point(0,(t)))) 
#define angle(v) (atan2((v).Y,(v).X)) 
#define length(v) ((long double)hypot((v).Y,(v).X)) 
#define lengthSqr(v) (dot(v,v)) 
#define dot(a,b) ((conj(a)*(b)).real()) 
#define cross(a,b) ((conj(a)*(b)).imag()) 
#define rotate(v,t) (polar(v,t)) 
#define rotateabout(v,t,a)  (rotate(vec(a,v),t)+(a)) 
#define reflect(p,m) ((conj((p)/(m)))*(m)) 
#define normalize(p) ((p)/length(p)) 
#define same(a,b) (lengthSqr(vec(a,b))<EPS) 
#define mid(a,b) (((a)+(b))/point(2,0)) 
#define perp(a) (point(-(a).Y,(a).X)) 
#define colliner pointOnLine 
enum STATE { IN, OUT, BOUNDRY };

#define ll long long
#define ld long double
#define ull unsigned ll 
#define endl '\n'
#define mk make_pair
#define PI acos(-1.)
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
int lx[] = { 2, 2, -1, 1, -2, -2, -1, 1 };
int ly[] = { -1, 1, 2, 2, 1, -1, -2, -2 };
const ld eps = 1e-3;
const int N = 5e5 + 50, M = 4e4 + 10, mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll t = gcd(a, b); return t ? (a / t * b) : 0; }
int main() {
	fast_in_out();
	//cout << fixed << setprecision(3);
	map<int, int>mp;
	int n, b;
	int cnt = 0;
	cin >> n >> b;
	while (n) {
		mp[n % b];
		n /= b;
		cnt++;
	}
	cout << cnt << endl;
	return 0;


}

Measured memory_bytes: 256
import Data.Maybe
import Data.List

main = putStrLn . solve . lines =<< getContents

solve :: [String] -> String
solve = solve' 0 . map (map $ maybe 0 id . flip elemIndex ids)
    where
        ids = "abc"
        solve' 0 [[],_,_] = "A"
        solve' 1 [_,[],_] = "B"
        solve' 2 [_,_,[]] = "C"
        solve' 0 [(a:as),bs,cs] = solve' a [as,bs,cs]
        solve' 1 [as,(b:bs),cs] = solve' b [as,bs,cs]
        solve' 2 [as,bs,(c:cs)] = solve' c [as,bs,cs]


Measured memory_bytes: 508
from math import ceil

def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
    ret = 0
    for i in range(n):
        ret += ceil(A[i]/arg)-1
    return bool(ret<=k)

def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

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

print(meguru_bisect(0,max(A)+1))

Measured memory_bytes: 31116
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Jan 17 11:42:47 2019
//
package main

import "fmt"

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var N int
	fmt.Scan(&N)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	dp := make([]bool, N*100)
	dp[0] = true

	for i := range arr {
		for j := len(dp) - 1; j >= 0; j-- {
			if 0 <= j-arr[i] && dp[j-arr[i]] {
				dp[j] = true
			}
		}
	}

	ans := 0
	for j := range dp {
		if dp[j] && j%10 != 0 {
			ans = max(ans, j)
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int dp[305][305][305];
int pw(int n,int k){
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
//main
signed main(){
  int N,M;cin>>N>>M;
  memset(dp,0,sizeof(dp));
  dp[0][N-1][1]=1;
  for(int i=0;i<M;i++){
    for(int j=0;j<=N;j++){
      for(int k=0;k<=N;k++){
        if(j)dp[i+1][j-1][k]+=dp[i][j][k]*j;
        dp[i+1][j][N-j]+=dp[i][j][k]*k;
        dp[i+1][j][k]+=dp[i][j][k]*(N-j-k);
        if(j)dp[i+1][j-1][k]%=MOD;
        dp[i+1][j][N-j]%=MOD;
        dp[i+1][j][k]%=MOD;
      }
    }
  }
  cout<<dp[M][0][N]<<endl;
}


Measured memory_bytes: 221952
n=int(input())
l=[[] for _ in range(n+1)]
q=[(1,0)]
ans=[-1]*n
while n>1:
    u,v,w=map(int,input().split())
    l[u]+=[(v,w)]
    l[v]+=[(u,w)]
    n-=1
while q:
    u,w=q.pop()
    ans[u-1]=w%2
    for v,d in l[u]:
        q+=[(v,w+d)]*(ans[v-1]<0)
print(*ans)


Measured memory_bytes: 70432
N,Q=map(int,input().split())
S=list(input()+'T')
index=[0]*(N+1); s=0
for i in range(1,N+1):
    if S[i-1]+S[i]=='AC': s+=1
    index[i]=s
for i in range(Q):
    l,r=map(int,input().split())
    if S[l-1]=='C': print(index[r-1]-index[l])
    else: print(index[r-1]-index[l-1])

Measured memory_bytes: 8560
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n);
  VC1(n,a);
  S s;
  int cou = 0;
  REP(i,n){
    if(a[i]>=3200){
      cou++;
      continue;
    }
    int t = (a[i]) / 400;
    s.insert(t);
  }
  if(s.size()==0)SCOUT(1);
  else SCOUT(s.size());
  COUT(s.size() + cou);


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back 
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;

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



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U;
    int x;
    cin>>k>>x;
    if(k*500>=x) cout<<"Yes";
    else cout<<"No";
}


signed main()
{
 //   #ifndef ONLINE_JUDGE 
   //    freopen("input.txt","r",stdin);
   //    freopen("output.txt","w",stdout);
  //  #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



int main() {
	int a,n,t=0;
	cin >> n;
	rep(i, n) {
		cin >> a;
		t += a - 1;
	}
	cout << t << endl;
}


Measured memory_bytes: 256
S=list(input())
a=0
if len(S)%2==1:
    a=1
for i in range(len(S)):
    if i%2==0:
        if S[i]!="h":
            a=1
            break
    if i%2==1:
        if S[i]!="i":
            a=1
            break     
if a==0:
    print("Yes")
else:
    print("No")

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

int main() {
  int n;
  string s;
  while ( cin >> n >> s ) {
    int change = 0;
    for (auto x : s) if ( x == '.' ) change++ ;
    
    int min_c = change;
    for (auto x : s) {
      if ( x == '.' ) change-- ;
      else change++ ;
      
      min_c = min( min_c, change );
    }
    
    cout << min_c << '\n';
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int n;
    cin >> n;
    int o[100001]={};
    int e[100001]={};
    int mxo=0;
    int mxo2=-1;
    int xo=0;
    int mxe=0;
    int mxe2=-2;
    int xe=0;
    rep(i,n){
        int x;
        cin >> x;
        if(i%2==0)e[x]++;
        else o[x]++;
    }
    rep(i,100002){
        chmax(mxo2,o[i]);
        if(mxo<o[i]){
            mxo2=mxo;
            mxo=o[i];
            xo=i;
        }
        else if(mxo==o[i])xo=1e9;
        chmax(mxe2,e[i]);
        if(mxe<e[i]){
            mxe2=mxe;
            mxe=e[i];
            xe=i;
        }
        else if(mxe==e[i])xe=1e8;
    }
    if(xo!=xe)cout << n-mxo-mxe;
    else cout << min(n-mxo-mxe2,n-mxo2-mxe);
    


}

/*



 */


Measured memory_bytes: 1152
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int n, m;
	cin >> n >> m;
	vector<int>a;
	LL sum = 0;
	vector<ipair>ab;
	for (int i = 0; i < n; i++) { int val; cin >> val; a.PB(val); }
	sort(a.begin(), a.end());
	for (int i = 0; i < m; i++) {
		int b, c;
		cin >> b >> c;
		ab.PB({ c,b });
	}
	sort(ab.begin(),ab.end());
	reverse(ab.begin(), ab.end());
	auto abc = ab.begin();
	for (auto itra = a.begin(); itra != a.end(); itra++) {
		if (abc == ab.end())break;
		auto &curab = *abc;
		auto &rep = curab.ff;
		auto &rem = curab.ss;
		auto&curCard = *itra;
		if (curCard > rep)break;
		curCard = rep;
		rem--;
		if (rem <= 0)abc++;
	}
	for (auto i = a.begin(); i !=a.end(); i++)sum +=*i;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1784
#include <stdio.h>

int main(void){
	int a[100],b[100],t,i,n,m;
	scanf("%d",&m);
	while(m!=0){
	scanf("%d",&n);
	for(t=0;t<n;t++){
		scanf("%d",&a[t]);
	}
	for(t=1;t<n;t++){
		b[t]=a[t-1]-a[t];
	}
	for(i=1;i<n;i++){
		for(t=2;t<n;t++){
			if(b[t-1]>b[t]){
				a[0]=b[t-1];
				b[t-1]=b[t];
				b[t]=a[0];
			}
		}
	}
		if(n==2){
			if(b[1]>0){
				printf("0 %d\n",b[1]);
			}
			if(b[1]<0){
				printf("%d 0\n",-b[1]);
			}
		}
		else{
			if(b[1]>0){
				b[1]=0;
			}
			if(b[n-1]<0){
				b[n-1]=0;
			}
		printf("%d %d\n",-b[1],b[n-1]);
		}
		m--;
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

ll N, K;
vector<ll> A;

bool check(ll x) {
	ll sum = 0;
	REP(i, 0, A.size()) sum += (A[i] + x - 1) / x - 1;
	return sum <= K;
}

int main() {
	cin >> N >> K;
	A.resize(N);
	REP(i, 0, N)cin >> A[i];
	if (K == 0) {
		PRI(*max_element(A.begin(), A.end()));
		return 0;
	}
	ll l = 1;
	ll r = 1000000000;
	while (true) {
		if (l == r) {
			PRI(l);
			return 0;
		}

		ll center = (l + r) / 2;
		if (check(center)) r = center;
		else l = center+1;
	}

	return 0;
}




Measured memory_bytes: 4688
#include<bits/stdc++.h>
using namespace std;
 
int n,c;
long long dp[102][100005];
pair<int,long long> a[100005];
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n>>c;
	for(int i=1;i<=n;i++){
		cin>>a[i].first>>a[i].second;
	}
	
	sort(a+1,a+n+1);
	
	for(int i=1;i<=n;i++){
		//cout<<a[i].first<<" "<<a[i].second<<endl;
		for(int j=1;j<a[i].first;j++){
			dp[i][j] = dp[i-1][j];
		}
		for(int j=a[i].first;j<=c;j++){
			dp[i][j] = max(dp[i-1][j],a[i].second+dp[i-1][j-a[i].first]);
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	long long ans = 0;
	for(int i=1;i<=c;i++){
		ans = max(ans,dp[n][i]);
	}
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 78720
n,x=map(int,input().split())

a,p=[1],[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)


def f(n,x):
    if n==0:return 0 if x<=0 else 1
    elif x<=1+a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])


print(f(n,x))

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	ans := 700
	for _, r := range s {
		if string(r) == "o" {
			ans += 100
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7

def main():
    N = cin.int()
    A = cin.mapInt()
    A.sort()
    ans = 1
    if N % 2 == 0:
        for i in range(0,N,2):
            if A[i] == A[i + 1] and A[i] == i + 1:
                ans *= 2
                ans %= MOD
            else:
                ans = 0
    else:
        if A[0] != 0:
            ans = 0
        for i in range(1,N,2):
            if A[i] == A[i + 1] and A[i] == i + 1:
                ans *= 2
                ans %=MOD
            else:
                ans = 0
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 52916
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    string s;
    ll k;
    cin>>s>>k;
    for(ll i=0;i<k;i++){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;

}



    

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int16_t hoge[30][100001];
int16_t used[30][100001];
int16_t anss[100001];
int main (){
      int N,C;
      cin>>N>>C;
      int s[N],t[N],c[N];
      rep0(i,N){
            cin>>s[i]>>t[i]>>c[i];
            --c[i];
      }
      rep0(ch,C){
            rep0(i,N){
                  if(c[i]==ch){
                        hoge[ch][s[i]-1]++;
                        hoge[ch][t[i]]--;
                  }
            }
      }
      rep0(ch,C){
            rep0(t,100001){
                  if(t==0) used[ch][t]=hoge[ch][t];
                  else used[ch][t]=used[ch][t-1]+hoge[ch][t];
            }
      }
      rep0(ch,C)rep0(t,100001){
            if(used[ch][t]>0) used[ch][t]=1;
      }
      rep0(t,100001)rep0(ch,C){
            anss[t]+=used[ch][t];
      }
      int16_t ans=0;
      rep0(t,100001){
            ans=max(ans,anss[t]);
      }
      cout<<ans<<endl;
      return 0;
}


Measured memory_bytes: 13312
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) 
#define X first
#define Y second 
#define nl '\n'
#define AC return 0
#define pb(a) push_back(a) 
#define mst(a,b) memset(a, b, sizeof a)
#define rep(i,n) for(int i = 0; (i)<(n); i++)
#define rep1(i,n) for(int i = 1; (i)<=(n); i++)
#define scd(a) scanf("%lld", &a)
#define scdd(a,b) scanf("%lld%lld", &a, &b)
#define scs(s) scanf("%s", s)
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll INF = (ll)0x3f3f3f3f3f3f3f, MAX = 9e18, MIN = -9e18;
const int N = 1e6+10, M = 2e6+10, mod = 1e9+7, inf = 0x3f3f3f;
ll a[N]; 


int main()
{
	IOS;
	string s;
	cin>>s;
	if(s[s.size()-1] == 's')
		s += "es";
	else
		s += "s";
	cout<<s<<nl;
	
	
	AC;
} 

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  int t = 1;
  sort(vec.begin(), vec.end());
  for(int i = 0; i < N -1; i++){
    if(vec.at(i) != vec.at(i + 1)){
      t += 1;
    }
  }
  cout << t << endl;
}

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

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

int main() {
  LL N; cin >> N;
  LL vmin = 1e18;
  for (int i = 0; i < 5; ++i) {
    LL a; cin >> a;
    vmin = min(vmin, a);
  }

  LL times = ceil(static_cast<double>(N) / vmin);
  cout << 4LL + times << endl;
}


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

public class Main
{
	static StringBuilder sb = new StringBuilder();
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//Scanner sc = new Scanner(System.in);
		Deque<String> nameQue = new ArrayDeque<>();
		Deque<Integer> workQue = new ArrayDeque<>();
		String[] rem  = br.readLine().split(" "); 
		int n = Integer.parseInt(rem[0]);//Integer.parseInt(sc.next());
		int time = Integer.parseInt(rem[1]); //Integer.parseInt(sc.next());
		//int[][] data = new int[n][2];
		//String[] stemp ;
		for(int i= 0 ; i< n ; i++){
			rem = br.readLine().split(" "); 
			nameQue.offer(rem[0]);
			workQue.offer(Integer.parseInt(rem[1]));
		}
		roundSche(nameQue,workQue,time);
	}
	public static void roundSche(Deque<String> nameQ , Deque<Integer> workQ , int time)
	{
		int pos , prog = 0;
		int temp ;
		while(workQ.size() != 0)
		{
			temp =  workQ.poll();
			if(temp <= time){
				prog += temp;
				sb.append(nameQ.poll()).append(' ').append(prog).append('\n');
			}
			else 
			{
				workQ.offer(temp - time);
				nameQ.offer(nameQ.poll());
				prog += time;
			}
		}
		System.out.print(sb);
		
	}
	
}

Measured memory_bytes: 57184