akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;

	int ans = 0;
	REP(i, 100000) {
		if (i*i <= N)chmax(ans, i*i);
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number, i;
    number = Integer.parseInt(sc.next());
    int[] height = new int[number];
    for(i = 0; i < number; i++) {
      height[i] = Integer.parseInt(sc.next());
    }
    for(i = 1; i < number; i++) {
      if(height[i-1] == height[i]) continue;
      else if(height[i-1] <= height[i] - 1) height[i]--;
      else break;
    }
    if(i == number) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 48788
program trickortreat;
var
    snuke : array[1..100] of boolean;
    n, k, i, j, x, y, counter : longint;
begin
    readln(n, k);
    counter := 0;
    for i := 1 to 100 do begin
        snuke[i] := false;
    end;
    
    for i := 1 to k do begin
        readln(x);
        for j := 1 to x do begin
            read(y);
            snuke[y] := true;
        end;
    end;    

    for i := 1 to n do begin
        if not(snuke[i]) then       
            counter += 1;
    end;
    writeln(counter);
end.

Measured memory_bytes: 1380
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<ll> m(n+1);
  vector<ll> h(n);
  rep(i, n+1) {
    cin >> m[i];
  }
  rep(i, n) {
    cin >> h[i];
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += min(h[i], m[i]);
    if (h[i] > m[i]) {
      ll r = h[i] - m[i];
      if (m[i+1] > r) {
        ans += r;
        m[i+1] -= r;
      } else {
        ans += m[i+1];
        m[i+1] = 0; 
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(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];
  vi b(n);
  rep(i,n) cin >> b[i];
  vi c(n);
  rep(i,n) cin >> c[i];

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  
  ll ans = 0;
  rep(i,n) {
    ll na = lower_bound(rng(a), b[i]) - a.begin();
    ll nc = c.end() - upper_bound(rng(c), b[i]);
    //debug(na);
    //debug(nc);
    ans += na*nc;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int a, b, c; cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << ' ' << b << ' ' << c << '\n';







}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>

using namespace std;
#define LL unsigned long long
#define MOD 998244353
#define inf 1999999999

LL N,D[100005],dist[100005]={},mx=0,ans=1;
int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> D[i];
		dist[D[i]]++;
		mx=max(mx,D[i]);
	}
	if(D[0]!=0 || dist[0]!=1){
		cout << 0 << endl;
		return 0;
	}
	for(int i=1; i<=mx; i++){
		if(dist[i]==0){
			cout << 0 << endl;
			return 0;
		}
		for(int j=0; j<dist[i]; j++){
			ans*=dist[i-1];
			ans%=MOD;
		}
	}
	cout << (ans%MOD) << endl;
	return 0;
}



Measured memory_bytes: 1792
var
    n : integer;
    a, b, x, val, y, z, k, res: int64;
    label ending;

begin
    read(n);
    read(a, b);
    n := n - 2;
    while n <> 0 do begin
            n := n - 1;
            read(val);
            x := x xor val;
    end;
    y := a + b - x;
    z := y shr 1;
    if (y < 0) or ((y and 1) <> 0) or ((x and z) <> 0) or (a < z) then
        begin
          writeln('-1');
          goto ending;
        end;
    res := z;
    k := 1 shl 40; 
    while k <> 0 do begin
        if (x and k) <> 0 then begin
            if (res or k) <= a then begin
              res := res or k;
            end;
        end;
        k := k shr 1;
    end;
    if res = 0 then writeln('-1') else writeln(a - res);
    ending:
end.

Measured memory_bytes: 1380
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename T> inline T range(T l, T r) {
    return uniform_int_distribution<T>(l, r)(rng);
}

inline void setin(string s) {
    freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
    freopen(s.c_str(), "w", stdout);
}

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

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

const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int N = 3e2 + 15;
int n, k;
string s;
int dp[2][N][N]; // dp[i][operation_applied][free_ones]
int a[N];

inline int add(int a, int b) {
    a += b;
    if(a >= mod)
        a -= mod;
    return a;
}

inline void add_t(int &a, int b) {
    a = add(a, b);
}

inline int mt(int a, int b) {
    return 1ll * a * b % mod;
}

inline void construct() {
    int sz = 1;
    for(int i = 1; i <= n && s[i] == '1'; ++i)
        a[1] = i;
    for(int i = a[1] + 1; i <= n; ++i) {
        if(s[i] == '0') {
            if(i + 1 <= n && s[i + 1] == '0')
                a[++sz] = 0;
        }
        else {
            int j = i;
            while(j + 1 <= n && s[j + 1] == '1')
                ++j;
            a[++sz] = j - i + 1;
            i = j;
        }
    }
    n = sz;
}

inline void solve() {
    // dp[i][operation_applied][free_ones]
    dp[(n + 1) & 1][0][0] = 1;
    int sum = 0;
    for(int i = n; i >= 1; --i) {
        int bit = i & 1;
        memset(dp[bit], 0, sizeof(dp[bit]));
        for(int k = 0; k <= sum; ++k) {
            int val = 0;
            for(int t = sum; t >= 0; --t) {
                add_t(dp[bit][k][t], val);
                for(int j = 0; j <= a[i] && k + j < N; ++j)
                    add_t(dp[bit][k + j][t + j], dp[bit ^ 1][k][t]);
                add_t(val, dp[bit ^ 1][k][t]);
            }
        }
        sum += a[i];
    }
}

inline void output() {
    int ans = 0;
    for(int i = 0; i < min(N, k + 1); ++i)
        add_t(ans, dp[1][i][0]);
    cout << ans << endl;
}

main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // setin("input.txt");
    cin >> s >> k;
    n = s.size();
    s = '#' + s;
    construct();
    solve();
    output();
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    vector<int> ra(n,0),rb(n,0);
    int res=0;
    int two=1;
    for(int loop=0;loop<30;loop++){
        vector<pair<int,int>> raa(n),rbb(n);
        for(int i=0;i<n;i++){
            raa[i]={ra[i],a[i]};
            rbb[i]={rb[i],b[i]};
        }
        sort(raa.begin(),raa.end());
        sort(rbb.begin(),rbb.end());
        for(int i=0;i<n;i++){
            a[i]=raa[i].second;
            ra[i]=raa[i].first;
            b[i]=rbb[i].second;
            rb[i]=rbb[i].first;
        }
        int l0cnt=0;
        int l1cnt=0;
        int r0cnt=0;
        int r1cnt=0;
        int r=n;
        for(int i=0;i<n;i++){
            if(b[i]%2) l1cnt++;
            else l0cnt++;
        }
        int kurai=0;
        for(int i=0;i<n;i++){
            while(r>0 && ra[i]+rb[r-1]>=two){
                if(b[r-1]%2){
                    l1cnt--;
                    r1cnt++;
                }
                else{
                    l0cnt--;
                    r0cnt++;
                }
                r--;
            }
            //[0,r)で繰り上がらない
            if(a[i]%2){
                kurai+=l0cnt+r1cnt;
            }
            else{
                kurai+=l1cnt+r0cnt;
            }
            kurai%=2;
        }
        for(int i=0;i<n;i++){
            ra[i]+=two*(a[i]%2);
            rb[i]+=two*(b[i]%2);
            a[i]/=2;
            b[i]/=2;
        }
        res+=(kurai%2)*two;
        two*=2;
    }

    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 8536
n,a,b = (int(i) for i in input().split())
s = input()
num,num2,x = 0,0,a+b
for i in range(n):
	if s[i]=="c": print("No")
	elif s[i]=="a":
		if num<x:
			num+=1
			print("Yes")
		else: print("No")
	else:
		if num<x and num2<b:
			num,num2 = num+1,num2+1
			print("Yes")
		else: print("No")

Measured memory_bytes: 4244
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int[] num=new int[N];
        int sumA=0;
        int sumB=0;
        for(int i=0;i<N;i++){
            num[i]=sc.nextInt();
        }
        num=sort(num);
        for(int i=0;i<N;i++){
            if(i%2 == 0){
                sumA+=num[i];
            }else{
                sumB+=num[i];
            }
        }
        System.out.println(sumA-sumB);
    }

    static int[] sort(int[] num){
        int temp=0;
        for(int i=0;i<num.length-1;i++){
            for(int j=num.length-1;j>i;j--){
                if(num[j] > num[j-1]){
                    temp=num[j];
                    num[j]=num[j-1];
                    num[j-1]=temp;
                }
            }
        }
        return num;
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
bool isprime(int num){
	if(num<2) return false;
	else if(num==2) return true;
	else if (num%2==0) return false;

	double sqrtNum = sqrt(num);
	for(int i=3;i<=sqrtNum;i+=2){
		if(num%i==0) return false;
	}
	return true;
}
int main(){
	int q; cin >> q;
	vector<int> f(1e5);
	vector<int> c(1e5,0);
	for(int i=1;i<=1e5;i++) f[i]=isprime(i);
	for(int i=3;i<=1e5;i+=2) if(f[i] && f[(i+1)/2]) c[i]++;
	for(int i=3;i<=1e5;i++) c[i]+=c[i-1];
	while(q--){
		int l,r;
		cin >> l >> r;
		cout << c[r]-c[l-1] << endl;
	}
}


Measured memory_bytes: 1408
use proconio::input;

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

    let mut a: Vec<(u64, usize)> = a.iter().copied().enumerate().map(|(i, x)| (x, i)).collect();
    a.sort();
    a.reverse();
    let a = a;

    let mut solve = Solve {
        n,
        a,
        memo: vec![vec![None; n + 1]; n + 1],
    };
    solve.solve();
}

struct Solve {
    n: usize,
    a: Vec<(u64, usize)>,
    memo: Vec<Vec<Option<u64>>>,
}

impl Solve {
    fn solve(&mut self) {
        let ans = self.calc(0, self.n);
        // dbg!(&self.memo);
        println!("{}", ans);
    }

    // 範囲とかをもらって、嬉しさの最大値を返す
    fn calc(&mut self, left: usize, right: usize) -> u64 {
        let n = self.n;
        let a = &self.a;

        if let Some(joy) = self.memo[left][right] {
            return joy
        }

        if left == right {
            self.memo[left][right] = Some(0);
            return 0
        }

        let next = left + (n - right);
        let (activeness, origin_i) = a[next];
        // dbg!(left, right, activeness);
        // dbg!(left, right);

        // 左に付け足す
        let ret1 = self.calc(left + 1, right) + activeness * (origin_i as i64 - left as i64).abs() as u64;
        let ret2 = self.calc(left, right - 1) + activeness * (origin_i as i64 - (right - 1) as i64).abs() as u64;
        // dbg!(activeness * (origin_i as i64 - (left + 1) as i64).abs() as u64);
        // dbg!(activeness * (origin_i as i64 - (right - 1) as i64).abs() as u64);

        let ret = std::cmp::max(ret1, ret2);
        self.memo[left][right] = Some(ret);

        // dbg!(ret);
        ret
    }
}


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

int main()
{
    int n;
    cin >> n;
    vector<double> x(n);
    vector<string> u(n);
    for (int i = 0; i < n; i++)
        cin >> x[i] >> u[i];
    double sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (u[i].compare("JPY") == 0)
            sum += x[i];
        else
            sum += x[i] * 380000.0;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll n; cin >> n;
    ll ans = 0;
    REP(i,n+1) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        ans += i;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3652
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Describe
"""
from operator import itemgetter

def main():
    n, m = map(int, input().split())
    data = []
    for i in range(m):
        p, y = map(int, input().split())
        data.append([p, y, i])
    # print(data)
    data_sorted = sorted(data, key=itemgetter(0, 1))
    # print(data_sorted)

    p, y, i = 0, 0, 0
    p_prev = 0 
    x = 1 # initialize
    codes = []
    for p, y, i in data_sorted:
        # initialize if new prefecture, increment if not
        if p != p_prev:
            x = 1
        else:
            x += 1
        code = '{:06d}{:06d}'.format(p, x)
        codes.append([i, code])
        p_prev = p
    # print(codes)

    codes_sorted = sorted(codes, key=itemgetter(0))
    # print(codes_sorted)

    for i, code in codes_sorted:
        print(code)
        
main()


Measured memory_bytes: 107608
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args){

		solve_abc164_a();
	}
  
  
  	public static void solve_abc164_a(){

		FastScanner sc = new FastScanner(System.in);
		
		int s = sc.nextInt();
		int w = sc.nextInt();
		
		String st;
		
		if(w >= s) st = "unsafe";
		else st = "safe";
		
		System.out.println(st);
		

	}
}

Measured memory_bytes: 26944
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <string>
#include <complex>
#include <cmath>

int D;
int c[26];
std::vector<std::vector<int>> s;
std::vector<int> d;
std::vector<int> last;
int satisfactoeries[26];

void update_last(int contest) {
  for (auto& e: last) {
    e += 1;
  }
  last[contest] = 0;
  return;
}

std::vector<int> assume_update_last(int contest) {
  std::vector<int> assumed_last;
  assumed_last.assign(D, 0);
  for (int i = 0; i < 26; i++) {
    assumed_last[i] = last[i] + 1;
  }
  assumed_last[contest] = 0;
  return assumed_last;
}

int calculate_satisfactory(int contest_candidate, int j) {
  int satisfactory = 0;
  satisfactory += s[j][contest_candidate];
  for (int i = 0; i < 26; i++) {
    satisfactory -= c[i] * assume_update_last(contest_candidate)[i];
  }
  return satisfactory;
}

int main() {
  std::cin >> D;
  d.assign(D, 0);
  last.assign(D, 0);
  s.assign(D, std::vector<int>(26, 0));
  int max_c = 0;
  int max_c_index = 0;
  for (int i = 0; i < 26; i++) {
    std::cin >> c[i];
    if (c[i] > max_c) {
      max_c = c[i];
      max_c_index = i;
    }
  }
  for (int j = 0; j < D; j++) {
    for (int i = 0; i < 26; i++) {
      std::cin >> s[j][i];
    }
  }
  for (int j = 0; j < D; j++) {
    if (j == 0) {
      d[j] = max_c_index;
      update_last(max_c_index);
    } else {
      int max_satisfactory = -1000000000;
      int max_sati_i = -1;
      for (int i = 0; i < 26 ; i++) {
        satisfactoeries[i] = calculate_satisfactory(i, j);
        if (max_satisfactory < satisfactoeries[i]) {
          max_satisfactory = satisfactoeries[i];
          max_sati_i = i;
        }
      }
      d[j] = max_sati_i;
      update_last(d[j]);
    }
  }

  for (int j = 0; j < D; j++) {
    std::cout << d[j]+1 << std::endl;
  }
}



Measured memory_bytes: 3708
from heapq import heappush, heappop

# 入力
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

INF = 10**15

# 幅優先探索により解を求める
a = sorted(A, reverse=True) + [-INF]
b = sorted(B, reverse=True) + [-INF]
c = sorted(C, reverse=True) + [-INF]
q = []
heappush(q, (-(a[0] + b[0] + c[0]), 0, 0, 0))
m = 0
d = []
u = set()
while m < K:
    s, i, j, k = heappop(q)
    if (i, j, k) not in u:
        d.append(-s)
        u.add((i, j, k))
        heappush(q, (-(a[i + 1] + b[j] + c[k]), i + 1, j, k))
        heappush(q, (-(a[i] + b[j + 1] + c[k]), i, j + 1, k))
        heappush(q, (-(a[i] + b[j] + c[k + 1]), i, j, k + 1))
        m += 1
ans = '\n'.join(map(str, d))

# 出力
print(ans)


Measured memory_bytes: 54488
#include<bits/stdc++.h>
#define fi(i,a,b) for(ll i = a; i < b; i++)
#define fd(i,a,b) for(ll i = a; i >= b; i--)
#define cfi(container,it) for(auto it = container.begin(); it != container.end(); it++)
#define cfd(container,it) for(auto it = container.rbegin(); it != container.rend(); it++)
#define vi vector<int>
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back

using namespace std;
using ll = long long;
const int MOD = (int) 1e9 + 7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s1, s2;
	cin>>s1>>s2;
	int n = s2.length();

	fi(i, 0, n - 1) {
		if(s2[i] != s1[i]) {
			cout<<"No\n";
			return 0;
		}
	}

	cout<<"Yes\n";

	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

#define NMAX 20
#define QMAX 200

int n, a[NMAX];

//m - a[0]) - a[1]) 
int isM(int i,int m){
  int r;
  if(m == 0) return 1;
  if(i >= n) return 0;

  r = isM(i + 1, m - a[i]);
  if(r == 0)
    r = isM(i + 1, m);
  return r;
}

int main(){
  int i,q,m[QMAX];

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

  for(i = 0; i < q; i++)
    printf( (isM(0,m[i]) == 1) ? "yes\n" : "no\n");
  
  return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdlib>

using namespace std;

typedef long long ll;
const int MAX = 1001;
const ll INF = (1LL<<60);

struct State{
  int t,pos;
  State(){}
  State(int t, int pos):t(t),pos(pos){}
  bool operator < (const State& s) const { return t > s.t;}
};
int len[MAX][MAX];
int N,W,cnt;
ll T[MAX];
vector<int> V;

void init(){
  V.clear();
  fill(T,T+MAX,INF);
}

void input(){
  V.resize(N+1);
  V[0] = 0;
  for(int i = 1; i <= N; i++) cin >> V[i];
}

void solve(){
  for(int i = 1; i <= N; i++){
    len[i][i] = V[i];
    for(int j = i+1; j <= N; j++) len[i][j] = len[i][j-1]+V[j];
  }

  priority_queue<State> Q;
  Q.push(State(0,0));
  T[0] = 0;
  
  while(!Q.empty()){
    State now = Q.top();
    Q.pop();
    
    if(T[now.pos] < now.t) continue;

    for(int i = now.pos+1; i < N; i++){
      State nex = now;
      nex.t += abs(len[now.pos+1][i]-W);
      nex.pos = i;
      if(T[nex.pos] > nex.t){
	T[nex.pos] = nex.t;
	Q.push(nex);
      }
    }
    T[N] = min(T[N],now.t + (ll)max(0,len[now.pos+1][N]-W));
  }
  cout <<"Case " << ++cnt << ": "  << T[N] << endl;
}

int main(){
  while(cin >> N >> W && N+W){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 13092
//2018-01-07
//LZYeah
//
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define Forr(i,a,b) for(register int i=a;i>=b;i--)
using namespace std;
inline void File()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
inline void read(int &x)
{
	int p=1;
	x=0;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c^'0');c=getchar();}
	x*=p;
}
int tot,n;

int main()
{
//	File();
	read(tot),read(n);
	int yu=n;
	n/=1000;
	int k=n-tot;
	For(i,0,2500)
	{
		int u=(k-(i*9))/4;
		if(i*9>k){puts("-1 -1 -1");return 0;}
		if((k-(i*9))%4==0)
		{
			int g=tot-i-u;			
			if(yu==(i*10000+u*5000+g*1000)&&g>=0) 
			{
				cout<<i<<' '<<u<<' '<<g<<endl;
				return 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>num(3);
  int sum=0;
  for(int i=0;i<3;++i){
    cin>>num[i];
    sum+=num[i];
  }
  sort(num.begin(), num.end());
  int goal=num[2]*3;
  if((sum%2==0 && goal%2==0) || (sum%2!=0 && goal%2!=0)){
    cout<<(goal-sum)/2<<endl;
  }else{
    goal+=3;
    cout<<(goal-sum)/2<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
const int MN=250005;
int N;
char s[MN];
const int P=998244353;
int Add(int x,int y){return (x+y)%P;}
int Mul(int x,int y){return (1ll*x*y)%P;}
const int B[]={691,769,823,877,911,967},
inv[]={37560569,983965175,992179685,349442436,115055606,356147158};
struct node
{
	int v[6];
	int& operator [](int x){return v[x];}
	bool operator <(const node o)const
	{
		for(int i=0;i<6;++i)if(v[i]!=o.v[i])return v[i]<o.v[i];
		return false;
	}
	bool operator ==(const node o)const
	{
		for(int i=0;i<6;++i)if(v[i]!=o.v[i])return false;
		return true;
	}
}pre[MN],all;
std::map<node,int> Mp;
int pos[MN],nm[6][MN<<1],cal[MN];
node get(node x,node y,int p)
{
	for(int j=0;j<6;++j)
		x[j]=Add(x[j],Mul(y[j],nm[j][p]));
	return x;
}
int main()
{
	scanf("%d%s",&N,s+1);
	reg int i,j,k;
	for(j=0;j<6;++j)for(nm[j][MN]=i=1;i<=N;++i)
		nm[j][i+MN]=Mul(nm[j][i-1+MN],B[j]),
		nm[j][-i+MN]=Mul(nm[j][-i+1+MN],inv[j]);
	for(k=j=0;j<6;++j,k=0)for(i=1;i<=N;++i)
	{
		switch(s[i])
		{
			case '<':--k;break;
			case '>':++k;break;
			case '+':all[j]=Add(all[j],nm[j][k+MN]);break;
			case '-':all[j]=Add(all[j],P-nm[j][k+MN]);break;
		}
		pos[i]=k;pre[i][j]=all[j];
	}
	++Mp[all];
	for(i=1;i<=N;++i)
		cal[i]=Mp[pre[i]],
		++Mp[get(pre[i],all,pos[i]+MN)];
	ll ans=0;
	for(i=1;i<=N;++i) ans+=cal[i];
	return 0*printf("%lld\n",ans);
}

Measured memory_bytes: 59136
#include<bits/stdc++.h>
using namespace std;
#define INF (1LL<<60)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

#define N 100


signed main(){
	int n,k;
	cin>>n>>k;
	if(k==1) cout<<0<<endl;
	else cout<<n-k<<endl;
  	return 0;
}

Measured memory_bytes: 256
import sys

lines = sys.stdin.readlines()

for n, line in enumerate(lines):
  if n == 0:
    n, k = [int(_) for _ in line.strip().split(' ')]
  elif n == 1:
    bars = [int(_) for _ in line.strip().split(' ')]
  else:
    raise

bars = sorted(bars, reverse=True)
print(sum(bars[:k]))

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

typedef long long int ll;
const ll MAX=6e5 + 10;

int main()
{
	int m,n; cin>>m>>n; char a[100][100];
	for(int i=0;i<m;i++) for(int j=0;j<n;j++) cin>>a[i][j];

	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			if(a[i][j]=='#'){
				bool ok=false;
				if(i-1>=0) ok |= (a[i-1][j]=='#');
				if(j-1>=0) ok |= (a[i][j-1]=='#'); 
				if(i+1<m) ok |= (a[i+1][j]=='#'); 
				if(j+1<n) ok |= (a[i][j+1]=='#');  
				if(!ok){
					cout<<"No"; return 0;
				}
			}
		}
	}
	cout<<"Yes";
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def cmb(a, b, mod):
    m, n = 1, 1
    b = min(b, a-b)
    for i in range(1, b+1):
        m *= (a-i+1)
        m %= mod
        n *= i
        n %= mod
    return m * pow(n, mod-2, mod) % mod
def main():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7
    total = pow(2, n, mod) - 1
    cmb1 = cmb(n, a, mod)
    cmb2 = cmb(n, b, mod)
    ans = total - cmb1 - cmb2
    ans %= mod
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38512
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
    var n = parseInt(tmp[0], 10);
    var k = parseInt(tmp[1], 10);
    var count = 0;
    do {
    var t=Math.floor(n/k); n=t;
    count=count+1;
   // console.log(t,n,count );
 
} while(t!==0 ){
    var t=Math.floor(n/k); n=t;
    count=count+1;
   // console.log(t,n,count );
};
  console.log(count-1);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
 
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
 
int compare(const void *a, const void *b){
  return (*(ll int *)a)- (*(ll int *)b);
} 
 
int main(){
  int n,w=0,e=0;
  scanf("%d",&n);
  char s[n];
  scanf("%s",s);
  
  for(int i=0;i<=n;i++){
    if(s[i]=='E'){
      e+=1;
    }
  }
  
  int min=n;
  
    for(int j=0;j<n;j++){
      if(s[j]=='W'){
        if(min>w+e){
          min=w+e;
        }w++;
      }
      
      else{
        e--;
        if(min>w+e){
          min=w+e;
        }
      }
    }
  printf("%d",min);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t n=0;
  int64_t a=0;
  int64_t b=0;
  int64_t x=0;
  int64_t y=0;  
  int64_t s=0;
  cin >> n;
  cin >> a;
  cin >> b;
  x = n / (a + b);  
  y = n % (a + b);
  if(y>a){
    s = a * (x+1);
  }
  else{
    s += a*x + y;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
def solve():
    a, b = list(map(int, input().split(" ")))
    if 0 < a <= b:
        print("Positive")
    elif a <= b < 0:
        if (b-a)%2==1:
            print("Positive")
        else:
            print("Negative")
    elif a < 0 < b:
        print("Zero")
    return

solve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
 
    long long int  n,k,mi,f1,a;
    scanf("%lld %lld",&n,&k);
    a=n%k;
    f1=abs(k-a);
    mi=min(a,f1);
    cout<<mi<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long n,a[10000],t=0;
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        long long b;
        cin>>b;
        if(a[i]<b){
            t+=(b-a[i])/2;
        }else{
            t+=b-a[i];
        }
        
    }
    if(t>=0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int A[100010];
    rep(i, n) cin >> A[i];
    int ans[100010] = {}; 
    int ok = INF / 2;
    int ng = -1;
    while(abs(ok - ng) > 1) {
        int mid = ((ok + ng) / 2) * 2;
        //mid = 2;
        ans[0] = mid;
        int tmp[100010] = {};
        tmp[0] += mid / 2;
        tmp[n - 1] += mid / 2;
        rep(i, n - 1) {
            int c = (A[i] - tmp[i]);
            ans[i + 1] = c * 2;
            tmp[i + 1] += c;
            tmp[i] += c;
        }
        // rep(i, n) cout << tmp[i] << " ";
        // cout << endl;
        if(tmp[n - 1] >= A[n - 1]) ok = mid / 2;
        else ng = mid / 2;
        //cout << ok << " " << ng << endl;
        //break;
    }
    ans[0] = ok * 2;
    int tmp[100010] = {};
    tmp[0] += ok;
    tmp[n - 1] += ok;
    rep(i, n - 1) {
        int c = (A[i] - tmp[i]);
        ans[i + 1] = c * 2;
        tmp[i + 1] += c;
        tmp[i] += c;
    }
    rep(i, n) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

// x[0] = x[1] + x[N - 1]


Measured memory_bytes: 3712
n,m = map(int,input().split())

in_group = set()
in_group.add(1)

boll_num = {}
for i in range(n):
    boll_num[i+1] = 1


for i in range(m):
    x,y = map(int,input().split())
    if(x in in_group):
        in_group.add(y)
        if(boll_num[x] == 1):
            in_group.remove(x)
    
    boll_num[x] = boll_num.setdefault(x,0) - 1
    boll_num[y] = boll_num.setdefault(y,0) + 1

print(len(in_group))


Measured memory_bytes: 26740
#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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

pair<pint,int> cnt[51];//{cnt,-pena,id}
int pn[51][12];
int main(){
    int m,t,p,r;
    while(cin>>m>>t>>p>>r,m|t|p|r){
        rep(i,t) cnt[i]={{0,0},i+1};
        memset(pn,0,sizeof(pn));
        int mi,ti,pi,ji;
        rep(i,r){
            cin>>mi>>ti>>pi>>ji;
            --ti;
            if(ji==0){
                ++cnt[ti].first.first;
                cnt[ti].first.second-=mi+pn[ti][pi];
            }
            else{
                pn[ti][pi]+=20;
            }
        }
        sort(cnt,cnt+t);
        reverse(cnt,cnt+t);
        rep(i,t){
            cout<<cnt[i].second;
            if(i<t-1){
                if(cnt[i].first==cnt[i+1].first) cout<<"=";
                else cout<<",";
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    ll sum = 0;
    ll ma = 0;
    rep(i, n) {
        chmax(ma, a[i]);
        sum += ma - a[i];
    }
    cout << sum << '\n';
    return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  ll a[n];
  rep(i,0,n){
    cin>>a[i];
  }
  ll b[m];
  rep(i,0,m){
    cin>>b[i];
  }
  ll x[n-1];
  rep(i,0,n-1){
    x[i]=a[i+1]-a[i];
  }
  ll y[m-1];
  rep(i,0,m-1){
    y[i]=b[i+1]-b[i];
  }
  ll c=0;
  rep(i,0,n-1){
    c+=x[i]*(i+1)%mod*(n-1-i)%mod;
    c%=mod;
  }
  ll d=0;
  rep(i,0,m-1){
    d+=y[i]*(i+1)%mod*(m-1-i)%mod;
    d%=mod;
  }
  cout<<c*d%mod<<endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, m;
  cin >> n >> m;
  map<ll, ll> mp;
  priority_queue<pair<ll, ll>> v;
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    mp[a]++;
  }
  for (int i = 0; i < m; ++i)
  {
    int b, c;
    cin >> b >> c;
    v.emplace(c, b);
  }

  pair<int, int> p = v.top();
  v.pop();

  for (auto &e : mp)
  {
    if (e.first >= p.first)
      break;
    if (e.second < p.second)
    {
      mp[p.first] += e.second;
      p.second -= e.second;
      e.second = 0;
    }
    else
    {
      while (e.second >= p.second)
      {
        if (e.first >= p.first)
          break;
        mp[p.first] += p.second;
        e.second -= p.second;
        p.second = 0;
        if (v.empty())
          break;
        p = v.top();
        v.pop();
      }
      if (e.second > 0 && p.second > 0 && e.first < p.first)
      {
        mp[p.first] += e.second;
        p.second -= e.second;
        e.second = 0;
      }
    }
    if (p.second == 0 && v.empty())
      break;
  }

  ll ans = 0;
  for (auto &e : mp)
  {
    ans += e.first * e.second;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc075.contest.atcoder.jp/tasks/arc075_c>
問題文============================================================
 長さ N の整数列 a= {a1,a2,…,aN} と、整数 K が与えられます。
 
 a の空でない連続する部分列 {al,al+1,…,ar} (1≤l≤r≤N) は N(N+1)⁄2 個存在します。
 これらのうち、算術平均が K 以上であるものは何個あるでしょうか？
 
 入力値はすべて整数である。
 1≤N≤2×10^5
 1≤K≤10^9
 1≤ai≤10^9
=================================================================

解説=============================================================

 
 
================================================================
*/


struct BIT {
    int N;
    vector<ll> bit;
    BIT(int N):N(N) {
        /* BITは[1..N]で扱う */
        bit.resize(N + 1, 0);
    }
    
    void add(int x, int val)
    {
        while (x <= N) {
            bit[x] += val;
            x += x & -x;
        }
    }
    
    int sum(int x)
    {
        int ret = 0;
        while (x) {
            ret += bit[x];
            x &= (x - 1);
        }
        
        return (ret);
    }
};

ll solve(){
    ll res = 0;
    ll N,K; cin >> N >> K;
    vector<ll> a(N); for(auto &in:a){ cin >> in; in -= K; }
    vector<pll> cusum(N);
    for(int i = 0; i < N;i++){
        if(i == 0){
            cusum[i] = {a[i],i+1};
        }else{
            cusum[i] = {cusum[i-1].first + a[i],i+1};
        }
    }
    sort(cusum.begin(),cusum.end());
    reverse(cusum.begin(),cusum.end());
    BIT bit(N);
    for(int i = 0; i < N;i++){
        if(cusum[i].first >= 0){
            res += bit.sum(cusum[i].second);
            bit.add(cusum[i].second,1);
        }else{
            bit.add(cusum[i].second,1);
            res += bit.sum(cusum[i].second);
        }
    }
    return N*(N+1)/2 - res;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long ni(long long ta, vector<long long> & v) {

}
long long rui(long long n, long long k, long long p) {
	if (k == 0) {
		return 1;
	}
	else {
		long long a = rui(n, k / 2, p);
		if (k % 2 == 0) {
			return (a*a) % p;
		}
		return (((a*a) % p)*n) % p;
	}
}
int main(){
	int n; cin >> n;
	int ans = 101;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		sum += a;
		ans = min(ans, sum / (i + 1));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main(){
    int n, a, b;

    cin >> n;
    cin >> a;
    cin >> b;

    int train, taxi;

    train = n * a;
    taxi = b;
    if (train < taxi){
        cout << train << endl;
    }else if(taxi <= train){
        cout << taxi << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: str):
    s = S[K - 1].lower()
    S = list(S)
    S[K - 1] = s
    S = "".join(S)
    print(S)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
    int index = 0;
    int m = 9;
    int count = 0;
    vector<int> a(5);
    for (int i = 0; i < 5; i++){
        cin >> a[i];
        if (m > a[i]%10 && a[i]%10 > 0){
            m = a[i]%10;
            index = i;
        }
    }

    for (int i = 0; i < 5; i++){
        if (i == index){
            count += a[i];
            continue;
        }
        count += 10*(a[i]/10);
        if (a[i]%10 != 0) {
            count += 10;
        }
    }
    cout << count << endl;
}

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

int main() {
	int a,b,N,s[1010]={0},f[1010]={0},hantei=0;
	cin>>a>>b;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>s[i]>>f[i];
        if (s[i]<=a&&b<=f[i]){
            hantei=1;
        }
        else if (a<=s[i]&&s[i]<b){
            hantei=1;
        }
        else if (a<f[i] && f[i] <= b){
            hantei=1;
        }
        else if (a < s[i] && f[i]<b){
            hantei=1;
        }
	}
	cout<<hantei<<endl;
	return 0;
}



Measured memory_bytes: 3104
/*
    Rem is cute :D
*/

# include <bits/stdc++.h>

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)2e6 + 7;
const ll linf = (ll)1e18 + 7;

const ld eps = ld(1e-11);

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

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

int n, m, k;
int u[111], a[211][211];
vector < int > g[111], vec;
char b[211][211];
string s;

int main(){
  cin >> s;
  for(char i : s){
    if(i == '9')
      cout << 1;
    else
      cout << 9;
  }
  return 0;
}


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

int N;
int A[100010];

inline bool r(int x, int y) {
  if (A[x+1] <= y) return true;
  return !r(x+1, y);
}

int main() {
  cin >> N;
  for (int i=1; i<=N; i++) {
    cin >> A[i];
  }
  sort(A+1, A+N+1, greater<int>());
  A[0] = A[1];
  int i = 0;
  while (A[i+2] > i+1) i++;
  cout << (!(r(i+1,i) && ((A[i+1]-(i+1)) % 2 == 0)) ? "First\n" : "Second\n");
  return 0;
}


Measured memory_bytes: 1152
import itertools
import numpy as np

H, W, K = map(int, input().split())

temp = []
for _ in range(H):
    C = list(input())
    A = [c.replace('.', '0') for c in C]
    A = [a.replace('#', '1') for a in A]
    A = list(map(lambda x: int(x), A))
    temp.append(A)

C = np.array(temp)

count = 0
l = [0, 1]
wide = itertools.product(l, repeat=W)
for w in wide:
    hight = itertools.product(l, repeat=H)
    for h in hight:
        copy_C = C.copy()
        for num, i in enumerate(w):
            if i == 1:
                copy_C[:, num-1] = 0
            for num2, j in enumerate(h):
                if j == 1:
                    copy_C[num2-1, :] = 0
        if copy_C.sum() == K:
            count += 1

print(count)

Measured memory_bytes: 27148
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    string a, b;
    cin>>a>>b;
    int la = a.length();
    int lb = b.length();
    rep(i,lb)cout << a[i] << b[i];
    if(la!=lb)
        cout << a[la - 1];
    cout << endl;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
X = list(map(int, input().split()))

sort_X = sorted(X)
l = sort_X[int(N/2 - 1)]
r = sort_X[int(N/2)]

for i in range(N):
    if (X[i] <= l):
        print(r)
    else:
        print(l)


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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)


typedef long long  ll;
#define endl '\n'




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


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

//////////////////////////////////////////


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

string s;
void Input() {

    cin >> s;
}



void Solve() {


    int i = 0;
    int j = s.size()-1;

    int cnt = 0;
    while(i < j) {

        if(s[i] != s[j]) {

            cnt++;

        }


        i++;
        j--;


    }

    cout << cnt << endl;


}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 256
//#include <bits/stdc++.h> // header file includes every Standard library
#include<iostream>
using namespace std;

int help(string s,string t,int n,int i,int j){
	if(j>=n) return 0;	
	if(s[i]==t[j]){
		return help(s,t,n,i+1,j+1);
	}
	return 1+help(s,t,n,i+1,j+1);
}

int main() {
	string s,t;
	int min=10000;
	cin>>s>>t;
	int m=s.length(),n=t.length();
	for(int i=0;i<=s.length()-t.length();i++){
		int x=help(s,t,n,i,0);
		if(x<min){
			min=x;
		}
	}
	//if(min==10000)
	cout<<min;
	return 0;
}

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


int main(){
  int n; cin >> n;
  string s; cin >> s;
  map<char,long long int> mp;
  for (auto &&i : s)
  {
    if(i == 'R') mp['R']++;
    if(i == 'G') mp['G']++;
    if(i == 'B') mp['B']++;
  }
  long long ans = mp['R'] * mp['B'] * mp['G'];

  for (int i = 0; i < n; i++)
  {
    for (int k = i + 2; k < n; k += 2)
    {
      int j = (i + k) / 2;
      //cout << "(" << i << "," << j << "," << k << ")" << endl;
      if (s.at(i) != s.at(j) && s.at(i) != s.at(k) && s.at(j) != s.at(k))
      {
        ans--;
      }
      
    }
    
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3592
#include<cstdio>
#include<vector>

using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	vector<long long> a(n), b(n);
	for(int i = 0; i < n; i++){
		scanf("%lld%lld", &a[i], &b[i]);
	}
	long long cnt = 0;
	for(int i = n - 1; i >= 0; i--){
		if((a[i] + cnt) % b[i] == 0){ continue; }
		cnt += b[i] - ((a[i] + cnt) % b[i]);
	}
	printf("%lld\n", cnt);
	return 0;
}


Measured memory_bytes: 1792