akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_;
#define cout (c_?cerr:cout)
#define debug(...) {if(!c_)cerr<<"\033[96;1m"; \
++c_; __VA_ARGS__ ; --c; \
if (!c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif
#define st first
#define nd second
#define dump(...) debug(print(#__VA_ARGS__, __VA_ARGS__))
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template< typename t > using V = vector< t >;
void print() { cout << '\n'; }
template< typename t, typename... v > void print(const t& a, v&&... b)
{ cout << a << (sizeof...(b)? " " : ""); print(b...); }
/*}}}*/



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

    int n, k;
    cin >> n >> k;
    V< int > tb(n);
    for (int& i : tb)   
        cin >> i;
    int v = 0;
    while (tb[v] != 1) ++v;
    int l = v; int r = n - 1 - v;
    int res = n;
    for (int i = 0; i < k; ++i)
    {
        auto la = [k](int v) -> int
        { return (v + k - 2) / (k - 1); };
        int lo = l - i;
        int hi = r - (k - 1 - i);
        if (lo < 0 or hi < 0) continue;
        res = min(res, la(lo) + la(hi) + 1);
    }

    print(res);
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int t[505][505];
priority_queue<P> q1;

int main(){
	int n;
	LL a,b,c,d;
	LL p,q;
	LL i;
	cin>>n>>a>>b>>c>>d;
	n--;
	a=abs(a-b);
	for(i=0;i<=n;i++){
		p=c*i-d*(n-i);
		q=d*i-c*(n-i);
		if(p<=a && a<=q)break;
	}
	print_YES_NO(i<=n);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  2000001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    char s[max];
    
    scanf("%s", s);
    
    int len=strlen(s);
    int sum=0;
    
    rep(i, len){
        sum+=s[i]-48;
    }
    
    if (sum%9==0) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 1908
//
//  ALDS1_8_A.cpp
//  AizuOnlineJudge
//
//  Created by jiji on 2019/09/12.
//  Copyright © 2019 jiji4000. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

struct Node{
    int key;
    Node *parent,*left,*right;
};

Node *root,*NIL;

void insert(int key){
    Node* y = NIL;
    Node* x = root;
    Node* z = (Node*)malloc(sizeof(Node));
    z->key = key;
    z->left = NIL;
    z->right = NIL;
    
    // 挿入するノードの探索
    while(x != NIL){
        // 親の設定
        y = x;
        // 挿入する位置を決定する
        if(key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    // 親の設定
    z->parent = y;
    
    // 親が空の場合(2分木が空の場合)
    if(y == NIL){
        root = z;
    }
    else if(key < y->key){
        y->left = z;
    }
    else{
        y->right = z;
    }
}

/**
    根→左→右の順番で出力する
*/
void preOrder(Node* node){
    if(node == NIL){
        return;
    }
    // 根である自身を出力する
    cout << " " << node->key;
    // 左
    if(node->left != NIL){
        preOrder(node->left);
    }
    // 右
    if(node->right != NIL){
        preOrder(node->right);
    }
}

/**
    左部分木 → 根節点 → 右部分木の順番で節点をまわること
*/
void inOrder(Node* node){
    if(node == NIL){
        return;
    }
    // 左を探す
    if(node->left != NIL){
        inOrder(node->left);
    }
    // 左がなくなったら左を出力する
    cout << " " << node->key;
    // 右
    if(node->right != NIL){
        inOrder(node->right);
    }
}

int main(void){
    int n,key;
    
    cin >> n;
    
    for(int i = 0;i < n;++i){
        string input;
        cin >> input;
        // insert
        if(input[0] == 'i'){
            cin >> key;
            insert(key);
        }
        else{
            inOrder(root);
            cout << endl;
            preOrder(root);
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 26492
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}

int main()
{
    vector<ll> v1,v2;
    ll i,j;
    ll x,y;
    ll n;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        v1.push_back(x+y);
        v2.push_back(x-y);

    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    cout<<max(v1[n-1]-v1[0],v2[n-1]-v2[0]);

}



Measured memory_bytes: 6632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    int count=0;
    for(int i=0;i<s.size();i++){
        int ncount=0;
        for(int j=i;j<s.size();j++){
            if(s[j]=='A' || s[j]=='G' || s[j]=='C' || s[j]=='T')ncount++;
            else break;
        }
        count=max(count,ncount);
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#pragma region
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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define x first
#define y second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

void solve()
{
    int n; cin>>n;
    vector<pair<int, int>> p(n);
    forn(i, n) cin >>p[i].x >> p[i].y;
    for(int i=2; i <n;++i)
    {
        if (p[i].x == p[i].y && p[i-1].x == p[i-1].y && p[i-2].x == p[i-2].y)
        {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    // cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << '\n';
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        String s = input.nextLine();
        if(s.length()>=4 && s.substring(0,4).equals("YAKI"))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 23124
while True:
  n, m, t, p = list(map(int, input().split()))
  if n==0:
    break
  gx, gy = 500, 500

  paper = [[0 for i in range(1000)] for i in range(1000)]
  for i in range(n):
    for j in range(m):
      paper[500+i][500+j] = 1
  for _ in range(t):
    d, c = list(map(int, input().split()))
    if d==1:
      gx = gx+c
      for i in range(c):
        for j in range(1000):
          paper[gx+i][j] += paper[gx-i-1][j]
          paper[gx-i-1][j] = 0
    if d==2:
      gy = gy+c
      for i in range(1000):
        for j in range(c):
          paper[i][gy+j] += paper[i][gy-j-1]
          paper[i][gy-j-1] = 0

  for i in range(p):
    x, y = list(map(int, input().split()))
    print(paper[gx+x][gy+y])


Measured memory_bytes: 23300
n=int(input())
a = list(map(int, input().split()))
q=int(input())
bc = [list(map(int, input().split())) for i in range(q)]
memo=[0]*100001
ans=0
for i in range(n):
    ans+=a[i]
    memo[a[i]-1]+=1
for i in range(q):
    memo[bc[i][1]-1]+=memo[bc[i][0]-1]
    ans+=memo[bc[i][0]-1]*(bc[i][1]-bc[i][0])
    memo[bc[i][0]-1]=0
    print(ans)


Measured memory_bytes: 32388
import math
def at(n):
	return math.degrees(math.atan(n))

def main():
	a, b, x = [int(p) for p in input().split(" ")]
	V = a * a * b
	if x < V / 2:
		print(at(a * b * b / (2 * x)))
	else:
		print(at(2*(a*a*b-x)/a**3))

main()


Measured memory_bytes: 9348
#include<bits/stdc++.h>
using namespace std;
bool ans[103];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		int a;
		cin>>a;
		ans[a]=true;
	}
	int mi=100000,cnt=n;
	for(int i=0;i<=102;i++)
	{
		if(ans[i]==true)
			continue;
		if(abs(n-i)<mi)
		{
			mi=abs(n-i);
			cnt=i;
		}
	}
	cout<<cnt;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    ll n, m;
    cin >> n >> m;

    ll ans = 0;
    if(m >= 2*n){
      ans += n;
      m -= 2 * n;
      ans += m / 4;
    }else{
      ans += m / 2;
    }

    cout << ans << endl;

    return 0;
}



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

typedef long long W;

const W INF = 1LL << 50;

struct edge{
	int to;
	W cost;
};
typedef vector<vector <edge > > Graph;

vector<W> dijkstra(int s, const Graph& G){
	typedef pair<W, int> P;
	vector<W> d(G.size(), INF);
	d[s] = 0;
	priority_queue< P, vector<P>, greater<P> > que;
	que.push(P(0, s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
	return d;
}

int d[100000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, M, s, t;
	cin >> N >> M >> s >> t;
	s--, t--;
	Graph G(N);
	for(int i = 0; i < N; i++){
		cin >> d[i];
		if(i) G[i].push_back({ i - 1, 0 });
	}

	for(int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].push_back({ b, d[b] });
	}

	auto res = dijkstra(s, G);
	cout << res[t] << endl;
}

Measured memory_bytes: 14132
import java.util.Scanner;

class Main{

public static void main(String args[]){
Scanner sc=new Scanner(System.in);

int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();

if(a<b && b<c){
    System.out.println("Yes");
}else{
    System.out.println("No");
}

sc.close();

}


}


Measured memory_bytes: 26052
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;
pii w[N];
string s;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int x;
	cin>>x;
	int d = gcd(x, 360);
	cout<<(360/d)<<"\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,n,m,tmp,sum=0,day,ad;
  cin >> n >> m;
  vector<ll> n_list[100001];
  day = 0;
  priority_queue<ll> que;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    n_list[a].push_back(b);
  }
  for(int i=m-1;i>=0;i--){
    tmp = m-i;
    for(int j=0;j<n_list[tmp].size();j++){
      que.push(n_list[tmp][j]);
    }
    if(!que.empty()){
      sum+=que.top();
      que.pop();
    }
  }
  cout << sum <<endl;
}


Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    vector<int> time(5);
    rep(i, 5) cin >> time[i];
    
    int ans = 0;
    rep(i, 5) ans += ((time[i] - 1) / 10 + 1) * 10;
    int M = 10;
    rep(i, 5) {
        if (time[i] % 10 == 0) continue;
        M = min(M, time[i] % 10);
    }
    ans -= 10 - M;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {
	/* --------------------------------------------------------------------
	   main
	 * -------------------------------------------------------------------- */
	public static void main(String args[]) {

		try(BufferedReader input = new BufferedReader(new InputStreamReader(System.in))) {

			// ----- input -----
			final int line1[] = InputUtil.readLine(input.readLine());
			final int col = line1[0];

			//  ----- data -----
			Queue<Data> data = InputUtil.getCollection(input, col);

			// ----- main -----
			int cnt = 0;
			int pre = 0;
			while(!data.isEmpty()) {
				Data d = data.poll();
				if(pre == d.a) {
					cnt++;
					pre = -1;
				} else {
					pre = d.a;
				}
			}

			System.out.println(cnt);

		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}

/* --------------------------------------------------------------------
* inupt class
* -------------------------------------------------------------------- */
class InputUtil {

	public static int[] readLine(String line) {

		String[] vals = line.split(" ");
		int[] data = new int[vals.length];
		int i = 0;

		try {
			for(String val : vals) {
				data[i++] = Integer.parseInt(val);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return data;
	}

	public static Queue<Data> getCollection(BufferedReader input, int num) {

		// Queue<Data> data = new PriorityQueue<>();	// sort
		Queue<Data> data = new ArrayDeque<>();			// fifo
		try {
			String[] line = input.readLine().split(" ");
			for(int i=0; i < num; i++) {
				data.add(new Data(line[i]));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return data;
	}
}

/* --------------------------------------------------------------------
* data class
* -------------------------------------------------------------------- */
class Data implements Comparable<Data>{
	int a;

	public Data(String value) {
		this.a = Integer.parseInt(value);
	}

	@Override
	public int compareTo(Data d) {
		return a - d.a;	// 昇順
//		return d.a - a;		// 降順
	}
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

template <typename T>
struct Union_Find {

  vector<T> par;//親の番号
  vector<T> urank;//集合のランク
  vector<T> usize;//集合の要素数
  T num;//集合の数

  Union_Find() {
    init(100000);
  }

  Union_Find(T n) {
    init(n);
  }

  void init(T n) {//0〜n-1までの要素を初期化 最初はバラバラ
    par.clear();urank.clear();usize.clear();
    par.resize(n);urank.resize(n);usize.resize(n);
    num = n;
    rep(i,n) {
      par[i] = i;
      urank[i] = (T)0;
      usize[i] = (T)1;
    }
  }

  T find(T x) {//xが属する集合の親を見つける
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }

  T get_usize(T x) {//xが属する集合の要素数を返す。
    return usize[find(x)];
  }

  void unite(T x,T y) {//xが属する集合とyが属する集合を併合する。
    x = find(x);
    y = find(y);
    if(x == y) return;

    T s = usize[x] + usize[y];
    num--;
    if(urank[x] < urank[y]) {
      par[x] = y;
      usize[y] = s;
    } else {
      par[y] = x;
      usize[x] = s;
      if(urank[x] == urank[y]) urank[x]++;
    }
  }

  bool same(T x,T y) {//同じ集合に属するかを判定する
    return find(x) == find(y);
  }

  T num_set() {//集合の数(木の数)を返す。
    return num;
  }
};

using ll = long long;

ll n,m;

int main() {
    cin >> n >> m;
    Union_Find<ll> uf(n);

    rep(i,m) {
      ll x,y,z;

      cin >> x >> y >> z;

      x--;y--;

      uf.unite(x,y);
    }

    cout << uf.num << endl;

    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <string>
#include <deque>

#pragma GCC optimize("O3")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef  double dbl;
typedef string str;



#define drobucs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define ff first
//#define ss second
#define pb push_back

const int  MOD = 1e9 + 7;
const int MAXN = 1e3 + 10;
const int INF = 2e9;
const ll INFL = 2e18;



int main() {
	drobucs;

	int n, k;
	str s, t = "i";
	cin >> n >> k >> s;
	int happy = 0;
	t += s;
	t += 't';
	for (int i = 1; i <= n; ++i) {
		if (t[i] == 'L') {
			if (t[i] == t[i + 1])happy++;
		}
		else {
			if (t[i] == t[i - 1])happy++;
		}
	}

	cout << min(happy + 2 * k, n - 1);

	return 0;
}


Measured memory_bytes: 512
Q = int(input())

mod = 10 ** 6 + 3
table = [1]
for i in range(1, mod):
    table.append(table[-1]*i % mod)

for i in range(Q):
    x, d, n = map(int, input().split())
    if d == 0:
        print(pow(x, n, mod))
    else:
        y = x * pow(d, mod - 2, mod) % mod
        if y + n - 1 >= mod:
            print(0)
        else:
            print(pow(d, n, mod) * table[y + n - 1] * pow(table[y - 1], mod - 2, mod) % mod)

Measured memory_bytes: 93804
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		while (true) {

			int a = scan.nextInt();
			String op = scan.next();
			int c = scan.nextInt();

			if (op.equals("+")) {
				System.out.println(a + c);
			} else if (op.equals("-")) {
				System.out.println(a - c);
			} else if (op.equals("*")) {
				System.out.println(a * c);
			} else if (op.equals("/")) {
				System.out.println(a / c);
			} else if (op.equals("?")) {
				break;
			}

		}

	}

}

Measured memory_bytes: 26112
#!usr/bin/env python3

'''
time score 7.88 for list
time score 03.17 for deque
time score 03.22 for defaultdict(dict)

''' 

from collections import defaultdict
from collections import deque
#import time

def main():
    # Read stdin
    #start = time.clock()
    fl = input().split(" ")
    V = int(fl[0])
    E = int(fl[1])
    R = int(fl[2])
    # Adjacency list
    G = defaultdict(list)
    for i in range(E):
        s, t, w = [int(x) for x in input().split(" ")]
        G[s].append((t, w))
    # initialized
    d = {}
    INF = float('inf')
    # INF = 10001
    nodes_list = range(V)
    for i in nodes_list:
        d[i] = INF
    d[R] = 0
    # deque is better than list aka double link list O(1) for pop head and append
    q = deque([R])
    while q:
        # u = heappop(q)
        u = q.popleft()
        for v in G[u]:
            if d[v[0]] > d[u] + v[1]:
                d[v[0]] = d[u] + v[1]
                # heappush(q, v[0])
                q.append(v[0])
    for k in nodes_list:
        if d[k] == float('inf'):
            print("INF")
        else:
            print(d[k])
    #end = time.clock() - start
    #print('Computation time : {}'.format(end))


if __name__ == '__main__':
    main()

Measured memory_bytes: 106748
#include <iostream>
#include<vector>
using namespace std;
vector<vector<long long>>v;
int main()
{
   long long T,n,flag,t,x,ans;
   cin>>n>>T;
   vector<long long>::iterator it;
   while(T--)
   {
       v.resize(n);
       cin>>flag>>t;
       switch(flag){
       case 0:
           cin>>x;
           v[t].push_back(x);
           break;
       case 1:
           for(ans=0,it=v[t].begin();it!=v[t].end();it++)
           {
               if(ans!=0)cout<<" ";
               cout<<*it;
               ans++;
           }
           cout<<endl;
           break;
       case 2:
           v[t].clear();
           break;
       }
   }
    return 0;
}
/*
||=== Build: Debug in T1vector2 (compiler: GNU GCC Compiler) ===|
C:\Users\86133\Desktop\stl第一场训练\T1vector2\main.cpp||In function 'int main()':|
C:\Users\86133\Desktop\stl第一场训练\T1vector2\main.cpp|28|error: jump to case label [-fpermissive]|
C:\Users\86133\Desktop\stl第一场训练\T1vector2\main.cpp|19|note:   crosses initialization of 'int ans'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
*/



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> a(n + 1);
  vector<int> b(n);
  for (int i = 0; i < n + 1; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  long long tot = 0;
  for (int i = 0; i < n; i++) {
    tot += min(b[i], a[i]);
    b[i] = max(0, b[i] - a[i]);
    tot += min(b[i], a[i+1]);
    a[i+1] = max(0, a[i+1] - b[i]);
  }
  cout << tot << '\n';
  return 0;
}

Measured memory_bytes: 1024
n=int(input())
A=list(map(int,input().split()))
ans=0
fail=0

while fail==0:
    for i in range(n):
        if A[i]%2==1:
            fail=1
    if fail==1:
        break
    else:
        for i in range(n):
            A[i]/=2
        ans+=1

print(ans)

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

int main(){
  int N, A;
  cin >> N >> A;
  bool can = false;
  for(int i = 0; i <= A; ++i){
    if((N-i)% 500 == 0){
      can = true;
      break;
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

#define N 5005
ll d[N],d2[N];
void solve(){
    ll k,q;cin>>k>>q;
    rep(i,k)cin>>d[i];
    while(q--){
        ll n,x,m;cin>>n>>x>>m;
        rep(i,k)d2[i]=d[i]%m;
        ll cnt=0;
        ll sum=0;
        rep(i,k){
            sum+=d2[i];
            if(d2[i]==0)cnt++;
        }
        cnt*=(n-1)/k;
        sum=x%m+sum*((n-1)/k);
        rep(i,(n-1)%k){
            sum+=d2[i];
            if(d2[i]==0)cnt++;
        }
        cout<<n-1-cnt-sum/m<<endl;
    }
}

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


Measured memory_bytes: 384
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	string s = read;
	
	X[] xs;
	int a, b;
	int f = 0;
	foreach(c; s){
		log("c:", c, "f:", f, "a:", a, "b:", b);
		if(f == 0){
			if(c == 'R') f = 1, a = 1;
		}
		else if(f == 1){
			if(c == 'R') a += 1;
			else f = 2, b = 1;
		}
		else{
			if(c == 'L') b += 1;
			else f = 1, xs ~= X(a, b), a = 1;
		}
	}
	xs ~= X(a, b);
	log("xs:", xs);
	
	int[] ans;
	foreach(x; xs) ans ~= x.ans;
	
	ans.map!(to!string).array.join(" ").writeln;
}
struct X{
	int a, b;
	int[] ans(){
		int total = a + b;
		int y = total / 2, x = total - y;
		X u;
		if(a % 2) u = X(x, y);
		else u = X(y, x);
	
		int[] res;
		foreach(i; 0 .. a - 1) res ~= 0;
		res ~= u.a;
		res ~= u.b;
		foreach(i; 0 .. b - 1) res ~= 0;
		
		return res;
	}
}


Measured memory_bytes: 7832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
#define pb  push_back
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(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])
          cout << p << " ";
}
int main()
{FAST
int n;
cin>>n;
int a[n],v=0;
FOR(i,n)
{
	cin>>a[i];
}
sort(a,a+n);
FOR(i,n-1)
{
	if(a[i]==a[i+1])
	{
		cout<<"NO"<<endl;
		v++;
		break;
	}
}
if(!v)
{
		cout<<"YES"<<endl;
}
return  0;
}




Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	
#include<list>

constexpr auto PI = 3.14159265359;

using namespace std;

class binary_tree {
public:
	binary_tree(int N) {
		_tree.resize(N);
	}
	void set_nodeID(int id) { 
		_tree[id].node_id = id; 
	}
	void set_sibling(int left, int right) {
		if (left != -1 && right != -1) {
			_tree[right].sibling = left;
			_tree[left].sibling = right;
		}
		else if (left != -1) {
			_tree[left].sibling = right;
		}
		else if(right != -1){
			_tree[right].sibling = left;
		}
	}
	void set_parent(int _parent, int left, int right) {
		if (left != -1 && right != -1) {
			_tree[right].parent = _parent;
			_tree[left].parent = _parent;


			_tree[_parent].degree = 2;
			_tree[_parent].left = left;
			_tree[_parent].right = right;

		}
		else if (left != -1) {
			_tree[left].parent = _parent;
			_tree[_parent].degree = 1;
			_tree[_parent].left = left;
		}
		else if(right != -1){
			_tree[right].parent = _parent;
			_tree[_parent].degree = 1;
			_tree[_parent].right = right;
		}
		else {
			_tree[_parent].degree = 0;
		}
	}

	int set_depth(int _nodeID, int _depth) {
		if (_nodeID == -1)return -1;
		_tree[_nodeID].depth = _depth;
		set_depth(_tree[_nodeID].left, _tree[_nodeID].depth + 1);
		set_depth(_tree[_nodeID].right, _tree[_nodeID].depth + 1);
		return _tree[_nodeID].depth;
	}
	int set_height(int _nodeID) {
		if (_nodeID == -1)return -1;
		_tree[_nodeID].height = max(set_height(_tree[_nodeID].left), set_height(_tree[_nodeID].right)) + 1;
		return _tree[_nodeID].height;
	}

	void set_nodeType(int _nodeID) {
		if (_tree[_nodeID].parent == -1) {
			_tree[_nodeID].node_type = "root";
			root_node = _nodeID;
		}
		else if (_tree[_nodeID].right == -1 && _tree[_nodeID].left == -1) {
			_tree[_nodeID].node_type = "leaf";
		}
		else {
			_tree[_nodeID].node_type = "internal node";
		}
	}
	struct tree {
		int node_id;
		int parent = -1;
		int sibling = -1;
		int right = -1;
		int left = -1;
		int degree = 0;
		int depth = 0;
		int height = 0;
		string node_type = "root";
	};
	int root_node;
	vector<tree> _tree;
};


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

	for (int i = 0; i < N; ++i) {
		int id, left, right;
		cin >> id >> left >> right;
		tree.set_nodeID(id);
		tree.set_sibling(left, right);
		tree.set_parent(id, left, right);
	}
	for (int i = 0; i < N; ++i) {
		tree.set_nodeType(i);
	}

	tree.set_height(tree.root_node);
	tree.set_depth(tree.root_node, 0);


	for (int i = 0; i < N; ++i) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
			tree._tree[i].node_id,
			tree._tree[i].parent,
			tree._tree[i].sibling,
			tree._tree[i].degree,
			tree._tree[i].depth,
			tree._tree[i].height
			);
		cout << tree._tree[i].node_type << "\n";
	}
	return 0;
}


Measured memory_bytes: 3316
#include<stdio.h>
int main(void){
 char s[10];
  int i=0;
  int cnt=0;
  int max=0;
  
  scanf("%s", s);
  
  while(s[i]){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      cnt++;
    }
    else{
      cnt=0;
    }
    if(max<cnt){
       max=cnt;
     }
    i++;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
 
template<class T> bool uin(T &a, T b) {return (a < b ? false : (a = b, true));}
template<class T> bool uax(T &a, T b) {return (a > b ? false : (a = b, true));}
 
//~ ifstream f(".in");
//~ ofstream g(".out");
 
struct Block {
  int w, s, v;
};
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen(".in", "r", stdin);
#endif
 
  int n;
  cin >> n;
  int max_s = 0;
  vector<Block> blocks(n + 2);
  for (int i = 1; i <= n; ++i) {
    int w, s, v;
    uax(max_s, s);
    cin >> w >> s >> v;
    blocks[i] = {w, s, v};
  }
  sort(blocks.begin() + 1, blocks.begin() + n + 1,
    [&](const Block &a, const Block &b) {
      return a.w + a.s < b.w + b.s;
  });
  
  ll ans = 0;
  vector<ll> dp(20005);
  for (int i = 1; i <= n; ++i) {
    for (int w = blocks[i].s; w >= 0; --w) {
      uax(dp[w + blocks[i].w], dp[w] + blocks[i].v);
    }
  }
  for (int i = 0; i <= (int)2e4 + 1; ++i) {
    uax(ans, dp[i]);
  }
  
  cout << ans << '\n';
 
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 384
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(6, 2), 2)

    def test_2(self):
        self.assertEqual(think(14, 3), 2)

    def test_3(self):
        self.assertEqual(think(20, 4), 3)


def solve():
    n, d = read()
    result = think(n, d)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, d):
    territory = 2 * d + 1
    if n % territory == 0:
        return n // territory
    return n // territory + 1


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 5620
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int N, t = 0, s = 0;
	scanf("%d", &N);
	t = N;
	while (t) {
		s += t % 10;
		t /= 10;
	}
	if (N%s == 0) return !printf("Yes\n");
	return !printf("No\n");
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

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

    if (K <= N) {
        int ans = 0;
        for (int i = 0; i < K; i++) ans = A[ans];
        cout << ans+1 << endl;
        return 0;
    }

    vector<bool> visited(N, false);
    vector<int> counter(N);
    visited[0] = true;
    counter[0] = 0;
    int cnt = 0;
    int node = 0;

    int loop_sz;
    int start;

    while (true) {
        int next = A[node];
        cnt++;

        if (visited[next]) {
            start = next;
            loop_sz = cnt - counter[next];
            break;
        }

        visited[next] = true;
        counter[next] = counter[node] + 1;
        node = next;
    }

    int remain = K - cnt;
    remain %= loop_sz;

    int ans = start;
    for (int i = 0; i < remain; i++) ans = A[ans];
    cout << ans+1 << endl;

    return 0;
}

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


int main() {

   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   int k, a, b;
   cin >> k >> a >> b;
   for (int i = a; i <= b; i++) {
      if (i % k == 0) {
         cout << "OK" << endl;
         return 0;
      }
   }
   cout << "NG" << endl;

   return 0;
}

Measured memory_bytes: 3612
from collections import defaultdict
n = int(input())
d = defaultdict(int)
S = [input() for _ in range(n)]
for i in range(ord('a'), ord('z')+1):
  c = chr(i)
  count = S[0].count(c)
  for s in S[1:]:
    count = min(count, s.count(c))
  d[c] = count

for k,v in sorted(d.items()):
  for _ in range(v):
    print(k, end='')
print()

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

int cnt(ll num){
	int i=0;
	for(;num>=1;i++){
		num /= 10;
	}
	return i;
}

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

	ll n;
	cin >> n;
	int ans;
	ans = cnt(n);

	for(int i=sqrt(n);i>=1;i--){
		if(n%i == 0) {
			cout << cnt(n/i) << "\n";
			return 0;
		}
	}
}

Measured memory_bytes: 256
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
ll n;
string ans;
int main(){
fcin;
    cin >> n;
    ll p = 1;
    while(n){
        n-=p;
        char x = ('a' + (n/p)%26);
        ans = x + ans;
        p*=26;
        if(p>n) break;
    }
    cout << ans << '\n';

}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main(){
  int Q, H, S, D;
  cin >> Q >> H >> S >> D;
  long long N;
  cin >> N;
  H = min(H, Q * 2);
  S = min(S, H * 2);
  D = min(D, S * 2);
  cout << (N / 2) * D + (N % 2) * S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	cout << max({(N-1)/A, (N-1)/B, (N-1)/C, (N-1)/D, (N-1)/E}) + 5 << endl ;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

class Program
{
	static void Main(string[] args)
	{
		string N = Console.ReadLine();
		string s = N.Substring(N.Length - 1, 1);

		if(s == "3")
			Console.WriteLine("bon");
		else if(s == "0" || s == "1" || s == "6" || s == "8")
			Console.WriteLine("pon");
		else
			Console.WriteLine("hon");
	}

	/// <summary>
	/// アナグラム
	/// </summary>
	/// <param name="word1"></param>
	/// <param name="word2"></param>
	/// <returns></returns>
	static bool IsAnagramOf(string word1, string word2)
	{
		return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
	}
	/// <summary>
	/// 最小公倍数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Lcm(long a, long b)
	{
		return a * b / Gcd(a, b);
	}

	/// <summary>
	/// 最大公約数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Gcd(long a, long b)
	{
		if (a < b)
			// 引数を入替えて自分を呼び出す
			return Gcd(b, a);
		while (b != 0)
		{
			var remainder = a % b;
			a = b;
			b = remainder;
		}
		return a;
	}
}




//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 25860
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.begin(),v.end(),greater<int>());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
using namespace std;
int main()
{
    rj
    ll a,b,c,d;
    cin>>a>>b>>c;
    if(c>=b-1)
    {

       cout<<a*(b-1)/b<<endl;
    }
    else
    {


       cout<<a*c/b<<endl;
    }


    return 0;
}


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

int main()
{
  int N, sum = 0;

  cin >> N;

  int A[N];

  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
    if (A[i] % 2 == 1)
    {
      cout << 0 << endl;
      exit(0);
    }
  }

  while (true)
  {
    for (int i = 0; i < N; i++)
    {
      if (A[i] % 2 == 1)
      {
        cout << sum << endl;
        exit(0);
      }
      else
      {
        A[i] /= 2;
      }
    }
    sum++;
  }
}

Measured memory_bytes: 256
def BubbleSort(A):
    count = 0
    for i in range(len(A)):
        for j in reversed(range(len(A) - 1, 0, -1)):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                count += 1
    return A, count

N = int(input())
A = list(map(int, input().split()))
bubble_sort, count = BubbleSort(A)
print(*bubble_sort)
print(count)


Measured memory_bytes: 5616
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(LCM(ab[0], ab[1]));
    }


    static long LCM(long a, long b) { return a / GCD(a, b) * b; }

    static long GCD(long a, long b)
    {
        while (true)
        {
            if (b == 0) return a;
            a %= b;
            if (a == 0) return b;
            b %= a;
        }
    }
}


Measured memory_bytes: 13396
import sys


def binary_search(a, t, n):
    low = 0
    high = n - 1
    while low <= high:
        mid = (high + low) // 2
        if a[mid] == t:
            return True
        elif a[mid] < t:
            low = mid + 1
        else:
            high = mid - 1
    return False


def main():
    n = int(sys.stdin.readline())
    s = [int(x) for x in sys.stdin.readline().split()]
    q = int(sys.stdin.readline())
    t = [int(x) for x in sys.stdin.readline().split()]
    cnt = 0

    for i in t:
        if binary_search(s, i, n):
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

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

int main() {
  int n; cin >> n;
  int64_t r = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 5 != 0 && i % 3 != 0) {
      r += i;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
using namespace std;


int p[8];
int m[] = {4, 1, 4, 1, 2, 1, 2, 1, 4, 1, 4, 1, 2, 1, 2, 1};

int to_i(string s) {
    istringstream is(s);
    int n; is >> n;
    return n;
}

int hash(int index) {
    string s;
    for (int i = index; i < index+8; i++) 
        s.push_back(m[i] + '0');
    return to_i(s);
}

string to_s(int n) {
    ostringstream os;
    os << n;
    return os.str();
}

string format(int n) {
    string s = to_s(n);
    string t;
    t.push_back(s[0]);
    for (int i = 1; i < 8; i++) {
        t.push_back(' ');
        t.push_back(s[i]);
    }
    return t;
}

const int INF = 1<<28;
int main() {
    while (cin >> p[0]) {
        for (int i = 1; i < 8; i++) cin >> p[i];

        int min_wait = INF;
        int min_hash = INF;
        for (int i = 0; i < 8; i++) {
            int wait = 0;
            for (int j = 0; j < 8; j++) {
                if (m[i+j] < p[j]) {
                    wait += (p[j] - m[i+j]);
                }
            }
            if (min_wait > wait) {
                min_wait = wait;
                min_hash = hash(i);
            } else if (min_wait == wait) {
                min_hash = min(min_hash, hash(i));
            }
        }

        cout << format(min_hash) << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include <cstdio>
int n, a, i;
int main() {
	scanf("%d", &n);
	if(n==3) {puts("2 5 63"); return 0;}
	a = n%3 ? n-2 : n-4;
	if(a>15000) a = a%2 ? 14999 : 15000;
	for(i=1; i<=a; i++) printf("%d ", 2*i);
	for(i=0; i<n-a; i++) printf("%d ", 6*i+3);
	return 0;
}

Measured memory_bytes: 256