akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

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

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

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



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int ans = 0;
	int H;
	int x = 1;
	
	cin>>H;
	
	while(H > 0){
		ans++;
		H >>= 1;
	}
	
	cout<<(1ll<<ans)-1<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define SORT(x) sort((x).begin(),(x).end())
#define MEMSET(x,y) memset((x),(y),sizeof(x))
#define P pair<int,int>

typedef long long ll;
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if(a < b) rep(i,b) cout << a;
  else rep(i,a) cout << b;
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        var res = int.MaxValue;
        for (int i = 0; i <= s.Length - t.Length; i++)
        {
            res = Min(s.Substring(i, t.Length).Zip(t, (x, y) => x == y ? 0 : 1).Sum(), res);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 26720
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<17)
#define MODULO (1000000007)
#define HA1 (2420609)
#define HA2 (19260817)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <vector>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
using namespace std;

inline int GetRand()
{
	int Res = rand()*rand()*rand();
	Res -= rand()*rand();
	Res += rand();
	return Res;
}

long long EuclidGCD(long long xx, long long yy)
{
	if (xx < 0 && yy < 0)
	{
		xx = -xx, yy = -yy;
	}
	if (xx > yy)
	{
		swap(xx, yy);
	}
	if (xx == 0LL)
	{
		return yy;
	}
	return EuclidGCD(yy%xx, xx);
}

int n, k;
int a[N];
int mx;
int gg;

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 0;i < n;i++)
	{
		scanf("%d", &a[i]);
		mx = max(mx, a[i]);
		if (gg == 0)
		{
			gg = a[i];
		}
		else
		{
			gg = (int)EuclidGCD((long long)gg, (long long)a[i]);
		}
	}
	if (k > mx)
	{
		printf("IMPOSSIBLE\n");
		return 0;
	}
	if (k%gg != 0)
	{
		printf("IMPOSSIBLE\n");
		return 0;
	}
	printf("POSSIBLE\n");
	//system("pause");
	return 0;
}



Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

ll solve2(int n, int p, string s) {
    ll ans = 0;
    rep(i, 0, s.size()) {
        if ((s[i] - '0') % 2 == 0) {
            ans += i + 1;
        }
    }
    return ans;
}

ll solve5(int n, int p, string s) {
    ll ans = 0;
    rep(i, 0, s.size()) {
        if (s[i] == '0' || s[i] == '5') {
            ans += i + 1;
        }
    }
    return ans;
}

ll solveOther(int n, int p, string s) {
    vector<int> count(p, 0);
    int sum = 0;
    int power = 1;
    ll ans = 0;
    repi(i, s.size() - 1, 0) {
        check(power < p);
        sum = (sum + (s[i] - '0') * power) % p;
        check(sum >= 0 && sum < p);
        // debug("i=%d,sum=%d,power=%d,count[%d]=%d\n", i, sum, power, sum, count[sum]);
        ans += count[sum];
        if (sum == 0) {
            ans++;
        }
        count[sum]++;
        power = power * 10 % p;
    }
    return ans;
}

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

    // debug("%d", 400000 * 400000 / 2);
    // exit(0);

    int n, p;
    cin >> n >> p;
    // n = 200000;
    // p = 7;
    string s;
    cin >> s;
    // srand(time(0));
    // rep(i, 0, n) {
    //     // s.push_back((int)(rand() * 10.0 / RAND_MAX) + '0');
    //     s.push_back('7');
    // }
    // cout << s << el;
    if (p == 2) {
        cout << solve2(n, p, s);
    } else if (p == 5) {
        cout << solve5(n, p, s);
    } else {
        cout << solveOther(n, p, s);
    }
}


Measured memory_bytes: 832
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=0;
	if(s[0]=='+')ans++;
	if(s[0]=='-')ans--;
		if(s[1]=='+')ans++;
	if(s[1]=='-')ans--;
		if(s[2]=='+')ans++;
	if(s[2]=='-')ans--;
		if(s[3]=='+')ans++;
	if(s[3]=='-')ans--;
	cout<<ans<<endl;
		
}

Measured memory_bytes: 888
import itertools
p=list(input())#HYF#MXwxNTY2OTA1OTN8eyJjaGFubmVsSWQiOiJ3YXAwMDIifQ==
s=[int(x) for x in p]
for x in itertools.product(['+','-'],repeat=3):
	t=s[0]
	for i in range(3):
		t=t+s[i+1] if x[i]=='+' else t-s[i+1]
	if t==7:
		ans=x
		break
for i in range(3):
	p.insert(2*i+1,ans[i])
print(''.join(p)+'=7')

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

int pTbl[10000] = { 2 };
int pn = 1;

void pCalc()
{
	for (size_t i = 3; i < 55555; i += 2)
	{
		for (int j = 0; j < pn; j++)
		{
			if (i % pTbl[j] == 0)
			{
				goto NotP;
			}
		}
		pTbl[pn] = i;
		pn++;

	NotP:;
	}
}

int main()
{
	int n;
	cin >> n;
	int a[55];

	pCalc();

	int i = 0, j = 1;
	while (i < n)
	{
		if (pTbl[j] % 5 == 2)
		{
			a[i] = pTbl[j];
			i++;
		}
		j++;
	}

	for (int i = 0; i < n; i++)
	{
		cout << a[i] << ' ';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
# 最弱 2 < ~ < 13 < 1 最強

alice_card, bob_card = map(int, input().split())

# 最強カード「1」をわかりやすく、13足して14にしとく。

if alice_card == 1:
    alice_card += 13

if bob_card == 1:
    bob_card += 13


# 勝負の処理
if alice_card == bob_card:
    print('Draw')
elif alice_card > bob_card:
    print('Alice')
elif alice_card < bob_card:
    print('Bob')

Measured memory_bytes: 9100
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int n, m;
int fac[1000005], inv[1000005], ifac[1000005];

void init_fac()
{
	fac[0] = 1;
	rep1(i, n + m) fac[i] = 1LL * fac[i - 1] * i % MOD;
	rep1(i, n + m) inv[i] = i == 1 ? 1 : MOD - 1LL * inv[MOD % i] * (MOD / i) % MOD;
	ifac[0] = 1;
	rep1(i, n + m) ifac[i] = 1LL * ifac[i - 1] * inv[i] % MOD;
}

int comb(int p, int q)
{
	return p < 0 || q < 0 ? 0 : 1LL * ifac[p] * ifac[q] % MOD * fac[p + q] % MOD;
}

int dp[1000005], dpn[1000005], dpm[1000005];

int main()
{
	scanf("%d%d", &n, &m);
	init_fac();
	
	dp[0] = 0;
	dpn[0] = comb(n - 1, m);
	dpm[0] = comb(m - 1, n);
	int ans = 0;
	rep(i, n + m) {
		dp[i + 1] = (dpn[i] + dpm[i]) % MOD;
		dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
		ans = (ans + 1LL * dp[i + 1] * inv[i + 1]) % MOD;
		if(i & 1) dpn[i + 1] = (dpn[i] + 1LL * comb(i / 2, i / 2 + 1) * comb(n - i / 2 - 2, m - i / 2 - 1)) % MOD;
		else dpn[i + 1] = (dpn[i] + 1LL * (MOD - comb(i / 2, i / 2)) * comb(n - i / 2 - 1, m - i / 2 - 1)) % MOD;
		if(i & 1) dpm[i + 1] = (dpm[i] + 1LL * comb(i / 2, i / 2 + 1) * comb(m - i / 2 - 2, n - i / 2 - 1)) % MOD;
		else dpm[i + 1] = (dpm[i] + 1LL * (MOD - comb(i / 2, i / 2)) * comb(m - i / 2 - 1, n - i / 2 - 1)) % MOD;
	}
	ans = 1LL * fac[n] * fac[m] % MOD * ifac[n + m] % MOD * ans % MOD;
	printf("%d\n", ans);
	return 0;
}

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

long long k, a, b;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> k >> a >> b;
	long long ans = k + 1;
	if(k + 1 >= a)
		ans = max(ans, a + ((k - a + 1) / 2) * (b - a) + (k - a + 1) % 2);
	cout << ans;
	return 0;
}

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

int main(){
	int h,w,k;
	string s[302];
	cin >> h >> w >> k;
	for(int i = 1 ; i <= h ; i ++){
		cin >> s[i];
	}
	
	static int ret[302][302] = {};
	static int t = 1;
	for(int i = 1 ; i <= h ; i ++){
		int cnt = 0;
		for(int j = 0 ; j < w ; j ++){
			if(s[i][j] == '#')cnt ++;
		}
		if(cnt == 0){
			for(int j = 0 ; j < w ; j ++){
				ret[i][j] = ret[i-1][j];
			}
		}
		else {
			cnt = 0;
			for(int j = 0 ; j < w ; j ++){
				if(s[i][j] == '#'){
					cnt ++;
					if(cnt > 1)t ++;
				}
				ret[i][j] = t;
			}
			t ++;
		}
	}
	for(int i = h ; i >= 1 ; i --){
		for(int j = 0 ; j < w ; j ++){
			if(ret[i][j] == 0)ret[i][j] = ret[i+1][j];
		}
	}
	
	for(int i = 1 ; i <= h ; i ++){
		for(int j = 0 ; j < w ; j ++){
			printf("%d%c",ret[i][j],(j+1==w)?'\n':' ');
		}
	}
}
	

Measured memory_bytes: 1280
#include<cstdio>
#include<map>
using namespace std;
typedef long long ll;

int N;
char g[12][10];
int num[30];
int maxnum;

int sum[10];
bool top[10];
bool canPut[10];

bool canP(int i) {
  if (i < 0 || i >= 10) return false;
  return canPut[i];
}

int ans(int n, int s) {
  if (n == maxnum - 1) {
    //printf("%d\n",s);
    if (s % sum[n] != 0) return 0;
    if (s == 0) {
      if (sum[n] == 0 || (canPut[0] && !top[n])) return 1;
      return 0;
    }
    int t = - s / sum[n];
    if (t < 0 || t >= 10) return 0;
    return canPut[t];
  }
  int a = 0;
  for (int i = 0; i < 10; i++) if (canPut[i]) {
    if (i == 0 && top[n]) continue;
    canPut[i] = false;
    a += ans(n + 1, s + i * sum[n]);
    canPut[i] = true;
  }
  return a;
}


int main() {
  while (1) {
    scanf("%d", &N);
    if (N == 0) break;
    maxnum = 0;
    for (int i = 0; i < 30; i++) num[i] = -1;
    for (int i = 0; i < 10; i++) sum[i] = 0, top[i] = false, canPut[i] = true;
    for (int i = 0; i < N; i++) {
      scanf("%s", g[i]);
      int count = 1;
      for (int j = 0; g[i][j] != 0; j++) count *= 10;
      for (int j = 0; g[i][j] != 0; j++) {
        count /= 10;
        int number;
        if (num[g[i][j] - 'A'] == -1) number = num[g[i][j] - 'A'] = maxnum++;
        else number = num[g[i][j] - 'A'];
        if (i == N - 1) sum[number] -= count;
        else sum[number] += count;
        if (j == 0 && count != 1) top[number] = true;
      }
    }
    printf("%d\n", ans(0, 0));
  }
}



Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; i++)
  {
    cin >> a.at(i);
    a.at(i) += '#';
  }
  a.push_back("#");
  for (int i = 0; i < W; i++) a.at(H) += "#";
  
  vector<vector<int>> dp(H, vector<int>(W, 0));
  dp.at(0).at(0) = 1;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (a.at(i + 1).at(j) == '.')
      {
        dp.at(i + 1).at(j) += dp.at(i).at(j);
        dp.at(i + 1).at(j) %= MOD;
      }
      if (a.at(i).at(j + 1) == '.')
      {
        dp.at(i).at(j + 1) += dp.at(i).at(j);
        dp.at(i).at(j + 1) %= MOD;
      }
    }
  }
  
  int ans = dp.at(H - 1).at(W - 1);
  cout << ans << endl;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	string N; int K;
	cin >> N;
	scanf ("%d", &K);
	vector < vector < ll > > dp (K + 1, vector < ll > (2));
	const int n = N.size();
	dp[0][0] = 1LL;
	//cout << "n = " << n << endl;
	for (int i = 0; i < n; i++) {
		vector < vector < ll > > new_dp (K + 1, vector < ll > (2, 0));
		for (int current_digit = 0; current_digit < 10; current_digit++) {
			int end = N[i] - '0';
			for (bool already_smaller : {false, true}) {
				if (already_smaller) end = 9;
				for (int next_digit = 0; next_digit <= end; next_digit++) {
					bool smaller = already_smaller || (next_digit < end);
					int endK = (next_digit == 0) ? K : (K - 1);
					for (int k = 0; k <= endK; k++) {
						if (next_digit) {
							new_dp[k + 1][smaller] += dp[k][already_smaller];
						} else {
							new_dp[k][smaller] += dp[k][already_smaller];
						}
					}
				}
			}
		}
		for (int i = 0; i <= K; i++) {
			for (bool b : {true, false}) {
				new_dp[i][b] /= 10;
			}
		}
		dp = new_dp;
	}
	//for (vector < ll > d : dp) {
		//for (ll x : d) {
			//cout << x << " ";
		//}
		//cout << endl;
	//}
	//cout << endl;
	int cnt = 0;
	for (int c : N) {
		cnt += (c != '0');
	}
	cout << (dp[K][true] + (cnt == K)) << endl;
	return 0;
}


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

using namespace std;

#define int long long

vector <int> v;

main()
{
	int n;
	cin >> n;
	
	int s1 = 0;
	int s2 = 0;
	
	for(int i = 1; i <= n; i++)
	{
		int x, y;
		cin >> x >> y;
		
		s2 += y;
		
		v.push_back(x + y);
	}
	
	sort(v.begin(), v.end());
	
	for(int i = n - 1; i >= 0; i -= 2)
		s1 += v[i];
	
	cout << s1 - s2;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n+2);
  a[0]=0;
  a[n+1]=0;
  int nom=0;
  rep(i,n){
    cin>>a[i+1];
  }
  for(int i=1; i<=n+1; i++){
    nom+=abs(a[i]-a[i-1]);
  }
  for(int i=1; i<=n; i++){
    int now_ans=0;
    if((a[i-1]<a[i] && a[i]>a[i+1]) || (a[i-1]>a[i] && a[i]<a[i+1])){
      now_ans=nom-min(abs(a[i]-a[i-1]),abs(a[i]-a[i+1]))*2;
    }else now_ans=nom;
    cout<<now_ans<<endl;
  }
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include<vector>
#include<string.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        vector<int>vec;
        for(int i=0;i<n;i++){
            int a;
            cin>>a;
            vec.push_back(a);
        }
        sort(vec.begin(),vec.end());
        double d=0;
        for(int i=1;i<vec.size()-1;i++){
            d+=vec[i];
        }
        cout<<(int)(d/(vec.size()-2))<<endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz size()
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x) {
  return x * x;
}
ll mod = 1e9 + 7;

signed main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) { cin >> A.at(i); }
  ll a_max = 0;
  ll ans = 0;
  rep(i, N) {
    if (A.at(i) <= a_max) {
      ans += (a_max - A.at(i));
    } else {
      a_max = A.at(i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4824
// Contest: AtCoder Beginner Contest 153 (https://atcoder.jp/contests/abc153)
// Problem: F: Silver Fox vs Monster (https://atcoder.jp/contests/abc153/tasks/abc153_f)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cpp_lib_nonmember_container_access >= 201411
#   define sz(x) ((int)size(x))
#else
#   define sz(x) ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define all(a)         (a).begin(),(a).end()
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __has_cpp_attribute(maybe_unused) >= 201603
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18;
//endregion }}}

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

    int n, d, a; cin >> n >> d >> a;
    vector<pl> m(n);
    trav(mi, m) cin >> mi.first >> mi.second;
    sort(all(m));

    ll totdmg = 0;
    queue<pl> dmg;
    ll tb = 0;
    trav(mi, m) {
        ll x, h; tie(x, h) = mi;
        while (sz(dmg) && dmg.front().first < x)
            totdmg -= dmg.front().second, dmg.pop();
        h -= totdmg;
        if (h > 0) {
            ll b = (h + a - 1) / a;
            tb += b;
            totdmg += b * a;
            dmg.emplace(x + 2 * d, b * a);
        }
    }

    cout << tb << '\n';
    return 0;
}

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

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

using namespace std;

signed main()
{
    int N;
    cin >> N;
    int X[N];
    rep(i, N) cin >> X[i];
    int sum_pow;
    int sum_min = INT_MAX;
    rep(i, 101)
    {
        sum_pow = 0;
        rep(j, N)
        {
            sum_pow += (X[j] - i) * (X[j] - i);
        }
        if (sum_pow < sum_min)
        {
            sum_min = sum_pow;
        }
    }
    cout << sum_min << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
int main(){
int k,a,b,i;
cin>>k>>a>>b;
for(i=1;i<=a;i++){
    if(k*i>=a)break;
}
if(k*i>=a&&k*i<=b)cout<<"OK";
else cout<<"NG";

return 0;}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

void solve() {
    int n; cin >> n;
    VI a(n); for (auto &x : a) cin >> x;


    sort(a.begin(), a.end());
    LL sum = a.back();
    int k = n - 2;

    for (int i = n - 2; i >= 0; i--) {
        int m = min(k, 2);
        sum += m * a[i];
        k -= m;
    }

    cout << sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;cin >> t;while(t--)
    solve();
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  if(S=="SUN") cout << 7 << endl;
  if(S=="MON") cout << 6 << endl;
  if(S=="TUE") cout << 5 << endl;
  if(S=="WED") cout << 4 << endl;
  if(S=="THU") cout << 3 << endl;
  if(S=="FRI") cout << 2 << endl;
  if(S=="SAT") cout << 1 << endl;
  return 0;
}


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

int main(){
    long long n,a,b,to[1 << 8] = {0};
    char c;
    cin >> n;
    while(n--){
        cin >> a >> c >> b;
        to[c] += b;
        cout << ((to['('] == to[')'])? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#define int long long

using namespace std;

const int maxn = 1e6;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    int k;
    cin >> s >> k;
    int aa = 1;
    for (int i = 1; i < s.size(); i++)
        aa += (s[i] == s[0]);
    if (s.size() == aa) {
        cout << (k * s.size()) / 2;
        return 0;
    }
    int cnt = 0, cg = 1;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] == s[i - 1]) ++cg;
        if (s[i] != s[i - 1] || i == s.size() - 1) {
            cnt += cg / 2;
            cg = 1;
        }
    }
    if (k == 1 || s[0] != s[s.size() - 1]) {
        cout << cnt * k;
        return 0;
    }
    int g1 = 0, g2 = 0;
    for (int i = s.size() - 1; i >= 0 && s[i] == s[0]; i--)
        ++g1;
    for (int i = 0; i < s.size() && s[0] == s[i]; i++)
        ++g2;
    cnt -= g1 / 2; cnt -= g2 / 2;
    cnt *= k;
    cnt += g1 / 2;
    cnt += (k - 1) * ((g1 + g2) / 2);
    cnt += g2 / 2;
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int W, H;
	scanf("%d%d", &H, &W);
	char C[101][101];
	for (int i = 0; i < H; i++) {
		scanf("%s", &C[i]);
	}
	for (int i = 0; i < H; i++) {
		printf("%s\n", C[i]);
		printf("%s\n", C[i]);
	}





#ifdef DEBUGF
	getch();
#endif
	return 0;
}

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

vector<int> e[50];
vector<int> p[50];
long long dp[52][1 << 20];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<pair<int, int>, int> edge;
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
        edge[{a, b}] = i;
        edge[{b, a}] = i;
    }
    int m; cin >> m;
    for (int i = 0; i < m; i++) {
        vector<int> v;
        auto path = [&](auto f, int curr, int prev, int end) {
            v.emplace_back(curr);
            if (v.back() == end) return;
            for (auto &to: e[curr]) {
                if (to == prev) continue;
                f(f, to, curr, end);
                if (v.back() == end) return;
            }
            v.pop_back();
        };
        int a, b; cin >> a >> b; a--, b--;
        path(path, a, -1, b);
        for (int j = 1; j < v.size(); j++) {
            p[edge[{v[j-1], v[j]}]].emplace_back(i);
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i < n-1; i++) {
        int bit = 0;
        for (auto &x: p[i]) bit |= 1 << x;
        for (int j = 0; j < (1 << m); j++) {
            dp[i+1][j] += dp[i][j];
            dp[i+1][j | bit] += dp[i][j];
        }
    }
    cout << dp[n-1][(1 << m) - 1] << "\n";
    return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  ll h;
  cin >> h;

  int k = log(h) / log(2);
  ll ans = pow(2, k + 1) - 1;

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


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

int main() {
	// your code goes here
	int n,k;
	cin >> n >> k;
	int c = 0;
	for(int i = 0 ; i < n ; i++)
	{
		int t;
		cin >> t;
		if(t >= k)c++;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i;
	long long m,n,a,b,temp;
	scanf("%lld%lld",&m,&n);
	if(m<n)
	{
		temp=m;
		m=n;
		n=temp;
	}
	a=m;
	b=n;
	while(m%n!=0)
	{
		temp=m;
		m=n;
		n=temp%n;
	}
	printf("%lld",(a*b)/n);
}

Measured memory_bytes: 128
#include <iostream>
 
using namespace std;
 
int main(){
  while(1){
    int n,p = 0;
    int ans[400000];
    int hoge[400000];
      
    cin >> n;
    if(n == 1)break;
  
    for(int i = 1 ; i <= n ; i++ )hoge[i] = 1;
    
    for(int i = 2 ; i <= n ; i++){
 
      if( n % i == 0)if(i % 7 == 6 || i % 7 == 1){
 
        for(int j = i*2 ; j <= n ; j+=i)hoge[j] = 0;
 
      if(hoge[i])ans[p++] = i;
    }
    }
    cout << n << ':';
    for(int i = 0 ; i < p ; i++ )cout << " "<< ans[i]; 
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2340
#include<cstdio>

int binarySearch(int A[], int n, int key)
{
    int left = 0, right = n - 1;
    while(left <= right)
    {
        int mid = (left + right)/2;
        if(A[mid] == key)
            return mid;
        else if( key < A[mid])
            right = mid - 1;
        else
            left = mid + 1;
    }
    return -1;
}

int main()
{
    int i, n, A[100001], q, key, sum = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &A[i]);

    scanf("%d", &q);
    for(int i = 0; i < q; i++)
    {
        scanf("%d", &key);
        if(binarySearch(A, n, key) != -1) sum++;
    }
    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 2952
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(ll, N);
	in_v(ll, a, N);
	sort_v(a);
	ll ap = 0, bp = 0;
	loop(i, N)
		if (i & 1)
			bp += a[N - 1 - i];
		else
			ap += a[N - 1 - i];
	out(ap - bp);
	return 0;
}


Measured memory_bytes: 256
<?php

while(true){
    $cards = trim(fgets(STDIN));
    if($cards == "-"){
        break;
    }
    $m = intval(trim(fgets(STDIN)));
    for($i=0; $i<$m; $i++){
        $h = intval(trim(fgets(STDIN)));
        $cards = substr($cards, $h) . substr($cards, 0, $h);
    }
    print $cards . "\n";
}



?>


Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
      cin >> N;
  
    vector<int> A(N);

    for (int i=0; i<N; i++){
        cin >> A.at(i);
    }
    int flag=1; //approved
  
    for (int i=0; i<N; i++){
       if (A.at(i) % 2==0 && A.at(i) % 3 != 0 && A.at(i) % 5 !=0){
           flag=0;
       }
    }
    
    if (flag==0){
        cout << "DENIED" << endl;
    } else {
        cout << "APPROVED" << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>

#define INT unsigned long long int
#define FORN(n) for(int i=0;i<n;i++)
#define PINT(d) printf("%d\n", d);
#define PDOUBLE(lf) printf("%lf\n", lf);
#define PSTR(s) printf("%s\n", s);
#define N 1000000007
#define MAX_N 500000

using namespace std;

int m, n, ans = 1;

main(){
    scanf("%d %d", &n, &m);
    
    int box[n];
    bool red[n] = {};
    FORN(n){
        box[i] = 1;
        red[i] = false;
    }
    red[0] = true;
    
    int x, y;
    FORN(m){
        scanf("%d %d", &x, &y);
        x--;
        y--;
        
        box[x]--;
        box[y]++;
        if(red[x]){
            if(box[x] == 0){
                red[x] = false;
                ans--;
            }
            if(red[y] == false){
                red[y] = true;
                ans++;
            }
        }
    }
    
    printf("%d", ans);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
//template<class T> T extgcd(T a, T b, T& x, T& y) { for (T u = y = 1, v = x = 0; a;) { T q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); swap(b -= q * a, a); } return b; }
//template<class T> T mod_inv(T a, T m) { T x, y; extgcd(a, m, x, y); return (m + x % m) % m; }
//ll mod_pow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }

const ll mn=404;
ll f[mn][mn];
ll a[mn],b[mn],s[mn][mn];
ll p[mn][mn];
inline ll mul(ll x,ll y) {return (x*y)%MOD;}
int main() {
	ios_base::sync_with_stdio(false);
	ll n,c;
	scanf("%lld %lld",&n,&c);
	for (ll x=0;x<mn;x++) {
		ll z=1;
		for (ll y=0;y<mn;y++) {
			p[x][y]=z;
			z=mul(z,x);
		}
	}
	for (ll i=0;i<n;i++) scanf("%lld",&a[i]);
	for (ll i=0;i<n;i++) scanf("%lld",&b[i]);
	for (ll x=0;x<n;x++) {
		for (ll y=0;y<=c;y++) {
			ll sum=0;
			for (ll d=a[x];d<=b[x];d++) {
				sum+=p[d][y];
				sum%=MOD;
			}
			s[x][y]=sum;
		}
	}
	for (ll x=0;x<mn;x++) for (ll y=0;y<mn;y++) {
		f[x][y]=0;
	}
	f[0][0]=1;
	for (ll x=0;x<n;x++) {
		for (ll y=0;y<=c;y++) {
			for (ll z=y;z<=c;z++) {
				ll diff=z-y;
				f[x+1][z]+=mul(f[x][y],s[x][diff]);
				f[x+1][z]%=MOD;
			}
		}
	}
	printf("%lld\n",f[n][c]);
}

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

int main(){
	int a,b,k;
	cin >> a >> b >> k;

	int cnt = 0;
	int i = max(a,b);
	while(cnt!=k){
		if(a%i==0 && b%i==0) cnt++;
		i--;
	}

	cout << i+1 << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
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()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> ruiseki(n + 1);
    for (int i = 0; i < n; i++)
    {
        ruiseki[i + 1] = ruiseki[i] + a[i];
    }
    ll min = INFLL;
    for (int i = 1; i < n; i++)
    {
        chmin(min, abs((ruiseki[n] - ruiseki[i]) - ruiseki[i]));
    }
    cout << min << endl;
}


Measured memory_bytes: 3328
from collections import namedtuple, deque
N = int(input())

connection = [[] for _ in range(N)]
branch = namedtuple('branch',['id', 'dist'])
for _ in range(N-1):
    a, b, c = map(int, input().split())
    connection[a-1].append(branch(b-1, c))
    connection[b-1].append(branch(a-1, c))

dist = [0] * N #dist from root(K)
Q, K = map(int, input().split())
#bfs
reserved = deque([K-1])
seen = {K-1}
while len(reserved) > 0:
    current = reserved.popleft()
    for next in connection[current]:
        if next.id in seen:
            continue
        seen.add(next.id)
        reserved.append(next.id)
        dist[next.id] = dist[current] + next.dist

#deal with query
Query = [map(int, input().split()) for _ in range(Q)]
for x,y in Query:
    print(dist[x-1] + dist[y-1])




Measured memory_bytes: 95308
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
array<int,26> a;
int main(){
    string s;
    cin>>s;
    rep(i,0,s.size()){
        a[s[i]-'a']^=1;
    }
    cout<<(accumulate(a.begin(),a.end(),0)?"No":"Yes");
}


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

struct Data{int player,score;};
bool operator<(Data a,Data b){return a.score!=b.score?a.score>b.score:a.player<b.player;}

int main()
{
  int n,player,score[21];
  int i;
  int frame,sum;
  vector<Data> result;
  vector<Data>::iterator it;
  string s;
  while(getline(cin,s)){
    stringstream ss(s);
    ss>>n;
    if(!n)break;

    result.clear();
    while(n-->0){
      getline(cin,s);
      stringstream ss(s);
      ss>>player;
      for(i=0;i<21;i++)ss>>score[i];
      i=sum=0;
      frame=1;
      while(frame<=9){
	if(score[i]+score[i+1]<10){
	  sum+=score[i]+score[i+1];
	  i+=2;
	}else if(score[i]==10){
	  sum+=score[i]+score[i+1]+score[i+2];
	  i++;
	}else if(score[i]+score[i+1]==10){
	  sum+=score[i]+score[i+1]+score[i+2];
	  i+=2;
	}
	frame++;
      }
      if(score[i]+score[i+1]<10)sum+=score[i]+score[i+1];
      else if(score[i]==10)sum+=score[i]+score[i+1]+score[i+2];
      else if(score[i]+score[i+1]==10)sum+=score[i]+score[i+1]+score[i+2];
      Data d={player,sum};
      result.push_back(d);
    }

    sort(result.begin(),result.end());
    for(it=result.begin();it!=result.end();it++)
      cout<<(*it).player<<" "<<(*it).score<<endl;
  }
}

Measured memory_bytes: 0
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

int main(void) {
    int n;
    while (cin >> n) {
        vector<int> ans;
        while (n > 0) {
            int p = 512;
            while (p > n) p /= 2;
            n -= p;
            ans.push_back(p);
        }
        cout << ans[ans.size()-1];
        for (int i = ans.size()-2; i >= 0 ; i--) {
            cout << " " << ans[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;
    std::vector<char> v;
    for (auto c : s) {
        if (v.empty() || v.back() != c) v.push_back(c);
    }

    std::cout << v.size() << std::endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        int i;
        for (i = n - 1; i >= 0; i -= 2) {
            System.out.print(a[i] + " ");
        }
        if (i == -2) i = 0;
        for (i = i + 1; i < n - 1; i += 2) {
            System.out.print(a[i] + " ");
        }
    }
}


Measured memory_bytes: 94052
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=1000000000;
ll INF=1e18;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}

void solve()
{
     ll x;
     cin>>x;
     cout<<1-x;
}

int main()
{
    ios;
    ll t;
     // cin>>t;
     t=1;
     while(t--)
     {
          solve();
     }
}

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

void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

int main() {
  vector<int> L;
  int N, num = 0;
  
  cin >> N;
  if(N < 3){
    cout << 0 << endl;
    return 0;
  }
  
  L.resize(N);
  for(int i = 0; i < N; i++)cin >> L[i];
  
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      for(int k = j+1; k < N; k++){
        if((L[i] == L[j]) || (L[i] == L[k]) || (L[j] == L[k]))continue;
        if(L[i] < L[j] + L[k] &&
           L[j] < L[k] + L[i] && 
           L[k] < L[i] + L[j])num++;
        }
    }
  }
  
  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
  	c*=2;
    int mn=mod;
    rep(i,max(x,y)+1){
        chmin(mn,i*c+max(0,x-i)*a+max(0,y-i)*b);
    }
    cout << mn;



    
}

/*
*/



Measured memory_bytes: 256
N =  int(input())
a = list(map(int, input().split()))
brk = 0
n = 0
src = 1
reigai = -1
for i in a:
    if n == N:
        break
    if i == src:
        src += 1
    else:
        brk += 1
    n += 1
if src == 1:
    print(reigai)
else:
    print(brk)

Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>A(3);
  cin>>A[0]>>A[1]>>A[2];
  sort(A.begin(),A.end());
  int B=A[1]-A[0];
  int C=A[2]-A[1];
  if(B%2==0){
    cout<<C+B/2<<endl;
  }
  else{
    cout<<C+2+B/2<<endl;
  }
}

Measured memory_bytes: 256
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
t = input()
for i in range(len(s)):
    if s[i] != t[i]:
        ans += 1
print(ans)

Measured memory_bytes: 74132
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  string s;
  cin >> s;
  vector<vector<int>> res;
  vector<int> tmp;
  for (int i = 0; i < (int) s.size(); i++) {
    bool flag = false;
    if (s[i] == 'A') {
      tmp.push_back(0);
      flag = true;
    } else {
      if (i + 1 < (int) s.size()) {
        if (s[i] == 'B' && s[i + 1] == 'C') {
          i++;
          tmp.push_back(1);
          flag = true;
        }
      }
    }
    if (!flag) {
      res.push_back(tmp);
      tmp.clear();
    }
  }
  res.push_back(tmp);
  long long ans = 0;
  for (auto v : res) {
    int cnt = 0;
    for (int i : v) {
      //cerr << i;
      if (i == 0) cnt++;
      else ans += cnt;
    }
    //cerr << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8772
from fractions import gcd

def solve(A,B,C,D):
  if D<B:
    return "No"
  if A<B:
    return "No"
  if C>=B-1:
    return "Yes"
  g = gcd(B,D)
  if A-(A-C-1)/g*g<B:
    return "No"
  return "Yes"

T = input()
for _ in range(T):
  A,B,C,D = map(int, raw_input().split())
  print solve(A,B,C,D)


Measured memory_bytes: 4392
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int N;

//解法
void solve() {

	if (N < 1000) {
		cout << "ABC";
	}
	else {
		cout << "ABD";
	}

	return;
}

int main() {
	//入力
	cin >> N;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(LL i=(a);i<(LL)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define FF first
#define SS second
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr> PQ;
const ut INF=1LL<<60;
const LL p=3+1e6;
const int SIZE=200005;
LL parent[SIZE];
VI child[SIZE];
LL N,K;
int disty[SIZE];
int counts[SIZE];

int main(){
	cin >> N >> K;
	FOR(i,1,N+1){
		cin >> parent[i];
		if(i!=1)
			child[parent[i]].PB(i);
	}
	
	queue<int> qu;
	FOR(i,1,N+1){
		if(child[i].empty())
			qu.push(i);
	}
	int ans=0;
	while(!qu.empty()){
		int now=qu.front();
		qu.pop();
		//cout << now <<" " << disty[now] << endl;
		if(now==1) continue;
		if(disty[now]==K-1 && parent[now]!=1) {
			ans++;
			disty[now]=-1;
		}
		
		counts[parent[now]]++;
		disty[parent[now]]=max(disty[parent[now]],disty[now]+1);
		if(child[parent[now]].size()-counts[parent[now]]==0){
			qu.push(parent[now]);
		}
	}
	if(parent[1]!=1) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9600
N = int(input())
S = input()
l = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

ss = ""
for i in range(len(S)):
    s = S[i]
    num = l.index(s)
    ss += l[(num + N) % len(l)]

print(str.upper(ss))

Measured memory_bytes: 3188
#include<iostream>  
#include<vector>
using namespace std;  
#define  max(x,y)   (x)>(y)?(x):(y)  
int main() 
{  
    int N,W;  
    cin>>N; 
    cin>>W;  
	vector<int> f(20, 0);
	vector<int> value(10, 0);
	vector<int> weight(10, 0);
    for (int i=1;i<=N; i++)  
    {  		
		if (i >= 10)
		{
			value.push_back(0);
			weight.push_back(0);
		}
        cin>>value[i]>>weight[i];
    }  
	if (W >= 20)
		for (int j=20; j<=W; j++)
			f.push_back(0);
    for (int i=1; i<=N; i++)  
        for (int j=W; j>=weight[i]; j--)  
                f[j] = max(f[j],f[j-weight[i]] + value[i]);         
    cout<<f[W]<<endl;
    return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int f = 0;
    for(int i=0;i<s.size();i++)
        if(s[i]!=t[i])
            f=1;
    if(f==0)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <set>

#define PI 3.1415926535897

typedef long long ll;

using namespace std;



int main() {
    ll x;
    cin >> x;

    ll money = 100;
    ll year = 0;

    while (true) {
        money *= 1.01;

        year++;
        if (money >= x) {
            break;
        }
    }

    cout << year;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

map<string, int> m;

int32_t main()
{
	IO_OP;
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		m[s]++;
	}
	int ans = 0;
	for(auto a:m)
		ans += a.S*(a.S-1)/2;
	cout << ans << endl;
}



Measured memory_bytes: 11264
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)

int32_t main()
{


   string s;
   cin >> s;

   int ans = 10000000000;

   for(int i = 0;i < s.length() -2; i++)
   {
    int a = (s[i]-'0')*100 + (s[i+1] - '0') * 10 + ( s[i+2] -'0');
    ans = min(ans , abs(a-753));

   }

   cout << ans;

   return 0;
}

Measured memory_bytes: 256