akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;

int main()
{

     int a , b , c ;
     cin >> a >> b >> c ;
     int maxi = max(a,max(b,c));
     int mini = min(a,min(b,c));
     int mini2 = a+b+c - ( maxi+mini);
     cout<<(maxi *10 + mini2 ) + mini<<endl;
     return 0 ;
 }

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

int main() {
    int N,M;cin >> N >> M;
    if (N == 1){
        int a;cin >> a;
        cout << "Yes" << endl;
    }
    else {
        int A[N] = {};
        int sum = 0;
        for (int i = 0; i < N; i++) {
            cin >> A[i];
            sum += A[i];
        }
        int L = (sum + (M * 4) - 1)/ (M * 4);
        int flag = 0;
        int count = 0;
        sort(A, A + N);
        for (int i = N - 1; i >= 0; i--) {
            if (A[i] >= L) count++;
            if (count == M) flag = 1;
        }
        if (flag == 1) {
            cout << "Yes" << endl;
        } else cout << "No" << endl;
    }
}


Measured memory_bytes: 256
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1

for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Measured memory_bytes: 7788
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        for(int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        Map<State, Long> before = new HashMap<>();
        before.put(new State(0, 0, 0), 1L);
        for(int k=0; k<N; k++) {
            Map<State, Long> after = new HashMap<>();
            for(State state : before.keySet()) {
                if(state.blue == A[k]) {
                    State nextState = new State(state.blue+1, state.red, state.green);
                    Long tmp = 0L;
                    if(after.containsKey(nextState)) {
                        tmp = after.get(nextState);
                    }
                    after.put(nextState, (tmp + before.get(state)) % 1000000007);
                }
                if(state.red == A[k]) {
                    State nextState = new State(state.blue, state.red+1, state.green);
                    Long tmp = 0L;
                    if(after.containsKey(nextState)) {
                        tmp = after.get(nextState);
                    }
                    after.put(nextState, (tmp + before.get(state)) % 1000000007);
                }
                if(state.green == A[k]) {
                    State nextState = new State(state.blue, state.red, state.green+1);
                    Long tmp = 0L;
                    if(after.containsKey(nextState)) {
                        tmp = after.get(nextState);
                    }
                    after.put(nextState, (tmp + before.get(state)) % 1000000007);
                }
            }
            before = after;
        }
        // calc result
        long result = 0L;
        for(State s : before.keySet()) {
            Long tmp = before.get(s);
            result = (result + tmp) % 1000000007;
        }
        System.out.println(String.format("%d", result));
    }

    static class State {
        int blue, red, green;
        State(int blue, int red, int green) {
            this.blue = blue;
            this.red = red;
            this.green = green;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            State state = (State) o;
            return blue == state.blue &&
                    red == state.red &&
                    green == state.green;
        }

        @Override
        public int hashCode() {

            return Objects.hash(blue, red, green);
        }
    }
}


Measured memory_bytes: 98232
//ABC 049-C
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	int i = 0, ans = 0;
	string Stone;
	
	cin >> Stone;
	for (int i = 1; i < Stone.size(); i++){
		if(Stone[i] != Stone[i-1]){
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
n = int(raw_input())
ws = []
for i in range(n):
    ws.append(raw_input())

status = True
known = []

for i, w in enumerate(ws):
    if w in known:
        status = False
        break
    if w == "":
        status = False
        break
    if i !=0 and known[-1][-1] != w[0]:
        status = False
        break
    known.append(w)

if status:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2696
N, M, K = map(int, input().split())

connected = [list(map(int, input().split())) for _ in range(M)]
blocked = [list(map(int, input().split())) for _ in range(K)]


class UnionFind(object):
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)


uf = UnionFind(N)
num_remove = [0] * N

for a, b in connected:
    uf.union(a - 1, b - 1)

for a, b in connected:
    if uf.same(a - 1, b - 1):
        num_remove[a - 1] += 1
        num_remove[b - 1] += 1

for c, d in blocked:
    if uf.same(c - 1, d - 1):
        num_remove[c - 1] += 1
        num_remove[d - 1] += 1


ret = []
for i in range(N):
    ret.append(str(uf.size(i) - num_remove[i] - 1))


print(' '.join(ret))


Measured memory_bytes: 64684
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h:usize = read();
    let w:usize = read();
    let mut grid = vec![vec![' '; w]; h];
    for i in 0..h {
        let s:String = read();
        grid[i] = s.chars().collect();
    }
    let dx = [1, -1i64, 0, 0];
    let dy = [0, 0, 1, -1i64];

    let mut ans = "Yes";

    'outer: for i in 0..h {
        for j in 0..w {
            if grid[i][j] == '.' {
                continue;
            }
            let mut c = false;
            for dir in 0..4 {
                let nx = (i as i64 + dx[dir]) as usize;
                let ny = (j as i64 + dy[dir]) as usize;
                if 0 <= nx && nx < h && 0 <= ny && ny < w {
                    if grid[nx][ny] == '#' {
                        c = true;
                        break;
                    }
                }
            }
            if !c {
                ans = "No";
                break 'outer;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2148
#include<iostream>
#include<map>
using namespace std;
int main()
{
    map<string,long long>m;
    string s,t,u;
    long long a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    m[s]=a;
    m[t]=b;
    m[u]--;
    cout<<m[s]<<" "<<m[t]<<endl;
    return 0;    
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int cc=s.length();
	for(int i=0;i<=cc/2;i++)
	{
		if(s[i]=='b'){if(s[cc-i-1]!='d'){cout<<"No";return 0;}}
		if(s[i]=='d'){if(s[cc-i-1]!='b'){cout<<"No";return 0;}}
		if(s[i]=='p'){if(s[cc-i-1]!='q'){cout<<"No";return 0;}}
		if(s[i]=='q'){if(s[cc-i-1]!='p'){cout<<"No";return 0;}}
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

#define INFTY 10000
#define black 2
#define gray 1
#define white 0
#define MAX 100

int n,A[MAX][MAX];

int prim()
{
  int i,v,u,min_v;
  int a[MAX],b[MAX],IRO[MAX];

  for(i=0;i<n;i++)
    {
      a[i] = INFTY;
      b[i] = -1;
      IRO[i] = white;
    }

  a[0] = 0;

  while(1)
    {
      min_v = INFTY;
      u = -1;
      for(i=0;i<n;i++)
	{
	  if(min_v > a[i] && IRO[i] != black)
	    {
	      u = i;
	      min_v = a[i];
	    }
	}
      if(u==-1) break;
      IRO[u] = black;
      for(v=0;v<n;v++)
	{
	  if(IRO[v] != black && A[u][v] != INFTY)
	    {
	      if(a[v]>A[u][v])
		{
		  a[v]=A[u][v];
		  b[v] = u;
		  IRO[v] = gray;
		}
	    }
	}
    }
  int sum =0;

  for(i=0;i<n;i++)
    {
      if(b[i] != -1) sum += A[i][b[i]];
    }

  return sum;
}

int main()
{
  int e,i,j;
  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  scanf("%d",&e);
	  A[i][j] = (e==-1) ? INFTY : e;
	}
    }
  printf("%d\n",prim());


  return 0;
}
  
      



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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    StringTokenizer st = new StringTokenizer(in.readLine());
    int D = Integer.parseInt(st.nextToken());
    int T = Integer.parseInt(st.nextToken());
    int S = Integer.parseInt(st.nextToken());

    System.out.println(solve(D, T, S));

    in.close();
  }

  private static String solve(int D, int T, int S) {
    if (T * S >= D) {
      return "Yes";
    }

    return "No";
  }
}

Measured memory_bytes: 32812
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e9;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    fast_io;
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a + b >= k) cout << min(a, k);
    else
    {
        k -= (a + b);
        cout << a - k;
    }
    return 0;
}

Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

const long long INF = 1LL<<60;

void solve() {
    int N, K; cin >> N >> K;
    vector<long long> plus, minus;
    plus.push_back(0); minus.push_back(0);
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        if (x >= 0) plus.push_back(x);
        else minus.push_back(-x);
    }

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

    long long ans = INF;

    for (int i = 0; i <= K; i++) {
        if (K-i >= minus.size() || i >= plus.size()) continue;
        long long tmp = min(plus[i]*2 + minus[K-i], plus[i] + minus[K-i]*2);
        ans = min(ans, tmp);
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 4468
package main

import (
	"fmt"
	"math"
)

func main()  {
	var num, total int

	fmt.Scan(&num, &total)

	// ダイスでトータルを超える確率
	clearRatio := float64(0.0)
	max := num
	if num >= total {
		clearRatio = 1 - float64(total) / float64(num)
		max = total
	}

	// トータルより下の
	// 数値で、連続して振ってクリアしなければならない数を出す
	z := float64(1) / float64(num)
	for i := 1; i <= max; i++ {
		cnt := 0
		x := i

		for x < total {
			x = x * 2
			cnt++
		}

		clearRatio += z * math.Pow(0.5, float64(cnt))
	}

	fmt.Println(clearRatio)
}


Measured memory_bytes: 512
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let S = rl().chars().collect::<Vec<_>>();
    let N = S.len();

    let mut ok = true;

    for i in 0..N {
        ok = ok && (i % 2 == 0 && S[i] != 'L' || i % 2 == 1 && S[i] != 'R');
        if !ok {
            break;
        }
    }

    println!("{}", if ok { "Yes" } else { "No" })
}


Measured memory_bytes: 4352
def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

def sieve(n):
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0,n) if s[i] and i > 1]

n = []
while True:
    tmp = int(input())
    if tmp == 0:
        break
    n.append(tmp)
m = max(n)
p = sieve(500000)

for i in range(len(n)):
    sum = 0
    if n[i] == 1:
        print(2)
    else:
        for j in range(n[i]):
            sum += p[j]
        print(sum)

Measured memory_bytes: 13172
#include <stdio.h>

int cnt[2];

int main(){

	int A,B,C;

	scanf("%d %d %d",&A,&B,&C);

	if(A==5){cnt[0]++;}
	if(A==7){cnt[1]++;}
	if(B==5){cnt[0]++;}
	if(B==7){cnt[1]++;}
	if(C==5){cnt[0]++;}
	if(C==7){cnt[1]++;}

	if(cnt[0]==2&&cnt[1]==1){printf("YES\n");}
	else{printf("NO\n");}

	return 0;
}

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

const int MAXN = 524289;
const int mod = 924844033;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int remod(LL x) { x %= mod; return x + (x >> 63 & mod); }

int wn[MAXN], wt[MAXN], rev[MAXN], lim, dig;
void init(int sz) {
	lim = 1, dig = -1;
	while (lim < sz) lim <<= 1, ++dig;
	for (int i = 0; i < lim; ++i) rev[i] = rev[i >> 1] >> 1 | (i & 1) << dig;
	const int W = pow(5, (mod - 1) / lim); *wn = 1;
	for (int i = 1; i <= lim; ++i) wn[i] = mul(wn[i - 1], W);
}
void NTT(int * A, int typ) {
	for (int i = 0; i < lim; ++i) if (i < rev[i]) std::swap(A[i], A[rev[i]]);
	for (int mid = 1; mid != lim; mid <<= 1) {
		const int Wn = lim / mid / 2;
		for (int i = 0, W = 0; i != mid; ++i, W += Wn)
			wt[i] = wn[typ == 1 ? W : lim - W];
		for (int k = 0; k != lim; k += mid << 1) {
			const int * W = wt;
			for (int l = 0; l != mid; ++l) {
				const int X = A[l + k], Y = mul(A[l + k + mid], *W++);
				reduce(A[l + k] = X + Y - mod);
				reduce(A[l + k + mid] = X - Y);
			}
		}
	}
	if (typ == -1) {
		const int liminv = pow(lim, mod - 2);
		for (int i = 0; i != lim; ++i) A[i] = mul(A[i], liminv);
	}
}

int A[MAXN], B[MAXN], n;
int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
void addedge(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
	nxt[++tot] = head[e]; to[head[e] = tot] = b;
}
int dfs(int u, int fa = 0) {
	int sz = 1;
	for (int i = head[u]; i; i = nxt[i])
		if (to[i] != fa)
			sz += dfs(to[i], u);
	if (fa) ++A[sz], ++A[n - sz];
	return sz;
}
int fac[MAXN], inv[MAXN];
int C(int a, int b) { return (LL) fac[a] * inv[b] % mod * inv[a - b] % mod; }
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i != MAXN; ++i) {
		fac[i] = mul(fac[i - 1], i);
		inv[i] = mul(inv[mod % i], mod - mod / i);
	}
	for (int i = 2; i != MAXN; ++i) inv[i] = mul(inv[i - 1], inv[i]);
	std::cin >> n;
	for (int i = 1, t1, t2; i < n; ++i)
		std::cin >> t1 >> t2, addedge(t1, t2);
	dfs(1);
	for (int i = 0; i <= n; ++i)
		B[i] = inv[n - i], A[i] = mul(A[i], fac[i]);
	init(n * 2 + 1);
	NTT(A, 1); NTT(B, 1);
	for (int i = 0; i != lim; ++i) A[i] = mul(A[i], B[i]);
	NTT(A, -1);
	for (int i = 1; i <= n; ++i) {
		int t = 0;
		reduce(t -= mul(A[i + n], inv[i]));
		reduce(t += mul(C(n, i), n) - mod);
		std::cout << t << '\n';
	}
	return 0;
}


Measured memory_bytes: 30592
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ANextAlphabet {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      char c; cin >> c;
      cout << (char)(c+1) << endl;

    }
};

signed main() {
  ANextAlphabet solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll INF = 1e13;

struct SegmentTree {
    int n;
    vector<ll> data;

    //使うときは、この3つを適宜変更する
    static ll INITIAL_VALUE;
    static ll merge(ll x, ll y); 
    void updateNode(int k, ll x);

    SegmentTree(int size) {
        n = 1;
        while (n < size) n *= 2;
        data.resize(2 * n - 1, INITIAL_VALUE);
    }

    ll getLeaf(int k) {
        return data[k + n - 1];
    }
    
    void update(int k, ll x) {
        k += n - 1; //葉の節点
        updateNode(k, x);
        while (k > 0) {
            k = (k - 1) / 2;
            data[k] = merge(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }
    
    //区間[a, b)に対するクエリに答える
    //k:節点番号, [l, r):節点に対応する区間
    ll query(int a, int b, int k, int l, int r) {
        //[a, b)と[l, r)が交差しない場合
        if (r <= a || b <= l) return INITIAL_VALUE;
        //[a, b)が[l, r)を含む場合、節点の値
        if (a <= l && r <= b) return data[k];
        else {
            //二つの子をマージ
            ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return merge(vl, vr);
        }
    }
    
    //外から呼ぶ用
    ll query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
};

//使うときは以下3つを変更
ll SegmentTree::INITIAL_VALUE = INF;

ll SegmentTree::merge(ll x, ll y) {
    return min(x, y);
}

void SegmentTree::updateNode(int k, ll x) {
    data[k] = x;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	ll a;
	cin >> n >> q >> a;
	a--;
	vector<ll> x(q + 1);
	cin >> x[0];
	x[0]--;
	for (int i = 1; i <= q; i++) {
		cin >> x[i];
		x[i]--;
	}

	SegmentTree st1(n), st2(n);

	st1.update(a, -a);
	st2.update(a, a);

	ll add = 0;
	for (int i = 1; i <= q; i++) {
		ll tmp = INF;
		tmp = min(tmp, st1.query(0, x[i]) + x[i]);
		tmp = min(tmp, st2.query(x[i], n) - x[i]);
		tmp += add;
		add += abs(x[i] - x[i - 1]);
		ll tar = st1.getLeaf(x[i - 1]) + x[i - 1] + add;
		if (tar <= tmp) continue;
		tmp -= add;
		st1.update(x[i - 1], tmp - x[i - 1]);
		st2.update(x[i - 1], tmp + x[i - 1]);
	}

	ll ans = INF;
	for (int i = 0; i < n; i++) {
		ans = min(ans, st1.getLeaf(i) + i);
	}
	ans += add;
	cout << ans << endl;

	return 0;
} 

Measured memory_bytes: 9984
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	x = int(input())
	rm = x%11
	print(2*math.floor(x/11)+math.ceil(rm/6))

main()

Measured memory_bytes: 67180
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int n; cin >> n;
  double x; string u;
  double sum = 0;
  REP(i, n){
    cin >> x >> u;
    if (u == "JPY") sum += x;
    else sum += x * 380000.0;
  }
  cout << sum << endl;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  string ans = "No";
  if((a==b &&b!=c) || (b==c && c!=a) || (c==a && a!=b)) ans ="Yes";
  cout << ans << endl;
}

Measured memory_bytes: 384
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final int N, K, X, Y;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        K = sc.nextInt();
        X = sc.nextInt();
        Y = sc.nextInt();
    }

    void solve(PrintWriter out) {
        out.println(Math.min(N, K) * X + Math.max((N - K) * Y, 0));
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

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

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

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

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

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

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

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

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


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string a[3];
	for(int i=0;i<3;i++)
	{
		cin >> a[i];
	}
	int j=0,ans=0;
	while(true)
	{
		if(a[j].size()==0)
		{
			ans=j+1;
			break;
		}
		char c = a[j][0];
		a[j].erase(a[j].begin());
		if(c=='a') j=0;
		else if(c=='b') j=1;
		else if(c=='c') j=2;
	}
	if(ans==1) cout << "A";
	if(ans==2) cout << "B";
	if(ans==3) cout << "C";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        boolean flag = false;
        String[] strArray = N.split("");
        int[] array = Arrays.asList(strArray).stream().mapToInt(Integer::parseInt).toArray();
        int sum = java.util.Arrays.stream(array).sum();

        if(sum % 9 == 0 || sum == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAX 100001

ll conv(string num) { stringstream ss; ss << num << flush; ll n; ss>>n; return n; }

string conv(ll n) { stringstream ss; ss << n << flush; return ss.str(); }

vector<string> split(string s, string delim) {
    vector<string> res;
    int pos = 0;
    while(true) {
        int found = s.find(delim, pos);
        if(found >= 0) {
            res.push_back(s.substr(pos, found - pos));
        }
        else {
            res.push_back(s.substr(pos));
            break;
        }
        pos = found + delim.size();
    }
    return res;
}
int ALPH_SIZE = 26;
char ALPH_L[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char ALPH_U[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};


int main() {
    int N, M;

    vector <pair <ll,ll> > AB;

   

    cin >> N >> M;
    ll A, B;

    for(int i=0; i<N; i++) {
        cin >> A >> B;
        AB.push_back(make_pair(A, B));
    }

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

    ll ans = 0;
    for(int i=0; i<N; i++) {
        if (M >= AB[i].second) {
            ans += AB[i].first * AB[i].second;
            M -= AB[i].second;
        } else if (M < AB[i].second) {
            ans += AB[i].first * M;
            break;
        }

    }

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


Measured memory_bytes: 2420
import sys

n = input()
a_uni = [[[0 for i in range(10)]for i in range(3)]for i in range(4)]
for i in range(n):
	b,f,r,v = map(int,raw_input().split())
	a_uni[b-1][f-1][r-1] += v
for i in range(4):
	for j in range(3):
		for k in range(10):
			if k==9:
				sys.stdout.write(' ')
				print(a_uni[i][j][k])
			else :
				sys.stdout.write(' ')
				sys.stdout.write(str(a_uni[i][j][k]))
	if not i==3:
		print '####################'

Measured memory_bytes: 6440
N = int(input())
a = input().split()
a = [int(s) for s in a]
a.sort()
a.reverse()

alice = 0
bob = 0

for i in range(0, N):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]

print(alice - bob)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    int ans=INF;
    string S;
    cin >> S;

    int size=S.size();

    REP(i,size-1){
        string n;
        n += S[i];
        n += S[i+1];
        n += S[i+2];
        int m = stoi(n);
        ans = min(ans,abs(m-753));
    }

    cout << ans << endl;
}

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

int gcd(int A,int B){
    if(B == 0)return A;
    return gcd(B,A%B);
}

int main(){
 int W,H,C;
 cin>>W>>H>>C;
 cout<<(W/gcd(W,H))*(H/gcd(W,H))*C<<endl;
}


Measured memory_bytes: 3092
object Main extends App {
	val N = scala.io.StdIn.readInt
	var A = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	var test = List[Long]()
	var test1 = List[Long]()
	val a: Int = N%2
	val b: Int = (N+1)%2

	for(i<-b until N by 2){
		test = A(i)::test
	}

	for(i<-a until N by 2){
		test1 = A(i)::test1
	}

	println(test.mkString(" ") +" " + test1.reverse.mkString(" "))

}



Measured memory_bytes: 96020
#include <bits/stdc++.h>
#define mod 9929
#define inf 1e18
#define endl '\n'
#define eps 1e-9
#define zeros(x) ((x)&(-x))
#define nmax 100000

using namespace std;

typedef long long ll;
typedef long double ld;

string s;
ll n;

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    cin>>s;
    for (char &i : s)
    {
        char c = i - 'A';
        c = (c + n) % 26;
        i = c + 'A';
    }
    cout<<s;
    return 0;
}



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

using namespace std;

int main() {
  int X;
  cin >> X;
  int result = 0;
  if (100 <= X) {
    vector<bool> b(X + 6, false);
    b[0] = true;
    for (int i = 0; i <= X - 100; ++i) {
      if (b[i]) {
        b[i + 100] = b[i + 101] = b[i + 102] =
          b[i + 103] = b[i + 104] = b[i + 105] = true;
      }
    }
    result = b[X];
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ll long long
#define ull unsigned long long
#define ii pair<ll, ll>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls signed
#define give main()
const int mod = 1000000007;
#pragma endregion

const int N = 200005;

int k, n, a, total, ans = INT_MAX;
deque<int> arr;
vector<int> diff;
 
pls give {
    AC;
    cin >> k >> n;
    for (int i=0; i<n; i++) {
        cin >> a;
        arr.pb(a);
    }
    qsort(arr);
    for (int i=0; i<arr.size()-1; i++) {
        diff.pb(arr[i+1] - arr[i]);
        total += (arr[i+1] - arr[i]);
    }
    diff.pb((k - arr[n-1]) + (arr[0]));
    total += diff.back();
    for (int i=0; i<diff.size(); i++) {
        ans = min(ans, total-diff[i]);
    }
    cout << ans << nl;
}

Measured memory_bytes: 4088
n = int(input())
d = [None]*n
for i in range(n):
    s,t = map(str,input().split())
    d[i] = [s,t]
x = input()

for i in range(n):
    if d[i][0]==x:
        num = i
        break

ans = 0
for i in d[(num+1):]:
    ans += int(i[1])
print(ans)

Measured memory_bytes: 3064
function Main(input) {
	var a = input.charAt(0);
	var r = 0;
	for(var i = 1; i < 4; i++) {
		if(a == input.charAt(i)){
			r = 1;
		}
		a = input.charAt(i);
	}
	if(r == 1){
		console.log("Bad");
	}else{
		console.log("Good");
	}
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21956
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    ss = ""
    for i in range(len(s)):
        if ss == "" and s[i] == "C":
            ss = s[i]
        elif ss == "C" and s[i] == "F":
            print("Yes")
            exit()
    print("No")


if __name__ == '__main__':
    slove()


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

int main()
{
    int n, m;
    std::cin >> n >> m;

    std::vector<bool> is_ok(n + 1, true);
    for (int i = 0; i < m; i++) {
        int temp;
        std::cin >> temp;
        is_ok[temp] = false;
    }

    std::vector<long long> dp(n + 1, 0);
    dp[0] = 1;
    if (is_ok[1]) {
        dp[1] = 1;
    }

    for (int i = 2; i <= n; i++) {
        if (is_ok[i]) {
            const int mod = 1000000007;
            dp[i] = dp[i - 1] + dp[i - 2];
            dp[i] %= mod;
        }
    }

    std::cout << dp[n] << std::endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
//#include <cassert>
//#include <stack>
//#include <queue>
//#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2000;
const int oo = 1e9 + 5;

int n, m, k, cnt[20][N], ans = oo;
char a[20][N]; 

int SumCnt(int x1, int y1, int x2, int y2) {
	return cnt[x2][y2] - cnt[x2][y1 - 1] - cnt[x1 - 1][y2] + cnt[x1 - 1][y1 - 1];
}

void solve() {
	cin >> n >> m >> k;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			cin >> a[i][j];
			cnt[i][j] = cnt[i][j - 1] + cnt[i - 1][j] - cnt[i - 1][j - 1];
			if(a[i][j] == '1') {
				++cnt[i][j];
			}
		}
	}
	for (int mask = 0; mask < (1 << (n-1)); ++mask) {
		/**int cur = 0, preX = 0;
		bool ok = 1;
		for (int i = 1; i < n; ++i) {
			if ((mask >> (i-1)) & 1) {
				++cur;
				int preY = 0;
				for (int j = 2; j <= m; ++j) {
					if (SumCnt(preX+1, preY+1, i, j) > k) {
						++cur;
						preY = j-1;
					}
				}
				preX = i;
			}
		}
		int preY = 0;
		for (int j = 2; j <= m; ++j) {
			if (SumCnt(preX+1, preY+1, n, j) > k) {
				++cur;
				preY = j-1;
			}
		}**/
		int preY = 0, cur = __builtin_popcount(mask);
		bool ok = 1;
		for (int j = 1; j <= m; ++j) {
			int preX = 0;
			for (int i = 1; i <= n; ++i) {
				if (((mask >> (i-1)) & 1) || i == n) {
					if (SumCnt(preX+1, j, i, j) > k) {
						ok = 0;
						break;
					}
					if (SumCnt(preX+1, preY+1, i, j) > k) {
						preY = j-1;
						++cur;
						break;
					}
					preX = i;
				}
			}
			if (!ok) break;
		}
		if (ok) ans = min(ans, cur);
	}
	cout << ans;
}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	“I’m not gonna run away, I never go back on my word! That’s my nindo: my ninja way.” Naruto
ц*/

Measured memory_bytes: 384
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 32
#define MAX 100000
typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int N, t[MAXN][MAXN];
int dp[MAX]; // dp[state]は今のstateからゴールするための最小時間

int dfs(int state) {
    if (state == (1 << N) - 1) return 0;
    if (dp[state] >= 0) return dp[state];
    int ret = INF;
    for (int i = 1; i <= N; i++) {
        if ((state >> (i-1)) & 1) continue; // もうクリアしてる
        int time = t[i][0];
        for (int j = 1; j <= N; j++) {
            if ((state >> (j-1)) & 1) {
                time = min(time, t[i][j]);
            }
        }
        int st = state | (1 << (i-1));
        ret = min(ret, time + dfs(st));
    }
    return dp[state] = ret;
}

int main(void) {
    while (1) {
        cin >> N;
        if (N == 0) break;
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= N; j++) {
                cin >> t[i][j];
            }
        }
        for (int i = 0; i < (1 << N); i++) dp[i] = -1;
        cout << dfs(0) << endl;
    }
    return 0;
}

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

using namespace std;

int M, N, a[200009], b[200009], c[200009], dp[200009][2];
bool isRoot[200009], can[200009];
vector < int > v[200009];
map < int, int > mp;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &M);
for (int i=1; i<=M; i++)
    scanf ("%d", &a[i]);
sort (a + 1, a + M + 1);
for (int i=1; i<=M; i++)
{
    int j = i;
    while (a[j + 1] == a[i] && j < M)
        j ++;
    b[++N] = a[i], c[N] = j - i + 1;
    mp[b[N]] = N, i = j;
}
for (int i=1; i<=N; i++)
{
    int p2 = 1;
    while (p2 <= b[i])
        p2 += p2;
    if (b[i] + b[i] == p2) can[i] = 1, isRoot[i] = 1;
    else
    if (mp.count (p2 - b[i]))
        v[mp[p2 - b[i]]].push_back (i);
    else
        isRoot[i] = 1;
}
int ans = 0;
for (int i=N; i>=1; i--)
{
    dp[i][1] = c[i], dp[i][0] = 0;
    for (auto j : v[i])
        dp[i][0] += dp[j][1],
        dp[i][1] += min (dp[j][0], dp[j][1]);
    if (isRoot[i])
    {
        if (!can[i])
            ans += min (dp[i][0], dp[i][1]);
        else
        if (dp[i][1] < dp[i][0])
            ans += dp[i][1];
        else
        {
            int maxK = min (c[i] / 2, (dp[i][1] - dp[i][0]) / 2);
            ans += dp[i][0] + maxK;
        }
    }
}
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 21248
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long double a, b, c;
  cin >> a >> b >> c;

  if (a + b + 2 * sqrt(a) * sqrt(b) < c ){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }   
 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

static const int MAX = 1e9;
int n, m, a, b, c, ida, idc, cnt;
pair<int, int> bc;
vector<int> A;
vector<pair<int, int> > BC;
long ans;

int main() {
    scanf("%d %d", &n, &m);
    
    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &a);
        A.push_back(a);
    }

    for ( int j = 0; j < m; j++ ) {
        scanf("%d %d", &b, &c);
        bc.first = b;
        bc.second = c;
        BC.push_back(bc);
    }

    sort(A.begin(), A.end(), [](const int& x, const int& y) { return x > y;});
    sort(BC.begin(), BC.end(), [](const pair<int, int>& x, const pair<int, int>& y) { return x.second > y.second;});

    ida = 0;
    idc = 0;
    cnt = 0;

    while ( true ) {
        if ( cnt == n ) {
            break;
        }

        if ( A[ida] > BC[idc].second ) {
            ans += A[ida];
            ida++;
        } else {
            ans += BC[idc].second;
            BC[idc].first--;

            if ( BC[idc].first == 0 ) {
                idc++;
            }
        }

        cnt++;
    }

    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 1784
#include<iostream>
using namespace std;
int main(){
string a,b; cin >> a >> b;
  a = string(max(0,(int)b.size()-(int)a.size()),'0') + a;
  b = string(max(0,(int)a.size()-(int)b.size()),'0') + b;
  if(a == b)cout << "EQUAL" << endl;
  if(a > b)cout << "GREATER" << endl;
  if(a < b)cout << "LESS" << endl;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  int X, t;
  cin >> X >> t;
  cout << max(X - t, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false) ;
#define endl '\n'
#define ll long long
using namespace std ;

int main() {
    char chr ;
    cin >> chr ;
    int num = int(chr) ;
    if(num>=97 && num<=122) cout << 'a' << endl ;
    else cout << 'A' << endl ;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main() {
    int n;
    cin>>n;
    pair<int,int> a[n];
    rep(i,n){
        cin>>a[i].first;
        a[i].second=i+1;
    }
    sort(a,a+n);
    rep(i,n){
        cout<<a[i].second;
        if(i!=n-1){
            cout<<" ";
        }
        else{
            cout<<endl;
        }
    }
}


Measured memory_bytes: 2432
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    var sc = new Scanner(System.in);
    var s = sc.next();
    if (s.endsWith("s")) {
      System.out.println(s + "es");
    } else {
      System.out.println(s + "s");
    }
  }
}

Measured memory_bytes: 38488
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    s = input()
    op = ["+","+","+"]
    for i in range(1 << 3):
        for j in range(3):
            if i >> j & 1:
                op[j] = "-"
        tmp = s[0]+op[0]+s[1]+op[1]+s[2]+op[2]+s[3]
        if eval(tmp) == 7:
            print(tmp+"=7")
            exit()
        op = ["+","+","+"]
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 20364
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

MOD = 10 ** 4 + 7

N = int(input())

A = [0] * N
for i in range(N):
    A[i] = int(input())

from collections import deque
d = deque([])
for a in A:
    l = -1
    r = len(d)
    while r - l > 1:
        m = l + (r - l) // 2
        if d[m] >= a:
            r = m
        else:
            l = m
    if r == 0:
        d.appendleft(a)
    else:
        d[r - 1] = a
print(len(d))

Measured memory_bytes: 13664