akhauriyash/Code-Regression huggingface dataset:
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<string> ss(n); cin >> ss;
    int as = 0, bs = 0, abs = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(ss[i].back() == 'A' && ss[i][0] == 'B'){
            abs++;
        }else{
            as += ss[i].back() == 'A';
            bs += ss[i][0] == 'B';
        }
        for(size_t j = 0; j + 1 < ss[i].size(); j++){
            if(ss[i][j] == 'A' && ss[i][j + 1] == 'B'){
                ans++;
            }
        }
    }
    if(as && bs){
        ans += min(as, bs) + abs;
    }else if(abs){
        ans += abs - 1 + bool(as) + bool(bs);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 512
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7;
ll OO=1e15;
const int N=3e3 + 5,M=1e5 + 3;
int dp[N][N];


ll n,m,k,cnt,SU,idx,len,MN,MX,T;
ll l,r,mid;
ll a,b,c,d;
vector<pair<int,pair<int,char>>> vec;
string str,s,t,ans;
bool flage;

int Solve(int x,int y){
	
	if(x == SZ(str) || y == SZ(s))
		return 0;
	
	int &ret = dp[x][y];
	if(~ret)
		return ret;

	if(str[x] == s[y])
		return ret = 1 + Solve(x+1,y+1);
	
	
	ret = 0;
	
	ret = max(ret,Solve(x+1,y));
	ret = max(ret,Solve(x,y+1));


	return ret;

}


void OutPut(int x,int y){
	
	if(x == SZ(str) || y == SZ(s))
		return;
	
	
	
	if(str[x] == s[y]){
		ans+=str[x];
		OutPut(x+1,y+1);
		return;
	}
	
	
	
	int val = Solve(x,y);
	
	int a = Solve(x+1,y);
	int b = Solve(x,y+1);
	
	if(val == a)
		OutPut(x+1,y);
	else if(val == b)
		OutPut(x,y+1);

}

int main(){
	
	memset(dp,-1,sizeof dp);
	
	cin>>str>>s;
	
	Solve(0,0);
	OutPut(0,0);

	cout<<ans;
	
	


}



















Measured memory_bytes: 35840
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

MOD = 10 ** 9 + 7

S = [0] * (x+1)
T = [0] * (x+1)

S[x] = 1

for i in range(n-1, -1, -1):
    T = [0] * (x + 1)
    for j in range(x+1):
        S[j] %= MOD
        T[j] += S[j] * i % MOD
        T[j % a[i]] += S[j]
    S, T = T, S

print(sum(i * S[i] % MOD for i in range(a[0]) ) % MOD)


Measured memory_bytes: 84684
def main():
    n = int(input())
    numbers = {}
    for _ in range(n):
        a = int(input())
        if a in numbers:
            numbers[a] += 1
        else:
            numbers[a] = 1
    answer = 0
    for c in numbers.values():
        if c % 2 == 1:
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 15076
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(ll)(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vl stones;
vl dp;
ll K;

ll cheap(ll in){
    if(dp[in] != -1){
        return dp[in];
    }
    ll mini = oo;
    FOR(i,max(0LL, in-K),in){
       ll res = cheap(i);
       ll ad = abs(stones[i] - stones[in]);
       mini = min(mini, res+ad);
    }
    dp[in] = mini;
    return mini;
}

int main(){
    ll N;
    cin >> N >> K;
    FOR(ghjk,0,N){
        ll in;
        cin >> in;
        dp.pb(-1);
        stones.pb(in);
    }
    dp[0] = 0;
    cout << cheap(N-1)<<endl;

} //cin.tie(0) bei schnellem Wechseln




Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
ac
実はAは22C11通りしかないので総当り可能
*/

ll n,m,q,a[51],b[51],c[51],d[51];
ll A[51];

ll f(ll cur, ll t){
	ll before = A[t];  // 記録
	A[t] = cur;  // 変更
	ll ans=0;
	if(t==n){
		rep(i,q)if(A[b[i]]-A[a[i]]==c[i])ans+=d[i];
		A[t]=cur;  // 復元
		return ans;
	}
	reg(i,cur,m){
		ans=max(ans,f(i,t+1));
	}
	A[t]=cur;  // 復元
	return ans;
}

int main(void){
	cin>>n>>m>>q;
	rep(i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
	cout<<f(1,0)<<endl;
	return 0;
}

Measured memory_bytes: 3536
#include <stdio.h>

int main() {
    int S,h,m,s;
    scanf("%d", &S);
    h = S/3600;
    m = (S%3600)/60;
    s = (S%3600)%60;
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
}


Measured memory_bytes: 2744
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    vector<int> v(3); cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end(), greater<int>());
    
    int K; cin >> K;
    for(int i=0; i<K; ++i){ v[0]*=2; }
    
    cout << accumulate(v.begin(), v.end(), 0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	/*int r;
	scanf("%d", &r);
	printf("%d\n", r * r);*/
	int n;
	char s[101];
	scanf("%d", &n);
	scanf("%s", s);
	if (n >= 2 && n % 2 == 0) {
		int half = n / 2;
		for (int i = 0; i < half; i++) {
			if (s[i] != s[half + i]) {
				printf("No\n");
				return 0;
			}
		}
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

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

using namespace std;

int a[10000],n,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n+n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n+n);
	for(int i=1;i<=n+n;i+=2)
		ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
    int n,ans;

    cin >> n;
    vector<int> x(n);
    rep(i, n) {
        cin >> x[i];
    }

    ll m=1000000000;
    for (int p = 1;p <= 100;++p) {
        int t = 0;
        rep(i, n) {
            t += (x[i]-p) * (x[i]-p);
        }
        if (m > t) {
            m = t;
        }
    }
    ans = m;

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


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

#define endl '\n'
#define ll long long

int sum(int n)
{
	int ans=0;
	while(n>0)
	{
		ans+=n%10;
		n/=10;
	}
	return ans;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll int n;
	cin >> n;
	if((n%sum(n))==0) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
long long K,A,B;

signed main()
{
	scanf("%lld%lld%lld",&K,&A,&B);
	if (B-A<=2) {
		cout<<K+1;
		return 0;
	}
	
	if (K+1<=A) {
		cout<<K+1;
		return 0;
	}
	
	long long ans=1;
	K-=(A-1); ans+=(A-1);
	ans+=(K/2)*(B-A); K%=2;
	ans+=K;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n, k; cin >> n >> k;
	vector<pair<ll,ll>> dt(n);
	REP(i, n) {
		cin >> dt[i].second >> dt[i].first;
		dt[i].second--;
	}
	sort(ALL(dt));
	reverse(ALL(dt));
	vl exists(n, false);
	vl v, w;
	ll ans = 0, cnt = 0;
	REP(i, k) {
		if (exists[dt[i].second]) {
			v.push_back(dt[i].first);
		}
		else {
			exists[dt[i].second] = true;
			cnt++;
		}
		ans += dt[i].first;
	}
	FOR(i, k, n) {
		if (!exists[dt[i].second]) w.push_back(dt[i].first);
		exists[dt[i].second] = true;
	}
	reverse(ALL(v));
	ll m = min(v.size(), w.size());
	ll nans = ans, ncnt = cnt;
	REP(i, m) {
		nans = nans - v[i] + w[i];
		ncnt++;
		if (ans + cnt * cnt < nans + ncnt * ncnt) {
			ans = nans;
			cnt = ncnt;
		}
	}
	cout << (ans + cnt * cnt) << endl;

	return 0;
}


Measured memory_bytes: 3392
void main() {
	auto N = ri;
	auto A = readAs!(long[]);
	ulong cnt = A.count!(i => i < 0);
	ulong res = A.map!(i => i.abs).sum;
	if(cnt % 2) res -= A.map!(i => i.abs).reduce!min * 2;
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

int main(){

    long long N;cin >> N;
    double root = sqrt(N);
    long long ans = N-1;

    for(int i = 1; i <= root; i++){

        if(N%i == 0){
            if((i + N/i) - 2 < ans){
                ans = (i + N/i) - 2;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 100010

bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll ans=0,n,k;
    cin >> n >> k;
    for (ll i=0;i<n;i++){
        ll x;
        cin >> x;
        if (x>=k)ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
 
 
int main() {
    int n, mini = 200;
    cin >> n;
    vector<int> s(n);
 
    rep(i,n){
        cin >> s[i];
        if(s[i] % 10 != 0){
            mini = min(mini, s[i]);
        }
    }
    int sum = accumulate(s.begin(), s.end(), 0);
    if(sum % 10 != 0) cout << sum << endl;
    else cout << (mini == 200 ? 0 : sum - mini) << endl;
}

Measured memory_bytes: 256
// I want to AC  


#include <vector>
#include<stdio.h>
#include<string.h>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
#include<cstring>
#include<queue>
#include<assert.h>
#define ll long long
#define MODD 1000000007
#define  pii  pair<int,int>
#include<stdio.h>
#include<string.h>
//#define  ll long long
using namespace std;
const int maxn = 1e7;


ll exgcd(ll a, ll b, ll &x, ll &y) {
 if (b == 0) { x = 1; y = 0; return a; }
 ll ret = exgcd(b, a % b, y, x);
 y -= a / b * x;
 return ret;
 }
ll inv(ll a, ll M) {
 static ll x, y;
 assert(exgcd(a, M, x, y) == 1);
 return (x % M + M) % M;
 }
//void gcd(ll a,ll b,ll &d,ll &x,ll &y){
//    if(!b){
//        d=a;x=1;y=0;
//    }else{
//        gcd(b,a%b,d,y,x);
//        y-=x*(a/b);
//    }
//}
//ll inv(ll a,ll n){
//    ll d,x,y;
//    gcd(a,n,d,x,y);
//    return d==1?(x+n)%n:-1;
//}
// LL get_inv(LL a, LL M) {
// static LL x, y;
// assert(exgcd(a, M, x, y) == 1);
// return (x % M + M) % M;
// }

//欧拉函数
ll euler(ll n)
{
    ll rt = n;
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            rt -= rt / i;
            while (n % i == 0)
                n /= i;
        }
    if (n > 1)
        rt -= rt / n;
    return rt;
}

bool st[1000005];
int primes[50005];
void prime(int n)
{
    int cnt =0 ;
	for(int i=2;i<=n;i++)
	{
		if(!st[i])
		{
			primes[cnt++]=i;
		}
		for(int j=0;j<cnt&&i*primes[j]<=n;j++)
		{
			st[primes[j]*i]=true;
			if(i%primes[j]==0)
			{
				break;
			}
		}
	}

}


vector<int > div(int x){
	vector<int > res;
	for(int i=1 ;i<=x/i;i++) {
		if(x%i==0){
			res.push_back(i);
			if(i!=x/i) res.push_back(x/i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}
ll mod = 1e9+7;
inline void read(int &x){
    x=0;int f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x*=f;
}


int cnt =0 ;
double dp[maxn],num[maxn];
char ch [2500][2500];
int main() {
  	
//string s; cin >>s;
//int k;cin >>k;
//for(int i=0)
int n,m;cin >>n>>m;
double sum =0 ;
for(int i=1;i<=n;i++)cin >>dp[i];
num[0]=0;
for(int i=1,j=0;i<=n;i++){
num[i] = num[i-1]+dp[i];
	
}int j =1 ;
for(int i=m;i<=n;i++){
	sum= max(sum,num[i]-num[j-1]);
	j ++;
}

//cout<<sum<<endl;
printf("%.8f",(sum+m)/2);
    return 0;



}

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


using namespace std;
using ll = long long;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

const int INF = 1e4;

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    int n; cin >> n;
    int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
    while(n--) {
        string s; cin >> s;
        if(s == "AC") c1++;
        if(s == "WA") c2++;
        if(s == "TLE") c3++;
        if(s == "RE") c4++;
    }

    char ss = 'x';

    cout << "AC" << " " << ss << " " << c1 << '\n';
    cout << "WA" << " " << ss << " " << c2 << '\n';
    cout << "TLE" << " " << ss << " " << c3 << '\n';
    cout << "RE" << " " << ss << " " << c4 << '\n';
    return 0;
}



Measured memory_bytes: 3600
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
x, a, b = M()
if abs(x-a) < abs(x-b):
    print('A')
else:
    print('B')

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

#define rep(i,m) for(int i = 0; i < m; i++)
using ll = long long;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a<=c&&c<=b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main() 
{
    IOS;
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    for(int i=k;i<n;i++)
    {
        if(arr[i]>arr[i-k])
            print("Yes");
        else
            print("No");
    }
}   

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double A,B;
  cin >> A >> B;
  
  double X,Y,Z,W,per,ans;
  
  X = ceil(A * 12.5);
  Y = B * 10.0;
  
  if (X < Y){
    Z = Y;
    W = A;
    per = 0.08;
  }
  else{
    Z = X;
    W = B;
    per = 0.10;
  }
  
  if (floor(Z * per) ==  W){
    ans = Z ;
  }
  else{
    ans = -1;
  }
  
  
  cout << ans << endl;


  
  
}


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

#define INF 131211109876543210LL
#define MAX_N 301
#define MAX_K 9
#define MAX_NUM 10

long long wa[MAX_N][MAX_N];
long long dp[MAX_N][MAX_N];
long long x[MAX_N], y[MAX_N];
long long power[MAX_K];
long long a1[MAX_K], a2[MAX_K], a3[MAX_K];
long long N;

long long keisan(long long v, long long w) {
	for (int i = 0; i < MAX_K; i++) {
		power[i] = 0LL;
		a1[i] = 0LL;
		a2[i] = 0LL;
		a3[i] = 0LL;
	}
	power[0] = 1;
	for (int i = 1; i < MAX_K; i++) {
		power[i] = power[i - 1] *MAX_NUM;
	}
	for (int i = 0; i < MAX_K; i++) {
		a1[i] = (v / power[i]) % MAX_NUM;
	}
	for (int i = 0; i < MAX_K; i++) {
		a2[i] = (w / power[i]) % MAX_NUM;
	}
	long long res1 = 0;
	for (int i = 0; i < MAX_K; i++) {
		res1 += a1[i] * a2[i];
	}
	a3[0] = (a1[0] + a2[0]) / MAX_NUM;
	for (int i = 1; i < MAX_K; i++) {
		long long a4 = a1[i] + a2[i] + a3[i - 1];
		if (a4 >= MAX_NUM) {
			a3[i] = 1;
		}
		else {
			a3[i] = 0;
		}
	}
	for (int i = 0; i < MAX_K; i++) {
		res1 += a3[i];
	}
	return res1;
}

void WA() {
	y[0] = x[0];
	for (int i = 1; i < N; i++) {
		y[i] = y[i - 1] + x[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			wa[i][j] = y[j] - y[i - 1];
		}
	}
}

int DP() {
	WA();
	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j < MAX_N; j++) {
			dp[i][j] = INF;
		}
	}
	for (int i = 0; i < N; i++) {
		dp[i][i] = 0;
	}
	for (int i = 1; i < N; i++) {
		for (int j = 0; j <= N - i; j++) {
			long long a5 = j, a6 = j + i;

			for (int k = a5; k < a6; k++) {
				long long a7 = dp[a5][k];
				long long a8 = dp[k + 1][a6];
				long long a9 = wa[a5][k];
				long long a10 = wa[k + 1][a6];
				long long a11 = keisan(a9, a10);
				long long a12 = a7 + a8 + a11;
				dp[a5][a6] = min(dp[a5][a6], a12);
			}
		}
	}
	return dp[0][N - 1];
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	cout << DP() << endl;
	return 0;
}

Measured memory_bytes: 2576
#include <bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll price = LONG_LONG_MAX;
    rep(i,0,1e5+1){
        ll p = 2*c*i + a*max(0LL,x-i) + max(0LL,y-i)*b;
        price = min(p,price);
    }
    cout << price << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}



void solve(){
    deque <char> dq;
    string s;
    cin >> s;
    for(auto c:s){
        dq.pb(c);
    }
    ll q;
    cin >> q;
    bool ok = 1;
    while(q --){
        ll ty;
        cin >> ty;
        if(ty == 1){
            ok^=1;
        }
        else
        {
            ll f;
            char c;
            cin >> f >> c;
            if(ok){
                if(f == 1){
                    dq.push_front(c);
                }
                else
                {
                    dq.pb(c);
                }
            }
            else
            {
                if(f == 1){
                    dq.pb(c);
                }
                else
                {
                    dq.push_front(c);
                }
            }
        }
    }
    if(ok){
        for(auto it:dq){
            cout << it;
        }
    }
    else
        {
            reverse(all(dq));
            for(auto it:dq)
                cout << it;
        }
}

int main()
{

 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
  //  cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 976
object Main {
  def main(args:Array[String]) = {
    val in = readLine.split(" ").map(_.toInt)
    val a = in(0)
    val b = in(1)
    
    val p = a + b
    val m = a - b
    val t = a * b
    
    val r1 = if(p > m) p else m
    val r2 = if(r1 > t) r1 else t
    println(r2)
  }
}

Measured memory_bytes: 25384
"""
103 C
"""

def read_input():
    n = int(input())
    alist = list(map(int, input().split()))
    return n, alist


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


def submit():
    n, alist = read_input()

    c = 1
    for a in alist:
        c = lcm(c, a)

    res = 0
    for a in alist:
        res += (c - 1) % a

    print(res)
    

if __name__ == "__main__":
    submit()

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    //if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m; cin >> n >> m;
  vector<P> x(n);
  rep(i, n) cin >> x[i].first >> x[i].second;
  sort(ALL(x));
  priority_queue<int> pq;
  int ans = 0;
  for(int day = 1; day <= m; ++day) {
    auto start = lower_bound(ALL(x), make_pair(day, 0));
    auto end = upper_bound(ALL(x), make_pair(day, INF));
    for(auto it = start; it != end; ++it) pq.push((*it).second);
    if(!pq.empty()) {
      ans += pq.top(); pq.pop();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char a,b;
    cin>>a>>b;
    if(a=='H')cout<<b<<endl;
    else if(a=='D'){
        if(b=='H')cout<<'D'<<endl;
        else cout<<'H'<<endl;
    }
}


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


public class Contest
{
	public static void Main()
	{
		int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

		int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
		int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
/*
		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) e[i] = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
*/

		double ss = (double)(b[0]-b[1])/0.006;
		double m = Math.Abs(ss-c[0]);
		int idx = 0;
		for(int i=1; i<c.Length; i++) if(Math.Abs(ss-c[i]) < m) {
			m = Math.Abs(ss-c[i]);
			idx = i;
		}

		string ans = (idx+1).ToString();

		Console.WriteLine(ans);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}


Measured memory_bytes: 11164
def relation(xa, ya, ra, xb, yb, rb)
    d = ((xa - xb) ** 2 + (ya - yb) ** 2) ** 0.5

    case
    when ra + rb < d; 0
    when d + rb < ra; 2
    when d + ra < rb; -2
    else 1
    end
end

$<.gets.to_i.times do
    p relation(*$<.gets.split.map(&:to_f))
end

Measured memory_bytes: 6164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005,mod=1000000007;
int nxt[N][2],dp[N],sum[N],Pos=N;
char ch[N];
vector<int> v[3];
inline void add(int &a,int b){
	a=a+b>=mod?a+b-mod:a+b;
}
signed main(){
	scanf("%s",ch+1);
	int n=strlen(ch+1);
	for(int i=1;i<=n;i++){
		ch[i]-='a'; ch[i]++;
		sum[i]=(sum[i-1]+ch[i])%3;
	}
	for(int i=1;i<=n;i++)v[sum[i]].push_back(i); ch[0]=-1;
	for(int i=n-1;i>=0;i--){
		if(ch[i+1]==ch[i])Pos=i;
		int t=(sum[i]+1)%3,pos=lower_bound(v[t].begin(),v[t].end(),Pos)-v[t].begin(); 
		if(sum[i+1]==t)nxt[i][0]=i+1; else if(pos<v[t].size())nxt[i][0]=v[t][pos];
		t=(t+1)%3; pos=lower_bound(v[t].begin(),v[t].end(),Pos)-v[t].begin();
		if(sum[i+1]==t)nxt[i][1]=i+1; else if(pos<v[t].size())nxt[i][1]=v[t][pos];
	}
	if(Pos>n){
		puts("1"); return 0;
	}
	dp[0]=1;
	for(int i=0;i<n;i++){
		if(nxt[i][0])add(dp[nxt[i][0]],dp[i]);
		if(nxt[i][1])add(dp[nxt[i][1]],dp[i]);
		//cout<<dp[i]<<" "<<nxt[i][0]<<" "<<nxt[i][1]<<endl;
	}
	for(int i=1;i<n;i++)if(sum[i]==sum[n])add(dp[n],dp[i]);
	cout<<dp[n]<<endl;
}
/*
aa/b/ab
aa/a/ab


*/


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

void solve(std::string O, std::string E) {
  string res;
  for (int i = 0; i < O.size(); i++) {
      res.push_back(O[i]);
      if (i < E.size())
	  res.push_back(E[i]);
      
  }
  cout << res << endl;
}

int main() {
  std::string O;
  std::cin >> O;
  std::string E;
  std::cin >> E;
  solve(O, E);
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
long long N, M;
int main() {
	cin >> N >> M;
	if (2 * N >= M) cout << M / 2 << endl;
	else cout << N + (M - 2 * N) / 4 << endl;
	return 0;
}

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

using namespace std;

int main()
{
ll sum,n;
cin>>sum>>n;
ll arr[n];
for(ll i=0;i<n;i++)cin>>arr[i];
ll dis[n];
for(ll i=0;i<n-1;i++){
    dis[i]=arr[i+1]-arr[i];
    }
    dis[n-1]=arr[0]+sum-arr[n-1];

  ll min=INT_MAX;
  if(sum-dis[0]<min)min=sum-dis[0];
  if(sum-dis[n-1]<min)min=sum-dis[n-1];
  for(ll j=1;j<n;j++){
    if(sum-dis[j]<min)min=sum-dis[j];
     if(sum-dis[j-1]<min)min=sum-dis[j];


  }


    cout<<min;






    return 0;
}


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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;


void solve(){
    int a,b;
    cin>>a>>b;
    int ans = 0;
    int num = 1;
    while(num < b){
        ++ans;
        num += a-1;
    }
    cout<<ans<<endl;
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
  //  freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef double db;
#define INF 1e8
#define EPS 1e-9
#define ALL(x) x.begin() , x.end()
#define ALLR(x) x.rbegin() , x.rend()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define PI acos(-1.0) 


int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  ll n,x;
  cin>>n;
  ll sec=n;
  n=(1<<n);
  vl c,d;
  multiset<ll> slimes;
  bool o=1;
  for(ll i=0;i<n;i++)
  {
    cin>>x;
    slimes.insert(-x);
  }
  c.push_back(-*slimes.begin());
  slimes.erase(slimes.begin());
  for(int s=0;s<sec;s++)
  {
    queue<int> aux;
    //cout<<c.size()<<endl;
    ll prevs=c.size();
    for(auto ct : c)
    {
        
        auto it= slimes.upper_bound(-ct);
        if(it==slimes.end())
        {
            o=0;
            break;
        }
        aux.push(-*it);
        //cout<<c[i]<<" "<<*prev(it)<<endl;
        slimes.erase(it);
        
    }
    if(!o)break;
    while(!aux.empty())
    {
      c.push_back(aux.front());
      aux.pop();
    }

  }
  
  if(o)cout<<"Yes\n";
  else cout<<"No\n";
}

Measured memory_bytes: 13808
#include <iostream>
#include <set>
#define int long long
using namespace std;
set<int>s; int n, m, p;
signed main() {
	cin >> n; for (int i = 0; i < n; i++) { int p; cin >> p; s.insert(p); }
	cin >> m; for (int i = 0; i < m; i++) { int p; cin >> p; s.insert(p); }
	for (int i : s)cout << i << endl;
}


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

int main()
{
  string S;
  cin>>S;
  int max = 0;
  for(int i = 0;i<=S.length();i++)
  {
    for(int j = 0;j<=S.length();j++)
    {
      if(i+j>S.length())
      {
        continue;
      }
      string sub = S.substr(i,j);
      bool isACGT = true;
      for(int k = 0;k<sub.length();k++)
      {
        if(sub[k] != 'A' && sub[k] != 'C' && sub[k] != 'G' && sub[k] != 'T')
        {
          isACGT = false;
          break;
        }
      }
      if(isACGT)
      {
        if(max < sub.length())
        {
          max = sub.length();
        }
      }
    }
  }
  cout<<max<<endl;
}

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

int main(){
    string s1, s2; cin >>s1 >> s2;
    int N=s1.size(), M = s2.size();
    int dp[1010][1010];
    for(int i=0; i<=N; i++){
        for(int j=0; j<=M; j++){
            if(i==0) dp[i][j]=j;
            else if(j==0) dp[i][j]=i;
            else dp[i][j]=100100;
        }
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            if(s1.at(i)==s2.at(j)) dp[i+1][j+1]=min({dp[i+1][j]+1 ,dp[i][j+1]+1, dp[i][j]});
            else dp[i+1][j+1] = min({dp[i+1][j],dp[i][j+1],dp[i][j]})+1;
        }
    }
    cout << dp[N][M] << endl;
}


Measured memory_bytes: 7144
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007
#define MAXS(x,y) (x = max(x,y))
#define MINS(x,y) (x = min(x,y))

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

vector<int> pre, in, post;

int N;
int pos = 0;


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

Node *root = NULL;

void insert(int v){
  Node *y = NULL;
  Node *x = root;
  Node *z = (Node *)malloc(sizeof(Node));

  z->key = v;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL){
    y = x;
    if(x->key > z->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }

  z->parent = y;
  if(y == NULL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

Node *find(int v){
  Node *y = NULL;
  Node *x = root;

  while(x != NULL){
    y = x;
    if(x->key == v){
      return x;
    }else if(x->key > v){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  return x;
}

void printIn(Node *p){
  if(p == NULL)return;
  printIn(p->left);
  cout << " " << p->key;
  printIn(p->right);
}

void printPre(Node *p){
  if(p == NULL)return;
  cout << " " << p->key;
  printPre(p->left);
  printPre(p->right);
}


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


  REP(i,N){
    cin >> cmd;

    if(cmd == "insert"){
      int v;
      cin >> v;
      insert(v);
    }else if(cmd == "find"){
      int v; 
      cin >> v;
      if(find(v) == NULL){
        cout << "no" << endl;
      }else{
        cout << "yes" << endl;
      }
    }else{
      printIn(root);
      cout << endl;
      printPre(root);
      cout << endl;
    }
  }
}



Measured memory_bytes: 21924
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    ll r, g, b, n;
    cin>>r>>g>>b>>n;
    ll ans = 0ll;
    for(ll i = 0; i <= n; i++){
        for(ll j = 0; j <= n; j++){
            ll k = n - i * r - j * g;
            if(k < 0) continue;
            if(k % b == 0) {
                //cout<<i<<' '<<j<<' '<<k/b<<endl;
                ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a=a[::-1]
b=[0]*n
x,y=0,1
t=True
for z in a:
    if t:
        b[x]=z
        x+=1
        t=False
    else:
        b[-y]=z
        y+=1
        t=True
print(*b)


Measured memory_bytes: 26184
N = gets.to_i
Mod = 10 ** 9 + 7

def modpow(x,p)   #x^p
  result = 1
  for i in 1..p do
    result = (result * x) % Mod
  end
  return result
end

if N == 1 then
  puts 0
else
  puts (modpow(10,N) - 2 * modpow(9,N) + modpow(8,N)) % Mod
end

Measured memory_bytes: 14416
N=int(input())
A=list(map(int,input().split()))
B=[0]
total=0
count=1
answer=0

for i in range(len(A)):
  total+=A[i]
  B.append(total) #iまでの部分和

B.sort() #部分和が同じ部分の数を数えると解ける
for i in range(1,len(B)):
  if B[i]==B[i-1]:
    count+=1
  else:
    answer+=count*(count-1)/2 #部分和が同じものを2個取り出す組み合わせ
    count=1
answer+=count*(count-1)/2
    
print(int(answer))

Measured memory_bytes: 25724
exception Exodus

let rec solve i j b b' =
  let k = (i + j) / 2 in
  Printf.printf "%d\n" k;
  let b'' =
    match read_line () with
    | "Male" -> true
    | "Female" -> false
    | "Vacant" -> raise Exodus in
  if (k - i) mod 2 = 0 <> (b = b'') then solve i k b b''
  else if (j - k) mod 2 = 0 <> (b'' = b') then solve k j b'' b'
  else (i, k, j, b, b'', b'')

let rec solve_acc candidates =
  List.map (fun (i, j, b, b') -> solve i j b b') candidates
  |> List.map (fun (i, j, k, b, b', b'') -> [(i, j, b, b'); (j, k, b', b'')])
  |> List.concat 
  |> solve_acc

let () =
  let n = int_of_string @@ read_line () in
  print_endline "0";
  try
    begin match read_line () with
    | "Male" -> true
    | "Female" -> false
    | "Vacant" -> raise Exodus
    end
    |> (fun b -> solve_acc [(0, n, b, b)])
  with Exodus -> ()

Measured memory_bytes: 980
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	static final int INF = (int)1e9 + 7;
	int N,M;
	ArrayList<Integer>[] G;
	boolean[][] usedEdge;
	int[][] cost;

	@SuppressWarnings("unchecked")
	public void solve() {
		N = nextInt();
		M = nextInt();

		G = new ArrayList[N];
		for(int i = 0;i < N;i++){
			G[i] = new ArrayList<Integer>();
		}

		usedEdge = new boolean[N][N];
		cost = new int[N][N];


		for(int i = 0;i < M;i++){
			int a = nextInt()-1;
			int b = nextInt()-1;
			int c = nextInt();

			G[a].add(b);
			G[b].add(a);
			cost[a][b] = c;
			cost[b][a] = c;
		}

		for(int i = 0;i < N;i++){
			int[] d = new int[N];
			int[] prev = new int[N];
			boolean[] used = new boolean[N];
			Arrays.fill(prev, -1);
			Arrays.fill(d, INF);
			d[i] = 0;

			while(true){
				int v = -1;
				for(int u = 0;u < N;u++){
					if(!used[u] && (v == -1 || d[u] < d[v]))v = u;
				}

				if(v == -1)break;
				used[v] = true;

				for(int u : G[v]){
					if(d[u] > d[v] + cost[v][u]){
						d[u] = d[v] + cost[v][u];
						prev[u] = v;
					}
				}
			}

			for(int j = 0;j < N;j++){
				if(i == j)continue;
				usedEdge[j][prev[j]] = true;
				usedEdge[prev[j]][j] = true;
			}
		}

		int ans = 0;
		boolean[][] used = new boolean[N][N];
		for(int i = 0;i < N;i++){
			for(int j : G[i]){
				if(used[i][j] || used[j][i])continue;
				if(!usedEdge[i][j] && !usedEdge[j][i]){
					used[i][j] = used[j][i] = true;
					ans++;
				}
			}
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 11088
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <numeric>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define pb push_back
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};


const int MAX_N = 202020;
int bit[MAX_N + 1], n = 202020;
int sum(int i) {
  // cout << "AAAAAA " << i << endl;
  int s = 0;
  while (i > 0) {
    // cout << "BABA" << endl;
    s += bit[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, int x) {
  // cout << i << "-" << x << endl;
  while (i <= n) {
    bit[i] += x;
    i += i & -i;
  }
}

string S;
map<char, int> cnt;
map<char, vector<int>> idx;
 
signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> S;
  int N = S.length();

  for (int i=0; i<N; i++) {
    cnt[S[i]]++;
    idx[S[i]].pb(i);
  }

  int oddnum = 0;
  char oddchar;
  for (auto it=cnt.begin(); it!=cnt.end(); it++) {
    if (it->second & 1) {
      oddchar = it->first;
      oddnum++;
    }
  }
  if (2 <= oddnum) {
    cout << -1 << endl;
    return 0;
  }

  string left;
  map<char, int> usenum;
  for (int i=0, len=0; i<N && len<N/2; i++) {
    if (usenum[S[i]] < cnt[S[i]] / 2) {
      left += S[i];
      usenum[S[i]]++;
      len++;
    }
  }
  int len = left.length();
  string full = left;
  if (N & 1) full += oddchar;
  for (int i=len-1; i>=0; i--) {
    full += left[i];
  }

  vector<int> a;
  usenum.clear();
  for (char c : full) {
    a.pb(idx[c][usenum[c]++]);
  }

  // cout << full << endl;
  // for (int i : a) cout << i << " ";

  int ans = 0;
  for (int j=0; j<N; j++) {
    // cout << "AAA" << endl;
    ans += j - sum(a[j] + 1);
    add(a[j] + 1, 1);
  }

  // cout << full << endl;
  // for (int i : a) cout << i << " ";
  cout << ans << endl;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    vector<int> c(3);
    for(auto &i:c)
        cin >> i;
    
    sort(c.begin(), c.end());
    auto it = unique(c.begin(), c.end());

    cout << it - c.begin() << endl;

    return 0;
}

Measured memory_bytes: 256