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

int main() {
  
  int a, b, c, cup;
  cin >>a >>b >>c;
  
  if(a > b){
    cup = a;
    a = b;
    b = cup;

  }
  if(b > c){
    cup = b;
    b = c;
    c = cup;

  }
  if(a > b){
    cup = a;
    a = b;
    b = cup;

  }
  
  cout <<a <<" " <<b <<" " <<c <<"\n";
  return 0;
}

Measured memory_bytes: 1164
N=list(map(int,input().split()))

one=0
four=0
nine=0
seven=0

for i in range(4):
  if N[i]==1:
    one=1
  if N[i]==4:
    four=1
  if N[i]==9:
    nine=1
  if N[i]==7:
    seven=1

if one+four+nine+seven==4:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,k;
    int ans=1;
    cin>>n>>k; 
    for(int i=1;i<=n;++i)
    {
        ans=min(ans*2,ans+k);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int N, sum = 0, aveint, ave,last=0;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++)
    {
        cin >> X.at(i);
    }
    // 合計と平均出す
    for (int i = 0; i < N; i++)
    {
        sum += X.at(i);
    }
    ave = ((double)sum / N) * 10;
    //cout << ave << endl;
    if (ave % 10 >= 5)
    {
        ave += 10;
        //cout << ave << endl;
    }
    ave = ave / 10;

    for (int i = 0; i < N;i++)
    {
        last += (X.at(i) - ave)*(X.at(i) - ave);
    }
    cout << last << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int x[200005], y[200005];
pii p[200005];
int main(){
    int n;
    scanf("%d", &n);

    int mx = 0, mn = 1e9;
    for(int i=1;i<=n;i++){
        scanf("%d%d", &x[i], &y[i]);
        mx = max(mx, x[i]);
        mx = max(mx, y[i]);
        mn = min(mn, x[i]);
        mn = min(mn, y[i]);
    }

    int r1 = 0, r2 = 1e9, b1 = 0, b2 = 1e9;
    for(int i=1;i<=n;i++){
        if(x[i] < y[i]) swap(x[i], y[i]);
        r1 = max(r1, x[i]);
        r2 = min(r2, x[i]);

        b1 = max(b1, y[i]);
        b2 = min(b2, y[i]);
    }
    ll ans = (r1-r2)*1ll*(b1-b2);

    for(int i=1;i<=n;i++) p[i] = pii(y[i], x[i]);
    sort(p+1, p+1+n);

    int mx2 = 0, mn2 = 1e9;
    multiset<int> ms;
    ms.insert(0);
    for(int i=1;i<=n;i++) ms.insert(p[i].fi);
    for(int i=1;i<=n;i++){
        ms.erase(ms.find(p[i].fi));
        int a = min(mn2, p[i].fi);
        int b = max(mx2, max(p[i].fi, *ms.rbegin()));
        ans = min(ans, (mx-mn)*1ll*(b-a));

        mx2 = max(mx2, p[i].se);
        mn2 = min(mn2, p[i].se);
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

int par[100010],r[100010],sz[100010];
int64_t ans=0;
void upd(int u,int v){
    ans-=1LL*u*(u-1)/2;
    ans-=1LL*v*(v-1)/2;
    ans+=1LL*(u+v)*(u+v-1)/2;
}
int find(int i){return i==par[i]?i:(par[i]=find(par[i]));}
void merge(int i,int j){
    int x=find(i);
    int y=find(j);
    if(x==y)return;
    upd(sz[x],sz[y]);
    if(r[x]<r[y])par[x]=y,sz[y]+=sz[x];
    else if(r[x]>r[y])par[y]=x,sz[x]+=sz[y];
    else par[x]=y,r[y]++,sz[y]+=sz[x];
}

int main() {
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;++i)par[i]=i,r[i]=1,sz[i]=1;
    vector<pair<int,int>> q;
    for(int i=0;i<m;++i){
        int u,v;
        cin>>u>>v;
        q.push_back({u,v});
    }
    vector<int64_t> a;
    while(!q.empty()){
        a.push_back(1LL*n*(n-1)/2-ans);
        int u=q.back().first;
        int v=q.back().second;
        q.pop_back();
        merge(u,v);
    }
    reverse(a.begin(),a.end());
    for(int64_t x:a)cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 4212
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 100000000000
#define MOD 1000000007
 
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
 
int main() {
	long sx, sy, tx, ty;
	long idx = 0;
	long i, j;
	long tmp;
	char ans[100000];
	
	sl(sx); sl(sy); sl(tx); sl(ty);
	
	ans[idx++] = 'D';
	for(i=0;i<(tx-sx);i++) ans[idx++] = 'R';
	ans[idx++] = 'R';
	for(i=0;i<(ty-sy);i++) ans[idx++] = 'U';
	ans[idx++] = 'U';
	ans[idx++] = 'L';
	ans[idx++] = 'U';
	for(i=0;i<(tx-sx);i++) ans[idx++] = 'L';
	ans[idx++] = 'L';
	for(i=0;i<(ty-sy);i++) ans[idx++] = 'D';
	ans[idx++] = 'D';
	ans[idx++] = 'R';
	for(i=0;i<(tx-sx);i++) ans[idx++] = 'R';
	for(i=0;i<(ty-sy);i++) ans[idx++] = 'U';
	for(i=0;i<(tx-sx);i++) ans[idx++] = 'L';
	for(i=0;i<(ty-sy);i++) ans[idx++] = 'D';
	
	ans[idx++] = '\0';
	
	ps(ans);
	
	return 0;
}

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

using namespace std;

#define int long long

const int N = 3005;
const int INF = 1e9;
int dp[N][N];
string s, t;

int sol(int i, int j) {
    if (i == s.size() || j == t.size()) return dp[i][j] = 0;
    int &ans = dp[i][j];
    if (ans != -1) return ans;
    if (s[i] == t[j]) return ans = sol(i + 1, j + 1) + 1;
    return ans = max(sol(i + 1, j), sol(i, j + 1));
}

void get(int i, int j) {
    if (i == s.size() || j == t.size()) return;
    int a1 = -INF;
    if (s[i] == t[j]) {
        a1 = dp[i + 1][j + 1] + 1;
        cout << s[i];
        get(i + 1, j + 1);
    } else {
        int a2 = dp[i + 1][j];
        int a3 = dp[i][j + 1];
        if (a2 >= a3) get(i + 1, j);
        else get(i, j + 1);
    }
}

void solve() {
    cin >> s >> t;
    memset(dp, -1, sizeof(dp));
    sol(0, 0);
    get(0, 0);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin>>t;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 71040
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  int n; cin >> n;
  cout << n*(n+1)/2;

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	static String S;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    S=gs();

	    List<String> l=new ArrayList<String>();
	    String c=String.valueOf(S.charAt(0));
	    l.add(c);
	    long a=f(1, l);



	    System.out.println(a);
	}

	public static long f(int index, List<String> num) {
		if (index==S.length()) {
			long sum = 0;
			for (int i=0; i<num.size();i++) {
				long n=Long.parseLong(num.get(i));
				sum+=n;
			}
			return sum;
		}
		String c=String.valueOf(S.charAt(index));

		long ans=0;
		List<String> l=new ArrayList<String>();
		l.addAll(num);
		l.add(c);
		ans+=f(index+1, l);

		List<String> l2=new ArrayList<String>();
		l2.addAll(num);
		String cn=l2.get(l2.size()-1) + c;
		l2.set(l2.size()-1, cn);
		ans+=f(index+1, l2);

		return ans;
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 39512
import os
import sys
from collections import deque

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N)]
for a, b in AB:
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)


def max_d(from_v):
    seen = [False] * N
    seen[from_v] = True
    v, d = from_v, 0
    que = deque([(v, d)])
    while que:
        v, d = que.popleft()
        for u in graph[v]:
            if not seen[u]:
                seen[u] = True
                que.append((u, d + 1))
    return v, d


v, _ = max_d(0)
_, diam = max_d(v)
# 直径を 1 か 2 減らせる
# 直径が 1 になったら負け
if diam % 3 == 1:
    print('Second')
else:
    print('First')


Measured memory_bytes: 96540
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

struct card;
int linersearch(int a[], int n, int x);
void insetrtionsort(int a[], int n);
void printcard(int n, card a[]);
void babblesort(int n, card a[]);
void selectionsort(int n, card a[]);
void countingsort(int n, int a[]);
void minimumcostsort(int n, int a[]);
string comparecardsarray(card a[], card b[]);

struct card
{
    char surt;
    int value;
};

void printcard(int n, card a[])
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i].surt << a[i].value;
        if (i != n - 1)
            cout << " ";
    }
    cout << endl;
}

void babblesort(int n, card a[])
{
    int flag = 1;
    while (flag)
    {
        flag = 0;
        for (int j = n - 1; j > 0; j--)
        {
            if (a[j].value < a[j - 1].value)
            {
                swap(a[j], a[j - 1]);
                flag = 1;
            }
        }
    }
    printcard(n, a);
}

void selectionsort(int n, card a[])
{
    int minj;
    for (int i = 0; i < n; i++)
    {
        minj = i;
        for (int j = i; j < n; j++)
        {
            if (a[j].value < a[minj].value)
                minj = j;
        }
        if (i != minj)
        {
            swap(a[minj], a[i]);
        }
    }
    printcard(n, a);
}

string comparecardsarray(card a[], card b[], int n)
{
    string ret;
    int check = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i].surt == b[i].surt && a[i].value == b[i].value)
            check++;
    }
    if (check == n)
        ret = "Stable";
    else
        ret = "Not stable";
    return ret;
}

int main()
{
    int n;
    string s;
    cin >> n;
    card a[n], b[n], c[n];
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        a[i].surt = s[0];
        a[i].value = s[1] - '0';
        b[i] = a[i];
        c[i] = a[i];
    }
    babblesort(n, b);
    cout << "Stable" << endl;
    selectionsort(n, c);
    cout << comparecardsarray(b, c, n) << endl;
    return 0;
}



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

struct UnionFind {
  vector<int> par;
  vector<int> rank;

  UnionFind(int n) : par(n), rank(n, 1) {
    for(int i=0; i<n; ++i) par[i] = i;
  }

  int find(int x) {
    if (x == par[x]) return x;
    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]) swap(x, y);
    par[y] = x;
    rank[x] += rank[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

struct edge{
    int src, dst;
    double cost;
    edge(int s, int t, double c) : src(s), dst(t), cost(c) {}
    bool operator < (const edge &rhs) const {return cost > rhs.cost;}
};

int main(void) {
    int n;
    while(cin >> n && n) {
        UnionFind uf(n);
        vector<double> x(n), y(n), z(n), r(n);
        vector<edge> edges;
        REP(i, n) {
            cin >> x[i] >> y[i] >> z[i] >> r[i];
        }
        REP(i, n)  {
            REP(j, n) {
                if(i == j) continue;
                double c = sqrt(pow(x[i]-x[j], 2.0) + pow(y[i]-y[j], 2.0) + pow(z[i]-z[j], 2.0)) - r[i] - r[j];
                edges.push_back(edge(i, j, max(0.0, c)));
            }
        }
        sort(edges.rbegin(), edges.rend());

        double ans = 0;
        for(auto e : edges) {
            if(!uf.same(e.src, e.dst)) {
                uf.unite(e.src, e.dst);
                ans += e.cost;
            }
        }
        printf("%.3f\n", ans);
    }
}

Measured memory_bytes: 3404
import java.io.*;
import java.util.*;
 
public class Main{
	int H, W;
	int[] count;
	public void solve(){
		H = nextInt();
		W = nextInt();
		count = new int[26];
		for(int i = 0; i < H; i++){
			String str = next();
			for(int j = 0; j < W; j++){
				count[str.charAt(j) - 'a']++;
			}
		}
		int odd = 0;
		int ni = 0;
		int yo = 0;
		for(int i = 0; i < 26; i++){
			if(count[i] % 4 == 0){
				yo++;
			}else if(count[i] % 2 == 0){
				ni++;
			}else{
				odd++;
			}
		}
		
		if(H % 2 == 0 && W % 2 == 0){
			if(odd == 0 && ni == 0){
				out.println("Yes");
			}else{
				out.println("No");
			}
		}else if(H % 2 == 1 && W % 2 == 0){
			if(odd == 0 && ni <= W / 2){
				out.println("Yes");
			}else{
				out.println("No");
			}	
		}else if(H % 2 == 0 && W % 2 == 1){
			if(odd == 0 && ni <= H / 2){
				out.println("Yes");
			}else{
				out.println("No");
			}
		}else{
			if(odd <= 1 && ni <= (H / 2) + (W / 2)){
				out.println("Yes");
			}else{
				out.println("No");
			}
		}
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 24916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll x;cin>>x;
  ll i,j,k=1;
  string s;
  while(k*(k+1)/2<x) k++;
  for(i=0;i<k;i++) s+=')';
  for(i=0;i<k;i++) s+='(';
  j=k*(k+1)/2-x;
  for(i=0;i<j;i++){
    swap(s[k-1],s[k]);
    k--;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3340
n = str(input())
ans = 'Yes'
if len(n)%2 == 1:
    ans = 'No'
else:
    for i in range(0, len(n)-1, 2):
        if n[i] != 'h' or n[i + 1] != 'i':
            ans = 'No'

print(ans)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	private double[] pos = new double[8];

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			String[] str = scan.nextLine().split(",");
			for (int i = 0; i < 8; i++) pos[i] = Double.parseDouble(str[i]);
			
			double sum = 0;
			for (int i = 0; i < 4; i++) {
				double x1, x2, y1, y2;
				if (i == 0) {
					x1 = pos[6] - pos[i];
					y1 = pos[7] - pos[i+1];
					x2 = pos[(i + 1) * 2] - pos[i];
					y2 = pos[(i + 1) * 2 + 1] - pos[i+1];
				}else if (i == 3) {
					x1 = pos[4] - pos[6];
					y1 = pos[5] - pos[7];
					x2 = pos[0] - pos[6];
					y2 = pos[1] - pos[7];
				}else {
					x1 = pos[(i - 1) * 2] - pos[i * 2];
					y1 = pos[(i - 1) * 2 + 1] - pos[i * 2 + 1];
					x2 = pos[(i + 1) * 2] - pos[i * 2];
					y2 = pos[(i + 1) * 2 + 1] - pos[i * 2 + 1];
				}
				
				sum += calsi(x1, y1, x2, y2);
			}
			System.out.println((int)sum == 360? "YES" : "NO");
		}
	}
	
	private double calsi(double x1, double y1, double x2, double y2) {
		double a = x1 * x2 + y1 * y2;
		double b = Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2));
		double cos = a / b;
		double acos = Math.acos(cos);
		double si = Math.toDegrees(acos);
		//System.out.println(si);
		return si;
	}
	
	private void debug() {
		System.out.println();
	}

}

Measured memory_bytes: 17176
#include <iostream>
using namespace std;
int main(void){
    
    
    static int A[7] = {1, 3, 5, 7, 8, 10, 12};
    static int B[4] = {4, 6, 9, 11};
    
    int x, y;
    bool b_X = false;
    bool b_Y = false;
    cin >> x >> y;
    
    // Cのパターンのとき
    if(x == 2 || y == 2){
        cout << "No" << endl;
        return 0;
    }
    
    // Bのパターンのとき
    for(int i = 0; i < 4; i++){
        if(x == B[i]) b_X = true;
        if(y == B[i]) b_Y = true;
    }
    
    if(b_X && b_Y){
        cout << "Yes" << endl;
        return 0;
    }
    
    b_X = false, b_Y = false;
    
    // Aのパターンのとき
    for(int i = 0; i < 7; i++){
        if(x == A[i]) b_X = true;
        if(y == A[i]) b_Y = true;
    }
    
    if(b_X && b_Y) cout << "Yes" << endl;
    else cout << "No" << endl;
    
} 


Measured memory_bytes: 256
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+10;
int n,k,a[N],vis[N],rt,dep[N];
vector<int> v;
void dfs(int x){
	if(vis[x])	return rt=x,void();	vis[x]=1;	v.push_back(x);
	dep[a[x]]=dep[x]+1;	dfs(a[x]);
}
signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)	cin>>a[i];
	dfs(1);
	if(k<v.size())	return cout<<v[k],0;
	memset(vis,0,sizeof vis);
	k-=dep[rt];	v.clear(); dfs(rt); k%=v.size();
	cout<<v[k];
	return 0;
}


Measured memory_bytes: 15692
#include<iostream>
using namespace std;
int main() {
	int N, M,i=0;
	cin >> N >> M;
	int L=0,R=100000,L0,R0;
	for (i=0;i<M;i=i+1) {
		cin >> L0 >> R0;
		if (L < L0) {
			L = L0;
		}
		if (R > R0) {
			R = R0;
		}
	}
	if (L <= R) {
		cout << R - L + 1;
	}
	else {
		cout << 0;
	}
	return 0;
}

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

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////

signed main() {
  int n;
  int ans=0;
  cin>>n;
  int sum=0;
  vector<int>a(n);
  map<int,int>m;
  rep(i,n){cin>>a[i];m[a[i]]++;ans+=a[i];}
  int q;
  cin>>q;
  rep(i,q){
    int k,l;
    cin>>k>>l;
    ans=ans-m[k]*k+m[k]*l;
    m[l]+=m[k];
    m[k]=0;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 10000
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    int ans=1;
    bool up=0,dn=0;
    for(int i=1;i<N;i++){
        if(a[i-1]<a[i]) up=1;
        if(a[i-1]>a[i]) dn=1;
        if(up and dn){
            up=dn=0;
            ans++;
        }
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    vector<string> s(n);
    ll ans = 0;
    map<string, ll> m;
    rep(i,n) {
        cin >> s[i], sort(s[i].begin(), s[i].end());
        ans += m[s[i]];
        m[s[i]]++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18176
#include <algorithm>　　　 //STL 通用算法
#include <bitset>　　　　　//STL 位集容器
#include <cctype>         //字符处理
#include <cerrno> 　　　　 //定义错误码
#include <cfloat>　　　　 //浮点数处理
#include <ciso646>         //对应各种运算符的宏
#include <climits> 　　　　//定义各种数据类型最值的常量
#include <clocale> 　　　　//定义本地化函数
#include <cmath> 　　　　　//定义数学函数
#include <complex>　　　　 //复数类
#include <csignal>         //信号机制支持
#include <csetjmp>         //异常处理支持
#include <cstdarg>         //不定参数列表支持
#include <cstddef>         //常用常量
#include <cstdio> 　　　　 //定义输入／输出函数
#include <cstdlib> 　　　　//定义杂项函数及内存分配函数
#include <cstring> 　　　　//字符串处理
#include <ctime> 　　　　　//定义关于时间的函数
#include <cwchar> 　　　　 //宽字符处理及输入／输出
#include <cwctype> 　　　　//宽字符分类
#include <deque>　　　　　 //STL 双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream> 　　　 //文件输入／输出
#include <functional>　　　//STL 定义运算函数（代替运算符）
#include <limits> 　　　　 //定义各种数据类型最值常量
#include <list>　　　　　　//STL 线性列表容器
#include <locale>         //本地化特定信息
#include <map>　　　　　　 //STL 映射容器
#include <memory>         //STL通过分配器进行的内存分配
#include<new>            //动态内存分配
#include <numeric>         //STL常用的数字操作
#include <iomanip> 　　　 //参数化输入／输出
#include <ios>　　　　　　 //基本输入／输出支持
#include <iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream> 　　　//数据流输入／输出
#include <istream>　　　　 //基本输入流
#include <iterator>        //STL迭代器
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL 队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　 //基于字符串的流
#include <stack>　　　　　 //STL 堆栈容器
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　 //底层输入／输出支持
#include <string>　　　　　//字符串类
#include <typeinfo>        //运行期间类型信息
#include <utility>　　　　 //STL 通用模板类
#include <valarray>        //对包含值的数组的操作
#include <vector>　　　　　//STL 动态数组容器
#define ll long long
using namespace std;
const int N=1000010;
ll n,x,mx;
ll c[N];
int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; i++) {
		scanf("%d",&x);
		++c[x];
		mx=max(mx,x);
	}
	int mi = (mx + 1) >> 1;
	for(int i = mx; i > mi; --i) {
		if(c[i] < 2)
			return puts("Impossible"), 0;
		n -= c[i];
	}
	if(c[mi] != 1 + (mx & 1) || n != c[mi])
		return puts("Impossible"), 0;
	puts("Possible");
}

Measured memory_bytes: 3128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<cstdio>
#include<set>
using namespace std;
int  main()
{
	long long n;
	cin>>n;
	int a;
	int x[1000];
	int num=0;
	while(n)
	{
		a=(n-1)%26;
		x[num++]=a;
		n--;
		n=n/26;
	}
	for(int i=num-1;i>=0;--i)
		cout<<static_cast<char>(x[i]+'a');
    return 0;
}



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

const int MAXN = 100000, INF = 2147483647;
int n, q, t[4 * MAXN + 5];

void ptupt(int l, int r, int pt, int p, int val) {
    if (r < pt || l > pt) return;
    if (l == r && l == pt) {
        t[p] = val;
        return;
    }
    int mid = (l + r) >> 1;
    ptupt(l, mid, pt, p << 1, val);
    ptupt(mid + 1, r, pt, p << 1 | 1, val);
    t[p] = min(t[p << 1], t[p << 1 | 1]);
}

int qry(int l, int r, int tl, int tr, int p) {
    if (r < tl || l > tr) return INF;
    if (tl <= l && r <= tr) {
        return t[p];
    }
    int rt = INF, mid = (l + r) >> 1;
    rt = min(rt, qry(l, mid, tl, tr, p << 1));
    rt = min(rt, qry(mid + 1, r, tl, tr, p << 1 | 1));
    return rt;
}

int main() {
    cin >> n >> q;
    fill(t, t + 4 * MAXN + 3, INF);
    while (q--) {
        int t1, t2, t3;
        cin >> t1 >> t2 >> t3;
        if (t1 == 0) ptupt(0, n - 1, t2, 1, t3);
        else cout << qry(0, n - 1, t2, t3, 1) << endl;
    }
}


Measured memory_bytes: 4672
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		if(n==1){
			System.out.println("Hello World");
		}else {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a+b);
		}
	}
}


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




int dp[1<<20][2];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  string s; cin >> s;
  if (s.size() == 1) cout << 1 << '\n', exit(0);
  int n = s.size();
  dp[1][0] = 1, dp[1][1] = -1e9;
  dp[2][0] = s[0] == s[1] ? -1e9 : 2;
  dp[2][1] = 1;
  for (int i = 2; i < n; ++i) {
    dp[i + 1][0] = (s[i] == s[i - 1] ? dp[i][1] + 1 : max(dp[i][0], dp[i][1]) + 1);
    dp[i + 1][1] = dp[i - 1][0] + 1;
  }
  cout << max(dp[n][0], dp[n][1]) << '\n';
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int H, W; cin >> H >> W;
  int cnt = 0;
  REP(h, H) REP(w, W) {
    char c; cin >> c;
    cnt += (c == '#' ? 1 : 0);
  }

  if (cnt == H+W-1) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}

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

#define MOD 1000000007

using namespace std;

int main() {
	int n, x, y;
	scanf("%d", &n);
	vector<pair<int, int>> jobs;
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &x, &y);
		jobs.push_back(make_pair(y, x));
	}
	sort(jobs.begin(), jobs.end(), greater<pair<int, int>>());
	int now = jobs[0].first;
	for (int i = 0; now >= 0 && i < n; i++) {
		if (jobs[i].first >= now) {
			now -= jobs[i].second;
		} else {
			now = jobs[i].first - jobs[i].second;
		}
	}
	if (now >= 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 2420
#include <cstdio>
#include <string>
#include <iostream>
#include <numeric>

int gcd(int a, int b) {
  while (a % b != 0) {
    a %= b;
    std::swap(a, b);
  }
  return b;
}

using int64 = long long;
int main(void) {
  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    std::string a, b;
    std::cin >> a >> b;
    bool ok = true;
    for (int i = 0; i < m && ok; i++) {
      long long jj = (long long)n * i;
      if (jj % m != 0) {
        continue;
      }
      long long j = jj / m;
      if (j <= m && b[i] != a[j]) {
        ok = false;
      }
    }
    std::cout << (ok ? ((long long)n * m) / gcd(n, m) : -1) << std::endl;
  }

  return 0;
}



Measured memory_bytes: 512
mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))
cnt = [0, 0, 0]
ans = 1
for a in A:
    c = 0
    for j in range(3):
        if cnt[j] == a:
            c+=1
            if c == 1:
                cnt[j]+=1
    ans*=c
    ans%=mod
print(ans)


Measured memory_bytes: 53996
/* ***********************************************
Author        :dasinlsb
Created Time  :2018/6/5 13:26:16
File Name     :C:\dasin\duipai.cpp
************************************************ */

#include<cstdio>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const int N=100005;
int n,s,x[N];ll p[N];
int main(){
 // freopen("C:/dasin/aa.in","r",stdin);
  //freopen("C:/dasin/mine.out","w",stdout);
  int i,j;
  scanf("%d%d",&n,&s);
  for(i=1;i<=n;++i)scanf("%d%d",x+i,p+i);
  int l=1,r=n;
  ll ans=0;
  for(;l<=r;){
    if(x[r]<=s){ans+=s-x[l];break;}
    if(x[l]>=s){ans+=x[r]-s;break;}
    ans+=x[r]-x[l];
    if(p[l]>=p[r])for(;l<r&&p[l]>=p[r];p[l]+=p[r--]);
    else for(;l<r&&p[l]<p[r];p[r]+=p[l++]);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1280
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

void main() {
    int N;
    int[] A;
    real B;
    int R; real V, E, F;

    bool input() {
        N = readln.chomp.to!int;
        if (N == 0) return false;
        A = readln.chomp.split(" ").map!(to!int).array;
        B = readln.chomp.to!real;
        scanf("%d %Lf %Lf %Lf\n", &R, &V, &E, &F);
        return true;
    }
    void solve() {
        real time(int d) {
            real t = 0;
            for (int x = 0; x < min(d, R); x++) {
                t += 1.0 / (V - F * (R - x));
            }
            for (int x = min(d, R); x < d; x++) {
                t += 1.0 / (V - E * (x - R));
            }
            return t;
        }
        A = [0] ~ A;
        N = cast(int)(A.length);
        auto dp = new real[N];
        dp[] = 1e10;
        dp[0] = 0;
        foreach (i; 0 .. N - 1) {
            foreach (j; i + 1 .. N) {
                dp[j] = min(dp[j], dp[i] + time(A[j] - A[i]) + (i == 0 ? 0 : B));
            }
        }
        writefln("%.20f", dp[N - 1]);
    }

    while (input()) solve();
}

Measured memory_bytes: 2720
#include<iostream>
using namespace std;
int main()
{
  int h, n;
  cin>>h>>n;
  int sum=0;
  for (int i=0; i<n; i++){
  	int a;
    cin>>a;
    sum+=a;
  }
  if (sum>=h){
  	cout<<"Yes";
  }
  else {cout<<"No";}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;
int gcd(int a,int b)
{
    if (a < b) {
        return gcd(b, a);
    }
    if (b==0) {
        return a;
    }
    return gcd(b, a%b);
}
int main() {
    int n;
    int r;
    cin >> n;
    cin >> r;
    for (int i=0; i<(n-1);i++) {
        int a;
        cin >> a;
        r = gcd(r,a);
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
	int N; cin >> N;
	int count = 0;
	vector<vector<int>> A(2,vector<int>(N));

	rep(i,2){
		rep(j,N){
			cin >> A[i][j];
		}
	}
	int sum = 0;
	int ans = 0;
	for(int i = 0; i < N; i++){
		sum += A[0][i];
		count = sum;
		for(int j = i; j < N ; j++){
			count += A[1][j];
}
	ans = max(count,ans);

	count = 0;
	}
	cout << ans << endl;
	
}


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

char maze[1010][1010];
int H,W;
int sx,sy;
int gx,gy;
int d[1010][1010];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(){
    queue<pair<int,int>> que;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            d[i][j]=INF;
        }
    }
    que.push(make_pair(sx,sy));
    d[sx][sy]=0;
    while(!que.empty()){
        pair<int,int> p=que.front();
        que.pop();
        if(p.first==gx && p.second==gy) break;
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#' && d[nx][ny]==INF){
                que.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
    return d[gx][gy];
}

int main(){
    cin>>H>>W;
    int cnt=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>maze[i][j];
            if(maze[i][j]=='#') cnt++;
        }
    }
    sx=0,sy=0,gx=H-1,gy=W-1;
    int num=bfs();
    int ans;
    if(num==INF) ans=-1;
    else ans=H*W-(num+1)-cnt;
    cout<<ans<<endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) 0
#endif
#define rout(i) cout << i << '\n', 0
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
const int maxn = 2001;
const int tomod = 1000000007;
int n, m;
ll k, minc;
vector<pair<int,pair<int,int>>> edge;
int p[maxn];
ll up[maxn]{1};
int find(int a){return a == p[a] ? a : p[a] = find(p[a]);}
#define merge(a) (p[find(a.first)] = find(a.second))
#define same(a) (find(a.first) == find(a.second))

int dif[maxn][maxn];
inline ll build(int id = 0){
	ll minc = 0;
	for(int i = 1;i <= n;++i)p[i] = i;
	minc += edge[id].first;
	merge(edge[id].second);
	dif[edge[id].second.first][edge[id].second.second] = -1;
	dif[edge[id].second.second][edge[id].second.first] = -1;
	for(int i = 0;i < edge.size();++i){
		if(!same(edge[i].second)){
			minc += edge[i].first;
			merge(edge[i].second);
			dif[edge[i].second.first][edge[i].second.second] = -1;
			dif[edge[i].second.second][edge[i].second.first] = -1;
		}
	}
	return minc;
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m >> k;
	for(int a, b, w, i = 0;i < m;++i){
		cin >> a >> b >> w;
		edge.push_back({w, {a, b}});
	}
	for(int i = 1;i <= m;++i)up[i] = (up[i-1] << 1) % tomod;
	sort(edge.begin(), edge.end());
	minc = build(); 
	if(minc > k)return rout(0);
	ll res = 0;
	int less = 0, eq = 0, bigger = 0;
	if(minc < k){
		for(int i = 0;i < edge.size();++i){
			ll c = build(i);
			less += c < k;
			eq += c == k;
			bigger += c > k;
		}
		res = up[bigger] * (up[eq]-1+tomod) % tomod * 2 % tomod;
	}
	else{
		for(int i = 0;i < edge.size();++i){
			ll c = build(i);
			eq += c == k;
			bigger += c > k;
		}
		res = (up[eq]-2+tomod) * up[bigger] % tomod;
	}
	dout(bigger)<<'\n';dout(less)<<'\n';dout(eq)<<'\n';
	cout << res << '\n';
}

Measured memory_bytes: 8192
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a = LI()
a.sort()
if a[0] == a[1] and a[1] != a[2]:
    print('Yes')
elif a[1] == a[2] and a[0] != a[1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38508
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NIL NULL
 struct Node {
	int key;
	struct Node * right, * left, * parent;
};
typedef struct Node *Node;

Node root;

void inorder(Node);
void preordee(Node);
void insert(int);

void insert(int k) {
	Node x, y, z;
	y = NIL;
	x = root;
	z = malloc(sizeof(struct Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

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

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

int main(void) {
	int n, i, x;
	char com[7];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", com);
		if (strcmp(com, "print")==0) {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (strcmp(com,"insert")==0){
			scanf("%d", &x);
			insert(x);
		}
	}
	return 0;
}


Measured memory_bytes: 25240
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)

//const int NAX = (int)3e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin >> n;
    ll res = n*(n-1)/2;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,k,r;
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>a>>b>>c>>k;
  r+=min(k,a);
  k=max(0,k-a);
  k=max(0,k-b);
  r-=min(k,c);
  cout<<r<<'\n';
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
 
int main(void){
	int A, B;
  	std::cin >> A >> B;
  	if( A-1 >= B) std::cout << 2*A - 1;
  	else if ( A <= B-1) std::cout << 2*B - 1;
  	else std::cout << 2*A;
  
  	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
	int a[3];
	int n;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
		if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) {
			cout << "YES\n";
		}
		else {
			cout << "NO\n";
		}
	}
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; ++i) {
        cin >> a.at(i);
    }
    vector<int> b(n);
    for (int i=0; i<n; ++i) {
        cin >> b.at(i);
    }

    int res = 0;
    for (int i=0; i<n; ++i) {
        int tmp = 0;
        for (int j=0; j<n; ++j) {
            if (j < i) {
                tmp += a.at(j);
            } else if (j == i) {
                tmp += a.at(j) + b.at(j);
            } else {
                tmp += b.at(j);
            }
        }
        chmax(res, tmp);
    }

    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
import itertools
P, Q, R = [int(i) for i in input().split()]

# A, B, C 
# A, C, B 
# B, A, C 
# B, C, A 
# C, A, B 
# C, B, A

print(min([sum(i) for i in (list(itertools.combinations([P, Q, R],2)))]))

 

Measured memory_bytes: 3060
# B - ∵∴∵
def main():
    o = list(input())
    d = list(input())

    for i in range(len(o)+len(d)):
        if i % 2 == 0:
            print(o.pop(0), end='')
        else:
            print(d.pop(0), end='')

  
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 8908
#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() {
  string S;
  cin >> S;
  if(S == "ABC") cout << "ARC";
  else cout << "ABC";
}


Measured memory_bytes: 3600
from sys import stdin

N, L = map(int,stdin.readline().rstrip().split())

taste=0
absMin=1000
min=1000
for i in range (L,L+N,1):
  if abs(i) < absMin:
    absMin=abs(i)
    min=i
  taste+=(i)
  
print(taste-min)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> C(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> C[i][j];
    }
  }

  rep(i, 2 * H) {
    rep(j, W) {
      cout << C[i / 2][j];
    }
    cout << endl;
  }
}

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

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

  int sum = 0, min_value = 1000;
  for (int i = 0; i < N; i++) {
    int s;
    cin >> s;
    sum += s;
    if (s % 10 != 0) {
      min_value = min(min_value, s);
    }
  }
  if (sum % 10 != 0) {
    cout << sum << endl;
  } else if (min_value == 1000) {
    cout << 0 << endl;
  } else {
    cout << sum - min_value << endl;
  }
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine();

        var output = string.Empty;
        foreach (var c in S)
        {
            output += (char)(c + N > 'Z' ? c + N - 26 : c + N);
        }
        
        Console.WriteLine(output);
    }
}


Measured memory_bytes: 34772
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;


int main()
{
    int n, a = 0;
    cin >> n;
    rep(i, n) {
        string aun;
        cin >> aun;
        if (aun[0] == 'A') {
            a++;
        } else {
            a--;
            if (a < 0) {
                puts("NO");
                return 0;
            }
        }
    }
    if (a) {
        puts("NO");
    } else {
        puts("YES");
    }




    return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int i,a1,b1,a2,b2,a3,b3;
  int A[5];
  A[1]=0;
  A[2]=0;
  A[3]=0;
  A[4]=0;
  cin >> a1 >> b1;
  cin >> a2 >> b2;
  cin >> a3 >> b3;
  A[a1]++;
  A[b1]++;
  A[a2]++;
  A[b2]++;
  A[a3]++;
  A[b3]++;
  if (A[1]>0 && A[2]>0 && A[3]>0 && A[4]>0 && A[1]<3 && A[2]<3 && A[3]<3 && A[4]<3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

main()

{ 

     int a,b,c,x,y,z; 

     scanf("%d%d%d",&a,&b,&c);  

    if(a > b){     x = a;     a = b;     b = x;  

}   

  if(b > c){  

   y = b;     b = c;     c = y; 

  }    

  if(a > b){  

   z = a;     a = b;     b = z;

  }    

  printf("%d %d %d\n",a,b,c); 

     return 0;

} 

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
using namespace std;
#define SIZE 100001
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int table[SIZE];
int solve(int n,int cnum,int *coin){
  rep(i,n+1)table[i]=n;
  table[0]=0;
  rep(i,n){
    rep(j,cnum){
      if ( i+coin[j]>n)break;
      table[i+coin[j]]=min(table[i]+1,table[i+coin[j]]);
    }
  }
  return table[n];
}

main(){
  int n,m;
  while(cin>>n>>m&&n){
    int in[n],cnum=1<<n,coin[1<<n];
    rep(i,n)cin>>in[i];
    rep(i,cnum){
      coin[i]=0;
      rep(j,n){
	if ( ( (1<<j)&i)!=0)coin[i]+=in[j];
      }
    }
    sort(coin,coin+cnum);
    cout << solve(m,cnum,coin) << endl;
  }
  return false;
}

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

int main(){
  int n;
  cin>>n;
  
  int m;
  m=100*n/108;
  
  if(m*108/100==n){
    cout<<m<<endl;
  }
  else if((m+1)*108/100==n){
    cout<<m+1<<endl;
    
  }
  else{
    cout<<":("<<endl;
  }

  
  return(0);
  


}

Measured memory_bytes: 256