akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

#define M 1008001
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}


long long getKey(char str[]){
  long long i, s = 0, p = 1;
  for ( i = 0; i < strlen(str); i++ ){
    s += p*(getChar(str[i]));
    p *= 5;
  }
  return s;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
  int i, j;
  int key;

  i = 0;
  key = getKey(str);

  while(1){
    j = (h1(key) + i*h2(key)) % M;

    if(strcmp(H[j], str)==0)
      return 1;

    else if(H[j][0]=='\0' || i>=M){
      return 0;
    }

    else
      i++;
  }
}

int insert(char str[]){
  int i, j;
  int key;

  i = 0;
  key = getKey(str);

  while(1){
    j = (h1(key) + i*h2(key)) % M;

    if(H[j][0]=='\0'){
      strcpy(H[j],str);
      return j;
    }

    else
      i++;
  }
}

int main(){
    int i, n;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
        insert(str);
    } else {
        if (find(str)){
        printf("yes\n");
        } else {
        printf("no\n");
        }
    }
    }

    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A.at(i);
  }
  
  for (int i = 0; i < n; i++) {
    int a = A.at(0);
    for (int j = 1; j < n; j++) {
     int b = A.at(j);
      if (a < b) {
        A.at(j) = a;
        A.at(j - 1) = b;
      }
      else {
        a = b;
      }
    }
  }
  
  int sub = 0;
  for (int i = 0; i < n; i++) {
    int a = A.at(i);
    if (i % 2 == 0) {
      sub += a;
    }
    if (i % 2 == 1) {
      sub -= a;
    }
  }
  
  cout << sub << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long t = sc.nextLong();
        long[] ti = new long[n];
        for(int i = 0;i < n;i++) ti[i] = sc.nextLong();
        
        long sum = t;
        long r = t;
        for(int i = 1;i < n;i++) {
            long l = ti[i];
            if(l < r) {
                sum += t - r + ti[i];
                r = ti[i] + t;
            }
            else {
                sum += t;
                r = ti[i] + t;
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 90856
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int n,l; cin>>n>>l;
	vector<string> v(n);
	rep(i,n) cin>>v[i];
	sort(v);
	string d="";
	rep(i,n){
		d+=v[i];
	}
	cout<<d;
	
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import defaultdict
def inpl(): return list(map(int, input().split()))

N = int(input())

def cal(i):
    if B[i] == "*":
        tmp = 1
        for g in G[i]:
            tmp *= cal(g)
    elif B[i] == "+":
        tmp = 0
        for g in G[i]:
            tmp += cal(g)
    else:
        tmp = int(B[i])
    return tmp

while N:
    A = [0]*N
    B = [0]*N
    for i in range(N):
        x = input()
        A[i], B[i] = x.count("."), x.replace(".", "")
    G = [[] for _ in range(N)]
    D = defaultdict(int)
    for i, a in enumerate(A):
        D[a] = i
        if a > 0:
            G[D[a-1]].append(i)
    print(cal(0))
    N = int(input())



Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

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

    string s;
    cin >> s;
    s += '1';
    ll k;
    cin >> k;
    
    rep(i,k){
        if(s[i] == '1'){
            continue;
        }else{
            cout << s[i] << endl;
            return 0;
        }
    }
    
    cout << '1' << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>

using namespace std;

// #define DEBUG 1
#define DFILE "t1.1"

int main() {
  int n, k;

#ifdef DEBUG
#define cin fin
  fstream fin(DFILE);
#endif
  double rate = 0.0;
  cin >> n >> k;
  int *a = new int[n + 1];
  for (int i = 1; i <= n; i++) {
    int j = i;
    int s = 0;
    while ((i << s) < k) {
      s++;
    }
    a[i] = 1 << s;
  }
  for (int i = 1; i <= n; i++) {
    // cout << i << ":" << a[i] << endl;
    rate += (1.0 / a[i]);
  }
  rate /= n;
  printf("%.10f\n", rate);
  // cout << rate << endl;
  return 0;
}

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

int main(){
    int k,s;
    cin >> k >> s;
    int count=0;
    for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){
            if(s-i-j>=0 && s-i-j<=k) count++;
        }
    }
    cout << count << endl;
}

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

typedef long long ll;
const int N = 2000006;

int a[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int r;
	cin>>r;
	
	if(r >= 2800) cout<<"AGC";
	else if(r >= 1200) cout<<"ARC";
	else cout<<"ABC";
	
	return 0;
}


Measured memory_bytes: 3648
N = gets.chomp.to_i
D = gets.chomp.split(" ").map(&:to_i)

if D[0] != 0 || D[1..-1].include?(0) then
  puts "0"
  exit
end

ranks = []
i = 1
D.each do |n|
  rank = ranks[n] || 0
  ranks[n] = rank + 1
end

if ranks.include?(nil) then
  puts "0"
  exit
end

s = 1
pr = 1
ranks.each do |r|
  s *= pr ** r
  pr = r
end

puts s % 998244353

Measured memory_bytes: 61972
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+5;
const int MOD=1e9+7;
const int INV2=MOD-MOD/2;
typedef long long ll;
struct state
{
	int dp[3];
	state(int _a=0,int _b=0,int _c=0){dp[0]=_a,dp[1]=_b,dp[2]=_c;}
};
vector<state> s[MAXN];
vector<int> E[MAXN];
int root[MAXN];
ll qpow(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1) ret=(ret*a)%MOD;
		b>>=1;
		a=(a*a)%MOD;
	}
	return ret;
}
int merge(int x,int y)
{
	if(s[x].size()<s[y].size()) swap(x,y);
	int x_sz=s[x].size()-1,y_sz=s[y].size()-1;
	for(int i=0;i<=y_sz;i++)
	{
		int px=x_sz-i,py=y_sz-i;
		int t0,t1,t2;
		t0=1LL*s[x][px].dp[0]*s[y][py].dp[0]%MOD;
		t1=(1LL*s[x][px].dp[1]*s[y][py].dp[0]%MOD+1LL*s[x][px].dp[0]*s[y][py].dp[1]%MOD)%MOD;
		t2=(1LL*s[x][px].dp[1]*s[y][py].dp[1]%MOD+(1LL*s[x][px].dp[0]+s[x][px].dp[1])%MOD*s[y][py].dp[2]%MOD+(1LL*s[y][py].dp[0]+s[y][py].dp[1])%MOD*s[x][px].dp[2]%MOD+1LL*s[x][px].dp[2]*s[y][py].dp[2]%MOD)%MOD;
		s[x][px].dp[0]=t0,s[x][px].dp[1]=t1,s[x][px].dp[2]=t2;
	}
	s[y].clear();
	return x;
}
void dfs(int now)
{
	int dep=0;
	root[now]=now;
	if(E[now].size()==0)
	{
		s[root[now]].push_back(state(INV2,INV2,0));
		return ;
	}
	for(int i=0;i<E[now].size();i++)
	{
		int v=E[now][i];
		dfs(v);
		dep=max(dep,min(int(s[root[now]].size()),(int)s[root[v]].size()));
		root[now]=merge(root[now],root[v]);
	}
	int id=root[now];
	int sz=s[id].size()-1;
	for(int i=0;i<dep;i++)
	{
		s[id][sz-i].dp[0]=(s[id][sz-i].dp[0]+s[id][sz-i].dp[2])%MOD;
		s[id][sz-i].dp[2]=0;
	}
	s[id].push_back(state(INV2,INV2,0));
}
inline char nc()
{
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline void rea(int &x)
{
	char c=nc();x=0;
	for(;c>'9'||c<'0';c=nc());for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n;
	//scanf("%d",&n);
	rea(n);
	for(int i=1;i<=n;i++)
	{
		int u;
		//scanf("%d",&u);
		rea(u);
		E[u].push_back(i);
	}
	root[0]=0;
	dfs(0);
	ll sum=0;
	for(int i=0;i<s[root[0]].size();i++)
	{
		sum=(sum+s[root[0]][i].dp[1])%MOD;
	}
	printf("%lld\n",sum*qpow(2,n+1)%MOD);
	return 0;
}


Measured memory_bytes: 35828
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
	int ta[4][2]={{0},{0}};
	double a,b;
	while(cin>>a>>b){
		if(a>=1.1)ta[0][0]++;
		else if(a>=0.6)ta[1][0]++;
		else if(a>=0.2)ta[2][0]++;
		else ta[3][0]++;
		
		if(b>=1.1)ta[0][1]++;
		else if(b>=0.6)ta[1][1]++;
		else if(b>=0.2)ta[2][1]++;
		else ta[3][1]++;
	}
		for(int i=0;i<4;i++)cout<<ta[i][0]<<" "<<ta[i][1]<<endl;
		return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a, b,c,d;
  cin >> a>>b>>c>>d;
  
  cout << (abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int n,a[105],lv[105],ans,mor;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n;i++){
		if (a[i]>3199){
			mor++;
		}else{
			lv[a[i]/400]++;
		}
	}
	ans=0;
	for (int i=0;i<8;i++) if (lv[i]>0) ans++;
	cout<<max(1,ans)<<' ';
	cout<<ans+mor;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {

  int pas,ju;
  int i,a,sum;

  pas = 10000;
  ju = 10000;
  for(i=0;i<3;i++) {
    scanf("%d",&a);
    if(pas > a) pas = a;
  }

  for(i=0;i<2;i++) {

    scanf("%d",&a);

    if(ju > a) ju = a;
  }

  sum = ju + pas - 50;

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

  return 0;

}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin>>n;

    //cout <<fixed<<setprecision(16)<< << endl;
    if(n<1200)cout << "ABC" <<endl;
    else cout << "ARC" <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
vector<int> inp;
vector<vector<vector<ll>>> dp;

ll dopont_dequ (int i=0,int j=n-1,int c = 1)
{
    //cout<<i<<" "<<j<<" "<<c<<" "<<sum<<'\n';
    if(i>j) return 0;
    if(dp[i][j][c] != -1) return dp[i][j][c];

    ll ans = 0;
    if(c)
    {
        ans = dopont_dequ(i+1,j,0)+inp[i];
        ans = max(ans,dopont_dequ(i,j-1,0)+inp[j]);
    }
    else
    {
        ans = dopont_dequ(i+1,j,1)-inp[i];
        ans = min(ans,dopont_dequ(i,j-1,1)-inp[j]);
    }
    
    
    return dp[i][j][c]=ans;
}

int main()
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //int k;
    cin>>n;//>>k;
    inp.resize(n);
    dp.assign(n+1,vector<vector<ll>> (n+1,vector<ll> (2,-1)));

    for(int i=0;i<n;i++)
    {
        cin>>inp[i];
    }

    cout<<dopont_dequ()<<'\n';
    /*for(int i=0;i<n;i++) 
    {
        for(int j=0;j<n;j++)*/

}


Measured memory_bytes: 496368
s = gets.chomp
words = ["dream","dreamer","erase","eraser"]
loop do
  flag = false
  words.each do |w|
   if s.slice(s.size - w.size,w.size) == w
    flag = true
    s = s.slice(0,s.size-w.size)
    break
   end
  end
  break if flag == false
end

puts s == "" ? "YES" : "NO"

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

int main(){
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  A--; B--; C--; D--;
  string S;
  cin >> S;

  bool ans = true;
  char pre;
  int brank = 0;
  int max_brank = 0;
  int gorl = max(C, D);
  for(int i=A; i<=gorl; i++){
    if(i == A){
      if(i == B-1){
        brank++;
      }
    }
    else if(i < B && i > C){
      continue;
    }
    else{
      if(S.at(i) == '#'){
        if(pre == '.'){
          max_brank = max(max_brank, brank);
          brank = 0;
        }
        else{ //pre == '#'
          ans = false;
          break;
        }
      }
      else{
        if(i >= B-1 && i <= D+1){
          brank++;
        }
      }
      if(i == D+1 || i == gorl){
        max_brank = max(max_brank, brank);
      }
    }
    pre = S.at(i);
  }
  
  
  if(C > D){
    if(max_brank < 3){
      ans = false;
    }
  }

  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int n;
int main()
{
	cin>>n;
	int d=0;
	int m=n;
	while (m>0)
	{
		d++;
		m/=10;
	}
	int ans=0;
	int t=1;
	for (int i=1;i<d;i++)
	{
		if (i%2==1) ans+=9*t;
		t*=10;
	}
	int p=1;
	for (int i=1;i<d;i++) p*=10;
	if (d%2!=0)
	{
		ans+=n-p+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
{-# LANGUAGE FlexibleContexts #-}

import Data.Array.IO
import Data.Array.ST
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Unboxed as VU
import Data.List

{-- IO union-find tree --}
type IOUnionFind = STUnionFind RealWorld
newIOUnionFind n = stToIO $ newSTUnionFind n
findIOUnionFind uf x = stToIO $ findSTUnionFind uf x
sameIOUnionFind uf x y = stToIO $ sameSTUnionFind uf x y 
uniteIOUnionFind uf x y = stToIO $ uniteSTUnionFind uf x y

{-- ST union-find tree --}
-- (親要素のIndex配列, 木の深さの配列, 木の要素数の配列)
type STUnionFind s = (VUM.MVector s Int, VUM.MVector s Int, VUM.MVector s Int)

newSTUnionFind :: Int -> ST s (STUnionFind s)
newSTUnionFind n = do
  parentList <- VU.thaw $ VU.fromList [0..n-1]
  depthList <- VU.thaw $ VU.fromList (take n (repeat 1))
  sizeList <- VU.thaw $ VU.fromList (take n (repeat 1))
  return (parentList, depthList, sizeList)

findSTUnionFind :: STUnionFind s -> Int -> ST s Int
findSTUnionFind uf@(plist,dlist,slist) x = do
  parent <- VUM.read plist x
  if parent == x then return x
    else findSTUnionFind uf parent >>= \next -> VUM.write plist x next >> return next

sameSTUnionFind :: STUnionFind s -> Int -> Int -> ST s Bool
sameSTUnionFind uf x y = (==) <$> findSTUnionFind uf x <*> findSTUnionFind uf y
  
uniteSTUnionFind :: STUnionFind s -> Int -> Int -> ST s ()
uniteSTUnionFind uf@(plist,dlist,slist) x y = do
  xx <- findSTUnionFind uf x
  yy <- findSTUnionFind uf y
  xdepth <- VUM.read dlist xx
  xsize <- VUM.read slist xx
  ydepth <- VUM.read dlist yy
  ysize <- VUM.read slist yy

  if xx == yy then return ()
    else if xdepth < ydepth then VUM.write plist xx yy >> VUM.write dlist yy ydepth >> VUM.write slist yy (ysize+xsize)
    else if xdepth > ydepth then VUM.write plist yy xx >> VUM.write dlist xx xdepth >> VUM.write slist xx (xsize+ysize)
    else VUM.write plist yy xx >> VUM.write dlist xx (xdepth+1) >> VUM.write slist xx (xsize+ysize)

nub' = map head . group

infixr 1 ?
(?) :: Bool -> (a,a) -> a
(?) b t = (if b then fst else snd) t

main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  uf <- newIOUnionFind m :: IO IOUnionFind

  langs <- nub' . sort . concat <$> (
    replicateM n $ do
        (k:ls) <- map read . words <$> getLine :: IO [Int]
        forM_ (zip ls (tail ls)) $ \(i,j) -> do
          uniteIOUnionFind uf (i-1) (j-1)
        return ls
    )

  putStrLn =<< (? ("YES", "NO")) . and <$> (forM (zip langs (tail langs)) $ \(i,j) -> sameIOUnionFind uf (i-1) (j-1))

  


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

int main(){
  double x; cin >>x;
  x /= 400;
  int ans;
  if(x<1.5) ans = 8;
  else if(x<2) ans = 7;
  else if(x<2.5) ans = 6;
  else if(x<3) ans = 5;
  else if(x<3.5) ans = 4;
  else if(x<4) ans = 3;
  else if(x<4.5) ans = 2;
  else ans = 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=4e18;
const li mod=1e9+7;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}

li mmi(li a){return power(a,mod-2);}

li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

void solve(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<min(a,b)+min(c,d);
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

int main(){
  int K,S;
  cin >> K >> S;
  int ans=0;
  for(int x=0;x<=K;x++){
    for(int y=0;y<=K;y++){
      if(S-x-y>K || S-x-y<0){
        continue;
      }
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func main() {
	a, b, c, d := readFloat64(), readFloat64(), readFloat64(), readFloat64()
	switch {
	case b <= c || d <= a:
		fmt.Println(0)
	default:
		fmt.Println(math.Min(b, d) - math.Max(a, c))
	}
}


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

int main(){

    int n, d;
    cin >> n >> d;

    int temp, ans;
    temp = 2*d + 1;
    
    if (n%temp == 0){
        cout << n/temp << endl;
    }
    else{
        cout << n/temp + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

ll n;

int main(){
FLASH;
cin>>n;
if(n%10==7)cout<<"Yes"<<endl;
else if(n/100==7)cout<<"Yes"<<endl;
else if(n/10%10==7)cout<<"Yes"<<endl;
else cout<<"No"<<endl;






return 0;
} 


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


// modint
// 1000000007 で割ったあまりに関する四則演算を直感的に行える
template<int MODULO> struct Fp {
    long long val;

    constexpr Fp(long long v = 0) noexcept : val(v % MODULO) {
        if (val < 0) v += MODULO;
    }
    constexpr Fp operator - () const noexcept {
        return val ? MODULO - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MODULO) val -= MODULO;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MODULO;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MODULO;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MODULO, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MODULO;
        if (val < 0) val += MODULO;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
};

template<int MODULO> constexpr ostream& operator <<
(ostream &os, const Fp<MODULO>& x) noexcept {
    return os << x.val;
}
template<int MODULO> constexpr istream& operator >>
(istream &is, Fp<MODULO>& x) noexcept {
    return is >> x.val;
}

template<int MODULO> constexpr Fp<MODULO> modpow
(const Fp<MODULO> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
}


// 二項係数ライブラリ
template<int MODULO> struct BiCoef {
    vector<Fp<MODULO> > fac, inv, finv;
    constexpr BiCoef(int n) noexcept : fac(n, 1), inv(n, 1), finv(n, 1) {
        for(int i = 2; i < n; i++){
            fac[i] = fac[i-1] * i;
            inv[i] = -inv[MODULO%i] * (MODULO/i);
            finv[i] = finv[i-1] * inv[i];
        }
    }
    constexpr Fp<MODULO> com(int n, int k) const noexcept {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * finv[k] * finv[n-k];
    }
};



// ここから解答
const int MAX = 201010;
const int MOD = 1000000007;
using mint = Fp<MOD>; // mod 計算を直感的に

int main() {
    BiCoef<MOD> bc(MAX); // 二項係数計算の前処理

    long long N, K;
    cin >> N >> K;
    cout << bc.com(K, N) << endl;
}



Measured memory_bytes: 7416
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
	long long a[10000], i, n, m, M, s;
	cin >> n >> a[1];
	m = a[1];
	M = a[1];
	s = a[1];
	for (i = 2;i <= n;i++) {
		cin >> a[i];
		if (a[i] < m) { m = a[i]; }
		if (a[i] > M) { M = a[i]; }
		s = s + a[i];
	}
	printf("%lld %lld %lld\n", m, M, s);
	return 0;
}


Measured memory_bytes: 3228
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  int res = inf;
  for(int i = 0; i + 2 < s.size(); i++){
    int tmp = 100 * int(s[i] - '0') + 10 * int(s[i+1] - '0') + int(s[i+2] - '0');
    res = min(res, abs(tmp-753));
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

ll gcd(ll a, ll b){
    if(a % b == 0){
        return(b);
    }
    else{
        return(gcd(b, a % b));
    }
}

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;

int main(){
    ll p, X;
    set<int> S;

    cin >> X >> N;
    REP(i, N){
        scanf("%lld", &p);
        S.insert(p);
    }

    if(N == 0){
        cout << X << endl;
        return 0;
    }
    if(S.find(X) == S.end()){
        cout << X << endl;
        return 0;
    }
    FOR(i, 1, 100){
        if(S.find(X - i) != S.end()){ // - の場合

        }else{//無かった場合
            cout << X - i << endl;
            break;
        }

        if(S.find(X + i) != S.end()){ // + の場合

        }else{//無かった場合
            cout << X + i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3700
n=int(input())
CSF=[list(map(int,input().split())) for _ in range(n-1)]
for i in range(n):
    t=0
    for j in range(n-i-1):
        c,s,f=CSF[i+j]
        if t<=s:
            t=s+c
        elif t%f==0:
            t+=c
        else:
            t=(t//f+1)*f+c
    print(t)

Measured memory_bytes: 3188
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e18) + 1;
const int mod = 479001599;
const int maxn = 5e5 + 111;
        
using namespace std;          

int k, ans;

void solve(){
	cin >> k;

    for (int i = 1; i <= k; i++)
    	for (int j = 1; j <= k; j++)
    		for (int h = 1; h <= k; h++)
    			ans += __gcd(__gcd(i, j), h);

    cout << ans;                                                            
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}


Measured memory_bytes: 3652
import           Control.Monad
import           Data.Array.ST
import           Data.Array.Unboxed

main :: IO ()
main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  hs <- listArray (1,n) . map read . words <$> getLine :: IO (UArray Int Int)
  let solve = solve2
  print $ solve hs n k ! n

solve1 :: UArray Int Int -> Int -> Int -> UArray Int Int
solve1 hs n k = runSTUArray $ do
  dp <- newArray (1,n) 0
  forM_ [1..n] $ \x ->
    minimum <$> forM [(max (x-k) 1)..(x-1)] (\y -> liftM2 (+) (readArray dp y) (return . abs $ hs!x - hs!y)) >>=  writeArray dp x
  return dp

solve2 :: UArray Int Int -> Int -> Int -> UArray Int Int
solve2 hs n k = runSTUArray $ do
  dp <- newArray (1,n) maxBound
  writeArray dp 1 0
  forM_ [1..n] $ \x ->
    forM [(x+1)..(min (x+k) n)] (\y -> liftM2 (+) (readArray dp x) (return . abs $ hs!x - hs!y) >>= \a -> readArray dp y >>= writeArray dp y . min a)
  return dp


Measured memory_bytes: 30972
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import collections
import sys

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

def main():
    n, k = list(map(int,ipti().split()))
    nn = [0] * (10**5 + 1)

    for i in range(n):
        a, b = list(map(int,ipti().split()))
        nn[a] += b

    cnt = 0
    for i in range(10**5 + 2):
        cnt += nn[i]
        if cnt >= k:
            print(i)
            sys.exit()

if __name__ == '__main__':
    main()


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

class DisjointSet{
    public:
    std::vector<int> rank, p;

    //DisjointSet();
    DisjointSet(int size){
        rank.resize(size, 0);
        p.resize(size, 0);
        for(int i = 0; i < size; i++){
            makeSet(i);
        }
    }

    void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }

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

    void unite(int x, int y){
        link(findSet(x), findSet(y));
    }

    void link(int x, int y){
        if(rank[x] < rank[y]){
            p[y] = x;
        }else{
            p[x] = y;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }

    int findSet(int x){
        if(x != p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main(void){
    int n, q;
    std::cin >> n >> q;

    DisjointSet djset = DisjointSet(n);

    int com, x, y;
    for(int i = 0; i < q; i++){
        std::cin >> com >> x >> y;
        if(com == 0){
            djset.unite(x, y);
        }else{
            std::cout << djset.same(x, y) << std::endl;
        }
    }
}


Measured memory_bytes: 3236
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int[] d = new int[3];

		for(int i = 0; i < d.length; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);

		System.out.println(d[0] + d[1]);
	}
}

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

const int INF = 1e9;

const int MAXN = 1.1e5;
const int MAXM = 2.1e5;
int N, M;
map<int, vector<int>> adj[MAXN];

map<int, int> dist[MAXN];

bool update(int v, int c, int d) {
	if (!dist[v].count(c) || dist[v][c] > d) {
		dist[v][c] = d;
		return true;
	} else {
		return false;
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M;
	for (int e = 0; e < M; e++) {
		int p, q, c; cin >> p >> q >> c;
		adj[p][c].push_back(q);
		adj[q][c].push_back(p);
	}

	deque<tuple<int, int, int>> que;
	que.emplace_back(0, 1, 0);
	dist[1][0] = 0;

	while (!que.empty()) {
		int d, v, c; tie(d, v, c) = que.front();
		que.pop_front();
		if (d != dist[v][c]) continue;

		if (v == N) {
			cout << d << '\n';
			exit(0);
		}

		if (c == 0) {
			for (auto& p : adj[v]) {
				if (update(v, p.first, d+1)) {
					que.emplace_back(d+1, v, p.first);
				}
			}
		} else {
			if (update(v, 0, d)) {
				que.emplace_front(d, v, 0);
			}
			for (auto& nv : adj[v][c]) {
				if (update(nv, c, d)) {
					que.emplace_front(d, nv, c);
				}
			}
		}
	}

	cout << -1 << '\n';

	return 0;
}


Measured memory_bytes: 73472
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    double ans = 0.0;
    for(int i = 1;i <= N;i++) {
        int j = i;
        int count = 0;
        while(j < K) {
            j *= 2;
            count++;
        }
        ans += (1.0/N)*pow(0.5,count);
    }

    printf("%.10f\n",ans);

    return 0;
}


Measured memory_bytes: 256
// AtCoder ABC130: C - Rectangle Cutting
// 2019.9.4 bal4u

#include <stdio.h>

typedef long long ll;

int main()
{
	int W, H, x, y; ll s;
	
	scanf("%d%d%d%d", &W, &H, &x, &y);
	s = (ll)W*H;
	printf("%lld", s/2);
	if (s & 1) puts(".5 0");
	else puts((2*x == W && 2*y == H)? " 1": " 0");
	return 0;
}


Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    writeln(N * (N-1) / 2 + M * (M-1) / 2);
}

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

using namespace std;

typedef long long ll;

int main()
{
    int n;  cin >> n;
    ll k;   cin >> k;

    const ll m = 60;

    vector <vector <int>> Next(n, vector <int> (m));
    for(int i = 0; i < n; i++)  scanf("%d", &Next[i][0]), Next[i][0]--;

    for(int j = 1; j < m; j++)
        for(int i = 0; i < n; i++)
            Next[i][j] = Next[Next[i][j - 1]][j - 1];

    int Ans = 0;

    for(ll j = 0; j < m; j++)
        if(k & (1LL << j))
            Ans = Next[Ans][j];

    cout << Ans + 1 << endl;
}


Measured memory_bytes: 57868
R,G,B,N=map(int,input().split())

ans=0
for r in range(N//R+1):
  for g in range(N//G+1):
    if 0<=N-r*R-g*G and (N-r*R-g*G)%B==0:
      #print(r,g,(N-r*R+g*G)//B)
      ans += 1
      
print(ans)

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll K = 0;
ll ret = 0;
vector<ll> v;
priority_queue<
  ll,
  vector<ll>,
  greater<ll>
> p;

void input() {
  IN(N);
  IN(K);
  ll tmp;
  REP(i, N) {
    IN(tmp);
    v.pb(tmp);
  }
}

void solve() {
  ll m = min(N, K);
  REP(i, m+1) {
    REP(j, m-i+1) {
      //左からi個、右からj個取り出す
      REP(k, N) {
        if (k < i || N-j-1 < k) {
          DEBUG(v[k]);
          p.push(v[k]);
        }
      }
      LN();

      ll trash = K - i - j;
      while(trash > 0 && !p.empty()) {
        if (p.top() < 0) {
          p.pop();
          trash--;
        } else {
          break;
        }
      }
      ll score = 0;
      while(!p.empty()) {
        score += p.top();
        p.pop();
      }
      ret = max(ret, score);
    }
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


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

int main(void){
    long long a, b, n;
    cin >> a >> b >> n;
    long long x = n;
    
    if(n >= (b - 1)) x = b - 1;
    int ans;
    ans = a * x / b - a * (x / b);
    cout << ans << endl;
}

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

int main(){
  int N;
  long long K;
  cin >> N >> K;
  vector<int> v(N+1);
  for(int i=1;i<=N;i++){
    int A;
    cin >> A;
    v.at(i)=A;
  }
  int cycle=0;
  vector<int> ans;
  int x=1;
  ans.push_back(1);
  vector<int> num(N+1,-1);
  num.at(1)=0;
  int s;
  for(int i=1;;i++){
    int y=v.at(x);
    if(num.at(y)!=-1){
      cycle=i-num.at(y);
      s=num.at(y);
      break;
    }
    num.at(y)=i;
    ans.push_back(y);
    x=y;
  }
  if(s>=K){
    cout << ans.at(K) << endl;
  }else{
    cout << ans.at((K-s)%cycle+s) << endl;
  }
  return 0;
}


Measured memory_bytes: 5880
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int solve(const std::vector<int>& xs, int remove) {
  int mid = xs.size() / 2;
  int s = xs[mid - 1];
  int l = xs[mid];
  return (remove <= s ? l : s);
}

int main() {
  int N;
  std::cin >> N;
  std::vector<int> xs;
  for (int i = 0; i < N; ++i) {
    int x;
    std::cin >> x;
    xs.push_back(x);
  }
  std::vector<int> xss = xs;
  std::sort(xss.begin(), xss.end());
  for (int i = 0; i < N; ++i) {
    std::cout << solve(xss, xs[i]) << std::endl;
  }
}


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

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

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)


ll a,b;

ll f(ll n){
  ll a = n%4;
  ll ans;
  if(a==0){
    ans = n;
  }else if(a==1){
    ans = 1;
  }else if(a==2){
    ans = 1^n;
  }else{
    ans = 0;
  }
  return ans;


  /*
  cout << n << endl;
  ll ans = 0;
  if(n%4ll == 0 || n%4ll == 3){
    ans = 0;
  }else{
    ans = 1;
  }
  n >>=1;
  ll i = 2;
  while(n>0){
    cout << "  " << i << ":";
    ll b = pow(2ll,i);
    ll a = n % b;
    if(a< pow(2ll,i-1)){
      cout << 1 <<endl;
      ans += pow(2ll,i-1);
    }else{
      cout << 0 << endl;
    }
  cout << ans << endl;
    n >>=1;
    i++;
  }
  return ans;
  */
}

int main(){
  cin >> a >> b;
  cout << (f(b)^f(a-1)) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int solve(string s1, string s2, int l1, int l2)
{
	int a[1001][1001];
	for(int i = 0; i <= l1; i++){
		a[i][0] = 0;
	}
	for(int i = 0; i <= l2; i++){
		a[0][i] = 0;
	}
	for(int i = 1; i <= l1; i++){
		for(int j = 1; j <= l2; j++){
			if(s1[i - 1] == s2[j - 1]) a[i][j] = a[i - 1][j - 1] + 1;
			else a[i][j] = max(a[i - 1][j], a[i][j - 1]);
		}
	}
	return a[l1][l2];
}

int main()
{
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		string s1, s2;
		cin >> s1 >> s2;
		cout << solve(s1, s2, s1.length(), s2.length()) << endl;
	}
	return 0;
}

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

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

int main(){
    string S;
    int K;
    cin>>S>>K;
    int N=S.size();
    set<string>A;
    rep(i,N){
        int T=min(K,N-i+1);
        for(int j=1;j<=T;j++){
            A.insert(S.substr(i,j));
        }
    }
    int count=0;
    for (auto value : A){
        count++;
        if(count==K){
            cout<<value<<endl;
        }
    }
}


Measured memory_bytes: 1664
#                           जय श्री राम

import sys; import math; from collections import *
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().split())
def get_list(): return list(get_ints())
def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9+7); SEXYMOD = 998244353; MAXN = int(1e5)

# sys.stdin  = open("input.txt","r"); sys.stdout = open("output.txt","w")

# for _testcases_ in range(int(input())):
from functools import reduce
n = int(input())
li = get_list()
xo = reduce(lambda x, y: x ^ y, li)
for i in li:
    printsp(i ^ xo)
print()



'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 93092
#include <iostream>

using namespace std;

int main() {
    
    int x, y, z, a, b, c;
    
    cin>> x >> y >> z;
    
    if(y > z){
        if(x > y){
            a = x;
            b = y;
            c = z;
        }
        else if(x < z){
            a = y;
            b = z;
            c = x;
        }
        else{
            a = y;
            b = x;
            c = z;
        }
    }
    else{
        if(x > z){
            a = x;
            b = z;
            c = y;
        }
        else if(x < y){
            a = z;
            b = y;
            c = x;
        }
        else{
            a = z;
            b = x;
            c = y;
        }
    }
    cout<< c << " " << b << " " << a << endl;
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main(){
	int a,b,i,j,k;
	cin >> a >> b;
	k=0;
	for(i=a;i<=b;i++){
        if(i/10000==i%10 && i/1000%10==i/10%10)
            k++;
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	S := scanner.Text()
	scanner.Scan()
	T := scanner.Text()

	if len(S)+1 == len(T) && S[:] == T[:len(S)] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

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

    int n;
    cin >> n;
    int mn = 1e9, mx = -1e9;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        mn = min(mn, x);
        mx = max(mx, x);
    }

    cout << mx - mn;

    return 0;
}


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

int main(void) {
    int N;
    cin >> N;
    int R[200010] = {0};

    for (int i=1; i<N; i++) {
        int A;
        cin >> A;
        R[A]++;
    }

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

    return 0;
}

Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 2019
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 2019;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=(a+d-1)/d;
    int y=(c+b-1)/b;
    if(x>=y){
        OUT("Yes");
    }else{
        OUT("No");
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265;

int main() {
  long double a,b,x;
  cin >> a >> b >> x;
  long double t = 2*x/a/a/b;
  cout << fixed << setprecision(7);
  if(2*x > a*a*b) {
      t = 2*b/a-2*x/a/a/a;
      cout << atanl(t)*180/PI << endl;;
  }
  else if(2*x < a*a*b) {
      t =2*x/a/b/b;
      cout << 90 - atanl(t)*180/PI << endl;
  }
  else {
      cout << 90 - atanl(t)*180/PI << endl;

  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n; cin>>n;
  vector<vector<ll>> a(9,vector<ll>(9,0));
  int k=1;
  ll ans=0;
  for(int i=1;i<=n;i++){
    if(i==k*10) k*=10;
    int A=i%10;A--;
    int B=i/k;B--;
    if(A<0) continue;
    // cout<<"i "<<i<<" k "<<k<<" ";
    // cout<<A<<" "<<B<<endl;
    a[B][A]++;
  }

  rep(i,9){
    rep(j,9){
      ans+=a[i][j]*a[j][i];
      // cout<<a[i][j]<<" ";
    }
    // cout<<endl;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 2000000020LL
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define POS(n, x) (lower_bound(ALL(n), x) - (n).begin())
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define PB push_back
#define EB emplace_back
#define MOD 1000000007
#define PRIME 101 
#define MAXN 200020
#define MAXL 23
#define endl '\n'

using namespace std;

// (1 + sqrt(5)) / 2
const ld GOLDEN_RATIO = 1.6180339887498949025257388711906969547271728515625;
const ld PI = 2.0 * acos(0.0);
const int BLOCK = 333;

int N, dp[MAXN][4], custo[MAXN][4];

int solve(int i, int p)
{
	if(dp[i][p] != -1) return dp[i][p];
	if(i > N) return dp[i][p] = 0;

	dp[i][p] = -INF;

	for(int j = 1; j < 4; j++)
		if(j != p)
			dp[i][p] = max(dp[i][p], custo[i][j] + solve(i + 1, j));

	return dp[i][p];
}

int main(int argc, char const *argv[])
{
	optimize;
	
	memset(dp, -1, sizeof dp);

	cin >> N;

	for(int i = 1; i <= N; i++)
		cin >> custo[i][1] >> custo[i][2] >> custo[i][3];

	cout << solve(1, 0) << endl;

	return 0;
}

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

int main(){ int K,S; cin >> K >> S; int cnt = 0;
           for(int i = 0; i <= K; i++){
             for(int j = 0; j <= K; j++){
              if( S - K <= i + j && i + j <= S){cnt++;}}}
           
           cout << cnt << endl;
           
           return 0;}

Measured memory_bytes: 256
object Main {
  import java.util.Scanner
  import scala.collection.mutable

  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def embeddable(S: String, T: String): Boolean = {
    val correspondence = mutable.HashMap.empty[Char, Char]
    S.zip(T).forall { case (s, t) =>
      correspondence.get(s) match {
        case Some(t1) => t == t1
        case None =>
          correspondence(s) = t
          true
      }
    }
  }

  def solve(implicit sc: Scanner): Unit = {
    val S = sc.nextLine()
    val T = sc.nextLine()
    if (embeddable(S, T) && embeddable(T, S)) println("Yes") else println("No")
  }
}


Measured memory_bytes: 61324