akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  } else
    return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){


}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  } else if(z->key < y-> key){
    y->left = z;
  } else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if (u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 20436
import java.util.*;

public class Main {
    static int max = 1000000;
    static long[] queue = new long[max];
    static int tail = 0; static int head = 0;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        for (int i=1;i<=9;i++)enqueue(i);
        for (int i=0;i<k-1;i++){
            long x = dequeue();
            if (x%10!=0)enqueue(10*x+(x%10)-1);
            enqueue(10*x+(x%10));
            if (x%10!=9)enqueue(10*x+(x%10)+1);
        }
        System.out.println(dequeue());
    }
    static void init(){head = 0; tail = 0;}
    static boolean isEmpty(){return (head==tail);}
    static boolean isFull(){return (head == (tail+1)%max);}
    static public void enqueue(long v){
        if (isFull()){
            System.out.println("error: queue is full.");
            return;
        }
        queue[tail++] = v;
        if (tail == max) tail = 0;
    }
    static public long dequeue(){
        if (isEmpty()){
            System.out.println("error: queue is empty");
            return -1;
        }
        long res = queue[head];
        ++head;
        if (head == max) head = 0;
        return res;
    }
}


Measured memory_bytes: 43392
from collections import defaultdict

H, W, N = map(int,input().split())
  
ans =[(H-2)*(W-2)]+[0]*9
blacks = defaultdict(int)
for i in range(N):
  a, b = map(int,input().split())
  for dx in [-1,0,1]:
    for dy in [-1,0,1]:
      if 2 <= a+dx <H and 2 <= b+dy <W:
        ans[blacks[(a+dx,b+dy)]]-=1
        ans[blacks[(a+dx,b+dy)]+1]+=1
      blacks[(a+dx,b+dy)]+=1
        
for i in range(10): print(ans[i])


Measured memory_bytes: 166868
#include <stdio.h>

char S[13];

int main()
{
	scanf("%s", S);
	for(int i=0; i<4; i++)
		printf("%c", S[i]);
	printf(" ");
	for(int i=4; i<12; i++)
		printf("%c", S[i]);
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int cost1, cost2, cost3, cost4, cost5;
  cost1 = A * X + B * Y;
  cost2 = A * max(X - Y, 0) + 2 * C * Y;
  cost3 = 2 * C * X + B * max(Y - X, 0);
  cost4 = 2 * C * max(X, Y);

  int ans = min({cost1, cost2, cost3, cost4});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    agc018a()
}

fun agc018a() {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    val aList = readLine()!!.split(" ").map { it.toLong() }.toLongArray()

    val max = aList.max()!!
    val gcd = aList.fold(aList.first()) { acc, l -> gcd(acc, l) }

    val answer = if (k <= max && k % gcd == 0L) "POSSIBLE" else "IMPOSSIBLE"

    println(answer)
}

private tailrec fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}


Measured memory_bytes: 52000
import itertools
import collections

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n = getint()
a = getints()

for i in range(n):
    a[i] -= i + 1

a = list(sorted(a))
mid = a[n//2]

res = 0
for i in range(n):
    res += abs(a[i]-mid)

print(res)

Measured memory_bytes: 89684
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
LL N,C;
priority_queue<tuple<LL,LL,LL>> prog;
 
LL ans = 0;
 
void solve(){
    vector<LL> finish_time(C+1,0);//チャンネルiの終了予定時刻をfinish_time[i]とする
    for(int time=1;time<=100000;time++){
        while(!prog.empty()){
            tuple<LL,LL,LL> p = prog.top();
            LL start = -get<0>(p);
            LL end = get<1>(p);
            LL channel = get<2>(p);
            if(start!=time) break;
            finish_time[channel] = end;
            prog.pop();
        }
        //時刻timeの時点で録画中のレコーダーの数
        LL counter = 0;
        for(int c=1;c<=C;c++){
            if(finish_time[c]>=time) counter++;
        }
        ans = max(ans,counter);
    }
}
 
int main(){
    cin >> N >> C;
    for(int i=0;i<N;i++){
        LL s,t,c;cin >> s >> t >> c;
        prog.push(tuple<LL,LL,LL>(-s,t,c));
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int cnt = 0;
int main()
{
    string s;
    cin >> s;
    string s2 = "CODEFESTIVAL2016";
    rep(i, 0, 16)
    {
        if (s[i] != s2[i])
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

    string str;
    int emp, a;
    
    cin >> emp >> a >> str;
    
    str.at(a - 1) = str.at(a - 1) -'A' +'a';
    
    cout << str << endl;

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( a == b ){
        cout << a + b << endl;
    } else {
        cout << max(a, b) * 2 - 1 << endl;
    }
    //*/
    
    //cout << c / a * b << endl;

    return 0; 
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int N, M;
vector<P> E[201010], EE[201010];
int vis[201010], col[201010];

string solve() {
    rep(i, N) if (!vis[i]) {
        col[i] = 0;
        vis[i] = 1;
        queue<int> que;
        que.push(i);
        while (!que.empty()) {
            int q = que.front();
            que.pop();
            for (P p : E[q]) {
                if (vis[p.fi]) {
                    if (col[q] + p.se != col[p.fi]) return "No";
                } else {
                    col[p.fi] = col[q] + p.se;
                    vis[p.fi] = 1;
                    que.push(p.fi);
                }
            }
            for (P p : EE[q]) {
                if (vis[p.fi]) {
                    if (col[q] - p.se != col[p.fi]) return "No";
                } else {
                    col[p.fi] = col[q] - p.se;
                    vis[p.fi] = 1;
                    que.push(p.fi);
                }
            }
        }
    }
    return "Yes";
}

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

    cin >> N >> M;
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        E[a].pb({b, c});
        EE[b].pb({a, c});
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 17664
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
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; }
const long long mod = 1e9 + 7;
ll dx[] = { 1,0 };
ll dy[] = { 0,1 };

int main() {

    ll N;

    cin >> N;

    ll ans = 0, j = 0, tmp = 2;

    if (N % 2 == 1) {
        ans = 0;
    }
    else {
        while (N > pow(5, j)) {
            j++;
        }
        rep(i, j) {
            tmp *= 5;
            ans += N / tmp;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3940
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	a[i]=0;
	for(int i=1;i<n;i++)
	{
		int b;
		cin>>b;
		a[b]++;
	}
	for(int i=1;i<=n;i++)
	cout<<a[i]<<endl;
	return 0;
} 

Measured memory_bytes: 4416
n=int(input())
a=[int(i) for i in input().split()]

cnt=[0]*8
count=0
for i in range(n):
    if a[i]>=1 and a[i]<=399:
        cnt[0]=1
    elif a[i]>=400 and a[i]<=799:
        cnt[1]=1
    elif a[i]>=800 and a[i]<=1199:
        cnt[2]=1
    elif a[i]>=1200 and a[i]<=1599:
        cnt[3]=1
    elif a[i]>=1600 and a[i]<=1999:
        cnt[4]=1
    elif a[i]>=2000 and a[i]<=2399:
        cnt[5]=1
    elif a[i]>=2400 and a[i]<=2799:
        cnt[6]=1
    elif a[i]>=2800 and a[i]<=3199:
        cnt[7]=1
    else:
        count+=1
min_ans=sum(cnt)

if count==0:
    min1=min_ans
elif min_ans==0:
    min1=1
else:
    min1=max(1,min_ans)
max1=min_ans+count
print(min1,max1)


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

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int h, w;
	cin >> h >> w;

	vector<string> s(h);
	for (int i = 0; i < h; i++) cin >> s[i];
	
	vector<int> di = { -1,0,1,0 };  //↑ ← ↓ →
	vector<int> dj = { 0,-1,0,1 };  //↑ ← ↓ →
	int ans = 0;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (s[i][j] == '#') continue;
			vector<vector<int>> dist(h, vector<int>(w, INT_MAX));
			queue<pair<int, int>> q;
			auto update = [&](int i, int j, int x)
			{
				if (dist[i][j] != INT_MAX) return;
				dist[i][j] = x;
				q.push(make_pair(i, j));
			};
			update(i, j, 0);
			while (!q.empty())
			{
				int i = q.front().first;
				int j = q.front().second;
				q.pop();
				for (int k = 0; k < 4; k++)
				{
					int ni = i + di[k];
					int nj = j + dj[k];
					if (ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
					if (s[ni][nj] == '#') continue;
					update(ni, nj, dist[i][j] + 1);
				}
			}
			for (int k = 0; k < h; k++)
			{
				for (int l = 0; l < w; l++)
				{
					if (dist[k][l] == INT_MAX) continue;
					ans = max(ans, dist[k][l]);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int n;
	cin>>n;
	int ans=0,tmp;
	for(int i=0;i<7;i++){
		tmp=pow(2,i);
		if(tmp<=n&&ans<tmp){
			ans=tmp;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main()
{
    int n, W, i, j, temp;
    scanf("%d", &n);
    scanf("%d", &W);
    int a[W + 1];
    int v[n];
    int w[n];
    for(i = 0; i < n; i++) { 
        scanf("%d", &v[i]);
        scanf("%d", &w[i]);
    }
    a[0] = 0;
    for(i = 1; i < W + 1; i++) { 
        a[i] = 0;
        for(j = 0; j < n; j++) { 
            if (i - w[j] >= 0 ) {
                temp = v[j]+ a[i - w[j]];
                if (a[i] < temp) {
                    a[i] =  temp;
                }
            }
        }
    }
    printf("%d\n", a[W]);
    return 0;
}

Measured memory_bytes: 2764
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int l=s.length();
	for(int i=0;i<l;i++){
		if(s[i]=='C')
		for(int j=i+1;j<l;j++){
			if(s[j]=='F'){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;
using u64 = std::uint_fast64_t;


void solve(void){

  int a;
  std::cin >> a;
  std::cout << a * a * a + a * a + a << std::endl;

}

int main(void){

  solve();

  return 0;
}



Measured memory_bytes: 3620
n,m = map(int,input().split())
qaw = [[0,0] for i in range(n)]
x = 0
y = 0
for i in range(m):
  p,s = input().split()
  p = int(p)-1
  if s == "AC":
    qaw[p][0] = 1
  elif qaw[p][0] == 0:
    qaw[p][1] += 1
for q in qaw:
  if q[0] == 1:
    x += 1
    y += q[1]
print(x,y)

Measured memory_bytes: 13172
#include<bits/stdc++.h>
#define lim 1001

using namespace std;
main()
{
    int n,q;
    cin>>n>>q;
    priority_queue <int> A[lim];
    while(q--)
    {
        int m,t;
        cin>>m;
        if(m==0)
        {
            int x;
            cin>>t>>x;
            A[t].push(x);
        }
        else if(m==1)
        {
            cin>>t;
            if(A[t].size()!=0)
            {
                cout<<A[t].top()<<endl;
            }
          //  cout<<*max_element(A[t].begin(),A[t].end())<<endl;

        }
        else
        {
            cin>>t;
            if(A[t].size()!=0)
            {
                A[t].pop();
            }
        }
    }

}



Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll,ll> vll;
typedef map<ll,ll> mll;
typedef set<ll> sll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair


ll n,m,ans;
ll a[200001];
ll d[200001];
int main() {
	cin>>n;
	for(ll i=1;i<=n;i++)
		cin>>a[i],d[i]=d[i-1]+a[i];
	ll pos=-1;
	for(ll i=1;i<=n;i++)
	{
		if(d[i]==d[n]/2 && d[n]%2==0)
		{
			cout<<0;
			return 0;
		}
		if(d[i]>d[n]-d[i])
		{
			pos=i;
			break;
		}
	}
	cout<<min(abs(d[pos]-(d[n]-d[pos])),abs(d[n]-d[pos-1]-d[pos-1]));
}

Measured memory_bytes: 3328
an, bn, m = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
min = a.min + b.min
m.times do
  x, y, c = gets.chomp.split(" ").map(&:to_i)
  sum = a[x-1] + b[y-1] - c
  min = min > sum ? sum : min
end
puts min

Measured memory_bytes: 19996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT32_MAX;

ll i,j;





int main(){
   ll A,B;
   cin>>A>>B;
   if(A*B%2)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  while (cin >> N) {
    vector<int> d(N + 1, 1), e(N + 1, 0);
    for (int p = 2; p <= N; p++) {
      if (d[p] != 1) continue;
      for (int kp = p; kp <= N; kp += p) {
        e[kp] = e[kp / p] + 1;
      }
      for (int kp = p; kp <= N; kp += p) {
        d[kp] *= e[kp] + 1;
        e[kp] = 0;
      }
    }
    int res = 0;
    for (int i = 1; i <= N; i += 2) {
      if (d[i] == 8) ++res;
    }
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;


int main(){
	long long int N, K, ans = 0;
	cin >> N >> K;
	vector<pair<long long int, long long int>>D(N);
	for( size_t i = 0; i < N; i++ ){
		cin >> D[i].first >> D[i].second;
		if( ( D[i].first | K ) == K ){
			ans += D[i].second;
		}
	}

	for( long long int i = 0; i <= 31; i++ ){
		if( ( K >> i ) % 2 == 1 ){
			long long int K_ = K;
			K_ >>= i;
			K_ <<= i;
			K_--;
			long long int memo = 0;
			for( long long int j = 0; j < N; j++ ){
				if( ( D[j].first | K_ ) == K_ ){
					memo += D[j].second;
				}
			}
			//cout << K_ << " " << memo << endl;
			ans = max(memo, ans);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1920
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)	
	sc.Scan()
	var R, _ = strconv.Atoi(sc.Text())

	if R < 1200 {
		fmt.Println("ABC")
	} else if R < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		
		if(t.length() == s.length()+1 && s.equals(t.substring(0, t.length()-1)))
		{
			System.out.println("Yes");
		}
		else System.out.println("No");

		
	}

}


Measured memory_bytes: 26912
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  int h, w;
  string mas[1005];
  cin >> h >> w;
  FOR(i,h) cin>>mas[i];
  bool x[105]={},y[105]={};
  FOR(i,105){
    x[i]=false;
    y[i]=false;
  }
  FOR(i,h){
    FOR(j,w){
      if(mas[i][j]=='#'){
        x[i]=true;
        y[j]=true;
      }
    }
  }
  FOR(i,h){
    if(x[i]){
      FOR(j,w){
        if(y[j]){
          cout <<mas[i][j];
        }
      }
      cout fin;
    }
  }
    
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
    int n, T;
    scanf("%d %d", &n, &T);
    int c[n], t[n];
    for(int i = 0; i < n; i++){
        scanf("%d %d", &c[i], &t[i]);
    }
    
    int mn = 10000;
    for(int i = 0; i < n; i++){
        if (t[i] <= T) {
            if (mn > c[i]) {
                mn = c[i];
            }
        }
    }
    if (mn == 10000){
        puts("TLE");
    }else{
        printf("%d\n", mn);
    }
}


Measured memory_bytes: 128
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		String S = nextString();

		long c=0;
		long ans = 0;
		for(int i=0;i<S.length();i++){
			if(S.charAt(i)=='I'){
				c++;
			}else{
				c--;
			}
			ans = Math.max(ans,c);
		}
		System.out.println(ans);
	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#include<stdio.h>
int main()
{
    int A1,A2,A3,T;
    scanf("%d%d%d",&A1,&A2,&A3);
    T=A1+A2+A3;
    if(1<=A1<=13,1<=A2<=13,1<=A3<=13){
    if(T>=22){
        printf("bust");
    }
    else{printf("win");}
    }
    
}

Measured memory_bytes: 2112
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int H, W;
int dp[1010][1010];
string G[1010];

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

	cin >> H >> W;
	rep(i, 0, H)cin >> G[i];
	dp[0][0] = 1;

	rep(i, 0, H)rep(j, 0, W)
	{
		if (G[i][j] == '#')continue;
		if (i - 1 >= 0 && G[i - 1][j] != '#')(dp[i][j] += dp[i - 1][j]) %= MOD;
		if (j - 1 >= 0 && G[i][j - 1] != '#')(dp[i][j] += dp[i][j - 1]) %= MOD;
	}

	cout << dp[H - 1][W - 1] << endl;

	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

int n, x;
string s;

int main(){

    cin >> n >> s;

    for(int i = 0; i < n-2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            x++;
        }
    }

    cout << x;



    

}

//g++ -std=c++14 comp.cpp -o b; ./b.exe

Measured memory_bytes: 256
def solve():
  N, K, C = map(int, input().split())
  workable = [i for i, s in enumerate(input()) if s=="o"]
  if len(workable) == K:
    return workable
  
  def to_left():
    prev = workable[-1]+C+1
    for x in reversed(workable):
      if prev - x > C:
        yield x
        prev = x
  latest = set(to_left())
  if len(latest) > K:
    return []
  def to_right():
    prev = -C-1
    for x in workable:
      if x - prev > C:
        if x in latest:
          yield x
        prev = x
  return to_right()

for i in solve():
  print(i+1)


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

int main()
{
    int n;
    cin >> n;
    int a[n] = {};
    long long sum[n] = {};
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(i==0){ 
            sum[i] = a[i];
        }else{
            sum[i] = sum[i-1] + a[i];
        }
    }
    
    int i = 0;
    int j = 0;
    int k = 0;
    int left = 0;
    int right = n-1;
    long long ans = 1e15;
    for(j = 1; j<n-1; j++){
        int l = 0;
        int r = j;
        long long P = sum[i];
        long long Q = sum[j] - sum[i];
        long long R = sum[k] - sum[j];
        long long S = sum[n-1] - sum[k];
        long long dis = 1e15;
        while(l <= r){
            i = (l+r)/2;
            long long w = sum[i];
            long long e = sum[j] - sum[i];
            if(dis > abs(w-e)){
                P = w;
                Q = e;
                dis = abs(w-e);
            }
            if(w == e){
                break;
            }else if(w < e){
                l = i+1;
            }else{
                r = i-1;
            }
        }
        l = j+1;
        r = n-2;
        dis = 1e15;
        while(l <= r){
            k = (l+r)/2;
            long long w = sum[k] - sum[j];
            long long e = sum[n-1] - sum[k];
            if(dis > abs(w-e)){
                R = w; 
                S = e;
                dis = abs(w-e);
            }
            if(w == e){ 
                break;
            }else if(w < e){
                l = k+1;
            }else{
                r = k-1;
            }
        }
        long long cur = max({P,Q,R,S}) - min({P,Q,R,S});
        ans = min(ans, cur);
        if(sum[j] < sum[n-1] - sum[j]){
            left = j+1;
        }else{
            right = j-1; 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>

using namespace std;

int main()
{
	int sa, sb;
	
	while (scanf("%d %d", &sa, &sb) && sa){
		int max = sa + sb;
		char ans = 'A';
		for (int i = 1; i < 5; i++){
			scanf("%d %d", &sa, &sb);
			if (max < sa + sb){
				max = sa + sb;
				ans = 'A' + i;
			}
		}
		printf("%c %d\n", ans, max);
	}
	
	return (0);
}

Measured memory_bytes: 1028
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    w,v = LI()
    for j in range(V+1):
        if j-v>=0:
            dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
        dp[i][j] = min(dp[i][j],dp[i-1][j])
print(max([i for i in range(V+1) if dp[-1][i]<=W]))


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



void test() {
    int x;
    for (int i=1; i<=5; ++i) {
        cin >> x;
        if (!x) {
            cout << i << '\n';
            return;
        }
    }
}

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

    // int t;
    // cin >> t;
    // while (t--) {
    //     test();
    // }
    test();

    return 0;
}

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

int main(){
    int H, W;
    cin >> H >> W;

    vector<vector<char>> table(H, vector<char>(W));
    vector<bool> sheetV(H, false);
    vector<bool> sheetP(W, false);

    //入力部(確定)
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> table.at(i).at(j);
        }
    }


    //圧縮部1(行圧縮工程)
    for (int i = 0; i < H; i++) {
        int count = 0;
        for (int j = 0; j < W; j++) {
            if (table.at(i).at(j) == '.') count++;
        }
        if (count == W) {
            
            sheetV.at(i) = true;
        }
    }

    //圧縮部2(列圧縮工程)
    for (int j = 0; j < W; j++) {
        int count = 0;
        for (int i = 0; i < H; i++) {
            if (table.at(i).at(j) == '.') count++;
        }
        if (count == H) {
            sheetP.at(j) = true;
        }
    }


    for (int i = 0; i < table.size(); i++) {
        if (sheetV.at(i) == true) continue;
        for (int j = 0; j < table.at(i).size(); j++) {
            if (sheetP.at(j) == true) continue;
            else {
                cout << table.at(i).at(j);
            }                
        }
        cout << endl;
    }


}

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

Ad = {x:0 for x in set(A)}
if len(set(A)) <= K:
    print(0)
else:
    count = 0
    for a in A:
        Ad[a] += 1
    Ad = sorted(Ad.items(), key=lambda x:x[1])
    for i in range(len(set(A))-K):
        count += Ad[i][1]
    print(count)

Measured memory_bytes: 118220
#include <bits/stdc++.h>
using namespace std;
int sx, sy, tx, ty;
int main() {
    cin >> sx >> sy >> tx >> ty;
    int dx = tx-sx;
    int dy = ty-sy;
    for(int i = 0; i < dy; ++i) {
        cout << 'U';
    }
    for(int j = 0; j < dx; ++j) {
        cout << 'R';
    }

    for(int i = 0; i < dy; ++i) {
        cout << 'D';
    }
    for(int j = 0; j < dx; ++j) {
        cout << 'L';
    }

    cout << 'L';
    for(int i = 0; i <= dy; ++i) {
        cout << 'U';
    }
    for(int j = 0; j <= dx; ++j) {
        cout << 'R';
    }
    cout << 'D';

    cout << 'R';
    for(int i = 0; i <= dy; ++i) {
        cout << 'D';
    }
    for(int j = 0; j <= dx; ++j) {
        cout << 'L';
    }
    cout << 'U' << endl;
}

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

using namespace std;

int main(void) {
  int X;

  cin >> X;

  for(int a=1; a<1000; a++) {
    long A = pow(a,5);
    for(int b=-1000; b<1000; b++) {
      long B = pow(b,5);
      if(A-B == X){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  
  return 0;
}


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

using namespace std;

typedef long long ll;
int N;
ll a[100001];
ll b[3];
ll c[3];

int main(){

  cin>>N;
  for(int i=0;i<N;i++)cin>>a[i];
  sort(a,a+N,greater<ll>());
  ll res=0;
  for(int i=2;i<N;i++){
    ll tmp=0;
    if(a[i-2]<a[i-1]+a[i]){
      tmp=a[i]+a[i-1]+a[i-2];
      bool ok=false;
      for(int j=i+3;j<N;j++){
	if(a[j-2]<a[j-1]+a[j]){
	  ok=true;
	  tmp+=a[j]+a[j-1]+a[j-2];
	  break;
	}	  
      }
      if(ok)res=max(res,tmp);
      break;
    }
  }
  for(int i=5;i<N;i++){
    for(int j=0;j<(1<<6);j++){
      int cnt=0;
      for(int k=0;k<6;k++)if((j>>k)&1)cnt++;
      if(cnt!=3)continue;
      int bid=0;
      int cid=0;
      for(int k=0;k<6;k++){
	if((j>>k)&1)
	  b[bid++]=a[i-5+k];
	else
	  c[cid++]=a[i-5+k];
      }
      sort(b,b+3);
      sort(c,c+3);
      if(b[2]<b[0]+b[1]&&c[2]<c[0]+c[1])
	res=max(res,b[0]+b[1]+b[2]+c[0]+c[1]+c[2]);
    }
  }
  cout<<res<<endl;
  
  return 0;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

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

    if (n == 2) cout << s << '\n';
    if (n == 3) {
        reverse(s.begin(), s.end());
        cout << s << '\n';
    }
    return 0;
}

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

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

use std::cmp::{max, min};

fn main() {
  let h = read::<i64>();
  let w = read::<i64>();
  let mut map: Vec<Vec<char>> = vec![];
  let mut done = false;
  let mut ans = "Yes";

  for _ in 0..h {
    let row = read::<String>();
    map.push(row.chars().collect());
  }

  for h_i in 0..h {
    for w_i in 0..w {
      let h_idx = h_i as usize;
      let w_idx = w_i as usize;
      if map[h_idx][w_idx] == '#' {
        let mut ok = false;
        if h_i != 0 && map[h_idx - 1][w_idx] == '#' {
          ok = true
        }
        if h_i != h - 1 && map[h_idx + 1][w_idx] == '#' {
          ok = true
        }
        if w_i != w - 1 && map[h_idx][w_idx + 1] == '#' {
          ok = true
        }
        if w_i != 0 && map[h_idx][w_idx - 1] == '#' {
          ok = true
        }

        if !ok {
          ans = "No";
          done = true;
          break;
        }
      }
    }

    if done {
      break;
    }
  }

  println!("{}", ans);

}



Measured memory_bytes: 4352
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p, q, r;
    cin >> p >> q >> r;
    if (r >= p && r >= q) {
        cout << p + q;
        return 0;
    }   
    if (p >= q && p >= r) {
        cout << q + r;
        return 0;
    }
    if (q >= r && q >= p) {
        cout << r + p;
        return 0;
    }   
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    n, a, b = map(int, input().split())
    ans = 0
    for i in range(1, n+1):
        tmp = i%10 + i//10%10 + i//(10**2)%10 + i//(10**3)%10 + i//(10**4)%10
        if a <= tmp and tmp <= b:
            ans += i
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Measured memory_bytes: 3316
using System;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = Converter(Console.ReadLine());
            Console.WriteLine(Calc(nums));
        }

        static int[] Converter(string str)
        {
            return Array.ConvertAll(str.Split(' '), int.Parse);
        }

        static string Calc(int[] array)
        {
            int d = array[0] / array[1];
            int r = array[0] % array[1];
            double f = (double)array[0] / array[1];
            return d + " " + r + " " + f.ToString("F10");
        }
    }
}



Measured memory_bytes: 9184
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

vector<int> sortunique(vector<int> a) {
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  return a;
}


const int BT = 131072;

const int mod = 1'000'000'007;
long long itree[BT*2];

bool compr(const pair<int,int> &a, const pair<int, int> &b) {
  if (a.first != b.first) return a.first < b.first;
  return a.second > b.second;
}

long long getsum(int p) {
  int l = p + BT, r = BT + BT - 1;
  long long ans = 0;
  while (l <= r) {
    if (l & 1) ans += itree[l];
    if (!(r & 1)) ans += itree[r];
    l = (l + 1) >> 1;
    r = (r - 1) >> 1;
  }
  return ans % mod;
}

void addpos(int pos, long long val) {
  val %= mod;
  val += mod;
  val %= mod;
  pos += BT;
  while (pos >= 1) {
    long long newval = itree[pos] + val;
    if (newval >= mod) newval -= mod;
    itree[pos] = newval;
    pos >>= 1;
  }
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> x(n), y(m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &y[i]);
  }
  vector<int> L, R;
  for (int i = 0; i < n; i++) {
    auto I = lower_bound(y.begin(), y.end(), x[i]);
    if (I == y.begin()) {
      continue;
    }
    else if (I == y.end()) {
      continue;
    }
    else {
      L.push_back(x[i] - *(I-1));
      R.push_back(*I - x[i]);
    }
  }
  n = L.size(); // throw end robots
  vector<int> Ls = sortunique(L), Rs = sortunique(R);
  for (int i = 0; i < n; i++) {
    L[i] = lower_bound(Ls.begin(), Ls.end(), L[i]) - Ls.begin();
    R[i] = lower_bound(Rs.begin(), Rs.end(), R[i]) - Rs.begin();
  }
  vector<pair<int, int>> coords;
  for (int i = 0; i < n; i++) {
    coords.emplace_back(L[i], R[i]);
  }
  sort(coords.begin(), coords.end(), compr);
  coords.resize(unique(coords.begin(), coords.end()) - coords.begin());
  long long ans = 1;
  n = coords.size();
  for (int i = n - 1; i >= 0; i--) {
    int r = coords[i].second;
    long long result = (getsum(r + 1) + 1)% mod;
    addpos(r, result);
    ans += result;
    ans %= mod;
  }
  ans %= mod;
  ans += mod;
  ans %= mod;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4592
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <tuple>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define f first
#define scd second

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);


int A, B, C, X, Y;


int main() {

	cin >> A >> B >> C >> X >> Y;
	int ans = 0;

	if (A + B <= 2 * C) {
		ans = A * X + B * Y;
		cout << ans << endl;
		return 0;
	}

	bool flg1 = X > Y;
	bool flg2 = 2 * C > A;
	bool flg3 = 2 * C > B;
	int del = abs(X - Y);

	if (flg1) {
		ans += C * Y * 2;
		if (flg2) {
			ans += A * del;
		}
		else {
			ans += 2 * C *del;
		}	
	}
	else {
		ans += C * X * 2;
		if (flg3) {
			ans += B * del;
		}
		else {
			ans += 2 * C *del;
		}
	}

	cout << ans << endl;


	return 0;
}






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

template <typename T, typename K> struct P {
	T a;
	K b;
};

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, K;
	cin >> N >> K;
	vector <ll> vec( N + 1 );
	vec[ 0 ] = 0;
	rep( i, 0, N ){
		ll input; cin >> input;
		vec[ i ] += input;
		vec[ i + 1 ] = vec[ i ];
	}
	ll ans = vec[ K - 1 ];
	rep( i, 0, N - K ){
		ans = max( ans, vec[ i + K ] - vec[ i ] );
	}
	printf("%.8f\n", ( double )(ans + K ) / 2);
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 1792
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))

print(dp[n-1])



Measured memory_bytes: 52208
from collections import Counter
N = int(input())
S = list(input())

c = Counter(S)
if S[0] == "E":
    change = c["E"] - 1
else:
    change = c["E"]
min_change = change
for i in range(1, N):
    mae = S[i - 1]
    if S[i] == "E":
        change -= 1
    if mae == "W":
        change += 1
    min_change = min(min_change, change)

print(min_change)


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int N;

//桁数取得
int getDigit(int n) {
    int ret = 0;
    while (n != 0) {
        ++ret;
        n /= 10;
    }
    return ret;
}

//n進数 d桁までの全探査
//Need setting data type of return value 
int allDec(int n, int d){
    int ret = 0;
    vector<int> t(d,0);
    for (int i = 0; i < pow(n,d); i++){
        int x = i;
        for (int k = 0; k < d; k++){
            t[k] = x % n;
            x /= n;
        }

        bool f[3] = {};
        string num = "";
        for (int k = 0; k < d; k++){
            //t[k] == 0 ~ N-1の時それぞれの場合分け
            //3,5,7が1つ以上存在するか確認
            if (t[k] == 0){
                f[0] = true;
                num += '3';
            } else if (t[k] == 1){
                f[1] = true;
                num += '5';
            } else {
                f[2] = true;
                num += '7';
            }
        }

        if (f[0] && f[1] && f[2]) { 
            if (stoi(num) <= N) {
                ret++;
            }
        }
    }
    return ret;
}
int main(){
    cin >> N;

    int ans = 0;
    for (int i = 3; i <= getDigit(N); ++i) {
        ans += allDec(3, i);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ld n,m,d;
    cin >> n >> m >> d;
    ld EX = (n-d)*2/(n*n);
    if(d == 0){
        EX = 1 / n;
    }
    ld ans = EX;
    rep(i,m-2){
        ans += EX;
    }
    cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;


int main(){
	ll x;
	cin>>x;
	ll ans=0;
	ans=x/11*2;
	x%=11;
	if(x>=7)ans++;
	if(x!=0)ans++;
	std::cout << ans << std::endl;
}

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


using namespace std;

int main() {
	int h,n;
	cin >> h >> n;
	
	int sum = 0;
	int at;
	
	for (int i = 0; i < n; i++) {
		cin >> at;
		sum += at;
	}
	
	if(sum>=h){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256