akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return x * m % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    constexpr int N = 100;
    vector<int> prime;
    vector<bool> erato(N+5);
    FOR(i,2,N+1) {
        if (erato[i]) continue;
        prime.push_back(i);
        for(int j = 1; i * j <= N; j++) erato[i*j] = true;
    }
    constexpr int FACT = 1000;
    int fact[FACT];
    fact[0] = 1;
    FOR(i,1,FACT) fact[i] = modm(fact[i-1],i);

    auto comb = [&](int x,int y) {
        int r = fact[x];r = modd(r,fact[y]);r = modd(r, fact[x-y]);return r;};

    int n; cin >> n;
    vector<int> pcount(prime.size());
    REP(i,n) {
        int x = i+1;
        int j = 0;
        while(x != 1) {
            if (x % prime[j] == 0) {
                pcount[j]++;
                x /= prime[j];
            } else j++;
        }
    }
    map<int,int> m;
    REP(i,pcount.size()) {
        if (pcount[i] >= 74) m[74]++;
        if (pcount[i] >= 24) m[24]++;
        if (pcount[i] >= 14) m[14]++;
        if (pcount[i] >= 4) m[4]++;
        if (pcount[i] >= 2) m[2]++;
    }
    int ans = 0;
    if (m[4] >= 2 && m[2] >= 3) ans = m[74] + m[24] * (m[2]-1) + m[14] * (m[4]-1) + comb(m[4],2) * (m[2]-2);
    //REP(i,prime.size()) cerr << prime[i] << " " << pcount[i] << endl;
    //cerr << m[4] << " " << m[2] << endl;
    //cerr << pow(2,4) * pow(3,4) * pow(5,2) <<endl;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(2e5)+10;
int n;
struct node {
	int h,a,id;
} d[maxn];
bool cmp(node x,node y) {
	return x.h<y.h;
}
ll tr[maxn],dp[maxn],ans;
void add(int x,ll y) {
	for (;x<=n;x+=x&(-x)) tr[x]=max(tr[x],y);
}
ll query(int x) {
	ll res=0;
	for (;x>0;x-=x&(-x)) res=max(res,tr[x]);
	return res;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(d[i].h);
	for (int i=1;i<=n;i++)
		read(d[i].a),d[i].id=i;
	sort(d+1,d+n+1,cmp);
	int x;
	for (int i=1;i<=n;i++) {
		x=d[i].id;
		dp[x]=query(x-1)+d[i].a;
		add(x,dp[x]);
		ans=max(ans,dp[x]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5760
import java.util.*;
public class Main {
  
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X = sc.nextInt();
    int[] L = new int[N+1];
    for (int i = 1; i <= N; i++) {
      L[i] = sc.nextInt();
    }

    int ans = N+1;
    int D = 0;
    for (int i = 2; i <= N+1; i++) {
      D = D + L[i-1];
      if (X < D) {
        ans = i-1;
        break;
      }
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	d := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		d[i] = nextInt(sc)
	}
	sort.Ints(d)
	r := d[n/2]   // 例えばn=4だったらn/2は2なので、真ん中の1個右
	l := d[n/2-1] // こっちは真ん中の1個左
	// 答えはl+1~rの間の個数 -> r-(l+1)+1 (== r-l)
	fmt.Println(r - l)
}


Measured memory_bytes: 1920
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#define MAX 1001

using namespace std;

int LCS(char *X, char *Y)
{
    int m = strlen(X);
    int n = strlen(Y);
    int  c[MAX][MAX] = {0};
    for (int i = 0; i <= m; i++)
    {
        c[0][i] = 0;
    }
    for (int j = 0; j <= n; j++)
    {
        c[j][0] = 0;
    }

    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (X[i - 1] == Y[j - 1])
            {
                c[i][j] = c[i - 1][j - 1] + 1;
            }
            else
            {
                if (c[i - 1][j] > c[i][j - 1])
                {
                    c[i][j] = c[i - 1][j];
                }
                else
                {
                    c[i][j] = c[i][j - 1];
                }
            }
        }
    }

    return c[m][n];
}

int main(int argc, char *argv[])
{
    char X[MAX], Y[MAX];
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%s", X);
        scanf("%s", Y);
        printf("%d\n", LCS(X, Y));
    }
    return 0;
}



Measured memory_bytes: 7140
N = int(input())

dp = list(range(0, N+1))

for i in range(1, N+1):
    for j in [6, 9]:
        for k in range(1, N):
            if 0 <= i-j**k:
                dp[i] = min(dp[i], dp[i-j**k]+1)
            else:
                break

print(dp[-1]) 

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

int n,q,a,b,p[200010],p0,x,c[200010],now;

int main(){
    cin>>n>>q;
    vector<vector<int>> g(n+1);
    for(int i=1;i<n;i++){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        cin>>p0>>x;
        p[p0]+=x;
    }
    queue<int> que;
    que.push(1);
    c[1]=1;
    while(que.size()){
        now=que.front();
        que.pop();
        for(int j=0;j<g[now].size();j++){
            if(c[g[now][j]]!=1){
                c[g[now][j]]=1;
                que.push(g[now][j]);
                p[g[now][j]]+=p[now];
            }
        }
    }
    cout<<p[1];
    for(int i=2;i<=n;i++)cout<<' '<<p[i];
    cout<<endl;
}


Measured memory_bytes: 16244
S = list(map(int, input()))

for case in range(8):
    ans = str(S[0])
    ans_val = S[0]
    case_tmp = case
    for i in range(3):
        if case_tmp % 2 > 0:
            ans_val += S[i + 1]
            ans += '+{}'.format(S[i + 1])
        else:
            ans_val -= S[i + 1]
            ans += '-{}'.format(S[i + 1])
        case_tmp >>= 1
    #
    if ans_val == 7: break
    else: continue
else:
    ans = 'kanipanman'

print(ans + '=7')

Measured memory_bytes: 3064
using System;

public class ITP1_11_B{
    public static void Main(){
        var values = Console.ReadLine().Split(' ');
        
        Dice dice = new Dice
        {
            Top = values[0],
            South = values[1],
            East = values[2],
            West = values[3],
            North = values[4],
            Bottom = values[5]
        };
        
        var q = int.Parse(Console.ReadLine());
        
        
        for (var i = 0; i < q; i++)
        {
            var question = Console.ReadLine().Split();
            var top = question[0];
            var front = question[1];
            
            while (dice.Top != top)
            {
                dice.RollToNorth();
                if (dice.Top == top)
                {
                    break;
                }
                dice.RollToWest();
                if (dice.Top == top)
                {
                    break;
                }
            }
            
            while (dice.South != front)
            {
                dice.RotateToRight();
            }
                
            Console.WriteLine(dice.East);
        }
    }
    
    class Dice
    {
        public string Top { get; set; }
        public string Bottom { get; set; }
        public string North { get; set; }
        public string South { get; set; }
        public string East { get; set; }
        public string West { get; set; }
        
        public void　RollToNorth()
        {
            string tmp = this.North;
            this.North = this.Top;
            this.Top = this.South;
            this.South = this.Bottom;
            this.Bottom = tmp;
        }
        
        public void　RollToSouth()
        {
            string tmp = this.South;
            this.South = this.Top;
            this.Top = this.North;
            this.North = this.Bottom;
            this.Bottom = tmp;
        }
        
        public void　RollToEast()
        {
            string tmp = this.East;
            this.East = this.Top;
            this.Top = this.West;
            this.West = this.Bottom;
            this.Bottom = tmp;
        }
        
        public void　RollToWest()
        {
            string tmp = this.West;
            this.West = this.Top;
            this.Top = this.East;
            this.East = this.Bottom;
            this.Bottom = tmp;
        }
        
        public void RotateToRight()
        {
            string tmp = this.North;
            this.North = this.West;
            this.West = this.South;
            this.South = this.East;
            this.East = tmp;
        }
        
        public void RotateToLeft()
        {
            string tmp = this.North;
            this.North = this.East;
            this.East = this.South;
            this.South = this.West;
            this.West = tmp;
        }
    }
}


Measured memory_bytes: 15924
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
  int n;
  cin >> n;
  int p[n+10];
  for(int i = 0; i < n; i++){
	cin >> p[i];
  }
  int ans = 1;
  int x = p[0];
	for(int j = 0; j < n; j++){
	  if(p[j] < x){
		x = p[j];
        ans++;
      }
    }

  cout << ans;
  
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define maxN 100
#define repeat(i, n) for(int i = 0; i < n; i++)

int
main(int argc, char *argv[])
{
  int n, s[maxN], t[maxN], k = 0, sum = 0;
  scanf("%d", &n);
  repeat(i, n){
    scanf("%d", &s[i]);
    if(s[i] % 10 != 0) t[k++] = s[i];
    sum += s[i];
  }

  int ans;
  if(k == 0) ans = 0;
  else if(sum % 10 != 0) ans = sum;
  else{
    int min = 100;
    repeat(i, k) min = (t[i] < min ? t[i] : min);
    ans = sum - min;
  }

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

  return 0;
}
   


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int maxv = 100005;

int main(){

    int N, M; cin >> N >> M;
    vector<vector<ll>> xyz(3, vector<ll>());
    rep(i,N){
        ll x, y, z; cin >> x >> y >> z;
        xyz[0].push_back(x);
        xyz[1].push_back(y);
        xyz[2].push_back(z);
    }
    
    ll ans = 0;
    rep(i, 1<<3){
        vector<ll> a;
        rep(j,N){
            ll tmp = 0;
            rep(k,3){
                if (i & (1<<k)) tmp += xyz[k][j];
                else tmp -= xyz[k][j];
            }
            a.push_back(tmp);
        }

        sort(a.begin(), a.end(), greater<ll>());

        ll total = 0;
        rep(i,M) total += a[i];

        ans = max(ans, total);
    }

    cout << ans << endl;
 }

Measured memory_bytes: 3644
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for an in range(a+1):
    for bn in range(b+1):
        for cn in range(c+1):
            if 500*an + 100*bn + 50 * cn == x:
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
 
 
int main(void){
    string s;
    cin>>s;
    if(s=="SUN")cout<<7;
    if(s=="MON")cout<<6;
    if(s=="TUE")cout<<5;
    if(s=="WED")cout<<4;
    if(s=="THU")cout<<3;
    if(s=="FRI")cout<<2;
    if(s=="SAT")cout<<1;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let (_n, _m) = {
        let mut ws = s.split_whitespace();
        let n: i32 = ws.next().unwrap().parse().unwrap();
        let m: i32 = ws.next().unwrap().parse().unwrap();
        (n, m)
    };
    let number = (_n * _m) % 2;
    let res = match number {
        0 => "Even",
        _ => "Odd",
    };
    println!("{}", res);
}

Measured memory_bytes: 4352
import collections
N = int(input())
d = [0]*N
route = [set() for i in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    route[u].add((v, w))
    route[v].add((u, w))
    d[u] += 1
    d[v] += 1
d = d.index(max(d))
q = collections.deque()
q.append((d, 0))

G = [0]*N

while(q):
    x, l = q.popleft()
    for v, w in route[x]:
        G[v] = w + l
        q.append((v, w+l))
        route[v].remove((x, w))
ans = [0]*N

for i in range(N):
    if i == d:
        continue
    if G[i] % 2 == 1:
        ans[i] = 1
for i in range(N):
    print(ans[i])


Measured memory_bytes: 55304
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(len(l)):
    right = i+1
    for left in range(i+1, len(l)):
        while right+1 < len(l) and l[right+1] < l[left] + l[i]:
            right += 1
        ans += right - left
        if right == left:
            right += 1

print(ans)


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

typedef long long ll;
ll lcm(ll a, ll b){
    ll pre_a = a;
    ll pre_b = b;
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return ll(pre_a*pre_b/b);
    //return b;
}

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = (b-a+1) - ((ll((b-b%c)/c) + ll((b-b%d)/d) - ll((b-b%lcm(c, d))/lcm(c, d))) - (ll((a-1-(a-1)%c)/c) + ll((a-1-(a-1)%d)/d) - ll((a-1-(a-1)%lcm(c, d))/lcm(c, d))));
//    cout << b-a+1 << endl;
//    cout << (ll((b-b%c)/c) + ll((b-b%d)/d) - ll((b-b%lcm(c, d))/lcm(c,d))) - (ll((a-1-(a-1)%c)/c) + ll((a-1-(a-1)%d)/d) - ll((a-1-(a-1)%lcm(c,d))/lcm(c,d))) << endl;
//
//    cout << "a-1 " << (ll((a-1-(a-1)%c)/c) + ll((a-1-(a-1)%d)/d) - ll((a-1-(a-1)%lcm(c,d))/lcm(c,d))) << endl;
//    cout << "a-1 " << (ll((a-1-(a-1)%c)/c)) << endl;
//    cout << "a-1 " << (ll((a-1-(a-1)%d)/d)) << endl;
//    cout << "a-1 " << (ll((a-1-(a-1)%lcm(c,d))/lcm(c,d))) << endl;
//    cout << (ll((b-b%c)/c) + ll((b-b%d)/d) - ll((b-b%lcm(c,d))/lcm(c,d))) << endl;

    cout << ans << endl;

//    ll a, b;
//    cin >> a >> b;
//    cout << lcm(a,b) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int N,s[100000];

int binarySearch(int key){
  int left=0;
  int right=N;
  int mid;

  while(left<right){
    mid=(left+right)/2;
    if(key==s[mid])return 1;
    if(key>s[mid])left=mid+1;
    else if(key<s[mid])right=mid;
  }
  return 0;
}

int main(){

  int i,key,N2,c=0;
  scanf("%d",&N);

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

  scanf("%d",&N2);
  i=0;    
  while(i!=N2){
    scanf("%d",&key);
    if(binarySearch(key))c++;
    i++;

  }

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


  return 0;
}


Measured memory_bytes: 2076
N,M = list(map(int,input().split()))
S =[0] * M
C =[0] * M
ans = 10**N + 1
cnt = 0

for i in range(M):
    S[i],C[i] = list(map(int,input().split()))

for i in range(10**(N-1),10**N):
    x = str(i).zfill(N+1)
    for j in range(M):
        if int(x[S[j]]) == int(C[j]):
            cnt += 1
    if cnt == M and ans > int(x) :
        ans = int(x)
    cnt  = 0

if M == 0 and N == 1:
    print(0)
elif N == 1  and 0 in C :
    print(0)
elif ans != 10**N + 1 :
    print(ans)
else :
    print(-1)


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

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

	int input_num;
	set <int> num_s;

	for (int i = 0; i < process_times; i++) {
		cin >> input_num;
		if (num_s.find(input_num) == num_s.end()) num_s.insert(input_num);
		else num_s.erase(input_num);
	}
	cout << num_s.size() << endl;

	return 0;
}

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

constexpr ll INF = ll(1e+18) + 1;

int main() {
    int N;
    int a[(int)1e+5] = {};
    int ans=0, buf;

    cin >> N;
    rep (i, N) {
        cin >> buf;
        a[buf]++;
    }

    int temp = a[0] + a[1] + a[2];
    ans = temp;
    rep(i, (int)1e+5-3) {
        temp = temp -a[i] + a[i+3];
        ans = max(ans, temp);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3976
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///using P = pair<int,int>;
///pow(x,n)
///cout << fixed << setprecision(桁数);
///string = to_string(数値)
///int = stoi(文字列)
///(int)(char-'0')
///string = itoa(int)
///円周率: M_PI

///0b:2進数 16進数

const unsigned int BIT_FLAG_0 = (1<<0);
const unsigned int BIT_FLAG_1 = (1<<1);
const unsigned int BIT_FLAG_2 = (1<<2);
const unsigned int BIT_FLAG_3 = (1<<3);
const unsigned int BIT_FLAG_4 = (1<<4);
const unsigned int BIT_FLAG_5 = (1<<5);
const unsigned int BIT_FLAG_6 = (1<<6);
const unsigned int BIT_FLAG_7 = (1<<7);

int main() {
    int l; int r; int d;
    cin >> l>>r>>d;
    int ans;
    if(l%d==0){
        ans=r/d-l/d+1;
    }
    else{
        ans=r/d-l/d;
    }
    cout << ans << endl;
}

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

int main() { 
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	int cnt = 1;
	int p = v[0];
	for (int i = 1; i < n; ++i) {
		p = max(p,v[i]);
		if (p == v[i]) {
			cnt++;
		}
	}
	cout << cnt;
	return 0; 
} 



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


int main()
{
	string t;
	cin >> t;
	t[5] = ' ';
	t[13] = ' ';
	cout << t << endl;
	return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };



int main()
{
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n-1);
	vector<int> buka(n-1,0);
	for(int i=0;i<n-1;i++)
	{cin >> a.at(i);
     buka.at(a.at(i)-1)++;}
     
    for(int i=0;i<n-1;i++)
	{cout << buka.at(i) << endl;}
     cout << "0" << endl;
    
  
}


Measured memory_bytes: 4840
N,Y = map(int, input().split())
for x in range(N+1):
    for y in range(N+1-x):
        z = N - x - y
        if (10000*x + 5000*y + 1000*z) == Y and 0 <= z <= 2000:
            print(x,y,z)
            exit()


print("-1 -1 -1")

Measured memory_bytes: 8872
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;
using namespace std;
map <string,int> m;
string s;
long long ans=0;
using namespace std;
int main()
{
    int n;
    cin >> n;
    while ( n--)
    {
        cin >> s;
        sort(s.begin(), s.end());
        ans += m[s]++;
    }
    cout << ans;
}


Measured memory_bytes: 11136
#include <stdio.h>

int main(void){
	int S, digit[4], i;
	scanf("%d", &S);
	for (i = 0; i < 4; i++){
		digit[i] = S % 10;
		S /= 10;
	}
	for (i = 0; i < 3; i++){
		if (digit[i] == digit[i+1]){
			printf("Bad\n");
			return 0;
		}
	}
	printf("Good\n");
	return 0;
}


Measured memory_bytes: 128
import math
n = int(input())
cities = [list(map(int, input().split())) for _ in range(n)]

n_fact = math.factorial(n)
n1_fact = math.factorial(n-1)
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += ((cities[i][0]-cities[j][0])**2+(cities[i][1]-cities[j][1])**2)**0.5*n1_fact
print(ans/n_fact*2)


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	while (1) {
		double q;
		cin >> q;
		if (q == -1)
			break;
		double x = q / 2;
		while (fabs(pow(x, 3) - q) >= 0.00001 * q) {
			x = x - (pow(x, 3) - q) / (3 * pow(x, 2));
		}
		cout << fixed << setprecision(6) << x << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using p  = pair<int, int>;
using vec_int = vector<int>;
using vec_str = vector<string>;
#define INF (1<<29)
ll ans = 0;

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

void debug_input(vec_str& argv)
{
    // デバッグ用引数読み込み
    ifstream file("./input.txt");
    string str;
    while( getline(file, str) ) {
        argv.push_back(str);
    }
}

void debug_split_string(const string& str, vec_str& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        v.push_back(buf);
    }
}

void debug_split_int(const string& str, vec_int& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        istringstream ss(buf);
        int temp;
        ss >> temp;
        v.push_back(temp);
    }
}

int main()
{
    int K = 0;
	cin >> K;
	int A, B;
	cin >> A >> B;

    
    for(int i = A; i <= B; ++i) {
        if( i % K == 0 ){
            cout << "OK" << endl;
            return 0;
        }
    }
    
    cout << "NG" << endl;
        
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  long long n;
  cin >> n;
  queue<long long> q;
  for (long long i = 1; i < 10; ++i) q.push(i);
  for (long long i = 1; i <= n; ++i) {
    long long v = q.front();
    q.pop();
    if (i == n) {
      cout << v << '\n';
      break;
    }
    if (v % 10 != 0) q.push(10 * v + v % 10LL - 1LL);
    q.push(10 * v + v % 10);
    if (v % 10 != 9) q.push(10 * v + v % 10LL + 1LL);
  }
}

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

int main( void )
{
  int N;
  cin >> N;
  vector<int> A( N + 1 );
  int Alice = 0;
  int Bob = 0;
  
  for( int i = 0; i < N; i++ )
    cin >> A.at( i );

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

  for( int i = 0; i < ( N + 1 ) / 2; i++ ) {
    Alice += A.at( 2 * i );
    Bob += A.at( 2 * i + 1 );
  }

  cout << Alice - Bob << endl;
}
    

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int S, W;
  cin >> S >> W;
  if (S <= W)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
  return 0;
}


Measured memory_bytes: 3652
inputText1 = input()
# inputText1 = "sippau"
textList = list(inputText1)
# print(textList)
# ['s', 'i', 'p', 'p', 'u', 'u']
flg = False
if textList[2] == textList[3]:
    if textList[4] == textList[5]:
        flg = True

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


Measured memory_bytes: 2940
N=int(input())
A=list()
B=list()
C=list()
DP_A=[0]
DP_B=[0]
DP_C=[0]
for i in range(N):
    a,b,c=input().split()
    A.append(int(a))
    B.append(int(b))
    C.append(int(c))
for i in range(1,N+1):
    if DP_B[i-1] + A[i-1] > DP_C[i-1] + A[i-1]:
        DP_A.append(DP_B[i-1] + A[i-1])
    else:
        DP_A.append(DP_C[i-1] + A[i-1])

    if DP_C[i-1] + B[i-1] > DP_A[i-1] + B[i-1]:
        DP_B.append(DP_C[i-1] + B[i-1])
    else:
        DP_B.append(DP_A[i-1] + B[i-1])

    if DP_A[i-1] + C[i-1] > DP_B[i-1] + C[i-1]:

        DP_C.append(DP_A[i-1] + C[i-1])
    else:
        DP_C.append(DP_B[i-1] + C[i-1])
print(max(DP_A[N], DP_B[N], DP_C[N]))


Measured memory_bytes: 26916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        String list = Console.ReadLine();
        int N = int.Parse(Console.ReadLine());
        bool isReversed = false;
        StringBuilder headList = new StringBuilder();
        StringBuilder tailList = new StringBuilder();
        for (int i = 0; i < N; i++) {
            string[] input = Console.ReadLine().Split();
            int T = int.Parse(input[0]);
            if (T == 1) { isReversed = !isReversed; }
            else if (T == 2) {
                int F = int.Parse(input[1]);
                if ((F == 1&&!isReversed)||(F==2&&isReversed)) { headList.Append(char.Parse(input[2])); }
                else  { tailList.Append(char.Parse(input[2])); }
            }
        }
        var head = (isReversed) ? tailList.ToString() : headList.ToString();
        head = new string(head.Reverse().ToArray());
        var tail = (isReversed) ? headList.ToString() : tailList.ToString();
        if (isReversed) list = new string(list.Reverse().ToArray());

        var answer = head + list + tail;
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 20540
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if(A1 + A2 +A3 >= 22) puts("bust");
    else puts("win");
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
 


int main()
{
	//ifstream cin("input.txt");
	ll n;
	vi a(5);
	cin>>n;
	rep(i,0,4)
	{
		cin>>a[i];
	}

	int min_idx = min_element(a.begin(), a.end()) - a.begin();
	if(a[min_idx] >= n)
		cout<<5;
	else
		cout<<(ll)ceil((long double)n/a[min_idx]) + (4 - min_idx) + min_idx;
	
	

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll maxn = 1e6 + 7;
const ll mod = 1e9 + 7;
const int maxx = 1005;
ll q, t, n, m, k, ans, mx , a[maxn], b[maxx][maxx], c[maxn];
priority_queue<ll> pr;
string s, ss[maxn], str, s1, s2;
map<ll, ll> mp;

void bak(ll i, ll tong)
{
    if(i > n)
    {

        //cout << k <<" ";
        q = 1;
        for(int l = 1; l <= m; l ++)
        {
            if(c[l] < k)
            {
                //cout << c[j]<<" ";
                q = 0;
                break;
            }
        }

        if(q == 1)ans = min(ans, tong);
        return;
    }
    else
    {
        for(int j = 0; j <= 1; j ++)
        {
            if(j == 0)
            {
                bak(i + 1, tong);
            }
            else
            {
                for(int l = 1; l <= m; l ++)
                    {
                        c[l] += b[i][l];
                    }
                tong += a[i];
                bak(i + 1, tong);
                tong -= a[i];
                for(int l = 1; l <= m; l ++)
                    {
                        c[l] -= b[i][l];
                    }
            }
        }
    }
}
void sol()
{
    cin >> n >> m >> k;
    ans = 1e16;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        for(int j = 1; j <= m; j ++)
        {
            cin >> b[i][j];
        }
    }
    bak(1, 0);
    if(ans == 1e16)cout << -1;
    else cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    sol();
}


Measured memory_bytes: 34916
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ans = 0;
    cin >> n;
    vector<int> a(n);
    cins(all(a));
    int k = 200;
    rep(i,n){
        ans += a[i];
        if (a[i]%10) chmin(k,a[i]);
    }
    if (ans%10){
        PRINT(ans);
    }
    else{
        if (k == 200){
            PRINT(0);
        }
        else{
            PRINT(ans-k);
        }
    }
}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val (n, m) = readListOfInt()
    
    val x = (1900 * m + 100 * (n - m)) * Math.pow(2.0, m.toDouble()).toInt()
    println(x)
    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)

fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


Measured memory_bytes: 38036
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

# A：時
# B：分
A, B, H, M = [int(x) for x in stdin.readline().rstrip().split()]


total_minute = H * 60 + M

tyosin = 6 * total_minute % 360
tanshin = 0.5 * total_minute % 360

kakudo = abs(tyosin - tanshin)

if kakudo > 180:
    kakudo = 360 - kakudo

C2 = A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudo))

print(math.sqrt(C2))

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

int N,a[101],ans,sum,na[101];

int abs(int v){return v>0?v:-v;}

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",&a[i]);
	for(int i=0;i<N;i++)sum+=a[i],na[i]=N*a[i];
	for(int i=1;i<N;i++)if(abs(na[ans]-sum)>abs(na[i]-sum))ans=i;
	printf("%d\n",ans);
	return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<Int> b(n + 1, 0);
    for (Int i = 0; i < n; i++) {
        b[i + 1] = b[i] + a[i];
    }
    map<Int, Int> mp;
    for (Int i = 0; i <= n; i++) {
        mp[b[i]]++;
    }
    Int res = 0;
    for (auto i : mp) {
        res += i.se * (i.se - 1) / 2;
    }
    dump(res);
    return 0;
}

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

const double eps = 1e-6;
 
int main(){
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  
  if(a1 + a2 + a3 >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  ll H, ans = 1;
  cin >> H;
  while (H > 0) {
    H /= 2;
    ans *= 2;
  }
  cout << ans - 1 << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

vector<ll> g[114514];
vector<ll> h[114514];
bool used[114514] = {};
ll d[114514];
void dfs(int from, int now, int cnt) {
	if (cnt == 0) {
		if (from != now) h[from].push_back(now);

		return;
	}
	for (int i = 0; i < g[now].size(); i++) {
		dfs(from, g[now][i], cnt - 1);
	}
	return;
}

int main() {
	IOS();
	int unko[26] = {};
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++) {
		unko[s[i] - 'A']++;
	}
	bool ok = true;
	for (int i = 0; i < 26; i++) {
		if (unko[i] != 0 && unko[i] != 2) ok = false;
	}
	dump(ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int i,sum;
    char x[1001];
    
    while(1){
        sum = 0;
        scanf("%s",x);
        if(x[0] == '0')break;
        for(i=0; x[i]!='\0'; i++){
            sum += (x[i] - '0');
        }
        printf("%d\n",sum);
    }
    return 0;
}



Measured memory_bytes: 2100
//ABC024 B問題
#include<iostream>
using namespace std;
int main(){
  long n,t,a,s,e,ans=0;
  cin>>n>>t;
  cin>>s;
  e=s+t;
  for(int i=1;i<n;i++){
    cin>>a;
    if(a<=e)e=a+t;
    else ans+=(e-s),s=a,e=s+t;
  }
  ans+=(e-s);
  cout<<ans<<endl;
  return 0;
}

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

#define ll long long
#define M 1000000007
using namespace std;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
	int n,m;
    cin>>n;int arr[n+1]={ 0 };
    long long sum=0,prod=1;
    for(int i=0;i<n-1;i++)
    {
        cin>>m;
        arr[m]++;
    }
    for(int i=1;i<=n;i++)
    {
         cout<<arr[i]<<"\n";
    }
    
    
}

Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	float a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	if(n==1){
		cout<<a[0]<<endl;
		return 0;
	}
	double c=(a[0]+a[1])/2;
	for(int i=2;i<n;i++){
		c=(c+a[i])/2;
	}
	cout<<c<<endl;
}

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

const int MAXN = 1e4+4;
const int MAXD = 1e2+2;
const int MOD = 1e9+7;


int mem[MAXN][MAXD][2];
bool solved[MAXN][MAXD][2];
char C[MAXN];
int d, n;

int dp(int x, int sum, bool less) {
  if (x == n) return sum == 0;
  int &ret = mem[x][sum][less];
  if (solved[x][sum][less]) return ret;
  solved[x][sum][less] = 1;
  
  int k = less == 0 ? C[x] - '0' : 9;
  for (int i = 0; i <= k; ++i) {
    ret = (ret + dp(x+1, (sum+i) % d, less || (i < (C[x] - '0')))) % MOD;
  }

  return ret;
}

int main() {
  scanf("%s%d", C, &d);
  n = strlen(C);
  printf("%d\n", (dp(0, 0, 0)-1+MOD) % MOD);
  return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int N, A[MAX], dp[MAX];
int main(){
    memset(dp, 0x3f, sizeof(dp));
    scanf("%d", &N);
    for(int i = 1; i <= N; i++){
        scanf("%d", A + i);
    }
    dp[1] = 0;
    dp[2] = abs(A[2] - A[1]);
    for(int i = 3; i <= N; i++){
        dp[i] = min(dp[i], dp[i - 2] + abs(A[i] - A[i - 2]));
        dp[i] = min(dp[i], dp[i - 1] + abs(A[i] - A[i - 1]));
    }
    printf("%d\n", dp[N]);
    return 0;
}


Measured memory_bytes: 1024
object Main{
  def main(args:Array[String]):Unit={
    var NT =readLine.split(" ").map(x => x.toInt)
    var res = scala.Int.MaxValue
    for(i <- 0 until NT(0)){
      var tmp = readLine.split(" ").map(x => x.toInt)
      if(NT(1)>=tmp(1)) res=scala.math.min(res,tmp(0))
    }
    if(res==scala.Int.MaxValue) println("TLE")
    else println(res)
  }
}

Measured memory_bytes: 25528
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll getinv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	int a=read(),b=read(),c=read(),n=read(),m=read(); ll ans=0;
	if (2*c<a+b){
		int x=min(n,m),y=max(n,m);
		ans=2ll*x*c;
		if (y==n) ans+=(ll)(y-x)*a; else ans+=(ll)(y-x)*b;
		ans=min(ans,2ll*y*c);
	} else{
		ans=(ll)a*n+(ll)b*m;
	}
	cout<<ans<<endl;
	return 0;
}
// sample data:
/*

*/

// rest:
/*

*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
int main() {
	int a, b,c,d;


	std::cin >> a >> b >> c >> d;
	if (a*b - c*d >= 0) {
		std::cout << a*b << std::endl;
	}
	else {
		std::cout << c*d << std::endl;
	}
}

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,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int a,b;
    cin>>a>>b;
    if (a<10&&b<10&&0<a&&0<b)
        cout<<a*b<<endl;
    else
        cout<<-1<<endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC target("sse,sse2,sse3,sse4.1,sse4.2,popcnt,abm,mmx,avx")
#pragma comment(linker,"/STACK:102400000,102400000")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
#define re register
using namespace std;
typedef long long ll;
typedef double db;
const ll inf=2e9,N=2001001,MAX=2001;
inline void read(register ll &ret)
{
    ret=0;register ll pd=0;register char c=getchar();
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c^48);c=getchar();}
    ret=pd?-ret:ret;
}
ll a,b; 
int main()
{
	read(a);
	read(b);
	printf("%lld\n",max(a-(b<<1),0ll));
	exit(0);
}


Measured memory_bytes: 256
def solve():
    ans = 0
    N, M = map(int, input().split())
    lis = [1]*N
    lis[0] = -1 #赤が入っている可能性があればマイナス
    for _ in range(M):
        x,y = map(int, input().split())
        x -= 1
        y -= 1
        if lis[x]<0:
            lis[y] = -(abs(lis[y])+1)
            lis[x] += 1
        else:
            if lis[y]==0:
                lis[y] = 1
            else:
                lis[y] = (abs(lis[y])+1)*lis[y]//abs(lis[y])
            lis[x] -= 1
    ans = sum(map(lambda x:x<0,lis))
    return ans
print(solve())

Measured memory_bytes: 9800
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

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

    s64 n;
    cin >> n;

    string s;
    s64 nl, nr;
    s64 ncl, ncr;
    nl = nr = ncl = ncr = 0;
    vector< pair<int, P> > nc;
    rep (i, n)
    {
        cin >> s;
        s64 l, r;
        l = r = 0;
        stack<char> st;
        rep (j, s.size())
        {
            if (!st.empty() && (st.top() == '(' && s[j] == ')'))
            {
                --r;
                st.pop();
            }
            else
            {
                if (s[j] == ')') ++l;
                else ++r;
                st.push(s[j]);
            }
        }
        if (l == 0) nr += r;
        else if (r == 0) nl += l;
        else nc.emplace_back(r - l, P{-l, r});
    }

    sort(nc.begin(), nc.end(), greater< pair<int, P> >());
    rep (i, nc.size())
    {
        nr += nc[i].second.first;
        if (nr < 0)
        {
            cout << "No\n";
            return 0;
        }
        nr += nc[i].second.second;
    }

    if (nr != nl)
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
    }

    return 0;
}



Measured memory_bytes: 6292