akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	vector<vpl> G(n);
	rep(i,n-1){
		ll a,b,c; cin >> a >> b >> c; a--; b--;
		G[a].emplace_back(b,c);
		G[b].emplace_back(a,c);
	}
	vl ans(n,inf);
	ans[0] = 0;
	queue<ll> q;
	q.push(0);
	while(!q.empty()){
		ll u = q.front(); q.pop();
		for(auto v : G[u]){
			if(ans[v.first] != inf) continue;
			if(v.second & 1) ans[v.first] = 1 - ans[u];
			else ans[v.first] = ans[u];
			q.push(v.first); 
		}
	}
	for(auto i : ans) cout << i << endl;
}

Measured memory_bytes: 8704
N=int(input())
H=list(map(int,input().split()))
for i in range(N-1):
    if H[N-(i+2)] > H[N-(i+1)]:
        if H[N-(i+2)]-1 > H[N-(i+1)]: print('No'); exit()
        else: H[N-(i+2)]-=1
print('Yes')

Measured memory_bytes: 14252
def main():
    n = int(input())

    tasks = []
    for i in range(n):
        a, b = map(int, input().split())
        tasks.append( [a, b] )

    tasks.sort(key=lambda x: x[1])

    now = 0
    for t, deadline in tasks:
        now += t
        if deadline < now:
            print("No")
            return

    print("Yes")

main()


Measured memory_bytes: 38076
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
	for(int i=0;i<n;i++)
	{
	cin>>a[i];
	}
	
	for(int i=0;i<n;i++)
	{
		if(i!=n-1){
		
		cout<<a[i]<<" "; 
	}
		else
		{
		
		cout<<a[i];
		}
	
	}
	cout<<endl;
	
	
	for(int i=1;i<n;i++)
	{
		int j=i;
		while(j>0&&a[j-1]>a[j])
		{
		int k=a[j];
			a[j]=a[j-1];
			a[j-1]=k;
		j--;
		}
		for(int j=0;j<n;j++)
		{
		
			if(j>0)
			{
			cout<<" ";
			
			}
			cout<<a[j];
		
		}
		cout<<endl;
		
	
	}
	
	


}



Measured memory_bytes: 3120
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n + 1];
        for(int i=0; i<n; i++)  S[i] = sc.nextInt();
        int q = sc.nextInt();
        int[] T = new int[q];
        for(int i=0; i<q; i++) T[i] = sc.nextInt();
        int ans = 0;
        for(int key : T){
            if(linearSearch(S, n ,key)) ans++;
        }
        System.out.println(ans);

    }
    public static boolean linearSearch(int[] A, int n, int key){
        int i = 0;
        A[n] = key;
        while(A[i] != key)i++;
        return i != n;
    }


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


Measured memory_bytes: 27036
def xc2(x)
  return 0 if x <= 1
  return x*(x-1)/2
end

n=gets.chomp.to_i
x=Array.new(n+1,0)
a=gets.chomp.split(" ").map{|i|i.to_i}
a.each{|i|x[i] += 1}
y=x.map{|i|xc2(i)}
sum=0
y.map{|i|sum += i}
0.upto(n-1) do |k|
   puts sum - (1*y[a[k]] - xc2(x[a[k]]-1))
end

Measured memory_bytes: 27660
#include<stdio.h>
int main(void){
    int matrix[100][100];
    int vector[100];
    int solution = 0;
    int i, j, m, n;

    scanf("%d %d", &n, &m);
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d", &matrix[i][j]);
        }
    }
    for(i = 0; i < m; i++){
        scanf("%d", &vector[i]);
    }
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            solution += matrix[i][j] * vector[j];
        }
        printf("%d\n", solution);
        solution = 0;
    }

    return 0;
}



Measured memory_bytes: 2048
s = input()
# 先頭が0, 1が決まれば次以降は確定してしまうのでは...
ans = int(1e5 + 1)
for i in range(2):
  b = i
  temp = 0
  for c in s:
    t = int(c)
    temp += (t != b)
    b = 0 if b else 1
  ans = min(ans, temp)
print(ans)

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

int main(void)
{
  int N, i, j, C0 = 0, C1 = 0, C2 = 0, C3 = 0;
  char str[100000][4], test[4][4] = {"AC", "WA", "TLE", "RE"};
  scanf("%d", &N);
  for (i = 0; i < N; i++)
  {
    for (i = 0; i < N; i++)
    {
      scanf("%s", &str[i]);
    }
  }

  for (i = 0; i < N; i++)
  {
    if (strcmp(str[i], test[0]) == 0)
    {
      C0++;
    }
    else
    {
      if (strcmp(str[i], test[1]) == 0)
      {
        C1++;
      }
      else
      {
        if (strcmp(str[i], test[2]) == 0)
        {
          C2++;
        }
        else
        {
          C3++;
        }
      }
    }
  }
  printf("AC x %d\n", C0);
  printf("WA x %d\n", C1);
  printf("TLE x %d\n", C2);
  printf("RE x %d\n", C3);
  return 0;
}


Measured memory_bytes: 2120
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

int main()
{
	long long n;
	long long k;
	vector<long long> arr, div;
	map<long long, long long> list;
	map<long long, long long>::iterator it, ret;
	long long input;
	long long sum = 0, tot, tot2;
	long long ub;
	long long i, j;

	scanf("%lld %lld", &n, &k);

	for (i = 0; i < n; i++)
	{
		scanf("%lld", &input);

		arr.push_back(input);

		sum += input;
	}

	ub = (long long)sqrt((double)sum);

	for (i = 1; i <= ub; i++)
	{
		if (!(sum%i))
		{
			div.push_back(i);
		}
	}

	if (ub*ub == sum)
	{
		for (i = (long long)div.size() - 2; i >= 0; i--)
		{
			div.push_back(sum / div[i]);
		}
	}

	else
	{
		for (i = (long long)div.size() - 1; i >= 0; i--)
		{
			div.push_back(sum / div[i]);
		}
	}

	for (i = div.size() - 1; i >= 1; i--)
	{
		list.clear();

		tot = 0;
		tot2 = 0;

		for (j = 0; j < n; j++)
		{
			if (!(arr[j] % div[i]))
			{
				continue;
			}

			ret = list.find(arr[j] % div[i]);

			if (ret == list.end())
			{
				list[arr[j] % div[i]] = 1;
			}

			else
			{
				ret->second++;
			}

			tot += div[i] - (arr[j] % div[i]);
		}

		for (it = list.begin(); it != list.end(); it++)
		{
			for (j = 0; j < it->second; j++)
			{
				tot -= div[i] - it->first;
				tot2 += it->first;

				if (tot == tot2)
				{
					break;
				}
			}

			if (j != it->second)
			{
				break;
			}
		}

		if (tot <= k)
		{
			printf("%lld\n", div[i]);

			return 0;
		}
	}

	printf("1\n");

	return 0;
}

Measured memory_bytes: 256
fn divisors(a: i64, x: i64) -> i64 {
    if a > 0 {
        (a - 1) / x + 1
    } else {
        0
    }
}

fn solve(a: i64, b: i64, x:i64) -> i64 {
    divisors(b + 1, x) - divisors(a, x)
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let mut iter = line.split_whitespace().map(|s| s.parse().unwrap());
    let a = iter.next().unwrap();
    let b = iter.next().unwrap();
    let x = iter.next().unwrap();
    let res = solve(a, b, x);
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    int m,d;
    int cnt=0;
    cin >> m>>d;
    
    for(int j=1;j<=m;j++){
        for(int d_10=2;d_10<=9;d_10++){
            for(int d_1=2;d_1<=9;d_1++){
                int day = d_10*10+d_1;
                if(day<=d&&d_1*d_10==j){
                    cnt++;
                }
            }
        }
    }
    
    
    cout << cnt<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	int n, i;
	cin >> n;
	double prev = 0;
	vector<double> value(n);
	for (i = 0; i < n; i++)
		cin >> value[i];

	sort(value.begin(), value.end());

	prev = value[0];
	for (i = 1; i < n; i++) 
		prev = (prev + value[i]) / 2.0;
		
	cout << fixed << setprecision(12) << prev << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++) {
        if ((s.substr(i) + s.substr(0, i)) == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
inline ll f(ll n){return n*n*n*n*n;}
void MAIN() {
	ll X;cin>>X;
	for(ll a=-1000;a<=1000;a++) {
		for(ll b=-1000;b<=1000;b++) {
			if(f(a)-f(b)==X) {
				cout<<a<<' '<<b;
				return;
			}
		}
	}
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
bitset<4000005> can;
int main() {
	int N;
	scanf("%d", &N);
	int sum = 0;
	can[0] = 1;
	for (int i = 0; i < N; ++i) {
		int a;
		scanf("%d", &a);
		can |= (can << a);
		sum += a;
	}
	for (int i = (sum + 1) / 2;; ++i)
		if (can[i]) {
			printf("%d\n", i);
			break;
		}
}


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

int cnt, n;
int head[MAX], Next[MAX*2], vet[MAX*2];
ll ans[MAX];

void add(int x, int y){
    cnt++;
    Next[cnt] = head[x];
    head[x] = cnt;
    vet[cnt] = y;
}

bool vis[MAX];
int dis[MAX];
void bfs(int s){
    memset(vis, 0, sizeof(vis));
    queue<int> q;
    dis[s] = 0, vis[s] = 1;
    q.push(s);
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int i = head[x]; i; i = Next[i]){
            int v = vet[i];
            if(vis[v]) continue;
            vis[v] = 1;
            dis[v] = dis[x]+1;
            q.push(v);
        }
    }
    for(int i = s+1; i <= n; i++){
        ans[dis[i]]++;
    }
}

int s, e;

int main()
{
    cin >> n >> s >> e;
    for(int i = 1; i < n; i++){
        add(i, i+1);
        add(i+1, i);
    }
    add(s, e);
    add(e, s);
    for(int i = 1; i <= n; i++){
        bfs(i);
    }
    for(int i = 1; i < n; i++){
        printf("%lld\n", ans[i]);
    }

    return 0;
}

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


struct node{
    int id;
    int k;
    int depth;
    int parent;
    vector<int> child;
};
int main()
{
    int n, id, k;
    cin >> n;
    vector<node> tree;
    tree.resize(n);
    for (int i = 0; i < n; i++)
    {
        tree[i].parent = -1;
        tree[i].depth = 0;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> id >> k;
        tree[id].id = id;
        tree[id].k = k;
        if (k != 0)
        {
            tree[id].child.resize(k);
            for (int j = 0; j < k; j++)
            {
                cin >> tree[id].child[j];
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (tree[i].k != 0)
        {
            for(int j = 0; j < tree[i].k; j++)
            {
                tree[tree[i].child[j]].parent = tree[i].id;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        int j = i;
        while (tree[j].parent != -1)
        {
            j = tree[j].parent;
            tree[i].depth++;
        }

    }
    for (int i = 0; i < n; i++)
    {
        cout<< "node " << tree[i].id << ": " << "parent = " << tree[i].parent << ", " << "depth = " << tree[i].depth << ", ";
        if (tree[i].k == 0 && tree[i].depth != 0)
        {
            cout << "leaf, []" << endl;
        }

        else
        {
            if (tree[i].depth == 0)
                cout << "root, [";
            else cout<< "internal node, [";
            for (int j = 0; j < tree[i].k; j++)
            {
                cout << tree[i].child[j] ;
                if (j != tree[i].k-1) cout << ", ";
            }
            cout << "]" << endl;
        }
    }

    return 0;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();
    // cout<<c<<endl;
    string s;
    cin>>s;
    n = (int)s.size();

    int ans =753;
    int mini=INF;
    for (int i = 0,j=2; i <=n-3; i++)
    {
    	/* code */
    	// j++;
    	string str=s.substr(i,3);

    	// watch(str-"0");
    	int x = stoi(str);
    	// debug(x);
    	mini=min(mini,abs(ans-x));


    }
    cout<<mini<<endl;
    return 0;
}



Measured memory_bytes: 3624
// https://atcoder.jp/contests/abc153/tasks/abc153_d
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

// ===

fn solve(h: i64) -> i64 {
    if h == 1 {
        return 1;
    }
    1 + solve(h/2) * 2
}

fn main() {
    input! {
        h: i64
    };
    println!("{}", solve(h));
}


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

vector<int> to[200005];
vector<ll> ans;
void dfs(int root, int p=-1) {
  for(auto x : to[root]){
    if (x == p) continue;
    ans[x] += ans[root];
    dfs(x,root);
  }
}

int main(){
  int n, q;
  cin >> n >> q;
  ans.resize(n);
  rep(i,n-1){
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,q){
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }
  dfs(0);
  for(auto x : ans){
    cout << x << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 25096
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl N;

void solve(void) {
  FOR0(i, N) {
    cout << "x";
  }
  cout << endl;
}

int main(void) {
  string S;
  cin >> S;
  N = S.size();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define uu unsigned
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mkp make_pair
#define ss second
#define ff first
#define mit(a,b) map<a,b>::iterator
#define sit(a) set<a>::iterator
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pprint(x) print(x),putchar(' ')
#define fprint(x) print(x),putchar('\n')
#define printcas cout<<"Case "<<cas<<": "
#define _ continue;
#define endl '\n'
#define __ cout<<endl;continue;
#define vec4d(nam,type,a,b,c,d,fix) vector<vector<vector<vector<type>>>> nam(a,vector<vector<vector<type>>>(b,vector<vector<type>>(c,vector<type>(d,fix))))
const ll oo=(1ll<<60);
int gi(){
    int x=0,w=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')w=0,ch=getchar();
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return w?x:-x;
}
void print(ll x)
{
    if(x < 0) putchar('-'),x = -x;
    if(x > 9) print(x / 10);putchar(x % 10 + '0');
}
double dis(double x,double y)
{
    return sqrt((x*x*1.0)+(y*y*1.0));
}
int main()
{
     io;
    int T=1;
    //T=gi();
    //cin>>T;
    //for(int cas=1;cas<=T;cas++)
    while(T--)
    {
       ll n=gi();double d=gi();

       ll cnt=0;
       while(n--)
       {
           double x=gi()*1.0,y=gi()*1.0;
           if(dis(x,y)<=d)cnt++;
       }
       fprint(cnt);
    }
    return 0;
}


Measured memory_bytes: 3700
N, K = map(int, input().split())
d_a = [input() for _ in range(2 * K)]
length = len(d_a)
people = []
answer = []
for i in range(length):
    if i % 2 == 1:
        people.append(d_a[i])

for data in people:
    if len(data) > 1:
        data = data.split()
        for d in data:
            if d not in answer:
                answer.append(d)
    else:
        if data not in answer:
            answer.append(data)

print(N - len(answer))

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <fstream>
#include <unordered_map>
#include <vector>
#include <numeric>
#include <algorithm>

int main() {
	std::vector<int> s;
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		std::cin >> t;
		s.push_back(t);
	}
	std::sort(s.begin(), s.end());
	std::cout << s[s.size() - 1] - s[0] << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
const ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x);
        }
        p = p >> 1;
        x = (x*x);
    }
    return res;
}
struct Matrix
{
    vector< vector<ll> > mat; // the contents of matrix as a 2D-vector
    int n_rows, n_cols; // number of rows and columns

    Matrix(vector< vector<ll> > values): mat(values), n_rows(values.size()),
        n_cols(values[0].size()) {}

    static Matrix identity_matrix(int n)
    {
        // Return I_n - the identity matrix of size n.
        // This function is static, because it creates a new Matrix instance
        vector< vector<ll> > values(n, vector<ll>(n, 0));
        for(int i = 0; i < n; i++)
            values[i][i] = 1;
        return values;
    }

    Matrix operator*(const Matrix &other) const
    {
        int n = n_rows, m = other.n_cols;
        vector< vector<ll> > result(n_rows, vector<ll>(m, 0));
        for(int i = 0; i < n; i++)
            for(int k = 0; k < n_cols; k++) {
                for(int j = 0; j < m; j++) {
                    result[i][j] = (result[i][j] + (mat[i][k] * 1LL * other.mat[k][j])%MOD) % MOD;
                }
            }
        // Multiply matrices as usual, then return the result as the new Matrix
        return Matrix(result);
    }

    inline bool is_square() const
    {
        return n_rows == n_cols;
    }
};

Matrix fast_exponentiation(Matrix &m, ll power)
{
    assert(m.is_square());
    Matrix result = Matrix::identity_matrix(m.n_rows);

    while(power) {
        if(power & 1)
            result = result * m;
        m = m * m;
        power >>= 1;
    }

    return result;
}
vector<vector<ll>> values;
int main() {
    IO;
    int n;
    ll k;
    cin >> n >> k;
    values.resize(n);
    for (int i = 0; i < n; i++) {
        values[i].resize(n);
        for (int j = 0 ; j < n; j++) {
            cin >> values[i][j];
        }
    }
    Matrix m(values);
    Matrix x = fast_exponentiation(m, k);
    ll ans = 0;
    for (vector<ll>& v: x.mat) {
        for (int s: v) {
            ans = (ans + s) %MOD;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<bitset>
using namespace std;
bool g[777][777];
vector<int>G[777];
int n,m;
int color[777];
bool dfs(int u,int c)
{
	color[u]=c;
	int ans=1;
	for(int i=0;i<G[u].size();i++)
	{
		ans&=color[G[u][i]]<0?dfs(G[u][i],c^1):color[G[u][i]]^c;
	}
	return ans;
}
bool check()
{
	bool ans=true;
	int c=-2;
	for(int i=0;i<n;i++)if(color[i]<0)ans&=dfs(i,c+=2);
	return ans;
}
int cnt[777][2];
bitset<777>dp(1);
int f(int a)
{
	return a*(a-1)/2+(n-a)*(n-a-1)/2;
}
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)color[i]=-1;
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		g[a][b]=g[b][a]=1;
	}
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)
	{
		if(!g[i][j])
		{
			G[i].push_back(j);
			G[j].push_back(i);
		}
	}
	int ans=1e9;
	if(!check())ans=-1;
	for(int i=0;i<n;i++)cnt[color[i]/2][color[i]%2]++;
	for(int i=0;i<n;i++)dp=dp<<cnt[i][0]|dp<<cnt[i][1];
	for(int i=0;i++<n;)if(dp[i])ans=min(ans,f(i));
	cout<<ans<<endl;
}


Measured memory_bytes: 3200
n=int(input())
s=[input() for i in range(n)]
s=sorted(s)
poll=[s[0]]
counta=[1]
kind=0
for i in range(1,n):
  if s[i]==s[i-1]:
    counta[kind]+=1
  else:
    kind+=1
    poll.append(s[i])
    counta.append(1)
m=max(counta)
for i in range(kind+1):
  if counta[i]==m:
    print(poll[i])

Measured memory_bytes: 24708
public class Main {
    public static void main(String[] args) {

         java.util.Scanner sc = new java.util.Scanner(System.in);
        int n = sc.nextInt();

         int taro_point = 0, hanako_point = 0;
        String taro_card, hanako_card;
        for (int i = 0; i < n; i ++) {
            taro_card = sc.next();
            hanako_card = sc.next();
            if (taro_card.compareToIgnoreCase(hanako_card) > 0) { taro_point += 3; }
            else if (taro_card.compareToIgnoreCase(hanako_card) < 0) { hanako_point += 3; }
            else { hanako_point ++; taro_point ++; }
        }
        System.out.println(taro_point + " " + hanako_point);
    }
}

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

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int main(){
    int n,k;
    cin >> n >> k;
    string S;
    cin >> S;
    vector<int> C;
    int now = 1;
    int cnt = 0;
    rep(i,n){
        if(S[i] == '0'+now){
            ++cnt;
        }else{
            C.push_back(cnt);
            cnt=1;
            now = 1 - now;
        }
    }
    if(cnt!=0)C.push_back(cnt);
    if(C.size()%2==0)C.push_back(0);
    // 尺取法
    int left,right,tmp;
    left = right = tmp = 0;
    int ans =0;
    int Add = 2*k + 1;
    for(int i = 0; i<C.size(); i+=2){
      int Nextleft = i;
      int Nextright = min((int)C.size(), i + Add);

      while(Nextleft>left){
        tmp -= C[left];
        ++left;
      }
      
      while(Nextright>right){
        tmp += C[right];
        ++right;
      }

      ans = max(ans, tmp);
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxn 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e9+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
//for making unordered_map with pair
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
int32_t main()
{
fastio;
int n;in n;int k;in k;
n%=k;
out min(n,abs(n-k));
    return 0;
}

/*
google kick start
  cout << "Case #" << tt << ": "<<ans<<endl;
*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<limits.h>
#include<algorithm>
#include<queue>
#include<set>


#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}


int main()
{

	long long int n, a, b;
	cin >> n >> a >> b;

	if (a == 0) {
		cout << 0 << endl;
		return 0;
	}
	
	long long int c = n / (a + b);
	n -= c * (a + b);

	long long int ans = 0;
	ans += c * a;

	ans += min(n, a);

	cout << ans << endl;


	
	
	


	return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	int n;
	cin>>n;
	vector<int> a(n,0);
	for(int i=0;i<n;i++)
		cin>>a[i];
	int ctr=0,curr=1;
	for(int i=0;i<n;i++){
		if(a[i]==curr){
			curr++;
			ctr++;
		}
	}
	if(ctr>0)
		cout<<n-ctr<<"\n";
	else
		cout<<"-1\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 1024
using System;

namespace AtCoder
{
    internal static class Program
    {
        private static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            long[] nbrs = new long[N];
            long res;

            for (int i = 0; i < N; i++)
                nbrs[i] = long.Parse(Console.ReadLine());

            res = nbrs[0];

            for(int i = 1; i < N; i++)
            {
                long min = Math.Min(res, nbrs[i]);
                long max = Math.Max(res, nbrs[i]);

                if (max % min == 0)
                    res = max;
                else
                {
                    long now = max;
                    while(true)
                    {
                        now += max;
                        if (now % min == 0)
                        {
                            res = now;
                            break;
                        }
                    }
                }
            }


            Console.WriteLine(res);
        }
    }
}

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

using value_type = pair<int, int>;

struct second_order {
    bool operator()(const value_type& x, const value_type& y) const {
        return x.second < y.second;
    }
};


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

    int n;
    cin >> n;
    map <int, int> v_odd, v_even;

    int tmp;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        if (i % 2) {
            v_odd[tmp]++;
        } else {
            v_even[tmp]++;
        }
    }

    priority_queue<value_type, vector<value_type >, second_order>  que_odd;
    priority_queue<value_type, vector<value_type >, second_order>  que_even;

    for (auto &e: v_odd) {
        que_odd.push(e);
    }
    for (auto &e: v_even) {
        que_even.push(e);
    }


    value_type first_odd = que_odd.top();
    que_odd.pop();
    value_type second_odd = que_odd.top();
    value_type first_even = que_even.top();
    que_even.pop();
    value_type second_even = que_even.top();

    if (v_odd.size() == 1 && v_even.size() == 1) {
        if (first_odd.first != first_even.first) {
            cout << 0 << endl;
        } else {
            cout << n / 2 << endl;
        }
    } else if (v_odd.size() == 1) {
        if (first_odd.first != first_even.first) {
            cout << n - (first_odd.second + first_even.second) << endl;
        } else {
            cout << n - (first_odd.second + second_even.second) << endl;
        }
    } else if (v_even.size() == 1) {
        if (first_odd.first != first_even.first) {
            cout << n - (first_odd.second + first_even.second) << endl;
        } else {
            cout << n - (second_odd.second + first_even.second) << endl;
        }
    } else {
        if (first_odd.first != first_even.first) {
            cout << n - (first_odd.second + first_even.second) << endl;
        } else {
            int res = max(first_odd.second + second_even.second, second_odd.second + first_even.second);
            cout << n -  res << endl;
        }
    }

    return 0;
}


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

#define ll long long int
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define finput ifstream cin;cin.open("in.txt")
#define foutput ofstream cout;cout.open("out.txt")  
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007

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

ll pwm(ll a, ll n){
	ll ans = 1;
	while(n>0){
		if(n%2==1){
			ans = (ans * a)%mod;
		}
		a = (a*a)%mod;
		n /= 2;
	}
	return ans%mod;
}

const int pwn = 100010;
ll pw[pwn];
void pwtwo(){
	pw[0] = 1;
	for(int i=1; i<pwn; i++){
		pw[i] = (pw[i-1]*2)%mod;
	}
}


ll gcdExtended(ll a, ll b, ll *x, ll *y); 
  
ll modInverse(ll a, ll m) 
{ 	
	if(a==1)
		return 1;
	//cout<<"mi "<<a<<" "<<m<<" ";
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1){
        //cout << "Inverse doesn't exist"<<endl; 
        return -1;
    }
    else
    { 
        // m is added to handle negative x 
        ll res = (x%m + m) % m; 
        //cout<<res<<endl;
        return res;
        // cout << "modular multiplicative inverse is " << res; 
    } 
} 
  
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 

ll fact[1010];
ll init(){
	fact[0] = 1;
	for(int i=1; i<1010; i++)
		fact[i] = (fact[i-1]*i)%mod;
}

ll ncr(ll n, ll r){
	ll ans = fact[n];
	if(r>n)
		return 0;
	//if(r!=0)
	ans = (ans*modInverse(fact[r], mod))%mod;
	// if(n-r!=0)
	ans = (ans*modInverse(fact[n-r], mod))%mod;

	return ans;
}

int main(){
	// finput;
	// foutput;
	fast;

	int n, k, i, j, x, m;
	ll ans,q,h,s,d;

	// string s;
	cin>>q>>h>>s>>d>>n;

	h = min(h, q*2ll);
	s = min(s, h*2ll);
	d = min(d, s*2ll);

	ans = 0ll;
	ans = (n/2ll)*d;
	n %= 2ll;
	ans += n*s;

	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    
    vector<int> v(q);
    for(int i = 0; i < q; i++) {
        cin >> v[i];
    }
    
    int save[100010] = {0};
    for(int i = 0; i < q; i++) {
        save[v[i] - 1]++;
    }
    
    for(int i = 0; i < n; i++) {
        if(k - (q - save[i]) > 0) {
            cout << "Yes" << "\n";
        }
        else {
            cout << "No" << "\n";
        }
    }
    
    return 0;
}



Measured memory_bytes: 1408
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key=lambda x: x[1], reverse=True)

d = []
for v in bc:
    b, c = map(int, v)
    d.extend([c] * b)
    if len(d) >= len(a):
        break

ans = sum(a)
for ai, di in zip(a, d):
    if ai < di:
        ans += di - ai

print(ans)

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

long n;
long p[100000+10];

int main(){
  cin >> n;
  for(long i=1;i<=n;i++){
    cin >> p[i];
  }
  p[n+1] = -1;
  
  long count = 0;
  bool containsFlag = false;
  long countTmp = 0;
  for(long i=1;i<=n+1;i++){
    if(i == p[i]){
      if(containsFlag == false){
	containsFlag = true;
	countTmp = 1;
      }else{
	countTmp++;
      }
    }else{ 
      if(containsFlag == false){
	continue;
      }else{
	containsFlag = false;
	if(countTmp%2 == 0){
	  count += countTmp/2;
	}else{
	  count += countTmp/2 + 1;
	}
	countTmp = 0;
      }
    } 
  }
  cout << count << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int fact(int n);
int main() {
    int n,m;
    cin>>n>>m;
    int sum=fact(n-1)+fact(m-1);
    cout<<sum;
}
int fact(int n){
    int res;
    if(n<1)
    return 0;
    else    
    res=1;
    for(int i=n;i>1;i--)
    res+=i;
    return res;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = input()

win_hand = {'r': 'p', 's': 'r', 'p': 's'}
win_point = {'r': p, 's': r, 'p': s}
history = []
points = 0
# dp = [0] * (n+1)  # i回目までプレイしたときの最高の点数
# if t[0] == 'r':
#     dp[1] = p
#     history[1] = 'p'
# elif t[0] == 'p':
#     dp[1] = s
#     history[1] = 's'
# else:
#     dp[1] = r
#     history[1] = 'r'
# k回目までは勝ち続ける
for i, s in enumerate(t):
    if(i < k):
        history.append(win_hand[s])
        points += win_point[s]
    else:
        if (history[i - k] == win_hand[s]):
            history.append('other')
            continue
        else:
            points += win_point[s]
            history.append(win_hand[s])
print(points)
# for s in t[k:]:
#     if(history[])
#     points += win_point[s]


# for in range(2, n+1):
#     if(i-k > 0):
#         # i回目に普通に勝てる時
#         if (win_hand[t[i]] != history[i - k]):
#             dp[i] = dp[i-1] + win_hand[t[i]]
#         # k回前の勝負を諦める?
#         else:

#     else:
#         dp[i] = dp[i-1] + win_hand[t[i]]


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

string n2bit(int n)
{
  string s;
  while (s.size() < 8 && n) {
    s += '0' + n % 2;
    n /= 2;
  }
  reverse(s.begin(), s.end());
  return s;
}

int main(int argc, char *argv[])
{
  int tc;
  cin >> tc;
  while (tc--) {
    int n, d;
    cin >> n >> d;
    if (n == 1) {
      cout << d << endl;
      continue;
    }
  
    vector<int> v;
    const int mask = (1 << 7) - 1;
    d = mask ^ d;
    --n;
    v.push_back(mask);
    while (v.size() < n) {
      v.push_back(mask);
      d = mask ^ d;
    }
    v.push_back(d);
    
    int sum = 0;
    each (i, v) sum += i;
    cout << sum << endl;
    // each (i, v) cout << n2bit(i) << endl; cout << endl;

    
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int S, s=0, m=0, h=0;
  cin >> S;
  if (S>=3600){
    h = S/3600;
    S = S%3600;
  }
  m = S/60;
  S = S%60;
  s = S;

  cout << h << ":" << m << ":" << s << endl;

  return 0;
}


Measured memory_bytes: 3096