akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

bool cmp(int a,int b){
	return a>b;
}

int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1; i<=n; i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1,cmp);
	int s1=0,s2=0;
	for(int i=1; i<=n; i++){
		if(i%2==1){
			s1+=a[i];
		}else{
			s2+=a[i];
		}
	}
	cout<<s1-s2<<endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	n := scanInt()
	x := scanInt()

	l := make([]int, n+1)
	p := make([]int, n+1)
	l[0] = 1
	p[0] = 1

	for i := 0; i < n; i++ {
		l[i+1] = l[i]*2+3
		p[i+1] = p[i]*2+1
	}

	ans := 0

	for i := 0; i < n; i++ {
		if x == l[n-i] {
			ans += p[n-i]
			x = 0
			break
		}

		if x > l[n-i]/2 {
			ans += p[n-i-1]+1
			x -= l[n-i-1]+2
		} else {
			x--
		}
		// fmt.Println(x,l[n-i])
	}

	if x==1 {
		ans++
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
	int a, b;
	char x[2];

	while (1) {
		scanf("%d %s %d", &a, x, &b);

		if (x[0]=='?') {
			break;
		}
		else if (x[0] == '+') {
			printf("%d\n", a + b);
		}

		else if (x[0] == '-') {
			printf("%d\n", a - b);
		}

		else if (x[0] == '*') {
			printf("%d\n", a*b);
		}

		else if (x[0] == '/') {
			printf("%d\n", a / b);
		}
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

using ll = long long;

int N;
ll L;
int I = 1;

const int MX = 210000;
int nex[MX][2];
int dep[MX];
bool marked[MX];

int main(){
	nex[0][0] = nex[0][1] = -1;
	cin>>N>>L;
	rep(i,N){
		string s;
		cin>>s;
		int K = s.size();
		int v = 0;
		rep(i,K){
			int c = s[i]-'0';
			if(nex[v][c]==-1){
				nex[v][c] = I;
				nex[I][0] = nex[I][1] = -1;
				dep[I] = dep[v]+1;
				I++;
			}
			v = nex[v][c];
		}
		marked[v] = 1;
	}
	ll ans = 0;
	rep(v,I){
		if(marked[v]) continue;
		rep(t,2) if(nex[v][t]==-1){
			ll n = L-dep[v];
			ll p = 1;
			while(n%p==0) p*=2;
			p/=2;
			ans ^= p;
		}
	}
	if(ans) puts("Alice");
	else puts("Bob");
	// int g[100]={};
	// rep(d,100){
	// 	vector<bool> can(1000);
	// 	can[0]=1;
	// 	int s = 0;
	// 	rep(i,d){
	// 		s ^= g[d-1-i];
	// 		can[s] = 1;
	// 	}
	// 	rep(i,1000) if(!can[i]){
	// 		g[d] = i;
	// 		break;
	// 	}
	// }
	// rep(d,20){
	// 	printf("g[%2d] = %2d\n",d,g[d]);
	// }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }

    sort(A.begin(), A.end(), greater<int>());

    int sum=0;
    bool ok=false;
    rep(i, A.size())
    {
        sum+=A[i];
        if(sum>=H)
        {
            ok=true;
            break;
        }
    }

    if(ok)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

    int i = 0;

    while (4 * i <= n) {
        if ((n - 4 * i) % 7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        i++;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    
    if(k%2==1){
        ll a=0;
        rep(i,1,n+1){
            if(i%k==0) a++;
        }
        cout<<a*a*a<<endl;
    }
    else{
        ll a=0,b=0;
        rep(i,1,n+1){
            if(i%k==0) a++;
            else if(i%k==(k/2)) b++;
        }
        cout<<a*a*a+b*b*b<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	LL N, D;
	cin >> N >> D;
	vector<LL>d;
	for (int i = 0; i < N; ++i)
	{
		LL dd; cin >> dd; d.push_back(dd);
	}
	vector<LL>alice;
	alice.push_back(D);
	for (int i = 0; i < N; ++i)
	{
		alice.push_back(min(alice.back(), abs(alice.back() - d[i])));
	}
	bool tok = alice.back();
	vector<LL>wid;
	wid.push_back(1);
	for (int i = 0; i < N; ++i)
	{
		if (wid.back() * 2 > d[N - 1 - i])
		{
			wid.push_back(wid.back() + d[N - 1 - i]);
		}
		else
		{
			wid.push_back(wid.back());
		}
	}
	reverse(wid.begin(), wid.end());
	LL Q;
	cin >> Q;
	for (int j = 0; j < Q; ++j)
	{
		LL q;
		cin >> q;
		--q;
		if (tok)
		{
			cout << "YES\n";
			continue;
		}
		if (wid[q + 1] > alice[q])
		{
			cout << "NO\n";
		}
		else
		{
			cout << "YES\n";
		}
	}
	return 0;
}


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

int main(void)
{
  int N;

  scanf("%d",&N);

  int s[N];
  int i;

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

  int max = s[0];
  int min = s[0];

  for(i = 1;i < N;i++){
    if(max < s[i]){
      max = s[i];
    }
  }

  for(i = 1;i < N;i++){
    if(min > s[i]){
      min = s[i];
    }
  }

  printf("%d",abs(max - min));

  return 0;
}

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

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, K, x;
	int dist = 0;
	cin >> N >> K;
	rep(i, N) {
		cin >> x;
		if (x * 2 < abs(K - x) * 2)
			dist += x * 2;
		else
			dist += abs(K - x) * 2;
	}
	cout << dist << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string x;
    cin >> x;
    int ans = 1;
    int take = 1;
    for (int i = 1; i < x.size(); i++) {
        if (take == 1) {
            if (x[i] == x[i - 1]) {
                if (i == x.size() - 1) break;
                take = 2;
                i++;
            }
            else {
                take = 1;
            }
        }
        else {
            take = 1;
        }
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 720
#include<iostream>
using namespace std;
int main ()
{
    int n;
    cin>>n;
    for(int i=9;i>=1;i--)
    {
        if(n%i==0)
        {
            if(n/i<=9){
            cout<<"Yes"<<endl;
            return 0;}
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

use std::collections::*;

fn main() {
    let a = read_vec::<usize>();
    let n = a[0];
    let m = a[1];

    let mut v = vec![];
    for _ in 0..n {
        let u = read_vec::<usize>();
        if u[0] <= m {
            v.push((m-u[0], u[1] as u64));
        }
    }
    v.sort_by_key(|&(a,_)| a);
    //println!("v={:?}", v);

    let mut ans = 0;
    let mut que = BinaryHeap::new();
    for j in 0..m+1 {
        while let Some((a, b)) = v.pop() {
            if m-a > j {
                v.push((a, b));
                break;
            }
            que.push(b);
        }
        //println!("v={:?}, que={:?}", v, que);

        if let Some(b) = que.pop() {
            ans += b;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    ll N, X;
    cin >> N >> X;
    vector<ll> all(N + 1, 1), pty(N + 1, 1);
    FOR(i, 1, N + 1) {
        all[i] = 2 * all[i - 1] + 3;
        pty[i] = 2 * pty[i - 1] + 1;
    }

    auto dfs = [&](auto f, ll n, ll x) -> ll {
        if (n == 0) {
            return x <= 0 ? 0 : 1;
        } else if (x <= 1 + all[n - 1]) {
            return f(f, n - 1, x - 1);
        } else
            return pty[n - 1] + 1 + f(f, n - 1, x - 2 - all[n - 1]);
    };
    print(dfs(dfs, N, X));

    return 0;
}

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

const ll MOD = 1000000007;

ll fmemo[200002];
ll imemo[200002];
ll ifmemo[200002];

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

ll fact(ll n){
    if(n == 0) return 1;
    if(fmemo[n]) return fmemo[n];
    return fmemo[n] = n * fact(n - 1) % MOD;
}

ll ifact(ll n){
    if(n == 0) return 1;
    if(ifmemo[n]) return ifmemo[n];
    return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
}

ll com(ll n, ll k){
    if(k > n) return 0;
    if(k == n || k == 0) return 1;
    return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
}

int main()
{
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    for(ll i = 1; i <= 200001; i++){
        imemo[i] = modpow(i, MOD - 2);
    }
    ll diag = min(h - a, w - b);
    ll ans = 0;
    for(ll i = 0; i < diag; i++){
        ans = (ans + com(h - a + b - 1, b + i) * com(w - b + a - 1, a + i)) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6784
#include "bits/stdc++.h"

using namespace std;
using uint = unsigned int;
using int64 = long long;
using i64 = int64;
using uint64 = unsigned long long;
using vint = vector<int>;
using vint64 = vector<int64>;
template<typename T>
using p_que = priority_queue<T>;
#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rep1(i,N) for(int i=1;i<=(int)(N);++i)
#define fs first
#define sc second
#define eb emplace_back
#define all(x) x.begin(),x.end()

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}

template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U> p) {
	return os << "P(" << p.first << ", " << p.second << ")";
}

template<class T, class U> ostream& operator<<(ostream& os, const map<T, U>& mp) {
	os << "{";
	for (auto& e : mp) os << e << " ";
	return os << "}";
}

void Main();
signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
}

/* Cut from here! */

//#define int long long

int GCD(int a, int b) {
	return b ? GCD(b, a % b) : a;
}

using vec=vector<bool>;
using dvec=vector<vec>;

void Main() {
	int N; cin >> N;
	vector<int64> d(N);
	rep(i, N) cin >> d[i], d[i] /= 10;

	i64 now = d[0];
	for (int i = 1; i < N; ++i) {
		now--;
		if (now < 0) {
			cout << "no" << endl;
			return;
		}
		now = max(now, d[i]);
	}
	now = d[N - 1];
	for (int i = N - 1; i >= 0; --i) {
		now--;
		if (now < 0) {
			cout << "no" << endl;
			return;
		}
		now = max(now, d[i]);
	}

	cout << "yes" << endl;
}


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

const int MAX = 100000;

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i + 1;
}

int main() {
    ios::sync_with_stdio(false);
    int H, i, A[MAX+1];
    cin >> H;
    for(i=1; i<=H; i++) cin >> A[i];
    for(i=1; i<=H; i++){
      cout << "node " << i << ": key = " << A[i] << ", ";
      if(parent(i) >=1) cout << "parent key = " << A[parent(i)] << ", ";
      if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
      if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
      cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
class dice:
    def __init__(self, d, t, s):
        self.d = d
        self.t = t
        self.s = s
    def top(self):
        from collections import OrderedDict
        p = OrderedDict()
        for k, v in zip(["T", "N", "S", "E", "W", "B"], [self.d[0], self.d[4], self.d[1], self.d[2], self.d[3], self.d[5]]):
            p[k] = v
        import random
        while True:
            c = random.choice(["N", "S", "E", "W"])
            t, n, s, e, w, b = p["T"], p["N"], p["S"], p["E"], p["W"], p["B"]
            
            if t == self.t and s == self.s:
                print(e)
                break
            if c == "N":
                
                p["N"], p["T"], p["S"], p["B"]= t, s, b, n
            if c == "S":
                p["N"], p["T"], p["S"], p["B"]= b, n, t, s
            if c == "E":
                p["E"], p["T"], p["W"], p["B"]= t, w, b, e
            if c == "W":
                p["E"], p["T"], p["W"], p["B"]= b, e, t, w
        
        

d = list(map(int, input().split()))        
for i in range(int(input())):
    t, s = map(int, input().split())
    dice1 = dice(d, t, s)
    dice1.top()



Measured memory_bytes: 8212
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{

	int a, b, k;
	cin >> a >> b >> k;
	for (int i = 100; i >= 1; -- i)
	{
		if (a%i == 0 && b%i == 0)
		{
			k --;
			if (k == 0)
			{
				cout << i << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
import numpy as np

H, W = [int(x) for x in input().split()]
s = [list(input()) for i in range(H)]

M = np.array([[ (0 if s[i][j] == '.' else 1) for j in range(W) ] for i in range(H)])
INF = 10 ** 9
dp = np.array([[INF for j in range(W)] for i in range(H)])

for i in range(H - 1, -1, -1):
    for j in range(W - 1, -1, -1):
        ans_r = INF
        ans_d = INF
        if i == H - 1 and j == W - 1:
            dp[i][j] = M[i][j]
            continue
        if j < W - 1:  # 右に動ける
            if M[i][j] == 1 and M[i][j + 1] == 0:
                ans_r = dp[i][j + 1] + 1
            else:
                ans_r = dp[i][j + 1]
        if i < H - 1:  # 下に動ける
            if M[i][j] == 1 and M[i + 1][j] == 0:
                ans_d = dp[i + 1][j] + 1
            else:
                ans_d = dp[i + 1][j]
        dp[i][j] = min(ans_r, ans_d)

print(dp[0][0])


Measured memory_bytes: 12680
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,p = readInts()
    m = 0
    A = readInts()
    for i in range(n):
        a = A[i]
        if a % 2 == 1:
            m += 1
    if m == 0:
        print(2**n if p == 0 else 0)
    else:
        print(2**(n-1))
if __name__ == '__main__':
  main()


Measured memory_bytes: 6156
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<numeric>
#include<math.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll pre_a = a[0];
    bool up = false;
    bool dn = false;
    ll cnt = 1;
    for ( int i = 1; i < n; ++i ) {
        if ( a[i] > pre_a ) {
            up = true;
        }
        else if ( a[i] < pre_a ) {
            dn = true;
        }
        if ( up && dn ) {
            up = false;
            dn = false;
            ++cnt;
        }
        pre_a = a[i];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque

n,q = map(int,input().split())

S = deque([deque() for _ in range(n)])
for i in range(q):
    query = tuple(map(int,input().split()))

    if query[0] == 0:
        S[query[1]].append(query[2])
    elif query[0] == 1:
        if len(S[query[1]]) != 0:
            print(S[query[1]][-1])
    else:
        if len(S[query[1]]) != 0:
            S[query[1]].pop()


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

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int64_t> A(N);
  rep(i, N) cin >> A[i];
  int64_t answer = 1000;
  int buy_day = 0;
  int sell_day = 0;
  while (true) {
    while (A[buy_day] >= A[buy_day + 1]) ++buy_day;
    if (buy_day >= N - 1) break;

    sell_day = buy_day + 1;
    while (sell_day < N - 1) {
      if (A[sell_day] < A[sell_day + 1]) ++sell_day;
      break;
    }
    answer = (answer) / A[buy_day] * A[sell_day] + (answer) % A[buy_day];
    buy_day = sell_day;
  }
  cout << answer << endl;
  return 0;
}


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


int main() {
#ifndef ONLINE_JUDGE
	//freopen("inp.txt", "r", stdin);		freopen("outp.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);

	
	int k, n;	cin >> k >> n;
	vector <int> v(n);
	for (auto &i: v)	cin >> i;
	int final = 0;
	final = v[0] - v[n - 1] + k;
	for (int i = 1; i < n; i++) {
		final = max(final, v[i + 1] - v[i]);
	}
	cout << k - final << endl;


	return 0;
}

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

int main(){
	// sengen
	string s;
	// nyuryoku
	cin >> s;
	// keisan
	if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
		cout << "Yes";
	}else{
		cout << "No";
	}
}

Measured memory_bytes: 3628
from collections import deque
import sys


input = sys.stdin.readline
n, q = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n-1)]
p = [list(map(int, input().split())) for i in range(q)]

tree = [[] for i in range(n)]
for i in range(n-1):
    tree[info[i][0] - 1].append(info[i][1] - 1)
    tree[info[i][1] - 1].append(info[i][0] - 1)

memo = {}
for i in range(n):
    memo[i] = 0
for i in range(q):
    memo[p[i][0] - 1] += p[i][1]

dp = [0] * n
visited = [False]*n
q = deque([0])
visited[0] = True
dp[0] = memo[0]

while q:
    pos = q.popleft()
    for next_pos in tree[pos]:
        if visited[next_pos]:
            continue
        visited[next_pos] = True
        dp[next_pos] += dp[pos] + memo[next_pos]
        q.append(next_pos)
print(*dp)


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

int main(){
    
    int W, H;
    cin>>W>>H;
    
    int x, y, r;
    cin>>x>>y>>r;
    
    if(x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


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

int main(){

	//あられの個数
	int N;
	cin >> N;

	bool bYellowFound = false;
	char S;
	for(int i = 0; i < N; ++i){
		cin >> S;
		if('Y' == S){
			bYellowFound = true;
		}
	}

	if(bYellowFound){
		cout << "Four" << endl;
	}
	else{
		cout << "Three" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import math

a,b,h,m = map(int,input().split())

c = math.radians(30*h+m/2)
d = math.radians(6*m)

if c>=d:
  ans = math.sqrt(a**2+b**2-2*a*b*math.cos(c-d))
  print(ans)
elif c<d:
  ans = math.sqrt(a**2+b**2-2*a*b*math.cos(d-c))
  print(ans)

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

int main(){
    int d,n;
    cin>>d>>n;
    
    if(n==100)n++;

    if(d==0)cout<<n<<endl;

    if(d==1)cout<<100*n<<endl;

    if(d==2)cout<<10000*n<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    bool[] alp = new bool[](26);
    string s = readln.chomp;

    foreach (ch ; s) {
        alp[ch - 'a'] = 1;
    }

    foreach (i ; 0 .. 26) {
        if (!alp[i]) {
            writeln(('a' + i).to!char);
            return;
        }
    }

    writeln("None");
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 508
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


//verified AOJ GRL_3
#define MAX_V 100000
vector<int> G[MAX_V];   //???
vector<int> rG[MAX_V];  //??????
vector<string> str;

void add_edge(int from, int to){
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v, bool used[MAX_V], vector<int> &vs){     //????????????????????????????????????????????????????????????????????????vs?????\????????????
	used[v] = true;
	rep(i,G[v].size()){
		if(!used[G[v][i]])dfs(G[v][i],used,vs);
	}
	vs.push_back(v);
}

void rdfs(int v,int k,vector<int> &sccs, vector<int> &cmp, bool used[MAX_V]){   //??????????????£???????????????????????????????????????DFS
	used[v] = true;
	sccs.push_back(v);
	cmp[v] = k;
	rep(i,rG[v].size()){
		if(!used[rG[v][i]])rdfs(rG[v][i],k,sccs,cmp,used);
	}
}

int scc(int V, vector< vector<int> > &each_scc, vector<int> &cmp){
	vector<int> vs;
	bool used[MAX_V];
	rep(i,MAX_V)used[i] = false;
	vs.clear();
	rep(v,V){
		if(!used[v]) dfs(v, used, vs);
	}
	
	rep(i,MAX_V) used[i] = false;
	int k=0;
	for(int i=vs.size()-1;i>=0;i--){
		vector<int> sccs;
		if(!used[vs[i]]){
			rdfs(vs[i], k++, sccs, cmp, used);
			each_scc.push_back(sccs);
		}
	}
	return k;
}
/*
 add_edge(hoge,fuga);
 vector<vector<int>> each_scc;  //????????????????????£?????????????????????
 vector<int> cmp(MAX_V);        //???????????????????±??????????????????£??????????????????( ??????each_scc????????????????????? )
 int k = scc(v,each_scc,cmp);   //?????£?????????????????°
 */
int main(){
	int V,E;
	cin>>V>>E;
	rep(i,E){
		int s,t;
		cin>>s>>t;
		add_edge(s,t);
	}
 vector<vector<int>> each_scc;  //????????????????????£?????????????????????
 vector<int> cmp(MAX_V);        //???????????????????±??????????????????£??????????????????( ??????each_scc????????????????????? )
 int k = scc(V,each_scc,cmp);   //?????£?????????????????°

	int q;
	cin>>q;
	rep(i,q){
		int u,v;
		cin>>u>>v;
		cout<<(cmp[u]==cmp[v])<<endl;
	}
	
	
}

Measured memory_bytes: 9404
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;


int main(){
    int t=1;
    //cin>>t;
    while(t--){
        lli n;
        lli k;
        cin>>n>>k;
        lli p=n%k;
        if(abs(p-k)<p){
            cout<<abs(p-k);
        }
        else
            cout<<p;
    }
    return 0;
}
    

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

if sum(a) < x:
    print(n - 1)
elif sum(a) == x :
    print(n)
else:
    a.sort()
    cnt = 0
    for i in range(n):
        x -= a[i]
        if x < 0:
            print(cnt)
            quit()
        cnt += 1

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n+2);
    a[0]=0;
    for(int i = 0; i < n; i++) {
        cin >> a[i+1];
    }
    a[n+1]=0;

    int tl=0;
    for(int i = 0; i < n+1; i++) {
        tl+=abs(a[i+1]-a[i]);
    }

    int lend,leni;
    for(int i = 0; i < n; i++) {
        lend=abs(a[i+1]-a[i])+abs(a[i+2]-a[i+1]);
        leni=abs(a[i]-a[i+2]);
        cout << tl-lend+leni << "\n";
    }

    return 0;
}

Measured memory_bytes: 1664
n = int(input())
a = list(map(int, input().split()))

if a.count(0) > 0:
    print(0)
    exit()
ans = a[0]
for i in range(1, n):
    ans *= a[i]
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 21648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

std::vector<std::string> ans;

void rec(std::string str, char max_c, int n) {
	if (str.size() == n) {
		ans.push_back(str);
		return;
	}
	for (char c = 'a'; c <= max_c + 1; ++c) {
		str.push_back(c);
		rec(str, max_c + (c == max_c + 1), n);
		str.pop_back();
	}
}

int main(void) {
	int n;
	std::cin >> n;

	rec("a", 'a', n);

	for (int i = 0; i < ans.size(); ++i) std::cout << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 7356
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> A;
map<int, int> cnts;
int main()
{
    cin >> N;
    A.resize(N);
    for (auto &val : A)
    {
        cin >> val;
        cnts[val]++;
        // cout << cnts[val] << endl;
    }
    sort(A.rbegin(), A.rend());

    vector<ll> results;
    results.push_back(1);
    for (int i = 1; i < 40; i++)
    {
        results.push_back(2LL * results[i - 1]);
    }
    sort(results.rbegin(), results.rend());

    ll res = 0;
    for (int i = 0; i < N; i++)
    {
        if (cnts[A[i]] <= 0)
        {
            continue;
        }
        // cout << A[i] << " " << cnts[A[i]] << endl;
        for (int j = 0; j < results.size(); j++)
        {
            int value = results[j] - A[i];
            
            if (value <= 0)
            {
                continue;
            }
            if (value == A[i])
            {
                if (cnts[value] <= 1)
                {
                    continue;
                }
            }
            if (cnts[value] >= 1)
            {
                
                res++;
                cnts[value]--;
                cnts[A[i]]--;
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 39168
#include<stdio.h>
void swap(int*, int*);

int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a > b || a > c) {
		if (b > c) {
			swap(&a, &c);
		}
		else {
			swap(&a, &b);
		}
	}
	if (b > c) {
		swap(&b, &c);
	}
	printf("%d %d %d\n",a, b, c);
	return	0;
}

void swap(int *a, int *b) {
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

Measured memory_bytes: 1024
from math import floor
def main():
    a, b = map(int, input().split())
    r = -1
    for i in range(b * 10, (b + 1) * 10 + 1):
        if floor(i * 0.08) == a and floor(i * 0.1) == b:
            r = i
            break


    print(r)
main()

Measured memory_bytes: 3060
X = list(map(int, input().split()))
midle = sum(X)-min(X)-max(X)
dif_1 = max(X)-midle
new_min = min(X)+dif_1
dif_2 = max(X)-new_min
if dif_2%2 == 0:
    print(dif_1+dif_2//2)
else:
    print(dif_1+(dif_2//2)+2)

Measured memory_bytes: 38384
#include <stdio.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <algorithm>


int main()
{
    int n,w;
    long long value[110];
    long long weight[110];
    scanf("%d %d",&n,&w);

    int i,j,k;

    for(i=0;i<n;i++)
        scanf("%lld %lld", &weight[i], &value[i]);

    long long dp[n+10][w+10];

    memset(dp, 0, sizeof(dp));

    for(i=weight[0];i<=w;i++) {
        dp[1][i] = value[0];
    }

    for(i=2;i<=n;i++)
       for(j=0;j<=w;j++)
       {

           if(j-weight[i-1] >= 0)
               dp[i][j] = std::max(dp[i-1][j-weight[i-1]]+value[i-1], dp[i-1][j]);
           else dp[i][j] = dp[i-1][j];
       }

    long long max = LONG_LONG_MIN;

    for(i = 1; i<=w; i++)
    {
        if(dp[n][i] > max)
        max = dp[n][i];
    }
    printf("%lld \n", max);

    return 0;


}



Measured memory_bytes: 86144
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n, a, b;
  cin >> n >> a >> b;
  VI ps(n);
  FOR(p,ps) {
    cin >> p;
  }
  VI cs(3);
  FOR(p,ps) {
    if (p <= a) {
      cs[0]++;
    } else if (p <= b) {
      cs[1]++;
    } else {
      cs[2]++;
    }
  }
  cout << min(cs[0], min(cs[1], cs[2])) << endl;

  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
count = 0

loop{
    flg = 0
    for i in 1..n-1
        arr[i] > arr[i-1] && next
        if arr[i] < arr[i-1]
            arr[i],arr[i-1] = arr[i-1],arr[i]
            count += 1
            flg += 1
        end
    end
    flg == 0 && break
}

puts arr.join(" ")
puts count

Measured memory_bytes: 8740
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

int a[maxn];
signed main()
{
	int n,xorsum=0;
	fin>>n;
	for(rgi i=1;i<=n;++i) fin>>a[i],xorsum^=a[i];
	for(rgi i=1;i<=n;++i) fout<<(xorsum^a[i])<<' ';
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    string s, t;
    cin >> s >> t;
    priority_queue<string, vector<string>, greater<string>> pq;
    int n = s.size(), m = t.size();
    REP(i,n-m+1){
        string r = s;
        REP(j,n){
            if (r[j] == '?'){
                r[j] = 'a';
            }
        }
        REP(j, m)
        {
            if (s[i+j] != t[j] && s[i+j] != '?'){
                break;
            }else{
                r[i + j] = t[j];
            }
            if (j == m-1){
                pq.push(r);
            }
        }
    }
    if (pq.empty()){
        cout << "UNRESTORABLE" << endl;
    }else{
        cout << pq.top() << endl;
    }
}

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

string sed(const string& s, const string& pattern1, const string& pattern2) {
    string t = "";
    for (int j = 0, k = 0;; j = k + pattern1.size()) {
        k = s.find(pattern1, j);
        if (k == string::npos) {
            t += s.substr(j);
            break;
        }
        t += s.substr(j, k - j) + pattern2;
    }
    return t;
}

int solve(int n,
          const vector<string>& alpha, const vector<string>& beta,
          const string& gamma, const string& delta) {
    map<string, int> mem; mem[gamma] = 0;
    priority_queue<pair<int, string>> Q;
    for (Q.emplace(0, gamma); !Q.empty();) {
        int c; string s; tie(c, s) = Q.top(); Q.pop();
        if (s == delta) return -c;
        if (mem[s] != c) continue;
        rep(i, n) {
            string t = sed(s, alpha[i], beta[i]);
            if (t == s || t.size() > delta.size()) continue;
            if (!mem.count(t) || mem[t] < c - 1) Q.emplace(mem[t] = c - 1, t);
        }
    }
    return -1;
}

int main() {
    for (int n; cin >> n, n;) {
        vector<string> alpha(n), beta(n);
        rep(i, n) cin >> alpha[i] >> beta[i];
        string gamma, delta; cin >> gamma >> delta;
        cout << solve(n, alpha, beta, gamma, delta) << endl;
    }
}

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

// Example: dy[i%2][d] ( i is 0-indexed )
const int dx[2][6] = {{ 1,-1, 0, 0,-1,-1},{ 1,-1, 0, 0, 1, 1}};
const int dy[2][6] = {{ 0, 0, 1,-1,-1, 1},{ 0, 0, 1,-1,-1, 1}};

int W,H;
int field[110][110];
int done[110][110];

int ok(int x,int y){
	return x >= 0 && y < 110 && x < 110 && y >= 0;
}

int f(int x,int y){
	if(field[y][x]) return 1;
	if(done[y][x]) return 0;
	done[y][x] = true;
	int ans = 0;
	for(int i = 0 ; i < 6 ; i++){
		int tx = x+dx[(y+1)%2][i];
		int ty = y+dy[(y+1)%2][i];
		if(ok(tx,ty)) ans += f(tx,ty);
	}
	return ans;
}
int main(){
	cin >> W >> H;
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			cin >> field[i+2][j+2];
		}
	}
	cout << f(0,0) << endl;
	
}

Measured memory_bytes: 0
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

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;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int main(){
    
   
    ll n;
    cin >> n;
    ll a[n] = {};
    inrep(n,a);

    ll b[n];
    rep(i,0,n)b[i] = a[i];
    sort(b,b+n);

    rep(i,0,n){
	if(a[i] < b[n-1])P(b[n-1]);
	else P(b[n-2]);
    }
    
    return  0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int n, k, x, y, ans = 0;
    cin >> n >> k >> x >> y;
    if (n >= k) {
        ans += k * x;
        n -= k;
    }
    else {
        ans += x * n;
        n = 0;
    }
    ans += n * y;
    cout << ans << endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

int di[] = {2, 1, 0, -1, -2, 1, 0, -1, 0}, dj[] = {1, 1, 1, 1, 1, 2, 2, 2, 3};

main {
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    auto g = vectors(h, w, char());
    cin >> g;
    using state = tuple<int, int, int, int>;
    priority_queue<state, vector<state>, greater<state>> q;
    auto dist = vectors(h, w, 2, INF);
    rep(i, h) rep(j, w) {
      if (g[i][j] == 'S') {
        rep(k, 2) {
          dist[i][j][k] = 0;
          q.emplace(0, i, j, k);
        }
      }
    }
    int ans = INF;
    while (q.size()) {
      int d, i, j, k;
      tie(d, i, j, k) = q.top();
      q.pop();
      rep(t, 9) {
        int ni = i + di[t], nj = j + (k ? dj[t] : -dj[t]), nk = not k;
        if (ni < 0 || nj < 0 || ni >= h || nj >= w || g[ni][nj] == 'X') continue;
        int cost = dist[i][j][k] + (isdigit(g[ni][nj]) ? g[ni][nj] - '0' : 0);
        if (cmin(dist[ni][nj][nk], cost)) q.emplace(dist[ni][nj][nk], ni, nj, nk);
        if (g[ni][nj] == 'T') cmin(ans, cost);
      }
    }
    cout << (ans == INF ? -1 : ans) << endl;
  }
}



Measured memory_bytes: 3212
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()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
c = c[:k]
abc = sorted(i+j for i in ab for j in c)[:-k-1:-1]

print(*abc[:k], sep="\n")

Measured memory_bytes: 162236
S = input()

isAppeared = [False]*(26)

for s in S:
    for i in range(97, 97+26):
        if s == chr( i ): isAppeared[i-97] = True

def printLetter( isAppeared ):
    for i in range(26):
        if isAppeared[i] == False:
            print( chr(i+97) )
            return
    print( 'None' )

printLetter( isAppeared )


Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	a := ScanInt(scanner)
	b := ScanInt(scanner)
	c := ScanInt(scanner)
	
	if a + b < c {
	    fmt.Println("No")
	} else {
	    fmt.Println("Yes")
	}
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

#define pint pair<int,int>
//最終奥義
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n;cin >> n;
  vector<pair<int,int>> a(n);
  rep(i,n){
    cin >> a[i].first;
    a[i].second=i;
  }
  vint ans(n,0);

  sort(all(a),[](pint x, pint y) -> int {return x.first > y.first;});
  
  int e=a[0].second;
  int m = a[0].first;
  rep(i,n){
    if(i==e)continue;
    else ans[i]=m;
  }
  ans[e]=a[1].first;

  rep(i,n)
    cout << ans[i] << endl;
}


Measured memory_bytes: 3968