akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, i;
    int arr[100001];
    cin >> n;
    for(i=0; i<n; i++){
        cin >> arr[i];
    }
    sort(arr, arr+n);
    cout << (arr[n/2]-arr[(n/2)-1]) << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <typeinfo>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll x;
    x = min(a,b);
    x = min(x,c);
    x = min(x,d);
    x = min(x,e);
    cout << (n+x-1)/x + 4 << endl;
}

Measured memory_bytes: 256
import collections
import sys

n = input()
n = int(n)
v = [0]*int(n)
v[:] = map(int, input().split())
#print(n)
#print(v)
v_o = [0]*int((n/2))
v_e = [0]*int((n/2))
for i in range(n):
    if i%2 == 0:
        v_o[i//2] = v[i]
    else:
        v_e[i//2] = v[i]

cnt_o = collections.Counter(v_o).most_common(2)
#print(cnt_o[0][1])
collections.Counter(v_e).most_common(1)
cnt_e = collections.Counter(v_e).most_common(2)
#print(cnt_e[0][1])

if cnt_o[0][0] == cnt_e[0][0]:
    if (cnt_o[0][1] == n//2) and (cnt_e[0][1] == n//2):
        print(n//2)
        sys.exit()
    if cnt_o[0][1] >= cnt_e[0][1]:
        n_min = n -cnt_o[0][1] - cnt_e[1][1]
        if (n_min > n -cnt_o[1][1] - cnt_e[0][1]):
            n_min = n -cnt_o[1][1] - cnt_e[0][1]
        print(n_min)
        sys.exit()
    elif cnt_o[0][1] < cnt_e[0][1]:
        n_min = n -cnt_o[1][1] - cnt_e[0][1]
        if (n_min > n -cnt_o[0][1] - cnt_e[1][1]):
            n_min = n -cnt_o[0][1] - cnt_e[1][1]
        print(n_min)
        sys.exit()
else:
    n_min = n -cnt_o[0][1] - cnt_e[0][1]
    print(n_min)
    sys.exit()

Measured memory_bytes: 16044
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,k; cin>>n>>m>>k;
    vector<int> cost;
    vector<vector<int>>vec;
    for(int i=0; i<n; ++i){
    	int v; cin>>v; cost.push_back(v);
    	vector<int> tt;
    	for(int j=0; j<m; ++j){
    		int e; cin>>e;
    		tt.push_back(e);
    	}
    	vec.push_back(tt);
    }
    int ppow = pow(2,n);
    vector<int> A;
    vector<int> B;
    for(int i=1; i<ppow; ++i){
    	long long cst = 0;
    	vector<int> yy;
    	for(int j=0; j<m; ++j){
    		yy.push_back(0);
    	}
    	for(int j=0; j<n; ++j){
    		if( ((1<<j)&i) >0){
    			cst +=cost[j];
    			for(int k=0; k<m; ++k){
    				yy[k]+=vec[j][k];
    			}
    		}
    	}
    	A.push_back(cst);
    	B.push_back(*min_element(yy.begin(), yy.end()));
    }
    int ans = 10000000;
    for(int i=0; i<A.size(); ++i){
    	if(B[i]>=k && A[i]<ans){
    		ans = A[i];
    	}
    }
    if(ans==10000000){
    	cout<<"-1";
    }
    else{
    	cout<<ans;
    }
	return 0;
}

Measured memory_bytes: 4120
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#define CHKR
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define ARRS int(2e5+500)
#define BARRS int(6e4+600)
#define MAX ((long long)(1e9+1))
#define EP ((long double)(1e-9))
#define MMAX ((long long)(1e9+10))
#define HS1 ((long long)(1000001329))
#define HS2 ((long long)(1000001531))
#define MOD ((long long)1000000009ll)
#define SQ 31622780
#define PI 3.14159265358979323846264338327950288419716939937510
#define BG 4294967232ll
#define MH 200008



#ifndef CHKR
int main(){
#else
int doit(fstream &in,fstream &out){
    cin.rdbuf(in.rdbuf());
    cout.rdbuf(out.rdbuf());
#endif
    #ifdef KHOKHO
        #ifndef CHKR
        freopen("in.in","r",stdin);
        freopen("out.out","w+",stdout);
        #endif //CHKR
    #endif //KHOKHO
    ll n,k,p;
    cin>>n>>k>>p;
    if(k>p){
        cout<<0;
        return 0;
    }
    if(n==1&&k!=p){
        cout<<0;
        return 0;
    }
    cout<<p*(n-1)+k-k*(n-1)-p+1;
    return 0;
}


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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define REP(i, n) FOR(i, 0, n)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 2e9;
const ll MOD = 1e9+7;
//const ll MOD 998244353;

int main(void){
	int n;
	cin >> n;

	int d[n];
	REP(i, n){
		cin >> d[i];
	}

	ll ans = 0;
	REP(i, n-1){
		FOR(j, i+1, n){
			ans += d[i]*d[j];
		}
	}

	co(ans);

	return 0;
}


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

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

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let q: i64 = read();
    let bc: Vec<(usize, usize)> = (0..q).map(|_| (read(), read())).collect();

    const W: usize = 100_100;
    let mut freq = vec![0; W];
    let mut sum: i64 = 0;
    for s in a {
        freq[s] += 1;
        sum += s as i64;
    }

    for (b, c) in bc {
        let f = freq[b];
        freq[c] += f;
        freq[b] = 0;
        sum += (c as i64 - b as i64) * f;
        print!("{}\n", sum);
    }
}


Measured memory_bytes: 5120
h,w=map(int,input().split())
inf=10**3
d=((-1,0),(1,0),(0,-1),(0,1))
S=[["#"]*(w+2)]
S.extend([["#"]+[s for s in input()]+["#"] for _ in range(h)])
S.append(["#"]*(w+2))
import heapq

def dist(a,b):
  D=[[inf]*(w+2) for _ in range(h+2)]
  D[a][b]=0
  Visit=[100*a+b]
  heapq.heapify(Visit)
  while Visit:
    v=heapq.heappop(Visit)
    vd,va,vb=v//(10**4),(v%(10**4))//100,v%100
    for dx,dy in d:
      if S[va+dx][vb+dy]=="." and D[va+dx][vb+dy]==inf:
        heapq.heappush(Visit,(vd+1)*(10**4)+(va+dx)*(10**2)+vb+dy)
        D[va+dx][vb+dy]=vd+1
  ret=0
  for i in range(h):
    for j in range(w):
      if D[i+1][j+1]<inf:
        ret=max(ret,D[i+1][j+1])
  return ret
ans=0
for i in range(h):
  for j in range(w):
    if S[i+1][j+1]==".":
      ans=max(dist(i+1,j+1),ans)
print(ans)





Measured memory_bytes: 3188
#! /usr/bin/perl

use strict;
use warnings;

chomp(my $n = <>);

for(my $i = 0;$i < $n;$i ++) {
    chomp(my $buf = <>);
    my($t, $x, $y) = split(/\s+/, $buf);

    if($x + $y <= $t && ($t - ($x + $y))%2 == 0) {
    }else{
        print "No\n";
        exit 0;
    }
}
print "Yes\n";


Measured memory_bytes: 640
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

int main()
{
    int a, b, c;
    bool flg = false;
    cin >> a >> b >> c;

    switch (a)
    {
    case 5:
        switch (b)
        {
        case 5:
            if (c == 7) flg = true;
            break;
        case 7:
            if (c == 5) flg = true;
            break;
        default:
            break;
        }
        break;
    case 7:
        switch (b)
        {
        case 5:
            if (c == 5) flg = true;
            break;

        default:
            break;
        }
        break;

    default:
        break;
    }

    if (flg == true) { cout << "YES"; }
    else{ cout << "NO"; }


    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    string s,a,b;
    cin>>s>>a>>b;
    cout<<s[0]<<a[1]<<b[2]<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>

#define NUM 9

int main()
{
  int n;
  
  scanf("%d",&n);
  
  int a[n];
  int i,j;
  int color[NUM]={};
  int min=0,max=0;
  
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    if(3600<=a[i])
    {
      color[NUM-1]++;
    }
    else
    {
    color[a[i]/400]++;
    }
  }
  
  //int zero=0;
  for(i=0;i<NUM-1;i++)
  {
    if(color[i]!=0)
    {
      min++;
      max++;
    }
    /*if(color[i]==0)
    {
      zero++;
    }*/
  }
  
  int x;
  x=color[NUM-1];
  
  if(x!=0)
  {
    if(min==0)
    {
      min++;
    }
    
    max+=x;
  /*  if(x<=zero)
    {
      max+=x;
    }
    else
    {
      max+=zero;
    }*/
  }
  printf("%d %d\n",min,max);
  return 0;
}

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

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int H[20];

int main()
{
	int N;
	bool ok;
	int ans = 0;

	cin >> N;
	rep(i, N) cin >> H[i];

	rep(i, N) {
		if (i == 0) {
			ans++;
			continue;
		}

		ok = true;
		rep(j, i) {
			if (H[j] > H[i]) ok = false;
		}
		if (ok) ans++;
	}

	cout << ans << endl;

	return 0;
}


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

typedef pair<int, int> P;
// いもす用
int sum[100010];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N, C;
    cin >> N >> C;
    // 前処理用
    vector<vector<P>> time(C);
    for(int i = 0; i < N; ++i){
        int s, t, c;
        cin >> s >> t >> c;
        --c;
        time[c].push_back(P(s, t));
    }
    
    for(int i = 0; i < C; ++i){
        sort(time[i].begin(), time[i].end());
        
        int s = -1, t = -1;
        for(int j = 0; j < time[i].size(); ++j){
            if(s == -1 && t == -1){
                s = time[i][j].first - 1;
                t = time[i][j].second;
            }
            else{
                if(t == time[i][j].first){
                    t = time[i][j].second;
                }
                else{
                    sum[s] += 1;
                    sum[t] -= 1;
                    s = time[i][j].first - 1;
                    t = time[i][j].second;
                }
            }
        }
        
        if(s != -1 && t != -1){
            sum[s] += 1;
            sum[t] -= 1;
        }
    }
    
    int ans = sum[0];
    for(int i = 0; i < 100005; ++i){
        sum[i + 1] += sum[i];
        ans = max(ans, sum[i + 1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
from sys import stdin

l = stdin.readline().rstrip().split()
l.sort()

a, b, c = [int(x) for x in l]

if a == b == 5:
    if c == 7:
        print('YES', flush=True)
    else:
        print('NO', flush=True)
else:
    print('NO', flush=True)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int H, W, K; cin >> H >> W >> K;
	vector<string> S(H); cin >> S;

	int B = (1<<(H-1));	
	int ans = INF;
	for (int bit = 0; bit < B; bit++) {
		int size = __builtin_popcount(bit) + 1;
		vint num(size, 0);
		int data = size-1;
		bool muri = false;
		for (int j = 0; j < W; j++) {
			int cnt = 0;
			vint now(size, 0);
			for (int i = 0; i < H; i++) {
				now[cnt] += (int)(S[i][j] == '1');
				if (i < H-1 && ((bit>>i)&1)) cnt++;
			}
			for (int i = 0; i < size; i++) {
				if (now[i] > K) {
					muri = true;
					break;
				}
				if (num[i] + now[i] > K) {
					data++;
					num.assign(size, 0);
					break;
				}
			}
			if (muri) break;
			for (int i = 0; i < size; i++) {
				num[i] += now[i];
			}
		}
		if (!muri) chmin(ans, data);
	}

	cout << ans << endl;
}

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


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
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};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  	string s;
    cin >> s;
  	sort(ALL(s));
  	if(s=="abc")yes;
  	else no;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

ll calc(list<char> buf) {
	vector<ll> imos(buf.size(), 0);
	int idx = 0;
	for (auto itr = buf.begin(); itr != buf.end(); ++itr) {
		if (*itr == 'A')imos[idx]++;
		idx++;
	}
 	int tmp = (int)buf.size()-1;
	REP(i, tmp) {
		imos[i + 1] += imos[i];
	}

	idx = 0;
	ll res = 0;
	for (auto itr = buf.begin(); itr != buf.end(); ++itr) {
		if (*itr == 'D')res += imos[idx];
		idx++;
	}
	return res;
}

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

	list<char> li;
	REP(i, s.size()) {
		if (s[i] == 'A')li.push_back('A');
		else if (s[i] == 'C')li.push_back('C');
		else {
			if (i == s.size() - 1)li.push_back('B');
			else {
				if (s[i + 1] == 'C') {
					li.push_back('D');
					i++;
				}
				else {
					li.push_back('B');
				}
			}
		}
	}

	ll res = 0;
	list<char> buf;
	while (!li.empty()) {
		while (!li.empty() && (li.front() == 'A' || li.front() == 'D')) {
			buf.push_back(li.front());
			li.pop_front();
		}
		if (!li.empty())li.pop_front();
		res += calc(buf);
		buf.clear();
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 14468
/*input

*/
/*
Contest: 
Problem: 
*/
#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;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#define F first
#define S second
#define mp make_pair
#define append push_back
#define vi vector<ll>
#define pii pair<ll,ll>
#define qi queue<ll>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define print(a) cout<<a<<endl
#define sorted(a) sort(arr.begin(), arr.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define read(a) scanf("%d", &a)
 
const int MOD = 1e9 + 7, MAXN = 3010;

string s, t, ans;
int dp[MAXN][MAXN];

int solve(int i, int j){
    if(i == s.size() or j == t.size())
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];

    if(s[i] == t[j])
        return dp[i][j] = 1 + solve(i + 1, j + 1);
    else
        return dp[i][j] = max(solve(i + 1, j), solve(i, j + 1));
}

string lcs(int i, int j){
    string tmp;
    while(i < s.size() and j < t.size()){
        if(s[i] == t[j]){
            tmp += s[i];
            i++; j++;
        }
        else if(dp[i+1][j] > dp[i][j+1])
            i++;
        else
            j++;
    }
    return tmp;
    //return reverse(tmp.begin(), tmp.end());
}

signed main(){
    
    cin>> s >> t;

    mem(dp, -1);

    solve(0, 0);

    print(lcs(0, 0));

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 36096
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < (int)s.size(); i++) {
    	cout << s[i] << t[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct
{
  char ch;
  char num;
}P;

void Bubble(P C[],int n)
{
  P t;
  int i,j;

  for(i = 0;i < n;i++)
  {
    for(j = n - 1;j >= i + 1;j--)
    {
      if(C[j].num < C[j - 1].num)
      {
        t = C[j];
        C[j] = C[j - 1];
        C[j - 1] = t;
      }
    }
  }
}

void Select(P C[],int n)
{
  P t;
  int i,j,min;

  for(i = 0;i < n;i++)
  {
    min = i;
    for(j = i;j < n;j++)
    {
      if(C[j].num < C[min].num) min = j;
    }
    t = C[i];
    C[i] = C[min];
    C[min] = t;
  }
}

void Print(P C[],int n)
{
  int i;

  for(i = 0;i < n;i++)
  {
    if(i) printf(" ");
    printf("%c",C[i].ch);
    printf("%c",C[i].num);
  }
  printf("\n");
}

int Judg(P C1[],P C2[],int n)
{
  int i;

  for(i = 0;i < n;i++)
  {
    if(C1[i].ch != C2[i].ch) return 0;
  }
  return 1;
}

int main()
{
  P C1[100],C2[100];
  int i,n;

  scanf("%d",&n);
  for(i = 0;i < n;i++)
  {
    scanf(" %c%c",&C1[i].ch,&C1[i].num);
    C2[i] = C1[i];
  }

  Bubble(C1,n);
  Print(C1,n);
  printf("Stable\n");

  Select(C2,n);
  Print(C2,n);
  if(Judg(C1,C2,n)) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}



Measured memory_bytes: 2108
import sys, math

a = [int(i) for i in input().split()]
N = a[0]
D = a[1]
X = []
for i in range(N):
  tmp = [int(i) for i in input().split()]
  X.append(tmp)

if D == 1:
  print(int(N*(N-1)/2))
  sys.exit(0)

count = 0
for n in range(0,N-1):
  for nn in range(n+1,N):
    result = 0
    for d in range(D):
      tmp = (X[n][d]-X[nn][d])**2
      result+=tmp
    result = math.sqrt(result)
    
    if result.is_integer():
      count+=1;
print(int(count))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;

const long long MOD = 2019;

void solve(long long L, long long R){
  if (R-L+1 >= 2019) {
    std::cout << 0 << std::endl;
    return;
  }

  long long ans = 2019;

  for (int i = L; i <= R-1; i++) {
    for (int j = i + 1; j <= R; j++) {
      ans = min((i%MOD)*(j%MOD)%MOD, ans);
    }
  }

  std::cout << ans << std::endl;
}

int main(){
  long long L;
  scanf("%lld",&L);
  long long R;
  scanf("%lld",&R);
  solve(L, R);
  return 0;
}


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

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

using namespace std;

int n;
int M[N][N]; // ??£??\??????
int d[N]; // ????????????
int f[N]; // ????????????
int color[N]; // ?¨??????¶???
int nt[N];
int tt = 0; // ??????


int next(int u)
{
    int i;
    for (i = nt[u]; i < n; i++) {
        nt[u] = i + 1; 
        if (M[u][i]) return i;
    }
    return -1;
}


void dfs_visit(int r)
{
    int i;
    for (i = 0; i < n; i++) {
        nt[i] = 0;
    }
    
    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;
    
    while (!S.empty()) {
        int u = S.top();
        int v = next(u);
        if (v != -1) {
            if (color[v] == WHITE) {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }
        else {
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }        
    }
}

// ?????°ver
void dfs_visit_r(int r)
{
    int v;
    color[r] = GRAY;
    d[r] = ++tt;
    for (v = 0; v < n; v++) {
        if (M[r][v] == 0) continue;
        if (color[v] == WHITE) dfs_visit_r(v);
    }
    color[r] = BLACK;
    f[r] = ++tt;
}


void dfs()
{
    int i;
    for (i = 0; i < n; i++) {
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;
    
    for (i = 0; i < n; i++) {
        if (color[i] == WHITE) {
            //dfs_visit(i);
            dfs_visit_r(i);
        }
    }   
     
    for (i = 0; i < n; i++) {
        printf("%d %d %d\n", i+1, d[i], f[i]);
    }
}


int main()
{
    scanf("%d", &n);
    int i, j;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }
    
    // input graph
    int u, k, v;
    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            M[u-1][v-1] = 1;
        }
    }
    
    dfs();
    
    return 0;
}

Measured memory_bytes: 1072
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

typedef	pair<int,int>	pii;

int main()
{
	int n;
	for(;scanf("%d",&n),n;){
		vector<pii> total(n);
		for(int i=0;i<n;i++){
			int c1,m1,s1,m2,s2,m3,s3,m4,s4;
			scanf("%d%d%d%d%d%d%d%d%d",&c1,&m1,&s1,&m2,&s2,&m3,&s3,&m4,&s4);
			total[i]=make_pair(60*m1+s1+60*m2+s2+60*m3+s3+60*m4+s4,c1);
		}
		sort(total.begin(),total.end());
		printf("%d\n%d\n%d\n",total[0].second,total[1].second,total[n-2].second);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*約数の個数(x含む)*/ll divi(ll x){ll i,ans=0;rep(i,2,x+1){if(x%i==0){ans++;}}return ans;}
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;ll ans=0;///////////////////////////////////////////
ll x,y,n,k;
ll a[200010];
int main(){
 sc(x);
 ll ans=0;
 if(x>=500)ans+=(x/500)*1000;
 x%=500;
 if(x>=5)ans+=(x/5)*5;
 pr(ans);
return 0;}

Measured memory_bytes: 3604
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static void Write(object obj) {
#if DEBUG
        Debug.Write(obj.ToString());
#else
        Console.Write(obj.ToString());
#endif
    }

    //static long mod = 1000000007;
    static HashSet<int>[] friends;
    static HashSet<int>[] blocks;

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var m     = int.Parse(spl[1]);
        var k     = int.Parse(spl[2]);

        friends  = new HashSet<int>[n];
        blocks   = new HashSet<int>[n];

        for(int i=0; i<n; i++) {
            friends[i]  = new HashSet<int>();
            blocks[i]   = new HashSet<int>();
        }

        for(int i=0; i<m; i++) {
            spl   = input.ReadLine().Split(' ');
            var a = int.Parse(spl[0]) -1;
            var b = int.Parse(spl[1]) -1;
            friends[a].Add(b);
            friends[b].Add(a);
        }

        for(int i=0; i<k; i++) {
            spl   = input.ReadLine().Split(' ');
            var a = int.Parse(spl[0])-1;
            var b = int.Parse(spl[1])-1;
            blocks[a].Add(b);
            blocks[b].Add(a);
        }

        var graphs = new List<HashSet<int>>();
        var gno = new int[n];

        for(int i=0; i<n; i++) {
            gno[i] = -1;
        }

        for(int i=0; i<n; i++) {
            if(gno[i] < 0) {
                var gr = new HashSet<int>();
                NetWork(i, gr);
                graphs.Add(gr);
                foreach(var x in gr) {
                    gno[x] = graphs.Count - 1;
                }
            }
        }

        for(int i=0; i<n; i++) {
            var gr = graphs[gno[i]];

            int count = gr.Count;
            count -= friends[i].Count(x => gr.Contains(x));
            count -= blocks[i].Count(x => gr.Contains(x));
            count -= 1;

            Write(count.ToString());
            Write(' ');
        }

        return null;
    }

    private static void NetWork(int a, HashSet<int> box) {
        box.Add(a);

        foreach(var f in friends[a]) {
            if (!box.Contains(f)) {
                NetWork(f, box);
            }
        }
    }
}


Measured memory_bytes: 67472
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll w, h;
	cin>>w>>h;
	vector<ll> p(w), q(h);
	rep(i, w) cin>>p[i];
	rep(i, h) cin>>q[i];
	p.push_back(1e9); q.push_back(1e9);
	sort(all(p)); sort(all(q));
	reverse(all(p)); reverse(all(q));
	ll res = 0;
	while(w || h){
		if(p[w]<q[h]) res += p[w--]*(h+1);
		else res += q[h--]*(w+1);
	}
	cout<<res<<endl;
	return 0;
}


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


/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/
const ll INF = 1000100100100100100;
const int MAX_N = 405;

int n;
ll a[MAX_N];

ll dp[MAX_N][MAX_N];

void init(){
    rep(i,MAX_N){
        rep(j,MAX_N){
            dp[i][j] = -1;
        }
    }
}


ll f(int l, int r){
    if(dp[l][r]>=0) return dp[l][r];
    if(l == r) return dp[l][r] = 0;

    // どこで切るか全通り試す
    ll res = INF;
    for(int m=l; m<r; m++){
        res = min(res, f(l,m)+f(m+1,r));
    }
    if(l == 0) res = res + a[r];
    else res = res + a[r]-a[l-1];
    return dp[l][r] = res;
}


int main()
{
    cin >> n;
    rep(i,n) cin >> a[i];

    rep(i,n){
        if(i == 0) continue;
        a[i] = a[i-1]+a[i];
    }

    init();

    cout << f(0,n-1) << endl;

}

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

int main () {
  int N;
  cin >> N;
  string S[N];
  int i;
  int p=0;
  int w=0;
  int g=0;
  int y=0;
  for (i=0;i<N;++i) {
    cin >> S[i];
    if (S[i] == "P" && p==0) {
      p += 1;
    } else if (S[i] == "W" && w==0) {
      w += 1;
    } else if (S[i] == "G" && g==0) {
      g += 1;
    } else if (S[i] == "Y" && y==0) {
      y += 1;
    }
  }
  int num = p+w+g+y;
  if (num==3) {
    cout << "Three" << endl;
  } else {
    cout<<"Four"<<endl;
  }
  
}

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

int main(){
    int n; cin >> n;
    int a;
    int t;
    int MIN = 1e9;
    rep(i, n){
        t=0;
        cin >>a;
        while(a%2==0){
            a /=2;
            t +=1;
        } 

        MIN = min(MIN, t);
    }
    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[200100],n;
long long sum,psum[200100],ans = 0x7fffffffffffffffll;
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
	{
		scanf("%d",&a[i]);
		psum[i] = psum[i - 1] + a[i];
		sum += a[i];
	}
	for(int i = 1;i < n;i++)
		ans = min(ans,abs(sum - 2 * psum[i]));
	printf("%d",ans);
}

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    int N; cin >> N;
    vi odds(N/2), evens(N/2);
    F0R(i, N) {
    	if (i % 2 == 0) {
    		cin >> odds[i/2];
    	} else {
    		cin >> evens[i/2];
    	}
    }

    int counts[MX][2]; F0R(i, MX) {  counts[i][0] = 0; counts[i][1] = 0; }
    F0R(i, N/2) {
    	counts[odds[i]][0]++;
    	counts[evens[i]][1]++;
    }
    vpi pairs[2];
    F0R(i, MX) {
    	pairs[0].pb(mp(counts[i][0], i));
    	pairs[1].pb(mp(counts[i][1], i));
    }
    pairs[0].pb(mp(0, -1)); pairs[1].pb(mp(0, -2));

    sort(all(pairs[0])); sort(all(pairs[1]));
    reverse(all(pairs[0])); reverse(all(pairs[1]));

    int best = pairs[0][0].f + pairs[1][0].f;
    if (pairs[0][0].s == pairs[1][0].s) {
    	best = 0;
    	if (sz(pairs[0]) > 1) {
    		best = pairs[0][1].f + pairs[1][0].f;
    	} 
    	if (sz(pairs[1]) > 1) {
    		best = max(best, pairs[0][0].f + pairs[1][1].f);
    	}
    }

    cout << N - best << endl;
    
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

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

int main(){
    char c;
    cin >> c;

    switch(c){
        case 'a': case 'i':case 'u':case 'e':case 'o':
            cout << "vowel" << endl;
            break;
        default :
            cout << "consonant" << endl;
            break;
    }

    return 0;
     
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


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

  ll r, g, b, n;
  cin >> r >> g >> b >> n;
  ll ans = 0;
  for (int i = 0; i <= n / r; i++) {
    ll rr = r * i;
    for (int j = 0; j <= (n - rr) / g; j++) {
      ll gg = g * j;
      ll rem = n - rr - gg;
      if (rem % b == 0) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	int n; cin >> n;
	vector<int>p(n); for (auto&& x : p)cin >> x;
	int ans = 1, mini = p[0];
	for (int i = 1; i < n; i++) {
		if (mini > p[i]) { ans++; mini = p[i]; }
	}
	cout << ans << endl;
	return 0;
}

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

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

  int n;
  cin >> n;
  string s = to_string(n);
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    if (s[i] == '2') ans++;
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int n, ans = 1; cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end());
    for(int i = 1; i < n; i++) {
        if(s[i] != s[i-1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9504
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
using namespace std;

int main(){
    int N;

    cin >> N;
    double a[N];
    string b[N];
    double ans = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
        if(b[i][0] == 'J'){
            ans += a[i];
        }else{
            ans += a[i] * 380000;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
@a = [0] + gets.chomp.split.map(&:to_i)
@b = (0..n).to_a
count = 0

def root(i)
  return i if @b[i] == i
  @b[i] = root(@b[i])
end

def union(i, j)
  return if root(i) == root(j)
  @b[root(i)] = @b[root(j)]
end

m.times do
  x, y = gets.chomp.split.map(&:to_i)
  union(x, y)
end

(1..n).each do |i|
  count += 1 if root(@a[i]) == root(i)  
end

puts count

Measured memory_bytes: 12812
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
void end() {
	puts("NO");
	exit(0);
}
int main() {
	int k;
	cin >> k;
	vector<int> a(k);
	rep(i, 0, k)cin >> a[i];
	ll m, M;
	m = M = 2ll;
	for (int i = k - 1; i >= 0; i--) {
		m = ((m - 1) / a[i] + 1) * a[i];
		M = M / a[i] * a[i] + a[i] - 1;
		if (m / a[i] >= M / a[i] && m != m / a[i] * a[i] || m > M) {
			puts("-1");
			return 0;
		}
	}
	printf("%lld %lld\n", m, M);
	return 0;
}

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

int main()
{
    int p, q, r;
    cin >> p >> q >> r;
    cout << min({p + q, p + r, q + r}) << endl;
    return 0;
}

Measured memory_bytes: 3596
from sys import stdin
input = stdin.readline

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

ls = [0] * 10 ** 6

for a in A:
    ls[a] += 1

s = sum(A)

for _ in range(Q):
    B, C = map(int, input().split())
    s += ls[B] * (C - B)
    ls[C] += ls[B]
    ls[B] = 0
    print(s)


Measured memory_bytes: 23004
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;


int main(){

    string s1,s2;
    cin >> s1 >> s2;

    string s = "abcdefghijklmnopqrstuvwxyz";
    vector<int> a(26,0),b(26,0); 
    vector<bool> used_a(26,false),used_b(26,false);

    REP(i,s1.length()){
        a[s1[i] - 'a']++;
    }

    REP(i,s2.length()){
        b[s2[i] - 'a']++;
    }

    bool can = true;

    int count_a = 0,count_b = 0;

    REP(i,26){
        if(a[i] != 0){
            count_a++;
        }
    }

   

    REP(i,26){
        if(b[i] != 0){
            count_b++;
        }
    }

    

    for(int i = 0;i < 26;i++){

        if(a[i] == 0){
            continue;
        }
        for(int j = 0;j < 26;j++){
            if(b[j] == 0){
                continue;
            }else if(a[i] == b[j] && used_a[i] == false && used_b[j] == false){

                count_a--;
                count_b--;
                used_a[i] = true;
                used_b[j] = true;
                break;
            }
        }
    }

    if(count_a == 0 && count_b == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define M1 1000000007
#define M2 998244353
#define ll long long int
#define N (int)1e5+3
#define test(t) while(t--)
#define PI acos(-1.0)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,b,a) for(ll i=b-1;i>=a;i--)
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define V(a) vector<a>
#define M(a,b) map<a,b>
#define endl '\n'
#define all(x) begin(x),end(x)
#define allr(x) rbegin(x),rend(x)
#define pr(a) cout<<a<<endl;
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = { 0, -1, 0, 1 };
const int dy[4] = { -1, 0, 1, 0 };
using namespace std;

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;
    map<ll,ll> m;
    m[a]++;
    m[b]++;
    m[c]++;
    if (m[b] ==2 || m[c]==2) cout << "Yes" << endl;
    else cout <<"No" << endl;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

template<class T>
struct SegmentTree {
	using F = function<T(T, T)>;
	const T init;
	const F f;
	int sz;
	vector<T> seg;
	SegmentTree(int n, const T init, const F f) :
		init(init),
		f(f)
		{
			sz = 1;
			while(sz < n) sz <<= 1;
			seg.resize(sz << 1, init);
		}
	void update(int id) {
		while(id >>= 1) {
			seg[id] = f(seg[2 * id], seg[2 * id + 1]);
		}
	}
	void replace(int id, T x){
		id += sz;
		seg[id] = x;
		update(id);
	}
	// [l,r)
	T get(int l, int r){
		T L = init, R = init;
		for(l += sz, r += sz; l < r; l >>= 1, r>>= 1) {
			if(l & 1) L = f(L, seg[l++]);
			if(r & 1) R = f(seg[--r], R);
		}
		return f(L, R);
	}
	void debug(){
		int i = 1;
		for(int r = 2; r <= 2 * sz; r <<= 1) {
			while(i < r) {
				cout << seg[i++] << " ";
			}
			cout << "\n";
		}
	}
};


int main() {
	int n, m; cin >> n >> m;
	SegmentTree<int64_t> seg(n, LINF, [](int64_t l, int64_t r){return min(l, r);});
	seg.replace(0, 0);
	priority_queue<tuple<int, int, int64_t>, vector<tuple<int, int, int64_t>>, greater<tuple<int, int, int64_t>>> pq;
	rep(i,m) {
		int l, r, c; cin >> l >> r >> c;
		l--, r--;
		pq.emplace(l, r, c);
	}
	while(pq.size()) {
		int64_t ll, rr, cc;
		tie(ll, rr, cc) = pq.top();
		pq.pop();
		if(seg.get(ll, rr + 1) == LINF) continue;
		int64_t ncos = seg.get(ll, rr + 1) + cc;
		if(ncos <= seg.get(rr, rr + 1)) {
			// cerr << ll << " " << rr << " " << cc << endl;
			seg.replace(rr, ncos);
		}
	}
	int64_t ans = seg.get(n - 1, n);
	cout << (ans == LINF ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


int calc(ll a){
	int ret = 0;
	while(a > 0){
		ret++;
		a /= 10;
	}
	return ret;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	int ans = 1e9;
	for(ll a = 1; a * a <= n; a++){
		if(n % a == 0){
			ans = min(ans, max(calc(a), calc(n / a)));
		}
	}
	cout << ans << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 N;
	cin >> N;
	vector<PII> v(N);
	vector<int64> res(N);
	REP(i, N){
		cin >> v[i].fs;
		v[i].sc = i;
	}
	sort(all(v));
	REP(i, v.size()){
		if(i < N/2) res[v[i].sc] = v[N/2].fs;
		else res[v[i].sc] = v[N/2-1].fs;
	}
	REP(i, N){
		cout << res[i] << endl;
	}
}


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

using namespace std;
typedef long long LL;

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

    for(LL j=0; j<N/2; j++){
        char a = S[2*N - 1-j];
        S[2*N - 1- j] = S[N+j];
        S[N+j] = a;
    }

    LL counter = 0;
    for(LL i=0; i<1<<N; i++){
        string s1,s2;
        for(LL j=0; j<N; j++){
            if( (i>>j)%2 == 0){
                s1 += S[j];
            }
            else{
                s2 += S[j];
            }
        }
        LL l1 = s1.length();
        LL l2 = s2.length();





        LL dp[N+1][N+1];
        dp[0][0] = 1;
        for(LL j1 = 1; j1< N+1; j1++){
            for(LL j2 = 0; j2 <= j1; j2++){
                dp[j1][j2] = 0;
                if(j2 > 0 && j2 <= l1){
                    if(S[N + j1 - 1] == s1[j2 - 1]){
                        dp[j1][j2] += dp[j1-1][j2-1];
                    }
                }
                if(j2 < j1 && j1-j2 <= l2 ){
                    if(S[N+j1-1] == s2[j1-j2-1]){
                        dp[j1][j2] += dp[j1-1][j2];
                    }
                }

            }
        }
        counter += dp[N][l1];



    }
    cout<<counter<<endl;

    return 0;
}


Measured memory_bytes: 384
N,K=map(int,input().split())

S=input()
face2face=0
back2back=0
for i in range(N-1):
  if S[i]=='L' and S[i+1]=='R':
    back2back+=1
  if S[i]=='R' and S[i+1]=='L':
    face2face+=1


for i in range(K):
  face2face-=1
  back2back-=1
face2face=max(face2face,0)
back2back=max(back2back,0)
  
print(N-face2face-back2back-1)

Measured memory_bytes: 9248