akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main()
{
  ll n,k,i;
    cin >> n >> k;

    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }


    for(i=1;i<=k;i++){
    ll ans=0;
    ans = comb(n-k+1, i)*comb(k-1, i-1)%M;
    cout << ans << endl;
    }
    return 0;
}


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

int main(){
    double a, b;
    cin >> a >> b;
    if (b == 1){cout << 0 << endl; return 0;}
    cout << ceil((b- 1) / (a - 1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cctype>
#include<string>
#include<cstring>
#include<iostream>

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

using namespace std;

/*
GENOME ::= UNIT | UNIT GENOME
UNIT ::= MOLECULE | NUMBER MOLECULE | NUMBER '(' GENOME ')'
MOLECULE ::= A | B | .. | Z
NUMBER ::= 1 | 2 | .. | 1000
*/

void GENOME(int &,int &);
void UNIT(int &,int &);
void MOLECULE(int &,int &);
int NUMBER(int &);

string s;
int p,len;
char s2[1000001];

void GENOME(int &idx,int &idx2){
	while(idx<len && isalnum(s[idx])){
		if(p<idx2)	return;
		UNIT(idx,idx2);
	}
}

void UNIT(int &idx,int &idx2){
	if(isalpha(s[idx]))	MOLECULE(idx,idx2);
	else{
		int num=NUMBER(idx);
		int bef,aft;
		if(s[idx]!='('){
			bef=idx2;
			MOLECULE(idx,idx2);
			aft=idx2;
		}
		else{
			idx++;
			bef=idx2;
			GENOME(idx,idx2);
			aft=idx2;
			idx++;
		}
		int dif=aft-bef;
		rep(i,num-1)rep(j,dif){
			if(p<idx2)	return;
			s2[idx2++]=s2[bef+j];
		}
	}
}

void MOLECULE(int &idx,int &idx2){
	if(p<idx2)	return;
	s2[idx2++]=s[idx++];
}

int NUMBER(int &idx){
	int num=0;
	while(idx<len && isdigit(s[idx]))	num=num*10+(s[idx++]-'0');
	return num;
}

int main(){
	while(cin>>s>>p,s!="0"||p!=0){
		memset(s2,0,sizeof(s2));
		len=s.length();
		int idx=0,idx2=0;
		GENOME(idx,idx2);
		cout<<(p<idx2?s2[p]:'0')<<endl;
	}
	return 0;
}

Measured memory_bytes: 1888
def gcd(m,n):
    if m*n==0:
        return max(m,n)
    else:
        if m>=n:
            return gcd(n,m%n)
        else:
            return gcd(m,n%m)
a,b = map(int,input().split())
print(int(a*b/gcd(a,b)))


Measured memory_bytes: 2940
(function(input) {
    var p = input.split('\n');
    for (var i = 0; i < p.length; i++) {
        var x = p[i];
        if (x == 0) {
            return;
        }
        console.log(x.split('').reduce(function(a, b) {
            return Number(a) + Number(b);
        }));
    }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 8624
#include <math.h>
#include <iostream>

using namespace std;

int main() {
	long a, b, n, x, tmp, max=0;
	cin >> a >> b >> n;
	
	x = b - 1;
	if (b > n) x = n;
	
	cout << floorl(a*x / b) - a * floorl(x / b);;
	return 0;
}

Measured memory_bytes: 3260
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int s[] = new int[N];
		int sum=0;
		for(int i=0; i<N; i++){
			s[i] = sc.nextInt();
			sum = sum + s[i];
		}
		
		Arrays.sort(s);
		
		if((sum%10)!=0){
			System.out.println(sum);
			return;
		}
		for(int i=0; i<N; i++){
			int sumtmp = sum-s[i];
			if((sumtmp%10)!=0){
				System.out.println(sumtmp);
				return;
			}
		}
		System.out.println(0);
	}
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
	
	private void calc(){
		Scanner scanner = new Scanner(System.in);
		short i=1;
		while(true){
			int x=scanner.nextInt();
			int y=scanner.nextInt();
			int temp;
			
			if(x==0 && y==0)break;
			
			if(y<x){
				temp=x;
				x=y;
				y=temp;
			}
			System.out.print(x+" ");
			System.out.println(y);
			i++;
			
		}
		
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.calc();

	}
}

Measured memory_bytes: 27192
#include <bits/stdc++.h>
using namespace std;
const int N=200000+5;
int main()
{
    int a,b,c,x,y,ma=1e9;
    cin >> a >> b >> c >> x >> y;
    ma=min(ma,c*2*max(x,y));
    ma=min(ma,c*2*y+((x-y)>0?(x-y)*a:0));
    ma=min(ma,c*2*x+((y-x)>0?(y-x)*b:0));
    ma=min(ma,x*a+y*b);
    printf("%d\n",ma);
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let k: usize = sc.read();

    let mut cur = 1;
    for _ in 0..k {
        sc.write(format!("{}\n", cur));
        let mut candidate = vec![];
        for prefix in 0..4000 {
            let mut tmp = prefix;
            for _ in 0..13 {
                if tmp > cur {
                    candidate.push((s(tmp), tmp));
                }
                tmp *= 10;
                tmp += 9;
            }
        }

        candidate.sort_by(|&(sa, a), &(sb, b)| {
            if a * sb == b * sa {
                a.cmp(&b)
            } else {
                (a * sb).cmp(&(b * sa))
            }
        });
        let (_, next) = candidate[0];
        cur = next;
    }
}

fn s(mut x: usize) -> usize {
    let mut result = 0;
    while x > 0 {
        result += x % 10;
        x /= 10;
    }
    result
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
    int x;
    int n; cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++) {
        cin >> x;
        v.push_back(x);
    }
    int q; cin >> q;
    unordered_set<int> us;
    int upper = 1 << n;
    for(int j = 0; j < upper; j++) {
        int sum = 0;
        int jj = j;
        int index = 0;
        while(jj != 0) {
            if(jj & 1 == 1) {
                sum += v[index];
            }
            index++;
            jj >>= 1;
        }
        us.insert(sum);
    }
    for(int i = 0; i < q; i++) {
        cin >> x;
        if(us.find(x) != us.end())
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}



Measured memory_bytes: 3180
def solve():
    from itertools import accumulate

    N, W = map(int, input().split())

    e = tuple([] for _ in range(4))
    w1, v1 = map(int, input().split())
    e[0].append(v1)

    for _ in range(N - 1):
        _w, _v = map(int, input().split())
        e[_w - w1].append(_v)

    g = [None for _ in range(4)]
    for j in range(4):
        e[j].sort(reverse=True)
        g[j] = (0,) + tuple(accumulate(e[j]))

    ret = 0
    for a in range(len(e[0]) + 1):
        for b in range(len(e[1]) + 1):
            for c in range(len(e[2]) + 1):
                diff = W - (w1 * a + (w1 + 1) * b + (w1 + 2) * c)
                if diff < 0:
                    break
                d = min(len(e[3]), diff // (w1 + 3))
                ret = max(ret, g[0][a] + g[1][b] + g[2][c] + g[3][d])
    return ret


print(solve())

# https://atcoder.jp/contests/arc073/submissions/2794675
# https://atcoder.jp/contests/arc073/submissions/7328854


Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    vector<pair<int,int>> jewel(n);
    int v,c;
    
    for(int i = 0;i < n;i++){
        cin >> jewel[i].first;
    }

    for(int i = 0;i < n;i++){
        cin >> jewel[i].second;
    }

    int sum = 0;
    for(int i = 0;i < n;i++){
        if(jewel[i].first - jewel[i].second > 0){
        sum += jewel[i].first - jewel[i].second;
        }
    }

    cout << sum << endl;
    
}

Measured memory_bytes: 256
import math
n = int(input())
S = list(map(int,input().split()))
M = 10**9 + 1
def merge(A, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = A[left:left + n1]
    R = A[mid:mid + n2]
    L.append(M)
    R.append(M)
    i = 0
    j = 0
    for k in range(left,right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

count = 0
mergeSort(S,0,len(S))
print(*S)
print(count)

Measured memory_bytes: 63796
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int ans;
        int[] input = Console.ReadLine().Split().Select(i=>int.Parse(i)).ToArray();
        if (input[1]/input[0]>input[2])
        {
            ans = input[2];
        }
        else
        {
            ans = (input[1] / input[0]);
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }
}


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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector <long long> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  sort(h.begin(), h.end());
  for (int i = n-1; i >= n-k && i >= 0; i--)
    h[i] = 0;
  cout << accumulate(h.begin(), h.end(), 0L) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF 10000000
#define INF_LL 1e18
#define REP(i, n) for(int i = 0;i < (n);i++)
#define all(n) n.begin(),n.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

int main(void){
	int V, E, r;
	cin >> V >> E >> r;
	vector<PII> G[100000];
	ll d[100000];
	fill(d, d+100000, INF_LL);
	REP(i, E){
		int a, b, c;
		cin >> a >> b >> c;
		G[a].push_back(PII(c, b));
	}
	d[r] = 0;
	priority_queue<PII, vector<PII>, greater<PII> > que;
	que.push(PII(0, r));
	while(que.size()){
		PII p = que.top();que.pop();
		int v = p.second;
		if(p.first > d[v]) continue;
		REP(i, G[v].size()){
			if(G[v][i].first + d[v] < d[G[v][i].second]){
				d[G[v][i].second] = G[v][i].first + d[v];
				que.push(PII(d[G[v][i].second], G[v][i].second));
			}
		}
	}
	REP(i, V){
		if(d[i] == INF_LL){
			cout << "INF" << endl;
		}else{
			cout << d[i] << endl;
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);


void solve()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a+b < c+d){
        cout << "Right" << "\n";
    }
    else if(a+b > c+d){
        cout << "Left" << "\n";
    }
    else{
        cout << "Balanced" << "\n";
    }
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

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

    int N, M; cin >> N >> M;
    vi A(N); REP(i, N) cin >> A[i];
    vi B(M), C(M); REP(i, M) cin >> B[i] >> C[i];

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

    vector<pii> D;
    REP(i, M) D.push_back(pii(C[i], B[i]));
    sort(D.begin(), D.end());
    
    stack<pii> sc;
    REP(i, M) sc.push(D[i]);

    ll ans = 0;
    REP(i,N) {
        pii hi = pii(0, 0);
        if (sc.size()>0) {
            hi = sc.top(); sc.pop();
        }

        if (A[i] < hi.first) {
            ans += hi.first;
        } else {
            ans += A[i];
        }

        if (hi.second -1 >=1) {
            sc.push(pii(hi.first, hi.second - 1));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>
#define M 4
#define R 13

int main(void){
	
	int t[M][R], i, j, k, n;
	char m;
	for(i = 0; i < M; i++){
		for(j = 0; j < R; j++){
			t[i][j] = 0;
		}
	}
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf(" %c %d", &m, &k);
		if(m == 'S'){
			t[0][k - 1] = -1;
		}
		else if(m == 'H'){
			t[1][k - 1] = -1;
		}
		else if(m == 'C'){
			t[2][k - 1] = -1;
		}
		else if(m == 'D'){
			t[3][k - 1] = -1;
		}
	}

	for(i = 0; i < M; i++){
		for(j = 0; j < R; j++){
			if(t[i][j] == 0){
				if(i == 0){
					printf("S %d\n", j + 1);
				}
				else if(i == 1){
					printf("H %d\n", j + 1);
				}
				else if(i == 2){
					printf("C %d\n", j + 1);
				}
				else if(i == 3){
					printf("D %d\n", j + 1);
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 596
// AOJ 0606: Tower of JOIOI
// 2018.1.10 bal4u@uu

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

char s[1000005], *p;

int check(char *p, int m)
{
	int i, si, oi, soi, n;

	i = si = oi = soi = n = 0;
	while (*p) {
		if (*p == 'J') {
			if (soi > oi) { oi++; if (++n == m) return 1; }
		} else if (*p == 'O') {
			if (si > i && soi < m) soi++, i++;
		} else {						// *p == 'I'
			if (si < m) si++;
			else if (soi > oi) { oi++; if (++n == m) return 1; }
		}
		p--;
	}
	return 0;
}

int main()
{
	int n, i, oi, ans;
	int lo, hi, m;

	fgets(s+1, 10, stdin), n = atoi(s+1);
	fgets(s+1, 1000005, stdin);
	i = oi = ans = 0;
	p = s+n; while (*p) {
		if (*p == 'J') {
			if (oi) ans++, oi--;
		} else if (*p == 'O') {
			if (i) oi++, i--;
		} else i++;					// *p == 'I'
		p--;
	}
	if (oi > 0) {
		m = ans + (i + oi)/2;
		if (check(s+n, m)) ans = m;
		else {
			hi = ans + 1 + (i + oi)/2;
			i = 0; while (*++p) {
				if (*p == 'O') break;
				if (*p == 'I') i++;
			}
			lo = ans + i;
			while (lo + 1 < hi) {
				m = (lo + hi) >> 1;
				if (check(s+n, m)) lo = m; else hi = m;
			}
			ans = lo;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2812
N = int(input())
A = list(map(int,input().split()))
mult = 1
 
if 0 in A:
  mult = 0
  
for i in range(N):
  mult *= A[i]
  if mult > 1e18:
    print(-1)
    break

if mult <= 1e18:
  print(mult)

Measured memory_bytes: 21640
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
using pii=pair<int,int>;

#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rREP(i,a) for(int i=(a)-1;i>=0;i--)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define out(S) cout<<(S)<<endl;
#define beginend(v) (v).begin(),(v).end()
#define IfOut(condition,text) if(condition){out(text);return 0;}
#define IfOutElse(condition,if_text,else_text) if(condition){out(if_text);return 0;}else{out(else_text);return 0;}
#define mod(s) ((s)%(ll)(1e9+7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a*modpow((ll)b,(ll)(1e9+5))))
#define pb(i) push_back(i)
#define fst first
#define snd second
#define Foreach(item,collection) for(auto item:collection)
#define INF 1e10
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
ll sum(vi v) {ll sum=0;Foreach(i,v){sum+=i;}return sum;}
#define ShowAll(v) Foreach(i,v) out(i);


int main(){
    vi ans;
    int n,p;
    while (cin>>n>>p,!(!n&&!p))
    {
        int stones=p;
        vi members(n);
        int index=0;
        while (1)
        {
            if(stones>0){
                members[index]++;stones--;
                if(stones==0&&members[index]==p) break;
            }
            else{
                stones=members[index];members[index]=0;
            }
            index++;
            index%=n;
        }
        ans.pb(index);
    }    
    ShowAll(ans);
    return 0;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll N;

int main() {
    cin >> N;
    vector<int> A(N), B(N);
    REP(i, N) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(A.begin(), A.end());
    REP(i, N) {
        if (A[N / 2-1] >= B[i])cout << A[N / 2] << endl;
        else cout << A[N / 2 - 1] << endl;

    }
    return 0;
}


Measured memory_bytes: 3712
/**
 *  author: abhiy13
 *  created: 07.07.2019 17:26:32
**/
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(a * b, c) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll INF=1e18;
    
int main(){
  int n,r;
  cin>>n>>r;
  int ans;
  if(n>=10) {ans=r;}
  else{ ans=r+100*(10-n);}
  
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define inf    0x3f3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef vector<int>      vi;
typedef vector<bool>     vb;
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

 int main(){

  ll x,k,d;
  cin>>x>>k>>d;

  x = abs(x);

  if( x > 0 && (x/d) >= k)
  {
        ll y = (x/d);
      x = x - k*d;
      cout<<x<<endl;
     return 0;
  }
else {
   ll y = x/d;
  x = x - y*d;

  k -= y;

  if(k%2 == 0)
      cout<<abs(x)<<endl;
  else{
      ll ans = min(abs(x+d),abs(x-d) );
      cout<<ans<<endl;
  }

  }

return 0;
 }
 

Measured memory_bytes: 3636
function Main(input) {
  const rows = input.split('\n')
  const maxNum = parseInt(rows[0])
  const phrase = rows[1]
  const trimmedPhrase = phrase.length > maxNum ? phrase.slice(0, maxNum) + '...' : phrase
  
  console.log(trimmedPhrase)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main()
{
	fast;
	string s;
	cin >> s;
	
	int k;
	cin >> k;
	
	int id = -1;
	for(int i=0 ; i<s.length() ; i++)
	{
		if(s[i] != '1')
		{
			id = i;
			break;
		}
	}
	k--;
	if(id == -1 || k < id)
		cout << "1";
	else
		cout << s[id];
}



Measured memory_bytes: 256
#include <stdio.h>
int parent(int i){
        return i/2;
}
int left(int i){
        return 2*i;
}
int right(int i){
        return 2*i+1;
}
int main(){
        int n,i;
        scanf("%d",&n);
        int A[100000];
        for(i=1; i<=n; i++) {
                scanf("%d",&A[i]);
        }
        for(i=1; i<=n; i++) {

                printf("node %d: key = %d, ",i,A[i]);
                if(parent(i)>=1) {
                        printf("parent key = %d, ",A[parent(i)]);
                }
                if(left(i)<=n) {
                        printf("left key = %d, ",A[left(i)]);
                }
                if(right(i)<=n) {
                        printf("right key = %d, ",A[right(i)]);
                }

                printf("\n");
        }
        return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cctype>

using namespace std;
int main(){
	int n;
	int k;
	string s;

	// read values
	cin >> n;
	cin >> k;
	cin >> s;

	// some processing here
	transform(begin(s) + k - 1, begin(s) + k, begin(s) + k - 1, ::tolower);

	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string S;
            cin >> S;
                if(S.at(0) == 'a' && S.at(1) == 'b' && S.at(2) == 'c'){
                    cout << "Yes" << endl;
                }else if(S.at(0) == 'a' && S.at(1) == 'c' && S.at(2) == 'b'){
                    cout << "Yes" << endl;
                }else if(S.at(0) == 'b' && S.at(1) == 'a' && S.at(2) == 'c'){
                    cout << "Yes" << endl;
                }else if(S.at(0) == 'b' && S.at(1) == 'c' && S.at(2) == 'a'){
                    cout << "Yes" << endl;
                }else if(S.at(0) == 'c' && S.at(1) == 'a' && S.at(2) == 'b'){
                    cout << "Yes" << endl;
                }else if(S.at(0) == 'c' && S.at(1) == 'b' && S.at(2) == 'a'){
                    cout << "Yes" << endl;
                }else{
                    cout << "No" << endl;
                }
    return 0;}

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

int main(){
	int n, a, b, i, cost;
	cin >> n;
	int h[n][3] = {0};
	for(i = 0; i < n; i++){
		cin >> h[i][0];
	}

	for(i = 1; i < n; i++){
		h[i][1] = min(h[i-1][1], h[i-1][2]) + abs(h[i-1][0] - h[i][0]);
		if(i > 1)
			h[i][2] = min(h[i-2][1], h[i-2][2]) +
			 abs(h[i-2][0] - h[i][0]);
		else
			h[i][2] = INT_MAX;
	}

	cout<<min(h[n-1][1], h[n-1][2])<<"\n";
}

Measured memory_bytes: 1408
// Believe in yourself
#include<bits/stdc++.h>

using namespace std;

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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


void eea(ll a,ll b,ll &x,ll &y)
{
    if (a == 1)
    {
        x = 1; y = 0;
        return;
    }
    ll x1, y1;
    eea(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
}
ll mi(ll a,ll m)
{
    ll x,y;
    eea(a,m,x,y);
    x= (x%m+m)%m;
    return x;
}

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
       int n,c=0,p=0;
      cin>>n;
      string s;
      cin>>s;
      for(int i=0;i<n;i++)
      {
        if(s[i]=='R')
          c++;
      }
      for(int i=0;i<c;i++)
      {
        if(s[i]=='R')
        p++;
      }
      cout<<c-p<<"\n";
    }
}



Measured memory_bytes: 3732
//BISMILLAHIR RAHMANIR RAHIM


#include<bits/stdc++.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

#define ls ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define quit return 0

using namespace std;
int main()
{
    ls
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    string a,b;
    cin >> a >> b ;
    int m,c=0,n=a.size();
    for(m=0;m<n;m++){
        if(a[m]!=b[m])
            c++;
    }
    cout << c ;
    quit;

}

Measured memory_bytes: 3816
#include<stdio.h>

int main(){
    long long int n, m, k;
    scanf("%lld%lld%lld", &n, &m, &k);
    long long int a[200005], b[200005], i, j;
    for(i = 0; i < n; i++)
        scanf("%lld", &a[i+1]);
    
    for(i = 0; i < m; i++)
        scanf("%lld", &b[i+1]);
        
    
    a[0] = b[0] = 0;
    
    for(i = 0; i < n; i++)
        a[i+1] += a[i];
    
    for(i = 0; i < m; i++)
        b[i+1] += b[i];
    
    long long int ans = 0;
    j = m;
    for(i = 0; i <= n; i++){
       while(j >=0 && a[i] + b[j] > k)
           j--;
        if(j >= 0)
               if(ans < i + j)
                   ans = i + j; 
    }
    printf("%lld\n", ans);
    return 0;
}    


Measured memory_bytes: 4852
#include <iostream>
#include <algorithm>
#include <vector>

#define LL long long

using namespace std;

LL solve(LL t) {
	if (t % 4 == 0){
		return t;
	}
	if (t % 4 == 1) {
		return 1;
	}	if (t % 4 == 2) {
		return t + 1;
	
	}
	return 0;
}
int main()
{
	LL A, B ,ans; cin >> A >> B;
	ans = A > 0 ?  solve (B)^ solve(A-1) :solve(B);
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

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

int gcd(int a, int b) {
  int r = 1;
  while (r != 0) {
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}

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

  int n; cin >> n;
  int X; cin >> X;

  int ans;
  rep(i, n) {
    int x; cin >> x;
    x -= X;
    if (x < 0) {
      x = -x;
    }
    if (i == 0) {
      ans = x;
    } else {
      ans = gcd(ans, x);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> N;

    string S,T;
    
    cin >> S >> T;
    rep(si,S.size()){
        cout << S.substr(si,1);
        cout << T.substr(si,1);
    }

    

}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>

int main()
{
    int A, B, C;
    std::cin >> A >> B >> C;
    int K;
    std::cin >> K;

    int max = std::max({ A,B,C });
    int sum = A + B + C - max;
    for (int i = 0; i < K; i++)
    {
        max *= 2;
    }
    std::cout << sum + max << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < W + 1; i++) {cout << "#";}
  cout << "#" << endl;
  for (int i = 0; i < H; i++) {
    string a;
    cin >> a;
    cout << "#" << a << "#" << endl;
  }
  for (int i = 0; i < W + 1; i++) {cout << "#";}
  cout << "#" << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void){
	long int a,b,c,k;
    int i,sum=0;
    scanf("%ld%ld%ld%ld",&a,&b,&c,&k);
    if(k<=a){
        printf("%d",k);
        return 0;
    }else if(k<=a+b){
        printf("%d",a);
        return 0;
    }else{
        k=k-(a+b);
        for(i=0;i<k;i++){
            a--;
        }
        printf("%d",a);
        return 0;
    }
	return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    string S; cin >> S;

    if (S.size() % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    string a = S.substr(0, (S.size()/2));
    string b = S.substr((S.size()/2), S.size());
    if (a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    string s; cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i + 1]) {
            cout << "Bad\n";
            exit(0);
        }
    }
    cout << "Good\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << (abs(a-b) % 2 ? "Borys" : "Alice") << endl;
    return 0;
}


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

int main() {
  int N , K , x , sum = 0 ;
  cin >> N >> K ;
  for (int i=0 ; i<N ; i++){
    cin >> x ;
      if ( x <= K-x )
        sum += 2*x ;
      else
        sum += 2*(K-x) ;
    }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    int b = 0;
    int n = s.length();
    ll ans = 0;
    int sh = n-1;
    for (int i = n-1; i >= 0; --i) {
        if(s[i] == 'B'){
            ans += (sh-i);
            sh--;
        }
    }
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	int a[n];
	rep(i, n) cin >> a[i];
	int l = 0, r = 1000000001;
	while (r - l > 1) {
		int m = (l + r) / 2;
		int cnt = 0;
		rep(i, n) cnt += (a[i] + m - 1) / m - 1;
		if (cnt <= k)
			r = m;
		else
			l = m;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 4400
package main

import "fmt"

func main() {
	var X int
	const base = 400

	fmt.Scan(&X)

	for i := 0; i < 8; i++ {
		added := base + (i * 200)
		if added <= X && X < added+200 {
			fmt.Println(8 - i)
		}
	}
}


Measured memory_bytes: 1768
#include<iostream>

using namespace std;
typedef long long ll;

ll EuclideanAlgorithm(ll a,ll b)
{
    int k,m,n;
    if(a<b)
    {
        m=b;
        n=a;
    }
    else
    {
        m=a;
        n=b;
    }
    do
    {
        k=m%n;
        m=n;n=k;
    }
    while(k!=0);

    return m;
}

int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)/EuclideanAlgorithm(a,b)<<endl;

    return 0;
}


Measured memory_bytes: 256
import fractions

A,B,C,D=map(int,input().split())

sum1=(A-1)//C
sum2=B//C
sum3=sum2-sum1
sum1=(A-1)//D
sum2=B//D
sum4=sum2-sum1
num=(C*D)//fractions.gcd(C,D)
sum1=(A-1)//num
sum2=B//num
sum5=sum2-sum1
sum=sum3+sum4-sum5
sum=B-A+1-sum


print(sum)


Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
#define allsort(X) sort(X.begin(),X.end())

typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;





ll i,j,k;


int main(){
    ll N;
    cin>>N;
    V A(N);
    rep(i,N)cin>>A[i];
    

    sort(A.begin(),A.end());
    
    
    ll n=(A.size()-2)/2;
    ll amari=(A.size()-2)%2;

    ll ans=A.at(N-1);

    if(n>0)rep(i,n)ans+=2*A.at(N-2-i);
    if(amari)ans+=A.at(N-n-2);

    cout<<ans<<endl;
}

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

int main() {
  int64_t a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if (abs(a - b) <= t*(v - w)) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3580
#include<cstdio>
using ll = long long;

int main(){
	int N;
	scanf("%d", &N);
	ll X[3];
	for (int i = 0; i < 3; ++i) scanf("%lld", X + i);
	if(X[0] + X[1] + X[2] == 0){
		printf("No\n");
		return 0;
	}
	fflush(stdin);
	int instruction[N];
	for (int i = 0; i < N; ++i){
		char tmp[3];
		scanf("%s", tmp);
		if(tmp[0] == 'B' && tmp[1] == 'C') instruction[i] = 0;
		else if(tmp[0] == 'A' && tmp[1] == 'C') instruction[i] = 1;
		else instruction[i] = 2;
	}
	int ans[N];
	bool sum_is_two = X[0] + X[1] + X[2] == 2;
	for (int i = 0; i < N; ++i){
		for (int j = 0; j < 3; ++j){
			if(X[j] == 0 && X[(j+1)%3] == 0 && instruction[i] == (j+2)%3){
				printf("No\n");
				return 0;
			}
		}
		bool flag = false;
		if(sum_is_two){
			for (int j = 0; j < 3; ++j){
				if(X[j] == 1 && X[(j+1)%3] == 1 && instruction[i] == (j+2)%3){
					if(i == N - 1 || instruction[i+1] == j){
						flag = true;
						ans[i] = (j+1)%3;
						X[(j+1)%3]++;
						X[j]--;
					}else if(instruction[i+1] == (j+1)%3){
						flag = true;
						ans[i] = j;
						X[j]++;
						X[(j+1)%3]--;
					}
				}
			}
		}
		if(!flag){
			if(X[(instruction[i]+1)%3] > X[(instruction[i]+2)%3]){
				ans[i] = (instruction[i]+2)%3;
				X[(instruction[i]+2)%3]++;
				X[(instruction[i]+1)%3]--;
			}else{
				ans[i] = (instruction[i]+1)%3;
				X[(instruction[i]+1)%3]++;
				X[(instruction[i]+2)%3]--;
			}
		}
	}
	printf("Yes\n");
	for (int i = 0; i < N; ++i){
		printf("%c\n", 'A' + ans[i]);
	}
	return 0;
}

Measured memory_bytes: 2476
import itertools
n,k = map(int, input().split())
d = list(input().split())
d = [str(i) for i in range(10) if str(i) not in d]

ans = float("INF")
for v in itertools.product(d, repeat=len(str(n))):
  if v[0] != "0" and int("".join(v)) >= n:
    if ans > int("".join(v)): ans = int("".join(v))
if ans == float("INF"):
  for v in itertools.product(d, repeat=len(str(n))+1):
    if v[0] != "0" and int("".join(v)) >= n:
      if ans > int("".join(v)): ans = int("".join(v))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false); 
    string s;
    cin>>s;
    if(s.compare("ABC")==0)
        cout<<"ARC";
    else
    {
        cout<<"ABC";
    }
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


int main()
{
  ll n;
  cin >> n;
  vector<ll> p;
  for(ll i = 0;i < n;i++)
  {
    ll P;
    cin >> P;
    p.push_back(P);
  }
  ll count = 1;
  ll min = p[0];
  for(ll i = 1;i < n;i++)
  {
    if(min >= p[i])
    {
      count++;
      min = p[i];
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 2420
#include <stdio.h>
 
int main(void){
  int w, h, x, y, r, f = 1;
  scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);

  if(!(x - r >= 0)) f = 0;
  if(!(y - r >= 0)) f = 0;

  if(!(x + r <= w)) f = 0;
  if(!(y + r <= h)) f = 0;

  if(f) printf("Yes\n");
  else  printf("No\n");

  return 0;
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int h[N][3];
int dp[N][3];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>h[i][0]>>h[i][1]>>h[i][2];

    dp[n-1][0]=h[n-1][0];
    dp[n-1][1]=h[n-1][1];
    dp[n-1][2]=h[n-1][2];

    for(int i=n-2;i>=0;i--)   
        for(int j=0;j<3;j++) 
            for(int k=0;k<3;k++) 
                if(j^k)
                    dp[i][j]=max(dp[i+1][k]+h[i][j],dp[i][j]);
    cout<< *max_element(dp[0] , dp[0] + 3);
    
    return 0;
}

Measured memory_bytes: 2560
h,w,m = map(int,input().split())
t = [tuple(map(lambda x:int(x)-1,input().split())) for _ in range(m)] 
ht = [0]*h
wt = [0]*w
for y,x in t:
  ht[y] += 1
  wt[x] += 1
htm = max(ht)
wtm = max(wt)
htt = [i for i in range(h) if ht[i]==htm]
wtt = [i for i in range(w) if wt[i]==wtm]
ans = htm+wtm-1
t = set(t)
for i in htt:
  for j in wtt:
    if (i,j) not in t:
      print(htm+wtm)
      exit()
print(htm+wtm-1)

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

using namespace std;

int main(int argc, char *argv[]) {
        int N, K;
        cin >> N >> K;

        int cur;
        vector<int> arr;
        for (int i = 0; i < N; i++) {
                cin >> cur;
                arr.push_back(cur);
        }

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

		int ans = INT_MAX;
        for (int l = 0; l < N; l++) {
			int sub = arr[l + K - 1] - arr[l];
			if (sub <= ans) {
				ans = sub;
			}
			if (l + K == N) {
				break;
			}
        }

        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 892
A, B, C = map(int, input().split())
K = int(input())

ans = 0

import itertools
X = list(itertools.product(range(0,8), range(0,8), range(0,8)))
for i in X:
    if sum(i)<=K and B*(2**i[1])>A*(2**i[0]) and C*(2**i[2])>B*(2**i[1]):
        ans += 1


if ans >=1:
    print("Yes")
else:
    print("No")

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

int main() {
   int n,t,a;
   cin >> n >> t >> a;
   int ans; double dmin=1e9;
   rep(i,n){
      int h;  cin >> h;
      double d=abs(a-(t-h*0.006));
      if(d<dmin)
      ans=i+1, dmin=d;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
N,K = map(int,input().split())
def powmod(a, n):
	ans = 1
	while n > 0:
		if n % 2 == 0:
			a = (a * a) % MOD
		else:
			ans = (ans * a) % MOD
			a = (a * a) % MOD
		n = n // 2
	return ans

def fact(n):
	ans = 1
	for i in range(2, n+1):
		ans = (ans * i) % MOD
	return ans
def combination(n,k):
	bunbo = fact(n)
	bunshi = (fact(k) * fact(n-k)) % MOD
	return bunbo * powmod(bunshi, MOD-2)

print(N-K+1)
for i in range(2,K+1):
	ans = 0
	if N-K >= i-1:
		B = combination(K-1, i-1)
		ans = (ans + (combination(N-K+1, i) * B) % MOD) % MOD
	print(ans)

Measured memory_bytes: 3316
N,A,B = map(int, input().split())
S = input()

a = b = 0

for s in S:
    if s == 'a':
        if a + b < A + B:
            print('Yes')
            a += 1
            continue
    elif s == 'b':
        if a + b < A + B and b < B:
            print('Yes')
            b += 1
            continue
    print('No')


Measured memory_bytes: 53080
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
ll kai[202020];
ll gya[202020];
ll nck[202020];
//
ll pow(ll x,ll n,ll mod){
	ll res=1;
  	if(n>0){
		res=pow(x,n/2,mod);
    	if(n%2==0){
    		res=(res*res)%mod;
    	}else{
    		res=(((res*res)%mod)*x)%mod;
    	}
  	}
	return res;
}
//
ll inv(ll n,ll mod){
	return pow(n,mod-2,mod);
}
//
void nCk(ll N,ll mod){
    kai[N]=N;
    ROF(i,1,N){
		(kai[i]=kai[i+1]*i)%=mod;
    }
    gya[1]=inv(1,mod);
    FOR(i,2,N+1){
        (gya[i]=gya[i-1]*inv(i,mod))%=mod;
    }
    FOR(i,1,N){
        (nck[i]=kai[N+1-i]*gya[i])%=mod;
    }
    nck[0]=1;nck[N]=1;
}
//
ll a[202020],b[202020];
int main(){
	ll H,W,A,B;
	cin>>H>>W>>A>>B;
	nCk(H-A+B-1,mod);
	FOR(i,0,H-A){
		a[i]=nck[i];
	}
	nCk(W-B+A-1,mod);
	FOR(i,0,W-B){
		b[i]=nck[i];
	}
	//
	ll ans=0;
	ll aa=H-A-1,bb=W-B-1;
	while(aa>=0&&bb>=0){
		(ans+=(a[aa]*b[bb]%mod))%=mod;
		aa--;bb--;
	}
	cout<<ans<<endl;
	return 0;
}

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


void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c){
    int f[3] = { -1, -1, -1 };
    bool flag = false;
    for (int i = 0; i < M; i++) {
        int a = f[(3 - N) + s[i] - 1];
        if (a == -1 || a == c[i]) {
            f[(3 - N) + s[i] - 1] = c[i];
        } else {
            flag = true;
            break;
        }
    }

    if (N == 3 && f[0] == 0) flag = true;
    if (N == 3 && f[1] == 0 && f[0] == -1) flag = true;
    // if (N == 3 && f[2] == -1 && f[1] == -1 && f[0] == -1) flag = true;
    if (N == 2 && f[1] == 0) flag = true;
    // if (N == 2 && f[2] == -1 && f[1] == -1) flag = true;

    if (flag) {
        cout << -1 << endl;
        return;
    }

    bool top = true;
    for (int i = (3-N); i < 3; i++) {
        if (f[i] != -1) {
            top = false;
        } else {
            if (top && N != 1) {
                f[i] = 1;
                top = false;
            }
            else f[i] = 0;
        }
    }

    int result = 0;
    int b = 100;
    for (int i = 0; i < 3; i++) {
        if (f[i] == -1) f[i] = 0;
        result += f[i] * b;
        b /= 10;
    }

    cout << result << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


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

int main()
{
  int N;
  int* A;
  int i, j, k;
  int max=0, max2=0;

  scanf("%d", &N);

  A = (int *)malloc(N * sizeof(int));

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

  for(i=1; i<N; i++){
    if(max < A[i]){
      max = A[i];
      k=i;
    }
  }
  printf("%d\n", max);
  i=1;

  if(A[0] > max){
    printf("%d\n", A[0]);
    max = A[0];
    i=2;
  }

  for(; i<N; i++){
    if(i==k){
      for(j=0; j<N; j++){
        if(max2 < A[j] && j != k){
           max2 = A[j];
         }
      }
      printf("%d\n", max2);
    }else{
      printf("%d\n", max);
    }
  }


  free(A);

  return 0;

}

Measured memory_bytes: 2304