akhauriyash/Code-Regression huggingface dataset:
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
 
typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define boost                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define REP(i, a, b)            for (int i = (a); i <= (b); i++)
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define TRAV(i, n)              for(auto&i:n)
#define beg(x)                  (*(x.begin()))
#define re(x)                   int x; cin >>x;   
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
 
const ll T = 1 << 20;
const ll INF = 1e9 + 7;
//const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 1e6+7;
const int LOG = 17;
 
ll n, m, k, q;

ll sil[N];
ll odw[N];

void prep(){
	sil[0]=1;
	for(int i = 1; i < N; i++)
		sil[i] = sil[i-1]*i%INF;
	odw[N-1] = fast(sil[N-1], INF-2, INF);
	for(int i = N-2; i >= 0; i--)
		odw[i] = odw[i+1]*(i+1)%INF;
}

ll npok(ll a, ll b){
	if(b>a || b <0)
		return 0;
	return (sil[a] * odw[b]%INF)*odw[a-b]%INF;
}

ll komb_pow(ll a, ll b){
	return npok(a+b-1, b);
}

signed main(){
	boost;

	prep();
	cin >> n >> m;
	for(int i=1; i<=m; i++ )
		cout << npok(n-m+1, i) * komb_pow(i, m-i)%INF<<'\n';
}

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

using namespace std;

int n;
vector<int> primos;
int vet[1000000];

void getPrimos(){
    int limite = 1000000;
    int raiz = sqrt(limite);

    for(int i=2;i<=limite;i++){
        vet[i] = i;
    }

    for(int i=2;i<=raiz;i++){
        if(vet[i] == i){
            for(int j = 2*i;j<=limite;j+=i){
                vet[j] = 0;
            }
        }
    }
}

int main(){
    getPrimos();
    scanf("%d",&n);
    while(1){
        if(vet[n] != 0){
            printf("%d\n",n);
            break;
        }else n++;
    }
}


Measured memory_bytes: 4096
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var n = Reader.NextInt;
        var W = Reader.NextInt;
        Dictionary<long, long> values = new Dictionary<long, long>();
        values.Add(0, 0);
        for (int i = 0; i < n; i++)
        {
            var w = Reader.NextInt;
            var v = Reader.NextInt;
            var newValues = new Dictionary<long, long>();
            foreach (var item in values)
            {
                if (!newValues.TryAdd(item.Key, item.Value)) newValues[item.Key] = Max(newValues[item.Key], item.Value);
                if (W < item.Key + w) continue;
                if (!newValues.TryAdd(item.Key + w, item.Value + v)) newValues[item.Key + w] = Max(newValues[item.Key + w], item.Value + v);
            }
            values = newValues;
        }
        Console.WriteLine(values.Values.Max());
    }

    static bool TryAdd<T1, T2>(this Dictionary<T1, T2> dic, T1 key, T2 value)
    {
        if (dic.ContainsKey(key)) return false;
        dic.Add(key, value);
        return true;
    }
}

struct Object
{
    public int Weight;
    public long Value;
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = 0;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

        
    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


Measured memory_bytes: 16096
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <list>
#include <set>
using namespace  std;

#define int long long int 

constexpr int INF = std::numeric_limits<int>::max();

class UnionFindTree {
public:
    vector<int> rank, p, len;
    int huben;
    UnionFindTree(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        len.resize(size, 0);
        huben = (size - 1) * size / 2;
        for (int i = 0; i < size; i++) {
            makeSet(i);
        }
    }

    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
        len[x] = 1;
    }

    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y) {
        x = findSet(x);
        y = findSet(y);
        if (x == y) {
            return;
        }

        huben -= len[x] * len[y];
        link(x, y);
    }

    void link(int x, int y) {
        if (rank[x] > rank[y]) {
            len[x] += len[y];
            p[y] = x;
        } else {
            len[y] += len[x];
            p[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }

    int findSet(int x) {
        if (x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> V;
    while (M--) {
        int a, b;
        cin >> a >> b;
        V.emplace_back(a, b);
    }

    reverse(V.begin(), V.end());

    vector<int> ANS;
    UnionFindTree tree(N);
    for (auto &p : V) {
        ANS.push_back(tree.huben);
        tree.unite(p.first - 1, p.second - 1);
    }

    reverse(ANS.begin(), ANS.end());
    for (int ans : ANS) {
        cout << ans << endl;
    }
}

Measured memory_bytes: 7024
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a::Array{Tuple{Int,Int,Int},1},x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m][1]<=x;l=m;else;r=m;end;end;r;end
function func(f::Int,a::Int,m::Int)
	if f*a<m
		0
	else
		(f*a-m)%f==0?div(f*a-m,f):div(f*a-m,f)+1
	end
end
function main()
	n,k = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	f = readline() |> split |> parseMap
	a =	sort(a)
	f = sort(f,rev=true)
	b = Tuple{Int,Int,Int}[(f[i]*a[i],f[i],a[i]) for i in 1:n]
	b = sort(b,by=x->x[1])
	l = -1
	r = b[n][1]
	while r-l>1
		m = (l+r)>>1
		s = 0
		t = bsearch(b,m)
		for i in t:n
			s += func(b[i][2],b[i][3],m)
		end
		if s<=k
			r = m
		else
			l = m
		end

	end
	println(r)
end

main()


Measured memory_bytes: 157944
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int R = sc.nextInt();
		int[] D = new int[N];
		for (int i = 0; i < N; ++i) {
			D[i] = sc.nextInt();
		}
		ArrayList<ArrayList<Edge>> g = new ArrayList<>();
		for (int i = 0; i < N; ++i) {
			g.add(new ArrayList<>());
		}
		for (int i = 0; i < M; ++i) {
			int A = sc.nextInt() - 1;
			int B = sc.nextInt() - 1;
			int C = sc.nextInt();
			g.get(A).add(new Edge(B, C));
			g.get(B).add(new Edge(A, C));
		}
		int[][][] dp = new int[R + 1][2 * N][2 * N];
		for (int[][] a : dp) {
			for (int[] aa : a) {
				Arrays.fill(aa, -1);
			}
		}
		dp[0][0][0] = 0;
		for (int i = 0; i < R; ++i) {
			for (int j = 0; j < 2 * N; ++j) {
				int prev = j % N;
				for (int k = 0; k < 2 * N; ++k) {
					if (dp[i][j][k] == -1) continue;
					int pos = k % N;
					for (Edge e : g.get(pos)) {
						if (i + e.cost > R) continue;
						if (e.to != prev) {
							dp[i + e.cost][k][e.to] = Math.max(dp[i + e.cost][k][e.to], dp[i][j][k] + D[e.to]);
						} else {
							if (e.cost * 2 < 15) {
								if (j >= N) {
									dp[i + e.cost][k][e.to] = Math.max(dp[i + e.cost][k][e.to], dp[i][j][k] + D[e.to]);
								}
								dp[i + e.cost][k][e.to + N] = Math.max(dp[i + e.cost][k][e.to + N], dp[i][j][k]);
								if (i - e.cost + 15 <= R) {
									dp[i - e.cost + 15][pos + N][e.to] = Math.max(dp[i - e.cost + 15][pos + N][e.to], dp[i][j][k] + D[e.to]);
								}
							} else {
								dp[i + e.cost][k][e.to] = Math.max(dp[i + e.cost][k][e.to], dp[i][j][k] + D[e.to]);
							}
						}
					}
					if (i + 15 <= R) dp[i + 15][pos][pos] = Math.max(dp[i + 15][pos][pos], dp[i][j][k] + D[pos]);
					dp[i + 1][j][k] = Math.max(dp[i + 1][j][k], dp[i][j][k]);
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < 2 * N; ++i) {
			ans = Math.max(ans, dp[R][i][N - 1]);
			ans = Math.max(ans, dp[R][i][N + N - 1]);
		}
		System.out.println(ans);
	}

	static class Edge {
		int to, cost;

		public Edge(int to, int cost) {
			this.to = to;
			this.cost = cost;
		}

	}

}

Measured memory_bytes: 85716
#include <stdio.h>
int main(){
  int x, y, a;
  while(1){
    scanf("%d %d", &x, &y);
    if(x==0 && y==0) break;
    if(x > y){
      a = x;
      x = y;
      y = a;
    }
    printf("%d %d\n", x, y);
  }
  return 0;
}

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

int main() {
    long long N;
    cin >> N;
    vector<long long> h(N);
    rep(i, N) cin >> h[i];
    long long ans;
    vector<long long> dp(N);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << dp[N - 1] << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct rolling_hash{
	typedef unsigned int ui;
	typedef unsigned long long ull;

	const ull MASK30 = (1ull<<30) - 1;
	const ull MASK31 = (1ull<<31) - 1;
	const ull MOD = (1ull<<61) - 1;
	const ull POSITIVISER = MOD * ((1ull<<3) - 1);
	ui base;
	int n;
	vector<ull> pw, hs;

	rolling_hash(){}

	rolling_hash(const string &s, int bs){
		// set base
		base = (ui)bs;
		
		n = s.size();
		hs.assign(n+1, 0);
		pw.assign(n+1, 0);
		hs[0] = 0;
		pw[0] = 1;
		for(int i=0;i<n;i++){
			pw[i+1] = calc_mod(mul(pw[i], base));
			hs[i+1] = calc_mod(mul(hs[i], base) + s[i]); 
		}
	}

	ull hash(int l, int r){
		return calc_mod(hs[r] + POSITIVISER - mul(hs[l], pw[r-l]));
	}

	ull mul(ull l, ull r){
		ull lu = l>>31;
		ull ld = l & MASK31;
		ull ru = r>>31;
		ull rd = r & MASK31;
		ull middle_bit = ld * ru + lu * rd;
		return ((lu*ru)<<1) +ld*rd + ((middle_bit & MASK30) << 31) + (middle_bit>>30);
	}

	ull mul(ull l, ui r){
		ull lu = l>>31;
		ull rd = r & MASK31;
		ull middle_bit = lu * rd;
		return (l & MASK31) * rd + ((middle_bit & MASK30)<<31) + (middle_bit>>30);
	}

	ull calc_mod(ull val){
		val = (val & MOD) + (val>>61);
		if(val > MOD) val -= MOD;
		return val;
	}
};

int generate_base(){
	random_device seed_gen;
	mt19937_64 rnd(seed_gen());
	uniform_int_distribution<int> dist(129, INT_MAX);
	int base = dist(rnd);
	return base;
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B&lang=ja
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string T, P;
    cin >> T >> P;
    int base = generate_base();
    rolling_hash rT(T, base), rP(P, base);

    ll len = P.size();
    ull h = rP.hash(0, len);
    REP(i, (int)T.size()-len+1){
    	ull hh = rT.hash(i, i+len);
    	//dump(i)
    	//dump(hh)
    	//dump(h)
    	if(hh == h){
    		cout << i << endl;
    	}
    }
    return 0;
}


Measured memory_bytes: 19768
import sys


def partition_for_second_element(array, first, end):
    criteria = array[end][1]
    i_ins = first
    for i_cur in range(first, end):
        if array[i_cur][1] <= criteria:
            array[i_ins], array[i_cur] = array[i_cur], array[i_ins]     # swap
            i_ins += 1
    array[i_ins], array[end] = array[end], array[i_ins]     # swap
    return i_ins


def quick_sort(array, first, end):
    #print("quick_sort",first,end,array)
    if first < end:
        criteria_idx = partition_for_second_element(array, first, end)
        quick_sort(array, first, criteria_idx - 1)
        quick_sort(array, criteria_idx + 1, end)


def shcd_order(cards):
    orders = {}
    for card in cards:
        if card[1] not in orders:
            orders[card[1]] = [card[0]]
        else:
            orders[card[1]].append(card[0])
    return orders


def is_identical_order(prev_orders, after_orders):
    for key, value in prev_orders.items():
        if after_orders[key] != value:
            return False
    return True


def main():
    input_lines = sys.stdin.readlines()
    n = int(input_lines[0].rstrip())
    cards = [(x.split()[0], int(x.split()[1])) for x in input_lines[1:]]
    prev_orders = shcd_order(cards)
    quick_sort(cards, 0, n-1)
    after_orders = shcd_order(cards)
    if is_identical_order(prev_orders, after_orders):
        print('Stable')
    else:
        print('Not stable')
    [print(x[0], x[1]) for x in cards]
    return


main()


Measured memory_bytes: 31620
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


bool is_prime(ll x){
    if(x<=1) return false;
    for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
    return true;
}


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

    ll X;
    cin >> X;
    
    while(!is_prime(X)) X++;

    cout << X << endl;

    return 0;
}

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

int main() {
    int N; string S;
    cin >> N >> S;
    long long r = 0, g = 0, b = 0;
    for (auto c : S) {
        if (c == 'R') ++r;
        else if (c == 'G') ++g;
        else ++b;
    }
    long long all = r * g * b;
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            ++sub;
        }
    }
    cout << all - sub << endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll nowT, nowA;

int main(){
  cin >> N;
  cin >> nowT >> nowA;

  for (int i = 1; i < N; i++){
    ll T, A; cin >> T >> A;

    ll G = (nowT + nowA - 1) / (T + A) + 1;
    G = max(G, (nowT - 1) / T + 1);
    G = max(G, (nowA - 1) / A + 1);

    nowT = G * T; nowA = G * A;
  }
  cout << nowT + nowA << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define in(x) int x; cin>>x;
#define inn(x, y) int x, y; cin>>x>>y;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

//int gcd(int a, int b){
//	return b==0 ? a : gcd(b, a%b);
//}

int32_t main(void){
	IOS;
	
	inn(n, m);
	double thr = (1.00/(4.00*m));
	int arr[n];
	int tot = 0;
	rep(i, 0, n)
	{
		cin>>arr[i];
		tot+=arr[i];
	}
	sort(arr, arr+n, greater<int>());
	int ans = 0;
	// cout<<thr<<endl;
	rep(i, 0, n)
	{
		double x = (arr[i]*1.00)/(tot*1.00);
		// cout<<x<<endl;
		if(x < thr) break;
		else
		{
			ans+=1;
			if(ans == m)
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	int N;
	bool f = true;
	string s;
	vector<char> A;
	vector<char> B;
	cin >> N >> s;

	if (N % 2 == 0) {
		for (int i = 0; i < N;i++) {
			if (i < (N / 2)) { A.push_back(s[i]); }
			else { B.push_back(s[i]); }
		}
		for (int i = 0; i < (N/2); i++) {
			if (A[i] == B[i]) {
				continue;
			}
			else {
				f = false;
			}
		}
	}
	else {
		f = false;
	}

	if (f == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vector<ll> cnt(1000000, 0);
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      for(int k=1;k<=100;k++){
        cnt[i*i+j*j+k*k+i*k+i*j+j*k]++;
      }
    }
  }
  for(int i=1;i<=n;i++) std::cout << cnt[i] << '\n';
  return 0;
}


Measured memory_bytes: 10616
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
d = dd(int)
l = dd(lambda: N + 1)
for i in range(N):
  d[a[i]] += 1
  l[a[i]] = min(l[a[i]], i + 1)

#print(d, l)
ks = sorted(d.keys(), reverse = True)
res = [0] * (N + 1)
for i in range(len(ks) - 1):
  t = ks[i] - ks[i + 1]
  k = ks[i]
  res[l[k]] += d[k] * t
  d[ks[i + 1]] += d[k]
  l[ks[i + 1]] = min(l[ks[i + 1]], l[k])
res[1] += d[ks[-1]] * ks[-1]
for r in res[1: ]: print(r)

Measured memory_bytes: 87480
#include <stdio.h>

void x(int*,int);
void y(int*,int);

int main(){
  int i,a[1000],n;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  x(a,n);
  y(a,n);

  return 0;
}

void x(int *a,int n){
  int i;

  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
}

void y(int *a,int n){
  int i,j,key;
  for(i=1;i<n;i++){
    key=a[i];
    j=i-1;
    while(j>=0 && a[j]>key){
    a[j+1]=a[j];
    j--;
    }
    a[j+1]=key;
    x(a,n);
  }
}



Measured memory_bytes: 2044
#include <cstdio>
#include <algorithm>

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

using namespace std;

bool prime[(int)1e7];
int integral[(int)1e7];

int main(){
	fill(prime + 2, prime + (int)1e7, true);
	
	for(int i = 2; i < (int)1e7; ++i){
		if(prime[i]){
			for(int j = i * 2; j < (int)1e7; j += i){
				prime[j] = false;
			}
		}
	}

	for(int i = 1; i < (int)1e7; ++i){
		integral[i] = integral[i - 1] + prime[i];
	}

	int n;
	while(scanf("%d", &n) != EOF){
		printf("%d\n", integral[n]);
	}
	return 0;
}

Measured memory_bytes: 49852
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
int main(){
    LL x;
    scanf("%lld",&x);
    LL res;
    if(x<=6)
        res=1;
    else{
        if(x%11==0)
            res=(x/11)*2;
        else{
            LL before=(x/11)*2;
            x-=before/2*11;
            if(x<=6)
                res=before+1;
            else
                res=before+2;
        }
    }

    printf("%lld\n",res);

    return 0;
}



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;

typedef pair<int, int> Node;

Node w[15000], y[15000], z[15000],v[45000];

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

	cin >> N ;
	while(N){
	  cin>>M;
	cin >> L >> R >> K;
	v[0] = { 1,N };
	int vs = 1;
	for (int i = 0; i < M; i++) {
		cin >> H >> W;
		int ws = 0, ys = 0, zs = 0;
		int used = 0;
		for (int k = 0; k < vs; k++) {
			auto j = v[k];
			if (used < H) {
				if (used + j.second - j.first + 1 > H) {
					w[ws++] = Node(j.first, H - used + j.first - 1);
					j.first = H - used + j.first;
					used = H;
				}
				else {
					used += j.second - j.first + 1;
					w[ws++] = j;
					continue;
				}
			}
			if (used < W) {
				if (used + j.second - j.first + 1 > W) {
					y[ys++] = Node(j.first, W - used + j.first - 1);
					j.first = W - used + j.first;
					used = W;
				}
				else {
					used += j.second - j.first + 1;
					y[ys++] = j;
					continue;
				}
			}
			if (used >= W) {
				used += j.second - j.first + 1;
				z[zs++] = j;
			}
		}
		vs = zs + ws + ys;
		for (int j = 0; j < zs; j++)v[j] = z[j];
		for (int j = 0; j < ys; j++)v[j + zs] = y[j];
		for (int j = 0; j < ws; j++)v[j + zs + ys] = w[j];
	}
	int ans = 0;
	int used = 0;
	//for (auto i : v) {
	for(int j=0;j<vs;j++){
		auto i = v[j];
		//for (int j = i.first; j <= i.second; j++) {
		//	//if (used > R)break;
		//	if (used >= L && used <= R && j <= K)ans++;
		//	used++;
		//}

	//	cout << i.first << " " << i.second << endl;
		if (used + i.second - i.first + 1 < L) {
			used += i.second - i.first + 1;
			continue;
		}
		if (used < L) {
			i.first += L - used - 1;
			used = L - 1;
		}
		if (used > R)continue;
		int add = max(0, min(min(K, i.second) - i.first + 1, R - used));
		ans += add;
		used += i.second - i.first + 1;
	//	cout << ans << endl;
	}
	cout << ans << endl;
	cin>>N;
	}
	return 0;
}


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

int main() {
    int N, K; cin >> N >> K;
    vector<int> v(2000001, 0);
    for(int i=1; i<=N; ++i){
        int a; cin >> a;
        v[a]++;
    }
    int cnt=0;
    for(int i=0; i<2000001; ++i){
        if(v[i]!=0) cnt++;
        else v[i] = 1000000;
    }
    sort(v.begin(), v.end());
    int ans=0, index=0, loop=0;
    
    while(loop!=cnt-K&&cnt-K>0){
        ans += v[index];
        if(v[index]!=0){
            loop++;
        }
        index++;
    }
    cout << ans << endl;
    
        
    return 0;
}


Measured memory_bytes: 8064
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,h,k,l,m,n,w,x,y,z;
	int ans;
	String[] S;

	Main(){
		// 整数の入力
		n = sc.nextInt();

		m = sc.nextInt();
		for(int i=1;i<n;i++){
			h = sc.nextInt();
			if(m<h){
				if(ans<w)ans=w;
				w=0;
			} else {
				w++;
			}
			m=h;
		}
		if(ans<w)ans=w;

		// 出力
		System.out.println(ans);
	}

	public static void main(String[] args){
		new Main();
	}
}

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

int D[181] = {} ; // 10^6 越え → 181
int dp_map[2][1000002] = {} ;

void t(){
	for( int i=1 ; i<181 ; i++ ){
		D[i] = i * (i+1) * (i+2) / 6 ;
	}
}

void dp(){
	
	for( int i=0 ; i<=1000000 ; i++ ){
		dp_map[0][i] = i ;
		dp_map[1][i] = i ;
	}
	
	for( int i=0 ; i<=1000000 ; i++ ){
		for( int j=1 ; j<181 ; j++ ){
			if( i+D[j] <= 1000000 )
				dp_map[0][i+D[j]] = min( dp_map[0][i+D[j]] , dp_map[0][i]+1 ) ;
			if( D[j]%2 == 1 && i+D[j] <= 1000000 )
				dp_map[1][i+D[j]] = min( dp_map[1][i+D[j]] , dp_map[1][i]+1 ) ;
		}
	}
}

int main(){
	
	t() ;
	dp() ;
	
	int n ;
	
	while( cin >> n , n ){
		cout << dp_map[0][n] << ' ' ;
		cout << dp_map[1][n] << endl ;
	}
	
return 0 ;
}

Measured memory_bytes: 8972
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    char a, b;
    cin >> a >> b;
    if (a == 'H' && b == 'H' || a == 'D' && b == 'D') {
        cout << 'H';
    } else {
        cout << 'D';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  double a,n;
  cin >> N;
  
  if (N % 2 == 0){
     double a = (double) 1/2;
    cout << a << endl;
  }
  
  else if (N % 2 == 1){
     n =(double) ( N + 1 ) / ( 2 * N );
    cout << n << endl;
  }
  
  else if (N ==1){
    cout << 1 << endl;
  }
}

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

long long a[100010], b[100010];

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	long long _count = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = n; i >= 1; i--) {
		a[i] += _count;
		if (a[i] % b[i] != 0) {
			_count += (a[i] / b[i] + 1) * b[i] - a[i];
		}
	}
	cout << _count << endl;
	return 0;
}

Measured memory_bytes: 1792
N = input()
last = int(N[-1])

hon_list = (2, 4, 5, 7, 9)
pon_list = (0, 1, 6, 8)
bon_list = [3]

if last in hon_list:
    print('hon')
elif last in pon_list:
    print('pon')
elif last in bon_list:
    print('bon')
else:
    raise Exception


Measured memory_bytes: 61676
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

//map
int main()
{
    int H,W;

    while(true)
    {
        cin >> H >> W;
        if(H + W == 0)break;

        REP(i,H)
        {
            REP(j,W)
            {
                if(i == 0 || i == H - 1 || j == 0 || j == W-1)
                {
                    cout << "#";
                }
                else
                {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    string a;
    cin >> a;
    ll n = a.size();
    ll cnt[26] = {};
    ll ans = n * (n - 1) / 2;
    REP(i,n){
        int t = a[i] - 'a'; 
        ans -= cnt[t];
        cnt[t]++;
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;
	vector<int64_t> as(n); for (auto& a : as) { cin >> a; };

	FOR_LT(i, m, n) {
		if (as[i - m] < as[i]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4760
using namespace std;
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <unordered_map>
//#include <bits/stdc++. h>
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(int i=0;i<(n);i++)
#define forab(i,a,b) for(int i=(a);i<(b);i++)
#define fordec(i,a,b) for(int i=(a);i>=(b);i--)
#define vi vector<int>
#define vl vector<ll>
#define vd vector<double>
#define vs vector<string>
#define pb push_back
#define vpi vector<pair<int, int>
#define vpl vector<pair<ll, ll>>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<30;
const char nl = '\n';
typedef long long ll;
inline int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline void print(vector<int> x) {for (auto& a : x) cout << a << ' '; cout << nl;}
inline void print(vector<char> x) {for (auto& a : x) cout << a << ' '; cout << nl;}
inline void print(vector<string> x) {for (auto& a : x) cout << a << ' '; cout << nl;}
inline void print(vector<ll> x) {for (auto& a : x) cout << a << ' '; cout << nl;}
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////



int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
		ll n; cin >> n;
		if (n % 1000 == 0) cout << 0 << nl;
		else {
			cout << 1000 * (n / 1000 + 1) - n << nl;
		}
	

	return 0;
}


Measured memory_bytes: 3116
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]*(n+1)
for i in range(n):
    d[i+1] = d[i] + l[i]
count = 0
for i in range(n+1):
    if x >= d[i]:
        count += 1
print(count)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const ll mod = 1000000007;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

int main() {
    ll n, k;
    cin >> n >> k;
    ll sum = 0;
    vll x(k+1);
    for (int i = k; i >= 1; i--) {
        ll tmp = k/i;
        tmp = modpow(tmp,n,mod);
        for (int l = 2; i*l <= k; l++) {
            tmp += mod;
            tmp -= x[i*l];
            tmp %= mod;
        }
        x[i] = tmp % mod;
        sum += x[i] * i;
        sum %= mod;
    }
    cout << sum%mod << endl;
}

Measured memory_bytes: 4000
import sys
input=sys.stdin.readline
import heapq

def dijkstra(Route,v,start):
    Dist=[float('inf')]*v
    Dist[start]=0
    Visited=[False]*v
    hq=[(0,start)]
    while hq:
        dist,fr=heapq.heappop(hq)
        Visited[fr]=True
        for to,cost in Route[fr]:
            if (not Visited[to]) and Dist[to]>dist+cost:
                Dist[to]=dist+cost
                heapq.heappush(hq,(Dist[to],to))
    return Dist

def main():
    n,m=map(int,input().split())
    Edges=[[] for _ in range(n)]
    for i in range(n-1):
        Edges[i+1].append((i,0))
    for _ in range(m):
        l,r,c=map(int,input().split())
        l-=1; r-=1
        Edges[l].append((r,c))
    Dist=dijkstra(Edges,n,0)
    print(-1 if Dist[-1]==float('inf') else Dist[-1])
    
if __name__=='__main__':
    main()

Measured memory_bytes: 77728
#include <stdio.h>
#include <stdlib.h>

int int_sort( const void * a , const void * b ) {
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}

int main(void)
{
  int n,k;
  scanf("%d %d", &n, &k);

  int h[n];
  for(int i1=0;i1<n;i1++){
    scanf("%d", &h[i1]);
  }

  qsort(( void * )h ,n ,sizeof(h[0]),int_sort );
  /*  
  int tmp;
  for (int i1=0; i1<n; i1++) {
    for (int i2=i1+1; i2<n; i2++) {
      if (h[i1] > h[i2]) {
        tmp = h[i1];
        h[i1] = h[i2];
        h[i2] = tmp;
  } } }
*/
  int min=h[k-1]-h[0];
  for(int i1=1;i1<n-k+1;i1++){
    if(min>h[i1+k-1]-h[i1]) min = h[i1+k-1]-h[i1];
  }
  
  printf("%d", min);

  return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n) {
    if(i % 2 != 0) continue;
    if(a[i] % 2 == 0) continue;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n,T = LI()
ans = 0
t = LI()
for i in range(n-1):
    ans += min(T,t[i+1]-t[i])
ans += T
print(ans)
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 78288
import Foundation
let A = Int(readLine()!)!
let B = Int(readLine()!)!
let C = Int(readLine()!)!
let X = Int(readLine()!)!
var count = 0
//500A + 100B + 50C = X を満たす(A,B,C)

for a in 0 ... A {
    if a*500 > X {
        break
    }
    for b in 0 ... B {
        if 500*a + 100*b > X {
            break
        }
        for c in 0 ... C {
            if 500*a + 100*b + 50*c == X {
                count += 1
            }
        }
    }
}
print(count)

Measured memory_bytes: 12928
def getValue(A, B, C, List):
  D=A+B
  Sum=int(D)+int(C)
  List.append(Sum)
  return List
  
A, B, C=input().split()

List=[]
List=getValue(A, B, C, List)
List=getValue(A, C, B, List)
List=getValue(B, A, C, List)
List=getValue(B, C, A, List)
List=getValue(C, B, A, List)
List=getValue(C, A, B, List)

print(max(List))





Measured memory_bytes: 3064
s = input()

a = 0
z = 0

for i in range(len(s)):
    char = s[i]
    if s[i] == "A":
        a = i
        break

for i in range(len(s)-1, 0, -1):
    char = s[i]
    if s[i] == "Z":
        z = i
        break

print(z - a + 1)

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

using namespace std;

int main()
{
    int rows, cols, colors;
    cin >> rows >> cols >> colors;

    vector<vector<int>> mat(rows, vector<int>(cols));
    auto x = 0;
    auto y = 0;

    for (auto i = 0; i < colors; i += 1) {
        int size;
        cin >> size;

        for (auto j = 0; j < size; j += 1) {
            mat[x][y] = i;
            y += (x % 2 == 0 ? 1 : -1);
            if (y < 0 || y >= cols) {
                x += 1;
                y = (x % 2 == 0 ? 0 : (cols - 1));
            }
        }
    }

    for (const auto &row : mat) {
        for (const auto &c : row) {
            cout << c + 1 << " ";
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
from itertools import product

d, g = [int(i) for i in input().split()]
p = []
c = []
for _ in range(d):
    ipt = [int(i) for i in input().split()]
    p.append(ipt[0])
    c.append(ipt[1])

res = 100*10+1
for solved in product((0, 1),repeat=d):
    cnt = score = max_i = 0
    for i, prob in enumerate(solved):
        if prob:
            cnt += p[i]
            score += p[i] * 100 * (i+1) + c[i]
        else:
            max_i = i

    if score < g:
        for _ in range(p[max_i]):
            cnt += 1
            score += 100 * (max_i+1)
            if score >= g:
                break

    if score >= g and cnt < res:
        res = cnt

print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll sa = b - a;
  ll ans = sa/2;
  if (sa%2) {
    ans = min(max(a-1, b-1), max(n-a, n-b));
    if (sa >= 4) {
      ll x = min(a-1, n-b);
      ll res = x+2;
      res += (sa-3)/2;
      ans = min(ans, res);
    }
  } 
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a==b){
		printf("a == b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a < b\n");
	}
	return 0;
}

Measured memory_bytes: 580
import java.util.*;
import java.lang.*;

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

		String str = input.nextLine();
		int len = str.length();
		if(str.charAt(len-1) == 's')str += "es";
		else str += "s";
		System.out.println(str);
		
	}
}

Measured memory_bytes: 38596
// https://atcoder.jp/contests/abc095/tasks/arc096_a
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long ans = LONG_MAX;
    long temp = 0;
    for (int i = 0; i <= max(x, y) * 2; i += 2)
    {
        int numA = ((x - i / 2) >= 0 ? (x - i / 2) : 0);
        int numB = ((y - i / 2) >= 0 ? (y - i / 2) : 0);
        temp = a * numA + b * numB + c * (i);
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int n = Integer.parseInt(str);
		String[][] list = new String[n][];
		long[] t = new long[n];
		long[] a = new long[n];

		for(int i=0; i<n; i++){
			str = input.readLine( );
			list[i] = str.split(" ");
			t[i] = Long.parseLong(list[i][0]);
			a[i] = Long.parseLong(list[i][1]);
		}

		long tans = t[0];
		long aans = a[0];

		for(int i=1; i<n; i++){
			for(long j=1; j< (long)Math.pow(10, 18);){
				if(tans<=t[i]*j && aans<=a[i]*j){
					tans = t[i]*j;
					aans = a[i]*j;
					break;
				}else if(tans<t[i]*j && aans>a[i]*j) {
					j = (long) Math.max(j+1,(aans/a[i]));
				}else if(tans>t[i]*j && aans<a[i]*j) {
					j = (long) Math.max(j+1,(tans/t[i]));
				}else  {
					j = (long) Math.max(j+1,Math.max((tans/t[i]),(aans/a[i])));
				}
			}
		}
		System.out.println(tans+aans);
	}
}


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

int main() {
  string str;
  cin >> str;
  char c = str.at(0);
  
  if(str.at(0) == 'a' || str.at(0) == 'i' || str.at(0) == 'u' || str.at(0) == 'e' || str.at(0) == 'o'){
    cout << "vowel" <<endl;
  }
  else{
    cout << "consonant" <<endl;
  }
}

Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
#include <cmath>
#include <ctime>
using namespace std;
typedef long long ll;

class CPoint
{
public:

	int x, y;

	CPoint() : x(0), y(0){};
	CPoint(int ax, int ay) : x(ax), y(ay){};

	bool operator==(const CPoint& obj);
	bool operator!=(const CPoint& obj);

	CPoint  operator+(const CPoint& obj);
};


class CPoint;

const int MAX_H = 1000;
const int MAX_W = 1000;
const ll  INF	= 1000000000;

char field[MAX_H][MAX_W];
bool used[MAX_H][MAX_W];
ll	 d[MAX_H][MAX_W];
int  H, W, N;

ll getroad(CPoint start, CPoint goal);


int main()
{
	cin>>H>>W>>N;
	vector<CPoint> factorys(N+1);

	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin>>field[i][j];
			if(field[i][j] != 'X' && field[i][j] != '.'){
				if(field[i][j] == 'S')	factorys[0] = CPoint(i, j);
				else					factorys[field[i][j] - '0'] = CPoint(i, j);
			}
		}
	}

	ll res = 0;
	for(int i = 0; i < N; i++)
		res += getroad(factorys[i], factorys[i+1]);

	cout<<res<<endl;
}

ll getroad(CPoint start, CPoint goal)
{
	for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) d[i][j] = INF;

	queue<CPoint> que;
	que.push(start);
	d[start.x][start.y] = 0;

	while(!que.empty()){
		CPoint v = que.front();
		que.pop();
		if(v.y+1 < W  && field[v.x][v.y+1] != 'X' && d[v.x][v.y] + 1 < d[v.x][v.y+1]){
			d[v.x][v.y+1] = d[v.x][v.y] + 1;
			que.push(v + CPoint(0, 1));
		}
		if(v.y-1 >= 0 && field[v.x][v.y-1] != 'X' && d[v.x][v.y] + 1 < d[v.x][v.y-1]){
			d[v.x][v.y-1] = d[v.x][v.y] + 1;
			que.push(v + CPoint(0, -1));
		}
		if(v.x+1 < H  && field[v.x+1][v.y] != 'X' && d[v.x][v.y] + 1 < d[v.x+1][v.y]){
			d[v.x+1][v.y] = d[v.x][v.y] + 1;
			que.push(v + CPoint(1, 0));
		}
		if(v.x-1 >= 0 && field[v.x-1][v.y] != 'X' && d[v.x][v.y] + 1 < d[v.x-1][v.y]){
			d[v.x-1][v.y] = d[v.x][v.y] + 1;
			que.push((v + CPoint(-1, 0)));
		}
	}
	return d[goal.x][goal.y];
}

bool CPoint::operator==(const CPoint& obj)
{
	return (x == obj.x && y == obj.y);
}

bool CPoint::operator!=(const CPoint& obj)
{
	return !(*this == obj);
}

CPoint CPoint::operator+(const CPoint& obj)
{
	CPoint tmp;
	tmp.x = x + obj.x;
	tmp.y = y + obj.y;
	return tmp;
}

Measured memory_bytes: 9664
n = int(input())

left = 0
right = n
print(left, flush=True)
sl = input()
if sl[0] == "V":
    quit()
while right - left > 1:
    mid = (left + right) // 2
    print(mid, flush=True)
    sm = input()
    if sm[0] == "V":
        quit()

    if ((mid - left) % 2 == 1) ^ (sl == sm):
        left = mid
        sl = sm
    else:
        right = mid



Measured memory_bytes: 9164