akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int n;
  cin >> n;
  cout << "ABC" << n << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 50;
const int MAX_N = 1 << 17;
const int def = 0;

struct MaxSegTree2 {
	int n;
	ll segMax[2 * MAX_N - 1], segAdd[2 * MAX_N - 1];
	void init(int n_) {
		n = 1;
		while(n < n_) n *= 2;
		for(int i = 0; i < 2 * n - 1; i++) segMax[i] = def;
	}

	void add(int a, int b, ll x) { add(a, b, x, 0, 0, n); }

	void add(int a, int b, ll x, int k, int l, int r) {
		if(r <= a || b <= l) return;
		if(a <= l && r <= b) {
			segAdd[k] += x;
			return;
		}
		add(a, b, x, k * 2 + 1, l, (l + r) / 2);
		add(a, b, x, k * 2 + 2, (l + r) / 2, r);
		segMax[k] = max(segMax[k * 2 + 1] + segAdd[k * 2 + 1], segMax[k * 2 + 2] + segAdd[k * 2 + 2]);
	}

	ll query(int a, int b) { return query(a, b, 0, 0, n); }

	ll query(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return -INF;
		if(a <= l && r <= b) return segMax[k] + segAdd[k];
		ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return max(vl, vr) + segAdd[k];
	}
};

MaxSegTree2 st;
typedef pair<ll, int> P;

ll d[100000];
ll heal[100000];
int c[1000000];

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

	//ifstream ifs("input.txt");
	//cin.rdbuf(ifs.rdbuf());
	//ofstream ofs("output.txt");
	//cout.rdbuf(ofs.rdbuf());

	int N, H;
	cin >> N >> H;
	st.init(N);
	st.add(0, N, H);
	for(int i = 0; i < N - 1; i++) {
		cin >> d[i] >> heal[i];
		st.add(i + 1, N, -d[i]);
	}
	ll hp = H, ans = 0;
	priority_queue<P> q; // <head,idx>
	for(int i = 0; i < N - 1; i++) {
		////cerr << "d : " << d[i] << ", heal : " << heal[i] << endl;
		q.push({ heal[i], i });
		if(hp - d[i] >= 1) {
			hp -= d[i];
		}
		else {
			while(hp - d[i] <= 0) {
				P p = q.top();
				q.pop();
				ll h = p.first, idx = p.second;

				ll x = -hp + d[i] + 1;
				ll rem = H - st.query(idx, N);
				assert(rem >= 0);
				if(rem == 0) continue;
				if(rem < h) {
					q.push({ rem, idx });
					continue;
				}
				int cnt = (x + h - 1) / h;
				if(h * cnt > rem) cnt = rem / h;
				//cerr << "idx : " << idx << ", h : " << h << ", cnt : " << cnt << endl;
				//cerr << hp << " -> ";
				hp = min(ll(H), hp + h * cnt);
				//cerr << hp << endl;
				ans += cnt;
				c[idx] += cnt;
				st.add(idx, N, h * cnt);
				rem -= h * cnt;
				if(rem > 0) {
					q.push({ min(rem, h), idx });
				}
			}
			hp -= d[i];
		}
		/*for(int j = 0; j < N - 1; j++) {
			cout << st.query(j, j + 1) << " ";
			}
			cout << endl;*/
		//cerr << "hp : " << hp << endl;

	}
	cout << ans << endl;

	hp = H;
	for(int i = 0; i < N; i++) {
		hp = min(ll(H), hp + c[i] * heal[i]);
		hp -= d[i];
		assert(hp >= 1);
	}
}

Measured memory_bytes: 8688
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <queue>
#include <cmath>

typedef long long ll;

bool is10n(ll x)
{
    if (x < 1) {return false;}

    while(x != 1) {
        if (x%10) {return false;}
        x /= 10;
    }

    return true;
}

ll solve(const int n)
{
    const int digit = std::log10(static_cast<double>(n)) + 1;
    const int top = n / pow(10, digit - 1);
    const int top2 = top * pow(10, digit - 1);

    // 1桁
    if (n < 10) {return n;}

    // 10の整数乗の場合
    if (is10n(n)) {
        ll pattern = 0;
        for (int aLen = 1; aLen < digit; aLen++) {
            for (int bLen = 1; bLen < digit; bLen++) {
                if (aLen >= 2 && bLen >= 2) {
                    pattern += 9 * 9 * pow(10, aLen - 2) * pow(10, bLen - 2);
                } else if (
                    (aLen >= 2 && bLen == 1)||
                    (aLen == 1 && bLen >= 2)
                ) {
                    pattern += 9 * pow(10, std::max(aLen, bLen) - 2);
                } else {
                    // aLen == 1 && bLen == 1
                    pattern += 9;
                }
            }
        }

        return pattern;
    }

    ll pattern = solve(pow(10, digit - 1));
    for (int aLen = 1; aLen <= digit; aLen++) {
        for (int bLen = 1; bLen <= digit; bLen++) {
            if ((aLen != digit)&&(bLen != digit)) {
                continue;
            }
            if ((aLen < digit)||(bLen < digit)) {
                const int minLen = std::min(aLen, bLen);
                if (minLen > 1) {
                    pattern += (top - 1) * 9 * pow(10, aLen - 2) * pow(10, bLen - 2);
                    for (int a = top * pow(10, digit - 1); a <= n; a++) {
                        const int aLast = a % 10;
                        if (aLast == 0) {continue;}
                        pattern += pow(10, minLen - 2);
                    }
                } else { // minLen == 1
                    pattern += (top - 1) * pow(10, std::max(aLen, bLen) - 2);
                    for (int a = top * pow(10, digit - 1); a <= n; a++) {
                        const int aLast = a % 10;
                        if (aLast == top) {pattern++;}
                    }
                }
            } else {
                pattern += (top - 1) * (top - 1) * pow(10, digit - 2) * pow(10, digit - 2);
                for (int a = top * pow(10, digit - 1); a <= n; a++) {
                    const int aLast = a % 10;
                    if (aLast == 0) {continue;}
                    if (aLast >= top) {continue;}
                    pattern += 2 * pow(10, digit - 2);
                }
                for (int a = top * pow(10, digit - 1) + top; a <= n; a += 10) {
                    for (int b = top * pow(10, digit - 1) + top; b <= n; b += 10) {
                        pattern++;
                    }
                }
            }
        }
    }

    return pattern;
}

int main(int argc, char *argv[])
{
    int n;

    std::cin >> n;

    ll ans = solve(n);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
N,A,B=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=1)
s=sum(v[:A])
print(s/A)
from math import factorial
t=v[A-1]
p,q=0,0
for i in v:
    if i>t:
        p+=1
    elif i==t:
        q+=1
a=0
def c(n,k):
    return (factorial(n)//factorial(k)//factorial(n-k))
for i in range(A,B+1):
    if p+q>=i:
        a+=c(q,i-p)
    if t!=v[0]:
        break
print(a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, tmp;
  cin >> N;
  int shine[200001] = {0};
  for(int i = 1; i < N; i++){
    cin >> tmp;
    shine[tmp]++;
  }
  
  for(int i = 1; i <= N; i++){
    cout << shine[i] << endl;    
  }
}
    

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

int main() {
  ll n; cin>>n;
  vector<pll> v(n);
  rep(i,n){
    ll a,b; cin>>a>>b;
    v[i].first=a+b;
    v[i].second=a-b;
  }
  sort(v.begin(),v.end());
  ll m=v[0].first;
  ll c=1;
  rep(i,n){
    if(v[i].second>=m){m=v[i].first;c++;}
  }
  cout<<c;
}

Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    char s[100];
    string ans="Three";
    cin>>n;
  for(int i=0;i<n;i++){
      cin>>s[i];
   if (s[i]=='Y'){
      ans="Four";
      break;
        }
    }
		cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    xyz = []
    for i in range(N):
        x, y, z = map(int, input().split())
        tmp = [x, y, z]
        for i in range(8):
            t = 0
            for j in range(3):
                if i&1:
                    t += tmp[j]
                else:
                    t -= tmp[j]
                i >>= 1
            tmp.append(t)
        xyz.append(tmp)
    
    ans = 0
    for i in range(8):
        xyz = sorted(xyz, key=lambda x: x[i+3])
        x, y, z = 0, 0, 0
        for i in range(M):
            x += xyz[i][0]
            y += xyz[i][1]
            z += xyz[i][2]
        ans = max(ans, abs(x) + abs(y) + abs(z))
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;

ll N,K;

int sum[12][11];

void solve(){
	ll a,b;
	if (N<=2){
		printf("0\n");
		return;
	}
	a=N-2;
	b=a%11;
	ll res=0;
	res=sum[11][K]*(a/11);
	REP(i,b){
		res+=sum[i][K];
	}
	printf("%lld\n",res);
}

int main(){
	int F=13;
	FOR(i,2,F){
		FOR(j,2,7){
//			printf("%3d ",(7*i+j-7)*9%11);
			sum[i-2][(7*i+j-7)*9%11]++;
		}
//		printf("\n");
	}
	REP(i,11){
		REP(j,11){
			sum[11][i]+=sum[j][i];
		}
	}
	scanf("%lld %lld",&N,&K);
	solve();
	/*
	FOR(i,2,18){
		FOR(j,2,7){
			fprintf(stderr,"%3d ",(7*i+j-7)*9%11);
		}
		fprintf(stderr,"\n");
	}
	*/
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[2]*10+a[1]+a[0] << endl;
}

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

const double pi = acos(-1);
#define INF 999999999
int main ()
{
   int n,x;  cin >> n;
    

    for(int i=1;i<=n;i++){
        if(i%3 == 0){
            cout << " " << i;
        }
else{x=i;
        do{
            if(x%10 == 3) {cout << " " << i;
            break;
            }
            x/=10;
        }while(x);

}

    }
cout << endl;
    
}



Measured memory_bytes: 3088
// O(|E||V|)

#include <vector>
#include <cassert>
#include <algorithm>

using namespace std;

class Prim {
#define MAX_V 101

private:
  const int INF = 1e9 + 10;
  struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) { }
  };

  int V;
  vector<Edge> G[MAX_V];
  int mincost[MAX_V];
  bool used[MAX_V];

public:

  Prim(int V): V(V) { 
    if (V >= MAX_V) {
      assert(false);
    }
  }

  void AddEdge(int from, int to, int cost) {
    G[from].push_back(Edge(to, cost));
  }

  int Solve() {
    for (int i = 0; i < V; i++) {
      mincost[i] = INF;
      used[i]    = false;
    }

    mincost[0] = 0;
    int res = 0;

    while (true) {
      int v = -1;
      for (int u = 0; u < V; u++) {
        if (!used[u] && (v == -1 || mincost[u] < mincost[v])) {
          v = u;
        }
      }
      if (v == -1) {
        break;
      }
      used[v] = true;
      res += mincost[v];

      for (auto &e : G[v]) {
        mincost[e.to] = min(mincost[e.to], e.cost);
      }
    }

    return res;
  }
};

#include <iostream>

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int c; cin >> c;
      if (c != -1) {
        prim.AddEdge(i, j, c);
      }
    }
  }

  int ans = prim.Solve();

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3104
a,b,c=input(),input(),input()
dict={'a':a,'b':b,'c':c}
start='a'
save=start
while True:
    val = dict.get(save)
    if val==None:
        print(save.upper())
        exit()
    else:
        key=val[0]
        if len(val)==1:
            new=None
            dict[save]=new
            save=key
        else:
            new=val[1:]
            dict[save]=new
            save=key


Measured memory_bytes: 3064
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


S = instr()
r = "Yes"
e, w, n, s = 0, 0, 0, 0
for i in S:
    if i in "N":
        n += 1
    elif i == "S":
        s += 1
    elif i == "E":
        e += 1
    else:
        w += 1
if (n > 0 and s > 0) or (n == 0 and s == 0):
    pass
else:
    r = "No"
if (e > 0 and w > 0) or (e == 0 and w == 0):
    pass
else:
    r = "No"
print(r)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(string,s);
  bool ok = (s[0]==s[1] || s[1]==s[2] || s[2]==s[3]);
  OUT((ok?"Bad":"Good"))BR;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import deque

YES = "Yes"  # type: str


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    dq = deque([])
    traversed = [False for _ in range(N+1)]
    ans = [None for _ in range(N+1)]

    G = {n : set([]) for n in range(1, N+1)}
    for a, b in zip(A,B):
        G[a].add(b)
        G[b].add(a)

    dq.append(1)
    traversed[1] = True

    while dq:
        s = dq.popleft()

        for node in G[s]:
            if not traversed[node]:
                dq.append(node)
                traversed[node] = True
                

                ans[node] = s

    print(YES)
    for s in ans:
        if s != None:
            print(s)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 122256
/* ****_hela**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll int n,m;
		cin>>n>>m;
		ll int a[n],tot=0;
		rep(i,0,n)cin>>a[i],tot+=a[i];
		ll int c=0;
		rep(i,0,n)
		{
			if(4*m*a[i]>=tot)c++;
		}		
		if(c<m)cout<<"No";
		else cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <unordered_set>

using std::string;
using std::cout;
using std::cin;
using std::vector;
using ull = unsigned long long;
using ll = long long;

int main(){
    ull n,k;
    cin >> n >> k;
    vector<ull> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    std::unordered_set<ull> s;
    ull count = 0ULL;
    ull current = 0Ull; //0
    vector<ull> path;
    while(s.find(current) == s.end()){
        s.insert(current); // {0}
        path.push_back(current); // {0}
        current = a.at(current)-1;
        count++; // 1
    }
    // find last appearance of current node in the path
    auto itr = path.end()-1;
    ull loop_count = 1ULL; // 1
    while(*itr!=current){ // 0 == 0
        itr--;
        loop_count++;
    }
    //                                          count:loop_count:non_loop_count        
    ull non_loop_count = count - loop_count; // 5    :3         :2
    if(k<=non_loop_count){                   // k:k-non_loop_count:ans
        cout << path.at(k)+1 << "\n";        // 3:1               :1
        return 0;                            // 5:3               :0
    }
    //                                          7:5               :2
    ull ans = (k-non_loop_count) % loop_count; //  3-2
    cout << path.at(ans+non_loop_count)+1 << "\n";
    
    return 0;
}

Measured memory_bytes: 14376
#include<stdio.h>

int main(){
		int n,d,i,j,x[10][10],ans=0;
		scanf("%d%d",&n,&d);
		for(i=0;i<n;i++){
				for(j=0;j<d;j++){
						scanf("%d",&x[i][j]);
				}
		}
		for(i=0;i<n;i++){
				for(j=i+1;j<n;j++){
						int k,sum=0;
						for(k=0;k<d;k++)sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
						for(k=0;k*k<=sum;k++){
								if(k*k==sum)ans++;
						}
				}
		}
		printf("%d\n",ans);
		return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;
    if (s=="SUN") cout<<7;
    else if (s=="MON") cout<<6;
    else if (s=="TUE") cout<<5;
    else if (s=="WED") cout<<4;
    else if (s=="THU") cout<<3;
    else if (s=="FRI") cout<<2;
    else cout<<1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll a,b,c,d;
cin >>a>>b>>c>>d;
ll e=0,f=0;
while(a>0){
a=a-d; e++;}
while(c>0)
{ c=c-b; f++;}
if(e<f) cout << "No"<<endl;
else cout << "Yes" <<endl;
}


Measured memory_bytes: 3524
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int main(int argc, char **argv) {
    llong N;
    cin >> N;
    llong res = N * (N - 1) / 2;
    cout << res << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct tp
{
    long long weight, value;
};
tp a[101];
long long n, f[101][1000001], k;
int main()
{
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i].weight>>a[i].value;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=k;j++)
        {
            f[i][j]=f[i-1][j];
            if(j>=a[i].weight) f[i][j]=max(f[i-1][j], f[i-1][j-a[i].weight]+a[i].value);
        }
    cout<<f[n][k];
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n=s.size();
    int flag=0;
    for(int i=0;i<n;i++){
        if(s.at(i)=='7') flag=1;
    }
    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3624
// 各iビット目について、
// 集合{Ai}のうちiビット目が立っている数がCiとすると、
// Xのiビット目を0にしたとき、fの値の寄与はCi*2^iになり、
// Xのiビット目を1にしたとき、fの値の寄与は(N - Ci)*2^iになる。
// なので、Xの各ビットについて、1か0のどちらにしたらfの値が大きくなるか調べ、
// それを答えにすればよい。。。
// 、、、が、X <= Kという制約があるため、これを満たしつつ最大となる数を探す。
// 詳しくはeditorial参照のこと
#include <bits/stdc++.h>
using namespace std;

int main() {
    long long N;
    long long K;
    cin >> N >> K;
    long long res = 0;
    vector<long long> keta(60, 0);
    for (int i = 0; i < N; ++i) {
        long long A;
        cin >> A;
        res += A;
        for (int j = 0; j < 60; ++j) {
            if ((A >> j) & 1LL) ++keta[j];
        }
    }
    for (int mask = 0; mask < 60; ++mask) {
        if (((K >> mask) & 1LL) == 0) continue;  // Xi < Kiを満たせない場合を無視
        long long tmp = 0;
        //long long k_tmp = 0;  // デバッグ用
        for (int i = 0; i < mask; ++i) {
            tmp += max(N - keta[i], keta[i]) * (1LL << i);
            //if (keta[i] <= N - keta[i]) k_tmp += (1LL << i);
        }
        // maskビット目はかならず0にする。
        tmp += keta[mask] * (1LL << mask);  // この文を書いてなくてずっとバグってた
        for (int i = mask + 1; i < 60; ++i) {
            if ((K >> i) & 1LL) {
                tmp += (N - keta[i]) * (1LL << i);
                //k_tmp += (1LL << i);
            } else {
                tmp += keta[i] * (1LL << i);
            }
        }

        /*
        if (true) {
            cout << "mask: " << mask << " k_tmp: " << k_tmp << " K:" << K << " tmp: " << tmp << endl;
        }
        */

        //assert(k_tmp <= K);
        res = max(res, tmp);
    }
    // X == Kの場合について調べてなかったので、以下で調べる
    {
        long long tmp = 0;
        for (int i = 0; i < 60; ++i) {
            if ((K >> i) & 1LL) {
                tmp += (N - keta[i]) * (1LL << i);
            } else {
                tmp += keta[i] * (1LL << i);
            }
        }
        res = max(res, tmp);
    }

    cout << res << endl;
    //cout << "sum 0 to 99999: " << (long long)(0 + 99999) * 100000LL / 2LL << endl;
    return 0;
}

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

string S;

int main() {
    cin >> S;
    
    if (S.length() < 26) {
        int alpha[26];
        memset(alpha, 0, sizeof(alpha));
        for (int i = 0; i < S.length(); i++) {
            alpha[S[i] - 'a']++;
        }

        for (int i = 0; i < 26; i++) {
            if (alpha[i] == 0) {
                cout << S << (char)(i + 'a') << endl;
                break;
            }
        }
    }
    else {
        string ans = "";
        for (int i = 25; i >= 1; i--) {
            if (S[i-1] < S[i]) {
                char tmp;
                for (int j = 25; j >= i; j--) {
                    if (S[i-1] < S[j]) {
                        tmp = S[j];
                        break;
                    }
                }
                ans = S.substr(0, i-1) + tmp;
                break;
            }
        }

        if (ans == "") cout << -1 << endl;
        else cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#1,1,1 -> (1,1) 1

#1,2,3 -> (1,3) 2

#1,1,3 -> (1,3) 1  <=> 1,1,3,3 -> (1,3) 1,3

#1,2,1,3,7 == [1:2, 2:1, 3:1, 7:1]
#[1:4, 2:3, 3:2, 5:1, 6:2, 8:2, 11:1]

#それぞれ1または2と等しい
#[1:2, 2:1, 3:2, 5:1, 6:2, 8:2, 11:1]
#[1,1,3,3,6,6,8,8]
#[1,1,3,6,6,8,8]
#[1,3,6,8]

N = int(input())
A = list(map(int, input().split()))
B = [-1 for i in range(100005)]

for i in range(N):
    if B[A[i]] == -1:
        B[A[i]] = 1
    elif B[A[i]] == 1:
        B[A[i]] = 2
    elif B[A[i]] == 2:
        B[A[i]] = 1

n = len(B) - B.count(-1)

if B.count(2) % 2 == 0:
    print(n)
else:
    print(n-1)


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

int main(){
  int n,x,t;cin >> n >> x >> t;
  if(n % x == 0)cout << (n / x) * t<< endl;
  else cout << (n / x + 1) * t<< endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;
using ll = long long;

#define rep(i,n) for(int i = 0;i < n;i++)

int main()
{
    string s;
    cin >> s;
    
    if (s[1] == 'B'){
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
bool exist[1000005];

int main(){
	int k;
	cin>>k;
	if(k%2==0) cout<<-1;
	else{
		int curr = 7%k;
		int sum = curr;
		int counter = 1;
		exist[sum] = true;
		while(sum%k){
			curr*=(10%k);
			curr%=k;
			sum+=curr;
			sum%=k;
			if(exist[sum]){
				cout<<-1;
				return 0;
			}
			exist[sum] = true;
			counter++;
		}
		cout<<counter;
	}
}

Measured memory_bytes: 4536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[1000];
int main()
{
	int n;
	cin>>n;
	int a[n],sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	if(sum%10!=0)
	{
		cout<<sum<<endl;
		return 0;
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		if((sum-a[i])%10!=0)
		{
			sum-=a[i];
			break;
		}
	}
	sum=sum%10==0?0:sum;
	cout<<sum<<endl;

}

Measured memory_bytes: 256
require 'prime'

n = 10 ** 5
near2017 = Array.new(n + 1,0)

1.upto(n) do |i|
    near2017[i] = near2017[i-1]
    near2017[i] += 1 if i.prime? && ((i+1)/2).prime?
end

q = gets.to_i
q.times do 
    l,r = gets.split.map(&:to_i)
    puts near2017[r] - near2017[l-1]
end

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

using namespace std;

mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l, long long r) {
    return (mt_rnd_64() % (r - l + 1)) + l;
}
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

#define rall(x) (x).rbegin(), (x).rend()

using ll = long long;
using ld = long double;
using ull = unsigned long long;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const ll INF = 1e9;

ld sqr(ld x) {
    return x * x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << setprecision(10) << fixed;
    vector<ld> fq(9);
    fq[1] = 1;
    fq[0] = 1;
    for (ll i = 2; i <= 8; ++i) {
        fq[i] = fq[i - 1] * i;
    }
    ll n;
    cin >> n;
    vector<pdd> pos(n);
    for (ll i = 0; i < n; ++i) {
        cin >> pos[i].f >> pos[i].s;
    }
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        a[i] = i;
    }
    ll cnt = 0;
    ld avg = 0;
    while (cnt < fq[n]) {
        ld curr = 0;
        for (ll i = 0; i < n - 1; ++i) {
            curr += sqrt(sqr(pos[a[i]].f - pos[a[(i + 1) % n]].f) + sqr(pos[a[i]].s - pos[a[(i + 1) % n]].s));
        }
        avg += curr / fq[n];
        ++cnt;
        next_permutation(all(a));
    }
    cout << avg << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    ll n, s;
    cin >> n >> s;
    if(n < s){
        cout << -1 << endl;
        return 0;
    }
    if(n == s){
        cout << n + 1 << endl;
        return 0;
    }

    for(int i = 2; (ll)i * i <= n; ++i){
        ll x = n;
        ll S = 0;
        while(x > 0){
            S += x % i;
            x /= i;
        }
        if(S == s){
            cout << i << endl;
            return 0;
        }
    }
    
    constexpr ll inf = 1e+15;
    ll ans = inf;
    for(int p = 1; (ll)p * p < n; ++p){
        ll r = s - p;
        if(r < 0)   continue;
        if(n - r < 0 || (n - r) % p != 0)   continue;
        ll b = (n - r) / p;
        ll S = 0;
        ll val = n;
        while(val > 0){
            S += val % b;
            val /= b;
        }
        if(S == s)  chmin(ans, b);
    }
    if(ans == inf)  ans = -1;
    cout << ans << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
  vector<bool> ans(1000000000, false);
  int N;
  cin >> N;
  FOR(i, 0, N) {
    int a = 0;
    cin >> a;
    if (ans[a]) {
      cout << "NO" << endl;
      return 0;
    }
    ans[a] = true;
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 122368
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            long a = Long.parseLong(strArr[0]);
            long b = Long.parseLong(strArr[1]);
            if (a <= 0) {
                if (b >= 0) {
                    System.out.println("Zero");
                } else {
                    long temp = b - a;
                    if (temp % 2 == 0) {
                        System.out.println("Negative");
                    } else {
                        System.out.println("Positive");
                    }
                }
            } else {
                System.out.println("Positive");
            }
       } catch (IOException e) {
            e.printStackTrace();
       }
    }
}


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

int main(){
  int num;
  cin >> num;
  int a[4];
  for (int i = 3; i >= 0; i--){
    a[i] = num % 10;
    num /= 10;
  }

  if (a[0] - a[1] - a[2] - a[3] == 7) printf("%d-%d-%d-%d=7\n", a[0], a[1], a[2], a[3]);
  else if (a[0] + a[1] - a[2] - a[3] == 7) printf("%d+%d-%d-%d=7\n", a[0], a[1], a[2], a[3]);
  else if (a[0] + a[1] + a[2] - a[3] == 7) printf("%d+%d+%d-%d=7\n", a[0], a[1], a[2], a[3]);
  else if (a[0] + a[1] + a[2] + a[3] == 7) printf("%d+%d+%d+%d=7\n", a[0], a[1], a[2], a[3]);
  else if (a[0] - a[1] + a[2] - a[3] == 7) printf("%d-%d+%d-%d=7\n", a[0], a[1], a[2], a[3]);
  else if (a[0] - a[1] + a[2] + a[3] == 7) printf("%d-%d+%d+%d=7\n", a[0], a[1], a[2], a[3]);
  else if (a[0] - a[1] - a[2] + a[3] == 7) printf("%d-%d-%d+%d=7\n", a[0], a[1], a[2], a[3]);
  else if (a[0] + a[1] - a[2] + a[3] == 7) printf("%d+%d-%d+%d=7\n", a[0], a[1], a[2], a[3]);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  string s;
  cin >> s;
  ll ans = 0;
  ll cnt = 1;
  s += "e";
  ll tmp = 0;
  rep(i,s.size()-1) {
    if (s[i] == s[i+1]) {
      ++cnt;
    }
    else {
      ans += cnt*(cnt+1)/2;
      if (s[i] == '>') {
        if (tmp < cnt) ans -= tmp;
        else ans -= cnt;
      }
      tmp = cnt;
      cnt = 1;
    }
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3912
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <set>

using namespace std;

int main(){
    string s;
    cin >> s;
    s.insert(s.find("7"), "8");
    s.erase(s.find("7"), 1);
    cout << s << endl;
}

Measured memory_bytes: 256
def solve():
    H,W,N= [int(x) for x in input().split()]
     
    Sr,Sc = [int(x) for x in input().split()]
     
    S = input()
    T = input()
     
    minu = Sr
    maxd = Sr
    maxr = Sc
    minl = Sc
    for i in range(N):
        if S[i] == 'U':
            minu -= 1
            if minu == 0:
                return "NO"
        if S[i] == 'D':
            maxd += 1
            if maxd == H+1:
                return "NO"
        if S[i] == 'R':
            maxr += 1
            if maxr == W+1:
                return "NO"
        if S[i] == 'L':
            minl -= 1
            if minl == 0:
                return "NO"
 
        if T[i] == 'D' and minu < H:
            minu += 1
        if T[i] == 'U' and maxd > 1:
            maxd -= 1
        if T[i] == 'L' and maxr > 1:
            maxr -= 1
        if T[i] == 'R' and minl < W:
            minl += 1
 
    return "YES"
 
print(solve())


Measured memory_bytes: 3888
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    b = input()
    res = {"A": "T", "T": "A", "C": "G", "G": "C"}

    print(res[b])

if __name__ == '__main__':
    main()


Measured memory_bytes: 80324
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
char a,b,c,d,e,f,o;
a=getchar();
b=getchar();
c=getchar();
o=getchar();
d=getchar();
e=getchar();
f=getchar();
if(a==f && b==e && c==d)
printf("YES");
else
printf("NO");
}

Measured memory_bytes: 128
import sys
import bisect
import math
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from operator import itemgetter

n,s=map(int,readline().split())
a=list(map(int,readline().split()))
mod=998244353
dp=[[0 for j in range(s+1)] for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(s+1):
        dp[i+1][j]+=2*dp[i][j]
        dp[i+1][j]%=mod
        if j+a[i]<=s:
            dp[i+1][j+a[i]]+=dp[i][j]
            dp[i+1][j+a[i]]%=mod
print(dp[n][s])

Measured memory_bytes: 153328
X, K, D = list(map(int, input().split()))

if D * K < abs(X):
  print(abs(X) - D * K)
elif D * K > abs(X):
  D *= 2
  if K % 2 == 0:
    print(min(abs(X) % D, abs((abs(X) % D) - D)))
  else:
    print(min((abs(X) + abs(D // 2)) % D, abs((abs(X) + abs(D // 2)) % D - D)))
else:
  print(0)

Measured memory_bytes: 9196
#include <stdio.h>
#include <stdlib.h>
 
typedef struct node{
  struct node *prev;
  int key;
  struct node *next;
} D;
 
D *head;
 
void insert(int v);
void delete(D *v);
void find(int v);
 
int main()
{
  int i,n,v;
  char cmd[16];
  D *temp;
   
  head=malloc(sizeof(D));
  head->key=-1;
  head->prev=head;
  head->next=head;
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",cmd);
    if(cmd[0]=='i'){
      scanf("%d",&v);
      insert(v);
    }
    else if(cmd[6]=='F') delete(head->next);
    else if(cmd[6]=='L') delete(head->prev);
    else{
      scanf("%d",&v);
      find(v);
    }
  }
 
  temp=head->next;
  while(temp->next->key!=-1){
    printf("%d ",temp->key);
    temp=temp->next;
  }
  if(temp->key!=-1) printf("%d\n",temp->key);
   
  return 0;
}
 
void insert(int v){
 
  D *temp;
   
  temp=malloc(sizeof(D));
  temp->key=v;
  temp->next=head->next;
  temp->prev=head;
 
  head->next=temp;
  temp->next->prev=temp;
}
 
void delete(D *v){
 
  v->prev->next=v->next;
  v->next->prev=v->prev;
   
  free(v);
}
 
void find(int v){
   
  D *temp;
  temp=head;
   
  while(temp->next->key!=-1){
    temp=temp->next;
    if(temp->key==v){
      delete(temp);
      break;
    }
  }
}

Measured memory_bytes: 31788
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<stack>
using namespace std;

struct Panel{
  string name;
  int x1,y1,x2,y2;
  Panel *parent;
  vector<Panel> child;

  void init(){name="";x1=y1=x2=y2=0;parent=NULL;child.clear();}
};

Panel list;
pair<string,int>ans;
int maxDepth;

void parse(string s)
{
  stringstream ss;
  for(int i=0;i<s.size();i++)if(s[i]==','||s[i]=='<'||s[i]=='>')s[i]=' ';
  ss.str(s);

  stack<string>st;

  Panel *now=&list;
  ss>>list.name>>list.x1>>list.y1>>list.x2>>list.y2;
  st.push(list.name);

  while(!st.empty()){
    Panel p={"",0,0,0,0,NULL};
    ss>>p.name;
    if(p.name[0]=='/'){
      st.pop();
      now=(*now).parent;
      continue;
    }
    st.push(p.name);
    p.parent=now;
    ss>>p.x1>>p.y1>>p.x2>>p.y2;
    (*now).child.push_back(p);
    now=&(*now).child[(*now).child.size()-1];
  }

}

void solve(Panel p, int x, int y, int depth)
{
  if(x<p.x1 || p.x2<x || y<p.y1 || p.y2<y)return;
  if(maxDepth<depth){
    maxDepth=depth;
    ans.first=p.name;
    ans.second=p.child.size();
  }
  vector<Panel>::iterator it;
  for(it=p.child.begin();it!=p.child.end();it++)solve(*it,x,y,depth+1);
}

int main()
{
  string s;
  int n,x,y;
  while(cin>>n,n){
    cin>>s;
    list.init();
    parse(s);
    for(int i=0;i<n;i++){
      cin>>x>>y;
      maxDepth=-1;
      solve(list,x,y,0);
      if(maxDepth==-1){
	ans.first="OUT OF MAIN PANEL";
	ans.second=1;
      }
      cout<<ans.first<<" "<<ans.second<<endl;
    }
  }
}

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

int main() {
  
  int a, b;
  cin >> a >> b;
  int c, d;
  cin >> c >> d;
  
  if ((c+b-1)/b>(a+d-1)/d) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3636
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let sss = Array.init h @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s
let _ =
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      let f (dy, dx) =
        let y, x = i + dy, j + dx in 0 <= y && y < h && 0 <= x && x < w && sss.(y).[x] = '#' in
      if sss.(i).[j] = '#' then
        if not @@ List.exists f [-1, 0; 0, -1; 1, 0; 0, 1] then (print_endline "No"; exit 0) done done;
  print_endline "Yes"

Measured memory_bytes: 640
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		int[] n = new int[5];
		Scanner sc = new Scanner(System.in);
		for(int i=0;i<n.length;i++){
			n[i] = sc.nextInt();
		}
		System.out.println(n[0]-(int)Math.max(Math.ceil((double)n[1]/n[3]),Math.ceil((double)n[2]/n[4])));
	}
}

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

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

  if( a<b&&b<c)
    printf("Yes\n");
  else if(a>b&&b>c)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
N,M = map(int,input().split())
MOD = 1000000007
 
a = set()

for m in range(M):
    aa = int(input())
    a.add(aa)

# print(a)



x = [0 for n in range(N+1)]
x[0] = 1
x[1] = 1 if 1 not in a else 0
for n in range(2,N+1):
    if n in a or (n-1 in a and n-2 in a):
        x[n] = 0
    elif n-1 in a:
        x[n] = x[n-2]%MOD
    elif n-2 in a:
        x[n] = x[n-1]%MOD
    else:
        x[n] = (x[n-1] + x[n-2])%MOD

# print(x)
print(x[N])

Measured memory_bytes: 11884
# ABC 067
def getIntList(): return [int(x) for x in input().split()]
def db(x): 
    global debug
    if debug: print(x)
debug = False
N,K = getIntList()
L = getIntList()
db((N,K))
db(L)
L.sort()
L.reverse()
db(L)
print(sum(L[:K]))

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
pii n[55];
int dfs(int N, int X) {
  dump(N, X, n[N].fi);
  if (X <= 0)
    return 0;
  if (N == 0) {
    return n[0].se;
  }

  int m = n[N - 1].fi + 2;
  dump(m, X);
  if (m > X) {
    return dfs(N - 1, X - 1);
  } else {
    return dfs(N - 1, X - m) + n[N - 1].se + 1;
  }
}
signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  int X;
  cin >> X;
  /*
  vector<string> b;
  b.eb("P");
  rep(i, 1, N + 1) {
    b.eb("B" + b.back() + "P" + b.back() + "B");
    dump(i, b.back().size(), b.back());
  }
  */

  n[0] = pii(1, 1);
  rep(i, 1, N + 1) { n[i] = pii(n[i - 1].fi * 2 + 3, n[i - 1].se * 2 + 1); }
  dump(n);
  cout << dfs(N, X) << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
a = [int(input()) for _ in range(n)]

s = deque([a[0]])

from bisect import bisect_left

for i in a[1:]:
    if i <= s[0]:
        s.appendleft(i)
    else:
        s[bisect_left(s, i) - 1] = i

# print(s)
print(len(s))


Measured memory_bytes: 47196
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))



struct unifo{
	int n;
	int uni[100005];
	void init(int in){
		n=in;
		rep(i,n)uni[i]=i;
	}
	int find(int p){
		if(uni[p]==p)return p;
		else return (uni[p]=find(uni[p]));
	}
	void mer(int p,int q){
		if(!same(p,q))uni[find(p)]=find(q);
	}
	bool same(int p,int q){
		return find(p)==find(q);
	}
} uni;


typedef pair<lli,lli> mp;
typedef pair<lli,int> lmp;
mp dat[100005];

lli rn[100005]={};
int main(void){
	int n,sa,sb;
	lli d;
	scanf("%d%d%d",&n,&sa,&sb); sa--; sb--;
	uni.init(n+3);
	rep(i,n){
		lli x,y;
		scanf("%lld%lld",&x,&y);
		//printf("%lld %lld\n",y+x,y-x);
		dat[i]=mp(y+x,y-x);
	}
	d = max(abs(dat[sa].fir-dat[sb].fir),abs(dat[sa].sec-dat[sb].sec));
	//printf("d .. %lld\n",d);
	rep(t,2){
		map<lli, vector<lmp> > mas;
		rep(i,n){
			mp pa=dat[i];
			if(mas.find(pa.fir) == mas.end())mas[pa.fir] = vector<lmp>();
			mas[pa.fir].push_back(lmp(pa.sec,i));
		}

		iter(mas,ite){
			sort((ite->sec).begin(),(ite->sec).end());
		}
		
		iter(mas,ite){
			lli y=ite->fir;
			if(mas.find(y+d) == mas.end())continue;
			//printf("%lld -> %lld\n",y,y+d);
			vector<lmp> vs,tvs;
			vs = ite->sec;
			tvs = mas[y+d];
			
			rep(k,2){
				queue<lmp> que;
				int tp=0;
				rep(i,vs.size()){
					lmp pa=vs[i];
					lli p=pa.fir;
					int idx=pa.sec;
					
					while(tp<tvs.size()){
						if(tvs[tp].fir<p+d || 
							(t==0 && tvs[tp].fir==p+d)){
							
							if(!(tvs[tp].fir<p-d || 
								(t==1 && tvs[tp].fir==p-d))){
							
								//printf("p %lld add %lld\n",p,tvs[tp].fir);
								uni.mer(idx,tvs[tp].sec);
								que.push(tvs[tp]);
							}
							tp++;
						}
						else break;
					}
					
					while(que.size()>0){
						if(que.front().fir<p-d || 
							(t==1 && que.front().fir==p-d)){
							
							//printf("p %lld remove %lld\n",p,que.front().fir);
							que.pop();
						}
						else break;
					}
					
					if(que.size()>0){
						uni.mer(idx,que.front().sec);
					}
					//printf("idx %d add %u\n",idx,que.size());
					rn[idx] += (lli)(que.size());
				}
				swap(vs,tvs);
			}
		}
				
		rep(i,n){
			mp pa=dat[i];
			dat[i]=mp(pa.sec,pa.fir);
		}
	}
	
	lli ans=0;
	rep(i,n){
		if(uni.same(sa,i)){
			//printf("%d %lld\n",i,rn[i]);
			ans += rn[i];
		}
	}
	printf("%lld\n",ans/2);
	
	return 0;
}






Measured memory_bytes: 14276
n, m = gets.split.map(&:to_i)
a = Array.new(n, 1)
b = Array.new(n, false)
b[0] = true

m.times do |_i|
  x, y = gets.split.map(&:to_i)
  a[x - 1] -= 1
  a[y - 1] += 1
  b[y - 1] = true if b[x - 1]
  b[x - 1] = false if a[x - 1].zero?
end
puts b.count{_1 == true}


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

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

    cin >> A >> B >> C >> D;

    while (true) {
        C -= B;
        if ( C <= 0 ) break;
        A -= D;   
        if ( A <= 0 ) break; 
    }

    cout << ( A > 0 ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	char str[100];
	int ac = 0, wa = 0, tle = 0, re = 0;
		
	int i;
	for (i = 1; i <= n; i++)
	{
		scanf("%s", str);
		if (str[0] == 'A' && str[1] == 'C')
		{
			ac++;
		}
		
		else if (str[0] == 'W' && str[1] == 'A')
		{
			wa++;
		}
		
		else if (str[0] == 'T' && str[1] == 'L' && str[2] == 'E')
		{
			tle++;
		}
		
		else if (str[0] == 'R' && str[1] == 'E')
		{
			re++;
		}
	}
	
	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);
	
	return 0;
}

Measured memory_bytes: 1720