akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fr(i,j) for(int i=beg[j];i;i=nxt[i])
using namespace std;
int const mn=2*1e3+3,mo=1e9+7;
int n,K,tmp,u[mn],v[mn],gra,beg[mn],to[mn*2],nxt[mn*2];
void insert(int u,int v){
    to[++gra]=v;
    nxt[gra]=beg[u];
    beg[u]=gra;
}
void dfs(int p,int q,int dep){
    tmp++;
    if(!dep)return;
    fr(i,p)if(to[i]!=q)
        dfs(to[i],p,dep-1);
}
int main(){
    scanf("%d%d",&n,&K);
    fo(i,1,n-1){
        scanf("%d%d",&u[i],&v[i]);
        insert(u[i],v[i]);
        insert(v[i],u[i]);
    }
    int ans=0;
    if(K&1){
        fo(i,1,n-1){
            tmp=0;
            dfs(u[i],v[i],K/2);
            dfs(v[i],u[i],K/2);
            ans=max(ans,tmp);
        }
    }else{
        fo(i,1,n){
            tmp=0;
            dfs(i,0,K/2);
            ans=max(ans,tmp);
        }
    }
    printf("%d",n-ans);
    return 0;
}

Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse = True)

alice =[]
bob = []

for i in range(len(a)):
    if i%2==0:
        alice.append(a[i])
    elif i%2 != 0:
        bob.append(a[i])
dif = sum(alice) - sum(bob)
print(dif)
    

Measured memory_bytes: 9188
s=input()
s=s.split('eraser')
if s.count('')>0:
  s.remove('')
s=''.join(s)
s=s.split('erase')
if s.count('')>0:
  s.remove('')
s=''.join(s)
s=s.split('dreamer')
if s.count('')>0:
  s.remove('')
s=''.join(s)
s=s.split('dream')
if s.count('')>0:
  s.remove('')
s=''.join(s)
if s=='':
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define endl "\n"
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
typedef long long int ll;
const int INF = 1e9;
 
using namespace std;
 
void solve()
{
  ll i, j, n, k, a, b, c, d, x, y;
  string s, t, temp;
  cin>>s>>t;
  if(t.length() == s.length()+1)
  {
    temp = t.substr(0,s.length());
    //cout<<temp<<endl;
    if(s==temp)
    {
      cout<<"Yes\n";
      return;
    }
    else
    {
      cout<<"No\n";
      return;
    }
  }
  else
  {
    cout<<"Yes\n";
    return;
  }
}
 
int main()
{
    FASTIO
    solve();
    return 0;
}

Measured memory_bytes: 3588
N = int(input())
S = [input() for _ in range(N)]

def check(SS):
  for i in range(N-1):
    for j in range(i+1,N):
      if SS[i][j] != SS[j][i]:
        return 0
  return N

ans = 0
SS = []
for i in range(N):
  SS = []
  for j in range(1,N):
    SS.append(S[j])
  SS.append(S[0])
  #print(SS)
  ans += check(SS)
  S = SS
print(ans)

Measured memory_bytes: 41580
import sys
import numpy as np

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
P = np.array([np.float64(p) for p in readline().split()], dtype=np.float64)


def solve():
    dp = np.zeros(N + 1, dtype=np.float64)
    dp[0] = 1.0 - P[0]
    dp[1] = P[0]
    for i in range(1, N):
        p = P[i]
        q = np.zeros_like(dp)
        q[1:] = dp[:-1]
        dp = dp * (1.0 - p) + q * p
    return dp[N // 2 + 1 :].sum()


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 12544
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string s;unsigned int coun,i,k;
  cin >> s;coun = 0;
  for(i=0;i<s.size();i++){
    if((i%2==0 && s[i] == '0') || (i%2==1 && s[i] == '1')) coun += 1;
  }
  k = s.size()-coun;
  cout << min(coun,k) << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		Long N = scan.nextLong();
		int M = scan.nextInt();
		Long[] A = new Long[M];
		for(int i = 0;i<M;i++) {
			A[i] = scan.nextLong();
		}
		long sumdate = 0;
		long result = -1;

		for(long date:A) {
			sumdate = sumdate+date;
			}
		if(N-sumdate>=0) {
		result = N-sumdate;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 46508
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, M; cin >> N >> M;
  int A[N], B[N]; rep(i, N) cin >> A[i] >> B[i];
  int C[M], D[M]; rep(i, M) cin >> C[i] >> D[i];

  rep(i, N) {
    int result = 0;
    rep(j, M) if (abs(A[i]-C[result])+abs(B[i]-D[result]) > abs(A[i]-C[j])+ abs(B[i]-D[j])) result = j;
    result++;
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#define ALL(x) (x).begin(), (x).end()
typedef long long lld;
const int MAXS = 1e5+5;
const int NOPE = -1;
std::vector<int> dex[MAXS]{ };
char S[MAXS];
char T[MAXS];
int M, N;

lld solve() {
  for (int i = 0; i < N; ++i) {
    dex[S[i] - 'a'].push_back(i);
  }
  int pos = -1;
  lld ret = 0;
  for (int i = 0; i < M; ++i) {
    int c = T[i] - 'a';
    // Not in S.
    if (dex[c].empty()) {
      return NOPE;
    }
    // Cannot remain at current index.
    auto ptr = std::upper_bound(ALL(dex[c]), pos);
    if (ptr == dex[c].end()) {
/*
      if (pos == dex[c].front()) {
        return NOPE;
      }
*/
      ret += (N - pos) + dex[c].front();
      pos = dex[c].front();
    } else {
      ret += *ptr - pos;
      pos = *ptr;
    }
  }
  return ret;
}

int main() {
  scanf(" %s%s", S, T);
  N = strlen(S);
  M = strlen(T);
  printf("%lld\n", solve());
  return 0;
}

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

using namespace std;
constexpr int MOD = 1000000007;
int main()
{
    int N, W;
    cin >> N >> W;
    vector<int> w(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i];
    }
    sort(w.begin(), w.end());
    vector<int> sum(N + 1, 0);
    for (int i = 0; i < N; i++) {
        sum[i + 1] = sum[i] + w[i];
    }

    int ans = 0;
    if (sum[N] <= W) {
        ans = 1;
    }
    for (int i = 0; i < N; i++) {  // i-th man OUT && 1st~(i-1)th man IN
        const int initial = sum[i];
        vector<vector<int>> dp(N - i, vector<int>(W + 1, 0));
        dp[0][0] = 1;
        for (int j = 0; j < N - i - 1; j++) {
            for (int k = 0; k <= W; k++) {
                dp[j + 1][k] += dp[j][k];
                dp[j + 1][k] %= MOD;
                if (k + w[i + j + 1] <= W) {
                    dp[j + 1][k + w[i + j + 1]] += dp[j][k];
                    dp[j + 1][k + w[i + j + 1]] %= MOD;
                }
            }
        }
        int suma = 0;
        for (int j = max(0, W - w[i] + 1 - initial); j <= W - initial; j++) {
            suma = (suma + dp[N - i - 1][j]) % MOD;
        }
        ans = (ans + suma) % MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10648
g = ['R','U','D']
k = ['L', 'U', 'D']

S = input()
ans = 'Yes'
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] not in g:
            ans = 'No'
            break
    else:
        if S[i] not in k:
            ans = 'No'
            break
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef pair <ll, ll> dll;
typedef vector <ii> vii;
typedef vector <vi> graph;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll k, a, b;
    cin >> k >> a >> b;
    ll mayor = 1 + k;
    if (b - a > 2) {
    	k -= (a - 1);
        ll ganancia = b - a;
    	ll temp = a + ganancia * (k / 2);
    	k -= 2 * (k / 2);
    	temp += k;
    	mayor = max(temp, mayor);
    }
    cout << mayor << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    int N, K, d, A;
    int sunuke[100] = {};
    cin >> N >> K;
    for(int i=0; i<K; i++){
        cin >> d;
        for(int d_i=0; d_i<d; d_i++){
            cin >> A;
            sunuke[A-1] = 1;
        }
    }
    int count = 0;
    for(int i=0; i<N; i++){
        if(sunuke[i] == 0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r, D, x2000;
  cin >> r >> D >> x2000;
  int ans = 0;
  int xt = x2000;
  int xt1 = 0;
  REP(i, 10) {
    xt1 = r * xt - D;
    cout << xt1 << endl;
    xt = xt1;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

ll mpow(ll a) {
  return a * a * a * a * a;
}

int main(void) {
  ll i, j, x;
  scanf("%lld", &x);
  for(i = -200; i < 201; ++i) for(j = -200; j < 201; ++j) if(mpow(i) - mpow(j) == x) {
    printf("%lld %lld", i, j);
    return 0;
  }
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;

const int Inf = 100000;
const int mod = 1000000007;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void Solve()
{
	long long n, ans = 0, c;
	cin >> n;
	long long k = n / 500;
	ans += 1000 * k;
	n %= 500;
	k = n / 5;
	ans += 5 * k;
	cout << ans;	
}

signed main()
{
	Solve();
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int x[5],i,a=0;
	scanf("%d",&x[0]);
	scanf("%d",&x[1]);
	scanf("%d",&x[2]);
	scanf("%d",&x[3]);
	scanf("%d",&x[4]);
	for(i=0;i<5;i++){
		if(x[i]<40)
		x[i]=40;
		a+=x[i];
	}
	printf("%d\n",a/5);
return 0;
}

Measured memory_bytes: 1028
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int n = b-a;
    int east = 0;
    for(int i = 1; i<n; i++){
      east += i;
    }
    int res = east - a;
    System.out.println(res);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int n,ans=25;
int main(){
  cin>>n;
  vector<int>d(n+1);
  rep(i,n)cin>>d[i];
  d[n]=0;
  sort(d.begin(),d.end());
  rep(i,n+1)if(i&1)d[i]=24-d[i];
  sort(d.begin(),d.end());
  rep(i,n)if(d[i+1]-d[i]<ans)ans=d[i+1]-d[i];
  cout<<min(ans,24-d[n])<<endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> moti(N);
  rep(i, N) {
    cin >> moti.at(i);
  }
  int tmp = 0;
  
  rep(i, N) {
    for (int j = i+1; j < N ; j++) {
      if (moti.at(i) < moti.at(j)) {
        tmp = moti.at(i);
        moti.at(i) = moti.at(j);
        moti.at(j) = tmp;
      }
    }
  }
  
  int ans = 1;
  rep(i, N-1) {
    if (moti.at(i) != moti.at(i+1)) {
      ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
S = int(input())
mod = 10**9 + 7

dp = [0] * (S+1)
dp[0] = 1
x = 0
for i in range(1,S+1):
  if i >= 3:
    x += dp[i-3]
    x %= mod
  dp[i] = x
print(dp[S])

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

int selection_sort(int A[], int n){
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int minj = i;
        for(int j = i; j < n; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(A[i] > A[minj]) cnt++;
        swap(A[i],A[minj]);
        
    }
    return cnt;
}

void print(int A[],int n){
    for(int i = 0; i < n; i++){
        cout << A[i];
        if(i != n-1) cout << " ";
        else cout << endl;
    }
}

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    int k = selection_sort(a,n);
    print(a,n);
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <set>
#include <vector>

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

    std::vector<int> p(n);
    std::vector<int> idx(n);

    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
        p[i]--;
        idx[p[i]] = i;
    }

    std::set<int> s;

    long long ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        int id = idx[i];

        s.insert(id);

        std::vector<int> l(2, -1);

        auto center = s.find(id);
        for (int j = 0; j < 2; j++) {
            if (center == s.begin()) {
                break;
            }
            center--;
            l[j] = *center;
        }

        center = s.find(id);
        std::vector<int> r(2, n);
        for (int j = 0; j < 2; j++) {
            center++;
            if (center == s.end()) {
                break;
            }
            r[j] = *center;
        }

        std::vector<int> ls(2);
        std::vector<int> rs(2);

        ls[0] = id - l[0];
        ls[1] = l[0] - l[1];

        rs[0] = r[0] - id;
        rs[1] = r[1] - r[0];

        long long c = (long long)(ls[0] * rs[1]) + (long long)(ls[1] * rs[0]);

        ans += c * (i + 1);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 5760
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

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

    for i in 0..n - m + 1 {
        for j in 0..n - m + 1 {
            let mut f: bool = false;
            for k in 0..m {
                for l in 0..m {
                    if a[i + k][j + l] != b[k][l] {
                        f = true;
                    }
                }
            }
            if f == false {
                println!("Yes");
                return;
            }
        }
    }

    println!("No");
}


Measured memory_bytes: 4352
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
	"sort"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

type Unique struct {
	arr []int
	existsMap map[int]struct{}
}


type Pos struct {
	x int
	y int
}

func main() {
	con := NewConsole()
	defer con.Flush()

	// create list
	var n int
	fmt.Scanf("%d", &n)
	lines, _ := ReadLongLines(n)
	list := make([]Pos, n)
	for i := range lines {
		args := strings.Split(lines[i], " ")
		x, _ := strconv.Atoi(args[0])
		y, _ := strconv.Atoi(args[1])
		list[i] = Pos{x, y}
	}

	// sort
	sort.Slice(list, func(lhs, rhs int) bool {
		if list[lhs].x == list[rhs].x {
			return list[lhs].y < list[rhs].y
		} else {
			return list[lhs].x < list[rhs].x
		}
	})


	// print
	for _, v := range list {
		con.Printf("%d %d\n", v.x, v.y)
	}
}


Measured memory_bytes: 11100
#include <bits/stdc++.h>
using namespace std;
int a[20],n;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    int mx=0; int s=0;
    for(int i=0;i<n;i++){
        mx = max(mx,a[i]); s+=a[i];
    }
    if(mx<(s-mx)) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

using namespace std;

#define ll long long

template<typename T>
struct BellmanFord {
	struct edge {
		int u, v; T w;
		edge(int from, int to, T weight) {
			u = from;
			v = to;
			w = weight;
		}
	};

	int n; // 頂点数
	vector<vector<int>> G;
	vector<int> used, reach;
	BellmanFord(int number) {
		n = number;
		vector<vector<int>> G_(n);
		vector<int> used_(n, 0), reach_(n, 0);
		G = G_; used = used_; reach = reach_;
	}

	vector<edge> es;
	void add_edge(int u, int v, T c) {
		es.emplace_back(u, v, c);
		G[u].emplace_back(v);
	}

	void dfs(int v) {
		if (used[v]) return;
		used[v] = 1;
		for (int u : G[v])
			dfs(u);
	}

	T build(int from, int to, int& neg_loop) {
		for (int i = 0; i < n; i++) {
			fill(used.begin(), used.end(), 0);
			dfs(i);
			reach[i] = used[to];
		}
		const T INF = numeric_limits<T>::max();
		vector<T> ds(n, INF);
		ds[from] = 0;
		for (int j = 0; j < n; j++) {
			bool update = 0;
			for (auto e : es) {
				if (!reach[e.u] || !reach[e.v] || ds[e.u] == INF) continue;
				if (ds[e.v] > ds[e.u] + e.w) {
					ds[e.v] = ds[e.u] + e.w;
					update = 1;
				}
			}
			if (!update) break;
			if (j == n - 1) {
				neg_loop = 1;
				return INF;
			}
		}
		neg_loop = 0;
		return ds[to];
	}
};

signed main() {
	int n, m, p;
	cin >> n >> m >> p;
	BellmanFord<int> g(n + 1);
	for (int i = 0; i < m; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		g.add_edge(a, b, p - c);
	}

	int neg;
	int res = g.build(1, n, neg);

	if (neg) {
		cout << -1 << endl;
	}
	else {
		cout << max(0, -res) << endl;
	}

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  vector<int> A(5);
  REP(i, 5) { std::cin >> A.at(i); }
  int min_ = 10;
  int menu_index;
  REP(i, 5) {
    if (A.at(i) % 10 > 0) {
      if (A.at(i) % 10 < min_) {
        menu_index = i;
        min_ = A.at(i) % 10;
      }
    }
  }
  int time = 0;
  REP(i, 5) {
    if (i == menu_index) {
      time += A.at(i);
    } else {
      if (A.at(i) % 10 == 0) {
        time += A.at(i);
      } else {
        time += (A.at(i) / 10 + 1) * 10;
      }
    }
  }
  std::cout << time << '\n';
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

type Dice struct {
	T, S, E, W, N, B int
}

func (p *Dice) roll(direction rune) {

	if direction == 'S' {
		p.S, p.B, p.N, p.T = p.T, p.S, p.B, p.N
	} else if direction == 'N' {
		p.N, p.B, p.S, p.T = p.T, p.N, p.B, p.S
	} else if direction == 'W' {
		p.W, p.B, p.E, p.T = p.T, p.W, p.B, p.E
	} else if direction == 'E' {
		p.E, p.B, p.W, p.T = p.T, p.E, p.B, p.W
	}

}

func (p *Dice) matching(d Dice) bool {

	ret := false
	
	for j := 0; j < 6; j++ {//6面がそれぞれ一度top

		for j := 0; j < 4; j++ { //側面を一周
			if (p.T == d.T) && (p.S == d.S) && (p.E == d.E) && (p.W == d.W) && (p.N == d.N) && (p.B == d.B) {
				ret = true
				break
			} else {
				p.roll('N')
				p.roll('W')
				p.roll('S')
			}
		}

		if j%2 == 0 {
			p.roll('N')
		} else {
			p.roll('W')
		}
	}
	return ret
}

func main() {

	var t, s, e, w, n, b int

	fmt.Scanln(&t, &s, &e, &w, &n, &b)
	dice1 := Dice{t, s, e, w, n, b}

	fmt.Scanln(&t, &s, &e, &w, &n, &b)
	dice2 := Dice{t, s, e, w, n, b}

	if dice2.matching(dice1) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}



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

int main(){
  int n;
  cin >> n;
  vector<int> A(n), B(n), C(n-1);

  for (int i = 0; i < n; i++){
    cin >> A[i];
  }
  for (int i = 0; i < n; i++){
    cin >> B[i];
  }
  for (int i = 0; i < n-1; i++){
    cin >> C[i];
  }
  int cnt = 0;
  cnt += B[A[0]-1];
  for (int i = 1; i < n; i++){
    cnt += B[A[i]-1];
    if (A[i] - A[i-1] == 1)
    cnt += C[A[i-1]-1];
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
ans = [input() for i in range(n)]
a = collections.Counter(ans)
b = a.most_common()
count = 1
if b[0][1]==1:
    ans.sort()
    for i in ans:
        print(i)
else:
    key = b[0][1]
    for i,j in enumerate(b):
        if j[1] < key:
            count = i
            break
    c = b[:count]
    d = [i[0] for i in c]
    d.sort()
    for i in d:
        print(i)


Measured memory_bytes: 46844
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;

int main()
{
    string s;
    cin >> s;

    lli sum = 0;
    for(int i = 0; i < s.length(); i++)
    {
        sum += (s[i] - '0');
        if(sum > 10000000000)
        {
            sum = sum%9;
        }
    }

    if(sum%9 == 0)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}



Measured memory_bytes: 3680
#include<stdio.h>

int main(void)
{
	int i,n,loan = 100000;
	while (1){
		scanf("%d", &n);
		if (0 <= n&&n <= 100)
			break;
	}
	for (i = 0; i < n; i++){
		loan *= 1.05;
		if (loan % 1000 != 0){
			loan -= loan % 1000;
			loan += 1000;
		}
	}
	printf("%d\n", loan);
	return 0;
}

Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
const int N=100010;
vector<pi>v[20];
bool check(int num,int pos)
{
    return num&(1<<pos);
}
int main()
{
    IOS;
    int n;cin>>n;
    for(int i=1;i<=n;i++)
    {
        int m;cin>>m;
        for(int j=0;j<m;j++)
        {
            int a,b;cin>>a>>b;
            v[i].pb({a,b});
        }
    }
    int ans=0;
    for(int num=(1<<(n+1))-1;num>=0;num--)
    {
        bool f=true;
        for(int i=1;i<=n;i++)
        {
            if(check(num,i))
                for(int j=0;j<v[i].size();j++){
                    int person=v[i][j].ff;
                    if(check(num,person)!=v[i][j].ss)
                    {
//                        cout<<num<<" "<<person<<" "<<v[i][j].ss<<endl;
                        f=false;
                        break;
                    }
                }
            if(f==false)break;
        }

        if(f){
            int cnt=0;
            for(int i=1;i<=n;i++)
                if(num&(1<<i))cnt++;
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
}








Measured memory_bytes: 3648
import heapq

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

AB = [[] for _ in range(M)]

for _ in range(N):
    a, b = map(int, input().split())
    if a - 1 < M:
        AB[a - 1].append(-b)

res = 0
cand = []

for i in range(M):
    AB[i].sort(reverse=True)
    for b in AB[i]:
        heapq.heappush(cand, b)
    if cand:
        mb = heapq.heappop(cand)
        res -= mb

print(res)


Measured memory_bytes: 17604
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize("Ofast,no-stack-protector")
#define res register int
using namespace std;
bool showup[4];
map<char,int> M;
string s;
inline int read()
{
  int X=0,w=0;
  char ch=0;
  while(!isdigit(ch))
  {
    w|=ch=='-';
    ch=getchar();
  }
  while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
  return w?-X:X;
}
int main()
{
  cin>>s;
  M['S']=0;
  M['E']=1;
  M['W']=2;
  M['N']=3;
  for(res i=0; i<s.size(); i++)
    showup[M[s[i]]]=1;
  if((showup[0]^showup[3])||(showup[1]^showup[2]))
    puts("No");
  else
    puts("Yes");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		for(int i = 0; i < 3; ++i)
			a[i] = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		Arrays.sort(a);
		int tmp = (int)Math.pow(2,  k);
		int ans = a[0] + a[1] + a[2] * tmp;
		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
main()
{
 	long long int n,m ,k ;
 	cin >> n >> m >> k;
 	long long int i;
 	vector<long long int>a(n), b(m);
 	 
 	for(i=0;i<n;i++)
	 cin >> a[i];
	 for(i=0;i<m;i++)
	 cin >> b[i];
	 
	 long long int maxi = 0 , sum = 0 ;
	
	 for(i=1;i<b.size();i++)
	 b[i]+=b[i-1];
	long long int idx1 = lower_bound(b.begin(), b.end(), k)-b.begin();
 	if(idx1 == b.size())
 	idx1--;
	 if(b[idx1] > k)
		idx1--;
	
		if(idx1>=0)
		maxi = idx1+1;
		else
		maxi = 0;
	
			
	 for(i=0;i<n;i++)
	 {
	 	sum+=a[i];
	 	long long int x = k-sum;
		if(x < 0)
		break;
		long long int idx = lower_bound(b.begin(), b.end(), x)-b.begin();
		if(idx == b.size())
		idx--;
		if(b[idx]+sum > k)
		idx--;
		if(idx >=0)
		{
		if(i+1+idx+1 > maxi)
		maxi = i+1+idx+1;
	    }
	    else
	    {
	    	maxi = max(i+1, maxi);
		}
	 }
	 cout << maxi << endl;
	 return 0;
}

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

using namespace std;
using ll = long long;

bool chack(string s){
    int m = (int)s.size() / 2;

    return s.substr(0, m) == s.substr(m, m);

}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<bool> seen(n);
    for(int i = 0; i < n; i++){cin >> a[i]; a[i]--;}
    
    seen[0] = 1;
    int cur = 0;
    for(int i = 0; i < n; i++){
        if(seen[a[cur]]){
            cout << - 1 << endl;
            return 0;
        }
        if(a[cur] == 1){
            cout << i + 1 << endl;
            return 0;
        }
        cur = a[cur];
        seen[cur] = true;
    }
    cout << -1 << endl;

}

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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> t(N+1, 0), x(N+1, 0), y(N+1, 0);
    
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for (int i = 1; i < N+1; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }

    bool reachable = false;
    for(int i = 1; i < N+1; i++){
        int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        int diff = t[i] - t[i-1] - dist;
        if(diff >= 0 && diff % 2 == 0){
            reachable = true;
        } else {
            reachable = false;
            break;
        }
    }

    if(reachable){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod 		1000000007
#define inf 		1e18
#define IOS 		ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	string s;
	cin >> s;
	int n = s.size();

	if (s[n - 1] != 's')
		s += "s";
	else
		s += "es";

	cout << s;

	return 0;
}

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

using namespace std;

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

  int x = 0, y = 0, z = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    x += (p <= a);
    y += (a + 1 <= p && p <= b);
    z += (b + 1 <= p);
  }
  cout << min({x, y, z}) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>

int main() {
  intmax_t x;
  scanf("%jd", &x);

  intmax_t res = x / 11 * 2;
  x %= 11;
  if (x > 6) {
    res += 2;
  } else if (x > 0) {
    ++res;
  }
  printf("%jd\n", res);
}


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

using namespace std;
typedef long long ll;

vector<ll> a(100010);
int n;
ll calc(bool s, ll su) {
    ll cnt = 0;
    ll sum = su;
    bool sign = s;
    for(int i=1;i<n;i++) {
        sum += a[i];
        if(sign) {
            if(sum >= 0) {
                cnt += sum + 1;
                sum = -1;
            }
            sign = false;
        } else {
            if(sum <= 0) {
                cnt += abs(sum) + 1;
                sum = 1;
            }
            sign = true;
        }
    }
    return cnt;
}
int main() {
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];

    ll sum = a[0];
    bool sign;
    if(a[0] > 0) sign = true;
    else if(a[0] < 0) sign = false;

    ll ans1 = calc(sign, sum);
    ll arg;
    if(a[0] > 0)
        arg = -1;
    else
        arg = 1;
    ll ans2 = calc(!sign, arg) + abs(a[0]) + 1;
    ll ans;
    if(a[0] == 0) {
        ll ans3 = calc(true, 1) + 1;
        ll ans4 = calc(false, -1) + 1;
        ans = min(ans3, ans4);
    }
    else
        ans = min<ll>(ans1, ans2);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 205;

int dis[N][N];
char s[N];

int main()
{
	int n = read();
	memset(dis, 0x3f, sizeof(dis));
	for (int i = 1; i <= n; ++i)
	{
		scanf("%s", s + 1);
		for (int j = 1; j <= n; ++j) 
			if (s[j] == '1') dis[i][j] = 1;
	}
	
	for (int k = 1; k <= n; ++k)
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j) 
				dis[i][j] = min(dis[i][j],
					dis[i][k] + dis[k][j]);
	
	for (int k = 1; k <= n; ++k)
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j)
				if (abs(dis[i][j] - dis[i][k] - dis[k][j]) & 1)
					return puts("-1"), 0;
	
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			ans = max(ans, dis[i][j]);
	printf("%d\n", ans + 1);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(void)
{
    int a;
    scanf("%d", &a);
    if(a==19||a==89||a==79||a==69||a==59||a==49||a==39||a==29||(a>=90&&a<=99))
        printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <deque>
#include <vector>
using namespace std;

int main(){
  int k;
  cin >> k;
  while(k % 2 == 0){
    k /= 2;
  }
  while(k % 5 == 0){
    k /= 5;
  }
  vector<int> digitSum_mod(k, 1e9);
  deque<int> dq;
  digitSum_mod[1] = 1;
  dq.push_back(1);
  while(!dq.empty()){
    int u = dq.front(); dq.pop_front();

    if (digitSum_mod[u*10 % k] > digitSum_mod[u]){
      digitSum_mod[u*10 % k] = digitSum_mod[u];
      dq.push_front(u*10 % k);
    }

    if (digitSum_mod[(u+1) % k] > digitSum_mod[u] + 1){
      digitSum_mod[(u+1) % k] = digitSum_mod[u] + 1;
      dq.push_back((u+1) % k);
    }
  }

  cout << digitSum_mod[0] << endl;

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#ifdef LOCAL
#define debug(x) cerr << '[' << #x << " = " << (x) << "]\n"
#else
#define debug(x)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	rep(i,0,n){
		cin>>a[i]>>b[i];
	}
	sort(all(a));
	sort(all(b));
	if(n&1){
		cout<<b[n/2]-a[n/2]+1<<'\n';
	}else{
		cout<<b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1<<'\n';
	}
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define N 100005

using namespace std;

int n;
long long m, ans;

int a[N];
long long psum[N];

bool check(int mid) {
	int r = n;
	long long cnt = 0;
	for(int i = 1; i <= n; ++i) {
		if(a[i] + a[i] < mid) break;
		while(r > i && a[r] + a[i] < mid) --r;
		if(r >= i) {
			++cnt;
			cnt += (r - i) << 1;
		}
	}
	return cnt >= m;
}

int main() {
	scanf("%d%lld", &n, &m);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n, greater<int>());
	for(int i = 1; i <= n; ++i) psum[i] = a[i] + psum[i - 1];
	int l = 1, r = 2e5, mid, mpos = l;
	while(l <= r) {
		mid = l + r >> 1;
		if(check(mid)) {
			if(mid > mpos) mpos = mid;
			l = mid + 1;
		} else {
			r = mid - 1;
		}
	}
	r = n;
	long long cnt = 0;
	for(int i = 1; i <= n; ++i) {
		if(a[i] + a[i] <= mpos) break;
		while(r > i && a[r] + a[i] <= mpos) --r;
		if(r >= i) {
			++cnt;
			cnt += (r - i) << 1;
			ans += (psum[r] - psum[i - 1]) << 1;
			ans += 1LL * a[i] * ((r - i) << 1);
		}
	}
	ans += (m - cnt) * mpos;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int n, c, a[100009], b[100009], deg[100009], deg2[100009], g[100009][2], v[100009], ans[100009], cur[100009];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i];
		deg[--a[i]]++;
		deg[--b[i]]++;
	}
	bool ok = true;
	for (int i = 0; i < n - 1; i++) {
		if (deg[a[i]] >= 2 && deg[b[i]] >= 2) {
			if (deg2[a[i]] <= 1) g[a[i]][deg2[a[i]]++] = b[i];
			else ok = false;
			if (deg2[b[i]] <= 1) g[b[i]][deg2[b[i]]++] = a[i];
			else ok = false;
		}
	}
	int m = 0;
	for (int i = 0; i < n; i++) {
		if (deg2[i] >= 1) m++;
	}
	if (m == 0) {
		if (n >= 3) {
			cout << '1';
			for (int i = 3; i <= n - 1; i++) cout << ' ' << i;
			cout << " 2 " << n << "\n";
		}
		else cout << "1 2\n";
	}
	else if (!ok) cout << "-1\n";
	else {
		ans[0] = 1 << 30;
		for (int i = 0; i < n; i++) {
			if (deg2[i] != 1) continue;
			int pos = i, pre = -1, cnt = 0;
			for (int j = 0; j < m; j++) {
				cur[cnt++] = deg[pos] - deg2[pos] + (j != 0 && j != m - 1);
				for (int k = 0; k < deg2[pos]; k++) {
					if (g[pos][k] != pre) {
						pre = pos;
						pos = g[pos][k];
						break;
					}
				}
			}
			for (int j = 0; j < m; j++) {
				if (ans[j] < cur[j]) break;
				else if (ans[j] > cur[j]) {
					for (int k = 0; k < m; k++) {
						ans[k] = cur[k];
					}
					break;
				}
			}
		}
		cout << 1;
		int s = 1;
		for (int i = 0; i < m; i++) {
			for (int j = s + 2; j <= s + ans[i]; j++) cout << ' ' << j;
			cout << ' ' << s + 1;
			s += ans[i];
		}
		cout << ' ' << n << '\n';
	}
	return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[12345678], cost[12345678];
signed main() {
	vector<int> v; map<string, int> mn;
	int n, m, k, a, b, c = 0, d = 0, cnt = 0, ans = 0; string s, t;
	cin >> n >> a >> b;
	for (int h = a; h <= b; h++) {
		if (h % n == 0) { cout << "OK" << endl; return 0; }
	}
	cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <iterator>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <map>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n, m;
	map<int, int> mp;
	string s;
	int countac = 0, countwa = 0;
	cin >> n >> m;
	rep(i, m) {
		cin >> n >> s;
		if (s == "AC"&&mp[n]!=-1) {
			countac++;
			countwa += mp[n];
			mp[n] = -1;
		}
		else if (s == "WA" && mp[n] != -1) {
			mp[n]++;
		}
	}

	cout << countac << " " << countwa;
}

Measured memory_bytes: 8144
N=int(input())
S = []
for _ in range(N):
    tmp = []
    for s in input():
        tmp.append(s)
    tmp.sort()
    S.append("".join(tmp))
dic = {}
for s in S:
    if s not in dic:
        dic[s] = 0
    dic[s] += 1
ans = 0
for v in dic.values():
    ans += v * (v - 1) // 2
print(int(ans))


Measured memory_bytes: 19460
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
    ll n;
    string s;
    cin >> s;
    vector<ll> arr;
    for(ll i =0;s[i]!='\0';i++)
    {
        if(s[i]=='0')
        {
            arr.push_back(0);

        }
        if(s[i]=='1')
        {
            arr.push_back(1);
        }
        if(s[i]=='B')
        {
            if(!arr.empty())
            {

                arr.pop_back();
            }
        }
    }
    for(long long int i=0;i<arr.size();i++)
    {

    cout << arr[i];
    }

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
//int count1=0;
int solve(int E) {
    int ans = E;
    for (int z = 0; z*z*z <= E; z++) {
        for (int y = 0; y*y <= E; y++) {
            //count1++;
            int x = E - y*y - z*z*z;
            if (x >=0&&x+y+z<ans)
                ans=x+y+z;
            
        }
    }
    return ans;
}

int main() {
    int E;
    while(cin >> E && E > 0) {
        cout << solve(E) << endl;
    }
}

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

int main(){
int a,b;cin>>a>>b;
if(abs(a-b)%2==1){
    cout<<"IMPOSSIBLE";
    return 0;
}
cout<<min(a,b)+abs(a-b)/2;

    
}


Measured memory_bytes: 3628
#include<iostream>

int main(){

    size_t a, b, c, x, y;
    std::cin >> a >> b >> c >> x >> y;

    size_t ans = 0;

    while(x != 0 && y != 0){
        if(a + b > c * 2){
            ans += c * 2;
        }else{
            ans += a + b;
        }
        x--, y--;
    }

    if(x == 0){
        if(b > c * 2){
            ans += c * 2 * y;
        }else{
            ans += b * y;
        }
    }else{
        if(a > c * 2){
            ans += c * 2 * x;
        }else{
            ans += a * x;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a, b, c, d, n;
	while(cin >> n){
		int count = 0; 
		if(n <= 36){
			for(a = 0; a <= 9 ; a++){
				for(b = 0; b <= 9; b++){
					for(c = 0; c <= 9; c++){
						for(d = 0; d <= 9; d++){
							if(( a + b + c + d) == n){
								count ++;
							}
						}
					}
				}
			}
				cout << count << endl;
		}
		else if(n > 36){
			cout << 0 << endl;
		}
	}
	return(0);
}

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


int main(){
	int vx[]={ 0, 1,-1, 0, 0,-1,-1, 1, 1, 2,-2, 0, 0};
	int vy[]={ 0, 0, 0, 1,-1,-1, 1,-1, 1, 0, 0, 2,-2};
	int x,y,size;
	int map[10][10];
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			map[i][j]=0;
		}
	}
	
	int nm_ans=0,max_ans=0;
	
	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
		switch(size){
		case 1:
			for(int i=0;i<5;i++){
				if((min(x+vx[i],y+vy[i])>=0)&&max(x+vx[i],y+vy[i])<10){
					map[x+vx[i]][y+vy[i]]++;
				}
			}
			break;
		case 2:
			for(int i=0;i<9;i++){
				if((min(x+vx[i],y+vy[i])>=0)&&max(x+vx[i],y+vy[i])<10){
					map[x+vx[i]][y+vy[i]]++;
				}
			}
			break;
		case 3:
			for(int i=0;i<13;i++){
				if((min(x+vx[i],y+vy[i])>=0)&&max(x+vx[i],y+vy[i])<10){
					map[x+vx[i]][y+vy[i]]++;
				}
			}
			break;
		}
	}
	
	
	
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			if(map[i][j]>max_ans){
				max_ans=map[i][j];
			}
			if(map[i][j]==0){
				nm_ans++;
			}
		}
	}
	cout<<nm_ans<<endl;
	cout<<max_ans<<endl;
	return 0;
}

Measured memory_bytes: 1208
# coding: utf-8
# Your code here!
import math
num = int(input())
x =  [int(s) for s in input().split()]
Abs = []
for T in range(1,num):
    light = 0
    heavy = 0
    for i in range(num):
        if(i+1 <= T):
            light += x[i]
        else:
            heavy += x[i]
    Abs.append(abs(light-heavy))
print(min(Abs))
            
            
            

Measured memory_bytes: 3316
#include <stdio.h>

int main(void){
	double w;
	char *s;
	
	while( scanf("%lf", &w) !=EOF ) {
		if(w<=48) s="light fly";
		else if(w<=51) s="fly";
		else if(w<=54) s="bantam";
		else if(w<=57) s="feather";
		else if(w<=60) s="light";
		else if(w<=64) s="light welter";
		else if(w<=69) s="welter";
		else if(w<=75) s="light middle";
		else if(w<=81) s="middle";
		else if(w<=91) s="light heavy";
		else s="heavy";
	
		printf("%s\n", s);
	}
	
	return 0;
}
	
	

Measured memory_bytes: 608
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n,q;
	cin >> n;
	std::map<int, int> m{};
	int ret = 0;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		m[tmp]++;
		ret += tmp;
	}
	vector<int>a(n);
	cin >> q;
	rep(i, q) {
		int b,c;
		cin >> b >> c;
		ret += (c-b) * m[b];
		m[c] += m[b];
		m[b] = 0;
		//cout << "ans=" << ret << endl;
		print(ret);
	}
}

Measured memory_bytes: 10120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=2010;
int N,a[maxn],sum[maxn];

int main(){
	//freopen("in","r",stdin);
	N=read();
	for(int i=1;i<=N;i++)
		a[i]=read(),sum[a[i]]++;
	sort(a+1,a+1+N);
	for(int i=1;i<maxn;i++)
		sum[i]+=sum[i-1];
	long long ans=0;
	for(int i=1;i<=N;i++)
		for(int j=1;j<i;j++){
			int L=a[i]-a[j]+1,R=a[i]+a[j]-1;
			if(L>R)continue;
			int cnt=sum[R]-sum[L-1];
			if(a[i]>=L&&a[i]<=R)cnt--;
			if(a[j]>=L&&a[j]<=R)cnt--;
			//printf("%d %d: %d %d %d\n",a[i],a[j],L,R,cnt);
			ans+=cnt;
		}
	printf("%d\n",ans/3);
	return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

int main()
{
  string s;
  cin>>s;
  int ans = 0;
  char curr = s[0];
  rep(i, 1, s.length())
  {
    if(s[i] != curr)
    {
      ans++;
      curr = s[i];
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 12416
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
        sc.Scan()
        i, e := strconv.Atoi(sc.Text())
        if e != nil {
                panic(e)
        }
        return i
}

func main() {
        sc.Split(bufio.ScanWords)

        for {
                h := nextInt()
                w := nextInt()

                if h == 0 && w == 0 {
                        break
                }

                for i := 1; i <= h; i++ {
                        for j := 1; j <= w; j++ {
                                switch {
                                case i%2 == 1 && j%2 == 1:
                                        fmt.Print("#")
                                case i%2 == 1 && j%2 == 0:
                                        fmt.Print(".")
                                case i%2 == 0 && j%2 == 1:
                                        fmt.Print(".")
                                case i%2 == 0 && j%2 == 0:
                                        fmt.Print("#")
                                }

                        }
                        fmt.Println()
                }
                fmt.Println()
        }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int d, n;
	cin>>d>>n;
	if(d==0){
		cout<<(n==100 ? 101 : n)<<'\n';
		return 0;
	}
	if(d==1){
		cout<<(n==100 ? 100*101 : 100*n)<<'\n';
		return 0;
	}
	cout<<(n==100 ? 100*100*101 : 100*100*n)<<'\n';
	return 0;
}


Measured memory_bytes: 256