akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define N 200005
using namespace std;
bool cur1;
int n;
int a[N];
inline void Rd(int &res){
	char c;res=0;
	while(c=getchar(),c<48);
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>47);
	return;
}
bool cur2;
int main(){
//	printf("%lf MB\n",(&cur2-&cur1)/1024.0/1024);
	Rd(n);
	int mx1=0,mx2=0;
	for(int i=1;i<=n;i++){
		Rd(a[i]);
		if(a[i]>mx1)mx2=mx1,mx1=a[i];
		else if(a[i]>mx2)mx2=a[i];
	}
	for(int i=1;i<=n;i++){
		if(a[i]==mx1)printf("%d\n",mx2);
		else printf("%d\n",mx1);
	}
	return 0;
}

Measured memory_bytes: 2432
#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: 580
#include<bits/stdc++.h>

using namespace std;

int main(){
  int n;
  cin>>n;
  int k;
  cin>>k;
  
  vector<int>h(n); for(int i=0;i<n;i++){cin>>h[i];}
  
  vector<int>cost(n,INT_MAX);
  cost[0] = 0;
  cost[1] = abs(h[0]-h[1]);
  
  for(int i=2;i<n;i++){
    for(int j=1;j<=k;j++){
    	int index  = i-j;
        if(index>=0){
        	cost[i] = min(cost[i],cost[index]+abs(h[i]-h[index]));
        }
    }
  }
  
  cout<<cost[n-1];
  


return 0;
}

Measured memory_bytes: 1024
1x$_~~/^(11+)\1+$/||push@p,$_ for 2..1e3;
for$i(1..<>){
	for$p(@p){
		++$_[$p],$i/=$p while$i%$p==0
	}
}
$x=1;
$x*=$_+1,$x%=1e9+7for@_;
print$x,$/


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

int main()
{
	int n;
	cin >> n;
	double a[n];
	for(int i=0;i<n;i++)
		cin >> a[i];
	double dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	/*
		dp[i][j]- i heads from first j coins
		case head - i-1 heads from j-1 coins
		case tail - i heads from j-1 coins
	*/
	dp[0][0] = 1.0;
	for(int i=1;i<=n;i++)
		dp[0][i] = (1-a[i-1])*dp[0][i-1];
	for(int i=1;i<=n;i++)
	{
		for(int heads=1;heads<=i;heads++)
		{
			dp[heads][i] = a[i-1]*dp[heads-1][i-1] + (1-a[i-1])*dp[heads][i-1];
		}
	}
	// for(int i=0;i<=n;i++)
	// {
	// 	for(int j=0;j<=n;j++)
	// 		cout << dp[i][j] << " ";
	// 	cout << endl;
	// }
	double ans = 0.0;
	for(int i=n/2+1;i<=n;i++)
		ans += dp[i][n];
	cout << setprecision(9) << ans << endl;
}

Measured memory_bytes: 70528
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>

using namespace std;
typedef long long ll;
const ll MAXN = 45;

int main(){
    int n; cin >> n;
    double mult = 1;
    double sum = 0;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        mult *= a[i];
    }
    for(int i = 0; i < n; i++){
        sum += mult/a[i];
    }
    cout << mult/sum << endl;
    return 0;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

int d[10][10];

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;

  rep2(i, 1, n) {
    string s = to_string(i);
    int front = s.front() - '0';
    int back = s.back() - '0';

    ++d[front][back];
  }

  int ans = 0;
  rep(i, 10) rep(j, 10) ans += d[i][j] * d[j][i];

  cout << ans << endl;
}


Measured memory_bytes: 3744
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
/*ll ceilVal(ll a,ll b)
{
return (a / b) + ((a % b) != 0);
}
vector<ll> adj[1000000] ;
ll vis[1000000]={0} ;
void dfs(ll w)
{
    vis[w] = 1;
    for(ll u=0;u<adj[w].size();u++)
     {
      if(!vis[adj[w][u]])
            dfs(adj[w][u]) ;
	  }
}
ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
}*/
int main()
{
 ios_base::sync_with_stdio(false);                      
 cin.tie(NULL);
 ll i,j,k,n,ans,c1,c2,c3,c4;
 string s;
 //map<string,ll> m;
 cin>>n;
 i=0;
 c1=0;
 c2=0;
 c3=0;
 c4=0;
 while(i<n)
 {
     cin>>s;
     if(s=="AC")
     {
     c1++;
     }
   if(s=="WA")
     {
     c2++;
     }
     if(s=="TLE")
     {
     c3++;
     }
    if(s=="RE")
     {
     c4++;
     }
     i++;
 }
 cout<<"AC"<<" x "<<c1<<endl;
  cout<<"WA"<<" x "<<c2<<endl;
   cout<<"TLE"<<" x "<<c3<<endl;
    cout<<"RE"<<" x "<<c4<<endl;
return(0);
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(p,a,b)    for(int p=a;i<b;i++)
#define INF 0x3f3f3f3f

int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("o2.txt", "w", stdout);
    #endif

    int n,m,sum=0,x,i;
    cin>>n>>m;
    while(m--){cin>>x;sum+=x;}
    cout<<max(-1,n-sum);
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;


int main() {
    int  a, b;
    cin >> a >> b;
    if (a + b < 10)cout << a + b << endl;
    else cout << "error" << endl;
 
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

typedef long long ll;

#define fs first
#define sc second


const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


int n;
ll a[100100];
int check[100100];

int main(){
    cin >> n;
    fill(check, check+n+1, 0);
    ll duplicate = -1;
    for(int i = 0; i <= n; i++){
        cin >> a[i];
        if(check[a[i]] == 0){
            check[a[i]] = 1;
        }
        else{
            duplicate = a[i];
        }
    }

    int f = -1, s = -1;
    for(int i = 0; i <= n; i++){
        if(a[i] == duplicate && f == -1){
            f = i;
        }
        else if(a[i] == duplicate){
            s = n-i;
        }
    }

    make_fact(n+10);
    make_invfact(n+10);


    for(int k = 1; k <= n+1; k++){
        if(k == 1){
            cout << n << endl;
        }
        else if(f+s >= k-1){
            cout << sub(comb(n + 1, k), comb(f + s, k - 1)) << endl;
        }
        else{
            cout << comb(n + 1, k) << endl;
        }
    }

    return 0;

}

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

typedef pair<ll, ll> P;
vec d;
struct edge {
    ll to, cost;
};
vector<vector<edge>> G;

void dijkstra (ll s, ll V) {
    priority_queue<P, vector<P>, greater<P>> que;
    d.assign(V, inf);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (edge e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

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

    ll N, M;
    cin >> N >> M;
    G.assign(N, vector<edge>());
    while (M--) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back({b, 1});
        G[b].push_back({a, 1});
    }

    set<ll> path;
    deque<ll> order;
    ll start = 0;
    ll finish = G[0][0].to;
    // cout << start << " " << finish << "\n";
    path.insert(0);
    path.insert(G[0][0].to);
    order.push_front(start);
    order.push_back(finish);

    while (true) {
        bool flag = false;
        for (auto e : G[start]) {
            if (path.find(e.to) == path.end()) {
                path.insert(e.to);
                order.push_front(e.to);
                start = e.to;
                flag = true;
                break;
            }
        }

        if (flag) continue;

        for (auto e : G[finish]) {
            if (path.find(e.to) == path.end()) {
                path.insert(e.to);
                order.push_back(e.to);
                finish = e.to;
                flag = true;
                break;
            }
        }

        if (!flag) break;
    }

    cout << order.size() << "\n";

    for (ll e : order) {
        cout << e+1 << " ";
    }

    cout << "\n";

}

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

vector<vector<int>> G;
vector<bool> m0;
vector<bool> m1;
vector<bool> m2;
int S, T;

int main() {
    int N, M;
    cin >> N >> M;
    G.resize(N), m0.resize(N, 0), m1.resize(N, 0), m2.resize(N, 0);
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        G[u].push_back(v);
    }
    cin >> S >> T;
    --S, --T;

    vector<vector<ll>> dist(N, vector<ll>(3, -1));
    dist[S][0] = 0;
    queue<pair<int, int>> q;
    q.push({S, 0});

    while (!q.empty()) {
        int v = q.front().first;
        int p = q.front().second;
        q.pop();
        for (auto nv : G[v]) {
            int np = (p + 1) % 3;
            if (dist[nv][np] == -1) {
                dist[nv][np] = dist[v][p] + 1;
                q.push({nv, np});
            }
        }
    }
    if (dist[T][0] == -1)
        cout << -1 << endl;
    else
        cout << dist[T][0] / 3 << endl;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
long long int p(long long int a, long long int b){
	long long int c = 1;
	for(long long int i = 0;i < b;i++){
		c *= a;
		c = c % 998244353;
	}
	return c;
}
long long int d2[100000];
long long int d[100000];
int main(){
	long long int n;
	long long int d0;
	long long int ans = 1;
	cin >> n;
	cin >> d0;
	if(d0 != 0){
		cout << 0 << endl;
		return 0;
	}
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	for(long long int i = 0;i < 100000;i++) d2[i] = 0;
	for(long long int i = 0;i < n - 1;i++){
		cin >> d[i];
		if(d[i] == 0){
			cout << 0 << endl;
			return 0;
		}
		d2[d[i]]++;
	}
	d2[0] = 1;
	for(long long int i = 1;i < (n - 1);i++){
		ans *= p(d2[i - 1], d2[i]);
		ans = ans %= 998244353;
	}
  cout << ans << endl;
}

Measured memory_bytes: 1792
{-
?????????: Recursion / Divide and Conquer - Koch Curve
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=jp
?????°:
19:13:58 ?????°??¨????????°Haskell???Haskell??¨????????°?????°???????????????????????¨????????°Haskell?????????????????£?????????????????????
19:26:43 ????????????????\????????????????????????????????´???°???
19:27:43 ??¨??????????????????????????????
19:30:18 ????´???°?????????
19:33:48 ????????????
-}
import Control.Applicative
import Control.Monad
import Data.Complex


main = do
 n <- fmap read getLine
 forM_ (koch n) $ \(x:+y) -> putStrLn (show x ++ " " ++ show y)

type Coor = Complex Double

koch :: Int -> [Coor]
koch 0 = [(0:+0), (100:+0)]
koch n = interweave foo $ koch (n-1)

foo :: Coor -> Coor -> [Coor]
foo p1 p2 = [p1+vec, p1 + vec + vec * cis (pi/3) , p2-vec] where vec = (p2-p1)/3

-- interweave f [a,b,c] ==  [a] ++ a `f` b ++ [b] ++ b `f` c ++ [c]
interweave :: (a -> a -> [a]) -> [a] -> [a]
interweave _ [u] = [u]
interweave f (a:b:cs) = [a] ++ a `f` b ++ interweave f (b:cs)

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

using namespace std;

int main(){
	int n;
	cin>>n;
	if(n<=2) cout<<1<<endl;
	else{
		vector<int> v(n);
		for(int i=0; i<n; i++) cin>>v[i];
		
		int i=2, sgn=0, a, ans=0;
		if(v[0]<v[1]) sgn=1;
		else if(v[0]>v[1]) sgn=-1;
		a=v[1];
		while(i<n){
			int ts=0;
			if(a<v[i]) ts=1;
			else if(a>v[i]) ts=-1;
			
			if(sgn==0){
				a=v[i];
				sgn=ts;
				i++;
			}
			else if(sgn==1){
				if(ts>=0){
					a=v[i];
					i++;
				}
				else{
					ans++;
					i++;
					if(i<n) a=v[i];
					else break;
					sgn=0;
					if(v[i-1]<a) sgn=1;
					else if(v[i-1]>a) sgn=-1;
					i++;
				}
			}
			else{
				if(ts<=0){
					a=v[i];
					i++;
				}
				else{
					ans++;
					i++;
					if(i<n) a=v[i];
					else break;
					sgn=0;
					if(v[i-1]<a) sgn=1;
					else if(v[i-1]>a) sgn=-1;
					i++;
				}
			}
		}
		ans++;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 640
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;

int main()
{
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,k;
	cin>>n>>k;
	int r,si,p;
	cin>>r>>si>>p;
	string s;
	cin>>s;
	string s1="";
	int ans=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='r')
		{
			s1+='p';
			ans+=p;
		}
		else if(s[i]=='s')
		{
			s1+='r';
			ans+=r;
		}
		else
		{
			s1+='s';
			ans+=si;
		}
	}
	for(int i=0;i<s1.size()-k;i++)
	{
		if(s1[i+k]==s1[i])
		{	
			if(s1[i]=='r')
			{
				ans-=r;
				if(i+k+k<s1.size()&&s1[i+k+k]=='s')
				{
					s1[i+k]='p';
				}
				else
				{
					s1[i+k]='s';
				}
			}
			else if(s1[i]=='s')
			{
				ans-=si;
				if(i+k+k<s1.size()&&s1[i+k+k]=='r')
				{
					s1[i+k]='p';
				}
				else
				{
					s1[i+k]='r';
				}
			}
			else
			{
				ans-=p;
				if(i+k+k<s1.size()&&s1[i+k+k]=='r')
				{
					s1[i+k]='s';
				}
				else
				{
					s1[i+k]='r';
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
 
parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine
 
main = do
  [a, b, k] <- readIntegerList
  let c = max (a - k) 0
      d = if c == 0 then max (b - (k - a)) 0 else b
  putStrLn . unwords . map show $ [c, d]



Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 


int main(){
  int n,m;
  cin >> n >> m;
  VI a(n);
  VI b(n);
  rep(i,n){
    cin >> a.at(i) >> b.at(i);
  }
  VI c(m);
  VI d(m);
  rep(i,m){
    cin >> c.at(i) >> d.at(i);
  }
  int y;
  rep(i,n){
    ll x=1000000000000;
    rep(j,m){
      ll e=abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));      
      if(e<x){
        x=e;
        y=j+1;
      }
    }
    cout << y << endl;
  }

}

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

typedef long long ll;

const int N = (int)2e5 + 50;

int n, a, b, c, d;
string str;

void No() {
    cout << "No" << endl;
    exit(0);
}

void Yes() {
    cout << "Yes" << endl;
    exit(0);
}

int main() {
    cin >> n >> a >> b >> c >> d;
    a--, b--, c--, d--;
    cin >> str;
    if(str[c] == '#' || str[d] == '#') No();
    if(c < d) {
        for(int i = a; i <= c - 1; i++) {
            if(str[i] == '#' && str[i+1] == '#') No();
        }
        for(int i = b; i <= d - 1; i++) {
            if(str[i] == '#' && str[i+1] == '#') No();
        }
        Yes();
    }
    else {
        for(int i = a; i <= c - 1; i++) {
            if(str[i] == '#' && str[i+1] == '#') No();
        }
        bool jp = false;
        for(int i = b; i <= d; i++) {
            if(i >= 1 && i < n - 1 && str[i-1] == '.' && str[i] == '.' && str[i+1] == '.') Yes();
        }
        No();
    }
}

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

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
const ll MOD = 1e9+7;

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

  ll n, x;
  cin >> n >> x;
  ll ans = n;
  ll a = x, b = n - x;
  while (1) {
    if (a < b) {
      if (b % a == 0) {
        ans += (b / a) * 2 * a - a;
        break;
      }
      ans += (b / a) * 2LL * a;
      ll tmpa = b % a, tmpb = a;
      a = tmpa;
      b = tmpb;
    } else {
      if (a % b == 0) {
        ans += (a / b) * 2 * b - b;
        break;
      }
      ans += 2LL * (a / b) * b;
      a = a % b;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 17 23:38:43 2018

@author: ashida
"""

N=int(input())

A1 = list( map(int, input().split()))
A2 = list( map(int, input().split()))

SA1 = [0]*N
SA2 = [0]*N

SA1[0] = A1[0]
SA2[N-1] = A2[N-1]

for i in range(N-1):
    SA1[i+1] = SA1[i]+A1[i+1]
    SA2[N-2-i] = SA2[N-1-i]+A2[N-2-i]
    
ans = [0]*N

for i in range(N):
    ans[i] = SA1[i]+SA2[i]

print(max(ans))


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		A();
		return;
	}
	
	public static void A() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		if(A==B) System.out.println(C);
		else if(B==C) System.out.println(A);
		else System.out.println(B);
	}
}

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

int main() {
    int n;

    cin >> n;
    vector<int> v(n), c(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    for(int i = 0; i < n; i++)
        cin >> c[i];

    int res = 0;
    for(int i = 0; i < n; i++){
        if(v[i] > c[i])
            res += v[i] - c[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int gcd(int a,int b){
  int i;
  if(a<b)
    swap(a,b);
  for(i=1;a%(b/i);)
    for(i++;b%i;i++);  
  return b/i;
}
long long lcm(int a,int b){
  return (long long)a*b/gcd(a,b);
}
int main(){
  int i;
  int n,b,h,w,bb,hh,ww;
  long long l;
  for(;;){
    cin>>n;
    if(n==0)
      break;
    cin>>bb>>hh>>ww;
    for(i=1;i<n;i++){
      cin>>b>>h>>w;
      l=lcm(hh*hh,h*h);
      if(llabs(ww*10000*l/hh/hh-l*22)>llabs(w*10000*l/h/h-l*22)){
	bb=b;
	hh=h;
	ww=w;
      }
    }
    cout<<bb<<endl;
  }
  return 0;
}

Measured memory_bytes: 868
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let S: String = read();
    if &S == "ARC" {
        println!("ABC");
    } else {
        println!("ARC")
    }
}

#[allow(dead_code)]
fn solve() {}

#[cfg(test)]
#[allow(unused_imports)]
mod tests {
    use super::*;

    #[test]
    fn test1() {
        assert_eq!(true, true);
    }
}


Measured memory_bytes: 2056
from collections import defaultdict

N = int(input())

def pair(n):
    l = n % 10
    while n != 0:
        f = n
        n = n // 10
    return (f, l)

d = defaultdict(int)

for i in range(1, N + 1):
    d[pair(i)] += 1

ans = 0
for key, value in d.items():
    tmp1 = value
    l, f = key
    if (f, l) in d.keys():
        tmp2 = d[(f, l)]   
        ans += tmp1 * tmp2
print(ans)

Measured memory_bytes: 3316
class UnionFind:
    def __init__(self, n):
        self.par = [-1]*(n+1)  # 頂点番号とindexをそろえるためにn+1。idx0は使わない
        self.rank = [0]*(n+1)

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])  # 再帰で根までたどる.その過程で根とつなぎかえる
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        else:
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)  # 根同じならTrue違うならFalseを返す

    def size(self, x):
        return -self.par[self.find(x)]


n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    uf.union(a, b)
st = set()
for i in range(1, n+1):
    st.add(uf.find(i))
print(len(st)-1)

Measured memory_bytes: 79564
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char c;
	cin>>c;
	if(c>='A'&&c<='Z')
		cout<<'A';
	else
		cout<<'a';
	return 0;
}

Measured memory_bytes: 3632
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		Set s = new HashSet<Integer>();
		s.add(a);
		s.add(b);
		s.add(c);
		System.out.println(s.size());
		
	}
}


Measured memory_bytes: 10188
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N - 1; i++)
    {
        ans += (N - 1) / i;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int d,n;cin>>d>>n;
  int ans=1;
  rep(i,d)ans*=100;
  if(n==100)n++;
  cout<<ans*n<<endl;
}

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


int main()
{
        int N,a,i;

        scanf("%d", &N);
        int even=0, odd=0;
        for(i=0; i<N; i++){
            scanf("%d",&a);
            if(a%2==0)  even++;
            else odd++;
        }

        if(odd%2==0){
           puts("YES");
        }
        else puts("NO");

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
 
void Main() {
  int n,m,r;
  cin >> n >> m >> r;
  int a[r];
  rep(i,r) {
    R a[i];
    a[i]--;
  }
  ll d[n][n];
  rep(i,n)rep(j,n) d[i][j]=MAX;
  rep(i,n)d[i][i]=0;
  rep(i,m) {
    ll x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    d[x][y]=min(d[x][y],z);
    d[y][x]=min(d[y][x],z);
  }
  rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  ll ans=MAX;
  sort(a,a+r);
  do {
    ll sum=0;
    rep(i,r-1) sum+=d[a[i]][a[i+1]];
    ans=min(ans,sum);
  } while(next_permutation(a,a+r));
  pr(ans);
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

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

int main(void){
	int L,R;
	int i,I,ans(2018);
	scanf("%d %d",&L,&R);
	if(2019 < R - L) ans = 0; else {
		R = R % 2019;
		L = L % 2019;
		if(L > R) ans = 0;
	}
	if(L == 0) ans = 0;
	for(i = L ; i <= R; i ++){
		if(ans == 0) break;
		for(I = i + 1 ; I <= R ; I ++){
			if(ans > (i * I) % 2019) ans = (i * I) % 2019;
			if(ans == 0) break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long int
#define pp pair<int,int>
#define endl "\n"
#define PI 3.14159265
int MAX = INT_MAX;
const int mod=1e9+7;
const int INF =INT_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
       int n,x,t;
       cin>>n>>x>>t;
       if(n%x==0){cout<<(n/x)*t<<endl;}
       else cout<<((n/x)+1)*t<<endl;


    }
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1000141919
#define MOD 1000000007
inline void chmin(int &x,int v){if(x>v)x=v;}

int N, X, D;
int A[50], C[50];
vector<int> G[50];

void dfs(int x) {
  C[x] = 1;
  for (int t : G[x]) {
    dfs(t);
    C[x] += C[t];
    A[x] = min(A[x]+A[t], INF);
  }
}

const int MAX = 5000;
int dp[2][MAX+1];
int W[30];
void decomp(int a) {
  // w<=2
  rep(k, 30) {
    if (a >= 1<<k) W[k]++, a -= 1<<k;
    else break;
  }
  rep(k, 30) if ((a>>k)&1) W[k]++;
}

int f(int Y) {
  rep(j, MAX+1) dp[0][j] = INF;
  dp[0][0] = 0;
  int m = INF;
  for (int k=29; k>=0; k--) {
    rep(j, MAX+1) dp[1][j] = INF;
    rep(j, MAX+1) if (2*j+((Y>>k)&1) <= MAX) chmin(dp[1][2*j+((Y>>k)&1)], 2*dp[0][j]);
    swap(dp[0], dp[1]);

    rep(i, N) {
      int w = i==0?1:W[k];
      rep(_, w) rep(j, MAX+1) {
        if (j >= C[i]) chmin(dp[0][j-C[i]], dp[0][j]+A[i]);
        else chmin(m, min(0LL+INF, (0LL+dp[0][j]+A[i])<<k));
      }
    }
  }
  m = min(m, dp[0][0]);
  //cout<<"f("<<Y<<")="<<m<<"\n";
  return m;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> X >> D;
  rep(i, N) {
    cin >> A[i];
    if (i != 0) {
      int p; cin >> p; p--;
      G[p].pb(i);
    }
  }
  dfs(0);
  decomp(D);
  //rep(i, N) cout<<C[i]<<"->"<<A[i]<<"\n";

  int lo = 0, hi = 1e9+10;
  while (hi-lo>1) {
    int mid = (lo+hi)/2;
    if (f(mid) <= X) lo = mid;
    else hi = mid;
  }
  cout << lo << "\n";
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;

  vector<int> a(n);
  REP(i, n) cin >> a[i];

  REP(i, min(k, 51)) {
    vector<int> b(n, 0);

    REP(i, n) {
      int l = max(i - a[i], 0);
      int r = min(i + a[i], n - 1);

      b[l]++;
      if(r + 1 < n) b[r + 1]--;
    }

    FOR(i, 1, n) b[i] += b[i - 1];

    a = b;
  }

  REP(i, n) cout << a[i] << " ";
  cout << endl;
}


Measured memory_bytes: 4964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

class UnionFind{
public:
    vector<int> par;
    vector<int> rank;
    UnionFind(int n){
        init(n);
    }
    void init(int n){
        par.resize(n);
        for(int i=0;i<n;i++){
            par[i] = i;
        }
        rank.assign(n, 0);
    }
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

struct edge{
    int u, v;
    double c;
    edge(int u, int v, double c) : u(u), v(v), c(c) {}
    bool operator<(const edge& right) const {
        return c > right.c;
    }
};

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

    vector<int> x(N), y(N);
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i];
    }

    double total_cost = 0;
    vector<edge> edges;
    UnionFind uf(N);
    for(int i=0;i<M;i++){
        int p, q;
        cin >> p >> q;
        p--; q--;
        uf.unite(p, q);
        double cost = sqrt((x[p]-x[q]) * (x[p]-x[q]) + (y[p]-y[q]) * (y[p]-y[q]));
        edges.emplace_back(p, q, cost);
        total_cost += cost;
    }

    sort(edges.begin(), edges.end());

    map<int, vector<int>> mp;
    for(int i=0;i<N;i++){
        mp[uf.find(i)].push_back(i);
    }

    uf.init(N);
    for(const auto& p : mp){
        const vector<int>& vs = p.second;
        vector<bool> active(N, false);
        for(int v : vs){
            active[v] = true;
        }
        for(edge& e : edges){
            if(active[e.u] && active[e.v] && !uf.same(e.u, e.v)){
                uf.unite(e.u, e.v);
                total_cost -= e.c;
            }
        }
    }
    printf("%.4f\n", total_cost);

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if(a * b % 2) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}


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

using namespace std;

int main() {
  string S;
  cin >> S;

  int ans = 1e9;
  for (int i = 0; i < S.length() - 2; i++) {
    string ss = S.substr(i, 3);
    ans = min(ans, abs(753 - stoi(ss)));
  }

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


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    R = I()
    print(2 * R * 3.1415926535)

main()



Measured memory_bytes: 10940
/////////////==========================
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================


int main(){
    int n , m;
    cin >> n >> m;
    int temp; 
    vector<int> v;    int sum = 0; int count = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> temp; sum+= temp;
        v.push_back(temp);
    }
    double req = (double)sum / ((double)m * 4);
    
    for (int i = 0; i < n; i++)
    {
        if( v[i] >= req){
            count++;
        }
    }

    if(count >= m){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    


    

}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  s <- getLine
  unless (s == "#") $ do
    putStrLn $ solve $ words s
    main

solve :: [String] -> String
solve [g, y, m, d]
  | iy < 31 || iy == 31 && im < 5 = unwords [g, y, m, d]
  | otherwise = unwords ["?", show (iy - 30), m, d]
  where
    iy = read y
    im = read m



Measured memory_bytes: 4120
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	int sum = 0;
	rep(i,n)sum+=a[i];
	sum-=n;
	cout<<sum<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int 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();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=305;
char s[maxn];
int f[maxn][maxn][maxn],k,n;
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	read(k);int ans=0;
	rep(i,1,n)per(j,n,i)rep(p,0,k){
		f[i][j][p]=max(f[i-1][j][p],f[i][j+1][p]);
		if(s[i]==s[j])f[i][j][p]=max(f[i][j][p],f[i-1][j+1][p]+1+(i!=j));
		if(p){
			f[i][j][p]=max(f[i][j][p],f[i-1][j+1][p-1]+1+(i!=j));
		}
		ans=max(ans,f[i][j][p]);
	}cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 110592
def check(m, f, r)
  return 'F' if m == -1 || f == -1
  return m + f >= 80 ? 'A' :
         m + f >= 65 ? 'B' :
         m + f >= 50 || m + f >= 30 && r >= 50 ? 'C' :
         m + f >= 30 ? 'D' : 'F'
end

while (n = gets.split(' ').map(&:to_i)) != [-1, -1, -1]
  m, f, r = n
  puts check(m, f, r)
end

Measured memory_bytes: 8632
"""Minimum cost Sort."""

def min_cost_sort(A):
    """Sort list A in ascending order.
 
    And return the switching cost in sorting.
    """
    B = list(A)
    B.sort()
    cost = 0
    min_w = B[0]
    for i, b in enumerate(B):
        tmp_cost = 0
        bi = A.index(b)
        cnt = 0
        while bi != i:
            cnt += 1
            st = B[bi]
            si = A.index(st)
            tmp_cost += b + st
            A[bi], A[si] = st, b
            bi = si
        dec = cnt * (b - min_w)
        inc = 2 * (min_w + b)
        if dec < inc:
            cost += tmp_cost
        else:
            cost += tmp_cost - dec + inc
    return cost


n = input()

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

ans = min_cost_sort(A)

print(ans)

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

using namespace std;

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int n = a * x + b * y;

  int m = 2 * c * max(x, y);

  int p = x < y ? b : a;

  int l = 2 * c * min(x, y) + p * abs(x - y);

  cout<<min(n, min(m, l))<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
#define LL long long
#define inf 0x3f3f3f3f
#define lson rt<<1
#define rson rt<<1|1
#define PII pair<int,int>
#define test freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
const int maxn=1e5+5;
int n;
PII a[maxn],b[maxn];
int fa[maxn];
int main()
{
    //test
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&a[i].first),a[i].second=i;
    for(int i=1;i<=n;++i) scanf("%d",&b[i].first),b[i].second=i;
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    for(int i=1;i<=n;++i) 
    {
        if(a[i].first>b[i].first) {cout<<"No";return 0;}
        fa[b[i].second]=a[i].second;
    }
    for(int i=1;i<n;++i) if(i!=n&&a[i+1].first<=b[i].first) {cout<<"Yes";return 0;}
    int x=1,ct=0;
    do 
    {
        x=fa[x];
        ++ct;
    }while(x!=1);
    if(ct==n) cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 2176
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S;
ll cntA = 0;
ll cnt = 0;
int main() {
	cin >> S;
	if(S[0] != 'A') {
		printf("WA\n");
		return 0;
	}
	for(int i = 2; i <= S.size() - 2; i++) {
		if(S[i] == 'C'){
			cnt++;
		}
	}
	if(cnt != 1) {
		printf("WA\n");
		return 0;
	}
	for(int i = 0; i < S.size(); i++) {
		if(S[i] - 'a' < 0) {
			cntA++;
		}
	}
	if(cntA > 2) {
		printf("WA\n");
		return 0;
	}

		printf("AC\n");
	
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k =s.nextInt();
        int arr[] = new int[n];
        for(int i= 0;i<n;i++){
            arr[i] = s.nextInt();
        }
        int dp[] = new int[n];
        dp[0] = 0;
        for(int i= 1;i<n;i++){
            int min = 1000000007;
            for(int j = i-1;j>=0 && j>=(i-k);j--){
                min = Math.min(Math.abs(arr[i] - arr[j])+dp[j],min);
            }
            dp[i] = min;
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 50068
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 500005
//<<fixed << setprecision(9)

int arr[space];
int cnt[space];
int distinct;

const int block_size=700;

struct Query
{
    int l, r, idx;
    bool operator<(Query other) const
    {
        if(l/block_size != other.l/block_size) return l<other.l;
        return ((l/block_size)&1) ? r<other.r : r>other.r ;
    }
};

void add(int x)
{
    cnt[arr[x]]++;
    if(cnt[arr[x]]==1) distinct++;
}
void remove(int x)
{
    cnt[arr[x]]--;
    if(cnt[arr[x]]==0) distinct--;
}

int main()
{
    int n,i,j,t;
    boost;

    cin>>n>>t;

    rep(i,1,n+1) cin>>arr[i];

    Query Q[t];
    int ans[t];
    rep(i,0,t)
    {
        int l,r;
        cin>>l>>r;
        Q[i]={l,r,i};
    }
    sort(Q,Q+t);

    int cur_l = 1;
    int cur_r = 0;
    
    for (Query q : Q)
    {
        while (cur_l > q.l) {
            cur_l--;
            add(cur_l);
        }
        while (cur_r < q.r) {
            cur_r++;
            add(cur_r);
        }
        while (cur_l < q.l) {
            remove(cur_l);
            cur_l++;
        }
        while (cur_r > q.r) {
            remove(cur_r);
            cur_r--;
        }
        ans[q.idx] = distinct;
    }

    rep(i,0,t)cout<<ans[i]<<'\n';

    return 0;
}

Measured memory_bytes: 15464
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=998244353;
map<int,int> mii;
int d[200050];
int vis[200050];
int main()
{
    ios::sync_with_stdio(false);
    ll k,n,t=0;
    cin >> k >> n;
    ll x,fir=0,ans=0,ma=0;
    cin >> fir;
    t+=fir;
    for(int i=1;i<n;i++){
        cin >> x;
        d[i]=x-fir;
        fir=x;
        if(ma<=d[i])
            ma=d[i];
        ans+=d[i];
    }
    t+=k-x;
    if(t<ma)
        ans=ans+t-ma;
    cout << ans;
    return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    int h[n];
    rep(i, n) cin >> h[i];
    int a, b;
    int ans[n];
    rep(i, n) ans[i] = 1;
    int cnt = n;

    rep(i, m)
    {
        cin >> a >> b;
        a--;
        b--;
        if (h[a] > h[b])
        {
            if (ans[b] == 1)
            {
                cnt--;
                ans[b] = 0;
            }
        }
        else if (h[a] < h[b])
        {
            if (ans[a] == 1)
            {
                cnt--;
                ans[a] = 0;
            }
        }
        else if (h[a] == h[b])
        {
            if (ans[a] == 1)
            {
                cnt--;
                ans[a] = 0;
            }
            if (ans[b] == 1)
            {
                cnt--;
                ans[b] = 0;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4416
#include<bits/stdc++.h>
#define ll                    long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)          for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define eb                    emplace_back
#define ab(a)                 (a<0)?(-1*a):a
#define pc                    putchar_unlocked
#define gc                    getchar_unlocked
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define max(x,y)              (x>y)?x:y
#define min(x,y)              (x<y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
const int MX=10010896;
const int lmt=3164;
const int N=10000001;
int flag[MX>>6];
#define ifc(i)                (flag[i>>6]&(1<<((i>>1)&31)))
#define isc(i)                (flag[i>>6]|=(1<<((i>>1)&31)))
#define chk(n)                (n==2||(n>2&&(n&1)&&!ifc(n)))
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
void sieve(){ int i,j,k; for(i=3;i<lmt;i+=2) if(!ifc(i)) for(j=i*i,k=i<<1;j<MX;j+=k) isc(j);}

ll val[N],wei[N];
ll ans[105][100005];
void init()
{
    memset(ans,-1,sizeof(ans));
}
ll dp(ll n,ll w)
{
    if(n==0 || w==0)
    return 0;
    if(ans[n][w]!=-1)
    return ans[n][w];
    else if(wei[n]>w)
    return ans[n][w]=dp(n-1,w);
    else
    {
        ans[n][w]=max(val[n]+dp(n-1,w-wei[n]),dp(n-1,w));
    }
}
void solve()
{
    init();
    ll n,w;
    cin>>n>>w;
    for(ll i=1;i<=n;i++)
    {
        cin>>wei[i]>>val[i];
    }
    dp(n,w);
    cout<<ans[n][w];
}
int main()
{
	int t;
    t=1;
    while(t--)
    {
        solve();
    }
}


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

int main()
{
	int n;
	cout << fixed << setprecision(8);
	cin >> n;
	vector<int> x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> y[i];
	}
	double res = 0;
	for (int i = 0; i < n; i++) {
		res += abs(x[i] - y[i]);
	}
	cout << res << endl;
	res = 0;
	for (int i = 0; i < n; i++) {
		res += (x[i] - y[i]) * (x[i] - y[i]);
	}
	cout << sqrt(res) << endl;
	res = 0;
	for (int i = 0; i < n; i++) {
		res += abs(x[i] - y[i]) * abs(x[i] - y[i]) * abs(x[i] - y[i]);
	}
	cout << pow(res, 1.0 / 3.0) << endl;
	int che = 0;
	for (int i = 0; i < n; i++) {
		che = max(che, abs(x[i] - y[i]));
	}
	cout << che << endl;
	return 0;
}

Measured memory_bytes: 3440