akhauriyash/Code-Regression huggingface dataset:
// Structured Programming
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_D
//
// Accepted

use std::io::{Read, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut buf = String::new();
    stdin.read_to_string(&mut buf).unwrap();

    let n: i32 = buf.trim().parse().unwrap();

    'outer: for i in 1..(n + 1) {
        let mut x = i;
        if x % 3 == 0 {
            print!(" {}", i);
            continue;
        }
        'inner: loop {
            if x % 10 == 3 {
                print!(" {}", i);
                continue 'outer;
            }
            x /= 10;
            if x != 0 {
                continue;
            }
            break;
        }
    }
    println!();
}


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

int lcm(int a,int b);

int main(void){
  int n,i,a,t;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a;
    if (i==0) t=a;
    else t=lcm(t,a);
  }
  cout << t << endl;
  return 0;
}

int lcm(int a,int b){
  if (a>b) swap(a,b);
  if (a==0) return b;
  return lcm(b%a,a);
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<list>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint n,i,j,K;cin>>n>>K;
	vector<int>yku;
	for(i=1;i*i<=n;i++){
		if(n%i==0){
			yku.pub(i);
			if(i*i<n){yku.pub(n/i);}
		}
	}
	SO(yku);
	vector<llint>suu(yku.size());
	llint ans=0;
	for(i=0;i<yku.size();i++){
		llint aaa=(yku[i]+1)/2;
		llint bgen=K;
		llint pta=1;
		for(int h=0;h<30;h++){
			if(aaa&(1<<h)){pta*=bgen;pta%=mod;}
			bgen*=bgen;bgen%=mod;
		}
		llint xxx=yku[i];
		if(yku[i]%2==0){xxx/=2;}
		pta*=xxx;pta%=mod;pta-=suu[i];pta%=mod;
		//cerr<<"pt="<<pta<<endl;
		for(j=i+1;j<yku.size();j++){if(yku[j]%yku[i]==0){
			llint hos=yku[j];
			if(hos%2==0){hos/=2;}
			suu[j]+=pta*hos/xxx;
		}}
		ans+=pta;ans%=mod;
		
	}
	ans+=mod;ans%=mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    if N == 1:
        print('Yes')
        print(2)
        print(1,1)
        print(1,1)
        exit()
    i = 3
    l = 2
    while i <= 10**5:
        if i == N:
            break
        else:
            l += 1
            i += l
    else:
        print('No')
        exit()

    # 長さl, k = 2N/l個の配列が答え
    ans = [[1,2],[2,3],[3,1]]
    now = 3# 今使ってる最大の数字
    M = 2# 今の長さ
    k = 2*N//l
    while M < l:
        for j in range(M+1):
            ans[j].append(now+1+j)
        ans.append(list(range(now+1,now+2+M)))
        now += M+1
        M += 1
    print('Yes')
    print(k)
    for i in range(k):
        print(l,*ans[i])



if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
    long N, K;
    cin >> N >> K;
    for(int i =0; i < N; i++){
        long a;
        cin >> a;
    }
    long a = (N-K)/(K-1)  + 1;
    if((N-K)%(K-1) > 0) a+=1;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric> 
#include <string> 

using namespace std;

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

	long long cm = 0;
	long long ca = 0;
	long long cr = 0;
	long long cc = 0;
	long long ch = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M') cm++;
		if (s[0] == 'A') ca++;
		if (s[0] == 'R') cr++;
		if (s[0] == 'C') cc++;
		if (s[0] == 'H') ch++;
	}

	long long ans = 0;
	ans += cm * ca * cr;
	ans += cm * ca * cc;
	ans += cm * ca * ch;
	ans += cm * cr * cc;
	ans += cm * cr * ch;
	ans += cm * cc * ch;

	ans += ca * cr * cc;
	ans += ca * cr * ch;
	ans += ca * cc * ch;

	ans += cr * cc * ch;

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


Measured memory_bytes: 888
# -*- coding:utf-8 -*-
import sys

def solve(n, r):
	fuda = [i for i in xrange(1,n+1)]
	fuda = fuda[::-1]
	for i in xrange(r):
		p,c = map(int,raw_input().split())
		fuda = fuda[p-1:p+c-1] + fuda[0:p-1] + fuda[p+c-1:n]
	print fuda[0]

if __name__ == "__main__":
	while 1:
		n,r = map(int,raw_input().split())
		if n == 0 and r == 0:
			sys.exit()
		else:
			solve(n,r)

Measured memory_bytes: 4228
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 100010
using namespace std;
struct node{double x,y;}b[N];
node O;
double R;
double sqr(double x){return x*x;}
double dis(node x,node y)
{
    return sqrt(sqr(x.x-y.x)+sqr(x.y-y.y));
}
bool incircle(node x)
{
    if(dis(O,x)<=R) return true;
    return false;
}
node solve(double a,double b,double c,double d,double e,double f)
{
    double y=(f*a-c*d)/(b*d-e*a);
    double x=(f*b-c*e)/(a*e-b*d);
    return (node){x,y};
}
int main()
{
    int n;
    scanf("%d",&n);
    int i,j,k;
    for(i=1;i<=n;i++)
    scanf("%lf%lf",&b[i].x,&b[i].y);
    random_shuffle(b+1,b+n+1);
    R=0;
    for(i=1;i<=n;i++)
    if(!incircle(b[i]))
    {
        O.x=b[i].x;O.y=b[i].y;R=0;
        for(j=1;j<i;j++)
        if(!incircle(b[j]))
        {
            O.x=(b[i].x+b[j].x)/2;
            O.y=(b[i].y+b[j].y)/2;
            R=dis(O,b[i]);
            for(k=1;k<j;k++)
            if(!incircle(b[k]))
            {
                O=solve(
                b[i].x-b[j].x,b[i].y-b[j].y,(sqr(b[j].x)+sqr(b[j].y)-sqr(b[i].x)-sqr(b[i].y))/2,
                b[i].x-b[k].x,b[i].y-b[k].y,(sqr(b[k].x)+sqr(b[k].y)-sqr(b[i].x)-sqr(b[i].y))/2 
                );
                R=dis(b[i],O);
            }
        }
    }
    printf("%.10lf",R);
}

Measured memory_bytes: 256
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<double> ps(n);
    for(int i = 0; i < n; ++i) cin >> ps[i];
    // DP[i, j] [0, i) coins, j heads
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0));
    dp[0][0] = 1.0;
    for(int i = 1; i <= n; ++i) {
        double p_head = ps[i - 1], p_tail = 1 - p_head;
        for(int j = 0; j <= i; ++j) {
            dp[i][j] = dp[i - 1][j] * p_tail;
            if(j - 1 >= 0) dp[i][j] += dp[i - 1][j - 1] * p_head;
        }
    }
    // cout << dp[n][n / 2 + 1] << endl;
    double ans = 0.0;
    for(int j = n / 2 + 1; j <= n; ++j) ans += dp[n][j];
    // cout << ans << endl;
    printf("%.10lf\n", ans);
    return 0;

}



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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Nmax=114514;
vi g[Nmax];
void dfs(int v,int p,int d,vi&dst){
	dst[v]=d;
	for(auto to:g[v])if(to!=p)
		dfs(to,v,d+1,dst);
}
signed main(){
	int n=read();
	REP(i,n-1){
		int a=read()-1,b=read()-1;
		g[a].PB(b);
		g[b].PB(a);
	}
	vi a(n),b(n);
	dfs(0,-1,0,a);
	dfs(n-1,-1,0,b);
	int cnt=0;
	REP(i,n)if(a[i]<=b[i])cnt++;
	if(cnt*2>n)
		cout<<"Fennec"<<endl;
	else
		cout<<"Snuke"<<endl;
}

Measured memory_bytes: 15232
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, m, c, b[22], a, res;

signed main() {
	cin >> n >> m >> c;
	rep(i,m) cin >> b[i];
	rep(i,n) {
		int s = c;
		rep(j,m) {
			cin >> a;
			s += a * b[j];
		}
		if (s>0) res++;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#pragma region

#ifdef LOCAL
#define debug cout
#else
#define debug \
    if (0) cout
#endif

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;

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

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    solve();
}

#pragma endregion

struct block {
    int w, s;
    ll v;
    bool operator<(const block& b) const {
        return (w + s != b.w + b.s) ? (w + s < b.w + b.s) : v < b.v;
    }
};

void solve() {
    int n;
    cin >> n;
    vector<block> b(n);
    for (int i = 0; i < n; ++i) cin >> b[i].w >> b[i].s >> b[i].v;
    sort(b.begin(), b.end());
    vector<vector<ll>> dp(2e4 + 5, vector<ll>(n, 0));
    for (int t = 0; t < dp.size(); ++t) {
        dp[t][0] = (t >= b[0].w) ? b[0].v : 0;
        for (int i = 1; i < n; ++i) {
            dp[t][i] = dp[t][i - 1];
            if (t >= b[i].w) {
                dp[t][i] = max(dp[t][i], b[i].v + dp[min(b[i].s, t - b[i].w)][i - 1]);
            }
        }
    }
    cout << dp.back().back() << "\n";
}

Measured memory_bytes: 157312
#include<bits/stdc++.h>
using namespace std;
int ans1,ans2,n,a1=0,a2=0;
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;++i){
		scanf("%d",&x);
		if(!ans1)ans1=x;
		if(ans1==x)++a1;
		else{
			if(!ans2)ans2=x;
			if(ans2==x)++a2;else {puts("No");return 0;}
		}
	}
	if(abs(ans1-ans2)>1&&ans2!=0){puts("No");return 0;}
	if(ans1>ans2)swap(ans1,ans2),swap(a1,a2);
	if(ans1){n-=a1;ans2-=a1;if(ans2>0&&(n>=(ans1-a1+1)*2))puts("Yes");else puts("No");}
	else{if(n>=ans2*2||n==ans2+1)puts("Yes");else puts("No");}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

ll gcd(ll x,ll y){
    if(x<y) return gcd(y,x);
    if(y==0) return x;
    return gcd(y,x%y);
}

int main(){
    ll n,m;cin>>n>>m;
    ll a[n];
    ll b[n];
    ll g=1;
    int bol=0;
    rep(i,0,n-1){
        cin>>a[i];
        b[i]=a[i]/2;
        if(i==0){
            bol=b[i]%2;
        }else{
            if(bol!=b[i]%2){
                cout<<0<<endl;
                return 0;
            }
        }
        if(g<=10*m){
            g=(g*b[i])/gcd(g,b[i]);
        }else{
            cout<<0<<endl;
            return 0;
        }
    }
    if(bol==1){
        ll ans=(m+g)/(2*g);
        cout<<ans<<endl;
    }else{
        rep(i,0,n-1){
            if((g/b[i])%2==0){
                cout<<0<<endl;
                return 0;
            }
        }
        ll ans=(m+g)/(2*g);
        cout<<ans<<endl;
    }
    
    
    
    return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int A,B,C;
    int K;
    Scd3(A,B,C);
    Scd(K);

    int ans = 0;
    ans += min(K,A);
    K -= A;
    if( K > 0 ){
        K -= B;
    }
    if( K > 0 ){
        ans -= min(K,C);
    }

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

    return 0;
}



Measured memory_bytes: 3816
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:usize,
        ass:[usize1;n],
        bs:[i64;n],
        cs:[i64;n-1]
    }

    let mut ans = bs.iter().sum::<i64>();
    for i in 0..n - 1 {
        if ass[i] + 1 == ass[i + 1] {
            ans += cs[ass[i]];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include <stdio.h>

int main(void) {
  int a;
  int b;
  int c;
  char buf1[20];
  fgets(buf1, 20, stdin);
  sscanf(buf1, "%d" "%d"" %d" , &a, &b, &c);
  
  int d, e;
  d = b - a;
  e = c - b;
  if(d == e){
  printf("YES \n");
  }
  else{
  printf("NO \n");
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
long long k, x[50];
 
int main() {
	scanf("%lld", &k);
	printf("50\n");
	for (int i = 0; i < 50; i++)
		x[i] = 50 + k / 50;
	for (int i = 0; i < (50 - k % 50); i++)
		for (int j = 0; j < 50; j++)
			if (i == j)
				x[j] -= 50;
			else
				x[j]++;
	for (int i = 0; i < 50; i++)
		printf("%lld%c", x[i], i == 49 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int w,a,b;
    cin >> w >> a >> b;
    //処理
    //出力
    cout << max(0,max(a-b-w,b-a-w)) << ENT;
    return 0;
}

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


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

int h,w;
char s[55][55];
int map[55][55];
int main()
{
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) s[i][j]='-1';
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) map[i][j]=0;
	cin>>h>>w;
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) cin>>s[i][j];
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++)
	{
		if(s[i][j]=='#')
		{
			if(s[i-1][j-1]=='.') map[i-1][j-1]++;
			if(s[i-1][j]=='.') map[i-1][j]++;
			if(s[i-1][j+1]=='.') map[i-1][j+1]++;
			if(s[i][j-1]=='.') map[i][j-1]++;
			if(s[i][j+1]=='.') map[i][j+1]++;
			if(s[i+1][j-1]=='.') map[i+1][j-1]++;
			if(s[i+1][j]=='.') map[i+1][j]++;
			if(s[i+1][j+1]=='.') map[i+1][j+1]++;
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(s[i][j]=='.') cout<<map[i][j];
			if(s[i][j]=='#') cout<<s[i][j];
		}
		cout<<endl;
	} 
	return 0;
 } 

Measured memory_bytes: 888
from collections import deque

S = str(input())
Q = int(input())

#pop_flag = True => 正常
#pop_flag = False => 反転している
pop_flag = True
S_deque = deque(S)
for i in range(Q):
  Querie = [str(j) for j in input().split()]
# 反転させるやつ
  if Querie[0] == "1":
    if pop_flag == True:
      pop_flag = False
    elif pop_flag == False:
      pop_flag = True

# 追加するやつ
  elif Querie[0] == "2":
    if Querie[1] == "1":
      if pop_flag == True:
        S_deque.appendleft(Querie[2])
      elif pop_flag == False:
        S_deque.append(Querie[2])
    elif Querie[1] == "2":
      if pop_flag == True:
        S_deque.append(Querie[2])
      elif pop_flag == False:
        S_deque.appendleft(Querie[2])

if pop_flag == False:
  S_deque.reverse()

ans = ''.join(S_deque)

print(ans)


Measured memory_bytes: 8564
#include <stdio.h>

int main()
{
    int N;
    int times[]={1,2,4,8,16,32,64};
    int answer;

    scanf("%d\n",&N);

    if(N<2){
        answer=times[0];
    }
    else if(N<4){
        answer=times[1];
    }
    else if(N<8){
        answer=times[2];
    }
    else if(N<16){
        answer=times[3];
    }
    else if(N<32){
        answer=times[4];
    }
    else if(N<64){
        answer=times[5];
    }
    else{
        answer=times[6];
    }

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

    return 0;
}

Measured memory_bytes: 128
unittest
{
	assert( [ "4 5", "1 2", "3 4", "1 3", "2 3", "1 4" ].parse.expand.solve == "0\n0\n4\n5\n6" );
	assert( [ "6 5", "2 3", "1 2", "5 6", "3 4", "4 5" ].parse.expand.solve == "8\n9\n12\n14\n15" );
	assert( [ "2 1", "1 2" ].parse.expand.solve == "1" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto abs = new long[][]( nm[ 1 ], 2 );
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	return tuple( nm[ 0 ], abs );
}

auto solve( long n, long[][] abs )
{
	// 不便さの最大値を計算
	auto f = n * ( n - 1 ) / 2;		// nC2をそのまま計算するとオーバーフローするので式変形した結果が左のやつ
	
	// 橋が崩落するときの不便さの増加を逆順で考えて、橋を架けるときの不便さの減少として計算
	auto anss = new long[]( abs.length );
	auto uft = UnionFind( n );
	for( auto i = anss.length.signed - 1; 0 <= i; i-- )
	{
		anss[ i ] = f;
		
		auto a = abs[ i ][ 0 ] - 1;
		auto b = abs[ i ][ 1 ] - 1;
		if( uft.same( a, b ) ) continue;
		
		// 橋を架けて不便さを減らす
		auto ac = uft.count( a );
		auto bc = uft.count( b );
		uft.unite( a, b );
		f -= ac * bc;
	}
	return anss.to!( string[] ).join( "\n" );
}

// UnionFind木
struct UnionFind
{
	private long[] ps;
	
	public this( long n )
	{
		ps = new long[]( n );
		ps[] = -1;		// マイナスは根であり、その木に属するノードの数でもある
	}
	
	public long root( long x )
	{
		return ( ps[ x ] < 0 ) ? x : ( ps[ x ] = root( ps[ x ] ) );
	}
	
	public bool same( long x, long y )
	{
		return root( x ) == root( y );
	}
	
	public void unite( long x, long y )
	{
		x = root( x );
		y = root( y );
		if( x == y ) return;
		if( ps[ x ] < ps[ y ] ){ ps[ x ] += ps[ y ]; ps[ y ] = x; }
		else                   { ps[ y ] += ps[ x ]; ps[ x ] = y; }
	}
	
	public long count( long x )
	{
		return -ps[ root( x ) ];
	}
}


Measured memory_bytes: 28156
#include <bits/stdc++.h>
#include <string.h>
#include <algorithm> 
#include<vector>
#include<map>
#define ll long long int
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    ll i;
    cin>>s;
    for(i=0;s[i]!='\0';i++)
    {
    	if(s[i]=='R'&&s[i-1]=='A'&&s[i+1]=='C')
    	{
    		cout<<"B";
		}
	else if (s[i]=='B'&&s[i-1]=='A'&&s[i+1]=='C')
    	{
    		cout<<"R";
    	}
    	
		
		else
		{
			cout<<s[i];
		}}
	}

Measured memory_bytes: 3608
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

r = inp()
ans = r**2
print(ans)

Measured memory_bytes: 21884
#include<iostream>
using namespace std;
int main(){
	int n,x[3]={},ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		ans=0;
		for(int j=0;j<3;j++)
		cin>>x[j];
		while(x[0]>=1 && x[1]>=1 && x[2]>=1){
			ans++;
			x[0]--;
			x[1]--;
			x[2]--;
		}
		while(x[0]>=2 && x[1]>=1){
			ans++;
			x[0]-=2;
			x[1]--;
		}
		while(x[0]>=3){
			ans++;
			x[0]-=3;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
sumA = sum(a)

sumBy4 = sumA/(4*m)

count = 0

for i in range(n):
    if(a[i] < sumBy4):
        continue

    else:
        count += 1

if(count >= m):
    print("Yes")

else:
    print("No")

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

using namespace std;

bool check(int x) {
  int ans = 0;
  while (x > 0)
    x /= 10, ++ans;
  return (ans & 1) == 1;
}

int main(void) {
  int n;
  scanf("%d", &n);
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    ans += check(i);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Int
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import Data.Array.IO

exEuclid :: (Eq a, Integral a) => a -> a -> (a, a, a)
exEuclid !f !g = loop 1 0 0 1 f g
  where loop !u0 !u1 !v0 !v1 !f 0 = (f, u0, v0)
        loop !u0 !u1 !v0 !v1 !f g =
          case divMod f g of
            (q,r) -> loop u1 (u0 - q * u1) v1 (v0 - q * v1) g r

modulo = 10^9+7 :: Int64
addMod, subMod, mulMod, divM :: Int64 -> Int64 -> Int64
addMod !x !y = (x + y) `rem` modulo
subMod !x !y = (x - y) `mod` modulo
mulMod !x !y = (x * y) `rem` modulo
recipM :: Int64 -> Int64
recipM !x = case exEuclid x modulo of
             (1,a,_) -> a `mod` modulo
             (-1,a,_) -> (-a) `mod` modulo
divM !x !y = x `mulMod` recipM y

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  N x + N y = N ((x + y) `rem` modulo)
  N x - N y = N ((x - y) `mod` modulo)
  N x * N y = N ((x * y) `rem` modulo)
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined

instance Fractional N where
  N x / N y = N (divM x y)
  recip (N x) = N (recipM x)
  fromRational = undefined

-- binomColumn j !! k == binom k j
binomColumn :: Fractional a => Int -> [a]
binomColumn !j = replicate j 0 ++ (1 : loop 1 (j+1))
  where loop !x !k = let !y = x * fromIntegral k / fromIntegral (k - j)
                     in y : loop y (k + 1)

-- tweakedBinomColumn j !! k == binom k j * (1/2)^(k+2)
tweakedBinomColumn :: Fractional a => Int -> [a]
tweakedBinomColumn !j = replicate j 0 ++ (half^(j+2) : loop (half^(j+2)) (j+1))
  where loop !x !k = let !y = x * fromIntegral k / (2 * (fromIntegral $ k - j))
                     in y : loop y (k + 1)
        half = 1/2

main = do
  [b,w] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  let half = 1 / 2 :: N
      minBW = min b w
  let solution = scanl (\x (y,z) -> x + y - z) half (zip (tweakedBinomColumn (w-1)) (tweakedBinomColumn (b-1)))
  forM_ (take (b + w) solution) $ \x -> do
    print $ unwrapN x


Measured memory_bytes: 3964
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;







int main(){

    int x;
    cin >> x;

    int a, b;

    int delta;

    for(delta = 1; delta <= 100000; delta++){
        for(a = -118; a <= 119; a++){
            b = a - delta;
            if(a*a*a*a*a - b*b*b*b*b == x){

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

  
}

Measured memory_bytes: 3752
A,B=map(int,input().split())
N=min(A,B)
i=X=0

for i in range(N+1,1,-1):
  if A%i==0 and B%i==0:
    X=round(A*B/i)
    break
  else:
    X=round(A*B)

print(X)

Measured memory_bytes: 2940
x=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    divisors.sort()
    return divisors
    
a=make_divisors(x)

for i in range(len(a)):
    if a[i]>=x**0.5:
        y=str(a[i])
        print(len(y))
        exit()

    

    
    
    





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

using namespace std;

int BestPrice(int a, int b, int c, int x, int y) {
    int res = x * a + y * b;
    if (a + b > 2 * c) {
        int m = min(x, y);
        x -= m;
        y -= m;
        int res2 = 2 * m * c + x * a + y * b;
        cerr << res << "\n";
        cerr << res2 << "\n";
        if (a > 2*c) {
            res2 -= x * (a - 2*c);
        }
        if (b > 2*c) {
            res2 -= y * (b - 2*c);
        }
        res = min(res, res2);
    }

    return res;
}

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

    cin >> a >> b >> c >> x >> y;
    cout << BestPrice(a, b, c, x, y) << "\n";;
    return 0;
}

Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int n, w;
ll wts[100001], val[100001], dp[101][100001];

ll recur(int pos, ll lft) {
	if(lft < 0) return -1;
	if(pos == n) return 0;
	if(dp[pos][lft] != -2) return dp[pos][lft];
	dp[pos][lft] = recur(pos+1, lft);
	ll res = recur(pos+1, lft-wts[pos]);
	if(res != -1) dp[pos][lft] = max(dp[pos][lft], val[pos]+res);
	return dp[pos][lft];
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> w;
	forl(i, 0, n) cin >> wts[i] >> val[i];
	forl(i, 0, 101) forl(j, 0, 100001) dp[i][j] = -2;
	println(recur(0, w));
}


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

int main() {
  int N;
  double denominator=0;
  cin >> N;
  vector<double> A(N);
  for (int i=0; i<N; i++) {
    cin >> A.at(i);
    A.at(i) = 1/A.at(i);
  }
  for (int i=0; i<N; i++) {
    denominator += A.at(i);
  }
  cout << (1/denominator) << endl;
}

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    string N;
    cin >> N;

    string ans = (N[0] == '7' || N[1] == '7' || N[2] == '7') ? "Yes" : "No";
    cout << ans << endl;
}

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


Measured memory_bytes: 3672
N = int(input())
A = list(map(int,input().split()))
count_plus=0
count_minus=0
sum_all = 0

for i in range(N):
    if A[i] < 0:
        count_minus += 1
        
    A[i] = abs(A[i])
    sum_all = sum_all + A[i]

if count_minus % 2 == 0:
    print(sum_all)
else:
    print(sum_all - (min(A)*2))


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

#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a)		cerr << #a << ": "; for (int& x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, n, m) for (int i = 0; i < n; i++, cout << endl)           \
						for (int j = 0; j < m; j++) cout << a[i][j] << ' ';

#define int long long

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

int32_t main()
{
	int n;
	cin >> n;
	
	vvi adj(n);
	
	vii input;
	for (int i = 0; i < n-1; i++) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		input.push_back(make_pair(u, v));
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	int k = 0;
	for (int i = 0; i < (int)adj.size(); i++)
		k = max((int)adj[i].size(), k);
	
	vi ans;
	
	vi color(n);
	
	queue<int> q;
	q.push(0);
	vector<bool> used(n, false);
	used[0] = true;
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		
		int uc = color[v];
		int c = 1;
		for (int u: adj[v]) {
			if (!used[u]) {
				if (c == uc) c++;
				color[u] = c;
				q.push(u);
				used[u] = true;
				c++;
			}
		}
	}
	
	for (int i = 0; i < (int)input.size(); i++) {
		ans.push_back(color[input[i].second]);
	}
	
	cout << k << endl;
	for (int i = 0; i < (int)ans.size(); i++) {
		cout << ans[i] << endl;
	}
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 10736
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
#A = np.random.randint(1, 1000000000, size=(N))
#print(A)
cnt = 0
B = 0
for i in range(len(A)):
    if B < A[i]:
        B = A[i]
    elif B > A[i]:
        cnt += (B - A[i])

print(cnt)

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

using namespace std;

const int MAXN = 1e5 + 10;

int n, m, sec[MAXN], sz;
bool vis[MAXN];
vector<int> adj[MAXN];

void dfs(int v){
	if (!vis[v])
		sec[sz++] = v;
	vis[v] = 1;
	for (int u:adj[v])
		if (!vis[u]){
			dfs(u);
			break;
		}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	while (m--){
		int u, v;	cin >> u >> v, u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	dfs(0);
	reverse(sec, sec + sz);
	dfs(0);

	cout << sz << "\n";
	for (int i = 0; i < sz; i++)
		cout << sec[i]+1 << " ";
	cout << "\n";
	return 0;
}


Measured memory_bytes: 6784
//om namah shivaaay//
#include <bits/stdc++.h>
#define input int t;cin>>t;while(t--)
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout.precision(10)
 #define ll long long
 #define vi  vector<int>vec
 #define pb push_back
 #define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
 #define f(i, a, b) for (int i = 0; i < (b); i++)
 #define w(t) int t;cin>>t;while(t --)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
 const int N=1e5 +5;
 using namespace std;
 int main()
 {
    Om_namah_Shivaay;
    int n;
 cin >> n;
 cout << (1000-n%1000)%1000 << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
   ll h;
   cin >> h;
   ll ans = 0;
   ll foo = 0;
   while(h>0)
   {
      ans += (1LL<<foo);
      h/=2;
      foo++;
      //cout<<ans<<endl;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace EDPC
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);

            input = Console.ReadLine().Split(' ');

            // initialize
            int[] h = new int[N];
            for (int i = 0; i < N; i++)
            {
                h[i] = int.Parse(input[i]);
            }

            long H = int.MaxValue;
            long[] dp = new long[N];
            for (int i = 0; i < N; i++)
            {
                dp[i] = H;
            }
            //var dp = Enumerable.Repeat(int.MaxValue, N).ToArray();

            // Main processing
            dp[0] = 0;
            for (int i = 1; i < N; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    if (j <= i)
                    {
                        dp[i] = Math.Min(dp[i], dp[i - j] + Math.Abs(h[i] - h[i - j]));
                    }
                }
            }
            Console.WriteLine(dp[N - 1]);
        }
    }
}


Measured memory_bytes: 19680
N,D = map(int, input().split())
X = [list(map(int,input().split())) for i in range(N)]
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for k in range(D):
            tmp += (X[i][k]-X[j][k])**2
        if (tmp**0.5)%1 == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int x,y;
	do{
		scanf("%d %d", &x, &y);
		if (x != 0 || y != 0){
			if (x <= y)
				printf("%d %d\n", x, y);
			else
				printf("%d %d\n", y, x);
		}
	} while (x != 0 || y != 0);
	

	return 0;
}

Measured memory_bytes: 1024
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)

struct cmp
{
    template <typename T, typename U>
    bool operator()(T const &left, U const &right)
    {
        if (left.second > right.second)
            return true;
        return false;
    }
};

int edgeTo[100000 + 5];
int distTo[100000 + 5];
set<pair<int, int>> pq;
void relax(int from, int to, int weight)
{
    if (distTo[to] > distTo[from] + weight)
    {
        pair<int, int> backup = {to, distTo[to]};
        distTo[to] = distTo[from] + weight;
        edgeTo[to] = from;
        if (pq.find(backup) != pq.end())
        {
            pq.erase(backup);
            pq.insert({to, distTo[to]});
        }
        else
        {
            pq.insert({to, distTo[to]});
        }
    }
}

void dijsktra(vector<vector<pair<int, int>>> g, int s)
{
    int n = g.size();
    for (int i = 0; i < n + 1; i++)
    {
        distTo[i] = 2147483647;
    }

    distTo[s] = 0;
    pq.insert({s, 0});
    while (!pq.empty())
    {
        auto it = pq.end();
        it--;
        pair<int, int> top = *it;
        pq.erase(*it);
        for (pair<int, int> e : g[top.first])
        {
            relax(top.first, e.first, e.second);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> graph(n + 1);
    rep(i, 1, m + 1)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back({b, 1});
        graph[b].push_back({a, 1});
    }
    dijsktra(graph, 1);

    cout << "Yes" << endl;
    rep(i, 2, n + 1)
    {
        cout << edgeTo[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 23172
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

#define FORR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)

template <typename T, typename U>
inline auto update_max (T & x, U && y) noexcept
{
  return x < y ? static_cast <void> (x = forward <U> (y)), true : false;
}
template <typename T, typename U>
inline auto update_min (T & x, U && y) noexcept
{
  return x > y ? static_cast <void> (x = forward <U> (y)), true : false;
}


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

  size_t n;
  cin >> n;
  string s;
  cin >> s;
  vector <vector <size_t>> dp (n, vector <size_t> (n, 0));
  size_t ans = 0;

  FORR (i, 0, n) FORR (j, 0, n)
  {
    if (s [i] == s [j])
    {
      dp [i] [j] = 1;
      if (i + 1 < n && j + 1 < n)
      {
        dp [i] [j] += dp [i + 1] [j + 1];
      }
      update_min (dp [i] [j], static_cast <size_t> (abs (static_cast <ll> (j) - static_cast <ll> (i))));
      update_min (dp [i] [j], n - j - 1);
      update_max (ans, dp [i] [j]);
    }
    else
    {
      dp [i] [j] = 0;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 195840
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;
    int a[10];
    a[0]=A+B;
    a[1]=A-B;
    a[2]=A*B;
    sort(a,a+3);
    cout<<a[2]<<endl;
    //printf("The largest number among A+B=%d,A-B=%d,and AxB=%d is %d\n",A+B,A-B,A*B,a[2]);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,X,Y,Z;
int nxt[200005][12],Ncnt,pre[200005],dp[2][40000][2];
bool ed[200005];
vector<vector<int> > line[3],all;
vector<int> t;
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void getline(int id,int x) {
    if(!x) {
	line[id].pb(t);
	return;
    }
    for(int i = 1 ; i <= x ; ++i) {
	t.pb(i);
	getline(id,x - i);
	t.pop_back();
    }
}
void Append(int id,vector<int> b = {}) {
    if(id >= 3) {
	all.pb(b);
	return;
    }
    for(auto a : line[id]) {
	vector<int> c = b;
	c.insert(c.end(),a.begin(),a.end());
	Append(id + 1,c);
    }
}
void Insert(vector<int> s) {
    int p = 1;
    for(auto t : s) {
	if(!nxt[p][t]) {
	    nxt[p][t] = ++Ncnt;
	}
	p = nxt[p][t];
    }
    ed[p] = 1;
}
queue<int> Q;
void build_ACAM() {
    for(int i = 1 ; i <= 10 ; ++i) nxt[0][i] = 1;
    pre[1] = 0;
    Q.push(1);
    while(!Q.empty()) {
	int u = Q.front();Q.pop();
	for(int i = 1 ; i <= 10 ; ++i) {
	    if(nxt[u][i]) {
		Q.push(nxt[u][i]);
		pre[nxt[u][i]] = nxt[pre[u]][i];
	    }
	    else nxt[u][i] = nxt[pre[u]][i];
	}
    }
}
void Solve() {
    read(N);read(X);read(Y);read(Z);
    getline(0,X);getline(1,Y);getline(2,Z);
    Append(0);
    Ncnt = 1;
    for(auto k : all) {
	Insert(k);
    }
    build_ACAM();
    int cur = 0;dp[0][1][0] = 1;
    for(int i = 1 ; i <= N ; ++i) {
	memset(dp[cur ^ 1],0,sizeof(dp[cur ^ 1]));
	for(int u = 1 ; u <= Ncnt ; ++u) {
	    for(int k = 0 ; k <= 1 ; ++k) {
		for(int h = 1 ; h <= 10 ; ++h) {
		    update(dp[cur ^ 1][nxt[u][h]][k | ed[nxt[u][h]]],dp[cur][u][k]);
		}
	    }
	}
	cur ^= 1;
    }
    int ans = 0;
    for(int u = 1 ; u <= Ncnt ; ++u) {
	update(ans,dp[cur][u][1]);
    }
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

using namespace std;
typedef long long ll;




int main()
{
    int R;
    cin >> R;
    if(R>=2800) cout << "AGC" << endl;
    else if(R>=1200) cout << "ARC" << endl;
    else cout << "ABC" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7, inf = 2e18;
ll n, a, b, x[100005], za, zb;
vector<ll> ca, cb;

ll getA (ll X) {
	if(X < za) return 0;
	if(za) return (ca[X] - ca[za-1] + mod) % mod;
	return ca[X];
}

ll getB (ll X) {
	if(X < zb) return 0;
	if(zb) return (cb[X] - cb[zb-1] + mod) % mod;
	return cb[X];
}

int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	for(int i=1;i<=n;i++) {
		scanf("%lld",&x[i]);
	}
	x[0] = -inf;
	ca.push_back(1);
	cb.push_back(1);
	for(int i=2;i<=n;i++) {
		ll fa = min(upper_bound(x, x+n+1, x[i]-a) - x - 1ll, i - 2ll);
		ll fb = min(upper_bound(x, x+n+1, x[i]-b) - x - 1ll, i - 2ll);
		ca.push_back((getB(fb)+ca.back())%mod);
		cb.push_back((getA(fa)+cb.back())%mod);
		if(x[i-1] + a > x[i]) zb = i-1;
		if(x[i-1] + b > x[i]) za = i-1;
	}
	printf("%lld\n",(getA(n-1)+getB(n-1)) % mod);
}


Measured memory_bytes: 2932
n = input()
a_list = [int(num) for num in input().split()]

alice = 0
bob = 0

while True:
  if len(a_list) < 1:
    break
  next_num = max(a_list)
  alice += next_num
  a_list.remove(next_num)
  if len(a_list) < 1:
    break
  next_num = max(a_list)
  bob += next_num
  a_list.remove(next_num)

print(alice - bob)

Measured memory_bytes: 3064
#include <cstdio>

const int MAXN=1e5+5;
char s[MAXN];

int main(){
	int n;
	scanf("%d%s",&n,s);
	int ans=0;
	char pre='\0';
	for(int i=0;i<n;++i){
		ans+=(pre!=s[i]);
		pre=s[i];
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int N,ans,a,n;
	ans = 0;
	scanf("%d", &N);
	n = N;
	while (N) {
		a = N  % 10;
		ans += a;
		N= N / 10;
	}
	//printf("N=%dans=%d(n/ans)=%d", n, ans,n/ans);
	if ((n%ans) == 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

}

Measured memory_bytes: 128