akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <cstdio>
using namespace std;

typedef int Weight;
const Weight INF=99999999;

struct Edge{
	int dst,cap;Weight cost,rev;
};
typedef vector<Edge> Node;
typedef vector<Node> Graph;

//srcからdstへ向かう容量cap,コストcostの辺をグラフに追加する
void add_edge(Graph &G,int src,int dst,Weight cap,Weight cost){
	G[src].push_back((Edge){dst,cap,cost,G[dst].size()});
	G[dst].push_back((Edge){src,0,-cost,G[src].size()-1});
}

//sからtへの流量fの最小費用流を求める
//流せない場合は-1を返す
int min_cost_flow(Graph &G,int s,int t,int f){
	typedef pair<int,int> P;
	int res=0;
	int V=G.size();
	vector<Weight> h(V,0);
	vector<int> prevv(V);
	vector<int> preve(V);
	
	while(f>0){
		priority_queue<P,vector<P>,greater<P> > que;
		vector<Weight> dist(V,INF);
		dist[s]=0;
		que.push(P(0,s));
		while(!que.empty()){
			P p=que.top();que.pop();
			int v=p.second;
			if(dist[v]<p.first)continue;
			for(int i=0;i<(int)G[v].size();i++){
				Edge &e=G[v][i];
				if(e.cap>0&&dist[e.dst]>dist[v]+e.cost+h[v]-h[e.dst]){
					dist[e.dst]=dist[v]+e.cost+h[v]-h[e.dst];
					prevv[e.dst]=v;
					preve[e.dst]=i;
					que.push(P(dist[e.dst],e.dst));
				}
			}
		}
		if(dist[t]==INF){	
			return -1;
		}
		for(int v=0;v<V;v++)h[v]+=dist[v];

		int d=f;
		for(int v=t;v!=s;v=prevv[v]){
			d=min(d,G[prevv[v]][preve[v]].cap);
		}
		f-=d;
		res+=d*h[t];
		for(int v=t;v!=s;v=prevv[v]){
			Edge &e=G[prevv[v]][preve[v]];
			e.cap-=d;
			G[v][e.rev].cap+=d;
		}
	}
	return res;
}
int E[100][100];
int W[100][100];
char str[100][102];
int D[100][100];
int R[10000];
int C[10000];
char ope[10001];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++)
			scanf("%d",&W[i][j]);
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++)
			scanf("%d",&E[i][j]);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	Graph g(2+a*2);
	for(int i=0;i<a;i++){
		add_edge(g,a*2,i,1,0);
		add_edge(g,i+a,a*2+1,1,0);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(str[i][j]=='.')D[i][j]+=W[i][j];
			for(int k=0;k<a;k++){
				if(j!=k&&str[i][k]=='o')D[i][j]+=E[i][k];
			}
	//		printf("%d ",D[i][j]);
		}//printf("\n");
	}
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++)
			add_edge(g,i,a+j,1,D[i][j]);
	int ret=min_cost_flow(g,a*2,a*2+1,a);
	printf("%d\n",ret);
	int n=0;
	for(int i=0;i<a;i++){
		for(int j=0;j<g[i].size();j++){
			if(g[i][j].dst<a*2){
				if(g[i][j].cap==0&&str[i][g[i][j].dst-a]=='.'){
					R[n]=i;
					C[n]=g[i][j].dst-a;
					ope[n++]='w';
				}
				if(g[i][j].cap&&str[i][g[i][j].dst-a]=='o'){
					R[n]=i;
					C[n]=g[i][j].dst-a;
					ope[n++]='e';
				}
			}
		}
	}
	printf("%d\n",n);
	for(int i=0;i<n;i++){
		printf("%d %d ",R[i]+1,C[i]+1);
		if(ope[i]=='e')printf("erase\n");
		else printf("write\n");
	}
}

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

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

        if (a + b == c + d) {
            System.out.println("Balanced");
        } else if (a + b < c + d) {
            System.out.println("Right");
        } else {
            System.out.println("Left");
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int c=0;
    if(n==1)
    {
        c++;
    }
    else
    {
        c++;
        char pre = s[0];
        for(int i=1;i<n;i++)
        {
            if(s[i]!=pre)
            {
                c++;
                pre=s[i];
            }
        }
    }
    cout<<c<<endl;
}


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

template<class I, class BiOp = I (*) (I, I)>
class SegTree {
private:
  int n;
  std::vector<I> dat, lazy;
  BiOp op;
  I e;

public:
  SegTree(int n_, BiOp op, I e) : op(op), e(e) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, 0);
    lazy.resize(2 * n - 1, 0);
  }

  void eval(int k, int l, int r) {
    if (lazy[k] == 0) return;
    // cerr << "eval: k = " << k << ", l = " << l << ", r = " << r << endl;
    dat[k] += lazy[k];
    if (k < n - 1) {
      lazy[2 * k + 1] += lazy[k];
      lazy[2 * k + 2] += lazy[k];
    }
    lazy[k] = 0;
  }

  void update(int a, int b, I x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    // cerr << "update: a = " << a << ", b = " << b << ", x = " << x << ", k = " << k << ", l = " << l << ", r = " << r << endl;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] += x;
      eval(k, l, r);
    }
    else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      dat[k] = op(dat[2 * k + 1], dat[2 * k + 2]);
    }
  }

  I query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    // cerr << "query: a = " << a << ", b = " << b << ", k = " << k << ", l = " << l << ", r = " << r << endl;
    eval(k, l, r);
    if (b <= l || r <= a) return INT_MAX;
    if (a <= l && r <= b) return dat[k];
    I vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    I vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return op(vl, vr);
  }

  void print() {
    int j = 2;
    for (int i = 0; i < 2 * n - 1; i++) {
      cerr << "(" << dat[i] << ", " << lazy[i] << ")";
      if (i == j - 2) {
        cerr << endl;
        j *= 2;
      }
      else {
        cerr << " ";
      }
    }
  }
};

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

  int n, q;
  cin >> n >> q;
  SegTree<int> seg(n, [](int a, int b){return min(a, b);}, INT_MAX);

  // seg.print();

  rep(i, q) {
    // cerr << "i = " << i << endl;

    int t;
    cin >> t;
    if (t == 0) {
      int a, b, x;
      cin >> a >> b >> x;
      seg.update(a, b + 1, x);
    }
    else {
      int a, b;
      cin >> a >> b;
      cout << seg.query(a, b + 1) << endl;
    }

    // seg.print();
    // cerr << endl;
  }

  return 0;
}



Measured memory_bytes: 4948
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

N,M=MI()
SC=[tuple(map(int,input().split())) for _ in range(M)]
def check(n):
  n=str(n)
  if len(n)!=N:
    return False
  for i in range(M):
    if n[SC[i][0]-1]!=str(SC[i][1]):
      return False
  return True

for i in range(1000):
  if check(i):
    print(i)
    exit()
else:
   print(-1)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    string w;
    cin >> w;
    int counter[255];
    rep(i,255){
        counter[i]=0;
    }
    int k=0;
    bool result=true;
    while(w[k]!='\0'){
        counter[w[k++]]++;
    }
    for(int i=(int)'a';i<=(int)'z';++i){
        if(counter[i]%2==1){
            result=false;
            break;
        }
    }
    if(result){
        Yes;
    }else{
        No;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 2e5 + 10;
int a[N];
int main() {
  int n, T;
  scanf("%d%d", &n, &T);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int64 ret = T;
  for (int i = 1; i < n; ++i) {
    ret += min(T, a[i] - a[i - 1]);
  }
  printf("%lld\n", ret);
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    string C;
    cin >> C;
    if (C != "Y"){
      if (i == N - 1){
        cout << "Three" << endl;
      }
      else{
        continue;
      }
    }
    else{
      cout << "Four" << endl;
      break;
    }
  }
}
    

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int isPrime(int);

int main(){
  int i,n,d;
  int prime_sum=0;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&d);
    prime_sum += isPrime(d);
  }
  printf("%d\n",prime_sum);
}

int isPrime(int p){
  int sq;
  int i;
  if(p < 2) return 0;
  else if(p == 2) return 1;
  else if(p % 2 == 0)return 0;

  sq = sqrt(p);
  for(i=3; i<=sq; i+=2){
    if(p % i == 0) return 0;
  }
  return 1;
}



Measured memory_bytes: 2100
import numpy as np
N, K = map(int, input().split())
snuke = np.zeros(N, dtype=int)
for n in range(K):
    snack = int(input())
    d_snuke = map(int, input().split())
    for d in d_snuke:
        snuke[d-1] = snack
print(N-np.count_nonzero(snuke, axis=0))

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;
const lf pi = acos(-1);

int n,L,t[maxn];
lf x,y;

void get(int a,int b) {
    if(a>b) {
        lf p=(t[b]+L-t[a])/2.0;
        lf w=1.0*t[a]+p;if(w>L) w-=L;
        x+=cos(2.0*pi*w/L)*(a-b-1);
        y+=sin(2.0*pi*w/L)*(a-b-1);
        // if(a-b-1) printf("%d %d %.3lf %d\n",a,b,w,a-b-1);
    } else {
        lf w=(t[a]+t[b])/2.0;
        x+=cos(2.0*pi*w/L)*(n-(b-a+1));
        y+=sin(2.0*pi*w/L)*(n-(b-a+1));
        // if(n-(b-a+1)) printf("%d %d sc %.3lf %d\n",a,b,w,n-(b-a+1));
    }
}

int main() {
    read(n),read(L);
    for(int i=1;i<=n;i++) read(t[i]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(i!=j) get(i,j);
    lf pps=1.0*n*(n-1)*(n-2)/6.0;
    printf("%.10lf %.10lf\n",x/pps,y/pps);
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Endl endl
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    vi data(n);
    rep(i, n) cin >> data[i];
    sort(all(data));
    cout << (data[data.size()-1] - data[0]) << endl;

    return 0;
}



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

#define allof(a) (a).begin(),(a).end()

using lint = long long;
using pii = pair< int, int >;
template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int main() {
	int N;
	cin >> N;
	
	set< pii > edge;
	for (int a=1; a<=N; ++a) for (int b=a+1; b<=N; ++b) edge.insert(pii(a, b));
	
	if (N % 2 == 0) {
		for (int v=1; v<=N; ++v) edge.erase(pii(v, N-v+1));
	}
	else {
		for (int v=1; v<N; ++v) edge.erase(pii(v, N-v));
	}
	
	cout << edge.size() << endl;
	for (pii p : edge) cout << p.first << " " << p.second << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//


Measured memory_bytes: 512
//なぁにこれぇ

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b) f(i,0,n){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

/*****************************************************************************/


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

	int n;
	cin >> n;
	vvi F(n, vi(10));
	vvi P(n, vi(11));
	f(i, 0, n) {
		f(j, 0, 10) {
			cin >> F[i][j];
		}
	}
	f(i, 0, n) {
		f(j, 0, 11) {
			cin >> P[i][j];
		}
	}
	int res = -(1 << 30);
	f(b, 1, (1 << 10)) {
		int cc = 0;
		f(i, 0, n) {
			int c = 0;
			f(j, 0, 10) {
				if ((b >> j & 1) && F[i][j]) {
					c++;
				}
			}
			cc += P[i][c];
		}
		if (res < cc)res = cc;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long r, wrong = 0;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define w(t) int t; cin>>t;while(t--)
#define ps(x, y) fixed<<setprecision(y)<<x
// double ans = 1.012345668992
//cout<<ps(ans , 6)
// ans = 1.012345 // 6 decimal places
#include<iomanip>
#include<cmath>
#include "cmath"
#include "iostream"
void pi() {

	// Find value of pi using
	// asin() function
	double pi = 2 * asin(1.0);

	// Print value of pi
	printf("%f\n", pi);
}

const double PI = 3.14159264;
int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r", stdin);
//	freopen("output.txt" , "w", stdout);
#endif
	

	
		int n;
		cin >> n;
		if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
cout<<"hon"<<"\n";
  else if (n%10==0||n%10==1||n%10==6||n%10==8)
    cout<<"pon"<<"\n";
  else cout<<"bon"<<"\n";
	return 0;


}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#define endl '\n'
#define ll unsigned long long
//#define mod 1000000007
#define NCONS 101

using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcd(ll a, ll b)
{
	if (b > a) swap(a, b);
	auto ret = gcd(a, b);
	ret *= (a / ret) * (b / ret);
	return ret;
}

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	int N; vector<ll> vec;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		ll temp; cin >> temp;
		vec.push_back(temp);
	}
	ll ret = 1;
	for (int i = 0; i < N; i++)
	{
		ret = lcd(vec[i], ret);
	}
	cout << ret;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; i++) cin >> H[i];
  
  int counter = 0;
  bool f;
  for(int i = 0; i < N; i++){
    f = false;
    for(int j = 0; j <= i; j++){
    if(H[i] < H[j]) f = true;
    }
  if(f == false) counter++;
  }
  cout << counter;
}




Measured memory_bytes: 256
from collections import defaultdict
 
N = int(input())
raw_numbers = list(map(int, input().split()))
Q = int(input())
 
total = sum(raw_numbers)
 
numbers = defaultdict(int)
 
for num in raw_numbers:
    numbers[num] += 1

for _ in range(Q):
    a, b = map(int, input().split())
    taken = numbers[a]
    total -= numbers[a]*a
    numbers[b] += numbers[a]
    numbers[a] = 0
    total += taken*b
    print(total)

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

typedef long long ll;
typedef pair<int, int> P;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795;

int main (){
	ll H, W;
    cin >> H >> W;
    string C;
    for(int i=0; i<H; i++){
        cin >> C;
        for(int j=0; j<2; j++){
            cout << C << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
s = input()

n = len(s)

flg = True

if n != 4:
    flg = False  

else:  
    l = []
    for i in range(n):
        l.append(s[i])
    l.sort()
    if l[0] != l[1] or l[1] == l[2] or l[2] != l[3]:
        flg = False

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

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline


def main():
    N, Y = map(int, input().split())

    M = Y//1000
    for x in range(M//9 + 1):
        for y in range(M//4 + 1):
            z = M - x*10 - y*5
            if x+y+z == N and z>=0:
                print(' '.join(map(str, [x, y, z])))
                return
    print('-1 -1 -1')


if __name__ == '__main__':
    main()

Measured memory_bytes: 39536
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s,t;
int main(){
        cin >> s >> t;
        sort(begin(s),end(s));sort(begin(t),end(t));
        reverse(begin(t),end(t));
        if(s<t){
          cout << "Yes" << endl;
        }
        else{
          cout <<"No" << endl;
        }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main(){
	int a,b,c;
	while(scanf("%d %d %d",&a,&b,&c)!=EOF){
		a%=b;
		int ans=0;
		for(int i=0;i<c;i++){
			a*=10;
			ans+=a/b;
			a%=b;
		}
		printf("%d\n",ans);
	}
}

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

int main(){
  int n;
  int taro_point = 0;
  int hanako_point = 0;
  string taro_card;
  string hanako_card;

  cin >> n;

  for(int i = 0;i < n;i++){
    cin >> taro_card >> hanako_card;

      if(taro_card > hanako_card){
        taro_point += 3;
      }else if(taro_card < hanako_card){
        hanako_point += 3;
      }else{
        hanako_point += 1;
        taro_point += 1;
    }

  }
  cout << taro_point << " " << hanako_point << endl;
  return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

int main() {
  int N;
  long int *A;
  long int *B;
  long int tmp,counter=0;
  int i;
  

  cin >> N; 

  A = new long int[N];
  B = new long int[N];  

  for(i=0; i<N; i++){
    cin >> A[i];
    cin >> B[i];
  }
  
  for(i=N-1;i>=0;i--){
    tmp = (A[i]+counter)%B[i];
    if(tmp > 0)
      counter += B[i]-tmp;
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 1792
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
mod=10**9+7


n_max=(2*10**5+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
for i in reversed(range(n_max-1)):
  FI[i]=(FI[i+1]*(i+1))%mod
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod
def I(x):
  return pow(x,mod-2,mod)

edge=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
Ans=[]
inf=10**6

#親と入次数を求める
Par=[inf]*n
Par[0]=-1
Deg=[0]*n
Deg[0]=0
Chk=[0]
while Chk:
  c=Chk.pop()
  for next in edge[c]:
    if Par[next]==inf:
      Par[next]=c
      Deg[next]+=1
      Chk.append(next)
 
#トポソする
from collections import deque
TS=list(v for v in range(n) if Deg[v]==0)
D=deque(TS)
while D:
  v=D.popleft()
  for t in edge[v]:
    if t!=Par[v]:
      Deg[t]-=1
      if Deg[t]==0:
        D.append(t)
        TS.append(t)

Used=[False]*n
C=[0]*n
for i in reversed(range(n)):
  v=TS[i]
  Used[v]=True
  for g in edge[v]:
    if not Used[g]:
      C[g]+=C[v]+1

D=[1]*n
for i in reversed(range(n)):
  v=TS[i]
  D[v]=(D[v]*F[C[v]])%mod
  if Par[v]!=-1:
    D[Par[v]]=(D[Par[v]]*I(F[C[v]+1])*D[v])%mod
E=[1]*n
for i in range(n):
  v=TS[i]
  if Par[v]!=-1:
    cur=E[v]*FI[n-C[v]-1]
  else:
    cur=1
  for e in edge[v]:
    if e!=Par[v]:
      cur=(cur*FI[C[e]+1]*D[e])%mod
  for e in edge[v]:
    if e!=Par[v]:
      E[e]=(cur*F[n-2-C[e]]*F[C[e]+1]*I(D[e]))%mod
for i in range(n):
  print((comb(n-1,C[i])*D[i]*E[i])%mod)

Measured memory_bytes: 126896
#include <bits/stdc++.h>
using namespace std;
queue <pair<int,int> > q;
int main() {
    int n,m;
    cin>>n>>m;
    char ch[n+1][m+1];
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            cin>>ch[i][j];
    int ans=0;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            if (ch[i][j]=='.') {
                int fix[n+1][m+1];
                for (int a=1;a<=n;a++)
                    for (int b=1;b<=m;b++)
                        fix[a][b]=-1;
                fix[i][j]=0;
                q.push({i,j});
                while (q.size()) {
                    int x=q.front().first;
                    int y=q.front().second;
                    q.pop();
                    if (x>1 && ch[x-1][y]=='.' && fix[x-1][y]==-1) {
                        fix[x-1][y]=fix[x][y]+1;
                        ans=max(ans,fix[x-1][y]);
                        q.push({x-1,y});
                    }
                    if (x<n && ch[x+1][y]=='.' && fix[x+1][y]==-1) {
                        fix[x+1][y]=fix[x][y]+1;
                        ans=max(ans,fix[x+1][y]);
                        q.push({x+1,y});
                    }
                    if (y>1 && ch[x][y-1]=='.' && fix[x][y-1]==-1) {
                        fix[x][y-1]=fix[x][y]+1;
                        ans=max(ans,fix[x][y-1]);
                        q.push({x,y-1});
                    }
                    if (y<m && ch[x][y+1]=='.' && fix[x][y+1]==-1) {
                        fix[x][y+1]=fix[x][y]+1;
                        ans=max(ans,fix[x][y+1]);
                        q.push({x,y+1});
                    }
                }
            }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 2e5 + 7;
 
int com[N];
 
bool cmp(int a, int b)
{
    return a > b;
}
 
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> com[i];
    
    sort(com + 1, com + 1 + n, cmp);
    long long ans = 0;
    int cnt = 0;
    for(int i = 1; ; i++)
    {
        if(cnt == n - 1)
            break;
        
        ++cnt;
        ans += com[i];
        if(cnt == n - 1)
            break;
 
        if(cnt != 1 && cnt != n - 1)
        {
            ans += com[i];
            cnt++;
        }
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4428
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N], B[N], C[N];
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];
    for(int i=0;i<N-1;i++) cin >> C[i];
    int ans = 0;
    int p=0;
    for(int i=0;i<N;i++){
        ans+=B[A[i]-1];
        if(i<N-1 && A[i]+1 == A[i+1]) ans += C[A[i]-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    int alphabet[26] = {};
    for (char c : s) alphabet[c - 'a']++;

    int ans = 1 << 28;
    REP(i, 0, 26) {
        if (alphabet[i] == 0) continue;

        int cnt = 0;
        string prev = s;
        while (1) {
            int replace = 0;
            string next;
            REP(j, 0, prev.size() - 1) {
                if (prev[j] == 'a' + i) {
                    if (j + 1 == prev.size() - 1) {
                        if (prev[j] != prev[j + 1]) replace++;
                    }
                    next += (char)('a' + i);
                    continue;
                }
                if (prev[j + 1] == 'a' + i) {
                    next += (char)('a' + i);
                } else {
                    next += prev[j];
                }
                replace++;
            }
            if (replace == 0) break;
            prev = next;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	map<vector<int>,int> mp;
	int ans = 0;
	int N;
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		string s;
		vector<int> a(26);
		
		cin>>s;
		
		for(int j = 0; j < s.size(); j++){
			a[s[j] - 'a']++;
		}
		
		ans += mp[a];
		mp[a]++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 29952
N, K = list(map(int, input().split()))
a = [i - 1 for i in list(map(int, input().split()))]
logK = K.bit_length()
doubling = [[-1 for _ in range(N)] for _ in range(logK)]
for i in range(N):
    doubling[0][i] = a[i]
for i in range(logK - 1):
    for j in range(N):
        doubling[i + 1][j] = doubling[i][doubling[i][j]]
now, i = 0, 0
while K > 0:
    if (K & 1):
        now = doubling[i][now]
    K = K >> 1
    i += 1
print(now + 1)


Measured memory_bytes: 217420
#include <stdio.h>
int main () {
  int n, a[100], i, v, j, k;

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

  for(i = 0 ; i < n ; i++) {
    printf("%d", a[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n");

  for(i = 1 ; i <= n-1 ; i++) {
    v = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
      a[j+1] = v;
    }
    for(k = 0 ; k < n ; k++) {
      printf("%d", a[k]);
      if(k != n-1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
using namespace std;
int main(void){
  int a,b;
  cin >> a >> b;
  
  if(a == b){
    for(int i=0;i<b;i++){
      cout << a;
    }
    cout << endl;
  }
  else{
    if(a > b){
      for(int i=0;i<a;i++){
        cout << b;
      }
      cout << endl;
    }
    
    else{
      for(int i=0;i<b;i++){
      cout << a;
    }
    cout << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
using namespace std;
int a[310][310];
void broke(int x){
	printf("%d\n",x);
	exit(0);
}
int main(){
//	freopen("D.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				if(a[i][k]+a[k][j]<a[i][j])
					broke(-1);
	bool bo;
	long long ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			bo=1;
			for(int k=1;k<=n;k++)
				if(k!=i&&k!=j&&a[i][k]+a[k][j]==a[i][j]){
					bo=0;
					break;
				}
			ans=ans+a[i][j]*bo;
		}
	printf("%lld\n",ans/2);
	return 0;
}


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

string s;

int main() {
  cin >> s;
  int cnt_even_0 = 0; // 010..
  int cnt_even_1 = 0; // 101..
  for (int i=0;i<s.length();i++){
    //cout << s[i] << ",";
    if (i%2==0) {
      if (s[i]=='0') {
        cnt_even_1++;
      } else {
        cnt_even_0++;
      }
    } else {
      if (s[i]=='1') {
        cnt_even_1++;
      } else {
        cnt_even_0++;
      }
    }
  }
  //cout << "\n";
  if (cnt_even_0 < cnt_even_1) {
    cout << cnt_even_0 << "\n";
  } else {
    cout << cnt_even_1 << "\n";
  }

#if 0
  cout << s << "\n";
#endif
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAXN = 1e5+5;

int n;
int a[MAXN], b[MAXN], c[MAXN];
int dp[MAXN][3];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", a+i, b+i, c+i);
  }

  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for (int i = 1; i < n; ++i) {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a[i];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2])+b[i];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1])+c[i];
  }

  printf("%d\n", max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}));
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>


void main(void){
    char str[10];

    scanf("%s",str);
    int i;
    int ans = 1;
    for(i = 1;i <= 5;i++){
        if(str[i*2-2] != 'h'){
            if(str[i*2-2] == '\0'){
                break;
            }
            ans = 0;
            break;
        } else if( str[i*2-1] != 'i'){
            if(str[i*2-2] == '\0'){
                break;
            }
            ans = 0;
            break;
        }
    }
    printf("%s",ans ? "Yes" : "No");
    return;
}

Measured memory_bytes: 128
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    if(a>=13){
        cout << b;
    }
    else if(a<=5){
        cout << 0;
    }
    else{
        cout << b/2;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<LL, LL> P;
struct edge { LL to, cost; };

int H, W, N;
std::string field[1123];
int Sx, Sy, xy[11];
int ans;

LL d[1123456];
std::vector<edge>G[1123456];
void dijkstra(LL s)
{
	std::priority_queue<P, std::vector<P>, std::greater<P>>que;
	std::fill(d, d + H * W + 1, 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; }
		rep(i, G[v].size())
		{
			edge e = G[v][i];
			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()
{
	in >> H >> W >> N;
	rep(i, H) { in >> field[i]; }

	rep(x, H)
	{
		rep(y, W)
		{
			if (field[x][y] == 'X') { continue; }
			if (field[x][y] == 'S') { Sx = x; Sy = y; }
			else if (field[x][y] != '.') { xy[field[x][y] - '0'] = x*W + y; }
			if (x < H - 1)
			{
				if (field[x + 1][y] != 'X')
				{
					G[x*W + y].push_back({ (x + 1)*W + y,1 });
					G[(x + 1)*W + y].push_back({ x*W + y,1 });
				}
			}
			if (y < W - 1)
			{
				if (field[x][y + 1] != 'X')
				{
					G[x*W + y].push_back({ x*W + (y + 1),1 });
					G[x*W + (y + 1)].push_back({ x*W + y,1 });
				}
			}
		}
	}
	dijkstra(Sx*W + Sy);
	rep(i, N)
	{
		ans += d[xy[i + 1]];
		dijkstra(xy[i + 1]);
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 58140
from collections import defaultdict
from itertools import combinations
def inpl(): return list(map(int, input().split()))

C = defaultdict(int)
N = int(input())
for _ in range(N):
    C[input()[0]] += 1

res = 0
for H in combinations("MARCH", r=3):
    res += C[H[0]] * C[H[1]] * C[H[2]]
print(res)

Measured memory_bytes: 9336
import sys

n = int(input())
a_list = list(map(int, input().split()))
trade_list = []
prev = "+"
money = 1000
kabu = 0

while a_list[len(a_list) - 1] <= a_list[len(a_list) - 2]:
    a_list.pop()
    if len(a_list) == 1:
        print(1000)
        sys.exit()

while a_list[0] >= a_list[1]:
    a_list.pop(0)
    if len(a_list) == 1:
        print(1000)
        sys.exit()

trade_list.append(a_list[0])

#この時点で少なくとも2つは要素ある状態
#少なくとも最初の要素 < 最後の要素

for i in range(len(a_list) - 1):
    if a_list[i] > a_list[i + 1]:
        now = "-"
    elif a_list[i] < a_list[i + 1]:
        now = "+"
    else:
        now = prev

    if prev != now:
        trade_list.append(a_list[i])
    prev = now

trade_list.append(a_list[-1])

for i in range(len(trade_list)):
    #買い
    if i % 2 == 0:
        kabu = money // trade_list[i]
        money -= kabu * trade_list[i]
    else:
        money += kabu * trade_list[i]

print(money)


Measured memory_bytes: 9232
#include<iostream>
#include<string>
using namespace std;
string S; char T[8] = "IVXLCDM"; int X[7] = { 1,5,10,50,100,500,1000 }, l[10000];
int main() {
	while (cin >> S) {
		int cnt = 0;
		for (int i = 0; i < S.size(); i++) {
			for (int j = 0; j < 7;j++){
				if (S[i] == T[j]) { l[i] = j; cnt += X[j]; }
			}
		}
		for (int i = 1; i < S.size(); i++) {
			if (l[i - 1] < l[i]) { cnt -= X[l[i - 1]] * 2; }
		}
		cout << cnt << endl;
	}
}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
const double PI  = acos(-1.0);

//-------------------------------------------

int main(){


    cin.tie(0);
    ios::sync_with_stdio(false);
    int W,a,b;

    cin >> W >> a >> b;
    int ans = 0;


    if( a < b){
        if(a+W >= b ){
            ans = 0;
        }else ans = b - a - W;

    }else if(a > b){
        if(a <= b+W){
            ans = 0;
        }else ans = a - b - W;

    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
using namespace std;
bool solve(string S);

bool solve(string S){
    map<char,int> ma; // あるなら 1、ないなら 0
    for (int i = 0; i < S.size(); ++i){
        if (ma.count(S[i])) ma[S[i]] = 1;
        else ma[S[i]] = 1;
    }
    if (ma['N'] != ma['S']) return false;
    if (ma['W'] != ma['E']) return false;
    return true;
}

int main() {
    string S; cin >> S;
    if (solve(S)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    vector<int> res(10, MOD);
    res[0] = a*x + b*y;
    res[1] = c*2*x + max(0, y-x)*b;
    res[2] = c*2*y + max(0, x-y)*a;
    res[3] = max(y, x)*2*c;
    int ans = MOD;
    REP(i, 10) ans = min(ans, res[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
// int const mod = 998244353;
int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 5e5+5;
int const inf = 2e16;


void solve(){  
    int i,j,l;
    int n;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    int x1 = a[0];
    int x2 = a[1];

    int xr = 0;
    for(i=2;i<n;i++){
        xr = xr^a[i];
    }

    // if(x1^x2 == xr){
    //     cout<<0<<endl;
    //     return;
    // }

    int sm = x1 + x2;
    sm = sm - xr;

    if(sm%2 == 1){
        cout<<-1<<endl;
        return;
    }

    int fi = sm/2;

    int a1,a2;
    a1 = fi;
    a2 = fi;

    // cout<<a1<<" "<<a2<<endl;

    for(i=43;i>=0;i--){
        if(xr&(1LL<<i)){
            int p = (1LL<<i);
            if((a1 + p) <= x1){
                a1 = a1 | (1LL<<i);
            }
            else{
                a2 = a2 | (1LL<<i);
            }
        }
    }

    int ans = -1;

    // cout<<a1<<" "<<a2<<endl;

    if(((a1^a2) == xr) && a1 <= x1  && a1 > 0) ans = x1-a1;

    cout<<ans<<endl; 
}           


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*

8
10 9 8 7 6 5 4 3

8

0100
0100

x1 ^ x2 = x

*/

Measured memory_bytes: 3584
import java.util.Scanner;
import java.util.Arrays;
import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int dataCount = Integer.parseInt(scanner.nextLine());
        String[] dataString = scanner.nextLine().split(" ");
        int data[] = new int[dataCount];
        
        for (int i = 0; i < dataCount; i++) {
            data[i] = Integer.parseInt(dataString[i]);
        }

        int changeCount = 0;
        // 1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A
        // 2   flag = 1 // 逆の隣接要素が存在する
        // 3   while flag
        // 4     flag = 0
        // 5     for j が N-1 から 1 まで
        // 6       if A[j] < A[j-1]
        // 7         A[j] と A[j-1] を交換
        // 8         flag = 1
        boolean flag = true;
        while (flag) {
            flag = false;
            for (int i = dataCount - 1; i >= 1; i--) {
                if (data[i] < data[i - 1]) {
                    int tmp = data[i];
                    data[i] = data[i - 1];
                    data[i - 1] = tmp;
                    changeCount++;
                    flag = true;
                }
            }
        }
        
        StringJoiner joiner = new StringJoiner(" ");
        Arrays.stream(data).forEach(n -> joiner.add(Integer.toString(n)));
        System.out.println(joiner.toString());
        System.out.println(changeCount);
    }
}


Measured memory_bytes: 31748
from collections import defaultdict

S = input()
S = S[::-1]
N = len(S)
MOD = 2019
D = defaultdict(int)
res = 0
p = 1
for i in range(N):
    tmp = res + int(S[i]) * p
    tmp %= MOD
    D[tmp] += 1

    res = tmp
    p *= 10
    p %= 2019 

ans = 0
for k,v in zip(D.keys(), D.values()):
    if k == 0:
        ans += v
        ans += v * (v - 1) //2
    elif v >= 2:
        ans += v * (v - 1) // 2

print(ans)

Measured memory_bytes: 9692
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;	cin>>N;
	vector<ll> data(N);
	ll sum=0,ans=0;
	FOR(i,0,N){
		cin>>data.at(i);
		sum+=data.at(i);
	}

	FOR(i,0,N){
		ll sumc=sum-data.at(i);
		sumc%=mod;
		ans+=(sumc*data.at(i))%mod;
		ans%=mod;
		sum-=data.at(i);
	}

	cout<<ans<<endl;




    return 0;
}



Measured memory_bytes: 4780
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int[] ar, ss, at;
	int j, k, x, put, alo;
	while(sc.hasNext()){
	    put = 0; alo=0;
	    x = sc.nextInt();
	    ar = new int[x];
	    ss = new int[x];
	    
	    for(j=1; j<x; j++)
		if(ar[j]==0){
		    ss[put]=j+1;
		    put++;
		    for(k=j+1; k<x+1; k+=(j+1))
			ar[k-1]=1;
		}
	    at = new int[x];
	    for(int le=0; ss[le]!=0; le++)
		at[ss[le]-1] = 1;
	    for(int pak=0; pak<x; pak++)
		if(at[pak]==1 && at[x-pak-1]==1)
		    alo++;
	    System.out.println(alo);
	}
    }
}

Measured memory_bytes: 12000
let inp = require('fs').readFileSync('/dev/stdin', 'utf8').replace(/\n/g, '').trim();

const zoAry = Array.from(Array(Math.ceil(inp.length / 2))).map(_ => '01']).join('').split('');
const ozAry = Array.from(Array(Math.ceil(inp.length / 2))).map(_ => '10']).join('').split('');

let diffZo = 0;
let diffOz = 0;

inp.split('').forEach((v,i) => {
  if (v !== zoAry[i]) ++ diffZo;
  if (v !== ozAry[i]) ++ diffOz;
})

console.log(Math.min(diffZo, diffOz))

Measured memory_bytes: 16308
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    set<int>ss;
    for(int i=0;i<s.length();i++){
        ss.insert(s[i]);
    }
    if(ss.size() == 1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    
    return 0;
    
}



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	char a; cin >> a;
	if(a == toupper(a)) cout << 'A' << endl;
	else cout << 'a' << endl;

	return 0;
				
}


Measured memory_bytes: 3616
from sys import stdin
from heapq import heappop, heappush
manhattan = [[abs((i % 4) - (j % 4)) + abs((i // 4) - (j // 4)) for j in range(16)] for i in range(16)]
movables = ((1, 4), (0, 2, 5), (1, 3, 6), (2, 7), (0, 5, 8), (1, 4, 6, 9), (2, 5, 7, 10), (3, 6, 11),
            (4, 9, 12), (5, 8, 10, 13), (6, 9, 11, 14), (7, 10, 15), (8, 13), (9, 12, 14), (10, 13, 15), (11, 14))
swap_mul = [[(1 << mf) - (1 << mt) for mt in range(0, 64, 4)] for mf in range(0, 64, 4)]
destination = 0xfedcba9876543210
i = 0
board_init = 0
blank_init = 0
for _ in range(4):
    for n in map(int, stdin.readline().split()):
        if n:
            n -= 1
        else:
            n = 15
            blank_init = i
        board_init += n * 16 ** i
        i += 1
estimation_init = sum(manhattan[i][((board_init >> (4 * i)) & 15)] for i in range(16) if i != blank_init)
queue = [(estimation_init, board_init, blank_init)]
visited = set()
while True:
    estimation, board, blank = heappop(queue)
    if board in visited:
        continue
    elif board == destination:
        print(estimation)
        break
    visited.add(board)
    for new_blank in movables[blank]:
        num = (board >> (4 * new_blank)) & 15
        new_board = board + swap_mul[new_blank][blank] * (15 - num)
        if new_board in visited:
            continue
        new_estimation = estimation + 1 - manhattan[new_blank][num] + manhattan[blank][num]
        if new_estimation > 45:
            continue
        heappush(queue, (new_estimation, new_board, new_blank))

Measured memory_bytes: 163336