akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
n, a, b, c = map(int, input().split())

value_dict = {'A': a, 'B': b, 'C': c}
result_list = []
input_list = []
flag = True

for i in range(n):
    input_list.append(input())

for next, input in enumerate(input_list, 1):
    if value_dict[input[0]] < value_dict[input[1]]:
        value_dict[input[0]] += 1
        value_dict[input[1]] -= 1
        result_list.append(input[0])
    elif value_dict[input[1]] < value_dict[input[0]]:
        value_dict[input[1]] += 1
        value_dict[input[0]] -= 1
        result_list.append(input[1])
    else:
        if value_dict[input[0]] == 0:
            flag = False
            break
        elif next == len(input_list):
            result_list.append(input[0])
        elif input[0] in input_list[next]:
            value_dict[input[0]] += 1
            value_dict[input[1]] -= 1
            result_list.append(input[0])
        else:
            value_dict[input[1]] += 1
            value_dict[input[0]] -= 1
            result_list.append(input[1])

if flag:
    print('Yes')
    for result in result_list:
        print(result)

else:
    print('No')


Measured memory_bytes: 16960
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize
    }
    let mut num = n;
    let mut ans = Vec::new();
    loop {
        if num <= 0 {
            break;
        }
        num -= 1;
        let m = num % 26;
        ans.push(m);
        num = num / 26;
    }
    ans.reverse();
    let mut moji = String::new();
    for a in ans {
        moji.push((b'a' + a as u8) as char);
    }
    println!("{}",  moji);
}


Measured memory_bytes: 2136
(n,m),*s,p=[list(map(int,t.split()))for t in open(0)]
a=0
r=range
for i in r(1<<n):
 c=[0]*m
 for j in r(n):
  for k in r(m):c[k]+=i>>j&(j+1in s[k][1:])
 a+=all(j==i%2for i,j in zip(c,p))
print(a)

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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }


int ans = MOD;

void dfs(int f, int e){

}

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    REP(i, N) cin >> L[i];
    sort(all(L));
    ll ans = 0;
    REP(B, N){
        REP(A, B){
            int K = lower_bound(L.begin(), L.end(), L[A] + L[B]) - L.begin();
            ans += max(K - (B + 1), 0);
        }
    }
    print(ans);
}



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

int main() {
	string x;
	int n,y=0;
	cin>>x>>n;
	for(int i=2;i<(n+2);i++){
		string s;
		cin>>s;
		s=s+s;
		if(s.find(x)<=10){
			y++;
		}
	}
	cout<<y<<endl;
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
using namespace std;

int main(){
    int S; cin>>S;
    int h=S/3600;
    int m=(S%3600)/60;
    int s=S-h*3600-m*60;

    cout<<h<<":"<<m<<":"<<s<<endl;
}



Measured memory_bytes: 3080
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<malloc.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int main(){
    int N;

    scanf("%d",&N);
    printf("%d\n", N*800 - (N/15)*200);
    
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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 main(){
  ll X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  
  vector<ll> A(X),B(Y),C(Z),ANS;
  REP(i,X) cin>>A[i];
  REP(i,Y) cin>>B[i];
  REP(i,Z) cin>>C[i];
  SORT(A);
  SORT(B);
  SORT(C);
  REVERSE(A);
  REVERSE(B);
  REVERSE(C);
  
  REP(i,X){
    REP(j,Y){
      REP(k,Z){
        if((i+1)*(j+1)*(k+1)<=K) ANS.PB(A[i]+B[j]+C[k]);
      }
    }
  }
  
  SORT(ANS);
  REVERSE(ANS);
  
  REP(i,K){
    cout<<ANS[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int r,d,x;cin>>r>>d>>x;
  for(int i=0;i<10;i++){
    x=r*x-d;
    cout<<x<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b && a!=c) cout <<"Yes";
    else if (a==c && a!=b)cout <<"Yes";
    else if (b==c && a!=b)cout <<"Yes";
    else cout <<"No";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a, int b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}
int main()
{
    int n;
    cin >> n;
    if(n == 3)
    {
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }
    set<int> ans;
    ans.insert(2);
    ans.insert(3);
    ans.insert(4);
    ans.insert(9);

    if(n > 4)
    {
        int size = n - 4;
        int x = size / 8;
        int k = 2;
        while(x--)
        {
            ans.insert(6*k);
            ans.insert(6*k+2);
            ans.insert(6*k+3);
            ans.insert(6*k+4);
            ans.insert(6*k+6);
            ans.insert(6*k+8);
            ans.insert(6*k+9);
            ans.insert(6*k+10);
            k += 2;
        }
        int y = size % 8;
        if(y == 1) ans.insert(6);
        else if(y == 2)
        {
            ans.insert(8);
            ans.insert(10);
        }
        else if(y == 3)
        {
            ans.insert(6);
            ans.insert(8);
            ans.insert(10);
        }
        else if(y == 4)
        {
            ans.insert(6*k);
            ans.insert(6);
            ans.insert(8);
            ans.insert(10);
        }
        else if(y == 5)
        {
            ans.insert(6);
            ans.insert(8);
            ans.insert(10);
            ans.insert(6*k);
            ans.insert(6*k+6);
        }
        else if(y == 6)
        {
            ans.insert(6);
            ans.insert(8);
            ans.insert(10);
            ans.insert(6*k);
            ans.insert(6*k+2);
            ans.insert(6*k+4);
        }
        else if(y == 7)
        {
            ans.insert(6);
            ans.insert(8);
            ans.insert(10);
            ans.insert(6*k);
            ans.insert(6*k+3);
            ans.insert(6*k+6);
            ans.insert(6*k+9);
        }
    }
    for(auto itr = ans.begin(); itr != ans.end(); itr++)
    {
        cout << *itr << " ";
    }
    return 0;
}



Measured memory_bytes: 1280
/// meowa 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;
  
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

void ma1n() {
    int s;
    cin >> s;
    vector<ll> dp(s+1);
    dp[0] = 1;
    for (int i = 3; i <= s; ++i) {
        for (int x = 3; x <= i; ++x) {
            dp[i] += dp[i-x];
            if (dp[i] >= MOD) {
                dp[i] -= MOD;
            }
        }
    }
    cout << dp[s];
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}

Measured memory_bytes: 3652
function Main(input){
  input = input.split(" ");
  input[0]=parseInt(input[0])
  input[1]=parseInt(input[1])

  if(input[0]%2==0 && input[1]%2==1){    
    console.log("IMPOSSIBLE")
    return 
  }
  if(input[0]%2==1 && input[1]%2==0){    
    console.log("IMPOSSIBLE")
    return 
  }
  if(input[0]>input[1]){
    console.log(input[1]+(input[0]-input[1])/2)
    return 
  }
  if(input[1]>input[0]){
    console.log(input[0]+(input[1]-input[0])/2)
    return 
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <stdio.h>

/* 26^1 + 26^2 + 26^3 + 26^4 + 26^5 */
int order_sum[26+676+17576+456976+11881376];

const int id_offset[5]={0,26,26+676,26+676+17576,26+676+17576+456976};

int alpha2id(const char* alpha) {
	int i;
	int id=0;
	for(i=0;alpha[i];i++) {
		id=id*26+(alpha[i]-'A');
	}
	return id+id_offset[i-1];
}

void id2alpha(char* alpha,int id) {
	int i;
	for(i=1;id>=id_offset[i] && i<5;i++);
	alpha[i]=0;id-=id_offset[--i];
	for(;i>=0;i--) {
		alpha[i]=id%26+'A';id/=26;
	}
}

int main(void) {
	int n,i;
	char name[8];
	int num;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%s%d",name,&num);
		order_sum[alpha2id(name)]+=num;
	}
	n=alpha2id("ZZZZZ")+1;
	for(i=0;i<n;i++) {
		if(order_sum[i]>0) {
			id2alpha(name,i);
			printf("%s %d\n",name,order_sum[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 45736
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0,k,x,r;
    cin >> n >> x >> r;
    r=std::min(r,x-1) ;
    ans = (n*r)/x ;
    cout << ans ;
    
    return 0;
}

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

const int MAXN = 200005;

int a[MAXN], n;
int nxt[MAXN], pre[MAXN];
int stk[MAXN], stk_top = 0;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), pre[i] = 0, nxt[i] = n+1;
	for (int i = 1; i <= n; i++) {
		while (stk_top && a[stk[stk_top]] > a[i]) nxt[stk[stk_top--]] = i;
		stk[++stk_top] = i;
	}
	stk_top = 0;
	for (int i = n; i >= 1; i--) {
		while (stk_top && a[stk[stk_top]] > a[i]) pre[stk[stk_top--]] = i;
		stk[++stk_top] = i;
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++)
		ans += (long long)a[i]*(i-pre[i])*(nxt[i]-i);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N, K;
int memo[101][3][3];
int p_fixed[100];
int mod = 10000;

int pasta(int n, int y2, int y1) {
	if (memo[n][y2][y1] > -1) return memo[n][y2][y1];

	if (p_fixed[n-1] > -1 && p_fixed[n-1] != y1) return memo[n][y2][y1] = 0;
	if (p_fixed[n-2] > -1 && p_fixed[n-2] != y2) return memo[n][y2][y1] = 0;
	if (n == N) return memo[n][y2][y1] = 1;
	
	memo[n][y2][y1] = 0;
	REP(i, 3) if (! (y2 == y1 && y1 == i)) memo[n][y2][y1] += pasta(n + 1, y1, i);

	return memo[n][y2][y1] %= mod;
}

int main() {
	fill(memo[0][0], memo[101][0], -1);
	fill(p_fixed, p_fixed + 100, -1);

	cin >> N >> K;
	REP(i, K) {
		int a, b;
		scanf("%d %d", &a, &b);
		p_fixed[a - 1] = b - 1;
	}

	int ans = 0;
	REP(i, 3) REP(j, 3) ans += pasta(2, i, j);

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

Measured memory_bytes: 1252
#include <stdio.h>

typedef struct{
  int num;
  int k;
  int v[1000];
}DATA;

int main() {

  int n,i,j,G[1000][1000];
  DATA data[1000];
  
  scanf("%d",&n);

  for(i = 1; i <= n; i++) {
    scanf("%d",&data[i].num);
    scanf("%d",&data[i].k);
    for(j = 1; j <= data[i].k; j++) {
      scanf("%d",&data[i].v[j]);
    }
  }

  for(i = 1; i <= n; i++) {
    for(j = 1; j <= n; j++) {
      	G[i][j] = 0;   
    }
  }
  
  for(i = 1; i <= n; i++) {
    for(j = 1; j <= n; j++) {
      	G[i][data[i].v[j]] = 1;   
    }
  }

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



Measured memory_bytes: 2472
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    int c=max(a,b);
    int d=min(a,b);
    if((c-d)%2!=0 || n==2)
    {
        cout<<"Borys"<<endl;
    }
    else
    {
        cout<<"Alice"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3712
import itertools

N = int(input())
S = [input() for _ in range(N)]

top = [0 for i in range(5)]
ans = 0

for i in range(N):
    if S[i][0] == 'M':
       top[0] += 1
    elif S[i][0] == 'A':
        top[1] += 1
    elif S[i][0] == 'R':
       top[2] += 1
    elif S[i][0] == 'C':
        top[3] += 1
    elif S[i][0] == 'H':
        top[4] += 1

comb = [0 for i in range(10)]
comb = list(itertools.combinations(top,3))


for i in range(len(comb)):
    mul = 1
    for j in comb[i]:
        mul *= j
    ans += mul

print(ans)

Measured memory_bytes: 9772
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
vector<ii> adj;
const long long mod=1000000007;
int fact[200500],invfact[200500],n,h,w,dp[200500],x,y;
int C(int k,int n)
{
	int ans=(invfact[k]%mod*invfact[n-k]%mod)%mod;
	return (ans*fact[n])%mod;
}
int binpow(int a,int n)
{
	if(n==1) return a;
	int tmp=binpow(a,n/2);
	if(n%2==0)
	{
		return ((tmp%mod)*(tmp%mod))%mod;
	}
	else
	{
		int ans=((tmp%mod)*(a%mod))%mod;
		return (ans*(tmp%mod))%mod;
	}
}
signed main()
{
	cin>>h>>w>>n;
	fact[0]=1;
	invfact[0]=1;
	for(int i=1;i<=200000;i++) fact[i]=fact[i-1]%mod*i%mod,invfact[i]=binpow(fact[i],mod-2)%mod;
	for(int i=0;i<n;i++) 
	{
		cin>>x>>y;
		adj.push_back(ii(x,y));
	}
	sort(adj.begin(),adj.end());
	adj.push_back(ii(h,w));
	for(int i=0;i<=n;i++)
	{
		dp[i]=C(adj[i].first-1,adj[i].first+adj[i].second-2)%mod;
		for(int j=0;j<i;j++)
		{
			if(adj[j].first<=adj[i].first&&adj[j].second<=adj[i].second)
			dp[i]=(dp[i]-dp[j]%mod*C(adj[i].first-adj[j].first,adj[i].first-adj[j].first+adj[i].second-adj[j].second)%mod+mod)%mod;
		}
	}
	cout<<dp[n];
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    if (N == M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        string s, t;
        cin >> s >> t;
        int ret = 0;
        for (size_t i = 0; i < s.length(); i++)
        {
            ret += s[i] != t[i];
        }

        cout << ret << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
ll n,A,B,C,D;
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > > q;
map<ll,ll> st;
void solve(){
	cin>>n>>A>>B>>C>>D;
	while(!q.empty()) q.pop();
	q.push(make_pair(0,n));
	ll ans=1e18;
	st.clear();st[n]=0;
	while(1){
		ll u=q.top().se,val=q.top().fi;q.pop();
		//cout<<u<<" "<<val<<endl;
		if((double)u*D+val<=4e18) ans=min(ans,u*D+val);
		if(val>ans) return (void)(cout<<ans<<endl);
		for(ll i=max(u-5,0ll);i<=u+5;++i){
			ll tmp=abs(i-u)*D;
			if(i%2==0 && (!st[i/2] || tmp+val+A<st[i/2])) st[i/2]=tmp+val+A,q.push(make_pair(tmp+val+A,i/2));
			if(i%3==0 && (!st[i/3] || tmp+val+B<st[i/3])) st[i/3]=tmp+val+B,q.push(make_pair(tmp+val+B,i/3));
			if(i%5==0 && (!st[i/5] || tmp+val+C<st[i/5])) st[i/5]=tmp+val+C,q.push(make_pair(tmp+val+C,i/5)); 
		}
	}
}
int main(){
	int T;cin>>T;
	while(T--) solve();
	return 0;
}

Measured memory_bytes: 6472
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"Yes"<<endl
#define cno cout<<"No"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int a,b,c;
    cin >> a >> b >> c;
    int cnt = 0;
    for(int i = a; i <= b; i++){
        if(c%i==0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstdlib>

#define NIL -1

struct Node{
    int parent, left, right;
};

void treeWalk(Node* nodes, int label, int mode);

int main(int argc, char** argv) {
    int len, root;
    Node* nodes;

    scanf("%d", &len);
    nodes = (Node *) calloc(sizeof(Node), len + 1);

    for (int i = 0; i < len; i++) {
        nodes[i].parent = nodes[i].left = nodes[i].right = NIL;
    }

    for (int i = 0; i < len; i++) {
        int label, child1, child2;
        scanf("%d %d %d", &label, &child1, &child2);

        nodes[label].left = child1;
        nodes[label].right = child2;
        nodes[child1].parent = label;
        nodes[child2].parent = label;
    }

    for (int i = 0; i < len; i++) {
        if (nodes[i].parent == NIL) {
            root = i;
            break;
        }
    }

    printf("Preorder\n");
    treeWalk(nodes, root, 0);
    printf("\nInorder\n");
    treeWalk(nodes, root, 1);
    printf("\nPostorder\n");
    treeWalk(nodes, root, 2);
    printf("\n");

    return 0;
}

void treeWalk(Node* nodes, int label, int mode) {
    if (label == NIL) {
        return;
    }

    if (mode == 0) {
        // preorder
        printf(" %d", label);
    }

    treeWalk(nodes, nodes[label].left, mode);

    if (mode == 1) {
        // pinorder
        printf(" %d", label);
    }

    treeWalk(nodes, nodes[label].right, mode);

    if (mode == 2) {
        // postorder
        printf(" %d", label);
    }
}


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

int n, m, o;
pair<int,int> p[100];
bool f;

int main() {
	while (scanf("%d %d",&n,&m) && (n||m)) {
		vector<int> r[1010];
		f = true;
		rep(i,m) p[i] = make_pair(0, i);
		rep(i,n) {
			rep(j,m) {
				scanf("%d",&o);
				p[j].first += o;
			}
		}
		rep(i,m) r[p[i].first].push_back(p[i].second);
		for (int i = n; i >= 0; --i) {
			sort(r[i].begin(), r[i].end());
			rep(j,r[i].size()) {
				if (!f) printf(" ");
				printf("%d",r[i][j]+1);
				f = false;
			}
		}
		printf("\n");
	}
}


Measured memory_bytes: 3208
import java.util.*;

public class Main {

    static String s;
    static int K;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = sc.next();
        K = sc.nextInt();

        System.out.println( solve() );

    }

    static String solve() {
        List<String> substrings = new ArrayList<>();

        for (int i = 0; i < s.length(); i++) {
            int count = 0;
            for (int j = i+1; j <= s.length(); j++) {
                String sub = s.substring(i, j);
                if (!substrings.contains(sub)) {
                    substrings.add(sub);
                }
                count++;
                if (count == K) {
                    break;
                }
            }
        }

        Collections.sort(substrings);
        return substrings.get(K - 1);
    }
}

Measured memory_bytes: 25556
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int>> lis;
	for (int i = 0; i < M; ++i)
		lis.push_back(vector<int>{i});
	for (int i = 1; i < N; ++i) {
		vector<vector<int>> nx;
		for (auto l : lis) {
			int lst = l[l.size() - 1];
			for (int j = lst; j < M; ++j) {
				vector<int> tmp = l;
				tmp.push_back(j);
				nx.push_back(tmp);
			}
		}
		lis = nx;
	}
	/*
	for (int i = 0; i < 100; i += 1) {
		for (auto j : lis[i])
			cout << j << " ";
		cout << endl;
	}
	*/
	using q = tuple<int, int, int, int>;
	vector<q> qs(Q);

	for (int i = 0; i < Q; ++i) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		--a, --b;
		qs[i] = make_tuple(a, b, c, d);
	}

	int res = 0;
	for (auto l : lis) {
		int tmp = 0;
		for (int i = 0; i < Q; ++i) {
			int a = get<0>(qs[i]);
			int b = get<1>(qs[i]);
			int c = get<2>(qs[i]);
			int d = get<3>(qs[i]);
			if (l[b] - l[a] == c)
				tmp += d;
		}
		res = max(res, tmp);
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 19696
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;

int main(){
  int a,b;
  cin >> a >> b;
  cout << a + b/2 << endl;
}

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

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

  vector<int> A(M);
  for (int i = 0; i < M; i++) cin >> A.at(i);

  int ans = N;
  for (int i = 0; i < M; i++) {
    ans -= A.at(i);
  }

  if(ans >= 0) cout << ans << endl;
  else cout << -1 << endl;
}

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

int kiriage(int x) {
    if (x % 10 == 0) {
        return x;
    } else {
        return (x / 10 + 1) * 10;
    }
}

int main() {
    // 入力
    int times[5];
    for (int i = 0; i < 5; i++) {
        cin >> times[i];
    }
    // 解答
    int ans = 0;
    int min_rest = 10;
    for (int i = 0; i < 5; i++) {
        ans += kiriage(times[i]);
        if (times[i] % 10 != 0) {
            int a = times[i] % 10;
            if (a < min_rest) {
                min_rest = a;
            }
        }
    }
    cout << ans - (10 - min_rest) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const double INF = 1e6;
int n, m;
int s, g;
int kyori[30][30], sokudo[30][30];
double dist[30][30][31];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n >> m, n) {
    fill_n((int*)kyori, 30 * 30, -1);
    fill_n((int*)sokudo, 30 * 30, -1);    
    cin >> s >> g;
    s--, g--;
    for (int i = 0; i < m; i++) {
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      x--, y--;
      kyori[x][y] = kyori[y][x] = d;
      sokudo[x][y] = sokudo[y][x] = c;
    }

    fill_n((double*)dist, 30 * 30 * 31, INF);
    using P = tuple<double, int, int, int>;
    priority_queue<P, vector<P>, greater<P>> que;
    for (int i = 0; i < n; i++) {
      if (kyori[s][i] < 0) continue;
      dist[s][i][1] = kyori[s][i];
      que.emplace(dist[s][i][1], s, i, 1);
    }
    while (!que.empty()) {
      P p = que.top(); que.pop();
      double sum;
      int prev, curr, v;
      tie(sum, prev, curr, v) = p;
      if (dist[prev][curr][v] < sum) continue;
      for (int i = 0; i < n; i++) {
        if (kyori[curr][i] < 0) continue;
        if (i == prev) continue;
        if (v <= sokudo[curr][i] && dist[curr][i][v] > dist[prev][curr][v] + 1.0 * kyori[curr][i] / v) {
          dist[curr][i][v] = dist[prev][curr][v] + 1.0 * kyori[curr][i] / v;
          que.emplace(dist[curr][i][v], curr, i, v);
        }
        if (v > 0 && v - 1 <= sokudo[curr][i] && dist[curr][i][v - 1] > dist[prev][curr][v] + 1.0 * kyori[curr][i] / (v - 1)) {
          dist[curr][i][v - 1] = dist[prev][curr][v] + 1.0 * kyori[curr][i] / (v - 1);
          que.emplace(dist[curr][i][v - 1], curr, i, v - 1);
        }
        if (v + 1 <= sokudo[curr][i] && dist[curr][i][v + 1] > dist[prev][curr][v] + 1.0 * kyori[curr][i] / (v + 1)) {
          dist[curr][i][v + 1] = dist[prev][curr][v] + 1.0 * kyori[curr][i] / (v + 1);
          que.emplace(dist[curr][i][v + 1], curr, i, v + 1);
        }
      }
    }
    double ans = INF;
    for (int i = 0; i < n; i++) {
      ans = min(ans, dist[i][g][1]);
    }
    if (ans == INF) cout << "unreachable" << endl;
    else cout << ans << endl;
  }  

  return 0;
}


Measured memory_bytes: 3724
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int f[15][15];
int x,y;
int main()
{
	int n;
	while(1)
	{
		cin >> n;
		if(n==0)break;
		memset(f,0,sizeof(f));
		x=(n+1)/2;y=(n-1)/2;
		f[x][y]=1;
		for(int i=2;i<=n*n;i++)
		{
			x+=1;
			y+=1;
			x%=n;
			y%=n;
			if(f[x][y]==0)
			{
				f[x][y]=i;
			}
			else
			{
				while(f[x][y]!=0)
				{
					x+=1;
					y-=1;
					x+=n;
					y+=n;
					x%=n;
					y%=n;
				}
				f[x][y]=i;
			}
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				printf("%4d",f[i][j]);
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    String[] DAY_OF_WEEK = new String[]{ "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    int d = -1;
    for (int i = 0; i < DAY_OF_WEEK.length; i++) {
      if (s.equals(DAY_OF_WEEK[i])) {
        d = i;
        break;
      }
    }

    System.out.println(7 - d);
  }
}


Measured memory_bytes: 23252
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
struct Edge{
	long long int from, to;
};
int main() {
	int n; std::cin >> n;
	std::vector<Edge> edges(n - 1);
	for (auto& e : edges) {
		std::cin >> e.from >> e.to;
		if (e.from > e.to) std::swap(e.from, e.to);
	}
	long long int result = 0;
	for (long long int l = 1; l <= n; ++l) {
		result += (n - l + 1) * l;
	}
	for (const auto edge : edges) {
		result -= edge.from * (n - edge.to + 1);
	}
	std::cout << result << std::endl;
}

Measured memory_bytes: 6320
S = input()
mod_bucket = [0] * 2019
mod_bucket[0] += 1

_S = S[::-1]
mod = 0
p = 1
for i in range(len(S)):
    mod = (p * int(_S[i]) + mod) % 2019
    mod_bucket[mod] += 1
    p *= 10
    p %= 2019

ans = sum([mod*(mod-1)/2 for mod in mod_bucket])
print(int(ans))


Measured memory_bytes: 9372
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;

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

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;

int N;
ll W,weight[110],value[110];

ll dp[110][100100]={0};

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

  cin >>N >>W;
  rep(i,0,N) {cin >>weight[i] >>value[i];}

  rep(i,0,N) {
    rep_eq(sum_w,0,W) {
      if (sum_w-weight[i]>=0) {
        chmax(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i]);
      }
      chmax(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }
  cout << dp[N][W] << '\n';
  return 0;
}


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

/// Constant:
#define         eps         10e-9
#define         pi          2*acos(0)
#define         P1          1e9+7
#define         P2          1e9+9
#define         lli         long long int
/// Loop:
#define         f1(a,b)     for (int i=a; i<=b; i++)
#define         f2(a,b)     for (int j=a; j<=b; j++)
#define         f-1(a,b)     for (int i=b; i>=a; i--)
#define         f-2(a,b)     for (int j=b; j>=a; j--)
///Print:
#define         pY          cout<<"YES"<<endl;
#define         pN          cout<<"NO"<<endl;
#define         py          cout<<"Yes"<<endl;
#define         pn          cout<<"No"<<endl;

using namespace std;
///ISNNJB

/// Functions:
//lli bigmod(lli b, lli p, lli m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ lli res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//lli mod_inverse(lli a, lli mod) { return bigmod(a,mod-2,mod); }
//lli LCM(lli a, lli b){ return a*b/ __gcd(a,b);}

///Global Variable:
int ara[300005],brr[100004];

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main() {

    /**freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    lli a,b,c,d,t,n,m,x,y,q,ctn=0,l1,l2,total=0;

    cin>>a;
    cout<<(a+a*a+a*a*a)<<endl;

    return 0;
}



Measured memory_bytes: 3636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int mod7=1e9+7;
const int mod=998244353;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    int a,b;
    read(a),read(b);
    if(a<=b) puts("unsafe");
    else puts("safe"); 
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int num[N];
  rep(i, N) {
    cin >> num[i];
  }
  
  sort(num, num + SIZE_OF_ARRAY(num), greater<>());
  
  int ans = 1;
  rep(i, N) {
    if (i != 0 && num[i-1] > num[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define maxn 65
#define eps 1e-8
double x[maxn],y[maxn],c[maxn],X[65*65*2],Y[65*65*2],r[maxn];
int tot,N,K;
double dis(double x,double y,double c,double X,double Y){
	return c*sqrt((X-x)*(X-x)+(Y-y)*(Y-y));
}
void cal(double x1,double y1,double r1,double x2,double y2,double r2){//计算两圆交点坐标
	double D;//A=a*a,H=h*h,D=d*d;
	double ad,h;//ad=a*d;
	D=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
	if(D==0)return;
	ad=(r1*r1+D-r2*r2)/2;//2*a*d=r1*r1+D-r2*r2
	h=D*r1*r1-ad*ad;
	if(h<0)return;//漏了此句的判定
	h=sqrt(h);
	tot++,X[tot]=x1+ad*(x2-x1)/D-(y2-y1)*h/D,Y[tot]=y1+ad*(y2-y1)/D+(x2-x1)*h/D;
	tot++,X[tot]=x1+ad*(x2-x1)/D+(y2-y1)*h/D,Y[tot]=y1+ad*(y2-y1)/D-(x2-x1)*h/D;
}
int judge(double t){
	int i,j,cnt;
	for(i=1;i<=N;i++)r[i]=t/c[i];
	tot=0;
	for(i=1;i<=N;i++){
		tot++,X[tot]=x[i],Y[tot]=y[i];//tot++,X[i]=x[i],Y[i]=y[i];
		for(j=i+1;j<=N;j++)
			cal(x[i],y[i],r[i],x[j],y[j],r[j]);
	}
	for(i=1;i<=tot;i++){
		cnt=0;
		for(j=1;j<=N;j++)
			if(dis(x[j],y[j],c[j],X[i],Y[i])<t+eps)cnt++;//浮点比大小无等于的情况，这是由浮点误差决定的。if(dis(x[j],y[j],c[j],X[i],Y[i])<t+eps)cnt++;
		if(cnt>=K)return 1;
	}
	return 0;
}
int main(){
	double l,r,mid;
	int i;
	scanf("%d%d",&N,&K);
	for(i=1;i<=N;i++)scanf("%lf%lf%lf",&x[i],&y[i],&c[i]);
	l=0,r=1000010;
	for(i=1;i<=100;i++){
		mid=(l+r)/2;
		if(judge(mid))r=mid;
		else l=mid;
	}
	printf("%.6lf\n",r);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
# define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;
typedef queue<int> qi;


const int N = 2e5 + 5;



void solve() {

	int a, b;
	cin >> a >> b;
	cout << a * b << endl;

}


signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout << fixed << setprecision(15);
	int t = 1;
	//cin >> t;

	while (t--)
		solve();
#ifdef aa
	cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


int norm(int a) {
	while (a >= mod) a -= mod;
	while (a < 0) a += mod;
	return a;
}

int powm(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}

int divide(int a, int b) {
	return (a % mod) * powm(b, mod - 2) % mod;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main() {
    int a, b, c, i, x;
    cin >> a >> b >> c;
    x=0;
    for (i=a; i<=b; i++)
    {
        if (c % i == 0)
            x = x+ 1;
        
    }
    cout << x << endl;
    
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int table[200001];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n, m;
    cin >> n >> m;
    vector<int> a;
    vector<int> x(m);
    rep(i, m) cin >> x[i];
    for (int i = m - 1; i >= 0; --i) {
        if (table[x[i]]) continue;
        table[x[i]] = 1;
        a.eb(x[i]);
    }
    rep3(i, 1, n + 1) if (table[i] == 0) a.eb(i);
    rep(i, n) cout << a[i] << endl;
}



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

int main() {
    string s;
    cin >> s;
    if (s.size() % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 1; i < s.size(); i += 2) {
        if (s[i - 1] != 'h' || s[i] != 'i') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
import sys

input = sys.stdin.readline

Q = int(input())

update_count = 0
al = []
sl = 0
ar = []
sr = 0
b = 0
for _ in range(Q):
    # print(f'al:{al}, sl:{sl}')
    # print(f'ar:{ar},sr:{sr}')
    # print(f'b:{b}')
    # print()
    s = tuple(map(int, input().split()))
    if s[0] == 1:
        # 更新クエリ
        b += s[2]
        if update_count % 2 == 0:
            # 左に追加
            heappush(ar, s[1])  # 右に追加
            sr += s[1]
            x = heappop(ar)  # 右の最小値
            sr -= x
            heappush(al, -x)  # 左に追加
            sl += x
        else:
            # 右に追加
            heappush(al, -s[1])  # 左に追加
            sl += s[1]
            x = heappop(al)  # 左の最小値
            sl -= (-x)
            heappush(ar, -x)  # 右に追加
            sr += (-x)
        update_count += 1
        # 左キューalの最大値が中央値になっている
        # 左キューにheappushする際,負値に変換したので,heappopで最大値*(-1)が求まる
    else:
        # 求値クエリ
        x = heappop(al)  # 中央値
        heappush(al, x)
        x *= (-1)
        cnt_l = (update_count + 1) // 2
        cnt_r = update_count - cnt_l
        print(x, (cnt_l * x - sl) + (sr - cnt_r * x) + b)


Measured memory_bytes: 11284
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int A,B,C;
  cin>>A>>B>>C;
  cout<<min(A+B,min(B+C,A+C))<<endl;
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
char s1[100],s2[100],s3[100];
int main()
{
    scanf("%s[^\t]",s1);
    scanf("%s[^\t]",s2);
    scanf("%s[^\t]",s3);
    printf("%c%c%c\n",s1[0]-32,s2[0]-32,s3[0]-32);
}

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

int main()
{
    int n;
    while(cin >> n, n != 0)
    {
        int t, l, b;
        cin >> t >> l >> b;
        int lose[l], back[b];
        for(int i = 0; i < l; i++)
        {
            cin >> lose[i];
        }
        for(int i = 0; i < b; i++)
        {
            cin >> back[i];
        }
        
        double ans = 0;
        
        double p[200][200];
        p[0][0] = 1;
        for(int i = 1; i < 201; i++)
        {
            p[0][i] = 0;
        }
        for(int time = 1; time < t+1; time++)
        {

            for(int x = 0; x < n+6; x++)
            {
                if(x < 6)
                {
                    p[time][x] = 0;
                    for(int i = 0; i < x; i++)
                    {
                        p[time][x] = p[time][x] + p[time-1][i]/6;
                    }
                }
                else
                {
                    p[time][x] = 0;
                    for(int i = 1; i < 7; i++)
                    {
                        p[time][x] = p[time][x] + p[time-1][x-i]/6;
                    }
                }
            }
            
//  ??´???????????????????????¶????????????
            for(int i = 1; i < 6; i++)  //  ??´?????????????§?????????????????????§n-6?????§?????£??????????????¨?????????
            {
                p[time][n-i] = p[time][n-i] + p[time][n+i];
                p[time][n+i] = 0;
            }
            
//  lose???????????????
            for(int i = 0; i < l; i++)
            {
                for(int j = 1; j < 7; j++)
                {
                    p[time][lose[i]+j] = p[time][lose[i]+j] - p[time-1][lose[i]]/6;
                    if(time > 1)
                    {
                        p[time][lose[i]+j] = p[time][lose[i]+j] + p[time-2][lose[i]]/6;
                    }
                }
            }

//  ??´???????????????????????¶????????????(lose?????????????????§??????????????¶??????????????????????????????)
            for(int i = 1; i < 6; i++)
            {
                p[time][n-i] = p[time][n-i] + p[time][n+i];
                p[time][n+i] = 0;
            }

//  back???????????????
            for(int i = 0; i < b; i++)
            {
                p[time][0] = p[time][0] + p[time][back[i]];
                p[time][back[i]] = 0;
            }
            
//  ??´?????????????§?????????????????????????
            ans = ans + p[time][n];
            p[time][n] = 0;
            

        }
        
        printf("%.6f\n",ans);
    
    }
}

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

vector<char> solve(string abcd){
  
  int a = abcd.at(0) - '0';
  int b = abcd.at(1) - '0';
  int c = abcd.at(2) - '0';
  int d = abcd.at(3) - '0';
  
  int sum;
  char op1, op2, op3;
  
  for (int i = 0; i < 2; i++){
    for (int j = 0; j < 2; j++){
      for (int k = 0; k < 2; k++){
        sum = a;
        
        if (i == 0){
          op1 = '+';
          sum += b;
        }
        else{
          op1 = '-';
          sum -= b;
        }
        
        if (j == 0){
          op2 = '+';
          sum += c;
        }
        else{
          op2 = '-';
          sum -= c;
        }
        
        if (k == 0){
          op3 = '+';
          sum += d;
        }
        else{
          op3 = '-';
          sum -= d;
        }
        
        if (sum == 7){
          vector<char> op123 = {op1, op2, op3};
          return op123;
        }
      }
    }
  }
}

int main() {
  string input;
  cin >> input;
  
  vector<char> op;
  op = solve(input);
  
  cout << input.at(0) << op.at(0) <<
    input.at(1) << op.at(1) <<
    input.at(2) << op.at(2) <<
    input.at(3) << "=7" << endl;
}


Measured memory_bytes: 3612
S=input()
flag=0
O=["R","U","D"]
E=["L","U","D"]
for i in range(len(S)):
    if i%2==0:
        if S[i] not in O:
            flag=1
    else:
        if S[i] not in E:
            flag=1
if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n==0) return ;
			int xs[] = new int[n];
			for(int i=0; i<n; i++){
				xs[i] = in.nextInt();
			}
			Arrays.sort(xs);
			int total = 0;
			for(int i=1; i<n-1; i++){
				total += xs[i];
			}
			System.out.println(total/(n-2));
		}
	}
	
}

Measured memory_bytes: 12000
W,H,M = map(int, input().split())
maxX,minX,maxY,minY = W, 0, H ,0
for i in range(M):
  x, y, a = map(int, input().split())
  if a == 1 and x > minX:
    minX = x
  elif a == 2 and x < maxX:
    maxX = x
  elif a == 3 and y > minY:
    minY = y
  elif a == 4 and y < maxY:
    maxY = y

  
xl = maxX - minX
yl = maxY - minY
if xl > 0 and yl > 0:
  print(xl * yl)
else:
  print(0)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    String S = "";
    if(2*X <= Y && Y <= 4*X && Y%2==0){
      S = "Yes";
    } else {
      S = "No";
    }
    System.out.println(S);
  }
}

Measured memory_bytes: 35788