akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
bool g[110][110];
int d[110];
int f[110];
int current;

void dfs1(int s)
{
	if (d[s] != -1) return;

	stack<int> stk;
	d[s] = ++current;
	stk.push(s);
	while (!stk.empty()) {
		int u = stk.top();
		int flag = 0;
		for (int j = 1; j <= n; j++) {
			if (g[u][j] && d[j] == -1) {
				flag = 1;
				stk.push(j);
				d[j] = ++current;
				break;
			}
		}

		if (flag == 0) {
			f[u] = ++current;
			stk.pop();
		}

	}
}

void dfs()
{
	for (int i = 1; i <= n; i++)
		dfs1(i);

}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		int u, k, v;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			g[u][v] = true;
		}
	}

	for (int i = 1; i <= n; i++) {
		d[i] = -1;
		f[i] = -1;
	}

	dfs();

	for (int i = 1; i <= n; i++) {
		cout << i << " " << d[i] << " " << f[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

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

	int N,K; cin >> N >> K;

	cout << (N-1) * (K-1) << endl;
	return 0;
}


Measured memory_bytes: 256
N,Q = map(int, input().split())
s = '_'+input()+'_'
td = [input().split() for _ in range(Q)]
right = N+1
left = 0
for t,d in reversed(td):
    if t == s[right-1] and d =='R':
        right -= 1
    elif t == s[right] and d == 'L':
        right += 1
    if t == s[left+1] and d == 'L':
        left += 1
    elif t == s[left] and d == 'R':
        left -= 1
print(max(0,right-left-1))


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

int main(int argc, char const *argv[])
{
    long h, w, k;
    cin >> h >> w >> k;
    string s;
    vector<int> table = vector<int>(h);

    for (int i = 0; i < h; i++)
    {
        cin >> s;
        for (int j = 0; j < s.size(); j++)
        {
            if (s[j] == '#')
            {
                table.at(i) |= 1;
            }
            table.at(i) <<= 1;
        }
        table.at(i) >>= 1;
    }
    // int aaa;
    // cout << table.at(0) << endl;
    vector<int> tmp_table = vector<int>(h, 0);
    long ans = 0;
    for (int i = 0; i < (1 << (w + 1)); i++)
    {
        for (int k = 0; k < h; k++)
        {
            tmp_table.at(k) = table.at(k) & i;
        }
        for (int j = 0; j < (1 << (h + 1)); j++)
        {
            int tmp = 0;
            for (int a = 0; a < h; a++)
            {
                if (!((1 << a) & j))
                {
                    for (int b = 0; b < w; b++)
                    {
                        if (tmp_table.at(a) & (1 << b))
                        {
                            tmp++;
                        };
                    }
                }
            }
            if (tmp == k)
            {
                ans++;
            }
        }
    }
    cout << ans / 4 << endl;

    return 0;
}


Measured memory_bytes: 3592
N = int( input() )
A = list( map( int, input().split() ) )
s = 0
f = 0
for i in range( N ):
  s += A[ i ]
  x = s
  if i & 1: # -> -1
    if x < 0: continue
    s -= x - ( -1 )
    f += x - ( -1 )
  else:
    if x > 0: continue
    s += 1 - x
    f += 1 - x
s = 0
g = 0
for i in range( N ):
  s += A[ i ]
  x = s
  if ~i & 1: # -> -1
    if x < 0: continue
    s -= x - ( -1 )
    g += x - ( -1 )
  else:
    if x > 0: continue
    s += 1 - x
    g += 1 - x
print( min( f, g ) )


Measured memory_bytes: 64112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n,m;
    map<string,int> mm;
    cin>>n;
    for(int i = 0; i < n; ++i) {
        string str; cin>>str;
        ++mm[str];
    }
    cin>>m;
    for(int i = 0; i < m; ++i) {
        string str; cin>>str;
        --mm[str];
    }

    vector<pair<int,string> > v;
    for(map<string,int>::iterator it = mm.begin(), end = mm.end(); it != end; ++it) { // it->first, it->second
        v.push_back(pair<int,string>(it->second, it->first));
    }
    sort(v.begin(), v.end(), greater<pair<int,string> >());

    cout << max(0, v[0].first) << endl;
    return 0;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#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(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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; }


int main(void){
  ios::sync_with_stdio(false);

  int ans;
  int A, B;
  cin >> A >> B;
  if (A < 10 and B < 10){
    ans = A * B;
  }

  else ans = -1;

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 256
import collections

num = int(input().rstrip())
line = input().rstrip().split()
line = [int(x) for x in line]

count_dict = collections.Counter(line)

last = 10**9 + 7

num_list = []

ans = 1

if num % 2 == 0:
    for k, v in count_dict.items():
        if v != 2:
            ans = 0

else:
    for k, v in count_dict.items():
        if v != 2 and k != 0:
            ans = 0

if ans == 0:
    print(0)
else:
    print(2**(num // 2) % last)


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n, m;
    cin >> n >> m;
    vvint g(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].pb(b);
        g[b].pb(a);
    }

    vint path;
    rep(i, n)
    {
        path.pb(i);
    }

    int ans = 0;
    do
    {
        if (path[0] != 0)
            break;
        int tmp = 1;
        rep(i, path.size() - 1)
        {
            int from = path[i];
            int to = path[i + 1];
            int cnt = 0;
            for (auto x : g[from])
            {
                if (x == to)
                    ++cnt;
            }
            tmp *= cnt;
        }
        ans += tmp;
    } while (next_permutation(ALL(path)));
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;
const int mod=1e9+7;
long n,m;
long long gt(long a){
    long long s=1;
    for(long i=2;i<=a;i++)s=(s*i)%mod;
    return s%mod;
}
int main()
{
    cin>>n>>m;
    if(n<m-1 || m<n-1)return cout<<0,0;
    if(n==m)cout<<2*gt(n)*gt(m)%mod;
    else cout<<gt(n)*gt(m)%mod;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int N,M;
vector<int> G[100000];

bool dfs(int n, int from, int A, int B){
  bool ext = false;
  for(int i=0;i<G[n].size();i++){
    if(G[n][i] == B) return false;
    if(G[n][i]!=from && G[n][i] == A) return true;
    if(G[n][i]!=from){
      if(dfs(G[n][i],n,A,B)) ext = true;
    }
  }
  return ext;
}

int main(){
  cin >> N >> M;
  int d[N] = {};
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    d[a]++;
    d[b]++;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  //オイラーグラフかどうか
  for(int i=0;i<N;i++){
    if(d[i] < 2 || d[i]%2!=0){
      cout << "No" << endl;
      return 0;
    }
  }

  //次数6以上の点が存在するか
  //次数4の点の個数を数えておく
  int num = 0;
  for(int i=0;i<N;i++){
    if(d[i] == 4) num++;
    if(d[i] >= 6){
      cout << "Yes" << endl;
      return 0;
    }
  }

  if(num >= 3){
    cout << "Yes" << endl;
    return 0;
  }

  if(num == 2){
    vector<int> v4; //次数４の点
    for(int i=0;i<N;i++){
      if(d[i] == 4) v4.push_back(i);
    }

    int A = v4[0];
    int B = v4[1];

    //AからBを通らずにAに行くパスが存在するか
    if(dfs(A,-1,A,B)){
      cout << "Yes" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  else cout << "No" << endl;
  return 0;
}


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

int main(){

    vector<int> S, H, D, C;

    for(int i=1; i<14; i++){
        S.push_back(i);
        H.push_back(i);
        D.push_back(i);
        C.push_back(i);
    }

    int n;
    cin >> n;

    char ch;
    int x;

    for(int i=0; i<n; i++){

        cin >> ch >> x;
        switch(ch){
            case 'S': {S[x-1] = 0; break;}
            case 'H': {H[x-1] = 0; break;}
            case 'D': {D[x-1] = 0; break;}
            case 'C': {C[x-1] = 0; break;}
        }
    }

    for(int i=0; i<13; i++){
        if(S[i]!=0){
            cout << "S " << S[i] << endl; 
        }
    }
    for(int i=0; i<13; i++){
        if(H[i]!=0){
            cout << "H " << H[i] << endl; 
        }
    }
    for(int i=0; i<13; i++){
        if(C[i]!=0){
            cout << "C " << C[i] << endl; 
        }
    }
    for(int i=0; i<13; i++){
        if(D[i]!=0){
            cout << "D " << D[i] << endl; 
        }
    }

    return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int A, B, C;

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

    int ans = 0;

    if(A >= B && B >= C){
        ans += A - B;
        C += ans;
        if((A-C) % 2 == 0){
            ans += (A-C) / 2;
        }else{
            ans += (A-C) / 2 + 2;
        }
    }else if(A >= C && C >= B){
        ans += A - C;
        B += ans;
        if((A-B) % 2 == 0){
            ans += (A-B) / 2;
        }else{
            ans += (A-B) / 2 + 2;
        }
    }else if(B >= A && A >= C){
        ans += B - A;
        C += ans;
        if((B-C) % 2 == 0){
            ans += (B-C) / 2;
        }else{
            ans += (B-C) / 2 + 2;
        }
    }else if(B >= C && C >= A){
        ans += B - C;
        A += ans;
        if((B-A) % 2 == 0){
            ans += (B-A) / 2;
        }else{
            ans += (B-A) / 2 + 2;
        }
    }else if(C >= A && A >= B){
        ans += C - A;
        B += ans;
        if((C-B) % 2 == 0){
            ans += (C-B) / 2;
        }else{
            ans += (C-B) / 2 + 2;
        }
    }else{
        ans += C - B;
        A += ans;
        if((C-A) % 2 == 0){
            ans += (C-A) / 2;
        }else{
            ans += (C-A) / 2 + 2;
        }
    }

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

    return 0;
}

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

N=int(input())
AB=[list(map(int,input().split())) for i in range(N)]

SUM=[[sum(AB[i])]+[i] for i in range(N)]

SUM.sort(key=lambda x:x[0],reverse=True)

T=[]
A=[]

for j in range(N):
    s,i=SUM[j]

    if j%2==0:
        T.append(i)
    else:
        A.append(i)

ANS=0
for t in T:
    ANS+=AB[t][0]
for a in A:
    ANS-=AB[a][1]

print(ANS)

Measured memory_bytes: 44124
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

struct UnionFind(T)
{
	void init(T n) { par = new T[](n); foreach (i; 0..n) par[i] = i; cnt = new T[](n); fill(cnt, 1); }
	T root(T i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(T i, T j) { return root(i) == root(j); }
	void unite(T i, T j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; cnt[j] += cnt[i]; }
	T size(T i) { return cnt[root(i)]; }
	T[] par, cnt;
}

void main()
{
	auto N = RD;
	auto M = RD;
	UnionFind!long uf;
	uf.init(N);
	foreach (i; 0..M)
	{
		auto A = RD-1;
		auto B = RD-1;
		uf.unite(A, B);
	}

	bool[long] set;
	foreach (i; 0..N)
	{
		auto r = uf.root(i);
		set[r] = true;
	}
	long ans = set.keys.length - 1;

	writeln(ans);
	stdout.flush;
	debug readln;
}


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

int main() {
  int s;
  cin>>s;
  int d[1000010];
  d[0]=s;
  rep(i,1000000){
  if(d[i]%2==0)d[i+1]=d[i]/2;
   else{ d[i+1]=d[i]*3+1;}            
  }
  
  bool ok=false;
  for(int i=1;i<1000000;i++){
   for(int j=i-1;j>=0;j--){
     if(d[i]==d[j]){
       cout<<i+1<<endl;
       ok=true;
       break;
     }
    if(ok)break;
   }
  } 
    
         
}


Measured memory_bytes: 4096
def solve():
    hm = {}
    steps = k
    curr = 0
    loopsize = 0
    pre = 0
    while not str(curr) in hm and steps > 0:
        hm[str(curr)] = pre
        pre+=1
        curr = a[curr] - 1
        steps -= 1
        loopsize += 1
    if str(curr) in hm:
        loopsize -= hm[str(curr)]
    steps %= loopsize
    while steps > 0:
        curr = a[curr] - 1
        steps -= 1
    print(curr + 1)
    return



n, k = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
solve()


Measured memory_bytes: 123544
#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, t;
  cin >> n >> t;
  vector<int> a(n), b(n);
  rep(i, n)
    cin >> a[i] >> b[i];
  vector<vector<int>> dp1(n, vector<int>(t, 0));
  vector<vector<int>> dp2(n, vector<int>(t, 0));
  rep(i, n - 1)
    for (int j = 1; j < t; j++)
    {
      dp1[i+1][j] = max(dp1[i][j], dp1[i+1][j-1]);
      if (j >= a[i])
        dp1[i+1][j] = max(dp1[i+1][j], dp1[i][j-a[i]] + b[i]);
    }
  for (int i = n - 1; i > 0; i--)
    for (int j = 1; j < t; j++)
    {
      dp2[i-1][j] = max(dp2[i][j], dp2[i-1][j-1]);
      if (j >= a[i])
        dp2[i-1][j] = max(dp2[i-1][j], dp2[i][j-a[i]] + b[i]);
    }
  int ans = 0;
  rep(i, n)
    rep(j, t)
      ans = max(ans, b[i] + dp1[i][j] + dp2[i][t-j-1]);
  cout << ans << endl;
  return 0;
}

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

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

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=4e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int N,K;
    cin >> N >> K;

    vector<i64> x(N),y(N),xs,ys;
    rep(i,0,N){
        cin >> x[i] >> y[i];
        xs.push_back(x[i]);
        ys.push_back(y[i]);
    }

    sort(begin(xs),end(xs));
    sort(begin(ys),end(ys));

    auto count_points=[&](i64 x1,i64 y1,i64 x2,i64 y2){
        int res=0;
        rep(i,0,N) if(x1<=x[i] and x[i]<=x2 and y1<=y[i] and y[i]<=y2) ++res;
        return res;
    };

    i64 ans=inf64;
    rep(i,0,N) rep(j,i+1,N) rep(k,0,N){
        int lb=k-1,ub=N;
        while(ub-lb>1){
            int mid=(lb+ub)/2;
            if(count_points(xs[i],ys[k],xs[j],ys[mid])>=K) ub=mid;
            else lb=mid;
        }
        if(ub<N) ans=min(ans,(xs[j]-xs[i])*(ys[ub]-ys[k]));
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

class BinaryIndexedTree:
    def __init__(self, As):
        self.numPow2 = 2 ** (len(As)-1).bit_length()
        self.data = [0] * (self.numPow2+1)
        for iA, A in enumerate(As):
            self.addValue(iA, A)

    def addValue(self, iA, A):
        iA += 1
        while iA <= self.numPow2:
            self.data[iA] += A
            iA += iA & -iA

    def getSum(self, iA):
        iA += 1
        ans = 0
        while iA > 0:
            ans += self.data[iA]
            iA -= iA & -iA
        return ans


N, K = map(int, input().split())
As = [int(input()) for _ in range(N)]

Bs = list(accumulate([0]+[A-K for A in As]))
iBs = list(range(N+1))
iBs.sort(key=lambda iB: Bs[iB])

BIT = BinaryIndexedTree([0]*(N+1))

ans = 0
for iB in iBs:
    BIT.addValue(iB, 1)
    ans += BIT.getSum(iB-1)

print(ans)


Measured memory_bytes: 85540
package main

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

var scanner *bufio.Scanner

func printIt() {
	for {
		numStr := nextString()
		if numStr == "0" {
			break
		}
		ans := 0
		for _, ch := range []byte(numStr) {
			ans += int(ch - '0')
		}
		fmt.Println(ans)
	}
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif
const int maxr=2e5+2;
ll BIT[maxr];
struct node{
	ll x,y;
};
void update(ll ind,ll val){
	for(;ind<maxr;ind+=(ind&(-ind))){
		BIT[ind]+=val;
	}
}
ll query(ll ind){
	ll ans=0;
	for(;ind>0;ind-=(ind&(-ind))){
		ans+=BIT[ind];
	}
	return ans;
}
bool cmp(node a,node b){
	return a.x<b.x;
}
//
int main()
{
	GO
	//fioe();
	ll n,d,a;
	cin>>n>>d>>a;
	node arr[n+2];
	for(ll i=0;i<n;i++){
		cin>>arr[i].x>>arr[i].y;
	}
	sort(arr,arr+n,cmp);
	mll m;
	ll referance[n+2];
	for(ll i=0;i<n;i++){
		m[arr[i].x]=i+1;
		referance[i]=arr[i].x;
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		if((arr[i].y-query(m[arr[i].x]))<=0){
			continue;
		}
		ll count=ceil(((arr[i].y-query(m[arr[i].x]))/(a*1.0)));
		update(m[arr[i].x],a*count);
		ll ind=lower_bound(referance,referance+n,arr[i].x+2*d)-referance;
		if(ind>=n){
			ind--;
		}
		else if(arr[ind].x>arr[i].x+2*d){
			ind--;
		}
		update(m[arr[ind].x]+1,-(a*count));
		ans+=count;
	}
	cout<<ans<<endl;
	time();
	return 0;
}

Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  rep(i, n) a[i] = -a[i];

  vector<int> v;
  rep(i, n) {
    int it = ub(v, a[i]);
    if (it == sz(v)) v.push_back(a[i]);
    else v[it] = a[i];
  }
  cout << sz(v) << endl;
}


Measured memory_bytes: 1276
#include <iostream>

using namespace std;

int main() {
	int N, S;
	cin >>S >> N;
	if (S >= 13) {
		cout << N << endl;
	}
	else if (S >= 6) {
		cout << N / 2 << endl;
	}
	else {
		cout << "0" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
'use strict'
function main(inp) {
  inp = inp.trim()*1;
  let num = inp%10;
  let ans;
  if(num == 3){
    ans = "bon"
  }else if(num == 0 || num == 1 || num == 6 || num == 8){
    ans = "pon"
  }else {
    ans = "hon"
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main() {
  int n;
  cin >> n;
  
  vector<int> d(n);
  for(int i=0; i<n; i++){
    cin >> d[i];
  }
  
  sort(d.begin(), d.end());
  
  int daburi = 0;
  for(int i=0; i<n-1; i++){
    if(d[i]==d[i+1]){
      daburi++;
    }
  }
  
  cout << n - daburi << endl;
}

Measured memory_bytes: 256
n=int(input())
s1=input()
s2=input()
MOD=10**9+7
flag=0
i=0
ans=1
while i<n:
  if s1[i]==s2[i]:
    if flag==0:
      ans=3
    if flag==1:
      ans=ans*2%MOD
    flag=1
    i+=1
  else:
    if flag==0:
      ans=6
    if flag==1:
      ans=ans*2%MOD
    if flag==-1:
      ans=ans*3%MOD
    flag=-1
    i+=2
print(ans)

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

int main(){
  int max=0,begin=0;
  string s;
  cin >> s;
  
  while(s.at(begin) != 'A'){
    begin++;
  }
  int end = s.size()-1;
  while(s.at(end) != 'Z'){
    end--;
  }
  max = end-begin+1;
  cout << max << endl;
  return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0;i < 3;i++){
    if(s.at(i) == t.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long LL;
const LL MODD = 1e9 + 7;

struct Matrix {
	LL el[55][55];
	LL size;
	Matrix operator * (Matrix other) {
		Matrix ans; ans.size = size;
		for (LL i = 0; i < size; i++) {
			for (LL j = 0; j < size; j++) {
				ans.el[i][j] = 0;
for (LL k = 0; k < size; k++) {
					ans.el[i][j] += (el[i][k] * other.el[k][j]) % MODD;
					if (ans.el[i][j] > MODD) ans.el[i][j] %= MODD;
				}
			}
		}

		return ans;
	}
};

Matrix mat;
LL N, K;
Matrix pkt(Matrix A, LL n) {
	if (n == 1LL) {
		return A;
	} else if (n & 1LL) {
		return A * pkt(A, n - 1);
	}

	Matrix tmp = pkt(A, n/2);
	return tmp * tmp;
}
int main() {
	cin >> N >> K;
	mat.size = N;
	for (LL i = 0; i < N; i++) {
		for (LL j = 0; j < N; j++) {
			cin >> mat.el[i][j];
		}
	}

	mat = pkt(mat, K);
	LL ans = 0;
	for (LL i = 0; i < N; i++) {
		for (LL j = 0; j < N; j++) {
			// cout << mat.el[i][j] << " " ;
			ans += mat.el[i][j];
			ans %= MODD;
		}
		// cout << endl;
	}

	assert(ans > -1LL);

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


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

int C[35][35];
int main() {
    int H, W, K; cin >> H >> W >> K;
    for(int i=0; i<H; ++i){
        string S;
        cin >> S;
        for(int j=0; j<W; ++j){
            C[i][j]=(S[j]-'0');
        }
    }
    int ans=0;
    for(int i=0; i<H*W; ++i){
        int ban[35][35], now=0, mul=1;
        for(int p=0; p<35; ++p) for(int q=0; q<35; ++q) ban[p][q]=C[p][q];
        ban[i/W][i%W]=0;
        bool flag=true;
        while(flag){
            int sum=0;
            for(int j=0; j<W; ++j){
                int cnt=H-1;
                for(int k=H-1; k>=0; --k){
                    if(ban[k][j]>0){
                        ban[cnt][j]=ban[k][j];
                        if(cnt!=k) ban[k][j]=0;
                        --cnt;
                    }
                }
            }
            flag=false;
            for(int j=0; j<H; ++j){
                for(int k=0; k<W; ++k){
                    if(ban[j][k]>0){
                        int ser=k;
                        while(ban[j][ser]==ban[j][k]) ++ser;
                        if(ser-k>=K){
                            sum += ban[j][k]*(ser-k);
                            flag=true;
                            for(int v=k; v<ser; ++v) ban[j][v]=0;
                        }
                    }
                }
            }
            now += sum*mul;
            mul *= 2;
        }
        ans=max(ans, now);
    }
    cout << ans << endl;
	return 0;
}


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

int main(){
	int N;
	cin >> N;
	int t[N+1],x[N+1],y[N+1];
	t[0]=0;
	x[0]=0;
	y[0]=0;
	
	for(int i=1;i<=N;i++)cin>>t[i]>>x[i]>>y[i];
	bool isNo=false;
	
	for(int i=0;i<N;i++){
		int value = abs(t[i+1]-t[i])-abs(x[i+1]-x[i])-abs(y[i+1]-y[i]);
		if(value%2==1)isNo =true;
		if(value < 0)isNo=true;
	}
	
	if(isNo==true)cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
#include<math.h>
using namespace std;

int main() {
	int a, b, ans;
	cin >> a >> b;
	ans = (a + b);
	if (ans % 2 == 0)
	{
		cout << ans / 2 << endl;
	}
	else {
		cout << (ans+1) / 2  << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int q;
    long long t;
    cin >> q;
    long long a[q], b[q];
    for(int i=0;i<q;i++){
        cin >> a[i] >> b[i];    
    }
    for(int i=0;i<q;i++){
        t = sqrt(a[i]*b[i]);
        if(a[i]==b[i]){
            cout << 2 * (a[i] -1) << endl;
        }else if(t*t == a[i]*b[i]){
            cout << 2*t-3 << endl;
        }else if(t* (t+1) >= a[i]*b[i]){
            cout << 2*t-2 << endl;
        }else{
            cout << 2*t-1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=3000+10;
const int mod=1e9+7;
void add(int& x,int y) { x+=y; if (x>=mod) x-=mod; }

int n,m; char str[N];
struct node { int l,r; } p[N];
bool operator <(node a,node b) { return a.l<b.l||(a.l==b.l&&a.r>b.r); }
int C[N][N],sum[N],dp[N][N];

int main() {
	n=read(),m=read(); scanf("%s",str+1);
	for (int i=1;i<=m;++i) p[i].l=read(),p[i].r=read();
	sort(p+1,p+m+1); int top=0;
	for (int i=1,x=0;i<=m;++i)
		if (p[i].r>x) p[++top]=p[i],x=p[i].r;
	m=top,p[m+1].l=n+1;
	for (int i=1;i<=n;++i) sum[i]=sum[i-1]+str[i]-'0';
	dp[p[1].l-1][sum[p[1].l-1]]=1;
	for (int i=C[0][0]=1;i<=n;++i)
		for (int j=C[i][0]=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	for (int i=1;i<=m;++i) {
		int l=p[i].l,r=p[i].r,nxt=p[i+1].l;
		for (int j=0;j<l;++j) {
//			if (!dp[l-1][j]) continue;
			int s=sum[r]-j;
			if (nxt>r) 
				add(dp[nxt-1][sum[nxt-1]],1ll*dp[l-1][j]*C[r-l+1][s]%mod);
			else {
				int x=max(0,s-(r-nxt+1)),y=min(s,nxt-l);
				for (int k=x;k<=y;++k)
					add(dp[nxt-1][j+k],1ll*dp[l-1][j]*C[nxt-l][k]%mod);
			}
		}
	}
	printf("%d\n",dp[n][sum[n]]);
	return 0;
}

Measured memory_bytes: 36412
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	int n;
	cin >> n;
	int ans = 0;
	int var = 0;
	if (n % 2 == 1)
	{
		cout << 0 << en;
	}
	else
	{
		ans = 0;
		int x = log2(n) / log2(5);
		n /= 2;
		while (n)
		{
			ans += n / 5;
			n = n / 5;
		}
		cout << ans << en;
		// rep(i, 1, x)
		// {
		// 	var = pow(10, i);
		// 	ans +=  (n / var);
		// }
		// cout << ans << en;
		//cout << x << en;
	}



	return 0;
}



Measured memory_bytes: 3780
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt();
            var r = line[0];
            var D = line[1];
            var x = new int[11];
            x[0] = line[2];
            for (int i = 0; i < 10; i++)
            {
                x[i + 1] = r * x[i] - D;
            }

            return MultiLine(x.Skip(1));
        }

        public const int mod = 1000000007;
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc()); static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

    #region Console
    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int() => int.Parse(String()); public long Long() => long.Parse(String()); public ulong ULong() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt() => String().Split().Select(int.Parse).ToArray(); public long[] SplitLong() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitULong() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt(int count) { for (int i = 0; i < count; i++) yield return Int(); } public IEnumerable<long> RepeatLong(int count) { for (int i = 0; i < count; i++) yield return Long(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt(int count) { for (int i = 0; i < count; i++) yield return SplitInt(); } }
    #endregion
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int a,b;
    cin>> a>>b;
    if(((a>b) && b!=1) || (a<b && a==1)) cout<<"Alice";
    else if(((b>a)&& a!=1) ||(b<a && b==1)) cout<<"Bob";
    else cout<<"Draw";
    return 0;
}



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

using namespace std;

int main(void){
  int n;
  int k;
  while(cin >> n >> k){
    if((n|k) == 0) break;

    int d[n][n];

    fill((int *)d, (int *)d+n*n, 65535);
    for(int i=0;i<n;i++) d[i][i] = 0;
    for(int i=0;i<k;i++){
      int p,q;
      cin >> p >> q;
      d[p-1][q-1] = 1;
      d[q-1][p-1] = 1;
    }

    //WF
    for(int r=0;r<n;r++)
      for(int p=0;p<n;p++)
	for(int q=0;q<n;q++){
	  d[p][q] = min(d[p][q], d[p][r]+d[r][q]);
	}
    int ret = 0;
    for(int i=1;i<n;i++){
      if(d[0][i] < 3) ret++;
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		int a = scan.nextInt();
		
		if(x < a) System.out.println(0);
		else if(a < x) System.out.println(10);
		else {
			System.out.println(10);
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#create date: 2020-08-22 21:03

import sys
stdin = sys.stdin

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

def main():
    n = ni()
    a = na()
    m = 0
    ans = 0
    for ai in a:
        ans += max(0, m - ai)
        m = max(m, ai)
        #print(m, ans)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 105256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

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;
}

ll gcd(const ll sx, const ll sy) {
    ll x = min(sx, sy);
    ll y = max(sx, sy);
    ll tmp;
    while (x > 0) {
        tmp = y;
        y = x;
        x = tmp % x;
    }
    return y;
}

vector<ll> as;

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    ll ans = as[0];
    for (int i = 1; i < N; i++) {
        ans = gcd(ans, as[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;


int main() {
  ll n,h; cin >> n >> h;
  ll max_a = 0;
  vector<ll> b(n);
  rep(i,n) {
    ll tmp_a,tmp_b;
    cin >> tmp_a >> tmp_b;
    b.push_back(tmp_b);
    max_a = max(max_a,tmp_a);
  }

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

  ll ans_count = 0;
  ll current_pos = 0;

  while(h > 0) {
    ans_count++;
    if(b[current_pos] <= max_a) {
      h -= max_a;
      continue;
    }
    h -= b[current_pos];
    current_pos++;
  }

  cout << ans_count << endl;
}


Measured memory_bytes: 4812
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long a[100], p[100];
long long f(int n, long long x){
    if(!n){
        if(x <= 0) return 0;
        else return 1;
    }
    if(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]);
}

int main(){
    int n; long long x; cin >> n >> x;
    for(int i = 0; i < n; i++){
        if(!i) a[0] = p[0] = 1;
        else{
            a[i] = 2 * a[i-1] + 3;
            p[i] = 2 * p[i-1] + 1;
        }
    }
    cout << f(n, x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> p;
typedef long long ll;
int main() {
  int r, d, x;
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i++) {
    cout << r * x - d << endl;
    x = r * x - d;
  }
  return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){
	
	string n;cin >> n;
	if(n[0] == '7')cout << "Yes" << endl;
	else if(n[1] == '7')cout << "Yes" << endl;
	else if(n[2] == '7')cout << "Yes" << endl;
	else cout << "No" << endl;
	

	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://atcoder.jp/contests/abc162/tasks/abc162_a


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

#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace boost::multiprecision;

using ci = cpp_int;
using cd = number<cpp_dec_float<10000>>;

int main() {
  cd a, b, c;
  cin >> a >> b >> c;
  cout << ((sqrt(a) + sqrt(b) < sqrt(c)) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 5116
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cctype>
#include<cstring>
using namespace std;
struct rec
{
	int x1,x2,y1,y2;
}s1,s2,s3;
#define MAXN 2000010
#define MOD 1000000007
int fac[MAXN],inv[MAXN];
int power(int a,int b)
{
	int res = 1;
	while(b > 0)
	{
		if(b & 1)res = 1ll * res * a % MOD;
		a = 1ll * a * a % MOD;
		b = b >> 1;
	}
	return res;
}
int comb(int n,int m)
{
	return 1ll * fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
int C(int x1,int y1,int x2,int y2)
{
	if(x1 > x2)swap(x1,x2);if(y1 > y2)swap(y1,y2);
	return comb(y2 - y1 + x2 - x1,y2 - y1);
}
int calc(int x,int y,rec s)
{//cout << x << " " << y << " " << s.x1 << " " << s.x2 << " " << s.y1 << " " << s.y2 << " : ";
	if(x >= s.x1 && x >= s.x2 && y >= s.y1 && y >= s.y2)
	{
		s.x1 *= -1;s.y1 *= -1;s.x2 *= -1;s.y2 *= -1;
		swap(s.x1,s.x2);swap(s.y1,s.y2);
		x *= -1;y *= -1;
	}//cout << C(x,y,s.x2 + 1,s.y2 + 1) - C(x,y,s.x2 + 1,s.y1) - C(x,y,s.x1,s.y2 + 1) + C(x,y,s.x1,s.y1) << endl;
	int ans = 0;
	ans = (ans + C(x,y,s.x2 + 1,s.y2 + 1)) % MOD;
	ans = (ans - C(x,y,s.x2 + 1,s.y1) + MOD) % MOD;
	ans = (ans - C(x,y,s.x1,s.y2 + 1) + MOD) % MOD;
	ans = (ans + C(x,y,s.x1,s.y1)) % MOD;
	return ans;
}
int main()
{
	fac[0] = 1;for(int i = 1;i < MAXN;++i)fac[i] = 1ll * fac[i - 1] * i % MOD;
	inv[MAXN - 1] = power(fac[MAXN - 1],MOD - 2);
	for(int i = MAXN - 2;i >= 0;--i)inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
	scanf("%d%d%d%d%d%d",&s1.x1,&s1.x2,&s2.x1,&s2.x2,&s3.x1,&s3.x2);
	scanf("%d%d%d%d%d%d",&s1.y1,&s1.y2,&s2.y1,&s2.y2,&s3.y1,&s3.y2);
	int ans = 0;
	for(int i = s2.x1;i <= s2.x2;++i)
	{
		ans = (ans - 1ll * calc(i,s2.y1 - 1,s1) * calc(i,s2.y1,s3) % MOD * (i + s2.y1) % MOD + MOD) % MOD;
		ans = (ans + 1ll * calc(i,s2.y2,s1) * calc(i,s2.y2 + 1,s3) % MOD * (i + s2.y2 + 1) % MOD) % MOD;
		//cout << calc(i,s2.y2,s1) << " " << calc(i,s2.y2 + 1,s3) << " " << (i + s2.y2 + 1) << endl;
		//cout << " : " << ans << endl;
	}//cout << ans << endl;
	for(int i = s2.y1;i <= s2.y2;++i)
	{
		ans = (ans - 1ll * calc(s2.x1 - 1,i,s1) * calc(s2.x1,i,s3) % MOD * (s2.x1 + i) % MOD + MOD) % MOD;
		ans = (ans + 1ll * calc(s2.x2,i,s1) * calc(s2.x2 + 1,i,s3) % MOD * (s2.x2 + i + 1) % MOD) % MOD;
		//cout << " : " << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
/*

Sviatoslav Bidzilia 2019
CF: anakib1

*/

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long

template<typename A, typename B, typename C>
struct triple
{
	A X;
	B Y;
	C Z;
	triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0)
{
	return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b)
{
	if (a.X != b.X)
		return a.X < b.X;
	if (a.Y != b.Y)
		return a.Y < b.Y;
	return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p)
{
	ofs << "( " << p.F << " , " << p.S << " )";
	return ofs;
}
template<typename T>
void print(T a)
{
	for (auto i : a)
		cout << i << ' ';
	cout << '\n';
}
template<typename T>
T max(T a, T b, T c)
{
	return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c)
{
	return min(a, min(b, c));
}
struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	srand(time(NULL));
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	int s = 0;
	rng(b)
	{
		int x;
		cin >> x;
		s += x;
	}
	cout << (s >= a ? "Yes" : "No") << '\n'; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=2e5+10;
int a[maxn],b[maxn];
main(){
    int n;
    cin>>n;
    ios::sync_with_stdio(false);
    cin.tie(0);
    int ans=0;
    for(int i=1;i<=n;++i){
        ans+=i*(n/i)*(1+n/i)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3612