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

typedef long long ll;
typedef unsigned long long ull;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

using namespace std;

int main() {

	int n;
	cin >> n;

	int a[n];
	pair<double, double> l[n];

	int k = 1;

	double x, y;
	rep(i, n) {
		cin >> x >> y;
		l[i] = make_pair(x, y);
		a[i] = i;

		k *= i + 1;
	}

	double sum = 0;

	do {
		rep(i, n - 1) {
			pair<double, double> mp = l[a[i]];
			pair<double, double> np = l[a[i + 1]];
			sum += sqrt( pow(mp.first - np.first, 2) + pow(mp.second - np.second, 2));
		}
		
	} while(next_permutation(a, a+n));

	double ans = sum / k;
	cout << std::fixed << std::setprecision(15) << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e5 + 5;
int k[MAXN];

int largest(int a, int b){
	return (a<b)?b:a;
}

int main() {
	string s, t;
	cin >> s;
	for(int i = 0; i < s.length(); ++i){
		if(s[i] == 'B'){
			if(!t.empty()){
				t.pop_back();
			}
		}
		else{
			t.push_back(s[i]);
		}
	}
	cout << t << endl;

    return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  int i;
  rep(i,n)cin>>a[i];
  vector<int> sum(n+1,0);
  rep(i,n)sum[i+1]=(sum[i]+a[i])%m;
  map<int,int> maps;
  ll ans=0;
  maps.insert(make_pair(0,1));
  rep(i,n)
  {
    auto it = maps.find(sum[i+1]);
    if(it!=maps.end())
    {
      int ch=maps[sum[i+1]];
      ans+=ch;
      maps[sum[i+1]]=ch+1;
    }
    else
    {
      maps.insert(make_pair(sum[i+1],1));
    }
  }
  cout<<ans<<endl;
}


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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  long long d=max(a,max(b,c));
  long long e=min(a,min(b,c));
  long long f=a+b+c-d-e;
  if(d%2==0){
    cout << 0 << endl;
  }
  else{
    cout << e*f << endl;
  }
}
  


Measured memory_bytes: 3520
a=list(input())
b=list(input())
c=list(input())
cards=[a,b,c]
name=["a","b","c"]
now=0
while(True):
    if(len(cards[now])==0):
        print(name[now].upper())
        break
    else:
        card=cards[now].pop(0)
        now=name.index(card)


Measured memory_bytes: 3060
from collections import deque

di_lst = []
N, U, V = map(int, input().split())
edges = {tuple(map(int, input().split())) for i in range(N - 1)}

stack = deque()


def BFS(X, edges, N):
    roots = [set() for _ in range(N + 1)]
    for a, b in edges:
        roots[a].add(b)
        roots[b].add(a)
    dist = {}
    stack = deque()
    stack.append(X)
    dist[X] = 0
    while stack:
        parent = stack.pop()
        for child in roots[parent]:
            if not child in dist:
                dist[child] = dist[parent] + 1
                stack.append(child)
    return dist


U_dist = BFS(U, edges, N)
V_dist = BFS(V, edges, N)

ans = 0
for i in range(1, N + 1):
    u, v = U_dist[i], V_dist[i]
    if u < v:
        ans = max(v - 1, ans)
print(ans)


Measured memory_bytes: 68252
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

#define dp_size 8010

int dp[dp_size];

int main() {
  string S; int X, Y; cin >> S >> X >> Y;
  int N = S.size();
  int I = 0;
  int sx = 0, sy = 0;
  vector<int> xv, yv;
  for (; I < N && S[I] == 'F'; I++) X--;
  X = abs(X); Y = abs(Y);
  while (I < N) {
    int x = 0, y = 0;
    for (I++; I < N && S[I] == 'F'; I++) y++;
    for (I++; I < N && S[I] == 'F'; I++) x++;
    if (x > 0) { xv.push_back(x); sx += x; }
    if (y > 0) { yv.push_back(y); sy += y; }
  }
  if ((X+sx)%2 != 0 || (Y+sy)%2 != 0) { cout << "No" << endl; return 0; }
  for (int i = 1; i < dp_size; i++) dp[i] = 0;
  dp[0] = 1;
  for (int xv_e : xv) {
    for (int i = dp_size-1-xv_e; i >= 0; i--) dp[i+xv_e] += dp[i];
  }
  if ((X+sx)/2 < dp_size && dp[(X+sx)/2] == 0) { cout << "No" << endl; return 0; }
  for (int i = 1; i < dp_size; i++) dp[i] = 0;
  dp[0] = 1;
  for (int yv_e : yv) {
    for (int i = dp_size-1-yv_e; i >= 0; i--) dp[i+yv_e] += dp[i];
  }
  if ((Y+sy)/2 < dp_size && dp[(Y+sy)/2] == 0) { cout << "No" << endl; return 0; }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=2e5+5;
long long k,n;
long long a[maxn],maxx=-1;
int main(){
	scanf("%lld%lld",&k,&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=2;i<=n;i++){
		long long tmp=a[i]-a[i-1];
		if(tmp>maxx){
			maxx=tmp;
		}
	}
	if(a[1]+k-a[n]>maxx)
		maxx=a[1]+k-a[n];
	printf("%lld",k-maxx);
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;

const int MOD = 1e9 + 7;
const int MAX = 2 * 10e5 + 1;

template<typename T>
T modPow(T x, T n, const T &mod){
    T res = 1;
    while(n > 0){
        if(n & 1) (res *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1; // nを1bit左にずらす
    }
    return res;
}

V<ll> finv, inv, Com;
void COMinit(){
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    ll res = 1;
    for(int i = n; i >= n - k + 1; i--){
        res = res * i % MOD;
    }
    return res * finv[k] % MOD;
}


int main() {
    ll n, a, b; cin >> n >> a >> b;
    finv.resize(MAX);
    inv.resize(MAX);
    COMinit();

    ll ans = (modPow<ll>(2, n, MOD) - 1 - COM(n, a) - COM(n, b)) % MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 31616
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] li = new int[n+1];
        for(int i = 0; i < m; i++){
            li[sc.nextInt()]++;
            li[sc.nextInt()]++;
        }
        for(int a : li){
            if(a % 2 != 0){
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 43088
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    cin >> s;

    string t = "ACGT";
    vector<int> ans = {0};
    rep(i, SZ(s)){
        bool ng = true;
        rep(j, 4){
            if(s[i] == t[j]){
                ng = false;
            }
        }
        if(ng){
            ans.push_back(0);
        }else{
            ans.back()++;
        }
    }
    cout << *max_element(ALL(ans)) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	int[] a = new int[n];
      	for(int i=0; i<n; i++){
        	a[i] = scan.nextInt();
        }
      	int count = 0;
      	while(true){
      	  boolean bool = false;
          for(int an: a){
              if(an % 2 != 0){
                  bool = true;
              }
          }
          if(bool){break;}
      	  for(int i=0; i<n; i++){
          	a[i] /= 2;
      	  }
          count++;
        }
      	System.out.println(count);
    }
}


Measured memory_bytes: 36140
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let line = get_input();
    let mut split = line.split_whitespace();
    let a:u64 = split.next().unwrap().parse().unwrap();
    let b:u64 = split.next().unwrap().parse().unwrap();
    let t:u64 = split.next().unwrap().parse().unwrap();

    let mut ans = 0;

    for i in 1..t+1 {
        if i % a == 0 {
            ans += b;
        }
    }

    println!("{}", ans);
}

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


int main(){
    long long w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << w * h / 2.0 << " ";
    if (x == w / 2.0 && y == h / 2.0){
        cout << "1" << endl;
    }
    else {
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	vector<int> a(N, 0);
	int rec = 0;
	int Max = 0;
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == S[i + 1]) {
			rec++;
		}
		else {
			a[i] = rec;
			Max = max(Max, rec);
			rec = 0;
		}
	}
	if (rec > 0) {
		a[N - 1] = rec;
		Max = max(Max, rec);
	}
	for (int i = 0; i < N; i++) {
		if (a[i] == Max) {
			cout << S[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 10400
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int x;
	cin >> x;
	cout << x*x*x << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define xx first
#define yy second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const int N=3e5+10;
const int M=1e6+10;
int n;
char s[N];

bool check(int l,int r){
	for(int i=l,j=r;i<=j;i++,j--) if(s[i]!=s[j]) return false;
	return true;
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if(check(1,n)&&check(1,n/2)&&check(n/2+2,n)) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

bool war(const vector<int>& x, const vector<int>& y){
    for(int z=-100;z<=100;z++){
        bool hassei = true;
        for(int i=0;i<x.size();i++){
            if(x[i] >= z) hassei = false;
        }
        for(int i=0;i<y.size();i++){
            if(y[i] < z) hassei = false;
        }
        if(hassei) return false;
    }
    return true;
}

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> x(n+1), y(m+1);
    cin >> x[0] >> y[0];
    for(int i=0;i<n;i++) cin >> x[i+1];
    for(int i=0;i<m;i++) cin >> y[i+1];
    
    if( war(x,y) ){
        cout  <<"War"<< endl;
    } else {
        cout  <<"No War"<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int *buildFail(char *p) {
  int m = strlen(p);
  int *fail = new int[m+1];
  int j = fail[0] = -1;
  for (int i = 1; i <= m; ++i) {
    while (j >= 0 && p[j] != p[i-1]) j = fail[j];
    fail[i] = ++j;
  }
  return fail;
}
int match(char *t, char *p, int *fail) {
  int n = strlen(t), m = strlen(p);
  int count = 0;
  for (int i = 0, k = 0; i < n; ++i) {
    while (k >= 0 && p[k] != t[i]) k = fail[k];
    if (++k >= m) {
      ++count; // match at t[i-m+1 .. i]
      k = fail[k];
    }
  }
  return count;
}


int main() {
  int n;
  while(cin >> n,n) {
    string s = "I";
    REP(i,n)
      s += "OI";
    char str[s.size()+1];
    strcpy(str, s.c_str());
    int m;
    cin >> m;
    char t[m+1];
    cin >> t;
    cout << match(t,str,buildFail(str)) << endl;
  }
}

Measured memory_bytes: 1864
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        String line=sc.next();
        char first=line.charAt(0);
        char last=line.charAt(line.length()-1);
        int mannaka=line.length()-2;
        System.out.println(first+""+mannaka+""+last);
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String z = sc.next();
		if (z.length() > k) {
			System.out.println(z.substring(0, k) + "...");
		}else {
			System.out.println(z);
		}
	}
}


Measured memory_bytes: 38632
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int n;
  while(cin >> n){
    vector<LLI> a(n); cin >> a;

    LLI ans = LLONG_MAX;

    LLI s = accumulate(ALL(a), 0LL);
    LLI t = 0;
    REP(i,n-1){
      t += a[i];

      chmin(ans, abs(t - (s-t)));
    }


    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
//
//  main.cpp
//  B
//
//  Created by 黄道煜 on 2018/7/14.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;

int t;
LL a, b, c, d;

LL gcd(LL x, LL y)
{
    if(x==0) return y;
    return gcd(y%x, x);
}

int main()
{
    scanf("%d", &t);
    for(int i=1; i<=t; i++)
    {
        scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
        if(a<b || d<b) {printf("No\n"); continue;}
        if(c>=b) {printf("Yes\n"); continue;}
        LL g=gcd(b, d), s=a%b, temp=(c-s)/g+1;
        if(s+temp*g<b || c<s) printf("No\n");
        else printf("Yes\n");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

int f(int a){
    int ans=0;
    while(a>0){
        ans++;
        a=a%int(bitset<32>(a).count());    
    }
    return ans;
}

void solve(){
    int n,cnt=0;
    cin>>n;
    string x;
    cin>>x;
    for(int i=0;i<n;i++) cnt+=(x[i]=='1'?1:0);
    if(cnt==0){
        for(int i=0;i<n;i++) cout<<"1\n";
        return;
    }
    if(cnt==1){
        for(int i=0;i<n;i++){
            if(x[i]=='1') cout<<"0\n";
            else{
                if(i!=n-1 && x[n-1]!='1') cout<<"1\n";
                else cout<<"2\n";
            }
        }
    }
    else{
        vector<vector<int>> dp(3,vector<int>(n,0));
        vector<int> tot(3,0),div{cnt-1,cnt,cnt+1};
        for(int i=0;i<3;i++){
            for(int j=n-1;j>=0;j--){
                if(j==n-1) dp[i][j]=1%div[i];
                else dp[i][j]=(2*dp[i][j+1])%div[i];
                if(x[j]=='1') tot[i]=(tot[i]+dp[i][j])%div[i];
            }
        }
        for(int i=0;i<n;i++){
            if(x[i]=='0'){
                int curr=(tot[2]+dp[2][i])%div[2];
                cout<<1+f(curr)<<"\n";
            }
            else{
                int curr=(tot[0]+cnt-1-dp[0][i])%div[0];
                cout<<1+f(curr)<<"\n";
            }
        }
    }

}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

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

int main(){
    int X;
    cin >> X;
    
    //１の時は明らか
    if(X==1){
        cout << 1 << endl;
        return 0;
    }
    
    
    //２以上～３２までの探索でよいが，全探索する．
    int ans=0;
    for(int i=2; i<=32; i++){
        
        int j=2;
        while(pow(i,j)<=X){
            if(i*j <=X){
                int x = pow(i,j);
                ans = max(ans, x);
            }
            j++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	const string ok = "Yes", ng = "No";
	int a, b, c;
	a = b = c = 0;
	int n; cin >> n;
	for(int i = 0; i < n; i++) {
		int t ;
		cin >> t;
		if(t % 4 == 0)
			a++;
		else if(t % 2 != 0)
			b++;
		else
			c++;
	}
	if(a + !c >= b)
		cout << ok << endl;
	else
		cout << ng << endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define INF 0x3f3f3f3f
#define INFll 0x3f3f3f3f3f3f3f3f
#define y0 _lxybz_
#define y1 _ljmnzyzhhhoscartxdy_
typedef long double ld;
typedef long long ll;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define lo(x) ((x)&(-(x)))
#define trav(a, x) for (auto &a : x)
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
const ld Pi = 4*atan((ld)1);
template<class T> void chmin(T &a,const T&b) { a = min(a, b); }
template<class T> void chmax(T &a,const T&b) { a = max(a, b); }
namespace IO{
template<class T> inline void read(T&ret)
{
	ret=0; int f=1; char c=getchar();
	while(c<48||c>57){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	ret*=f;
}
template<class T> inline void prin(const T&ret)
{
	if(!ret){putchar(48);return;} static T o; o=ret;
	if(o<0){putchar('-');o=-o;}
	static int op[25],tt; tt=0;
	while(o){
		op[++tt]=o%10;
		o/=10;
	}
	for(int i=tt;i;--i)putchar(op[i]+48);
}
template<class T> inline void pri_(const T&ret)
{
	prin(ret);putchar(' ');
}
template<class T> inline void priE(const T&ret)
{
	prin(ret);putchar('\n');
}
}
using namespace IO;

#define N 100006
#define MO 
ll h,n,f[N];
struct node {
	ll w,p;
}A[N];
inline void _Sol_()
{
	read(h);read(n);F(i,1,n)read(A[i].w),read(A[i].p);
	F(i,1,20000)f[i]=INF;
	F(i,1,n){
		F(j,1,20000)if(A[i].w<=j){
			chmin(f[j],f[j-A[i].w]+A[i].p);
		}
	}
	ll Ans=INF;
	F(i,h,20000)chmin(Ans,f[i]);
	priE(Ans);
}

int main()
{
	int T=1; //read(T);
	while(T--)_Sol_();
}

Measured memory_bytes: 384
N,M = map(int,input().split())
a = [int(input()) for i in range(M)]

dp = [-float("inf")]*(N+1)
dp[0] = 1
dp[1] = 1

for i in a:
    dp[i] = 0

for i in range(2,N+1):
    if dp[i] == 0:
        continue
    dp[i] = dp[i-2] + dp[i-1]
    dp[i] = dp[i] % (10**9+7)

print(dp[N])


Measured memory_bytes: 7824
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int H, N;
vector<int> A, B;
ll ans;
int main() {
  cin >> H >> N;
  A = vector<int>(N);
  B = vector<int>(N);
  rep(i, N) cin >> A[i] >> B[i];
  vector<ll> dp(H+1, longinf);
  dp[H] = 0;
  rrep(h, H+1) {
    rep(i, N) {
      dp[max(0, h-A[i])] = min(dp[h]+B[i], dp[max(0, h-A[i])]);
    }
  }
  cout << dp[0] << endl;
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int s[11],c[11];
vector<int> v;

int main(void){
	int n,m,i,j,x;
	bool flag;
	cin >> n >> m;
	for(i=0; i<m; ++i){
		cin >> s[i] >> c[i];
		s[i] = n-s[i];
	}
	for(i=0; i<1000; ++i){
		x = i;
		flag = true;
		do{
			v.push_back(x%10);
			x /= 10;
		}while(x);
		if(v.l_ength()!=n){
			flag = false;
		}
		for(j=0; j<m; ++j){
			if(!flag){
				break;
			}
			if(v[s[j]]!=c[j]){
				flag = false;
				break;
			}
		}
		if(flag){
			cout << i << endl;
			return 0;
		}
		v.clear();
	}
	cout << "-1" << endl;
	return 0;
}


Measured memory_bytes: 256
a = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().strip().split())
    a[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in range(3):
        print(''.join(' {}'.format(a[b][f][r]) for r in range(10)))
    if b < 3:
        print('#'*20)

Measured memory_bytes: 6724
#include <stdio.h>
#include <stdlib.h>
int compare(const void*a,const void*b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{
    int n;
    scanf("%d",&n);
    long a[3*n];
    for(int i=0;i<3*n;i++)
    scanf("%ld",&a[i]);
    qsort(a,3*n,sizeof(long),compare);
    long ans=0;
    for(int i=3*n-1;i>n-1;i-=2){
        ans+=a[i-1];
    }
    printf("%ld",ans);
    return 0;
}


Measured memory_bytes: 4860
for i in range (0,100000000):
    txt = input("")
    txt1,txt2 = txt.split(" ")
    a = int(txt1)
    b = int(txt2)
    if(a==0&b==0):
        break
    for i in range(0,a):
        for j in range(0,b):
            print("#", end="")
        print("")
    print("")



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

signed main(void)
{
	int a, b, c, k;
	int ans = 0;
	cin >> a >> b >> c >> k;
	if (k < a)
		ans += k;
	else
	{
		ans += a;
		k -= a;
		if (k > b)
			ans -= (k - b);
	}
	cout << ans << endl;
	return 0;
}


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

int main() 
{
    // Get position: 
    // pos = find(v.begin(), v.end(), 1) - v.begin()
    int n, k;
    cin >> n >> k;
    n--; k--;
    cout << (n-1)/k+1;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
     
     
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		int[] c = new int[m];
		Node[] list = new Node[n];
		for(int i = 0; i < n; i++) {
			list[i] = new Node(n);
		}
		for(int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
			list[a[i]].to.add(new Edge(list[b[i]],c[i]));
			list[b[i]].ss[a[i]] = true;
			list[b[i]].to.add(new Edge(list[a[i]],c[i]));
		}
		int[] A = new int[n]; //most fast
		while(true) {
			boolean ok = true;
			IN:for(int i = 0; i < n; i++) {
				Node tmp = list[i];
				for(int j = 0; j < n; j++) {
					if(tmp.ss[j] && !tmp.as[j]) {
						ok = false;
						continue IN;
					}
				}
				for(int j = 0; j < tmp.to.size(); j++) {
					if(tmp.to.get(j).to.as[tmp.id]) continue;
					A[tmp.to.get(j).to.id] = Math.max(A[i] + tmp.to.get(j).cost,A[tmp.to.get(j).to.id]);
					tmp.to.get(j).to.as[tmp.id] = true;
				}
			}
			if(ok) break;
		}
		System.out.println(A[n-1]);
		
		
		
		
		
		
	}
	static class Node {
		boolean[] ss;
		boolean[] as;
		static int ID = 0;
		int id = ID++;
		ArrayList<Edge> to = new ArrayList<Edge>();
		ArrayList<Edge> dst = new ArrayList<Edge>();
		Node(int n) {
			ss = new boolean[n];
			as = new boolean[n];
		}
	}
	static class Edge {
		Node to;
		int cost;
		Edge(Node a, int cost) {
			this.to = a;
			this.cost = cost;
		}
	}
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> table(n,0);
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        table[a-1]++;
    }
    sort(table.begin(),table.end());
    //reverse(table.begin(),table.end());
    int sum=0;
    for(int i=0;i<n;i++){
        if(table[i]>0)sum++;
    }
    //for(int i=0;i<n;i++){
    //    cout << table[i] << " ";
    //}
    //cout << endl;
    int res=0;
    //cout << "sum:" << sum << endl;
    int cou=0;
    for(int i=0;i<n;i++){
        if(cou>=sum-k)break;
        if(table[i]>0){
            res+=table[i];
            cou++;
        }
    }

    cout << res << endl;
}


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

int main(){
	ll n; scanf("%lld",&n);
	ll cnt = 0;
	ll t = 0;
	
	for(ll i = 100; i < n; i += t){
		t = i / 100;
		cnt++;
	}

	cout << cnt << endl;
}



Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

i64 cup(i64 xxx, i64 yyy) {//切り上げ
	return (xxx + yyy - 1) / yyy;
}

//メモリ置き場
int n, m;


//inputします
void input() {
	cin >> n >> m;
}

//ライブラリ置き場

//main
int main() {
	input();
	vector<int> ans(n,-1);
	ff(i, 0, m) {
		int a, b;
		cin >> a >> b;
		if (ans[a - 1] != -1 && ans[a - 1] != b) {
			cout << -1 << endl;
			return 0;
		}
		ans[a - 1] = b;
	}
	if (ans[0] == -1){
      if(n==1)ans[0]=0;
      else ans[0]=1;
    }
	ff(i, 1, n) {
		if (ans[i] == -1)ans[i] = 0;
	}
	if (ans[0] == 0&&n!=1) {
		cout << -1 << endl;
		return 0;
	}
	ff(i, 0, n) {
		cout << ans[i];
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
int main() {
	int N, M;
	cin >> N >> M;
 
	vector<tuple<ll, ll, ll>> data(M);
 
	for (ll i = 0; i < M; ++i) {
		ll p, y;
		cin >> p >> y;
		data[i] = make_tuple(y, p, i);
	}
 
 
	sort(data.begin(), data.end());
 
	vector<ll> cnt(N + 1);
 
 
	vector<pair<ll, ll>> id(M);
 
	for (ll i = 0; i < M; ++i) {
		ll y, p, idx;
		tie(y, p, idx) = data[i];
		++cnt[p];
		id[idx] = make_pair(p, cnt[p]);
	}
 
	for (ll i = 0; i < M; ++i) {
		cout << setw(6) << setfill('0') << id[i].first;
		cout << setw(6) << setfill('0') << id[i].second << endl;
	}
	return 0;
}

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

ll mod = 1e9 + 7;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll extgcd(ll a, ll b, ll &x, ll &y) { ll d; return b == 0 ? (x = 1, y = 0, a) : (d = extgcd(b, a % b, y, x), y -= a / b * x, d); }
ll modinv(ll a, ll mod = 1e9 + 7) { ll x = 0, y = 0; extgcd(a, mod, x, y); return (x + mod) % mod; }
ll modpow(ll a, ll b, ll mod = 1e9 + 7) { ll r = 1; while(b) { if(b & 1) r = r * a % mod; a = a * a % mod; b >>= 1; } return r; }

struct Biconnected {
  int n;
  vector< vector<int> > g;
  vector<int> low, ord, used;
  vector< vector< pair<int, int> > > comps;
  int id = 0;
  vector< pair<int, int> > tmp;
  Biconnected(vector< vector<int> > g)
    : n(g.size()), g(g), low(n), ord(n), used(n) {
    for(int i = 0; i < n; i++) if(!used[i]) dfs(i);
  }
  private:
  void dfs(int i, int p = -1) {
    used[i] = 1;
    ord[i] = low[i] = id++;
    for(int j : g[i]) if(j != p) {
      pair<int, int> e(min(i, j), max(i, j));
      if(used[j]) {
        if(ord[i] > ord[j]) tmp.emplace_back(e);
        low[i] = min(low[i], ord[j]);
      } else {
        tmp.emplace_back(e);
        dfs(j, i);
        low[i] = min(low[i], low[j]);
        if(low[j] >= ord[i]) {
          comps.push_back({});
          while(1) {
            pair<int, int> ne = tmp.back();
            comps.back().emplace_back(ne);
            tmp.pop_back();
            if(e == ne) break;
          }
        }
      }
    }
  }
};

ll fact[201], inv[201];
ll C(ll n, ll r) {
  if(n < r) return 0;
  return fact[n] * inv[r] % mod * inv[n - r] % mod;
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  fact[0] = 1;
  for(int i = 1; i <= 200; i++) fact[i] = fact[i - 1] * i % mod;
  inv[200] = modinv(fact[200]);
  for(int i = 199; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
  int n, m, k; cin >> n >> m >> k;
  vector< vector<int> > g(n);
  for(int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  Biconnected bc(g);
  ll ans = 1;
  for(auto es : bc.comps) {
    set<int> nums; int edge = es.size();
    for(auto e : es) {
      nums.emplace(e.first);
      nums.emplace(e.second);
    }
    int num = nums.size();
    if(num <= 1) {
    } else if(num == 2) {
      ans = ans * k % mod;
    } else {
      if(num == edge) {
        ll res = 0;
        for(int j = 1; j <= edge; j++) res += modpow(k, gcd(j, edge), mod);
        res = res % mod * modinv(edge, mod) % mod;
        ans = res * ans % mod;
      } else {
        ans = C(k + edge - 1, edge) % mod * ans % mod;
      }
    }
  }
  cout << ans << endl;
}



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

int main(){
    ios_base::sync_with_stdio(0);
    int N;
    cin >> N;
    V.resize(N);
    for (int i = 0; i < N; i++){
        cin >> V[i];
    }
    vector <int> DP(N, 123456789);
    DP[0] = 0;
    DP[1] = DP[0] + abs(V[0] - V[1]);
    for (int i = 2; i < N; i++){
        DP[i] = min(DP[i-2] + abs(V[i] - V[i-2]), DP[i-1] + abs(V[i-1] - V[i]) );
    }
    cout << DP[N-1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ans = 0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(i&1 and x&1)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()


ll sum(int n);

void go(){
	int n,k;cin>>n>>k;
	int ans=0;
	while(n--){
		int x;cin>>x;
		if(x>=k) ans++;
	}
	cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 256
N=int(input())
F=[int(input().replace(' ', ''), 2) for i in range(N)]
P=[[int(j) for j in input().split()] for j in range(N)]
a=-10**10
for i in range(1,1024):
    a=max(a, sum([P[j][bin(i&F[j]).count('1')] for j in range(N)]))
print(a)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (N, M, X, Y) = readInputLine().split(" ").map {it.toInt()}
    
    val xs = readInputLine().split(" ").map {it.toInt()}.sortedDescending()
    val ys = readInputLine().split(" ").map {it.toInt()}.sorted()
    
    for (i in X + 1..Y) {
        if (xs.first() < i && i <= ys.first()) {
            println("No War")
            return
        }
    }
    println("War")
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main() {
  int a,c=1;
  cin>>a;
  vector<int> b(a);
  for(int i=0;i<a;i++)
    cin>>b[i];
  sort(b.begin(),b.end());
  for(int i=0;i<a;i++){
    if(b[i]<b[i+1])
      c+=1;
    }
  cout<<c<<endl;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
 
  cin >> N;
  cin >> S;

  int iTmp=0,total=0;
  for (int i=0;i<(N-1);i++){
    if (S.at(iTmp)==S.at(i+1)){
      S.at(i+1)='0';
      total=total+1;
    }else{
      iTmp=i+1;
    }
  }
  
  cout << N-total << endl;

}

Measured memory_bytes: 512
N, K = map(int, input().split())
S = list(input())

l = -1
r = -1

k = 0
while k < K:
    for i in range(1, N):
        #print(i, l, "l")
        if S[i] != S[i-1]:
            if l < 0:
                l = i
            else:
                #print("a", l, i)
                r = i
                for s in range(l, r):
                    if S[s] == "L":
                        S[s] = "R"
                    else:
                        S[s] = "L"
                l = -1
                r = -1
                k += 1
                if k == K:
                    break
    l = -1
    r = -1
    # elif i == N-1 and l >= 0:
    #     for s in range(l, N):
    #         if S[s] == "L":
    #             S[s] = "R"
    #         else:
    #             S[s] = "L"
    #     l = -1
    #     k += 1
    #     if k == K:
    #         break
    if l < 0:
        break
ans = 0
#print(len(set(S)), k, K)
if len(set(S)) == 2 and k < K:
    ans += 1
for i in range(1, N):
    if S[i] == S[i-1]:
        ans += 1
# print(S)
print(ans)


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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 100100100100100100;
const int mod = 1e9;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */
int n,m;
char arr[100][100];
int dp[100][100];

int dfs(int x, int y){
    if(arr[y][x] == '#' or y < 0 or n <= y or x < 0 or m <= x) return 1;
    if(dp[y][x] != 0) return dp[y][x];
    if(dfs(x + 1, y) == -1) return dp[y][x] = 1;
    if(dfs(x, y + 1) == -1) return dp[y][x] = 1;
    if(dfs(x + 1, y + 1) == -1) return dp[y][x] = 1;
    return dp[y][x] = -1;
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, ab, ax, by;
    cin >> a >> b >> ab >> ax >> by;

    int ans = 0;
    ans += min(a + b, ab * 2) * min(ax, by);
    
    int tmp = min(ax, by);
    ax -= tmp;
    by -= tmp;

    if(ax > 0){
        ans += min(a, ab * 2) * ax;
    }else{
        ans += min(b, ab * 2) * by;
    }

    print(ans);




    
    



    
    



 
    
    


    

    
   
    













}






    










    




    










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

int main() {
	vector<int> v(3);
	int temp;
	cin >> v[0] >> v[1] >> v[2];
	for(int i=0;i<2;++i) {
		for(int j=0;j<2-i;++j) {
			if ( v[j]>v[j+1] ) {
				temp = v[j];
				v[j]=v[j+1];
				v[j+1]=temp;
			}
		}
	}
	cout << v[0] << " " << v[1] << " " << v[2] << endl;
	return 0;
}

Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(String[] args)
    {
        var s = Console.ReadLine().ToCharArray();
        var ans = new List<char>();
        for (var i = 0; s.Length > i; i++)
        {
            if (i % 2 == 0 || i == 0)
            {
                ans.Add(s[i]);
            }
        }
        var res = new String(ans.ToArray());
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 26916
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
 
int main()
{
    int n, y, mod;

    cin >> n >> y;

    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= n;j++){
            mod = y -  (i * 10000 + j * 5000);
            if(mod % 1000 == 0 && i + j + mod / 1000 == n && i >= 0 && j >= 0 && mod/1000 >= 0){
                cout << i <<" "<< j << " "<<mod / 1000;

                return 0;
            }
            
        }
    }

    cout << "-1 -1 -1";

    return 0;
}

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

area = []
for i in range(K):
    L, R = map(int, input().split())
    area.append((L, R))

area.sort()
d = [0] * N
a = [0] * N


def func(pos):
    for l, r in area:
        if pos + l - 1 < N:
            a[pos + l-1] += d[pos]
        if pos + r < N:
            a[pos + r] -= d[pos]
    d[pos+1] = (d[pos] + a[pos]) % 998244353


d[0] = 1
a[0] = -1
for i in range(0, N-1):
    func(i)

print(d[N-1] % 998244353)


Measured memory_bytes: 24976
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;
const int INF = 1e18;

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int BA, XX, XA, BX, cnt;
    BA = XX = XA = BX = cnt = 0;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;

        if (s[0] == 'B' && s[s.size() - 1] == 'A')
            BA++;
        else if (s[0] != 'B' && s[s.size() - 1] != 'A')
            XX++;
        else if (s[0] == 'B')
            BX++;
        else
            XA++;

        for (int j = 0; j < s.size() - 1; j++)
        {
            if (s[j] == 'A' && s[j + 1] == 'B')
                cnt++;
        }
    }

    if (1 <= BA)
    {
        cnt += BA - 1;
        if (BX > 0 && XA > 0)
        {
            cnt += 2;
            cnt += min(BX, XA) - 1;
        }
        else if (BX == 0 && XA == 0)
        {
            //do nothing
        }
        else
        {
            cnt++;
        }
    }
    else
    {
        cnt += min(BX, XA);
    }

    cout << cnt << endl;
}

signed main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;

long long GCD(long long a, long long b)
{
	if (b == 0) {
		return a;
	}

	GCD(b, a%b);
}

bool IsPrime(long long n)
{
	if (n == 1 || n == 2) return true;
	if (n % 2 == 0) return false;

	for (int ni = 3; ni <= sqrt(n); ni += 2) {
		if (n % ni == 0) {
			return false;
		}
	}

	return true;
}

long long CntPrime(long long n)
{
	vector<long long> P(n + 1, 1);

	P[0] = 0;
	for (int ni = 2; ni <= sqrt(n); ni++) {
		for (int mi = 2; ni * mi <= n; mi++) {
			P[ni * mi] = 0;
		}
	}

	long long cnt = 0;
	for (int ni = 1; ni <= n; ni++) {
		if (n % ni == 0 && P[ni] > 0) {
			cnt++;
		}
	}

	return cnt;
}

int main()
{
	long long A, B;

	cin >> A >> B;

	//long long gcd = GCD(max(A, B), min(A, B));

	long long gcd;

	long long a, b,c;
	a = max(A,B);
	b = min(A,B);
	while (1) {
		if (b == 0) {
			gcd = a;
			break;
		}
		c = a;
		a = b;
		b = c % b;
	}

	if (gcd == 1) {
		std::cout << 1;
		return 0;
	}
	if (IsPrime(gcd)) {
		std::cout << 2;
		return 0;
	}

	/*
	vector<long long> P(gcd + 1, 1);

	P[0] = 0;
	for (int ni = 2; ni <= sqrt(gcd); ni++) {
		for (int mi = 2; ni * mi <= gcd; mi++) {
			P[ni * mi] = 0;
		}
	}
	*/


	vector<long long> PFs;
	PFs.push_back(1);

	long long ni = 2;
	long long tar = gcd;
	while (1) {
		
		/*
		if (IsPrime(tar)) {
			PFs.push_back(tar);
			break;
		}
		*/
		
		if (tar % ni == 0) {
			PFs.push_back(ni);
			while (tar % ni == 0) {
				tar /= ni;
			}
			if (tar == 1) break;

			if (IsPrime(tar)) {
				PFs.push_back(tar);
				break;
			}
		}
		ni++;
	}
	
	long long ans = PFs.size();
	//printf("%.9f", ans);
	std::cout << ans;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	ll d[n];
	rep(i, 0, n){
		cin >> d[i];
	}
	if(d[0] != 0){
		print(0)
		return 0;
	}
	sort(d, d+n);
	if(n > 2 && d[1] != 1){
		print(0)
		return 0;
	}
	
	ll ans = 1;
	ll itr = 1;
	ll cnt = 0;
	ll cnt_before = 1;
	rep(i, 1, n){
		if(d[i] > itr+1){
			print(0)
			return 0;
		}
		if(d[i] == itr+1){
			rep(j, 0, cnt){
				ans *= cnt_before;
				ans %= MOD;
			}
			cnt_before = cnt;
			cnt = 1;
			itr++;
		}
		else{
			cnt++;
		}
	}
	
	rep(j, 0, cnt){
		ans *= cnt_before;
		ans %= MOD;
	}
	print(ans)
	return 0;
}

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

int A, B;
string s;
set<int> set_;

int main(){
    cin >> A >> B;
    int woTax_min = B * 10;
    int woTax_max = B * 10 + 9;
    for (int i = woTax_min; i <= woTax_max; i++)
    {
        int a = (int)(i * 0.08);
        if (a == A) { cout << i; return 0;}
    }
    cout << "-1";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(void)
{
    char s[1001];
	int n,i;
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;i++){
	    if(s[i]=='A'||s[i]=='B'||s[i]=='C'){
		    s[i]=s[i]+23;
		}
		else {
		    s[i]=s[i]-3;
		}
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 2688