akhauriyash/Code-Regression huggingface dataset:
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func divisor(n int) []int {
	res := []int{}
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	return res
}

func primeFactors(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2]++
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i]++
			n = n / i
		}
	}
	if n > 2 {
		pfs[n]++
	}

	return pfs
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()

	fmt.Fprintln(wtr, len(primeFactors(N)), len(divisor(N))-1)
	wtr.Flush()
}



Measured memory_bytes: 1156
def CountingSort(A, B, k):
    C = [ 0 for i in range(0, k+1)]
    for j in range(0, len(A)):
        C[A[j]] = C[A[j]] + 1
    for i in range(1, k+1):
        C[i] = C[i] + C[i-1]
    for j in range(n-1, -1, -1):
        B[C[A[j]]-1] = A[j]
        C[A[j]] = C[A[j]] - 1
        
n = int(input())
A = list(map(int, input().split()))

B = [0 for i in range(n)]
k = max(A)
CountingSort(A, B, k)

print(*B)


Measured memory_bytes: 224388
#include<stdio.h>
int main(void){
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '?'){
			break;
		}
		else if(op == '+'){
			printf("%d\n",a+b);
		}
		else if(op == '-'){
			printf("%d\n",a-b);
		}
		else if(op == '*'){
			printf("%d\n",a*b);
		}
		else if(op == '/'){
			printf("%d\n",a/b);
		}
	}
	return 0;
}

Measured memory_bytes: 600
import heapq
n, m = [int(i) for i in input().split()]
d = [[] for i in range(m+1)]
for i in range(n):
    a, b = [int(_) for _ in input().split()]
    if a <= m:
        d[a].append(b)
ans = 0
cand = []
for i in range(1, m+1):
    for dd in d[i]:
        heapq.heappush(cand, -dd)
    if len(cand) > 0:
        ans += -heapq.heappop(cand)
print(ans)


Measured memory_bytes: 18468
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int dp[114514][3];
signed main(){
	int n;
	cin>>n;
	vector<int> a,b,c;
	for(int i=0;i<n;i++){
		int x,y,z;
		cin>>x>>y>>z;
		a.pb(x);b.pb(y);c.pb(z);
	}
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i=1;i<n;i++){
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][2],dp[i-1][0]) + b[i];
		dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

set<string> st;

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

	ll N;
	cin >> N;

	vector<ll> v;
	// for(ll i = 0; i * (i - 1) <= N; i++){
	for(ll i = 0; i <= 10000; i++){
		v.push_back(i * (i + 1) / 2);
	}

	while(N > 0){
		auto itr = lower_bound(v.begin(), v.end(), N);
		ll k = distance(v.begin(), itr);
		cout << k << endl;
		N -= k;
	}
}


Measured memory_bytes: 512
# ABC088 C - Takahashi's Information
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
l = [nl() for i in range(3)]
a1=0
b1=l[0][0]-a1
b2=l[0][1]-a1
b3=l[0][2]-a1
a2=l[1][0]-b1
a3=l[2][0]-b1
a = [a1,a2,a3]
b = [b1,b2,b3]

for i,aa in enumerate(a):
    for j,bb in enumerate(b):
        if l[i][j]!=aa+bb:
            print('No')
            exit()
print('Yes')



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 1e3 + 10,Lim = 5e3 + 10;

bitset <Lim> A,B;
int to[N << 1],nex[N << 1],beg[N];
int Min[N],val[N];
int e;

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline void add(int x,int y) {
	to[++e] = y,nex[e] = beg[x],beg[x] = e;
}

inline void Dp(int x,int fa) {
	for(int i = beg[x];i;i = nex[i]) {
		if(to[i] == fa) continue;
		Dp(to[i],x);
	}
	A.reset(),A[0] = true;
	int sum = 0,tot = 0;
	for(int i = beg[x];i;i = nex[i]) {
		if(to[i] == fa) continue;
		int Minv = min(Min[to[i]],val[to[i]]);
		int Maxv = max(Min[to[i]],val[to[i]]);
		A |= (A << (Maxv - Minv)),sum += Minv,tot += Minv + Maxv;
	}
	Fordown(i,val[x] - sum,0) if(A[i]) {
		Min[x] = tot - i - sum;break;
	}
	if(Min[x] == INF) puts("IMPOSSIBLE"),exit(0);
}

int main() {
	int n = read();
	For(i,2,n) {
		int f = read();
		add(f,i);
	}
	For(i,1,n) val[i] = read();
	memset(Min,63,sizeof(Min));
	Dp(1,0);
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a)
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
int main() {
    int n;
    cin >> n;
    while(n>1){
        if(n%10==7){
            cout << "Yes" << endl;
            return 0;
        }else{
            n/=10;
        }
    }
    cout << "No" << endl;
	return 0;
}

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

int main(){
    long long int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    long long int ans = 0;
    if(a + b <= 2 * c) ans = a * x + b * y;
    if(a + b >  2 * c){
        ans = 2 * c * min(x, y)
            + min(a, 2 * c) * (x - min(x,y))
            + min(b, 2 * c) * (y - min(x,y));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <cstdio>
//#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include <string>//"reverse(s's it,s's it)"
//#include <functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include <cmath>//"abs" "sqrt"
//#include <numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include <algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

int main(){
	ll n;
	cin>>n;
	for(ll a=1;a<=3500;++a) for(ll b=1;b<=3500;++b){
		ll d=4*a*b-(a+b)*n;
		if(d>0&&(a*b*n)%d==0){
			cout<<a<<" "<<b<<" "<<(a*b*n)/d<<endl;
			return 0;
		}
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  char x, y; cin >> x >> y;
  if(x < y) cout << "<" << endl;
  else if(x > y) cout << ">" << endl;
  else cout << "=" << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int n, m;
struct edge{
    int u, v;
    ll cost;
    edge() = default;
    edge(int u, int v, ll cost) : u(u), v(v), cost(cost) {}
};
vector<edge> es;
vector<ll> dist(1005, 1e+17);

void bellman_fold(){
    dist[0] = 0;
    for(int i = 0; i < n; ++i){
        bool update = false;
        for(int i = 0; i < m; ++i){
            int u = es[i].u, v = es[i].v;
            ll cost = es[i].cost;
            if(dist[u] != 1e+17 && (dist[v] > dist[u] + cost)){
                dist[v] = dist[u] + cost;
                update = true;
            }
        }
        if(!update) break;
    }
    return;
}

bool link_negative_loop(){
    vector<bool> update(n, false);
    for(int loop = 0; loop < n; ++loop){
        for(int i = 0; i < m; ++i){
            int u = es[i].u, v = es[i].v;
            if(dist[u] == 1e+17)  continue;
            ll cost = es[i].cost;
            if(dist[v] > dist[u] + cost){
                dist[v] = dist[u] + cost;
                update[v] = true;
            }
            if(update[u]){
                update[v] = true;
            }
        }
    }
    return update[n - 1];
}

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

    cin >> n >> m;
    es.resize(m);
    for(int i = 0; i < m; ++i){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        --a, --b;
        es[i] = edge(a, b, -c);
    }

    bellman_fold();
    ll res = -dist[n-1];
    if(link_negative_loop()){
        cout << "inf\n";
        return 0;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
/* Dsingh_24 */
 
#include<bits/stdc++.h>
#define ll          int
#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
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
#define N  100005
int lis(int arr[], int n)
{
	// create an empty ordered set S. ith element in S is defined as the
	// smallest integer that ends an increasing sequence of length i
	multiset<int> S;

	// process every element one by one
	for (int i = 0; i < n; i++)
	{
		// insert current element into the set
		auto ret = S.insert(arr[i]);

		// get iterator to inserted element's
		multiset<int>::iterator it;
		it=S.upper_bound(arr[i]);

		// if element is not inserted at the end, then delete next
		// greater element from set
		if (it != S.end())
			S.erase(it);
	}

	// length of LIS is number of elements in the set	
	return S.size();
}
int main()
{
	ios
	ll n,i,j;
	cin>>n;
	ll a[n+1];
	for(i=0;i<n;i++)
		cin>>a[i];
	reverse(a,a+n);
	ll ans=lis(a,n);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(void)
{
	int a,b,c,z;

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

	if(a>b)
	{
		z = a;
		a = b;
		b = z;
	}
	if(b>c)
	{
		z = b;
		b = c;
		c = z;
	}
	if(a>b)
	{
		z = a;
		a = b;
		b = z;
	}
	printf("%d %d %d\n",a,b,c);
		

	return 0;
}

Measured memory_bytes: 596
n = int(input())
p = list(map(int, input().split()))

ans = 0

for i in range(n-2):
    #比較する3つのｐの値
    buf = p[i:i+3]
    #真ん中の数値
    buf1 = buf[1]
    
    buf.sort()
    if buf[1] == buf1:
        ans += 1
    #print(buf)

print(ans)

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

using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
using namespace std;

int main(){
  ll K; cin>>K;
  vi A(K); REP(i,K) cin>>A[i];
  vpii v(K);
  if(A[K-1]!=2){
    cout<<-1<<endl;
    return 0;
  }
  v[K-1]=make_pair(2,3);
  for(ll i=K-2;i>=0;i--){
    ll a=v[i+1].first,b=v[i+1].second,c=A[i];
    ll d,e;
    if(a%c==0) d=a;
    else d=a-a%c+c;
    e=b-b%c;
    if(d>e){
      cout<<-1<<endl;
      return 0;
    }
    v[i]=make_pair(d,e+c-1);
  }
  
  cout<<v[0].first<<' '<<v[0].second<<endl;
}


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
ll N;
ll A[300000];
const ll MOD = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    ll ans = 0;
    for(int i = 0; i <= 60; i++){
        ll m = (ll)1<<i;
        ll cnt = 0;
        for(int j = 0; j < N; j++){
            if(m&A[j]) cnt++;
        }
        // cout << cnt << endl;
        ans += (((cnt*(N-cnt))%MOD)*(m%MOD))%MOD;
       // cout << m << ' ' <<  cnt << endl;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

//for (auto& e : array)

signed main()
{
    int M, N, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));

    REP(i, N)
    {
        cin >> C[i];
        REP(j, M)
        {
            
            cin >> A[i][j];
        }
    }

    int price = INT32_MAX;

    for (int bit = 0; bit < (1 << N); ++bit)
    {
        vector<int> S;
        for (int i = 0; i < N; ++i)
        {
            if (bit & (1 << i))
            { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        int counter2 = 0;
        int price2 = 0;
        vector<int> R(M, 0);

        for (int i = 0; i < (int)S.size(); ++i)
        {
            int hon = S[i];
            REP(j, M)
            {
                R[j] = R[j] + A[hon][j];
            }
            price2 += C[hon];
        }
        REP(j, M)
        {
            if (R[j] < X)
                break;
            if (j == M-1 && price > price2)
                price = price2;
        }

        
    }
    if(price == INT32_MAX)
        price = -1;
    cout << price <<  endl;
}


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


int main(){
  int n; string s;
  cin>>n>>s;
  map<int, int> mp;
  vector<int> c1(10,0);
  vector<int> c2(100,0);
  ll ans=0;
  for(int i=0;i<n;i++){
    int a = s[i]-'0';
    if(c1[a]>0) continue;
    c1[a]=1;
    for(int j=i+1;j<n;j++){
      int b= s[j]-'0';
      if(c2[a*10+b]>0) continue;
      c2[a*10+b]=1;
      for(int k=j+1;k<n;k++){
        int c=s[k]-'0';
        int x = a*100+b*10+c;
        mp[x]++;
        if(mp[x]==1) ans++;
      }
    }
  }


  cout << ans << endl;

  return 0;
}


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

//#define DEBUG


int main(void)
{
    FILE *fpin;
#ifdef DEBUG
    fpin=fopen("input.txt","r");
#else
    fpin=stdin;
#endif

    while(feof(fpin)==0){
        char buf[256];
        int data[10];
        fscanf(fpin,"%s\n",buf);
        int i;
        for(i=0;i<10;i++){ data[i]=buf[i]-'0'; }

        int n,j;
        for(n=10;n!=0;n--){ //n is num of data 
            int data_tmp[10];
            for(j=0;j<n-1;j++){
                data_tmp[j]=(data[j]+data[j+1])%10;
            }
            memcpy((int*)data,(int*)data_tmp,sizeof(int)*10);
        }

        printf("%d\n",data[0]);
    }

    return 0;
}

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

int main()
{
    char S[11],T[12];
    int i,j;

    scanf("%s %s",&S,&T);

    for(i=0;i<strlen(S);i++){

    if(S[i]!=T[i]){

          printf("No\n");
          return 0;


        }
    }

           printf("Yes\n");


    return 0;
}


Measured memory_bytes: 1644
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		long A = sc.nextLong();
		long B = sc.nextLong();
		A -= 1;
		long b = B;
		long ans = 0;
		int d = 0;
		while(b > 0) {
			long bnum = B % (2l << d) - (1l << d) + 1; 
			if(bnum < 0) bnum = 0;
			bnum += B / (2l << d) * (1l << d);
			long anum = A % (2l << d) - (1l << d) + 1;
			if(anum < 0) anum = 0;
			anum += A / (2l << d) * (1l << d);
			long num = bnum - anum;
			//System.out.println(bnum + ":" + anum);
			if(num % 2 != 0) {
				ans += 1l << d ;
				//System.out.println(ans + " : " + d + " " +  b);
			}
			d++;
			b /= 2;
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

int n, m, ans;

void dfs(int cur, vi visit, const vector<vi> &edge)
{
  visit[cur] = 1;

  bool end = true;
  rep(i, n) if (visit[i] == 0) end = false;

  if (end) {
    ++ans;
    return;
  }

  for (auto next : edge[cur]) {
    if (visit[next]) continue;
    dfs(next,visit,edge);
  }
}

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  cin >> n >> m;
  vi visit(n,0);
  vector<vi> edge(n);

  rep(i, m) {
    int a, b; cin >> a >> b;
    edge[a-1].emplace_back(b-1);
    edge[b-1].emplace_back(a-1);
  }

  dfs(0,visit,edge);
  cout << ans << endl;
  
  return (0);
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

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

const int INF = 1 << 24;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

typedef unsigned long long ull;

int main(){
    int a[5];

    REP(i, 5){
        std::cin >> a[i];
    }

    int sum = 0;
    REP(i, 5){
        if(a[i] < 40){
            a[i] = 40;
        }
        sum += a[i];
    }

    std::cout << sum / 5 << std::endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;

// ModInt構造体
template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y%mod : (mod - (-y)%mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)((long long)1 * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a/b;
            a -= t*b;
            swap(a, b);
            u -= t*v;
            swap(u, v);
        }
        return ModInt(a);
    }

    ModInt pow(int e) const {
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) { p = (p*p) % mod; e /= 2; }
            else { a = (a*p) % mod; e--; }
        }
        return ModInt(a);
    }
};

// modの割り算との積を求めるときに必要
long long modinv(long long a, long long m) {
    // a %= mod; a * modinv(b, mod) % mod;
    long long b = m, u = 1, v = 0;
    while(b) {
        long long t = a/b;
        a -= t*b; swap(a, b);
        u -= t*v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;
}

int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    long long asum = 1;
    long long atsum = 1;
    long long bsum = 1;
    long long btsum = 1;
    int j = n;
    for(int i = 1; i <= a; ++i) {
        asum *= i;
        asum %= mod;
        atsum *= j;
        atsum %= mod;
        j--;
    }

    int k = n;
    for(int i = 1; i <= b; ++i) {
        bsum *= i;
        bsum %= mod;
        btsum *= k;
        btsum %= mod;
        k--;
    }

    long long aans = atsum * modinv(asum, mod) % mod;
    long long bans = btsum * modinv(bsum, mod) % mod;

    long long abans = (aans+bans) % mod;

    ModInt<mod> ln;
    ln.x = 2;
    long long lnp = ln.pow(n).x - 1;

    long long ans = lnp - abans;

    if(ans < 0) {
        cout << ans + mod << endl;
    }else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1069"

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
/*
  multiprecision:
  #include <boost/multiprecision/cpp_int.hpp>
  using Int = boost::multiprecision::cpp_int;
*/
#endif
//BEGIN CUT HERE
__int128_t abs128(__int128_t val){return val<0?-val:val;}

ostream &operator<<(ostream &os,__int128_t val){
  if(ostream::sentry(os)){
    __uint128_t tmp=abs128(val);
    char buf[64];
    char *d=end(buf);
    do{
      --d;
      *d=char(tmp%10+'0');
      tmp/=10;
    }while(tmp);
    if(val<0) *--d='-';
    int len=end(buf)-d;
    if(os.rdbuf()->sputn(d,len)!=len){
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}

istream &operator>>(istream &is,__int128_t &val){
  string s;
  is>>s;
  val=0;
  for(int i=0;i<(int)s.size();i++)
    if(isdigit(s[i])) val=val*10+s[i]-'0';
  if(s[0]=='-') val*=-1;
  return is;
}
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
signed main(){
  return 0;
}
#endif

#undef call_from_test

using ll = __int128_t;

ll sqrt(ll x){
  assert(x>=0);
  if(x<=1) return x;
  ll l=0,r=x;
  while(l+1<r){
    ll m=(l+r)>>1;
    if(m<=x/m&&m*m<=x) l=m;
    else r=m;
  }
  return l;
}

signed main(){
  int n;
  while(cin>>n,n){
    int m=n*(n+1)/2;

    vector<ll> bs(m),es,os;
    for(int i=0;i<m;i++) cin>>bs[i];
    for(ll b:bs)
      ((b&1)?os:es).emplace_back(b);

    sort(es.begin(),es.end());
    sort(os.begin(),os.end());

    ll a=sqrt(es[0]*es[1]/os[0]);
    cout<<a<<endl;
    for(int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<es[i]/a;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 4560
#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>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vi a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(all(b));
  sort(all(c));
  vl bc(n + 1);
  rep(i, n) {
    int num = upper_bound(all(c), b[i]) - c.begin();
    bc[i] = n - num;
  }
  for(int i = n - 2; i >= 0; i--) bc[i] += bc[i + 1];
  bc[n] = 0;
  ll ans = 0;
  rep(i, n) {
    int j = upper_bound(all(b), a[i]) - b.begin();
    ans += bc[j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int main() {
    int n, q;
    cin >> n >> q;
    char now, next;
    vector<int> ac_cnt(n, 0);
    cin >> now;
    for (int i = 0; i < n - 1; i++) {
        cin >> next;
        if (now == 'A' and next == 'C') {
            if (i == 0)
                ac_cnt[i + 1] = 1;
            else
                ac_cnt[i + 1] = ac_cnt[i] + 1;
        } else {
            ac_cnt[i + 1] = ac_cnt[i];
        }
        now = next;
    }
    int l, r;
    for (int i = 0; i < q; i++) {
        cin >> l >> r;
        l--, r--;
        cout << ac_cnt[r] - ac_cnt[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 3756
#include <stdio.h>

int main()
{
  int K, S;
  int X, Y, Z;
  int i, j, k;
  int ans = 0;

  scanf("%d %d", &K, &S);

  for(i = 0; i <= K; i++) {
    for(j = 0; j <= K; j++) {
      if(S-i-j <= K && S-i-j >= 0) {
	ans++;
      }
    }
  }

  printf("%d\n", ans);
  
  return 0;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    bool flag = true;
    rep(i, n){
        int a;
        cin >> a;
        flag &= a % 2 == 0;
    }
    if(flag){
        cout << "second" << endl;
    }else{
        cout << "first" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),d=nxt();
    cout<<(n+2*d)/(2*d+1)<<endl;
    
    
    return 0;   
}


 
 


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

int main() {
  short A[3][3];
  rep(i,3) {
    rep(j,3) {
      cin >> A[i][j];
    }
  }
  short N;
  cin >> N;
  short b[N];
  rep(i,N) {
    cin >> b[i];
  }
  
  bool opened[3][3] = {{false}};
  rep(i,3) {
    rep(j,3) {
      rep(k,N) {
        if(A[i][j] == b[k]) opened[i][j] = true;
      }
    }
  }
  
  rep(i,3) {
    if (opened[i][0] && opened[i][1] && opened[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
    if (opened[0][i] && opened[1][i] && opened[2][i]) {
      cout << "Yes" << endl;
      return 0;
    }
    if (opened[0][0] && opened[1][1] && opened[2][2]) {
      cout << "Yes" << endl;
      return 0;
    }
    if (opened[2][0] && opened[1][1] && opened[0][2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main(){
  int B, R;
  cin >> B;
  std::map<std::string, int> mp;
  for(int i = 0; i < B; i++){
    string v;
    cin >> v;
    auto itr = mp.find(v); 
    if( itr != mp.end() ) {
        mp[v] += 1;
    } else {
        mp[v] = 1;
    }
  }
  
  cin >> R;
  for(int i = 0; i < R; i++){
    string v;
    cin >> v;
    auto itr = mp.find(v); 
    if( itr != mp.end() ) {
        mp[v] -= 1;
    }
  }
  
  int maxV = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    maxV = max(maxV, itr->second);
  }
  cout << maxV << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    _LL n, d;
    cin >> n >> d;
    _LL dd = d * d;
    int ans = 0;
    rep(i, n)
    {
        _LL x, y;
        cin >> x >> y;
        if( x * x + y * y <= dd ) ans++;
    }
    cout << ans;
    return 0;    
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        int Q = reader.nextInt();
        String S = reader.next();
        int[] cnt = new int[N];
        // init
        for (int i=1; i<N; i++) {
            cnt[i] = cnt[i-1];
            if (S.charAt(i) == 'C' && S.charAt(i-1) == 'A') {
                cnt[i]++;
            }
        }

        for (int i=0; i<Q; i++) {
            int l = reader.nextInt()-1;
            int r = reader.nextInt()-1;
            System.out.println(cnt[r]-cnt[l]);
        }
    }
    
    public static void solver() {
        // write logic
    }
    
    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 51020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int dxx[8] = { 1, 1, 1, 0, 0, -1, -1, -1 }, dyy[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main() {
    int n;
    cin >> n;
    int cnta = 0, cntb = 0, cntab = 0, ans = 0;
    string s[n];
    rep (i, n) {
        cin >> s[i];
        rep (j, s[i].size() - 1) {
            if (s[i][j] == 'A' && s[i][j + 1] == 'B') ans++;
        }
        if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') cntab++;
        else if (s[i][0] == 'B')
            cntb++;
        else if (s[i][s[i].size() - 1] == 'A')
            cnta++;
    }
    if (cntab == 0) {
        ans += min (cnta, cntb);
    } else {
        if (cnta == 0 && cntb == 0) ans += cntab - 1;
        else
            ans += min (cnta, cntb) + cntab;
    }
    cout << ans << "\n";
}


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

using namespace std;

int main()
{
    int a, b, c, d; cin >> a >> b >> c >> d;
    if (min(b, d) - max(a, c) < 0)
    cout << 0 << endl;
    else cout << min(b, d) - max(a, c) << endl;

  return 0;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var r = new List<int>();
        r.Add(a);   r.Add(b); r.Add(a + b);
        foreach(var x in r)
            if (x % 3 == 0) { Console.WriteLine("Possible"); goto end; }
        Console.WriteLine("Impossible");
        end:;
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007


void solve()
{
  int N;
  cin>>N;
  vector<int> vec(N+1,0);
  vector<int> outvec(N+1,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i+1];
  }

  for (int i = N; i >= 1; i--)
  {
    int L = 2;
    int counting = 0;
    while(N - L*i >= 0)
    {
      if(vec[L*i] == 1)counting++;
      L++;
    }
    
    if(counting%2 == vec[i])
    {
      vec[i] = 0;
    }
    else
    {
      vec[i] = 1;
    }
  
    
    
  }
  
    int num = 0;
    for (int i = 1; i < N+1; i++)
    {
      if(vec[i] == 1)num++;
    }

    cout<<num<<endl;

    for (int i = 1; i < N+1; i++)
    {
      if(vec[i]==1)
      cout<<i<<endl;
    }
  
  return;  
}

int32_t main(int32_t argc, const char *argv[])
{
  // std::ios::sync_with_stdio(false);
  // std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>
#define N 100000

typedef int key;

void marge(key data[], key work[], int start, int mid, int end){
    int i = start;
    int j = mid + 1;
    int k = start;
    while(i <= mid && j <= end){
        if(data[i] <= data[j]){
            work[k++] = data[i++];
        }else{
            work[k++] = data[j++];
        }
    }
    
    if(i <= mid){
        while(i <= mid){
            work[k++] = data[i++];
        }
    }else{
        while(j <= end){
            work[k++] = data[j++];
        }
    }
    
    for(k = start; k <= end; k++){
        data[k] = work[k];
    }
}

void margesort(key data[], key work[], int start, int end){
    int mid;
    if(start < end){
        mid = start + (end - start)/2;
        margesort(data, work, start, mid);
        margesort(data, work, mid + 1, end);

        marge(data, work, start, mid, end);
    }
}

int main(void){
    int n;
    int d[N],work[N];
    int i;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &d[i]);
    }
    
    margesort(d, work, 0, n-1);
    
    printf("%d", d[n / 2] - d[n / 2 - 1]);
    
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=2e5+6;
const int INF=1e9+5e8;

template <typename T,typename E>
struct SegmentTree{
	using F = function<T(T,T)>;
	using G = function<T(T,E)>;
	using H = function<E(E,E)>;
	int n,height;
	F f;
	G g;
	H h;
	T ti;
	E ei;
	vector<T> dat;
	vector<E> laz;
	  SegmentTree(F f,G g,H h,T ti,E ei):
	    f(f),g(g),h(h),ti(ti),ei(ei){}
  
	void init(int n_){
		n=1;height=0;
		while(n<n_) n<<=1,height++;
		dat.assign(2*n,ti);
		laz.assign(2*n,ei);
	}
	void build(const vector<T> &v){
		int n_=v.size();
		init(n_);
		for(int i=0;i<n_;i++) dat[n+i]=v[i];
		for(int i=n-1;i;i--)dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
	}
	inline T reflect(int k){
		return laz[k]==ei?dat[k]:g(dat[k],laz[k]);
	}
	inline void eval(int k){
		if(laz[k]==ei) return;
		laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
		laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
		dat[k]=reflect(k);
		laz[k]=ei;
	}
	inline void thrust(int k){
		for(int i=height;i;i--) eval(k>>i);
	}
	inline void recalc(int k){    
		while(k>>=1)dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1));
	}
	void update(int a,int b,E x){
		thrust(a+=n);
		thrust(b+=n-1);
		for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
			if(l&1) laz[l]=h(laz[l],x),l++;
			if(r&1) --r,laz[r]=h(laz[r],x);
		}
		recalc(a);
		recalc(b);
	}
	void set_val(int a,T x){
		thrust(a+=n);
		dat[a]=x;laz[a]=ei;
		recalc(a);
	}
	T query(int a,int b){
		thrust(a+=n);
		thrust(b+=n-1);
		T vl=ti,vr=ti;
		for(int l=a,r=b+1;l<r;l>>=1,r>>=1) {
			if(l&1) vl=f(vl,reflect(l++));
			if(r&1) vr=f(reflect(--r),vr);
		}
		return f(vl,vr);
	}
};



int main(){
	int N,Q;
	cin>>N>>Q;
	int S[MAX],T[MAX],X[MAX];
	rep(i,N)cin>>S[i]>>T[i]>>X[i];
	vi v(Q,0);
	rep(i,Q)cin>>v[i];
	
	
	auto f=[](int a,int b){return min(a,b);};
	SegmentTree<int,int> seg(f,f,f,INF,INF);
	seg.init(Q);
	
	rep(i,N){
		int x=lower_bound(v.begin(),v.end(),S[i]-X[i])-v.begin();
		int y=lower_bound(v.begin(),v.end(),T[i]-X[i])-v.begin();
		seg.update(x,y,X[i]);
	}
	rep(i,Q){
		int k=seg.query(i,i+1);
		if(k==INF)cout<<-1<<endl;
		else cout<<k<<endl;
	}
}

Measured memory_bytes: 9088
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <iomanip>
#include <set>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,n) for(int i=1,i##_len=(n);i<=i##_len;++i)
#define rrep(i,n) for(int i=((int)((n)-1));i>=0;--i)
#define rreps(i,n) for(int i=((int)(n));i>0;--i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end());

// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#define DUMPOUT cout
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef LOCAL_
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif

typedef long long int lli;
typedef pair<int, int> ii;
typedef priority_queue<int, vector<int>, greater<int> > heapq;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
// #define int long long int
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main() {
    int A, B, C; cin >> A >> B >> C;
    cout << max(C - (A - B), 0) << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int N, K; cin >> N >> K;
    K++;
    vec A(N); readv(A);

    mat dp(61, vec(2, -INF));
    dp[60][0] = 0;
    IREP(i, 60){
        int n1 = 0;
        REP(j, N) if((A[j] >> i) & 1) n1++;
        if((K >> i) & 1){
            if(dp[i + 1][0] > -INF) Max(dp[i][0], dp[i + 1][0] + ((N - n1) << i));
            if(dp[i + 1][1] > -INF) Max(dp[i][1], dp[i + 1][1] + (max(n1, N - n1) << i));
            if(dp[i + 1][0] > -INF) Max(dp[i][1], dp[i + 1][0] + (n1 << i));
        }else{
            if(dp[i + 1][0] > -INF) Max(dp[i][0], dp[i + 1][0] + (n1 << i));
            if(dp[i + 1][1] > -INF) Max(dp[i][1], dp[i + 1][1] + (max(n1, N - n1) << i));
        }
    }
    cout << dp[0][1] << endl;

    return 0;
}


Measured memory_bytes: 1024
/* Author : Alokit Kumar */
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int t,n,i,j,k,x;
  for(i=1;i<=5;i++)
  {
    cin>>k;
    if(k==0)
     x=i;
  }
  cout<<x;
}

Measured memory_bytes: 3560