akhauriyash/Code-Regression huggingface dataset:
def f(a, b, le, tf):
    b[le] = tf
    if le == len(b)-1:
        t = ""
        s1 = 0
        for i in range(len(b)):
            t += a[i]
            if b[i] == 1:
                s1 += int(t)
                t = ""
        t += a[len(b)]
        s1 += int(t)
        return s1
    else:
        return f(a, b, le+1, 0) + f(a, b, le+1, 1)


aa = input()
bb = [0] * (len(aa)-1)
if len(aa) == 1:
    print(aa)
else:
    print(f(aa, bb, 0, 0) + f(aa, bb, 0, 1))

Measured memory_bytes: 3316
N, M, C = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for _ in range(N)]
ans = 0
for i in range(N):
    score = 0
    for j in range(M):
        score += A[i][j] * B[j]
    if score + C > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>

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

using namespace std;
using ll = long long;

int dis(int x1, int y1, int x2, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}

int main() {

	int n;
	cin >> n;
	ll y;
	cin >> y;

	REP(i, y / 10000 + 1) {
		REP(j, y / 5000 + 1) {
			ll c = i * 10000 + j * 5000;
			if (c > y) break;
			if (c + (n - i - j) * 1000 == y) {
				cout << i << " " << j << " " << n - i - j NL;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" NL;

	return 0;

}

Measured memory_bytes: 384
from collections import deque


n, d, a = map(int, input().split())
monsters = []
for _ in range(n):
    pos, hp = map(int, input().split())
    monsters.append([pos, hp])

monsters.sort()

bombs = deque([])
total_damage = 0
ans = 0
for pos, hp in monsters:
    while bombs:
        area, count = bombs[0]
        if area < pos:
            bombs.popleft()
            total_damage -= a * count
        else:
            break
    if hp <= total_damage:
        continue
    else:
        count = (hp-total_damage + a-1) // a
        ans += count
        total_damage += a * count
        bombs.append([pos + 2*d, count])

print(ans)

Measured memory_bytes: 54000
/**
 *    author:  FromDihPout
 *    created: 2020-08-18
**/

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

#define f first
#define s second

vector<vector<int>> adj;
map<pair<int,int>, int> colours;

int dfs(int u, int anc, int col) {
    int need = 0, curr = 1;
    for (int v : adj[u]) {
        if (v == anc) continue;
        if (curr == col) curr++;
        need = max(need, dfs(v, u, curr));
        colours[{u, v}] = curr;
        curr++;
    }
    return max(need, curr - 1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    adj.resize(n);
    vector<pair<int,int>> edges(n-1);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        edges[i] = {u, v};
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    cout << dfs(0, -1, -1) << '\n';
    for (auto e : edges) {
        int col = 0;
        if (colours.count({e.f, e.s})) {
            col = colours[{e.f, e.s}];
        }
        else {
            col = colours[{e.s, e.f}];
        }
        cout << col << '\n';
    }
}

Measured memory_bytes: 16872
use std::io;
use std::io::prelude::*;

fn solve (plane: &[u8], first: usize) -> char {
    if plane.get(first + 18) == Some(&b'1') {
        'B'
    } else if plane.get(first + 2) == Some(&b'1') {
        'C'
    } else if plane.get(first + 17) == Some(&b'1') {
        'D'
    } else if plane.get(first + 11) == Some(&b'1') {
        'E'
    } else if plane.get(first + 19) == Some(&b'1') {
        'F'
    } else if plane.get(first + 8) == Some(&b'1') {
        'G'
    } else {
        'A'
    }
}

fn main () {
    let mut stdin = io::stdin();
    let mut buf = [0; 72];

    loop {
        let mut dump = String::new();
        stdin.read_exact(&mut buf);
        let first = buf.iter().position(|&x| x == b'1').unwrap();
        println!("{}", solve(&buf, first));
        if stdin.read_line(&mut dump).unwrap() == 0 {
            break;
        }
    }
}



Measured memory_bytes: 5016
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

vector<string> split(string s, string p) {
  vector<string> ret;
  ll h = 0;

  REP(i, 0, s.size() - p.size() + 1) if(s.substr(i, p.size()) == p) {
    ret.push_back(s.substr(h, i - h));
    h = i + p.size();
    i += (ll) p.size() - 1;
  }
  ret.push_back(s.substr(h, (ll) s.size() - h));

  return ret;
}

int main(void) {
  ll N;
  while(cin >> N, N) {
    string S;
    cin >> S;
    S.resize(S.size() - 1);

    vector<string> seq = split(S, "u");

    bool ok = true;
    vector<vector<bool>> dp(1 << 10, vector<bool>(10));
    queue<pll> q;

    for(string s : seq) if(s.size() > 0) {
      ll x = 0;
      for(char c : s) {
        ll d = c - '0';
        dp[x][d] = true;
        q.push(pll(x, d));
        if(x & (1 << d)) ok = false;
        x = x | (1 << d);
      }
    }

    while(q.size()) {
      ll x1 = q.front().first, d1 = q.front().second;
      q.pop();
      dp[x1][d1] = true;
      REP(x2, 0, 1 << 10) REP(d2, 0, 10) if(!(x1 & x2) && dp[x2][d2]) {
        if((x1 & (1 << d2)) && !dp[x1 | x2][d1]) {
          dp[x1 | x2][d1] = true;
          q.push(pll(x1 | x2, d1));
        }
        if((x2 & (1 << d1)) && !dp[x1 | x2][d2]) {
          dp[x1 | x2][d2] = true;
          q.push(pll(x1 | x2, d2));
        }
      }
    }

    REP(x1, 0, 1 << 10) REP(d1, 0, 10) if(dp[x1][d1]) {
      REP(x2, 0, 1 << 10) REP(d2, 0, 10) if(dp[x2][d2]) {
        if(!(x1 & x2) && (x1 & (1 << d2)) && (x2 & (1 << d1))) ok = false;
      }
    }

    cout << (ok ? "SAFE" : "UNSAFE") << endl;
  }
}


Measured memory_bytes: 3364
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
#define MAX 1100000
#define MOD 1000000007

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(){
  init_io();
  ll n,x=0;
  bool is_o = false;
  vector<ll> v;
  string a;
  cin >> n >> a;
  COMinit();
  vector<ll> cp;
  for(char c:a){
    cp.push_back(c-'1');
  }
  for(int i=0;i<n-1;i++){
    v.push_back(abs(cp[i]-cp[i+1])); 
    if(v[i]==1){
      is_o = true;
    }
  }
  if(!is_o) for(int i=0;i<n;i++) v[i] /= 2;
  ll ans = 0;
  for(int i=0;i<n;i++){
    if(v[i]==1){
      if(((n-2)&i) == i){
        ans = !ans;
      }
    }
  }
  if(!is_o) ans *= 2;
  cout << ans << endl;
}



Measured memory_bytes: 49168
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<ll >    vecll;
typedef vector<string > vecstr;
////////////////////////////////////////////////
int main()
{
  ll n;
  cin >> n;
  ll m = sqrt(n);
  for(ll i = m; m >= 1; m-- ){
    if(n%m == 0){
      cout << (ll)max(log10(m),log10(n/m)) + 1 << endl;
      return 0;
    }
  }
} 

Measured memory_bytes: 256
N, C = map(int, input().split())
x, v = [0]*N, [0]*N
for n in range(N):
    x[n], v[n] = map(int, input().split())
R = [v[0] - x[0]] + [0]*(N-1)
L = [v[-1] - (C - x[-1])] + [0]*(N-1)
for i in range(N-1):
    R[i+1] = R[i] + v[i+1] - (x[i+1] - x[i])
    L[i+1] = L[i] + v[-i-2] - (x[-i-1] - x[-i-2])
Rmax = [R[0]]*N
Lmax = [L[0]]*N
for i in range(N-1):
    Rmax[i+1] = max(Rmax[i], R[i+1])
    Lmax[i+1] = max(Lmax[i], L[i+1])
RL = Rmax[-1]
LR = Lmax[-1]
for i in range(N-1):
    RL = max(RL, R[-i-2] - x[-i-2] + Lmax[i])
    LR = max(LR, L[-i-2] - (C - x[i+1]) + Rmax[i])
print(max(0, RL, LR))

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

int main() {
    int n;
    long long int ans = 0;
    cin >> n;
    int a[n+1] = {0};
    for(int i = 0; i < n; ++i) cin >> a[i];
    long long int sum = 0;
    for(int i = 0; i < n+1; ++i) {
        if(a[i] == 0) {
            ans += sum/2;
            sum = 0;
        } else sum += a[i];
    }
    cout << ans << '\n';

    return 0;
}


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

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

	vector<int> A(N,0);
	for(int i = 1; i <= N-1; i++){
		for(int j = 1; i * j <= N-1; j++){
			A[i*j]++;
		}
	}

	int c = 0;
	for(int i = 1; i <= N-1; i++){
		c += A[i];
	}

	cout << c << endl;
	return(0);
}


Measured memory_bytes: 7196
#include <bits/stdc++.h>
#define X first
#define Y second
#define PB push_back
#define ll long long
#define pii pair<ll,ll>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 20
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
using namespace std;
#define vi vector<int>
const int maxn = 2e5+7;
const ll mod=998244353;
ll a[maxn],b[maxn],c[maxn];
int n,x,y,ans[20010];
int main()
{
    FIO
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(i<=x)
			{
				if(j<=x)
					ans[j-i]++;
				else if(j<=y)
					ans[min(j-i,(x-i)+1+(y-j))]++;
				else
					ans[x-i+1+j-y]++;
			}
			else if(i<=y)
			{
				if(j<=y)
					ans[min(j-i,i-x+1+y-j)]++;
				else
					ans[min(j-i,j-y+1+i-x)]++;
			}
			else
				ans[j-i]++;
		}
	}
	for(int i=1;i<=n-1;i++)
		cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll a,b,x;
    cin >> a >> b >> x;
    ll c=a%x,d=a/x;
    ll x2;
    if (c==0){
        x2=d*x;
    }else{
        x2=(d+1)*x;
    }
    if (x2>b){
        cout << 0 << endl;
        return 0;
    }
    cout << (b-x2)/x+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll              long long
#define rep(i,a,N)      for(ll i=(a);i<(N);i++)
#define INF             ((1LL<<62)-(1LL<<31))
#define max(p,q)        ((p)>(q)?(p):(q))
#define min(p,q)        ((p)<(q)?(p):(q))

int n;
int x[20],y[20],p[20];
ll ans[20];
ll dist[20];

void dfs(int k,int cnt){
	if(k==n){
		ll sum=0;
		rep(i,0,n)sum+=dist[i]*p[i];
		ans[cnt]=min(ans[cnt],sum);
		return;
	}
	//素通り
	int temp[20];
	rep(i,0,n)temp[i]=dist[i];
	dfs(k+1,cnt);
	//x座標
	rep(i,0,n)dist[i]=min(temp[i],abs(x[i]-x[k]));
	dfs(k+1,cnt+1);
	//y座標
	rep(i,0,n)dist[i]=min(temp[i],abs(y[i]-y[k]));
	dfs(k+1,cnt+1);
}
 
 
int main(){
	scanf("%d",&n);
	rep(i,0,n)scanf("%d%d%d",x+i,y+i,p+i);
	rep(i,0,n)dist[i]=min(abs(x[i]),abs(y[i]));
	rep(i,0,n)ans[i]=INF;
	dfs(0,0);
	rep(i,0,n+1)printf("%lld\n",ans[i]);
}

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


void solve(long long N, long long K, std::vector<long long> l){
    sort(l.begin(), l.end(), [](long long x, long long y){ return x > y; });
    int ans = 0;
    for (int i = 0; i < K; i++) ans += l[i];
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> l(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&l[i]);
    }
    solve(N, K, std::move(l));
    return 0;
}


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

using ui = unsigned int;

template<class Tab>
auto solve(const Tab&t, ui i, ui m,ui imax) {
	if (m == 0)
		return true;
	if (imax <= i)
		return false;

	return solve(t, i + 1, m, imax)
		|| solve(t, i + 1, m - t[i],imax);

}

int main() {
	ui A[20]{};	ui M[200]{};
	bool log[200]{ false };

	ui n{}, q{};
	std::cin >> n;
	for (ui i{}; i < n; i++)
		std::cin >> A[i];

	std::cin >> q;
	for (ui i{}; i < q; i++)
		std::cin >> M[i];

	for (ui j{}; j < q; j++) {

		auto b = false;
		for (ui i{}; i < n; i++) {
	
			b |= solve(A, i, M[j], n);
		//	std::cout << " " << i << " " << j << " " << M[j] << "\n";
		}
		std::cout << (b ? "yes" : "no")<<"\n";

	}
		
	return 0;
}



Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;


int main(){
  stack<int>s;
  stack<pair<int, int> >sq;
  char ch;
  int sum = 0;
  string str;
  cin >> str;
  for(int i=0; i < str.size(); i++){
    ch = str[i];
    if(ch == '\\')s.push(i);
    else if(ch == '/' && s.size() > 0){
      int j = s.top();
      s.pop();
      sum += i - j;
      int ber = i - j;

      while(sq.size() > 0 && sq.top().first > j){
        ber += sq.top().second;
        sq.pop();
      }
      sq.push(make_pair(j, ber));
    }
  }

  vector<int>ans;
  while(sq.size() > 0){
    ans.push_back(sq.top().second);
    sq.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(int i=0; i < ans.size(); i++)cout << ' ' << ans[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 3280
import java.util.*;
import java.lang.Math;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
    int x[] = new int [n];
    int y[] = new int [n];
    double dis=0;
    for(int i=0; i<n; i++){
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
    }
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        if(i!=j){
          int sx = x[i] - x[j];
          int sy = y[i] - y[j];
          dis+=Math.sqrt(sx*sx+sy*sy);
        }
      }
    }
    System.out.println(dis/n);
  }
}

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

void reverse(vector<int>& v)
{
    for (int i = 0; i < v.size() / 2; i++)
    {
        swap(v[i], v[v.size() - i - 1]);
    }
}

int main(void)
{
    int n;
    cin >> n;
    vector<int> v;
    while (n-- > 0)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    reverse(v);
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if (i != (v.size() - 1))
        {
            cout << ' ';
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3108
#include<iostream>
#include<vector>
using namespace std;
typedef unsigned long long int  ll;
ll gcd(ll a,ll b){
	if(a%b==0){
	//	cout<<b<<endl;
		return b;
	}
	a=a%b;
	return gcd(b,a);

}
ll gcc(ll a,ll b){
	ll c=gcd(a,b);
	if(b%c==0)return a*(b/c);
	return (a*b)/c;
}
int main(void){
int n;
cin>>n;
ll ans=1;
ll t;
for(int i=0;i<n;i++){
	cin>>t;
	ans=gcc(ans,t);
//	cout<<ans<<endl;
}

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

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

ll gcd(ll i, ll j){
    if (i < j) {
        swap(i, j);
    }
    if (i % j == 0) {
        return j;
    }
    else {
        return gcd(j, i % j);
    }
}
int main() {
    int N; cin >> N;
    vector<ll> T(N);
    for (int i = 0; i < N; i++){
        cin >> T[i];
    }
    ll g = T[0];
    ll ans = T[0];
    for (int i = 1; i < N; i++){
        g = gcd(ans, T[i]);
        ans *= T[i] / g;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())

W=[input() for i in range(N)]

check=1

for i in range(1,N):
    if W[i-1][-1] != W[i][0]:
        check=0

W.sort()


for i in range(2,N):
    if W[i]==W[i-1]:
        check=0

if check==1:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll MAX=500000;
const ll INF=(1ll<<62)-1;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=finv[1]=finv[0]=inv[0]=inv[1]=1;
    rep(i,2,MAX){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=modpow(i,MOD-2);
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r]%MOD;
}
signed main(){
    COMinit();
    int N,A,B,C,D; cin>>N>>A>>B>>C>>D;
    vii dp(B+1,vi(N+1));
    dp[A-1][0]=1;
    REP(i,A,B){
        REP(j,0,N) dp[i][j]=dp[i-1][j];
        ll sum=1;
        if(i*C>N) continue;
        REP(j,1,C) sum=sum*COM(j*i,i)%MOD;
        REP(j,C,D){
            if(j*i>N) break;
            REP(k,j*i,N){
                dp[i][k]+=dp[i-1][k-j*i]*COM(N-k+j*i,j*i)%MOD*sum%MOD*finv[j]%MOD;
                dp[i][k]%=MOD;
            }
            sum*=COM((j+1)*i,i);
            sum%=MOD;
        }
    }
    cout<<dp[B][N]<<endl;
}
 

Measured memory_bytes: 19840
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long q = sc.NextLong();
        long h = sc.NextLong();
        long s = sc.NextLong();
        long d = sc.NextLong();
        long n = sc.NextLong();

        long[] nums = new long[] { 4 * q, 2 * h, s };
        long min = nums.Min();

        long answer;
        if (min * 2 <= d)
        {
            answer = min * n;
        }
        else
        {
            answer = n / 2 * d + (n % 2) * min;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    vector<bool> check(101);
    rep(i, n) {
        ll d;
        cin >> d;
        check[d] = true;
    }

    ll ans = 0;
    rep(i, 101) { ans += (ll)(check[i]); }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n, a, b;
    cin >> n >> a >> b;
    ll cen = INF, right = INF, left = INF;
    if(abs(a - b) % 2 == 0) {
        cen = abs(a - b) / 2;
    }
    right = n - b + 1 + (b - a - 1) / 2;
    left = a - 1 + 1 + (b - a - 1) / 2;
    cout << min(cen, min(right, left));
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;



int main() {
	string N;
	cin >> N;
	reverse(N.begin(), N.end());
	for (int i = 0; i < N.size(); i++) {
		if (N.substr(i, 5) == "maerd")i += 4;
		else if (N.substr(i, 5) == "esare")i += 4;
		else if (N.substr(i, 7) == "remaerd")i += 6;
		else if (N.substr(i, 6) == "resare")i += 5;
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Subscribers | diff Subscribers.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Subscribers.cpp && ./a.out

/*
 
 2/4/2019
 
 17:12-
 
 */

int N,A,B;

void solve() {
  cout<<min(A,B)<<" "<<max(0,A+B-N)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>A>>B;
  solve();
  
  return 0;
}


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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if((a*100 + b*10 + c)%4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int a[N];
int main(){
	int n,sum=0;scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i),sum^=a[i];
	for(int i=0;i<n;i++)printf("%d ",sum^a[i]);
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string s;
	cin>>s;
	int n=s.size();
	// int al[26]={};
	// rep(i,n){
	// 	al[s[i]-'a']++;
	// }
	// bool one=false;
	// rep(i,26){
	// 	if(al[i]==1){
	// 		if(one){
	// 			cout<<-1<<endl;
	// 			return 0;
	// 		}
	// 		one=true;
	// 	}
	// }
	// if(one){
	// 	string t;
	// 	rep(i,n)if(s[i]!='x')t+=s[i];
	// 	int m=t.size();
	// 	rep(i,m){
	// 		if(t[i]!=t[m-1-i]){
	// 			cout<<-1<<endl;
	// 			return 0;
	// 		}
	// 	}
	// }

	int left=0,right=n-1;
	int ans=0;
	while(left<right){
		if(s[left] != s[right]){
			if(s[left]!='x' && s[right]!='x'){
				cout<<-1<<endl;
				return 0;
			}
			ans++;
			if(s[left] == 'x') left++;
			else right--;
		}else{
			left++;
			right--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input())
S, T = list(input().split())

ans = [""]*(N*2)
id = 0
for i in range(2*N):
    if i % 2 == 0:
        ans[i] = S[id]
    else:
        ans[i] = T[id]
        id += 1
print("".join(ans))


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

using namespace std;

int main() {
    // blue input
    int n;
    cin >> n;
    vector<string> blue(n);
    for(int i = 0; i < n; i++) {
        cin >> blue.at(i);
    }
    // red input
    int m;
    cin >> m;
    vector<string> red(m);
    for(int i = 0; i < m; i++) {
        cin >> red.at(i);
    }

    int max = 0;

    for(int i = 0; i < n; i++) {
        string s = blue.at(i);
        int cnt = 0;
        for(int j = 0; j < n; j++) {
            if(s == blue.at(j)){
                cnt++;
            }
        }
        for(int k = 0; k < m; k++) {
            if(s == red.at(k)){
                cnt--;
            }
        }
        if(cnt >= max){
            max = cnt;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
N = int(input())
X = array = list(map(int, input().strip().split()))
num = 1
bor = 0
par = 0
score = 0
while par <= N-1:
        score = score + (X[par]-num)**2
        par = par +1
bor = score

while num <= 100:
    par = 0
    score = 0
    while par <= N-1:
        score = score + (X[par]-num)**2
        par = par +1
    if bor > score:
        bor = score
    num = num + 1
print (bor)


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

using namespace std;
int main()
{
	int a,i,j,n,k,num,ans=0;
	cin >> n >> k;
	int citizen[n];
	for (i=0;i<k;i++){
		cin >> num;
		for (j=0;j<num;j++) {
			cin >> a;
			citizen[a-1]=1;
		}
	}
	for ( i = 0; i < n;i++) {
		if (citizen[i]!=1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3164
#include <stdio.h>

#define dasitenai ( dasita == 0 )

int dataset,i,j,k,l,ai[1919],pii[114515],kyuu[1919],aaru[114514],P,Q,R,C,dasita;

int main(int argc,char **argv){
  while(1)
    {
  scanf("%d",&dataset);
  dasita = 0;
  if( dataset == 0 ) break;
  for(i=0;i<dataset;i++)
    {
      scanf("%d %d %d %d",&ai[i],&pii[i],&kyuu[i],&aaru[i]);
    }
  scanf("%d %d %d %d",&P,&Q,&R,&C);

  for(i=0;i<dataset;i++)
    {
      if( pii[i] <= P && kyuu[i] <= Q && aaru[i] <= R && pii[i]*4+kyuu[i]*9+aaru[i]*4 <= C ) 
	{
	  printf("%d\n",ai[i]);
	  dasita = dasita + 1;
	}
    }
  if( dasitenai ) 
    {
      printf("NA\n");      
    }
  }
}

Measured memory_bytes: 1072
#include"bits/stdc++.h"
using namespace std;

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


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int) 1e5 + 7;
int n;
int t[N];

int get(int x)
{
    if (t[x] == x)
    {
        return x;
    }
    else
    {
        return t[x] = get(t[x]);
    }
}

void unite(int x, int y)
{
    t[get(x)] = get(y);
}

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

    int m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        t[i] = i;
    }
    for (int i = 1; i <= m; i++)
    {
        int a, b;
        cin >> a >> b;
        unite(a, b);
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        cnt += (t[i] == i);
    }
    cout << cnt - 1 << "\n";
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long l[] = new long[100];

        if (n == 1) {
            System.out.println(1);
            return;
        }
        l[0] = 2;
        l[1] = 1;
        for (int i = 2; i <= n; i++) {
            l[i] = l[i - 1] + l[i - 2];
        }
        System.out.println(l[n]);
    }
}


Measured memory_bytes: 22228
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10

def main():
    N, M = map(int, input().split())
    num = [1] * N
    mark = [1] + [0] * (N - 1)
    for _ in range(M):
        x, y = map(int, input().split())
        x -= 1
        y -= 1

        num[x] -= 1
        num[y] += 1

        if mark[x] == 1:
            mark[y] = 1

        if num[x] == 0:
            mark[x] = 0

    print(sum(mark))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5620
//0016
// Time-stamp: <2012-07-10 18:48:35 naga>

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define PI 3.1415926535
using namespace std;


int main(){
  int walk, deg;
  double x, y;
  int direction;

  x = y = 0;
  direction = 90;
  while(true){
    //radian = (double)(direction * PI/ 180);
    scanf("%d,%d", &walk, &deg);
    if(!walk && !deg){
      break;
    }
    
    x += (double)walk * cos(direction * PI / 180);
    y += (double)walk * sin(direction * PI / 180);

    // 向きを変える。角度を360以下に
    direction += deg;
    if(direction > 360){
      direction = direction - 360;
    }
  }

  cout << (int)-x << endl << (int)y << endl;

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#define ULL unsigned long long
using namespace std;

ULL now,n,k,flag;

void deal1()
{
    printf("%lld\n",n);
    for(int i=0;i<n;i++)
        if((k-i)%50==0)flag=i;
    ULL tmp=(k-flag)/50;
    for(int i=1;i<=n;i++)
    {
        if(i<=flag)printf("%lld ",tmp+50-i+1);
        else printf("%lld ",tmp+50-i);
    }
}

void deal2()
{
    printf("%lld\n",n);
    for(int i=0;i<n;i++)
        printf("%lld ",n-i);
}

int main()
{
    scanf("%lld",&k);
    if(k==0)
    {
        puts("2");
        puts("1 1");
    }
    else if(k==1)
    {
        puts("2");
        puts("3 0");
    }
    else if(k>50)n=50,deal1();
    else n=k,deal2();
    return 0;
}

Measured memory_bytes: 256
io = STDIN
n=io.gets.to_i
ax=io.gets.split.map(&:to_i)
cnt,sum,r=0,0,0
ax.each_with_index do |a,l|
  while (r<n && sum+ax[r]==sum^ax[r])
    sum+=ax[r]
    r+=1
  end
  cnt+=r-l
  if l==r
    l+=1
  else
    sum-=a
  end
end
puts cnt


Measured memory_bytes: 15364
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 500050;
const int K = 230000;
const int mod = 1e9 + 7;
int a[N], d[N];
int binpow(int x, int y){
    int res = 1;
    while(y){
        if (y % 2){
            res = res * x % mod;
        }
        x = x * x % mod;
        y /= 2;
    }
    return res;
}
int c(int k, int n){
    if (k > n) return 0;
    int res = 1;
    for (int i = n - k + 1; i <= n; i++) res = res * i;
    for (int i = 1; i <= k; i++) res = res / i;
    return res % mod;
}
int f(int x){
    if (x < 0 || x % 2){
        return 0;
    }
    x /= 2;
    int res = 1;
    for (int i = 1; i <= 15; i++){
        res = res * binpow(i, mod - 2) % mod;
    }
    for (int i = x + 1; i <= x + 15; i++){
        res = res * i % mod;
    }
    return res;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
     //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        if (n < 5){
            cout << 0 << endl;
            continue;
        }
        n -= 5;
        int ans = 0;
        for (int i = 0; i <= 11; i++){
            ans = (ans +  c(i, 11) * f(n - i)) % mod;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3656
x,k,d = map(int,input().split())

ans = abs(x) % d
cal = abs(x) // d
if ans > abs(ans - d):
    cal += 1
    ans = abs(ans - d)

if cal > k:
    ans = abs(x) - k*d
else:
    if (k - cal) % 2 == 1:
        ans = min(abs(ans-d),abs(ans+d))

print(ans)

Measured memory_bytes: 9064
#include<stdio.h>

#define MAX 101
#define WHITE  0
#define GRAY   1
#define BRACK  2

void DFS();
void visit(int);

int G[MAX][MAX],n,time=0,color[MAX],d[MAX],f[MAX],k[MAX];

int main(){

  int i,j,u,v;

  scanf("%d",&n);

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

      G[i][j]=0;

    }
  }

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

    scanf("%d%d",&u,&k[i]);

    for(j=0;j<k[i];j++){

      scanf("%d",&v);

      G[u-1][j]=v-1;
    }
  }

  DFS();

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

    printf("%d %d %d\n",i+1,d[i],f[i]);

  }

  return 0;
}

void DFS(){
  int i;

  for(i=0;i<n;i++){
    color[i]=WHITE;
  }
  for(i=0;i<n;i++){
    if(color[i]==WHITE) visit(i);
  }
}


void visit(int u){
  int v;

  color[u]=GRAY;

  time++;
  d[u]=time;

  for(v=0;v<k[u];v++){
    if(G[u][v] && color[G[u][v]]==WHITE)
      visit(G[u][v]);
  }

  color[u]=BRACK;
  f[u]=++time;

}

Measured memory_bytes: 636
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int dif = b-a;
    int rhigh=0;


    for(int i=0;i<dif;i++){
      rhigh += (i +1);
    }

    int x = rhigh - b;

    cout <<x;

    // if (N >= 1000){
    //   cout << "ABD"  << endl;
    // }else {
    //   cout << "ABC"  << endl;
    // }

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

void solve() {
	int N;
	cin >> N;
	
	vector<int> K(N), L(N), R(N);
	REP(i, N) scanf("%d %d %d", &K[i], &L[i], &R[i]), --K[i];
	
	vector<int> lv, rv;
	REP(i, N) {
		if (L[i] > R[i]) lv.emplace_back(i);
		else rv.emplace_back(i);
	}
	
	auto calc = [&](vector<int> &lv) -> ll {
		ll res = 0;
		vector<int> ord(lv.size());
		iota(ALL(ord), 0);
		sort(ALL(ord), [&](int i, int j) {
			return K[lv[i]] < K[lv[j]];
		});
		
		set<pii> ss;
		for (int lv_idx : ord) {
			int i = lv[lv_idx];
			
			if ((int)ss.size() <= K[i]) {
				res += L[i];
				ss.emplace(L[i] - R[i], i);
				continue;
			}
			
			if (!ss.empty() && L[i] - R[i] > ss.begin()->fi) {
				int idx = ss.begin()->se;
				res += -L[idx] + R[idx];
				ss.erase(ss.begin());
				res += L[i];
				ss.emplace(L[i] - R[i], i);
			}
			else res += R[i];			
		}
		
		return res;
	};
	
	ll ans = calc(lv);
	
	for (int i : rv) {
		K[i] = N - (K[i] + 1) - 1;
		swap(L[i], R[i]);
	}
	ans += calc(rv);
	
	cout << ans << endl;
}

int main() {
	int T;
	cin >> T;
	while (T--) solve();
	return 0;
}


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

bool check(long long n){
    long long tmp[10] = {};
    while(n){
        tmp[n % 10]++;
        n /= 10;
    }
    return tmp[3] != 0 && tmp[5] != 0 && tmp[7] != 0;
}

int main(){
    int n;
    cin >> n;
    int sum = 0;
    queue<long long> que;
    int a[3] = {3, 5, 7};
    que.push(0);
    while(!que.empty()){
        long long cur = que.front(); que.pop();
        for(int i = 0; i < 3; i++){
            long long nx = cur * 10 + a[i];
            if(nx <= n){
                if(check(nx)) sum++;
                que.push(nx);
            }
        }
    }
    cout << sum << endl;
}


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

typedef long long ll;

ll A, B;

ll calc1(ll a, int bit) {
    if(bit == -1) return 1;
    for(int i = bit; i >= 0; i--) {
        if(a & (1LL << i)) return 2 * (1LL << i);
    }
    return 1;
}
ll calc2(ll a, int bit) {
    if(bit == -1) return 1;
    for(int i = bit; i >= 0; i--) {
        if(a & (1LL << i)) continue;
        return (1LL << i) + calc2(a, i - 1);
    }
    return 1;
}

ll solve3(ll a, ll b, int bit) {
    if(bit == -1) return 1;
    if(b >= (1LL << bit)) return solve3(a >= (1LL << bit)? (1LL << bit) - 1 : a, b - (1LL << bit), bit - 1);
    else return solve3(a >= (1LL << bit)? (1LL << bit) - 1 : a, b, bit - 1) + (1LL << bit);
}

ll solve2(ll a, ll b, int bit) {
    if(a + 1 >= b) return (1LL << (bit + 1));
    if(a & (1LL << bit)) return (1LL << (bit + 1));
    if(b < (1LL << bit)) return (1LL << bit) + solve2(a, b, bit - 1);
    return calc1(a, bit) + solve3(a, b, bit);
}

ll solve1(ll a, ll b, int bit) {
    if(a > b) return 0;
    if(bit == -1) return 1;
    if(a < (1LL << bit) && (1LL << bit) <= b) return solve2(b - (1LL << bit), a, bit - 1) + calc2(a, bit - 1);
    else return solve1(a & ((1LL << bit) - 1), b & ((1LL << bit) - 1), bit - 1);
}

int main() {
    cin >> A >> B;
    cout << solve1(A, B, 60);
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = sum(A)
d = {}
for i in range(N):
    if A[i] not in d:
        d[A[i]] = 1
    else:
        d[A[i]] += 1
Q = int(input())
for i in range(Q):
    B,C = map(int,input().split())
    if B in d:
        ans += (C-B) * d[B]
        if C in d:
            d[C] += d[B]
            d[B] = 0
        else:
            d[C] = d[B]
            d[B] = 0
    print(ans)

Measured memory_bytes: 20952
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

int a,b,c;

int main(){
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
}


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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl; 
  }
  else {
    cout << "consonant" << endl; 
  }
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main(){
  int a,b,c,counter=0;
  cin>>a;
  cin>>b;
  cin>>c;
  if(a==5){
  	if(b==5){
    	if(c==7){
          cout<<"YES"<<endl;
          counter++;
        }
    }
  }
  
  if(a==7){
  	if(b==5){
    	if(c==5){
          cout<<"YES"<<endl;
                   counter++;
        }
    }
  }
  
  if(a==5){
  	if(b==7){
    	if(c==5){
          cout<<"YES"<<endl;
                   counter++;
        }
    }
  }
  if(counter==0){
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define MOD 1000000007
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define dforn(a, n) for(int a = (n)-1; a>=0; --a)
#define forall(a, all) for(__typeof(all.begin()) a = all.begin(); a != all.end(); ++a)
#define EPS 0.000000000001
using namespace std;
typedef long long tint;
typedef pair<tint, tint> pii;
typedef vector<tint> vi;
typedef vector<vi> vvi;

tint solve(tint n, tint a, tint b, tint c, tint d, map<tint, tint>& memo) {
	if(n==0) return 0;
	if(memo.find(n) != memo.end()) {
		return memo[n];
	}
	tint r2 = n%2, r3 = n%3, r5 = n%5;
	tint ans = 1000000000000000000LL;
	if(log(n)+log(d) < 60*log(2)) ans = n*d; 
	ans = min(ans, solve(n/2, a,b,c,d, memo) + a + d*r2);
	if(n/2+1 < n)
	ans = min(ans, solve(n/2+1, a,b,c,d, memo) + a + d*(2-r2));
	ans = min(ans, solve(n/3, a,b,c,d, memo) + b + d*r3);
	if(n/3+1 < n)
	ans = min(ans, solve(n/3+1, a,b,c,d, memo) + b + d*(3-r3));
	ans = min(ans, solve(n/5, a,b,c,d, memo) + c + d*r5);
	if(n/5+1 < n)
	ans = min(ans, solve(n/5+1, a,b,c,d, memo) + c + d*(5-r5));
	memo[n] = ans;
	return ans;
}

int main()
{
	int T;
	cin >> T;
	forn(tc, T) {
		tint n;
		cin >> n;
		
		tint a, b, c, d;		
		cin >> a >> b >> c >> d;
		map<tint, tint> memo;
		cout << solve(n, a, b, c, d, memo) << endl;
	}
}


Measured memory_bytes: 4972
n = gets.to_i
atoz = ("a".."z")
ans = atoz.each_with_object({}) { |c, h| h[c] = 50 }

n.times do
  s = gets.chomp
  ans.each do |k, v|
    count = s.count(k)
    ans[k] = count if count <= v
  end
end

puts ans.select { |_, v| v > 0 }.map { |k, v| [k * v] }.join


Measured memory_bytes: 14240
#![allow(dead_code)]
use std::io;

fn main() {
    solve_c();
}

fn solve_d() {
    let mut x = String::new();

    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<i32> = x.trim()
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap())
        .collect();

    let w = v[0];
    let h = v[1];
    let x = v[2];
    let y = v[3];
    let r = v[4];
    if x + r <= w && 0 <= x - r && 0 <= y - r && y + r <= h {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn solve_c() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let mut v: Vec<u32> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u32>().unwrap())
            .collect();

        v.sort();
        if v[0] == 0 && v[1] == 0 {
            break;
        } else {
            println!("{} {}", v[0], v[1]);
        }
    }
}

fn solve_b() {
    let mut i = 1;
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();
        let n = x.trim().parse::<u64>().unwrap();

        if n == 0 {
            break;
        } else {
            println!("Case {}: {}", i, n);
            i += 1;
        }
    }
}

fn solve_a() {
    for _i in 0..1000 {
        println!("Hello World");
    }
}



Measured memory_bytes: 5032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		
		//入力表示
		long X = scanner.nextLong();
		double P = 100;
		int count =0;
		
		//計算
		while (P < X) {
			P = P *1.01;
			P = Math.floor(P);
			count++;
			
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 27084
#include<iostream>
#include<stdio.h>
using namespace std;
int gcd(int a,int b){
	int n;
	n = a%b;
	if (n == 0)return b;
	else return gcd(b, n);
}
int main() {
	int a, b, c, n,s;
	while (cin >> a >> b) {
		if (a > b)n = gcd(a, b);
		else n = gcd(b, a);
		s = a / n*b;
		cout << n << " " << s << endl;
	}
	return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

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

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 5005
const ll INF = 1e9 + 7;


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




int main() {

	ll n, k;
	cin >> n >> k;
	double ans = 0;


	int hoge = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i >= k)
		{
			hoge++;
		}
		else
		{
			int cnt = ceil(log2(k / (double)i));
			ans += 1 / (n*pow(2LL, cnt));
			//cout << "cnt= " << cnt << endl;
		}
		
		//cout << ans << endl;
		//cout << "cnt= " << cnt << endl;
	}

	ans += hoge / double(n);
	printf("%.12f\n", ans);

	return 0;
}



Measured memory_bytes: 256
using System;

class Program {
  static void Main(string[] args) {
    string[] val = Console.ReadLine().Split();
    int N = int.Parse(val[0]);
    int C = int.Parse(val[1]);
    int K = int.Parse(val[2]);

    int[] A = new int[N];
    for (int i = 0; i < N; ++i) {
      A[i] = int.Parse(Console.ReadLine());
    }

    Array.Sort(A);

    int timer = 0;
    int waithing = 0;
    int ans = -1;
    for (int i = 0; i < N; ++i) {
      if (A[i] > timer || waithing == C) {
        ++ans;
        timer = A[i] + K;
        waithing = 1;
      }
      else {
        ++waithing;
      }
    }

    ++ans;
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 15452
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(Q), B(N);
  for (int i = 0; i < Q; i++) {cin >> A.at(i);}
  for (int i = 0; i < N; i++) {B.at(i) = K - Q;}
  for (int i = 0; i < Q; i++) {
    int R = A.at(i);
    B.at(R - 1)++;
  }
  for (int i = 0; i < N; i++) {
    if (B.at(i) > 0) {cout << "Yes" << endl;}
    else {cout << "No" << endl;}
  }
}

Measured memory_bytes: 3976