akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int sum(ll x)
{
    int ans=0;
    while(x)
        ans+=x%10,x/=10;
    return ans;
}
int main()
{
    int k;scanf("%d",&k);
    ll ans=1,add=1;
    while(k--)
    {
        printf("%lld\n",ans);
        ll s1=ans+add,s2=ans+add*10;
        if(s1*sum(s2)>s2*sum(s1))
        {
            add*=10;
            ans=s2;
        }
        else ans=s1;
    }
    //for(int i=1;i<=1000;i++)
    //    if(1.0*i/sum(i)<1.0*(i+1)/sum(i+1))
    //    cout<<i<<' '<<1.0*i/sum(i)<<endl;
    return 0;

}
/*
9 1
19 1.9
29 2.63636
39 3.25
49 3.76923
59 4.21429
69 4.6
79 4.9375
89 5.23529
99 5.5
109 10.9

119 10.8182
129 10.75
139 10.6923
149 10.6429
159 10.6
169 10.5625
179 10.5294
189 10.5
199 10.4737

209 19
219 18.25
229 17.6154
239 17.0714
249 16.6
259 16.1875
269 15.8235
279 15.5
289 15.2105
299 14.95

309 25.75
319 24.5385
329 23.5
339 22.6
349 21.8125
359 21.1176
369 20.5
379 19.9474
389 19.45
399 19

409 31.4615
419 29.9286
429 28.6
439 27.4375
449 26.4118
459 25.5
469 24.6842
479 23.95
489 23.2857
499 22.6818
509 36.3571
519 34.6
529 33.0625
539 31.7059
549 30.5
559 29.4211
569 28.45
579 27.5714
589 26.7727
599 26.0435
609 40.6
619 38.6875
629 37
639 35.5
649 34.1579
659 32.95
669 31.8571
679 30.8636
689 29.9565
699 29.125
709 44.3125
719 42.2941
729 40.5
739 38.8947
749 37.45
759 36.1429
769 34.9545
779 33.8696
789 32.875
799 31.96
809 47.5882
819 45.5
829 43.6316
839 41.95
849 40.4286
859 39.0455
869 37.7826
879 36.625
889 35.56
899 34.5769
909 50.5
919 48.3684
929 46.45
939 44.7143
949 43.1364
959 41.6957
969 40.375
979 39.16
989 38.0385
999 37
*/


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    vector<ll> x(5);
    rep(i, 5) cin >> x[i];

    rep(i, 5) {
        if (x[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3520
/*+__+ zhopa:skoro respa(*/
    /*sps bfsu za rabotu-pishi bfs s used i obnovlyai v nem srazu*/
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ld long double
#define pui pair<ui,ui>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define sqr(x) (x)*(x)
#define pw(x) (1ui << x)
#define sz(x) (int)x.size()
#define endl "\n"
#define len(a) a.length()
#define rep(x,l,r) for(ui x=l;x<r;x++)
using namespace std;
const ll N=2*1e5;
vector<ll>g[N];
ll dp[N];
ll mx=LLONG_MIN;
ll used[N];
void dfs(ll v){
    used[v]=1;
    for(auto z : g[v]){
        if(!used[z]){
            dfs(z);
        }
                dp[v]=max(dp[v],dp[z]+1);
    }
    mx=max(mx,dp[v]);
}
signed main(){
    fast_io;
    ll n,m;
    cin>>n>>m;
    ll v,u;
    for(ll i=0;i<m;i++){
        cin>>v>>u;
        --v;--u;
        g[v].p_b(u);
    }
    for(ll i=0;i<n;i++){
        if(!used[i]){
            dfs(i);
        }
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 12416
n=int(input())
a=list()
for i in range(n):
    x,y=input().split()
    y=int(y)
    if x=='S':
        a.append(y+0)
    if x=='H':
        a.append(y+13)
    if x=='C':
        a.append(y+26)
    if x=='D':
        a.append(y+39)
for i in range(1,53):
    if not (i in a):
        if i<=13:
            print("S {}".format(i-0))
        elif i<=26:
            print("H {}".format(i-13))
        elif i<=39:
            print("C {}".format(i-26))
        else:
            print("D {}".format(i-39))


Measured memory_bytes: 5596
#[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)*}
    };
}

#[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, 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")
    };
}

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut tbl = vec![vec![None; n + 1]; n + 1];
    let ans = rec(0, n - 1, &a, &mut tbl);
    println!("{}", ans);
}

fn rec(l: usize, r: usize, a: &[i64], tbl: &mut [Vec<Option<i64>>]) -> i64 {
    if l == r {
        return a[l];
    }

    if tbl[l][r].is_some() {
        return tbl[l][r].unwrap();
    }

    let mut ret = -rec(l + 1, r, a, tbl) + a[l];
    ret = max(ret, -rec(l, r - 1, a, tbl) + a[r]);

    tbl[l][r] = Some(ret);
    return ret;
}


Measured memory_bytes: 166268
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n; cin >>n;
  li p=0,m=0,f=1,pc=0,mc=0;
  rep(i,n){
    li a; cin >>a;
    if(f){         // S>0 in p
      p+=a;
      if(p<=0){
        pc-=p-1;
        p=1;
      }
      m+=a;
      if(m>=0){
        mc+=m+1;
        m=-1;
      }
    }else{
      p+=a;
      if(p>=0){
        pc+=p+1;
        p=-1;
      }
      m+=a;
      if(m<=0){
        mc-=m-1;
        m=1;
      }
    }
    f^=1;
  }
  print(min(pc,mc));
}


Measured memory_bytes: 256
def main():
    n, y = map(int, input().split())
    ans = [-1, -1, -1]
    for i in range(n+1):
        for j in range(n-i+1):
            if 10000*i+5000*j+1000*(n-i-j) == y:
                ans = [i, j, n-i-j]
    print(*ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head
char s[11][1010];
int main(void){
    int h,w,k,ans=INF;
    cin>>h>>w>>k;
    rep(i,0,h)cin>>s[i];
    per(i,0,1<<h){
        int sum[11]={0};
        VI v;
        v.eb(0);
        int tmp=i,cnt=0;
        while(tmp){
            ++cnt;
            if(tmp&1){
                v.eb(cnt);
            }
            tmp>>=1;
        }
        v.eb(h);
        /*for(auto j:v)cout<<j<<' ';
        cout<<endl;*/
        cnt=v.size()-2;
        if(cnt>=ans)continue;
        bool flag=1;
        rep(j,0,w){
            if(!flag)break;
            if(cnt>ans)break;
            rep(l,0,v.size()-1){
                int now=0;
                rep(o,v[l],v[l+1]){
                    sum[l]+=s[o][j]-'0';
                    now+=s[o][j]-'0';
                }
                if(now>k){
                    flag=0;
                    break;
                }
                if(sum[l]>k){
                    ++cnt;
                    --j;
                    MEM(sum,0);
                    break;
                }
            }
        }
        if(!flag)cnt=INF;
        ans=min(ans,cnt);
        //cout<<ans<<" "<<endl;
        
    }
    cout<<ans;
    return 0;
}
/*4 10 4
111 001 0010

100 010 1110
001 110 1001
110 100 0111*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 


int main()
{
    long N,K;
    std::cin >> N >> K;
    N=N%K;
    long temp=N-K;
    if(N-K<0){
        temp=temp*(-1);
    }
    std::cout << std::min(N,temp) << std::endl;
    return 0;
}

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

int main(){
	int n, m, t;
	char o;
	
	while(1){
		int a[30][30] = {}, x, y, gx = 10, gy = 10, count = 0;
		cin>>n;
		
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			cin>>x>>y;
			a[y][x] = 1;
		}
		cin>>m;
		for(int i = 0;i < m; i++){
			cin>>o>>t;
			
			if(o == 'N'){
				for(int i = 0; i <= t; i++)a[gy+i][gx] = 0;
				gy += t;
			}if(o == 'S'){
				for(int i = 0; i <= t; i++)a[gy-i][gx] = 0;
				gy -= t;
			}if(o == 'E'){
				for(int i = 0; i <= t; i++)a[gy][gx+i] = 0;
				gx += t;
			}if(o == 'W'){
				for(int i = 0; i <= t; i++)a[gy][gx-i] = 0;
				gx -= t;
			}
		}
		for(int i = 0; i <= 20; i++){
			for(int j = 0; j <= 20; j++){
				if(a[i][j] == 1)count++;
			}
		}
		if(count == 0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3044
x,n = map(int,input().split())
l = [int(x) for x in input().split()]
mp = [False]*101
for i in range(n):
    mp[l[i]] = True

#xがリストになければ
if(mp[x]==False):
    print(x)
    exit()

#xより小さい整数 (x-1)から0まで
for i in range(x-1,-1,-1):
    if(i==0):
        bottom_savei = 0
        bottom_abs = abs(x) 
        break
    if(mp[i]==False):
        bottom_savei = i
        bottom_abs = abs(x-i)
        break

#xより大きい整数 (x+1)から101まで
for i in range(x+1,102):
    if(i==101):
        top_savei = 101
        top_abs = abs(101 - x)
        break
    if(mp[i]==False):
        top_savei = i
        top_abs = abs(x-i)
        break
    
if(bottom_abs <= top_abs):
    print(bottom_savei)
else:
    print(top_savei)


Measured memory_bytes: 9128
#include<iostream>
#include<string>

using namespace std;

int main(){

    string str;
    getline(cin, str);

    if(str[0]=='A' && str[1]=='A' && str[2]=='A'){
        cout<<"No";
        return 0;
    }
    if(str[0]=='B' && str[1]=='B' && str[2]=='B'){
        cout<<"No";
        return 0;
    }

    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define cBits(x) __builtin_popcount(x)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) a/gcd(a,b)*b
#define FOR(i,a,b) for (int i=a;i<b;i++)
#define FORr(i,a,b) for (int i=a;i>=b;i--)
#define MAX3(a,b,c) max(a,max(b,c))
#define MIN3(a,b,c) min(a,min(b,c))
#define eachTest int t; cin >> t; while(t--) solve();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;

const int MOD=1000000007;

void solve() {
	;
}

int main() {

	fastio;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	// eachTest

	int n, k;
	cin >> n >> k;
	vector <int> arr(n+1);
	FOR(i,1,n+1) {
		cin >> arr[i];
	}

	// int table[k+1][n+1];
	// FOR(i,0,n+1) {
	// 	table[0][i] = 0;
	// }
	// FOR(i,1,k+1) {
	// 	// given i number of stones

	// }

	int table[k+1];
	table[0] = 0;
	FOR(i,1,k+1) {
		table[i] = 0;
		FOR(j,1,n+1) {
			if (i-arr[j] == 0) {
				table[i] = 1;
				break;
			}
			if (i-arr[j] >= 0 && table[i-arr[j]]==0) {
				table[i] = 1;
				break;
			}
		}
	}

	if (table[k] == 1) {
		cout << "First\n";
	}
	else {
		cout << "Second\n";
	}


	return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<string, int> P;
typedef vector<vector<int>> Graph;

const double PI = 3.14159265358979323846;

const int mod = 1000000007;

int main(int argc, char *args[]) {
	int n, a, b;
	cin >> a >> b;
	n = (100 * 100 + 1) / 8;
	for (int i = 1; i <= n; i++) {
		int dmy_a = i * 0.08;
		int dmy_b = i * 0.1;
		//cout << dmy_a << " " << dmy_b << endl;
		if (dmy_a == a && dmy_b == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=map(int,input().split())
tree = UnionFind(n)
for _ in range(m):
    x,y,z=map(int,input().split())
    tree.union(x-1,y-1)
print(tree.group_count())

Measured memory_bytes: 7860
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int M = max({A, B, C});
    cout << A + B + C - M + M * pow(2, K) << endl;
    return 0;
}


Measured memory_bytes: 512
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

tmp = n
ans = 0
for i in A:
    ans += B[i - 1]
    if tmp + 1 == i - 1:
        ans += C[tmp]
    #print('ans :', end = ' ')
    #print(ans)
    tmp = i - 1
    #print('tmp :', end = ' ')
    #print(tmp)
print(ans)

Measured memory_bytes: 3060
#include<limits>
using ll=long long;constexpr int INF=std::numeric_limits<int>::max()/2;constexpr ll LNF=std::numeric_limits<ll>::max()/2;constexpr double EPS=1e-8;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};
#ifdef PA_DEBUG
#define PD(stmt)stmt
#else
#define PD(stmt)
#endif
#include<iostream>
#include<vector>
namespace pcl{namespace utility{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}}using namespace pcl::utility;
#include<bits/stdc++.h>
using namespace std;int main(){int N,C;cin>>N>>C;vector<vector<int>>strange(C,vector<int>(C));cin>>strange;vector<vector<int>>brd(N,vector<int>(N));for(int i=0;i<N;i++){for(int j=0;j<N;j++){cin>>brd[i][j];brd[i][j]--;}}vector<vector<int>>cost(3,vector<int>(C));for(int i=0;i<N;i++){for(int j=0;j<N;j++){int kind=((i+1)+(j+1))%3;for(int c=0;c<C;c++){cost[kind][c]+=strange[brd[i][j]][c];}}}int mi=INF;for(int i=0;i<C;i++){for(int j=0;j<C;j++){if(i==j)continue;for(int k=0;k<C;k++){if(i==k||j==k)continue;mi=min(mi,cost[0][i]+cost[1][j]+cost[2][k]);}}}cout<<mi<<endl;}

Measured memory_bytes: 1280
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
#include <deque>
#include <map>
#include <queue>
#include <stack>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i) {
		cout << 'x';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll intpow_mod(ll N, ll P,ll K){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2)%K;
        return t*t%K;
    }
    return N * intpow(N, P-1)%K;
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
ll cnt[60];
ll K=1000000007;
int main(){
    rep(i,60)cnt[i]=0;
    ll n;cin>>n;
    ll d=1;
    rep(i,n){
        ll a;cin>>a;
        rep(j,60)cnt[j]+=(a&(d<<j))>>j;
    }
    ll sum = 0;
    rep(i,60)sum = (sum + (cnt[i]*(n-cnt[i])%K)*intpow_mod(2,i,K))%K;
    cout <<sum<<endl;
}

Measured memory_bytes: 256
#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()
using ll = long long;
using P = pair<int, int>;

ll X, Y, A, B, C;
vector<ll> p(100005), q(100005), r(100005);
int main(){
    cin >> X >> Y >> A >> B >> C;
    rep(i, A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) cin >> r[i];
    sort(p.begin(), p.begin()+A, greater<>());
    sort(q.begin(), q.begin()+B, greater<>());
    sort(r.begin(), r.begin()+C, greater<>());
    vector<ll> s(X+Y);
    rep(i, X) s[i] = p[i];
    rep(i, Y) s[X+i] = q[i];
    rep(i, C) s.push_back(r[i]);
    sort(s.begin(), s.begin()+s.size(), greater<>());
    ll ans = 0;
    rep(i, X+Y) {
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
   int N;
   int i,j;
   int min, max, sub;
   int A[N];

   scanf("%d", &N);
   for(int i = 0; i < N; i++) {
      scanf("%d", &A[i]);
   }

   min = A[0];
   max = A[0];
   for (i = 0; i < N; i++) {
      if (A[i] > max) {
         max = A[i];
      } else if(A[i] < min) {
         min = A[i];
      }
   }
   sub = max -min;
   printf("%d\n", sub);

   return 0;
}

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

typedef long long ll;

int n,h,w;
int H,W;
int main()
{
    cin>>n>>H>>W;
    int ans=0;
    for(int i=0;i<n;i++){
        scanf("%d%d",&h,&w);
        if(H<=h&&W<=w)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	vector<int>v(999999,0);
	cin >> n;
	for (int i = 1; i <= 100; i++)
		for (int j = 1; j <= 100; j++)
			for (int k = 1; k <= 100; k++)
				v[(pow((i + j), 2) + pow((k + j), 2) + pow((i + k), 2)) / 2]++;
	for (int i = 1; i <= n; i++)
		cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 6984
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int N;
vector<int> G[MAXN];

void work(){
    scanf("%d",&N);
    for(int i=1;i<N;i++){
        int p; scanf("%d",&p);
        G[p].push_back(i);
    }
    for(int i=1;i<=N;i++){
        printf("%d\n",G[i].size());
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}





Measured memory_bytes: 14696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = INT_MAX / 2;

int main() {
    using P = pair<int,int>;
    int N, M; cin >> N >> M;
    set<P> s;
    vector<vector<P>> G(N);
    vector<tuple<int, int, int>> w;
    vector<bool> check(M, false);
    for (int i = 0; i < M; i++)
    {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        w.push_back(make_tuple(a, b, c));
        G[a].push_back(make_pair(c, b));
        G[b].push_back(make_pair(c, a));
    }
    
    for (int i = 0; i < N; i++)
    {
        vector<int> dist(N, INF);
        priority_queue<P, vector<P>, greater<P>> pos;
        pos.push(make_pair(0,i));
        dist[i] = 0;
        
        while(!pos.empty()){
            auto from = pos.top(); pos.pop();
            if(dist[from.second] < from.first) continue;
            for (auto to : G[from.second])
            {
                if(dist[to.second] > dist[from.second] + to.first){
                    dist[to.second] = dist[from.second] + to.first;
                    pos.push(make_pair(dist[to.second], to.second));
                }
            }
        }
        for (int i = 0; i < M; i++)
        {
            //cout << get<0>(w[i]) << ":" << dist[get<0>(w[i])] << " " << get<1>(w[i]) << ":" << dist[get<1>(w[i])] << endl;
            if(abs(dist[get<0>(w[i])] - dist[get<1>(w[i])]) == get<2>(w[i])){
                check[i] = true;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < M; i++)
    {
        if(!check[i]) ans++;
        //cout << check[i] << " ";
    }
    //cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, H, W;
	char S[52][52] = {};
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) scanf("%s", &(S[i][1]));
	
	int j, k, l, count[52][52] = {};
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (S[i][j] == '#') {
				for (k = -1; k <= 1; k++) {
					for (l = -1; l <= 1; l++) {
						if (S[i+k][j+l] == '.') count[i+k][j+l]++;
					}
				}
			}
		}
	}
	
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (S[i][j] == '.') printf("%d", count[i][j]);
			else printf("#");
		}
		printf("\n");
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
int n, m, k, b[N];
char s[N];
ll ans;
int main() {
	scanf("%d", &n); 
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++i) {
		b[i] = b[i - 1];
		if (s[i] == 'M') b[i]++;
	}
	scanf("%d", &m);
	while (m--) {
		ans = 0;
		scanf("%d", &k);
		int l = 1, r = 0;
		ll tmp = 0;
		int c = 0;
		for (int i = 1; i <= n; ++i) {
			while (r + 1 < i + k && r + 1 <= n) {
				++r;
				if (s[r] == 'C') {
					c++;
					tmp += b[r];
				}
			}
			while (l < i) {
				if (s[l] == 'C') {
					--c;
					tmp -= b[l];
				}
				++l;
			}
			if (s[i] == 'D') {
				ans += tmp;
				ans -= (ll)c * b[i];
			}
		}
		printf("%lld\n", ans);
	}
} 

Measured memory_bytes: 5120
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int H, W;
int A[100111];

int main() {
    scanf("%d%d", &H, &W);
    REP (i, H) REP (j, W){ 
	string s;
	cin >> s;
	if (s == "snuke") {
	    printf("%c%d\n", j+'A', i+1);
	}
    }


    return 0;
}



Measured memory_bytes: 764
from fractions import gcd
from functools import reduce
def gcd_list(numbers):
  return reduce(gcd, numbers)
n,k = map(int, input().split())
a = list(map(int, input().split()))
if k % gcd_list(a) != 0 or max(a) < k:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
string s,t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s>>t;
    ll ans=0;
    for(int i=0;i<s.size();i++)
        if(s[i]!=t[i])
            ans++;
    cout<<ans;
    return 0;
}


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


int main(){

    int N,count = 0;;
    cin >> N;

    vector<int>array(N+1,0);
    for(int i = 0;i < N+1;i++){
        cin >> array[i+1];
    }
    for(int i = 0;i < N;i++){
        if(array[i+1] != i+1){
            continue;
        }
        swap(array[i+1],array[i+2]);
        count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

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

	string S,T="abc";
	cin>>S;
	sort(all(S));

	yn(S == T);

	return 0;
}

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

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int k = max(a,b);
    k = max(k,c);
    int q = 3*k - a - b -c;
    int ans = 0;
    if (q % 2 == 0){
        ans = q / 2;
        cout << ans;
    }
    else{
        ans = (q+3)/2;
        cout << ans;
    }
    return 0;
}

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

long long n, m;
vector<vector<long long> > v(50, vector<long long> (50, 0));

vector<bool> visit(50, false);

void init(){
    for(long long i = 0; i < 50; i++) visit[i] = false;
}

void dfs(long long x){
    if(visit[x] == true) return;

    visit[x] = true;

    for(long long i = 0; i < n; i++){
        if(v[x][i] == 1) dfs(i);
    }
}

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

    vector<pair<long long, long long> > edges; 
    for(long long i = 0; i < m; i++){
        long long a, b;
        cin >> a >> b;
        a--;
        b--;
        edges.push_back(make_pair(a, b));
        v[a][b] = 1;
        v[b][a] = 1;
    }

    long long cnt = 0;
    for(long long i = 0; i < m; i++){
        long long a, b;
        a = edges[i].first;
        b = edges[i].second;
        v[a][b] = 0;
        v[b][a] = 0;
        dfs(0);

        bool flag = true;
        for(long long i = 0; i < n; i++){
            if(visit[i] == false) flag = false;
        }

        if(flag == false) cnt++;

        init();
        v[a][b] = 1;
        v[b][a] = 1;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
double util(double p[], int i, int n, int heads, vector<vector<double>>& dp){
    if(i == n){
        if(heads > n/2) return 1;
        else return 0;
    }
    if(dp[i][heads] != -1) return dp[i][heads];
    double res = p[i]*util(p, i + 1, n, heads + 1, dp) + (1 - p[i])*util(p, i + 1, n, heads, dp);
    dp[i][heads] = res;
    return res;
}
int main() {
	int n;
	cin>>n;
	double p[n];
	for(int i = 0;i<n;i++){
	    cin>>p[i];
	}
	vector<vector<double>> dp(n, vector<double>(n, -1));
	cout<<fixed<<setprecision(10)<<util(p, 0, n, 0, dp);
	return 0;
}

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

int main(void){

  int times,m,n,i,j,c[1001][1001];
  char x[1001], y[1001];

  scanf("%d",&times);

  while(times--){
    scanf("%s",x);
    scanf("%s",y);
    m = strlen(x);
    n = strlen(y);
    for(i=1; i<=m; i++){
      c[i][0] = 0;
    }
    for(j=0; j<=n; j++){
      c[0][j] = 0;
    }
    for(i=1; i<=m; i++){
      for(j=1; j<=n; j++){
	if(x[i-1] == y[j-1]){
	  c[i][j] = c[i-1][j-1] + 1;
	}else{
	  if(c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
	  else c[i][j] = c[i][j-1];
	}
      }
    }
    printf("%d\n",c[m][n]);
  }

}

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

int main() {
 int a ,b ;
 cin >> a >>b;
 bool finish =true;
 int ans =0;
 int count =1;
  for (int i=0; finish;i++){
    if (count>b-1){
      finish = false;
      cout << ans ;
      // cout<<count ;
    }
   ans ++ ;
   count = count + a -1;
   
  }
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

ll n;
bool check(ll x){return x*(x+1)/2ll<=n;}

int main()
{
	scanf("%lld",&n);
	ll l=1,r=100000;
	while(l<=r)
	{
		ll mid=l+r>>1;
		if(check(mid)) l=mid+1;
		else r=mid-1;
	}ll k=l-1; ll now=k*(k+1ll)/2;
	return printf("%lld\n",k+(now!=n?1:0)),0;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int N;
  int C[505], S[505], F[505];
  scanf("%d", &N);
  rep(i, 0, N-1) scanf("%d %d %d", &C[i], &S[i], &F[i]);

  rep(x, 0, N) {
    int t = 0;
    rep(s, x, N-1) {
      t = max(S[s], ((t - 1) / F[s] + 1) * F[s]) + C[s];
    }
    printf("%d\n", t);
  }
  return 0;
}


Measured memory_bytes: 128
import sys

sys.setrecursionlimit(100000)

N, K = map(int, raw_input().split())
H = map(int ,raw_input().split())
cost = [-1]*N

def sumOfCost(i):
  if cost[i] >= 0:
    return cost[i]
  elif i == 0:
    soc = 0
  else:
    soc = 1000000000
    for j in reversed(range(1, min(i+1,K+1))):
      soc = min(soc, sumOfCost(i-j)+abs(H[i]-H[i-j]))
  cost[i] = soc
  return soc

print sumOfCost(N-1)
    



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

const int INF = 10000000;   // 十分大きな値に

int N;
int A[210];         // 最大 200 個なので余裕を持って 210 に

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];

  int res = INF;

  for (int i = 0; i < N; ++i) {
    int count = 0;  // 何回 2 で割れるか

    while (A[i] % 2 == 0) {
      A[i] /= 2;
      ++count;
    }

    // 最小値を更新
    if (res > count) res = count;
  }

  cout << res << endl;
}

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

int main(){
  double n, n1, a, b, ai, aj, bi, bj;
  double c=0 , d=0 , e=0;
  cin >> n;
  vector<double> sx(n), sy(n);
  rep(i,0,n) cin >> sx[i] >> sy[i];
  rep(i,0,n){
    rep(j,i+1,n){
      c++;
    }
  }
  vector<double> ss(c);
  rep(i,0,n){
    rep(j,i+1,n){
      ss[d] = hypot(sx[i]-sx[j] , sy[i]-sy[j]);
      e+=ss[d];
      d++;
    }
  }
  c=1;
  rep(i,0,n) c*=(i+1);
  cout << setprecision(12) << (e*2 / n) << endl;
  return 0;
}

Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int n, k;
char a[MAX];

int main(void) {
//	in = fopen("B.in", "rt");
	
	n = 15;
	fscanf(in, "%s", a);
	k = (int)strlen(a);
	
	for (int i = k; i < n; i++)
	    a[i] = 'o';
	
	int cnt = 0;
	for (int i = 0; i < n; i++)
	    cnt += a[i] == 'o';
	
	fprintf(out, "%s\n", cnt >= 8 ? "YES" : "NO");
	
	return 0;
}

Measured memory_bytes: 128
#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++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

int main(){

lli N,K,Q,a;
  cin >>N >> K >> Q;
    std::map<std::string,int> point;
    std::string str; 
  rep(i, N){
    str = std::to_string(i);
    point[str]=0;
  }
  rep(i, Q){
  cin >> a;
    str = std::to_string(a-1);
    point[str]++;
  }
  rep(i, N){
    str = std::to_string(i);
  if(point[str]+K-Q<1)
    cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}

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

using namespace std;

#define int long long

void solve() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) cout << 'x';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
string s;
long long solve(long long i) {
	long long ans = 0;
	long long chainer = 0;
	long long doing = 0;
	long long pro = (long long)s.length() - i;
	for (int q = i;q < (long long)s.length() - i;++q) {
		if (s[q] == '0') {
			if (doing == 1) {
				doing = 0;
				pro = min(pro, chainer);
				chainer = 0;
			}
		}
		else {
			doing = 1;
			chainer++;
		}
	}
	if (doing == 1) {
		doing = 0;
		pro = min(pro, chainer);
		chainer = 0;
	}
	ans = max(ans, pro);
	chainer = 0;
	doing = 0;
	pro = (long long)s.length() - i;
	for (int q = i;q < (long long)s.length() - i;++q) {
		if (s[q] == '1') {
			if (doing == 1) {
				doing = 0;
				pro = min(pro, chainer);
				chainer = 0;
			}
		}
		else {
			doing = 1;
			chainer++;
		}
	}
	if (doing == 1) {
		doing = 0;
		pro = min(pro, chainer);
		chainer = 0;
	}
	ans = max(ans, pro);
	return ans;
}
int main() {
#define int long long
	cin >> s;
	long long top = (long long)s.length(), bot = 0;
	while (top - bot > 2) {
		long long bott = (top+bot+bot)/3,topp = (top+top+bot)/3;
		if (solve(bott) <= solve(topp)) {
			bot = bott;
		}
		else top = topp;
	}
	long long ans = 0;
	for (int i = 0;i < 10;++i) {
		ans = max(ans, solve(bot + i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int dp[1<<18][51];

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  rep(mask,1<<n)rep(last,51) dp[mask][last]=inf;
  dp[0][0]=0;
  rep(mask,1<<n)rep(last,51)if(dp[mask][last]!=inf){
    vector<i_i> zeros;
    int itr=0;
    rep(i,n){
      if(mask&(1<<i)) continue;
      zeros.emplace_back(i,itr++);
    }
    for(auto v:zeros){
      bool f=abs(__builtin_popcount(mask)-v.first)%2;
      if(f==0&&a[v.first]<last||f==1&&b[v.first]<last) continue;
      chmin(dp[mask|(1<<v.first)][f==0?a[v.first]:b[v.first]],dp[mask][last]+v.second);
    }
  }
  int ans=inf;
  rep(last,51) chmin(ans,dp[(1<<n)-1][last]);
  if (ans==inf) ans=-1;
  cout << ans << endl;
}


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

using namespace std;

long long int dp[102][100002]={};

int main() {
    int N;
    long int W;
    cin >> N >> W;
    
    long long int w[N+1], v[N+1];
    for(int i=0; i<N; i++) {
        cin >> w[i] >> v[i];
    }
    
    for(long int sum_w=0; sum_w<=W; sum_w++) {
        for(int i=0; i<N; i++) {
            if(sum_w>=w[i]) {
                dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w-w[i]]+v[i]);
            } else {
                dp[i+1][sum_w] = dp[i][sum_w];
            }
        }
    }
    
    cout << dp[N][W] << endl;

    return 0;
    
}

Measured memory_bytes: 78336
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
 
static const double EPS = 1e-8;

static const int tx[] = {+0,+1,+1,+1,+0,-1,-1,-1,+0};
static const int ty[] = {-1,-1,+0,+1,+1,+1,+0,-1,+0};

class Point {
public:
  int x;
  int y;
  Point(int x,int y){
    this->x = x;
    this->y = y;
  }
  bool include(const Point& p,int radius){
    return ((x - p.x) * (x - p.x)
            + (y - p.y) * (y - p.y) <= 16 * radius * radius);
  }
};

int main(){
  int num_of_combat_planes;
  int num_of_energy_bullets;
  int radius;
  while(~scanf("%d %d %d",
               &num_of_combat_planes,
               &num_of_energy_bullets,
               &radius)){
    if(num_of_combat_planes == 0 && num_of_energy_bullets == 0){
      break;
    }
    vector<Point> combat_planes;
    for(int combat_plane_i = 0; combat_plane_i < num_of_combat_planes; combat_plane_i++){
      int x,y;
      scanf("%d %d",&x,&y);
      combat_planes.push_back(Point(x,y));
    }
    vector<int> energy_bullets[10001];
    for(int energy_bullet_i = 0; energy_bullet_i < num_of_energy_bullets; energy_bullet_i++){
      int x,y;
      scanf("%d %d",&x,&y);
      energy_bullets[x].push_back(y);
    }
    for(int x = 0; x <= 10000; x++){
      sort(energy_bullets[x].begin(),energy_bullets[x].end());
    }

    int sum = 0;
    for(int combat_plane_i = 0; combat_plane_i < num_of_combat_planes; combat_plane_i++){
      for(int x = max(combat_planes[combat_plane_i].x - (4 * radius),0); x <= combat_planes[combat_plane_i].x + (4 * radius); x++){
        int end_y = upper_bound(energy_bullets[x].begin(),energy_bullets[x].end(),combat_planes[combat_plane_i].y + 4 * radius) - energy_bullets[x].begin();
        int begin_y = lower_bound(energy_bullets[x].begin(),energy_bullets[x].end(),combat_planes[combat_plane_i].y - 4 * radius) - energy_bullets[x].begin();
        for(int i = begin_y; i < end_y; i++){
          sum += combat_planes[combat_plane_i].include(Point(x,energy_bullets[x][i]),radius);
        }
      }
    }

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

Measured memory_bytes: 2868
#include <iostream>

using namespace std;

long long X;

int main(){
    cin >> X;
    long long sp,ep,cp;
    sp = 1;
    ep = X;
    while(sp+1 < ep){
        cp = (sp + ep) / 2;
        if(cp * cp + cp - 2*X < 0){
            sp = cp;
        }else{
            ep = cp;
        }
    }
    cout << ep << endl;
    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    ll a, b, n; cin >> a >> b >> n;

    if (n < b) cout << a * n / b - a * (n / b) << endl;
    else cout << a * (b - 1) / b << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int N=105;
inline int read()
{
	int x=0,t=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=-1,ch=getchar();
	while(ch>='0'&&ch<='9')x=x*10+ch-48,ch=getchar();
	return x*t;
}
int arr[N];
int main()
{
	register int n=read();
	for(register int i=0;i<n;i++)
		arr[i]=read();
	register int cnt=0;
	for(register int i=0;i<n;i++)
		if((i+1)%2!=0&&arr[i]%2!=0) cnt++;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 3652
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    A, B, C, K = map(int, input().split())

    res = 0
    res += min(K, A)
    K = max(K - A - B, 0)
    res -= min(K, C)

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68728
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let t: f64 = read();
    let x: f64 = read();
    let ans: f64 = t / x;

    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

Measured memory_bytes: 4352
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, Q = lr()
STX = [tuple(lr()) for _ in range(N)]
event = []
for s, t, x in STX:
    event.append((s-x, 0, x))
    event.append((t-x, -1, x))

for i in range(Q):
    d = ir()
    event.append((d, 1, i))

event.sort()
answer = [-1] * Q
cur = set()
flag = False
INF = 10 ** 10
min_x = INF
for a, b, c in event:
    if b == 0:
        cur.add(c)
        if c < min_x:
            min_x = c
            flag = True
    elif b == -1:
        cur.remove(c)
        if min_x == c:
            flag = False
    elif b == 1:
        if cur:
            if not flag:
                min_x = min(cur)
                flag = True
            answer[c] = min_x

print('\n'.join(map(str, answer)))
# 19


Measured memory_bytes: 134324
import itertools
n=int(input())
la=[]
for _ in range(n):
  d=int(input())
  for dd in range(d):
    x,y=map(int,input().split())
    la.append([_,x-1,y])
ans=0
for i in itertools.product([0,1],repeat=n):
  s=sum(list(i))
  for l in la:
    if i[l[0]]==1 and i[l[1]]!=l[2]:
      break
  else:
    ans=max(ans,s)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,t,ans;
  ans = 0;
  cin >> N;
  vector<int> data(N);
  for (int i =0 ; i < N ; i++){
    cin >> data.at(i);
  }

  for (int i = 0; i <N-1; i++){
      for (int j =i+1; j<N; j++){
          if(data.at(i)>data.at(j)){
          }else if(data.at(i)<data.at(j)){
              t = data.at(j);
              data.at(j) = data.at(i);
              data.at(i) = t;   
          }else{
              data.at(j)=0;
          }
      }
  }
  for (int i = 0; i<N; i++){
    if (data.at(i)==0){
        break;
    }else{
        ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3512