akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  string s; cin >> s;
  vector<int> a;
  for(int i = 0; i < s.size(); i++){
    int b = s[i]-'0';
    a.push_back(b);
  }
  int num = a.size();
  ll ans = 0;
  for(int bit = 0; bit < (1<<num-1); bit++){
    ll temp = 0;
    for(int i = 0; i < num-1; i++){
      temp *= 10;
      temp += a[i];
      if(bit & (1<<i)){
        ans += temp;
        temp = 0;
      }
    }
    temp *= 10;
    temp += a[num-1];
    ans += temp;
  }
  cout << ans << endl;
  return 0;
}

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

x = a[0] // 2
l = 1
r = N - 1
while r - l > 1:
    mid = l + (r - l) // 2
    if a[mid] < x:
        r = mid
    else:
        l = mid
if abs(x - a[l]) <= abs(x - a[r]):
    print(a[0], a[l])
else:
    print(a[0], a[r])


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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(long long i = 0;i < n;i++)
long long H,W,K,N,D,X,T;


int main()
{
  cin>>N>>X>>T;
  int ans=N/X;
  if(N%X!=0){
    ans++;
  }
  ans*=T;
  cout<<ans;
  return 0;
}




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

int main() {
    int ans = 0;
    int N, a;
    cin >> N;
    rep(i, N) {
        cin >> a;
        if(i % 2 == 0 && a % 2 == 1)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val xu = (1..n).map { Pair(sc.next(), sc.next()) }

  val ans = mutableListOf<Float>()

  for (i in 0 until n) {
    val x = xu[i].first
    val u = xu[i].second

    if (u == "JPY") {
      ans.add(x.toFloat())

    } else if (u == "BTC") {
      val btc = 380000.0

      val subs = x.split(".")
      val sub1 = subs.getOrElse(0) { "" }
      val sub2 = subs.getOrElse(1) { "" }

      val tmp1 = sub1.toLong() * btc
      val tmp2 = sub2.toLong() * btc / 100_000_000

      ans.add(tmp1.toFloat() + tmp2.toFloat())
    }
  }

  println(ans.sum())
}


Measured memory_bytes: 38736
#include<iostream>
using namespace std;
int main(void){
  int a, b, c;
  char y, z;
  cin>>a>>y>>b>>z>>c;
  if(a>2019){
    cout<<"TBD"<<endl;
  }else if(a==2019 && b>4){
    cout<<"TBD"<<endl;
  }else{
    cout<<"Heisei"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#define pi acos(-1)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxN = 2 * 1e5 + 5;
ll fact[maxN];
ll ans; 

void exgcd(ll a, ll b, ll& x, ll& y) {
	if(b == 0) {
		x = 1, y = 0; return;
	}
	exgcd(b, a % b, y, x);
	y -= a / b * x;
}

ll get_ni(int num) {
	ll x, y;
	exgcd(num, mod, x, y);
	return (x % mod + mod) % mod;
}

ll C(int n, int m) {
	//cout << n << ' ' << m << endl;
	return fact[n] * get_ni(fact[m]) % mod * get_ni(fact[n - m]) % mod;
}

int main() {
	int W, H, A, B; cin >> H >> W >> A >> B;
	fact[0] = 1; for(int i = 1; i <= 2 * max(W, H); ++i) fact[i] = (fact[i - 1] * i) % mod;
	for(int i = B + 1; i <= W; ++i) {
		ans += C(i - 1 + H - A - 1, i - 1) * C(W - i + A - 1, W - i);
		ans %= mod;
	}	
	cout << (ans % mod + mod) % mod;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i > 0)
            a[i] += a[i - 1];
    }

    ll add[2] = {0}, addcnt[2] = {0};
    for (int i = 0; i < n; ++i) {
        int sign = (i % 2 ? -1 : 1);
        ll tmp;

        // +, -, +, ...
        tmp = (a[i] + add[0]) * sign;
        if (tmp <= 0) {
            addcnt[0] += abs(tmp) + 1;
            add[0] += (abs(tmp) + 1) * sign;
        }

        // -, +, -, ...
        tmp = -(a[i] + add[1]) * sign;
        if (tmp <= 0) {
            addcnt[1] += abs(tmp) + 1;
            add[1] -= (abs(tmp) + 1) * sign;
        }
    }
    cout << min(addcnt[0], addcnt[1]) << endl;
    return 0;
}


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

public class Main {

    public static void main(String[] args) {

        FastScanner fs = new FastScanner();

        int r = fs.nextInt();
        System.out.println( r * 2 * 3.141592 );

    }

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

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

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

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

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

        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();
        }

        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());
        }
    }

    private static int gcd( int a , int b ){
        int x;
        int y;
        if (a > b) {
            x = a;
            y = b;
        } else {
            x = b;
            y = a;
        }
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }
        return y;
    }

}


Measured memory_bytes: 32928
N = int(input())
A = list(map(int, input().split()))
Ad, ans = {}, sum(A)
for a in A:
    Ad[a] = Ad.get(a, 0) + 1

Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    ans += (C - B) * Ad.get(B, 0)
    Ad[B], Ad[C] = 0, Ad.get(B, 0) + Ad.get(C, 0)
    print(ans)


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

const int N = 3e5 + 10;

int a[N], n, sum[2];

bool check(int x) {
  int sum = 0;
  for(int i = 1; i <= n; i += 2) {
    if(sum >= x) { 
      sum = max(sum + a[i] - a[i - 1], a[i]);
    } else {
      sum += a[i] - a[i - 1];
    }
  }
  return sum >= x;
}

int main(void) {
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i & 1] += a[i];
  }
  if(~n & 1) {
    cout << max(sum[0], sum[1]) << " " << min(sum[0], sum[1]) << endl;
  } else {
    int ans = 0, l = 0, r = sum[1];
    while(l <= r) {
      int mid = l + r >> 1;
      if(check(mid)) {
	ans = mid;
	l = mid + 1;
      } else {
	r = mid - 1;
      }
    }
    cout << sum[0] + ans << " " << sum[1] - ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
n=int(input())
a=list(map(int,input().split()))
m=sum(a)/n
for i in range(n):
  if i == 0:
    index=0
    d=abs(m-a[0])
  else:
    d_new = abs(m-a[i])
    if d_new < d:
      d = d_new
      index=i
print(index)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const ll INF = 1e10;

int n, m;
vector<int>a[100005];

bool done[100005];
int  memo[100005];
int dp(int v) {
	if (done[v])return memo[v];
	int ans(0);
	for (int j : a[v]) {
		ans = max(ans, dp(j) + 1);
	}
	done[v]=1;
	memo[v] = ans;
	return ans;
}
int main() {
	cin >> n >> m;
	rep(i, m) {
		int b,c;
		cin >> b>>c;
		b--;
		c--;
		a[b].push_back(c);
	}
	int ans = 0;
	rep(i, n)ans = max(ans, dp(i));
	cout << ans;
	return 0;
}

Measured memory_bytes: 11576
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    map<ll,ll>mp;
    ll tmp = n;
    FOR(i,2,(ll)sqrt(n)+1){
        while(tmp%i==0){
            mp[i]++;
            tmp/=i;
        }
    }
    if(tmp!=1)mp[tmp]++;
    vector<ll>index(1001000);
    REP(i,1001000){
        index[i] = (ll)(i+1)*(i+2)/2;
    }
    ll answer = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        answer+=lower_bound(ALL(index),itr->second+1)-index.begin();
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 11212
# -*- coding: utf-8 -*-

H = int(input())
W = int(input())
N = int(input())

a = 0
b = 0
c = set()

for i in range(H+1):
    for j in range(W+1):
        if i*H+j*W-i*j >= N:
            c.add((i,j))

ans = min(set([n1+n2 for (n1,n2) in c]))
print(ans)


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif

const int MAXN = 100;
//#define int long long
const int INF = 1e9;

int MOD = 1e9 + 7;
int add(int a, int b){
	return (a + b) % MOD;
}

int mul(int a, int b){
	return ((ll)a * (ll)b) % (ll)MOD;
}


void solve(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int  i = 0; i < n; i++) cin >> a[i];

	int s = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = add(ans, mul(s, a[i]));
		s = add(s, a[i]);
	}

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

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

		solve();

    return 0;
}


Measured memory_bytes: 4012
#include <bits/stdc++.h>
#include <atcoder/all>
#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;
using namespace atcoder;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
	if (ref < value) ref = value;
}

ll op(ll left, ll right) {
    return max(left, right);
}

ll e() {
    return 0;
}

int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> as(n);
    rep(i, n) {
        cin >> as[i];
    }
    segtree<ll, op, e> tree(300001);
    tree.set(as[0], 1);
    for (int i = 1; i < n; i++) {
        ll a = as[i];
        ll low = max(0LL, a - k);
        ll up = min(300000LL, a + k);
        auto p = tree.prod(low, up+1);
        tree.set(a, p + 1);
    }
    cout << tree.all_prod() << endl;
    return 0;
}


Measured memory_bytes: 16192
n,m = map(int,input().split())
g = list(map(int, input().split()))
n_ = max(g)+1
l = [False]*n_
p = [0]*m
b = [0]*m
for x in g:
  b[x%m] += 1
  if l[x]:
    p[x%m] += 2
    l[x] = False
  else:
    l[x] = True
ans = b[0]//2
for i in range(1,(m+1)//2):
  cur = min(b[i],b[m-i])
  ans += cur
  ans += min(b[i]-cur, p[i])//2
  ans += min(b[m-i]-cur,p[m-i])//2
if not m%2:
  ans += b[m//2]//2
print(ans)

Measured memory_bytes: 14132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n;
    cin >> n;
    VI a(n), b(n), c(n - 1);
    FOR(i, 0, n)cin >> a[i];
    FOR(i, 0, n)cin >> b[i];
    FOR(i, 0, n - 1)cin >> c[i];

    int ans = 0;
    FOR(i, 0, n)ans += b[a[i] - 1];
    FOR(i, 0, n - 1)if (a[i] == a[i + 1] - 1) {
        ans += c[a[i] - 1];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  sort(a.begin(), a.end());
  int i = 0;

  while (0 < x&&i<N) {
    x -= a[i];
    i++;
  }
  if (x != 0) i--;
  cout << i << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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! {
        h: usize,
        w: usize,
        a: usize,
        b: usize
    }
    for height in 0..h {
        for wide in 0..w {
            let hh = height < b;
            let ww = wide < a;
            let pri = if (hh || ww) && (hh != ww) {1} else {0};
            print!("{}", pri);
        }
        println!("");
    }
}


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

void solve()
{
	ll n;
	cin>>n;
	ll t = 0;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		t ^= a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		ll e = t^a[i];
		cout<<e<<" ";
	}
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 5100
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int s,a,b,c,d;
    cin>>s;
    a=s/1000;
    b=(s/100)%10;
    c=(s/10)%10;
    d=s%10;
    if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
}

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

const int MAXN = 1e5 + 10;
int a[MAXN], n, mx, num;

int dis(int r) {
	return min(abs(r - (mx + 1) / 2), abs(r - mx / 2));
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], mx = max(mx, a[i]);
	num = 0;
	for (int i = 0; i < n; i++)
		if (a[i] != mx && dis(num) >= dis(a[i]))
			num = a[i];
	cout << mx << ' ' << num;
}

Measured memory_bytes: 640
def Euclid(max, min):
    if max % min == 0:
        return min
    else:
        return Euclid(min, max % min)


a, b = map(int, input().split(" "))
if a > b:
    print(Euclid(a, b))
else:
    print(Euclid(b, a))

Measured memory_bytes: 7752
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int a,b; cin>>a>>b; 
    string  s; cin >> s; 
    bool ok=true;
    for (int i=0;i<sz(s);i++){
        if (i==a) {
            if (isdigit(s[i])) ok=false;
        }
        else {
            if (!isdigit(s[i])) ok=false;
        }
    }
    cout << ((ok)? "Yes":"No") <<endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main(){
    int k;
    string s;
    cin >> k >> s;
    int ls = s.size();

    if(ls > k){
        for(int i = 0;i < k;i++){
            cout << s.at(i);
        }
         cout << "..." << endl; 
    }
    else{
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int main(){

	int N;
	scanf("%d",&N);

	int** table = new int*[N];
	for(int i = 0; i < N; i++)table[i] = new int[3];

	int ans = 0;

	for(int i = 0; i < N; i++){
		scanf("%d %d %d",&table[i][0],&table[i][1],&table[i][2]);
		for(int k = 0; k <= 1; k++){
			for(int j = 2; j > k; j--){
				if(table[i][j] > table[i][j-1])swap(table[i][j],table[i][j-1]);
			}
		}
	}

	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){
			if(table[i][0] == table[k][0] && table[i][1] == table[k][1] && table[i][2] == table[k][2]){
				ans++;
				break;
			}
		}
	}

	printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 2756
n = gets.to_i
h = gets.split(' ').map(&:to_i)
count = 0
counts = []
if n ==1
    puts 0
else
    (n-1).times do |a|
        if h[a] >= h[a+1]
            count +=1 
        else
            count = 0
        end
        counts << count
    end
    
    puts counts.max
end

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

using namespace std;

using ll = long long;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

const int MAX_N = 1000010;
// two[i] := i! が 2 で割れる回数
vector<ll> two(MAX_N);

// nCr が 2 で割れる回数
ll comb_two(int n, int r) {
  assert(two[n] - two[r] - two[n - r] >= 0);
  return two[n] - two[r] - two[n - r];
}

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

  for (int i = 1; i < MAX_N; i++) {
    int cnt = 0;
    ll val = i;
    while (val % 2 == 0) {
      cnt++;
      val /= 2;
    }
    two[i] = two[i - 1] + cnt;
  }
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool one = false;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    a[i] = s[i] - '1';
    if (a[i] == 1) one = true;
  }
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    // n-1 C i
    if (comb_two(n - 1, i) == 0 && a[i] == 1) sum = (sum + 1) % 2;
  }
  if (sum) {
    cout << 1 << endl;
    return 0;
  }
  if (one) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    a[i] /= 2;
  }
  sum = 0;
  for (int i = 0; i < n; i++) {
    if (comb_two(n - 1, i) == 0 && a[i] == 1) sum = (sum + 1) % 2;
  }
  if (sum)
    cout << 2 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 17052
#include<bits/stdc++.h>
#define endl "\n" 
using namespace std;
#define debug(x) cout<<"The value of "<<#x<<" is "<<x<<endl;
typedef long long ll;
typedef unsigned long long ull;
bool is_palin(string s){
    string a=s;
    reverse(a.begin(),a.end());
    return a==s;
}
int main()
{
    cin.sync_with_stdio(0); cin.tie(0); 
    string s;
    cin>>s;
    if(!is_palin(s)){
        cout<<"No"<<endl;
        return 0;
    }
    int n=s.size();
    string a=s.substr(0,(s.size()-1)/2);
    string b=s.substr(((n+3)/2)-1,s.size());
    if(is_palin(a)&&is_palin(b)){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


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

const int N = 100010;
typedef std::pair <int, int> pii;

int a[N];
std::vector <int> e[N];
int dep[N];
std::set <pii, std::greater <pii>> set;

void dfs(int u){
	for (auto v : e[u]){
		dep[v] = dep[u] + 1;
		dfs(v);
	}
}

void dfs1(int u){
	set.erase({dep[u], u});
	for (auto v : e[u]){
		if (set.count({dep[v], v})){
			dfs1(v);
		}
	}
}

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++ i){
		scanf("%d", &a[i]);
	}
	int ans = a[1] != 1;
	a[1] = 1;
	for (int i = 2; i <= n; ++ i){
		e[a[i]].push_back(i);
	}
	dfs(1);
	for (int i = 1; i <= n; ++ i){
		set.insert({dep[i], i});
	}
	while (!set.empty()){
		pii p = *(set.begin());
		if (p.first <= k){
			break;
		}
		int u = p.second;
		for (int i = 0; i < k - 1; ++ i){
			u = a[u];
		}
		dfs1(u);
		++ ans;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  P b[n];
  rep(i,0,n) b[i]=P(a[i],i);
  sort(b,b+n);
  if(b[0].first>=0){
    cout<<n-1<<endl;
    rep(i,0,n-1){
      cout<<i+1<<' '<<i+2<<endl;
      a[i+1]+=a[i];
    }
  }
  else if(b[0].first+b[n-1].first>=0){
    cout<<2*n-2<<endl;
    rep(i,0,n){
      if(i==b[n-1].second) continue;
      cout<<b[n-1].second+1<<' '<<i+1<<endl;
      a[i]+=b[n-1].first;
    }
    rep(i,0,n-1){
      cout<<i+1<<' '<<i+2<<endl;
      a[i+1]+=a[i];
    }
  }
  else{
    cout<<2*n-2<<endl;
    rep(i,0,n){
      if(i==b[0].second) continue;
      cout<<b[0].second+1<<' '<<i+1<<endl;
      a[i]+=b[0].first;
    }
    rep(i,0,n-1){
      cout<<n-i<<' '<<n-1-i<<endl;
      a[n-2-i]+=a[n-1-i];
    }
  }
}

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


int main(){
  int64_t n;
  cin >> n;
  int64_t h[n];
  cin >> h[0];
  int p = 0;
  int ans = 0;
  for(int i=1; i<n; i++){
    cin >> h[i];
    if(h[i-1]>=h[i]){p++;}
    else{
      if(p>ans){
        ans=p;
      }
      p=0;
    }
  }
  if(p>ans){
    ans=p;
    p=0;
  }
  cout << ans << endl;
}


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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

typedef vector<int> VI;

vector<int> pre, in, post;
int pos = 0;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    REP(i, vec.size()) {
        if (i > 0) cout << ", ";
        os << vec[i];
    }
    os << "]";

    return os;
}


void reconstruct(int l, int r) {
    if(l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));

    reconstruct(l, m);
    reconstruct(m+1, r);

    post.push_back(root);
}


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

    int n;
    cin >> n;

    int k;

    REP(i, n) {
        cin >> k;
        pre.push_back(k);
    }

    REP(i, n) {
        cin >> k;
        in.push_back(k);
    }

    reconstruct(0, n);

    REP(i, n) {
        if (i) cout << " ";
        cout << post[i];
    }

    cout << endl;
}


Measured memory_bytes: 3184
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 c = sc.nextInt();
    if(b-a == c-b){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21844
A, B, C, D = input().split()
A = int(A)  # 高橋
B = int(B)
C = int(C)
D = int(D)
takahasiA = C // B
if C % B != 0:
    takahasiA += 1
aokiA = A // D 
if A % D != 0:
    aokiA += 1
# print(takahasiA)
# print(aokiA)
ans = "Yes" if takahasiA <= aokiA else "No"
print(ans)


Measured memory_bytes: 9184
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		long ans = 0;
		long mod = 1000_000_007;
		
		c = new long[n+2][n+2];
		c[0][0] = 1;
		for(int i = 0;i < n+1;i++){
			for(int j = 0;j <= i;j++){
				c[i+1][j] += c[i][j]%mod;
				c[i+1][j+1] += c[i][j]%mod;
			}
		}
		
		for(int i = 1;i <= k;i++){
			System.out.println((c[n-k+1][i] * c[k-1][i-1] % mod));
		}
		

		
	}


	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}







	static int find(int index,int current,int[] students,int ans,int[][] memo){
		if(current == index){
			return 1;
		}

		if(memo[current][index] != 0){
			return memo[current][index];
		}

		memo[current][index] = find(index, students[current]-1, students, ans+1, memo)+1;

		return memo[current][index];
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}






Measured memory_bytes: 79692
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define vi vector<ll>
#define all(v) v.begin(), v.end()

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

	ll a = 0, b = 0;
	cin >> a >> b;
	if((a * b) % 2 == 0)
		cout << "Even" << endl;
	else
		cout << "Odd" << endl;
	//cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = list(map(int, input().split()))


for i in range(M):
    if A[0] >= X:
        ans = 0
        break
    elif A[M-1] <= X:
        ans = 0
        break
    else:
        if A[i] == X:
            ans = min(i, M-1-i)
        elif A[i-1] < X and X < A[i]:
            ans = min(i,M-i)

print(ans)


Measured memory_bytes: 3060
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int calc(int[] xs) {

    int rec(int p, int[] buf) {
        if (p == buf.length) {
            return buf.any!(e => e % 2 == 0) ? 1 : 0;
        }

        int ans = 0;
        for (int i = -1; i <= 1; i++) {
            buf[p] = xs[p] + i;
            ans += rec(p + 1, buf);
        }
        return ans;
    }

    auto buf = new int[xs.length];
    return rec(0, buf);
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int x = c-a, y = d-b;
    printf("%d %d %d %d\n", c-y, d+x, c-y-x, d+x-y);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n,x,y;
ll res=LSHN;
int main()
{
	cin >>n>>x>>y;
	if (x>y) swap(x,y);
	x--,y--;
	if ((y-x)%2==0)
	{
		cout <<(y-x)/2;
		return 0;
	}
	res=min(res,x+(y-x-1)/2+1);
	res=min(res,n-y-1+(y-x-1)/2+1);
	cout <<res;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  double weight;
  while(scanf("%lf",&weight)!=EOF){
    if(weight<=48.0)
      cout<<"light fly"<<endl;
    else if(weight<=51.0)
      cout<<"fly"<<endl;
    else if(weight<=54.0)
      cout<<"bantam"<<endl;
    else if(weight<=57.0)
      cout<<"feather"<<endl;
    else if(weight<=60.0)
      cout<<"light"<<endl;
    else if(weight<=64.0)
      cout<<"light welter"<<endl;
    else if(weight<=69.0)
      cout<<"welter"<<endl;
    else if(weight<=75.0)
      cout<<"light middle"<<endl;
    else if(weight<=81.0)
      cout<<"middle"<<endl;
    else if(weight<=91.0)
      cout<<"light heavy"<<endl;
    else
      cout<<"heavy"<<endl;

  }
}

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

using namespace std;

const int MAX = 1000001;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> d(MAX);
  vector<int> cnt(MAX);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]] += 1;
  }
  for (int i = 1; i < MAX; i++) {
    for (int j = i; j < MAX; j += i) {
      d[j] += cnt[i];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (d[a[i]] <= 1) {
      ans += 1;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> d(N);
    REP(i, N) cin >> d[i];
    sort(ALL(d));
    ll ans = d[(N - 1) / 2 + 1] - d[(N - 1) / 2];
    cout << ans << endl;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

class aizu_judge
{
    static void Main()
    {
        int[] num = System.Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(num);
        Console.WriteLine("{0} {1} {2}",num[0],num[1],num[2]);
    }
}

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

int main() {
    string s; cin >> s;
    int K; cin >> K;
    int n = s.size();
    int dp[K+1][n+1][n+1];
    memset(dp, 0, sizeof dp);
    for (int k = 0; k <= K; k++)
        for (int i = 1; i <= n; i++)
            for (int j = n-1; j >= i; j--) {
                if (s[i-1] == s[j])
                    dp[k][i][j] = dp[k][i-1][j+1] + 1;
                else if (k > 0)
                    dp[k][i][j] = max({dp[k][i-1][j], dp[k][i][j+1], dp[k-1][i-1][j+1] + 1});
                else
                    dp[0][i][j] = max(dp[0][i-1][j], dp[0][i][j+1]);
            }

    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = max({ans, 1 + 2 * dp[K][i][i+1], 2 * dp[K][i][i]});
    cout << ans << endl;
}


Measured memory_bytes: 106752
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    x, y = nm()
    print(x + y // 2)


if __name__ == '__main__':
    main()


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

string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	if("A" <= s && "Z" >= s){
		cout<<"A"<<endl;
	}else{
		cout<<"a"<<endl;
	}
}


Measured memory_bytes: 3604
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 105;

int a[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	int ans = 1e9;
	for(int x=1;x<=100;x++) {
		int sum = 0;
		for(int i=0;i<n;i++) {
			sum += (a[i]-x)*(a[i]-x);
		}
		ans=min(ans, sum);
	}
	cout << ans;
	return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N,K;cin>>N>>K;
  VECINT AS(N);
  REP(i,N) cin>>AS[i];
  OUT(ceil((float)(N-1)/(K-1)));

  return 0;
}

Measured memory_bytes: 640
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
let input = readIntSplit(by: " ").map{Double($0)}
let (T, A) = (input[0], input[1])
var H = readIntSplit(by: " ").map{T - Double($0) * 0.006}
var arr = [(Int, Double)]()
for i in 0..<N {
    arr += [(i+1, abs(A-H[i]))]
}
arr = arr.sort{$0.1<$1.1}
print(arr[0].0)


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

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

int main()
{
	int n,k; cin>>n>>k;
	int ans=0;
	while(n>0){
		ans++;
		n/=k;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n,rt;
    cin>>n;
    int mn,mx=-1000100010;
    cin>>mn;
    FOR(i,1,n){
        cin>>rt;
        mx=max(mx,rt-mn);
        mn=min(rt,mn);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int a, b, c;
	cin >> a >> b >> c;
	int x, y;
	cin >> x >> y;
	int mn = min(x, y);
	int answer = 0;
	if (a + b >= 2 * c) {
		answer += mn * 2 * c;
	} else {
		answer += mn * (a + b);
	}
	debug(answer);
	x -= mn;
	y -= mn;
	if (y == 0) {
		if (2 * c <= a) {
			answer += x * 2 * c;
		} else {
			answer += x * a;
		}
	} else {
		if (2 * c <= b) {
			answer += y * 2 * c;
		} else {
			answer += y * b;
		}
	}
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))
    s = 0
    for i in range(N):
        s += A[i] - 1
    print s


if __name__ == '__main__':
    main()

Measured memory_bytes: 3184
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    A, B, C, D = map(int, input().split())
    while True:
        C -= B
        if C <= 0:
            result = "Yes"
            break
        A -= D
        if A <= 0:
            result = "No"
            break

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N, X, L[100];
  cin >> N >> X;
  int S=0, i=0;
  
  for(; i<N; i++){
    cin >> L[i+1];
    S+=L[i+1];
    
    if(S>X)
      break;
  }
  
  cout << i+1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int matrix[100][100],i,j,input,n,m,matrix1[100],sum=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&matrix[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&matrix1[i]);
    }
    for(i=0;i<n;i++){
        sum=0;
        for(j=0;j<m;j++){
            sum+=matrix[i][j]*matrix1[j];
        }
        printf("%d\n",sum);
    }
    return 0;
}



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

class Main{
    public static void main(String[] args){
        int count;
        int[] array = new int[2];
        int key = 0;

        try{
            Scanner scan = new Scanner(System.in);

            String str = scan.next();
            array[0] = Integer.parseInt(str);

            str = scan.next();
            array[1] = Integer.parseInt(str);

            //System.out.println(array[0] + " " + array[1]);


            if(array[0] < array[1]){
                key = array[0];
                array[0] = array[1];
                array[1] = key;
            }


            key = array[0] % array[1];
            while(true){
                if(key == 0){
                    break;
                }
                array[0] = array[1];
                array[1] = key;
                key = array[0] % array[1];
            }
            // for(int i = 0; i < array[0]; i++){
            //     if(i == 0){
            //         continue;
            //     }else{
            //         if(array[0] % i == 0 && array[1] % i == 0){
            //             key = i;
            //         }
            //     }
            // }

            System.out.println(array[1]);

        }catch(Exception e){
            System.out.println("ERROR");
        }

    }
}


Measured memory_bytes: 26232
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
vector<char>v;
int flag,p,cnt;
string s[2],t[2],q;
map<char,int>m;
int bnf1();
int num(){
  int res=0,f=0;
  while(s[cnt][p]=='-')p++,f++;
  if(s[cnt][p]=='(')p++,res=(bnf1()+f)%2,p++;
  else{
    while(isdigit(s[cnt][p]))res=(s[cnt][p++]-'0'+f)%2;
  }
  return res;
}
int bnf1(){
  int res=num();
  while(s[cnt][p]=='+'||s[cnt][p]=='*'||s[cnt][p]=='>'){
    int pp=p++;
    if(s[cnt][pp]=='+')res=res|num();
    if(s[cnt][pp]=='*')res=res&num();
    if(s[cnt][pp]=='>'){
      int pp=num();
      if(res&&!pp)res=0;
      else res=1;
    }
  }
  return res;
}
void dfs(int d){
  if(d==v.size()){
    r(i,2)s[i]=t[i];
    r(i,2)r(j,s[i].size()){
      if(isalpha(s[i][j])){
        s[i][j]=m[s[i][j]]+'0';
      }
    }
    cnt=p=0;
    int ans1=bnf1();
    cnt=1;p=0;
    int ans2=bnf1();
    if(ans1!=ans2)flag++;
  }
  else{
    m[v[d]]=1;
    dfs(d+1);
    m[v[d]]=0;
    dfs(d+1);
  }
}
int main(){
  while(cin>>q,q!="#"){
    r(i,2)t[i]="";
    flag=0;
    m.clear();
    v.clear();
    int c1=0;
    r(i,(int)q.size()-1){
      if(q[i]=='T')q[i]='1';
      if(q[i]=='F')q[i]='0';
      if(q[i]=='-'&&q[i+1]=='>'){
        q.erase(q.begin()+i);
        i--;
      }
    }
    set<char>st;
    r(i,q.size()){
      if(isalpha(q[i])&&!st.count(q[i])){
        v.push_back(q[i]);
        st.insert(q[i]);
      }
    }
    r(i,q.size()){
      if(q[i]=='=')c1++;
      else t[c1]+=q[i];
    }
    dfs(0);
    cout<<(flag?"NO":"YES")<<endl;
  }
}

Measured memory_bytes: 3208
#include <iostream>  
#include <string.h> 
using namespace std;
int main() {
    int a[3];
    for (int i = 0; i < 3; i++)
        cin >> a[i];
    
    for (int i = 1; i < 3; i++) {
        int min = 0;
        for (int j = 0; j < 3; j++) {
            if (a[i] < a[j]) {
                min = a[j];
                a[j] = a[i];
                a[i] = min;
            }

        }
    }
    
        cout << a[0]+a[1];
    

    return 0;
}
 


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int N, M, X;
  cin >> N >> M >> X;

  int C[N], A[N][M], sum;
  rep(i,0,N-1) {
    cin >> C[i];
    sum += C[i];
    rep(j,0,M-1) {
      cin >> A[i][j];
    }
  }

  set<vector<int>> s;

  rep(i,0,pow(2,N)-1) {
    vector<int> v;
    rep(j,0,N-1) {
      if (i & (1 << j)) v.push_back(j);
    }
    s.insert(v);
  }

  int ans = sum;
  bool exists = false;
  for (auto v : s) {
    int c = 0, x[M]={0};
    for (auto n : v) {
      c += C[n];
      rep(i,0,M-1) {
        x[i] += A[n][i];
      }
    }

    bool ok = true;
    rep(i,0,M-1) {
      if (x[i] < X) ok = false;
    }

    if (ok) {
      ans = min(ans, c);
      exists = true;
    }
  }

  if (exists) cout << ans << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 4460
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll x;
    cin >> x;

    ll ans = 0;
    ans = (x/500) * 1000;
    x -= (x/500) * 500;
    ans += (x/5) * 5;
    cout << ans << endl;
    return 0;
}



























Measured memory_bytes: 256