akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var r = int.Parse(list[0]);
        var g = int.Parse(list[1]);
        var b = int.Parse(list[2]);
        var n = int.Parse(list[3]);

        int count = 0;

        for (int rn = 0; rn <= n; rn += r)
        {
            var rest = n - rn;
            for (int gn = 0; gn <= rest; gn += g)
            {
                var bn = rest - gn;
                if (bn % b == 0)
                    ++count;
            }
        }

        Console.WriteLine(count);
    }
}


Measured memory_bytes: 11092
from itertools import permutations
import math

N = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
perm = list(permutations(range(1, N + 1)))
a = None
b = None

for i in range(math.factorial(N)):
    if perm[i] == tuple(p):
        a = i + 1
    if perm[i] == tuple(q):
        b = i + 1

print(abs(a - b))

Measured memory_bytes: 45552
import numpy as np

N = int(input())
inputs = np.array(input().split(), dtype=np.uint8)

total = inputs.sum()
s1 = 0
diffs = []

for t in range(N):
    s1 += inputs[t]
    s2 = total - s1
    diff = np.abs(s1-s2)
    diffs.append(int(diff))

print(np.min(diffs))

Measured memory_bytes: 12744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  for (int i = a; i <= b; i++) {
    string str_i = to_string(i);
    string r_str_i = str_i;
    reverse(r_str_i.begin(), r_str_i.end());
    if (str_i == r_str_i)
      ans++;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

signed main()
{
    int n,m;
    cin>>n>>m;

    char a[n+10][m+10];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }

    int dp[n+2][m+2];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            dp[i][j]=0;
        }
    }

    dp[1][1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(i==1 && j==1)
            {
                continue;
            }
            else if(a[i][j]=='.')
            {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
    }
    cout<<dp[n][m];

    return 0;
}


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

int main() {
    int A, B, C, K;
    std::cin >> A >> B >> C >> K;

    const int a = std::min(A, K);  
    const int c = std::max(0, K - A - B);  
    std::cout << a - c << std::endl;

    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main() {
	long long int n, m, l, i, j, k, a[100][100], b[100][100], c[100][100] = { 0 };
	scanf("%lld %lld %lld", &n, &m, &l);
	for (i = 0;i < n;i++) {
		for (j = 0;j < m;j++) {
			scanf("%lld", &a[i][j]);
		}
	}
	for (i = 0;i < m;i++) {
		for (j = 0;j < l;j++) {
			scanf("%lld", &b[i][j]);
		}
	}
	for (i = 0;i < n;i++) {
		for (j = 0;j < l;j++) {
			for (k = 0;k < m;k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
			printf("%lld", c[i][j]);
			if (j != l-1) {
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define PI acos(-1)
#define ld long double
//mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9+7, N = 2e5+5;

int a[N], n, m, k;

void solve(int test_case){
	int i, j;
	string s;
	cin >> s;
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')cout << 3;
	else if(s[0]=='R'&&s[1]=='R'||s[1]=='R'&&s[2]=='R')cout << 2;
	else if(s[0]=='R'||s[1]=='R'||s[2]=='R')cout << 1;
	else cout << 0;
	return;
}

signed main(){
	FASTIO;
#define MULTITEST 0
#if MULTITEST
	int ___T;
	cin >> ___T;
	for(int T_CASE = 1; T_CASE <= ___T; T_CASE++)
		solve(T_CASE);
#else
	solve(1);
#endif
	return 0;
}



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

int main(){
    vector<int>vec;
    for(int i=0;i<10;i++){
        int c;
        cin>>c;
        vec.push_back(c);
    }
    sort(vec.begin(),vec.end(),greater<int>());
    for(int i=0;i<3;i++){
        cout<<vec[i]<<endl;
    }
}

Measured memory_bytes: 3128
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int h,m,s;
	int sum[2];
	int ans;
	rep(i,3){
		rep(j,2){
			cin>>h>>m>>s;
			sum[j]=h*3600+m*60+s;
		}
		ans=sum[1]-sum[0];
		h=ans/3600;
		m=(ans-h*3600)/60;
		s=ans%60;
		cout<<h<<" "<<m<<" "<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  int ans=0;
  cin>>n>>d;
  int a[n][d];
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int dist=0;
      for(int k=0;k<d;k++){
        int sa=(a[i][k]-a[j][k]);
        dist+=sa*sa;
      }
      for(int k=1;k<=150;k++){
        if(k*k==dist){ans++;}
      }
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll dp[405][405]={0};
ll rpow[405][405]={0};
ll lb[405],rb[405];
int main(){
  ll n,c;
  cin>>n>>c;
  dp[0][0]=1;
  for(int i=0;i<405;i++) rpow[i][0]=1;
  for(int i=0;i<405;i++){
    for(int j=1;j<405;j++){
      rpow[i][j]=(rpow[i][j-1]*i)%mod;
    }
  }
  for(int i=1;i<405;i++){
    for(int j=0;j<405;j++){
      rpow[i][j]+=rpow[i-1][j];
      rpow[i][j]%=mod;
    }
  }
  for(int i=0;i<n;i++) cin>>lb[i];
  for(int i=0;i<n;i++) cin>>rb[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<=c;j++){
      for(int k=0;j+k<=c;k++){
        dp[i+1][j+k]+=dp[i][j]*(rpow[rb[i]][k]-rpow[lb[i]-1][k]+mod);
        dp[i+1][j+k]%=mod;
      }
    }
  }
  cout<<dp[n][c]<<endl;
}


Measured memory_bytes: 2816
import java.util.*;

public class Main {

	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int a, b;

		a= sc.nextInt();
		b= sc.nextInt();
		int c = a*b;

		if(a > 9 || b > 9){

			System.out.println("-1");

		}else {

			System.out.println(c);

		}

	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define met(s) memset(s, 0, sizeof(s))
const int mod = 100000007;
const int maxn = 1000000;
const int inf = 0x3f3f3f3f;
int main()
{
    int l, r;
    scanf("%d%d", &l, &r);
    int len = r - l;
    l %= 2019;
    r = l + len;

    if (r >= 2019)
        printf("%d\n", 0);
    else
    {
        int ans = inf;
        for (int i = l; i < r; i++)
        {
            for (int j = i + 1; j <= r; j++)
            {
                if (ans > (i * j) % 2019)
                    ans = (i * j) % 2019;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main{
	
	private static int N;
	private static BigDecimal a, b,z;
	private final static int MAX_LEN=80;
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		N = Integer.parseInt(br.readLine());
		
		for(int i=0;i<N;i++){
			a = new BigDecimal(br.readLine());
			b = new BigDecimal(br.readLine());
			z = a.add(b);
			
			if(String.valueOf(z).length()>MAX_LEN){
				System.out.println("overflow");
			}
			else {
				System.out.println(z);
			}
		}
	}
}

Measured memory_bytes: 18496
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, d; cin >> n >> d;
    vector<vector<int> > x(n, vector<int>(d));
    rep(i, n)rep(j, d) cin >> x[i][j];
    
    int ans = 0;
    rep(i, n) {
        for (int j=i+1; j<n; j++) {
            int tmp = 0;
            rep(k, d) {
                tmp += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            for (int k=0; k<=126; k++) {
                if (tmp == k*k) {
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read();
    pr2((n+1)/2);
    return 0;
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

void solve()
{
    cin>>k;
    cin>>a>>b;
    if(a/k >= b/k and a%k !=0 and b%k !=0)
        cout<<"NG";
    else
        cout<<"OK";
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3608
K, X = map(int, input().split())
data = []
data.append(X)
for i in range(1, K):
    num1 = X - i
    num2 = X + i
    if (num1 < -10000) and (num2 > 10000):
        break
    elif (num1 < -10000):
        data.append(num2)
    elif (num2 > 10000):
        data.append(num1)
    else:
        data.append(num1)
        data.append(num2)

sort_data = sorted(data)
print(' '.join(map(str,  sort_data)))

Measured memory_bytes: 3064
class Trump(str):
    def __init__(self, card):
        super().__init__()
        self.num = int(card[1])

def trump_bubble_sort(A, N):
    flg = True
    while flg:
        flg = False
        for i in range(1, N):
            if A[i - 1].num > A[i].num:
                A[i], A[i - 1] = A[i - 1], A[i]
                flg = True
    return A


def trump_selection_sort(A, N):
    for i in range(0, N-1):
        min_idx = i
        for j in range(i+1, N):
            if A[min_idx].num > A[j].num:
                min_idx = j
        A[i], A[min_idx] = A[min_idx], A[i]
        
    return A

N = int(input().rstrip())
A = [Trump(a) for a in input().rstrip().split()]
A_2 = A.copy()

bubble_result = trump_bubble_sort(A, N)
selection_result = trump_selection_sort(A_2, N)

stable = True
for i in range(0, N):
    if bubble_result[i] != selection_result[i]:
        stable = False
        break
print(" ".join(bubble_result))
print("Stable")
print(" ".join(selection_result))
print("Stable" if stable else "Not stable")
    



Measured memory_bytes: 5612
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
int kj[300005], kji[300005];
int modpow(int x, int n, int md) {
	if (!n)return 1;
	int res = modpow(x*x%md, n / 2, md);
	if (n & 1)res = res*x%md;
	return res;
}
int comb(int n, int r) {
	if (n < 0 ||r<0|| n < r)return 0;
	int ans = kj[n];
	ans = ans*kji[r] % mod;
	ans = ans*kji[n - r] % mod;
	return ans%mod;
}
signed main() {
	int n, k; cin >> n >> k;
	kj[0] = 1;
	rep(i, 100000) {
		kj[i + 1] = kj[i] * (i + 1);
		kj[i + 1] %= mod;
	}
	rep(i, 100000)kji[i] = modpow(kj[i], mod - 2, mod);
	
	rep(i, k) {
		int ans = comb(k - 1, i)*comb(n-k+1, n-k-i) % mod;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3200
n = int(input())
a = list(map(int,input().split()))

from math import gcd
g = a[0]
for i in range(n):
    g = gcd(g,a[i])

if g!=1:
    print('not coprime')
    exit()

f = True
l = set()
for i in a:
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            if i in l:
                f = False
                break
            l.add(i)
        while i%j==0:
            i = i//j
        if i<2:
            break
    if i>1:
        if i in l:
            f = False
            break
        l.add(i)
        
if f:
    print('pairwise coprime')
else:
    print('setwise coprime')


Measured memory_bytes: 191504
-module('Main').
-export([main/1]).

main(_) ->
    {ok, [A, B, C, D]} = io:fread("", "~d ~d ~d ~d"),
    Ans = lists:max([A * C, A * D, B * C, B * D]),    
    io:format("~p~n", [Ans]),
    halt().

Measured memory_bytes: 22056
MAX_COST = Float::INFINITY

module State
  UNKNOWN = 0
  FOUND   = 1
  REACHED = 2
end

def calc_min_costs_from(v_start, costs)
  vert_state = Struct.new :id, :cost_from_start, :state do
    define_method :cost_to do |v_to|
      costs[id][v_to.id]
    end

    def connected_to?(v_to)
      0 <= cost_to(v_to)
    end

    def is?(state)
      self.state == state
    end

    def cost_from_start_through(other_v)
      other_v.cost_from_start + other_v.cost_to(self)
    end
  end

  n_vertexes  = costs.size
  vert_states = n_vertexes.times.map do |id|
    if id == v_start
      vert_state.new id, 0, State::FOUND
    else
      vert_state.new id, MAX_COST, State::UNKNOWN
    end
  end

  while true
    v_from = vert_states.
      select { |v| v.is? State::FOUND }.
      min_by { |v| v.cost_from_start }

    break if v_from.nil?
    v_from.state = State::REACHED

    vert_states.each do |v_to|
      next if v_to.is?(State::REACHED) or not v_from.connected_to?(v_to)
      through_cost = v_to.cost_from_start_through v_from
      if through_cost < v_to.cost_from_start
        v_to.cost_from_start = through_cost
        v_to.state = State::FOUND
      end
    end
  end

  vert_states.map { |v| v.cost_from_start }
end

n_vertexes = gets.to_i
costs      = Array.new(n_vertexes) { Array.new(n_vertexes, -1) }
n_vertexes.times do
  v_from, n_degrees, *inputs = gets.split.map &:to_i
  1.step(n_degrees * 2, 2) do |i|
    v_to, cost = inputs[i - 1], inputs[i]
    costs[v_from][v_to] = cost
  end
end

min_costs = calc_min_costs_from(0, costs)
puts min_costs.map.with_index{ |cost, v| "#{v} #{cost}" }

Measured memory_bytes: 8956
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int dp[41][401][401];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,ma,mb;
    cin>>n>>ma>>mb;

    for(int i=0;i<=n;i++){
        for(int j=0;j<=400;j++){
            for(int k=0;k<=400;k++){
                dp[i][j][k]=5000;
            }
        }
    }
    for(int i=0;i<=n;i++){
        dp[i][0][0]=0;
    }

    for(int i=1;i<=n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        for(int j=0;j<=400-a;j++){
            for(int k=0;k<=400-b;k++){
                if(dp[i][j+a][k+b]>dp[i-1][j][k]+c){
                    for(int t=i;t<=n;t++){
                        dp[t][j+a][k+b]=dp[i-1][j][k]+c;
                    }
                }
            }
        }
    }

    ll ans=5000;
    for(int i=1;(i*ma<401)&&(i*mb<401);i++){
        int count=dp[n][i*ma][i*mb];
        if(count<ans)
            ans=count;
    }

    if(ans==5000){
        cout<<-1;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 25984
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
bool cc(vec v,vec vv)
{
    ll n=v.size();
    rep(i,0,n)
    if(v[i]!=vv[i])
    return false;
    return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,n,k,x,a,b; bool xx=true;
    	cin>>n;
    	vec v1(n),v2(n),v(n);
    	rep(i,0,n)
    	cin>>v1[i];
    	rep(i,0,n)
    	cin>>v2[i];
    	repi(i,1,n)
    	v[i-1]=i;
    	x=1;
    	while(xx==true)
    	{
    		if(cc(v,v1)==true)
    		a=x;
    		if(cc(v,v2)==true)
    		b=x;
    		xx=next_permutation(all(v));
    		x++;
		}
    	cout<<abs(a-b);
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
/*int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  if (C >= A && C >= B) cout << A*X + B*Y << endl;
  else if (C <= A && C <= B) {
    if (X > Y) {
      if (C*2*Y+A*(X-Y) < C*2*X) cout << C*2*Y+A*(X-Y) << endl;
      else cout << C*2*X;
    } else {
      if (C*2*X+A*(Y-X) < C*2*Y) cout << C*2*X+A*(Y-X) << endl;
      else cout << C*2*Y;
    }
  }
  else {
    int a,x;
    if (A > B) {
      a = A;
      x = X;
      A = B;
      B = a;
      X = Y;
      Y = x;
    }
    int max = 0;
    if (X < Y) {
      for (int i = 0; i <= X; i++) {
        if ((A-C)*i + (B-C)*i > max) max = (A-C)*i + (B-C)*i;
      }
      for (int i = X+1; i <= Y; i++) {
        if ((A-C)*i + (B-C)*i - A*(2*i-X) > max) max = (A-C)*i + (B-C)*i - A*(2*i-X);
      }
    }
    else {
      for (int i = 0; i <= Y; i++) {
        if ((A-C)*i + (B-C)*i > max) max = (A-C)*i + (B-C)*i;
      }
    }
    cout << A*X+B*Y-max << endl;
  }
}*/

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  if (X > Y) {
    swap(A, B);
    swap(X, Y);
  }
  int min = 1000000000;
  for (int i = 0; i <= Y; i++) {
    int x = C*2*i + A*max(0, X-i) + B*max(0, Y-i);
    if (x < min) min = x;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read() {
	int ans = 0, flag = 1; char ch = getchar();
	while(ch > '9' || ch < '0') {if(ch == '-') flag = - flag; ch = getchar();}
	while(ch >= '0' && ch <= '9') {ans = ans * 10 + ch - '0'; ch = getchar();}
	return ans * flag;
}
const int N = 200010;
vector <int> smax[N];
vector <int> edg[N];
int MAX[N], f[N];

int dfn[N], low[N], DFN;

void dfs(int x, int ff) {
	f[x] = ff;
	MAX[x] = max(MAX[f[x]], x);
	smax[MAX[f[x]]].push_back(x);
	dfn[x] = ++ DFN;
	for(auto it : edg[x])
		if(it != f[x])
			dfs(it, x);
	low[x] = DFN;
}

struct Tree {
	int ch[N * 30][2];
	int siz[N * 30];
	int cnt;
	int merge(int a, int b) {
		if(!a || !b) return a + b;
		siz[a] += siz[b];
		ch[a][0] = merge(ch[a][0], ch[b][0]);
		ch[a][1] = merge(ch[a][1], ch[b][1]);
		return a;
	}
	#define L (ch[x][0])
	#define R (ch[x][1])
	#define mid ((l + r) >> 1)
	int query(int x, int l, int r, int ll, int rr) {
		if(!x) return 0;
		if(l >= ll && r <= rr) return siz[x];
		int ans = 0;
		if(mid >= ll) ans += query(L, l, mid, ll, rr);
		if(mid < rr) ans += query(R, mid + 1, r, ll, rr);
		return ans;
	}
	void insert(int& x, int l, int r, int pos) {
		if(!x) x = ++ cnt; ++ siz[x];
		if(l == r) return;
		else {
			if(pos <= mid) insert(L, l, mid, pos);
			else insert(R, mid + 1, r, pos);
		}
	}
}tr;
int rt[N];

struct DisjointSet {
	int fa[N], siz[N];
	int find(int x) {return fa[x] == x ? x : fa[x] = find(fa[x]);}
	int merge(int x, int y) {
		x = find(x); y = find(y);
		if(siz[x] > siz[y]) swap(x, y);
		fa[x] = y; siz[y] += siz[x];
		return y;
	}
	void set(int n) {
		for(int i = 1; i <= n; ++ i) {
			fa[i] = i;
			siz[i] = 1;
		}
	}
}ds;

int ctr[N], sub[N];
int ctrs[N], subs[N];
int dep[N];
int Ans[N];

void dfspush(int x) {
	for(auto it : edg[x]) {
		if(it == f[x]) continue;
		ctrs[it] = ctrs[x] + ctr[it];
		subs[it] = subs[x] + sub[it];
		dep[it] = dep[x] + 1;
		dfspush(it);
	}
}

int n;

int main() {
	n = read();
	for(int i = 1; i < n; ++ i) {
		int u = read(), v = read();
		edg[u].push_back(v);
		edg[v].push_back(u);
	}

	dfs(1, 0);
	
	ds.set(n);
	for(int i = 1; i <= n; ++ i)
		tr.insert(rt[i], 1, n, dfn[i]);
	
	for(int i = 1; i <= n; ++ i) {
		for(auto it : smax[i]) {
			for(auto ii : edg[it]) {
				if(ii == f[it]) continue;
				if(ii > i) continue;
				ctr[ii] = tr.query(rt[ds.find(ii)], 1, n, dfn[ii], low[ii]);
				sub[it] += ctr[ii];
			}
		}
		if(i == 1) continue;
		int x = tr.merge(rt[ds.find(f[i])], rt[ds.find(i)]);
		int y = ds.merge(i, f[i]);
		rt[y] = x;
	}

	dfspush(1);

	for(int i = 2; i <= n; ++ i)
		printf("%d ", subs[i] - ctrs[i] + dep[i]);
	return 0;
}

Measured memory_bytes: 84728
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    ll N,C,K;
    cin >> N >> C >> K;
    vector<ll> v(N);
    REP(i,N) cin >> v[i];
    sort(ALL(v));
    ll now_bus_in = 0;
    ll ans = 0;
    ll now_bus_arrived = -1;
    for (const auto &it : v) {
        if (now_bus_arrived == -1) {
            now_bus_arrived = it;
            now_bus_in = 1;
            ans++;
            continue;
        }
        if ((now_bus_arrived+K)>=it) {
            if (now_bus_in < C) now_bus_in++;
            else {
                ans++;
                now_bus_in = 1;
                now_bus_arrived = it;
            }
            continue;
        }
        now_bus_arrived = it;
        ans++;
        now_bus_in = 1;
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 1024
from collections import Counter

N = int(input())

A = list(map(int, input().split()))

dic = Counter(A)

Q = int(input())

res = sum(A)

for i in range(Q):
    B, C = map(int, input().split())
    res = res +C*dic[B] - B*dic[B]
    dic[C] += dic[B]
    dic[B] = 0
    print(res)


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  constexpr ll INF = 1LL << 60;
  ll dp[100005];
  ll h[100005];
  int n, k;
  cin >> n >> k;
  rep(i, n) {
    cin >> h[i];
    dp[i] = INF;
  }

  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <=  k && j <= i; ++j) {
      dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     int ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/




string s,t;
int len;

bool calc(int n,int st,char op1,char op2){
     int p=st;
     for(int i=0;i<len;i++){
          if(s[i]==op2){p++;if(p>n)return false;}
          if(t[i]==op1){p=max(p-1,1);}
     }
     p=st;
     for(int i=0;i<len;i++){
          if(s[i]==op1){
               p--;if(p<1){return false;}
          }
          if(t[i]==op2){p=min(p+1,n);}
     }
     return true;
}





int main(){
     int h,w,n;
     cin>>h>>w>>n;
     int sx,sy;
     cin>>sx>>sy;
     cin>>s>>t;
     len=s.length();
     bool res=calc(w,sy,'L','R')&&calc(h,sx,'U','D');
     if(res)cout<<"YES";
     else cout<<"NO";


}



















































Measured memory_bytes: 3868
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 1e5 + 10;
int nums[MAXN];
LL sum[MAXN];

LL solve(int n) {
  if (n == 0 && nums[0] == 1) return 1;
  if (nums[0] != 0) return -1;
  LL ret = 1;
  LL cur = 1;
  for (int i = 1; i <= n; i++) {
    if (nums[i] > cur*2) return -1;
    cur = min(cur*2, sum[i]);
    ret += cur;
    cur -= nums[i];
  }
  assert(cur == 0);
  return ret;

}





int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int n; cin >> n;
  for (int i = 0; i <= n; i++) {
    cin >> nums[i];
  }
  for (int i = n; i >= 0; i--) {
    sum[i] = nums[i] + sum[i+1];
  }
  cout << solve(n) << endl;






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 4356
#include <stdio.h>
int main(void){
int a, b;
scanf("%d %d", &a, &b);
if (a<b){
printf("a < b\n");
}
else if (a > b){
printf("a > b\n");	
}
else{
printf("a == b\n");
return 0;
}
}


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

ll n,ans;

inline void U(ll &x,ll y){
  x+=y; if (x>=mod) x-=mod;
}

ll K(ll x,int y){ return y? K(x*x%mod,y/2)*(y&1?x:1)%mod: 1; }
void ddd(int x){
  if (x<10) return;
  ll an=K(10,x-1)*9%mod-n/x+1;
  an=(an%mod+mod)%mod;
  U(ans,an);
}
void sth_above_ten(){ // >=10
  static ll x,y,sum;
  for (int i=9;i<n;++i){
    // ix+ (i+1)y =n  x,y>0
    // i(x+y) =n-y
    sum=(n-1)/i; y=n-sum*i;
    if (sum<=y) continue;
    x=sum-y;
    U(ans,(x-1)/(i+1)+1);
  }
  for (int i=1;i*i<=n;++i)
    if (n%i==0){
      ddd(i);
      if (i*i!=n) ddd(n/i);
    }
}

void exgcd(ll a,ll b,ll &c,ll &x,ll &y){
  if (!b){
    y=0; x=1; c=a;
  }else{
    exgcd(b,a%b,c,x,y);
    ll xx=x, yy=y;
    x=yy; y=xx-a/b*yy;
  }
}

ll up(ll x,ll y){ return (x+y-1)/y; }

void cal(ll a,ll limx,ll b,ll limy,ll c){
  ll x,y,g,an,d;
  exgcd(a,b,g,x,y);
  if (c%g) return;
  x*=c/g; y*=c/g; a/=g; b/=g;
  if (x<=0){
    d=abs(x)/b+10;
    x+=d*b;
    y-=d*a;
  }
  d=(x-1)/b;
  x-=d*b; y+=d*a;
  if (y<1) return;
  if (y>limy){
    d=up(y-limy,a);
    x+=d*b; y-=d*a;
  }
  if (y<1) return;
  if (x>limx) return;
  an=(limx-x)/b+1;
  an=min(an,(y-1)/a+1);
  ans+=an;
  ans%=mod;
}

void all_below_ten(){ // <10
  static ll las,cc[10];
  cc[1]=9;
  for (int i=2;i<=9;++i)
    cc[i]=cc[i-1]*10;
  for (int i=1;i<=9;++i)
    for (int j=i+1;j<=9;++j){
      las=n;
      for (int k=i+1;k<j;++k) las-=cc[k]*k;
      if (las<i+j) continue;
      cal(i,cc[i],j,cc[j],las);
    }
  for (int i=1;i<=9;++i)
    if (n%i==0){
      ll nd=n/i;
      if (nd>cc[i]) continue;
      ans+=cc[i]-nd+1;
      ans%=mod;
    }
}

int main(){
  cin>>n;
  sth_above_ten();
  all_below_ten();
  cout<<ans<<endl;
}


Measured memory_bytes: 384
<?php
$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($L,$R,$d) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$p = intdiv($N,200);

printf("%d\n",abs($p-10));


Measured memory_bytes: 16208
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,w;
  cin>>n>>w;
  vector<pair<int,int>>a;
  int i,w1,v,j;
  for(i=0;i<n;i++)
  {
    cin>>w1>>v;
    a.push_back(make_pair(v,w1));
  }
  long long int ans[2][100001];
  for(i=0;i<100001;i++)
  {
    ans[0][i]=100000000000000;
    ans[1][i]=100000000000000;
  }
  sort(a.begin(),a.end());
  ans[0][0]=0;
  ans[1][0]=0;
  for(i=0;i<n;i++)
  {
    //j=a[i].first;
    if(a[i].second>w)
      break;
    for(j=0;j<100001;j++)
    {
      if(j>=a[i].first)
      ans[(i+1)%2][j] = min(ans[i%2][j],ans[i%2][j-a[i].first]+a[i].second);
      else ans[(i+1)%2][j]=ans[i%2][j];
    }
  }
  long int an=0;
  for(i=0;i<100001;i++)
  {
   // cout<<ans[n%2][i]<<" ";
    if(ans[(n)%2][i] <= w)
      an=i;
  }
  cout<<an<<endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> L(N);
  for (int &i: L) cin >> i;
  sort(L.begin(), L.end(), less<int>());
  
  int count = 0;
  for (int i : L) {
    for (int j : L) {
      if (i >= j) continue;
      for (int k: L) {
        if ((i >= k) || (j >= k)) continue;
        if (k < i + j) count++;
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <unordered_map>

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  unordered_map<ll, ll> A;
  for (int i = 0; i < N; ++i) {
    ll A_i;
    cin >> A_i;
    auto itr = A.find(A_i);
    if (itr != A.end()) {
      A[A_i] += 1;
    } else {
      A[A_i] = 1;
    }
  }
  ll ans = 0;
  for (auto itr = A.begin(); itr != A.end(); ++itr) {
    if (itr->second % 2 == 1) {
      ans += 1;
    }
  }

  cout << ans << endl;
  return 0;
}

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

using namespace std;

const long long MOD = 1000000007;

int nextPattern(int curr, const string& S1, const string& S2) {
    int N = S1.size();
    if (curr >= N - 1) {
        return 0;
    }
    string s1 = S1.substr(curr + 1, 1);
    string s2 = S2.substr(curr + 1, 1);
    if (s1 == s2) {
        return 1;
    }
    else {
        return 2;
    }
}

long long dp(int curr, int prevPattern, const string& S1, const string& S2) {
    int N = S1.size();
    if (curr >= N - 1) {
        return 1LL;
    }

    int np = nextPattern(curr, S1, S2);
    long long ret = 1;
    if (prevPattern == -1) {
        if (np == 1) {
            ret = 3 * dp(curr + 1, np, S1, S2);
        }
        else {
            ret = 6 * dp(curr + 2, np, S1, S2);
        }
    }
    else if (prevPattern == 1) {
        if (np == 1) {
            ret = 2 * dp(curr + 1, np, S1, S2);
        }
        else {
            ret = 2 * dp(curr + 2, np, S1, S2);
        }
    }
    else { // prevPattern == 2
        if (np == 1) {
            ret = 1 * dp(curr + 1, np, S1, S2);
        }
        else {
            ret = 3 * dp(curr + 2, np, S1, S2);
        }
    }
    return ret % MOD;
}

void Main() {
    int N;
    cin >> N;
    string S1, S2;
    cin >> S1;
    cin >> S2;

    long long ans = dp(-1, -1, S1, S2);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
signed main(){
	int n,c;
	cin>>n>>c;
	int x[100010],v[100010];
	rep(i,n)cin>>x[i]>>v[i];
	int r[100010],l[100010];
	rep(i,n){
		if(i==0){
			r[i]=v[i];
			l[i]=v[n-i-1];
		}else{
			r[i]=r[i-1]+v[i];
			l[i]=l[i-1]+v[n-i-1];
		}
	}
	rep(i,n){
		r[i]-=x[i];
		l[i]-=(c-x[n-i-1]);
	}
	int rmx[100010],lmx[100010];
	rmx[0]=r[0];
	lmx[0]=l[0];
	rep(i,1,n){
		rmx[i]=max(rmx[i-1],r[i]);
		lmx[i]=max(lmx[i-1],l[i]);
	}
	int re=0;
	rep(i,n){
		chmax(re,r[i]);
		chmax(re,l[i]);
	}
	rep(i,n-1){
		chmax(re,r[i]+lmx[n-i-2]-x[i]);
		chmax(re,l[i]+rmx[n-i-2]-(c-x[n-i-1]));
	}
	cout<<re<<endl;
	return 0;
}


Measured memory_bytes: 4992
// C++ program to print all primes smaller than or equal to 
// n using Sieve of Eratosthenes 
#include <bits/stdc++.h> 
using namespace std; 
long long prime[1000006]={0}; 
void SieveOfEratosthenes(long long n) 
{ 
    for(long long i=1;i<=n;i++)
    {
        prime[i]=i;
    }
	for (long long p=2; p*p<=n; p++) 
	{ 
		// If prime[p] is not changed, then it is a prime 
		if (prime[p] == p) 
		{ 
			// Update all multiples of p greater than or 
			// equal to the square of it 
			// numbers which are multiple of p and are 
			// less than p^2 are already been marked. 
			for (long long i=p*p; i<=n; i += p) 
			{
			    if(prime[i]==i)
			    prime[i] = p;
			}
		} 
	} 
} 

// Driver Program to test above function 
int main() 
{ 
	long long n = 1000000,b;  
	SieveOfEratosthenes(n);
	std::cin >> b;
	long long a[b],x,c=0;
	map<long long,long long>mp;
	for(long long i=0;i<b;i++)
	{
	    std::cin >> a[i];
	    if(i==0)
	    x=a[i];
	    else
	    x=__gcd(x,a[i]);
	    map<long long,long long>mp1;
	    if(c==1)
	    continue;
	    while(a[i]!=1)
	    {
	        mp1[prime[a[i]]]++;
	        a[i]/=prime[a[i]];
	    }
	    for(auto it=mp1.begin();it!=mp1.end();it++)
	    {
	        if(mp.find(it->first)!=mp.end())
	        c=1;
	        else
	        mp[it->first]=1;
	    }
	}
	if(c==0)
	{
	    cout << "pairwise coprime\n" ;
	}
	else if(x==1)
	{
	    cout<<"setwise coprime\n";
	}
	else
	cout<<"not coprime\n";
	return 0; 
} 


Measured memory_bytes: 19232
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    int fwd_cnt = 0;
    vector<bool> fwd(n, false);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'o') {
            fwd_cnt++;
            fwd[i] = true;
            i += c;
        }
    }

    int bwd_cnt = 0;
    vector<bool> bwd(n, false);
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'o') {
            bwd_cnt++;
            bwd[i] = true;
            i -= c;
        }
    }

    if (max(fwd_cnt, bwd_cnt) == k) {
        for (int i = 0; i < n; i++) {
            if (fwd[i] && bwd[i]) {
                cout << i + 1 << endl;
            }
        }
    }
}


Measured memory_bytes: 1796
sx,sy,tx,ty=map(int, input().split())
word = ""
word = word + "R" * (tx - sx)
word = word + "U" * (ty -sy)
word = word + "L" * (tx - sx)
word = word + "D" * (ty -sy + 1)
word = word + "R" * (tx - sx + 1)
word = word + "U" * (ty -sy + 1)
word = word + "L"
word = word + "U"
word = word + "L" * (tx - sx + 1)
word = word + "D" * (ty -sy + 1)
word = word + "R"
print(word)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int x,t;cin>>x>>t;

  if(x-t<=0){
    cout<<0<<"\n";
  }else{
    cout<<x-t<<"\n";
  }

  return 0;
}


Measured memory_bytes: 256
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int n, m, L, R;
int main() {
	cin >> n >> m;
	L = 1, R = n;
	while (m--) {
		int x, y; scanf("%d%d", &x, &y);
		L = max(L, x);
		R = min(R, y);
	}
	printf("%d\n", max(R - L + 1, 0));
	return 0;
}

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

template<typename T>struct SegmentTree {
    using F = function<T(T, T)>;
private : 
    const T id;
    const F f;
    int n;
    vector<T> node;

public : 
    SegmentTree (const F &f, const T &id) : 
        f(f), id(id) { }

    void init (int sz) {
        assert(0 < sz);
        n = 1;
        while (n < sz) n <<= 1;
        node.resize(2*n, id);
    }

    void build (vector<T> v) {
        init((int)v.size());
        for (int i = 0; i < (int)v.size(); i++) node[i+n] = v[i];
        for (int i = n-1; i > 0; i--) node[i] = f(node[i<<1|0], node[i<<1|1]);
    }

    void update (int i, const T &x) {
        assert((i += n) < node.size());
        node[i] = x;
        while (i > 0) {
            i >>= 1;
            node[i] = f(node[i<<1], node[i<<1|1]);
        }
    }

    const T fold (int l, int r) const {
        assert(l <= r);
        T vl = id, vr = id;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l&1) vl = f(vl, node[l++]);
            if (r&1) vr = f(node[--r], vr);
        }
        return f(vl, vr);
    }

    const T &operator[] (int i) const {
        assert(i += n < node.size());
        return node[i];
    }

};

void chmax (int &a, int b) {
    if (a < b) a = b;
}

constexpr int INF = 1'000'000'100;

int main() {
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    {
        vector<pair<int, int>> dat;
        for (int i = 0; i < n; i++) {
            int l, r;
            cin >> l >> r;
            dat.emplace_back(l, r + 1);
        }
        sort(dat.begin(), dat.end());
        for (int i = 0; i < n; i++) {
            tie(l[i], r[i]) = dat[i];
        }
    }

    int ans = 0;
    SegmentTree<int> sl([](int a, int b) { return max(a, b); }, -INF);
    SegmentTree<int> sr([](int a, int b) { return min(a, b); }, INF);
    sl.build(l); sr.build(r);

    for (int i = 0; i < n; i++) {
        int vl = max(sl.fold(0, i), sl.fold(i + 1, n));
        int vr = min(sr.fold(0, i), sr.fold(i + 1, n));
        chmax(ans, max(vr - vl, 0) + max(r[i] - l[i], 0));
        if (0 < i) {
            int vl = max(sr.fold(0, i) - sl.fold(0, i), 0);
            int vr = max(sr.fold(i, n) - sl.fold(i, n), 0);
            chmax(ans, vl + vr);
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, X, Y, Z, P;
  cin >> A >> B;
  X = A + B;
  Y = A - B;
  Z = A * B;
  P = max(X, Y);
  cout << max(P, Z) << endl;
}

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

const int MAX_N = 15;
int N;
int A[MAX_N];
std::vector<std::pair<int,int> > v[MAX_N];

int df(int i, std::vector<int> flags){
   if(i==N) return std::count(flags.begin(),flags.end(),1);
   
   int count = 0;
   if(flags[i]==1) {
      for(int j=0; j<A[i]; ++j){
	 if(flags[v[i][j].first]>=0 && flags[v[i][j].first]!=v[i][j].second) return 0;
	 else flags[v[i][j].first] = v[i][j].second;
      }
      count = df(i+1,flags);
   } else if(flags[i]==0) {
      count = df(i+1,flags);
   } else {
      //assuming i is unkind.
      std::vector<int> tmp = flags;
      tmp[i] = 0;
      count = df(i+1,tmp);

      //assuming i is honest.
      tmp = flags;
      tmp[i] = 1;
      for(int j=0; j<A[i]; ++j){
	 if(tmp[v[i][j].first]>=0 && tmp[v[i][j].first]!=v[i][j].second) return count;
	 else tmp[v[i][j].first] = v[i][j].second;
      }
      count = std::max(count,df(i+1,tmp));
   }
   return count;
}

int main(){
   std::cin >> N;
   int x, y;
   for(int i=0; i<N; ++i){
      std::cin >> A[i];
      for(int j=0; j<A[i]; ++j){
	 std::cin >> x >> y;
	 v[i].push_back(std::make_pair(--x,y));
      }
   }
   std::vector<int> flags(N,-1);
   std::cout << df(0,flags) << std::endl;
   return 0;
}


Measured memory_bytes: 256