akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int main(void){
    long long int h,k,l;

    scanf("%lld",&h);

    k = floorl(log2l((long double)h));

    l = powl(2,(long double)k + 1);

    printf("%lld",(long long int)l - 1);

    return 0;

}

Measured memory_bytes: 256
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long llong;
using namespace std;



int main() {
	int S[20];
	int H[20];
	int C[20];
	int D[20];

	int ipt_n;
	char ipt_c;
	int n;
	for (int i = 0; i < 20; i++) {
		S[i] = 0;
		H[i] = 0;
		C[i] = 0;
		D[i] = 0;
	}
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ipt_c >> ipt_n;
		if (ipt_c == 'S')S[ipt_n] = 1;
		if (ipt_c == 'H')H[ipt_n] = 1;
		if (ipt_c == 'C')C[ipt_n] = 1;
		if (ipt_c == 'D')D[ipt_n] = 1;
	}

	for (int i = 1; i <= 13; i++) {
		if (S[i] == 0)cout << "S " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (H[i] == 0)cout << "H " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (C[i] == 0)cout << "C " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (D[i] == 0)cout << "D " << i << endl;
	}

	return 0;
}



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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		String[] a = toStringArray(nextString());
		String[] b = toStringArray(nextString());
		String[] c = toStringArray(nextString());
		int ai=0;
		int bi=0;
		int ci=0;
		String next="a";
		String ans ="";
		while(ai<=a.length&&bi<=b.length&&ci<=c.length){
			if("a".equals(next)){
				if(ai==a.length){
					ans="A";
					break;
				}
				next=a[ai];
				ai++;
			}else if("b".equals(next)){
				if(bi==b.length){
					ans="B";
					break;
				}
				next=b[bi];
				bi++;

			}else{
				if(ci==c.length){
					ans="C";
					break;
				}
				next=c[ci];
				ci++;

			}
		}
		System.out.println(ans);

	}

public static long gcd(long a, long b) {
	long x, y;
	if (a < b) {
		x = b;
		y = a;
	} else {
		x = a;
		y = b;
	}
	long r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

public static long lcm(long a, long b) {
	long x, y;

	return ((a/gcd(a,b))*b);
}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 23124
def sol(t, tis):
    flow = 0
    ret = 0
    for ti in tis:
        ret += min(ti + t - flow, t)
        flow = ti + t

    return ret


if __name__ == "__main__":
    n, t = map(int, raw_input().strip().split())
    tis = map(int, raw_input().strip().split())
    print sol(t, tis)



Measured memory_bytes: 20036
from collections import deque

N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    # グラフに頂点と距離を追加
    G[u-1].append((v-1,w))
    G[v-1].append((u-1,w))


used = [0] * N
que = deque([0])
ans = [False] * N
while que:
    # print(list(que))
    u = que.popleft()
    for v,w in G[u]:
        if used[v]:
            # すでにチェックされていたら無視
            continue
        else:
            # wが奇数⇨色を分ける
            # wが偶数⇨色をそのまま
            if w%2 == 0:
                ans[v] = ans[u]
            else:
                ans[v] = not ans[u]
            # print(w,ans[u],ans[v])
            que.append(v)
            used[u] = True
for a in ans:
    print(int(a))

Measured memory_bytes: 39928
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  int m = n;
  int x = 0;
  while(m != 0){
    x += m%10;
    m /= 10;
  }
  if(n%x) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
    int a,b,c;

    cin>>a>>b>>c;

    int sum = a+b+c;
    if(sum % 2 == 1)
    {
	cout<<"No"<<endl;
    } else {
	if(sum/2 == a || sum/2 == b || sum/2 == c)
	    cout<<"Yes"<<endl;
	else
	    cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val K = sc.nextInt()
    val H = LongArray(N){0L}
    for (i in 0 until N) {
        val h = sc.nextLong()
        H[i] = h
    }
    H.sort()
    var ans = 1000000001L
    for (i in 0 .. N-K) {
        val dh = H[K+i-1]- H[i]
        if (ans > dh) ans = dh
    }

    println(ans)
}


Measured memory_bytes: 57160
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  set<char> S;
  int N; cin >> N;
  char s;
  FOR(i,0,N) {
    cin >> s;
    S.insert(s);
  }
  cout << (S.size() == 3 ? "Three" : "Four") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>

using namespace std;

#define ll long long

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

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

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void input(vector<T> &vec, int n){
	T temp;
	For(i, n){
		cin >> temp;
		vec.push_back(temp);
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
	Vec(int _x, int _y):
	x(_x), y(_y){}
};

template<typename T> void print(T *x, int n){
	For(i, n){
		cout << x[i] << " ";
	}
	cout << endl;
}

template<typename T> void print(vector<T> &x){
	For(i, (int)x.size()){
		cout << x[i] << " ";
	}
	cout << endl;
}

int gcd(int n, int m){
	if(n % m == 0){
		return m;
	}
	else{
		return gcd(m, n % m);
	}
}

unsigned ll func(unsigned ll n, unsigned ll i){

	n++;
	if(n >> i == 0){
		return 0;
	}
	unsigned ll num_one = (n / (2 << i)) * (1 << i);

	if((n % (2 << i)) != 0 && (n % (2 << i)) - (1 << i) > 0){
		num_one += (n % (2 << i)) - (1 << i);
	}

	return num_one;

}

int main(){

	int n;
	string s;

	in(n);

	int numAB = 0;
	int lastA = 0;
	int firstB = 0;
	int firstBlastA = 0;
	bool flugA;
	bool flugfirstB;

	For(i, n){
		in(s);
		flugA = false;
		flugfirstB = false;
		int lastIndex = (int)s.size() - 1;

		if(s[0] == 'B'){
			firstB++;
			flugfirstB = true;
		}
		else if(s[0] == 'A'){
			flugA = true;
		}

		for(int j = 1; j < lastIndex; j++){
			if(s[j] == 'A'){
				flugA = true;
				continue;
			}
			else if(s[j] == 'B' && flugA){
				numAB++;
			}
		
			flugA = false;
			
		}

		if(s[lastIndex] == 'A'){
			lastA++;
			if(flugfirstB){
				firstBlastA++;
			}
		}
		else if(s[lastIndex] == 'B' && flugA){
			numAB++;
		}
	}

	if(firstBlastA > 0 && lastA == firstBlastA && firstB == firstBlastA){
		numAB += firstBlastA - 1;
	}
	else if(lastA > firstB){
		numAB += firstB;
	}
	else{
		numAB += lastA;
	}

	out(numAB);

	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int a,b,c;
int tmp;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);

if(a>b){
tmp=a;
a=b;
b=tmp;
}
if(b>c){
tmp=b;
b=c;
c=tmp;
}
if(a>b){
tmp=a;
a=b;
b=tmp;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 592
use proconio::input;

fn solve(n: usize, a: Vec<i32>) -> Vec<i32> {
    let mut res: Vec<i32> = vec![0; n];
    for i in 0..(n-1) {
        res[(a[i] - 1) as usize] += 1;
    }
    res
}

fn main() {
    input! {
        n: usize,
        a: [i32; n - 1],
    }
    let r = solve(n, a);
    for i in r {
        println!("{}", i);
    }
}


Measured memory_bytes: 4768
#include <cstdio>
#include <queue>
#include <algorithm>
#include <climits>
#include <map>
#include <vector>
 
#define MAX_K (200010)
 
typedef long long lint;
 
using namespace std;
 
struct Point {
	int x, y, id;
	Point(int x, int y, int id) : x(x), y(y), id(id) {}
	Point() {}
};
 
struct Edge {
	int to;
	lint cost;
	Edge(int to, lint cost) : to(to), cost(cost){}
	Edge() {}
};
 
bool cmpx(const Point &a, const Point &b)
{
	if (a.x - b.x) return (a.x < b.x);
	return (a.y < b.y);
}
 
bool cmpy(const Point &a, const Point &b)
{
	if (a.y - b.y) return (a.y < b.y);
	return (a.x < b.x);
}
 
bool operator > (const Edge &a, const Edge &b)
{
	return (a.cost > b.cost);
}
	
vector<Point> Xv, Yv;
vector<Edge> G[(MAX_K + 2) * 2];
lint dist[(MAX_K + 2) * 2];
 
int main()
{
	int M, N, K;
	
	scanf("%d %d %d", &M, &N, &K);
	
	Xv.push_back(Point(0, 0, 0));
	Xv.push_back(Point(M - 1, N - 1, 1)); Yv.push_back(Point(M - 1, N - 1, MAX_K + 1));
	G[1].push_back(Edge(MAX_K + 1, 1)); G[MAX_K + 1].push_back(Edge(1, 1));
	for (int i = 2; i < K + 2; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		
		Xv.push_back(Point(x - 1, y - 1, i)); Yv.push_back(Point(x - 1, y - 1, MAX_K + i));
		G[i].push_back(Edge(i + MAX_K, 1));
		G[MAX_K + i].push_back(Edge(i, 1));
	}
	
	sort(Xv.begin(), Xv.end(), cmpx);
	sort(Yv.begin(), Yv.end(), cmpy);
	
	for (int i = 0; i < Xv.size() - 1; i++){
		if (Xv[i].x == Xv[i + 1].x){
			G[Xv[i].id].push_back(Edge(Xv[i + 1].id, abs(Xv[i].y - Xv[i + 1].y)));
			G[Xv[i + 1].id].push_back(Edge(Xv[i].id, abs(Xv[i].y - Xv[i + 1].y)));
		}
	}
	
	for (int i = 0; i < Yv.size() - 1; i++){
		if (Yv[i].y == Yv[i + 1].y){
			G[Yv[i].id].push_back(Edge(Yv[i + 1].id, abs(Yv[i].x - Yv[i + 1].x)));
			G[Yv[i + 1].id].push_back(Edge(Yv[i].id, abs(Yv[i].x - Yv[i + 1].x)));
		}
	}
	
	fill(dist, dist + (MAX_K + 2) * 2, LLONG_MAX);
	
	priority_queue<Edge, vector<Edge>, greater<Edge> > pq;
	
	for (pq.push(Edge(0, 0)); pq.size(); pq.pop()){
		Edge e = pq.top();
		if (e.to == 1 || e.to == MAX_K + 1) return (!printf("%lld\n", e.cost));
		if (dist[e.to] <= e.cost) continue;
		dist[e.to] = e.cost;
		
		for (int i = 0; i < G[e.to].size(); i++){
			pq.push(Edge(G[e.to][i].to, e.cost + G[e.to][i].cost));
		}
	}
	
	printf("-1\n");
	
	return (0);
}

Measured memory_bytes: 53400
S = input()

max0 = 0
max1 = 0
amax0 = []
amax1 = []
mi0 = 0
mi1 = 0
h0 = 0
h1 = 0
for i, c in enumerate(S):
    if c=="1":
        h1 += 1
        if h1-mi1 > max1:
            max1 = h1-mi1
            amax1 = [i]
        elif h1-mi1 == max1:
            amax1.append(i)
        h0 -= 1
        if h0 < mi0:
            mi0 = h0
    elif c=="0":
        h1 -= 1
        if h1 < mi1:
            mi1 = h1
        h0 += 1
        if h0-mi0 > max0:
            max0 = h0-mi0
            amax0 = [i]
        elif h0-mi0 == max0:
            amax0.append(i)
    else:
        h1 -= 1
        if h1 < mi1:
            mi1 = h1
        h0 -= 1
        if h0 < mi0:
            mi0 = h0
# if max0 < max1:
#     ma = max1
#     idx_max = amax1
# else:
#     ma = max0
#     idx_max = amax0
if max0 < max1:
    if len(set([i%2 for i in amax1]))==1:
        print(max1)
    else:
        print(max1+1)
elif max0 > max1:
    if len(set([i%2 for i in amax0]))==1:
        print(max0)
    else:
        print(max0+1)
else:
    if len(set([i%2 for i in amax1]+[(max0+i)%2 for i in amax0]))==1:
        print(max0)
    else:
        print(max0+1)


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

int s[100010], t[100010], n, l, r, L, R;
string S, T;

int main() {
    iostream::sync_with_stdio(0); cin.tie(0);
    cin >> S >> T >> n;
    for(int i = 1; i <= S.length(); i++) s[i] = (s[i-1] + (S[i-1] - 'A' + 1)) % 3;
    for(int i = 1; i <= T.length(); i++) t[i] = (t[i-1] + (T[i-1] - 'A' + 1)) % 3;
    while(n--) {
        cin >> l >> r >> L >> R;
        if((s[r] - s[l-1] - t[R] + t[L-1]) % 3 == 0) cout << "YES\n";
        else cout << "NO\n";
    }
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;
    multiset<int> s;
    rep(i, n) {
        int a;
        cin >> a;
        auto it = s.lower_bound(a);
        if ((sz(s) > 0) && (it != s.begin()) && (*(--it) < a)) s.erase(it);
        s.insert(a);
    }
    cout << sz(s) << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm> 
#define int long long
using namespace std;

int a[100000];
int b[100000];
signed main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0;
	if (n & 1) {
		b[0] = a[n / 2];
		for (int i = 2; i < n; i += 2) {
			b[i] = a[i / 2 - 1];
		}
		for (int i = 1; i < n; i += 2) {
			b[i] = a[n - i/2-1];
		}
		for (int i = 1; i < n; i++)ans += abs(b[i] - b[i - 1]);
	}
	else {
		b[0] = a[n / 2-1];
		b[n - 1] = a[n / 2];
		for (int i = 2; i < n; i += 2) {
			b[i] = a[i / 2 - 1];
		}
		for (int i = 1; i+1 < n; i += 2) {
			b[i] = a[n - i / 2 - 1];
		}
		int ans = 0;
		for (int i = 1; i < n; i++)ans += abs(b[i] - b[i - 1]);
	}
	int c = ans;
	ans = 0;
	for (int i = 0; i < n; i++) {
		a[i] = 10000000000ll - a[i];
	}
	sort(a, a + n);
	if (n & 1) {
		b[0] = a[n / 2];
		for (int i = 2; i < n; i += 2) {
			b[i] = a[i / 2 - 1];
		}
		for (int i = 1; i < n; i += 2) {
			b[i] = a[n - i / 2 - 1];
		}
		for (int i = 1; i < n; i++)ans += abs(b[i] - b[i - 1]);
		cout << max(c, ans) << endl;
	}
	else {
		b[0] = a[n / 2 - 1];
		b[n - 1] = a[n / 2];
		for (int i = 2; i < n; i += 2) {
			b[i] = a[i / 2 - 1];
		}
		for (int i = 1; i + 1 < n; i += 2) {
			b[i] = a[n - i / 2 - 1];
		}
		int ans = 0;
		for (int i = 1; i < n; i++)ans += abs(b[i] - b[i - 1]);
		cout << max(c, ans) << endl;
	}
}

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

int main()
{
	long long int n;
	cin>>n;
	long long int temp;
	long long int prev=0,i;
	long long int sum=0,maxnum=0;
	for(i=0;i<n;i++)
	{
		cin>>temp;
		maxnum=max(temp,maxnum);
		if(temp<prev)
		{
			sum+=prev-temp;
		}
		prev=max(prev,maxnum);
	}
	cout<<sum;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


int main()
{
	int N = 5;
	vector<int> Ps(N);

	int sum = 0;
	int min_mod = 10;
	int mod;
	for (int ni = 0; ni < N; ni++){
		cin >> Ps[ni];
		sum += (int)(ceil(Ps[ni]/10.0) * 10);
		mod = (Ps[ni]-1) % 10 + 1; 
		if ( mod < min_mod){
			min_mod = mod;
		}
	}

	int ans = sum - (10 - min_mod);
	std::cout << ans;

	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = []
mod = 10**9 + 7

if N % 2 == 0:
    for i in range(1, N, 2):
        B.append(i)
        B.append(i)
else:
    B.append(0)
    for i in range(2, N, 2):
        B.append(i)
        B.append(i)

if A != B:
    ans = 0
else:
    ans = 2 ** (N // 2) % mod

print(ans)

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

const ll MOD = 1e9+7;

int main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    rep(i,0,n) cin >> a[i];
    sort(a,a+n,greater<ll>());

    ll memo = 1;
    rep(i,2,n){
        if(abs(a[0]/2 - a[memo]) > abs(a[0]/2 - a[i])){
            memo = i;
        }
    }

    cout << a[0] << " " << a[memo] << endl;
}


Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  vector<pair<int, int>> A(100010);

  cin >> N;
  for (int i=0; i<N; i++){
    A[i].second = i+1;
    cin >> A[i].first;
  }

  sort(A.begin(), A.begin()+N);

  for (int i=0; i<N; i++){
    cout << A[i].second;
    if(i != N-1){
      cout << " ";
     } else {
      cout << endl;
     }
  }
}

Measured memory_bytes: 1664
def main(argv)
  n = gets.chomp.to_i
  a = gets.chomp.split(' ').map(&:to_i)
  b = gets.chomp.split(' ').map(&:to_i)
  
  s = 0
  n.times do |i|
    if b[i] <= a[i] then
      s += b[i]
      
      a[i] -= b[i]
    else
      r = b[i] - a[i]
      s += a[i]
      
      a[i] = 0
      
      if r <= a[i + 1] then
        s += r
        
        a[i + 1] -= r
      else
        s += a[i + 1]
        
        a[i + 1] = 0
      end
    end
  end
  
  puts s.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 17572
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

y, m, d = map(int, raw_input().split('/'))

d1 = y * 100000 + m * 1000 + d
d2 = 2019 * 100000 + 4 * 1000 + 30

print 'Heisei' if d1 <= d2 else 'TBD'

Measured memory_bytes: 2808
#include <stdio.h>

int main(void){
  int n;
  int p[50][2];
  int i;
  int loop=1;
  double area;

  while( 1 ){
    scanf("%d ",&n);
    if( !n )
      break;

    area = 0.0;
    for(i=0;i<n;i++){
      scanf("%d %d ",&p[i][0],&p[i][1]);
    }
    for(i=0;i<n-1;i++)
      area = area+(p[i][0]-p[i+1][0])*(p[i][1]+p[i+1][1]);
    area = area+(p[n-1][0]-p[0][0])*(p[n-1][1]+p[0][1]);

    area = area/2.0;
    if( area<0 ) area=-area;

    printf("%d %.1f\n",loop++,area);
  }

  return 0;
}

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

int main(){
int n;
  cin >> n;
  int sum = 0;
  vector<int> a(n);
  for(int i = 0; i < n; i++){ cin >> a[i]; sum+= a[i];}
  cout << (sum - *max_element(a.begin(), a.end()) > *max_element(a.begin(), a.end()) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3576
N=int(input())
H=list(map(int, input().split()))

D=[]
cnt=0
for i in range(N-1):
  if H[i+1]<=H[i]:
    #print(i,H[i+1],H[i],cnt)
    cnt+=1
  else:
    D.append(cnt)
    #print('!',i,cnt)
    cnt=0

D.append(cnt)   
print(max(D))

Measured memory_bytes: 14252
import Control.Applicative

main :: IO ()
main = solve <$> readLn <*> f >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: Int -> [Int] -> String
solve k [a, b]
  | a <= b `div` k * k = "OK"
  | otherwise = "NG"


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int sg[MAXN];
vector<int> E[MAXN];

void dfs(int u, int fa){
	sg[u] = 0;
	for (int v, i = 0; i < E[u].size(); i++){
		if ((v = E[u][i]) != fa){
			dfs(v, u);
			sg[u] ^= (sg[v] + 1);
		}
	}
}

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	scanf("%d", &n);
	for (int i = 1; i < n; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
	dfs(1, 0);
	puts(sg[1] ? "Alice" : "Bob");
}

void printans(){

}

int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}



Measured memory_bytes: 60288
#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>;

int main(){
	int n, k;
	for(int ii=0; ii>=0; ii){
		cin >> n >> k;
		if(n == 0 && k == 0) break;
		int ans = 0;
		for(int i=1; i<=n-2; i++) for(int j=i+1; j<=n-1; j++) for(int l=j+1; l<=n; l++) if(i+j+l == k) ans++;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int A,B;
    cin >> A >> B;
    pr(A < 2*B ? 0 : A - 2*B);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();

        if(y == x || y == 1 || x % y == 0){
            System.out.println(-1);
        }else{
            if(x < 999999990){
                System.out.println(x*1000000007);
            }else{
                System.out.println(x*999999937);
            }
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
}

int32_t main()
{
	c_p_c();
	int n;
	cin>>n;
	while(n>0)
	{
		int r=n%10;
		if(r==7){
		cout<<"Yes"<<endl;
		return 0;
	}
		n=n/10;
	}
	cout<<"No"<<endl;
	
		
	
	
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll gcd(ll a, ll b)
{
    if (b==0) return a;
    return gcd(b, a%b);
}

int main(){
    int k;
    cin >> k;
    ll ans = 0;
    rep(i, k) rep(j, k) rep(l, k) {
        ll v = gcd(gcd(i+1, j+1), l+1);
        
        ans += v;
    }
    
    
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
//
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
using pll = pair<long long, long long>;
static const int maxlen = 2100;
long long dp[maxlen][maxlen];

int main()
{
    long long N;
    cin >> N;
    vector<long long> A(N);
    vector<pll> indA(N);
    for (long long i = 0; i < N; ++i)
    {
        long long atemp;
        cin >> atemp;
        A[i] = atemp;
        indA[i] = make_pair(A[i], i);
    }

    sort(indA.begin(), indA.end(), [](pll a, pll b){return a.first > b.first;});

    for (int i = 0; i < maxlen; ++i) for (int j = 0; j < maxlen; ++j) dp[i][j] = 0;

    // 既に num 人並べた状態から num + 1 人目を並べた状態への遷移を考える
    for (long long num = 0; num < N; ++num)
    {
      // 左にはすでに left 人並べている。
      for (long long left = 0; left <= num; ++left)
      { 
        long long right = num - left;
        long long indr = N - 1 - (num - left);
        long long cur = dp[left][right]; 
        // num + 1 人目を並べる
        long long score = indA[num].first;
        long long id = indA[num].second;
        // 左に並べる
        dp[left + 1][right] = (std::max)(dp[left + 1][right], cur + score * abs(id - left));
        // 右に並べる
        dp[left][right + 1] = (std::max)(dp[left][right + 1], cur + score * abs(id - indr));
      }
    }
    long long ans = 0;
    for (long long x = 1; x <= N; ++x)
    {
      ans = (std::max)(ans, dp[x][N - x]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 38132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 2e5 + 5;

int n,a[N];
map<ll,ll>M;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;cin>>n;
	ll res=0;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		if(M.count(i-x)) res+=M[i-x];
		M[i+x]++;
	}
	cout<<res<<'\n';
	return 0;
}


Measured memory_bytes: 16108
from bisect import bisect_left

N, K = map(int, input().split())
x = list(map(int, input().split()))

idx = bisect_left(x, 0)

l = x[:idx][::-1]
r = x[idx:]

if K-1 <= len(l):
    s = 0
else:
    s = K-1-len(l)
g = min(len(r), K) 
ans = float("inf")    
for i in range(s, g):
    if i == K-1:
        ans = min(ans, r[i])
    else:
        ans = min(ans, 2 * r[i] + abs(l[K-i-2]), 2 * abs(l[K-i-2]) + r[i])

if len(l) >= K:
    ans = min(ans, abs(l[K-1]))

print(ans)

Measured memory_bytes: 14480
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
signed main(){
	int a,b;
	cin>>a>>b;
	int c=a%2019;
	int d=b%2019;
	int ans=2019;
	if(b-a<2019){
		if(c<d){
			rep(c,i,d+1){
				rep(c,j,d+1){
					if(i!=j&&(i*j)%2019<ans){
						ans=(i*j)%2019;
					}
				}
			}
		}
		else{
			rep(c,i,d+2020){
				rep(c,j,d+2020){
					if(i!=j&&(i*j)%2019<ans){
						ans=(i*j)%2019;
					}
				}
			}
		}
	}
	else{
		c(0)
		return 0;
	}
	c(ans)			
}


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

int main(){
    int64_t N;
    cin >> N;
    string name;
    int bin;
    while(N>0){
        bin = N % 26;
        if (bin==0){
            name += 'a'+25;
            N = (N-1)/26;
        }else{
            name += 'a'+bin-1;
            N = N/26;
        }
    }
    reverse(name.begin(),name.end());
    cout << name << endl;

    return 0;
}

Measured memory_bytes: 3600
BIGMOD = 10**9+7

def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD

def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact

def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact

def modPlus(a,b):
    return (a + b) % BIGMOD

def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD

# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD

n = int(input())
a = list(map(int,input().split()))

odda = []
evena = []
for i in range(n):
    if i%2 == 0:
        odda.append(a[i])
    else:
        evena.append(a[i])
ans = []
if n%2 == 0:
    evena.reverse()
    for i in range(len(evena)):
        ans.append(evena[i])
    for i in range(len(odda)):
        ans.append(odda[i])
else:
    odda.reverse()
    for i in range(len(odda)):
        ans.append(odda[i])
    for i in range(len(evena)):
        ans.append(evena[i])

print(" ".join(map(str,ans)))

Measured memory_bytes: 31892
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main(){
  int a,p;
  cin >> a >> p;
  a *= 3;
  p += a;
  int ans = p/2;
  cout << ans << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
using lint = long long int;

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

    int ans = (X / 500) * 1000;
    X %= 500;
    ans += (X / 5) * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e18
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

ll A,B,C,D;
map<ll,ll> memo;
ll solve(ll N){
  if(N==0) return 0;
  if(N==1) return D;
  if(memo.count(N)) return memo[N];
  ll ret=INF;
  if(N<ret/D) ret=N*D;
  if(N%2==0){
    chmin(ret,solve(N/2)+A);
  }
  if(N%2==1){
    chmin(ret,solve(N/2)+A+D);
    chmin(ret,solve(N/2+1)+A+D);
  }
  if(N%3==0){
    chmin(ret,solve(N/3)+B);
  }
  if(N%3==1){
    chmin(ret,solve(N/3)+B+D);
    chmin(ret,solve(N/3+1)+B+D*2);
  }
  if(N%3==2){
    chmin(ret,solve(N/3)+B+D*2);
    chmin(ret,solve(N/3+1)+B+D);
  }
  if(N%5==0){
    chmin(ret,solve(N/5)+C);
  }
  if(N%5==1){
    chmin(ret,solve(N/5)+C+D);
    chmin(ret,solve(N/5+1)+C+D*4);
  }
  if(N%5==2){
    chmin(ret,solve(N/5)+C+D*2);
    chmin(ret,solve(N/5+1)+C+D*3);
  }
  if(N%5==3){
    chmin(ret,solve(N/5)+C+D*3);
    chmin(ret,solve(N/5+1)+C+D*2);
  }
  if(N%5==4){
    chmin(ret,solve(N/5)+C+D*4);
    chmin(ret,solve(N/5+1)+C+D);
  }
  memo[N]=ret;
  return ret;
}

int main()
{
  INT(T);
  REP(i,T){
    memo.clear();
    ll N;
    cin >> N >> A >> B >> C >> D;
    cout << solve(N) << endl;
  }
}


Measured memory_bytes: 4488
import numpy as np


def solve(l, r):
    l.reverse()

    stops = []

    if l and r:
        while l and r:
            lx, lp = l.pop()
            rx, rp = r.pop()
            if lp >= rp:
                l.append((lx, lp + rp))
                stops.append(rx)
            else:
                r.append((rx, lp + rp))
                stops.append(lx)

    if l:
        stops.append(l[-1][0])
    else:
        stops.append(r[-1][0])
    stops.append(s)

    return abs(np.diff(np.array(stops, dtype=np.int64))).sum()


n, s = map(int, input().split())
l, r = [], []
for _ in range(n):
    x, p = map(int, input().split())
    if x < s:
        l.append((x, p))
    else:
        r.append((x, p))

print(solve(l, r))


Measured memory_bytes: 26564
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int a, b;
    cin >> a >> b;

    vector<vector<int>> m(100, vector<int>(100, 0));
    REP(i, 50)REP(j, 100) m[i][j] = 1;

    int a_tmp = 1, b_tmp = 1;
    REP(i, 50)REP(j, 100){
        if (i % 2 == 0 && j % 2 == 0 && a_tmp < a){
            m[i][j] = 0;
            a_tmp++;
        }
        if (a_tmp == a) break;
    }

    rep(i, 51, 100)REP(j, 100){
        if (i % 2 == 0 && j % 2 == 0 && b_tmp < b){
            m[i][j] = 1;
            b_tmp++;
        }
        if (b_tmp == b) break;
    }
    cout << 100 << " " << 100 << endl;
    REP(i, 100){
        REP(j, 100){
            if (m[i][j]) cout << "#";
            else cout << ".";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
x = list(map(int, input().split()))

xrui = []
ans = 0
for i in range(n-1):
    xrui.append(x[i + 1] - x[i])

for i in xrui:
    if i * a < b:
        ans += i * a
    else:
        ans += b
print(ans)


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int Q;
bool arr[100001];	// 外部変数なら初期値 false(素数なら false となる)
int  cnt[100001];	// 条件を満たす数を計算しておく（１～Ｎまでの）

// エラトステネスの篩(ふるい）　→　素数の表を作る

void eratosthenes(int64 n){
	arr[0] = arr[1] = true;		// 素数でない
	for(int64 i = 2; i * i <= n; i++){
		if( !arr[i] ) {
			for(int64 j = i + i; j <= n; j += i){	// j は i の倍数となる
				arr[j] = true;						// i の倍数は素数でない
			}
		}
	}
}

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

	cin >> Q;

	// 必要分作る
	eratosthenes(100000);

	// 事前に表を作っておく　→　解説より
	cnt[0] = cnt[1] = 0;
	for(int i = 3; i <= 100000; i+=2) {
		if(!arr[i] && !arr[(i+1)/2])	cnt[i] = cnt[i-2] + 1;
		else							cnt[i] = cnt[i-2];
	}
	
	int l, r;
	int ans;
	REP(i, 0, Q) {
		cin >> l >> r;
		ans = cnt[r] - cnt[l-2];
		cout << ans << endl;
	}
	
	return 0;
}


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

int main(){
  int n; cin >> n;
  int w[105];
  for (int i = 0; i < n; i++){
    cin >> w[i];
  }
  int ans = 10000;
  for (int i = 0; i < n-1; i++){
    int s1 = 0, s2 = 0;
    for (int j = 0; j <= i; j++){
      s1 += w[j];
    }
    for (int j = i+1; j < n; j++){
      s2 += w[j];
    }
    ans = min(ans, abs(s1-s2));
  }
  cout << ans << endl;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,sum=0;
	cin>>n;
	vector<int>a(n),b(n);
	for(int i=0;i<n-1;i++) cin>>b.at(i);
	a.at(0)=b.at(0);
	sum+=a.at(0);
	for(int i=1;i<n-1;i++){
		a.at(i)=b.at(i);
		if(a.at(i)>b.at(i-1)){
			a.at(i)=b.at(i-1);
		}
		sum+=a.at(i);
	}
	a.at(n-1)=b.at(n-2);
	sum+=a.at(n-1);
	cout<<sum<<endl;

}


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

constexpr long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define rrep(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair


int main(){
  ll n,t;
  cin >> n >> t;
  ll sum = 0, mx = 0;
  REP(i,n) {
    ll h;
    cin >> h;
    mx = max(mx,h);
    sum += h;
    //std::cout << sum << ' ' << mx << endl;
    ll ans;

    if(t >= sum) ans = (t-sum)/mx + 2;
    else ans = 1;

    cout << ans << endl;

  }


  return 0;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long 
#define sort(v) sort(v.begin(),v.end()) 
#define pb push_back
/*
ll ar[1000000+9]={0}; 
vector<ll>v;
void seiv() { 
ll n=1000000,i,j; 
ar[1]=1; 
for(i=4;i<=n;i+=2)ar[i]=1; 
for(i=3;i<=n;i+=2) 
{ if(ar[i]==0) 
{ for(j=i*i;j<=n;j+=i*2)ar[j]=1; }
                
 } 
    for(i=2;i<=2244;i++){if(ar[i]==0)v.pb(i);}}*/
int main()
{
ll a,b,c,d,i,j,k,l;
cin>>a>>b;
map<ll,ll>m;
 string s;k=l=0;
  for(i=1;i<=b;i++)
  {
  cin>>a>>s;
  if(s=="WA"){if(m[a]>=0)
        m[a]++;}
  if(s=="AC"){if(m[a]!=-1){l++;k+=m[a];m[a]=-1;}}
  }
    cout<<l<<" "<<k<<endl;
 }

Measured memory_bytes: 9752
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

vector<int> Build(const string & S) {
    vector<int> pref(S.size());
    for (int i = 1; i < S.size(); i++)
        pref[i] = pref[i-1] + (S[i] == 'A' ? 1 : -1);
    return pref;
}

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

    string S, T;
    cin >> S >> T;
    S = '@' + S;
    T = '@' + T;

    int Q;
    cin >> Q;

    auto prefS = Build(S);
    auto prefT = Build(T);

    //debug() << prefS;

    for (int i = 0; i < Q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        auto nS = (prefS[b] - prefS[a-1] + 3 * S.size()) % 3;
        auto nT = (prefT[d] - prefT[c-1] + 3 * T.size()) % 3;

        //debug() << nS << " " << nT;

        cout << (nS == nT ? "YES" : "NO") << "\n";
    }

    return 0;
}


Measured memory_bytes: 1644
#include<iostream>

using namespace std;

int main()
{
  int b, r, g, c, s, t;
  int coin;
  while(1)
  {
    cin >> b >> r >> g >> c >> s >> t;
    if(b == r && r == g && g == c && c == s && s == 0)
      break;

    coin = 100;
    coin -= t * 3;//コイン投入枚数                                              
    coin += b * 5 + r * 3; //ボーナス中は投入二枚                               
    coin += (b + r) * 15;//ボーナス突入時にも15枚                               
    coin += b * 5 * 15 + r * 3 * 15;//ボーナス中は15枚                          
    coin += g * 7;
    coin += c * 2;
    coin += s * 3;

    cout << coin << endl;
  }
  return 0;
}

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

int ABS(int a, int b) {
  if (a>b) {return a-b;}
  else {return b-a;}
}

int main() {
  int H, W;
  cin >> H >> W;
  
  int a[H][W];
  int b[H][W];
  

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> b[i][j];
    }
  }
  
  
  int abs[H][W];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (b[i][j] > a[i][j]) {abs[i][j] = b[i][j]-a[i][j];}
      else {abs[i][j] = a[i][j]-b[i][j];}
    }
  }
  
  bool dp[H][W][12801];
  
  for (int k = 0; k <= 12800; k++) {dp[0][0][k] = false;}
  dp[0][0][abs[0][0]] = true;
  
  for (int i = 1; i < H; i++) {
    for (int k = 0; k <= 12800; k++) {
      dp[i][0][k] = (dp[i-1][0][k+abs[i][0]] || dp[i-1][0][ABS(k,abs[i][0])]);
    }
  }
  
    
  
  for (int j = 1; j < W; j++) {
    for (int k = 0; k <= 12800; k++) {
      dp[0][j][k] = dp[0][j-1][k+abs[0][j]] || dp[0][j-1][ABS(k,abs[0][j])];
    }
  }
  
  for (int i = 1; i < H; i++) {
    for (int j = 1; j < W; j++) {
      for (int k = 0; k <= 12800; k++) {
        dp[i][j][k] = dp[i-1][j][k+abs[i][j]] || dp[i][j-1][k+abs[i][j]] || dp[i-1][j][ABS(k,abs[i][j])] || dp[i][j-1][ABS(k,abs[i][j])];
      }
    }
  }
  

  
  int ans = 12801;
  for (int k = 0; k <= 12800; k++) {
    if (dp[H-1][W-1][k]) {
      ans = k;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 80384
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

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

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N, M);
    vector<i64> a(N);
    read(a);
    sort(all(a));

    priority_queue<pii> pq;
    rep(i, 0, M) {
        var(i64, b, c);
        pq.emplace(c, b);
    }

    auto itr = a.begin();
    while (!pq.empty()) {
        if (itr == a.end()) break;
        const auto tmp = pq.top();
        pq.pop();

        const i64 value = tmp.first;
        i64 num = tmp.second;
        while (itr != a.end() && num > 0 && *itr < value) {
            *itr = value;
            ++itr;
            --num;
        }
    }

    print(accumulate(all(a), 0LL));

    return 0;
}


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdbool.h>

int size(char *s);

int main() {
	int i, j, count = 0, max = 0;
	char s[11];
	char *sp;
	char acgt[5] = { 'A', 'C', 'G', 'T' };
	bool ittiflag = false;

	scanf("%s", &s);

	sp = &s[0];
	for (i = 0; i < size(sp); i++) {
		for (j = 0; j < 4; j++) {
			if (s[i] == acgt[j]) {
				ittiflag = true;
			}
		}
		if (ittiflag == true) {
			count++;
			ittiflag = false;
		} else {
			count = 0;
		}
		if (count >= max) max = count;
	}

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

	return 0;
}

int size(char *s) {
	int cnt=0;

	while (*s != '\0') {
		s++;
		cnt++;
	}

	return cnt;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;

    int A_index;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'A'){
            A_index = i;
            break;
        }
    }

    int Z_index;
    for (int i = s.size() - 1; i >= 0; i--){
        if(s[i] == 'Z'){
            Z_index = i;
            break;
        }
    }
    cout << s.substr(A_index, Z_index - A_index + 1).size() << endl;
}


Measured memory_bytes: 772
N, K = gets.chomp.split.map(&:to_i)
res = 0

num = Array.new([N, K].max,0)

1.upto(N) do |i|
  num[i%K] += 1
end

K.times do |i|
  a = i % K

  b = (K - a) % K
  c = (K - a) % K

  next unless (b + c) % K == 0
  res += num[a] * num[b] * num[c]
end

p res



Measured memory_bytes: 3324