akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

int n, m, q;
vector<vector<int>> x(510, vector<int>(510));
vector<vector<int>> c(510, vector<int>(510));
vector<int> rv(200009);
vector<int> lv(200009);

int main() {
    cin >> n >> m >> q;
    for ( int i = 1; i <= m; i++ ) {
        cin >> lv[i] >> rv[i];
        x[lv[i]][rv[i]]++;
    }
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 1; j <= n; j++ ) {
            c[i][j] = c[i][j-1] + x[i][j];
        }
    }

    for ( int i = 1; i <= q; i++ ) {
        int tmp_p, tmp_q;
        cin >> tmp_p >> tmp_q;
        int sum = 0;
        for( int j = tmp_p; j <= tmp_q; j++ ) sum += c[j][tmp_q] - c[j][tmp_p-1];
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 4608
w, a, b = map(int, input().split())
migi = b - (a + w)
hidari = b + w - a
if b <= (a + w) and abs(migi) <= w:
    migi = 0
elif a <= (b + w) and abs(hidari) <= w:
    hidari = 0
print(min(abs(migi), abs(hidari)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
// const int N = ;

int sum;
string s;

void solve() {
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        sum += s[i] - '0';
    }
    cout << (sum % 9 == 0 ? "Yes\n" : "No\n");
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 
    solve();
    
}

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

using namespace std;


bool isPal(string &S) {
    int l = 0, r = S.length()-1;
    while(l < r) {
        if(S[l] != S[r]) {
            return false;
        }
        l++; r--;
    } 
    return true;
}

int main() {
    double L; cin >> L;
    L /= 3.0;

    double ans = L * L * L;

    cout << fixed;
    cout << setprecision(8) << ans << "\n";

    return 0;   
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <deque>
#include <functional>

inline void
rep(int n, std::function<void(int)> f) {
    for (int i = 0; i < n; i++) {
        f(i);
    }
};

typedef std::pair<int, int> P;

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	
	int n, q, l, r;
	std::string s;
	std::vector<P> v;
	std::vector<int> ans;
	std::deque<int> memo;
	
	std::cin >> n >> q;
	std::cin.ignore();
	std::cin >> s;
	std::cin.ignore();
	
	rep(q, [&](int i) {
			std::cin >> l >> r;
			v.push_back(std::make_pair(l, r));
			});
	
	int index = static_cast<int>(s.find("AC"));
	if (-1 != index) {
		for (int i = index; i < static_cast<int>(s.length())-1;) {
			if (s[i] == 'A' && s[i+1] == 'C') {
				memo.push_back(i);
				i += 2;
			}
			else {
				i++;
			}
		}
		int msize = static_cast<int>(memo.size());
		for (int i = 0; i < static_cast<int>(s.length()); i++) {
			if (i == memo.front()) {
				ans.push_back(static_cast<int>(memo.size()));
				memo.pop_front();
			}
			else {
				ans.push_back(0);
			}
		}

		int tmp = 0;
		for (int i = static_cast<int>(ans.size())-1; i >= 0 ; i--) {
			if (ans[i] != 0) {
				tmp = ans[i];
			}
			else {
				ans[i] = tmp;
			}
		}
	}
	else {
		for (const auto& e : v) {
			std::cout << 0 << '\n'; 
		}
		return 0;
	}
	
	for (const auto& e : v) {
		std::cout << ans[e.first-1] - ans[e.second-1]<< '\n'; 
	}
	return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

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

    char a[h][w] = {};
    ll dist[h][w] = {};

    rep(i,0,h){
        rep(j,0,w){
            cin >> a[i][j];
            if(a[i][j] == '.') dist[i][j] = LINF;
            else dist[i][j] = 0;
        }
    }

    rep(i,0,h){ //左から
        rep(j,1,w){
            dist[i][j] = min(dist[i][j],dist[i][j-1]+1);
        }
    }

    rep(i,0,h){ //右から
        rep(k,1,w){
            ll j = w-k-1;
            dist[i][j] = min(dist[i][j],dist[i][j+1]+1);
        }
    }

    rep(i,1,h){ //上から
        rep(j,0,w){
            dist[i][j] = min(dist[i][j],dist[i-1][j]+1);
        }
    }

    rep(k,1,h){ //下から
        rep(j,0,w){
            ll i = h-k-1;
            dist[i][j] = min(dist[i][j],dist[i+1][j]+1);
        }
    }

    ll ans = 0;
    rep(i,0,h){
        rep(j,0,w){
            ans = max(ans,dist[i][j]);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 12324
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int[]AB=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int sum =AB[0]+AB[1];
    int sub = AB[0]-AB[1];
    int multi=AB[0]*AB[1];
    if(sum>=sub&&sum>=multi)Console.WriteLine(sum);
    else if(sub>=sum&&sub>=multi)Console.WriteLine(sub);
    else Console.WriteLine(multi);
  }
}

Measured memory_bytes: 13268
/*
 *  Created on: 22 / 4 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n)
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ll mod = 1e9 + 7;
//__int128
const ld PI = 3.14159265358979323846;
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    stp(20);
    Eslam__Waheed
        ll n, m; cin >> n >> m;
    ll sum = 0;
    loop(i, 0, m)
    {
        ll a; cin >> a;
        sum += a;
    }
    if (sum > n)
    {
        cout << -1 << endl;
        return 0;
    }
    cout << n - sum;
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

int dp[110000];

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

    int N;
    cin>>N;
    vector<P> X(N);
    for(int i=0;i<N;i++){
        ll x,l;
        cin>>x>>l;
        X[i].first=x-l;
        X[i].second=x+l;
    }
    X.push_back(P(INF,0));
    sort(X.begin(),X.end());

    for(int i=0;i<N;i++){
        ll x=X[i].second;
        int t=(int)(lower_bound(X.begin(),X.end(),P(x,-INF))-X.begin() );
        //cout<<t<<endl;
        chmax(dp[t],dp[i]+1);
        chmax(dp[i+1],dp[i]);
    }
    cout<<dp[N]<<endl;



}


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

#define mod 1000000007 
#define check exit(0)
#define nl cout<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

int main()
{
    jaldi
    string s;
    cin>>s;
    (s[2]==s[3] && s[4]==s[5])?cout<<"Yes":cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const ll LINF = 1001002003004005006ll;

ll a, b, c, d;
map<ll, ll> mem;

ll f(ll x) {
    if (!x) return 0;
    if (mem.count(x)) return mem[x];
    ll res = LINF;
    if (LINF / d > x) res = x * d;
    auto f2 = [&](ll y) {
        if (y >= x) return LINF;
        return f(y);
    };
    {
        ll l = x / 2LL * 2LL, r = l + 2LL;
        res = min(res, f2(l/2LL) + a + (x - l) * d);
        res = min(res, f2(r/2LL) + a + (r - x) * d);
    }
    {
        ll l = x / 3LL * 3LL, r = l + 3LL;
        res = min(res, f2(l/3LL) + b + (x - l) * d);
        res = min(res, f2(r/3LL) + b + (r - x) * d);
    }
    {
        ll l = x / 5LL * 5LL, r = l + 5LL;
        res = min(res, f2(l/5LL) + c + (x - l) * d);
        res = min(res, f2(r/5LL) + c + (r - x) * d);
    }
    return mem[x] = res;
}

void solve() {
    ll n;
    cin >> n;
    cin >> a >> b >> c >> d;
    mem = map<ll, ll>();
    cout << f(n) << endl;
}

int main() {
    int t;
    cin >> t;
    rep(i, t) solve();
    return 0;
}


Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s;
	cin >> s;
	if ((s[0] == s[1]) || (s[1] == s[2]) || (s[2] == s[3])) cout << "Bad\n";
	else cout << "Good\n";


	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i, j;
		String a, b, c;
		long num, num1, num2;
		while (sc.hasNext()) {
			a = sc.next();
			b = sc.next();
			num1 = Long.parseLong(a);
			num2 = Long.parseLong(b);
			num = num1 + num2;
			c = Long.toString(num);
			System.out.println(c.length());
		}
	}
}

Measured memory_bytes: 19524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=600005;
const int mod=1e9+7;
inline int Add(int x,int y){
    return (x+=y)>=mod?x-mod:x;
}
inline int Sub(int x,int y){
    return (x-=y)<0?x+mod:x;
}
inline int Mul(int x,int y){
    return 1ll*x*y%mod;
}
inline int Pow(int x,int y){
    int res=1;
    while(y){
        if(y&1)res=1ll*res*x%mod;
        y>>=1;
        x=1ll*x*x%mod;
    }
    return res;
}
int m,n,l,r;
int f[max_n],inv[max_n];
void init(int n){
    f[0]=1;
    for(int i=1;i<=n;i++)f[i]=1ll*f[i-1]*i%mod;
    inv[n]=Pow(f[n],mod-2);
    for(int i=n-1;i>=0;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int C(int n,int m){
    if(n<m||m<0)return 0;
    return 1ll*f[n]*inv[m]%mod*inv[n-m]%mod;
}
int cal(int a,int b,int s){
    int res=0;
    for(int i=0;i<=n-m;i++){
        int ts=s-m*a-i*(b+1);
        if(ts<0)break;
        if(i&1)res=Sub(res,Mul(C(n-m,i),C(ts+n,n)));
        else res=Add(res,Mul(C(n-m,i),C(ts+n,n)));
    }
    res=Mul(res,C(n,m));
    //cout<<res<<endl;
    return res;
}
int solve(int s){
    int res=C(s+n,n);
    //cout<<res<<endl;
    for(int x=1;x*m<=s;x++){
        res=Sub(res,Sub(cal(x,x-1,s),cal(x+1,x-1,s)));
       // cout<<x<<' '<<cal(x,x-1,s)<<' '<<cal(x+1,x-1,s)<<endl;
    }
    return res;
}
int main(){
    scanf("%d%d%d%d",&n,&m,&l,&r);
    init(max_n-1);
    int ans=(solve(r)-solve(l-1)+mod)%mod;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	cin>>n;
	ll res=0;
	forn(i,1,n)
	{
		if(i%3!=0&&i%5!=0)res+=i;
	 } 
	 cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll N,A[200007],B[200007],C[200007],sum=0,D,F,E=0,G=0;
  cin >> N;
  rep(i,N){
    cin >> A[i];
    B[i]=A[i]-i;
    C[i]=A[i]-i;
    sum+=B[i];
  }
  sort(C,C+N);
  D=C[(N-1)/2];
  F=C[N/2];
  rep(i,N){
    E+=abs(B[i]-D);
    G+=abs(B[i]-F);
  }
  cout << min(E,G) << endl;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

const int MOD=1e8+7;

int ncr(int n,int r)
{
	static int memo[2001][2001];
	if(memo[n][r]==0){
		if(r==0 || r==n)
			memo[n][r]=1;
		else
			memo[n][r]=(ncr(n-1,r-1)+ncr(n-1,r))%MOD;
	}
	return memo[n][r];
}

int main()
{
	for(int r,c,a1,a2,b1,b2;cin>>r>>c>>a1>>a2>>b1>>b2;){
		int v1=abs(b1-a1),v2=r-v1; if(v1>v2) swap(v1,v2);
		int h1=abs(b2-a2),h2=c-h1; if(h1>h2) swap(h1,h2);
		int res=ncr(v1+h1,v1);
		if(v1==v2) (res*=2)%=MOD;
		if(h1==h2) (res*=2)%=MOD;
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 8524
#include <stdio.h>

int main()
{

    int a;
    int sum;
    int be;


    scanf("%d", &a);
    be = a;
    sum = be;

    for (int i = 0; i < 2; i++)
    {
        be=be *a;
        sum += be;
    }

        printf("%d\n",sum);
    
    


   
}

Measured memory_bytes: 2180
#include <stdio.h>

int main(void)
{
	int n;
	int flag = 0;
	
	while (scanf("%d", &n) != EOF){
		int soroban[5][6];
		int i, j;
		
		if (flag != 0){
			puts("");
		}
		else {
			flag = 1;
		}
		for (i = 0; i < 5; i++){
			int t = n % 10;
			
			soroban[i][0] = t / 5;
			for (j = 1; j <= t % 5; j++){
				soroban[i][j] = 1;
			}
			soroban[i][j] = 0;
			for (j++; j < 6; j++){
				soroban[i][j] = 1;
			}
			n /= 10;
		}
		for (i = 0; i < 2; i++){
			for (j = 4; j >= 0; j--){
				putchar(soroban[j][0] == i ? '*' : ' ');
			}
			puts("");
		}
		puts("=====");
		for (i = 0; i < 5; i++){
			for (j = 4; j >= 0; j--){
				putchar(soroban[j][i + 1] == 1 ? '*' : ' ');
			}
			puts("");
		}
	}
	
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	int A[N];
	rep(i,N) cin >> A[i];
	int num = 0;
	int ans = 0;
	rep(i,N){
		if(num < A[i]){
			num = A[i];
		}
		else{
			ans += num - A[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5204
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  ll n,C;
  cin>>n>>C;
  vec(s,n);vec(t,n);vec(c,n);
  mat(T,100001,30);
  
  rep(i,n){
    cin>>s[i]>>t[i]>>c[i];
    T[--s[i]][c[i]-1]++;
    T[t[i]][c[i]-1]--;
  }
  ll ans=0;
  ll tmp=0;
  
  rep(j,30){
    tmp=0;
    rep(i,100001){
      if(tmp==2&&T[i][j]==-1){
        T[i][j]=0;
        tmp=1;
      }
      tmp+=T[i][j];
      if(tmp==2){T[i][j]=0;}
    }
  }
  
 tmp=0;
  rep(i,100001){
    rep(j,30){
      tmp+=T[i][j];
      
    }
    ans=max(ans,tmp);
  }
  op(ans);

  return 0;
}

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

int gcd(int a, int b){
    int v0 = a, v1 = b, v2 = v0 % v1;
    while(v2 > 0){
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    }
    return v1;
}

int main() {
    int K;
    cin>>K;
    int DP[K+1][K+1];
    for(int i=1;i<=K;++i){
        for(int j=1;j<=K;++j){
            DP[i][j] = gcd(i, j);
        }
    }
    long ans = 0;
    for(int i=1;i<=K;++i){
        for(int j=1;j<=K;++j){
            for(int k=1;k<=K;++k){
                ans += DP[DP[i][j]][DP[k][i]];
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3784
#include <stdio.h>
int main()
{
	int A,B,C,D,E,F;
	A = 500;
	scanf("%d", &B);
	scanf ("%d", &C);
	D = B/500;
	E = D*500;
	F = B-E;
	if (C-F>=0){
		printf ("Yes");
	} else {
		printf ("No");
	} return 0;
}

Measured memory_bytes: 128
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=400010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,a[N],res,mi=1e18;
signed main()
{
    n=read();
    int pp=1;
    for(ri int i=1;i<=n;i++)
    {
        int x=read();
        res+=x;
        if(x%10) mi=min(mi,x), pp=0;
    }
    if(pp) { puts("0"); return 0; }
    if(res%10) printf("%lld\n",res);
    else printf("%lld\n",res-mi);
    return 0;
}

Measured memory_bytes: 3744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var str = Console.ReadLine().ToArray();
            for (var i = 0; i < str.Length; i++)
            {
                var tmp = str[i];
                str[i] = (char) ((tmp - 'A' + n) % 26 + 'A');
            }

            Console.WriteLine(new string(str));
        }
    }
}

Measured memory_bytes: 27920
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define MOD 1000000007

int N, x;

long* find_biggest(long c[], int size){
  long biggest = 0;
  int index = 0;
  for(int i = 0; i < size; i++){
    if(c[i] > biggest) index = i;
  }
  long *r = new long[2];
  r[0] = index;
  r[1] = biggest;
  return r;
}

int main(int argc, char const *argv[]) {
  int N, x;
  cin >> N >> x;
  int candy[N];
  long count = 0;
  for(int i = 0; i < N; i++){
    cin >> candy[i];
  }
  //bool pass = false;
  if(candy[0] > x){
    count += (candy[0] - x);
    candy[0] = x;
  }
  for(int i = 1; i < N; i++){
    if(candy[i-1]+candy[i] <= x){
      continue;
    }else{
      count += (candy[i-1]+candy[i]-x);
      candy[i] -= (candy[i-1]+candy[i]-x);
    }
  }
  cout << count << endl;
}


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

int n, a[200];

int main(){
  cin >> n;
  rep(i, n){
    cin >> a[i];
  }
  int res = 111111110;
  for(int y = -100; y <= 100; y++){
    int sum = 0;
    rep(i, n){
      sum += pow(abs(a[i] - y), 2);
    }
    res = min(res, sum);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline
MOD = 1000000007

N = int(input())

T = list(map(int,input().split()))

M = int(input())

_all = sum(T)

for _ in range(M):
    p,x = map(int,input().split())
    p-=1

    print(_all - T[p]+x)

Measured memory_bytes: 3064
#include <fstream>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <cassert>
#include <deque>
#include <set>
#include <map>
#include <vector>
#include <regex>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

//#define LOCAL_DEBUG
int main() {
#ifdef LOCAL_DEBUG
	freopen("input1.txt","r", stdin);
#endif
	string S; cin >> S;
	while (S.length() != 0) {
		int len = S.length();
		if (len < 3) break;
		if (S[len - 1] == 'r' && S[len - 2] == 'e') {
			if (S[len - 3] == 'm') {
				S = S.substr(0, len - 2);
				len -= 2;
			}
			else if (S[len - 3] == 's') {
				S = S.substr(0, len - 1);
				len -= 1;
			}
			else {
				break;
			}
		}
		if (len < 5) break;
		string ss = S.substr(len - 5, 5);
		if (ss == "dream" || ss == "erase")
			S = S.substr(0, len - 5);
		else {
			break;
		}
	}

	if (S.length() == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
 	return 0;
}


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

int main() {
  char a, b;
  cin >> a >> b;
  if((a == 'H' && b == 'H')||(a == 'D' && b == 'D'))
    cout << 'H' << endl;
  else
    cout << 'D' << endl;
}

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

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;
const int mxs = 1e6 + 10;

vector<bool> pr(mxs, true);
vector<int> prn;
unordered_map<int, int> mp;

void sieve(int n){
    for(int i = 2; (ll) i * i <= n; i++){
        if(pr[i]){
            for(ll j = i * i; j <= n; j += i){
                pr[j] = false;
            }
        }
    }
}
unordered_map<int, int> fint(int n){
    unordered_map<int, int> res;
    int p = 0;
    for(auto x : prn){
        if((ll) x * x > n) break;
        while(n % x == 0){
            p++;
            n /= x;
        }
        res[x] = p;
        p = 0;
    }
    if(n > 1) res[n]++;
    return res;
}

ll add(ll a, ll b){
    return (a + b) % mod;
}

ll mul(ll a, ll b){
    return ((a%mod) * (b%mod)) % mod;
}

ll power(ll a, ll p){
    ll res = 1;
    while(p){
        if(p & 1) res = mul(res, a);
        a = mul(a, a);
        p /= 2;
    }
    return res;
}

ll inv(ll a){
    return power(a, mod - 2);
}

ll _div(ll a, ll b){
    return mul(a, inv(b));
}

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int mx = -1;
    for(int i = 0; i < n; i++){
        cin>>a[i];
        mx = max(mx, a[i]);
    }
    unordered_map<int, int> pp;
    sieve(mx + 1);
    for(int i = 2; i < mx + 1; i++){
        if(pr[i]){
            prn.push_back(i);
            pp[i] = 0;
        }
    }
    // cout<<prn.size()<<endl;
    vector<int> res(prn.size());
    for(auto x : a){
        auto y = fint(x);
        for(auto xx : y){
            pp[xx.first] = max(pp[xx.first], xx.second);
        }
        // for(int i = 0; i < (int) prn.size(); i++){
        //     res[i] = max(res[i], y[prn[i]]);
        // }
    }
    ll lcm = 1;
    for(auto x : pp){
        lcm = mul(lcm, power(x.first, x.second));
    }
    // for(int i = 0; i < (int) prn.size(); i++){
    //     lcm = mul(lcm, power(prn[i], res[i]));
    // }
    ll ans = 0;
    for(auto x : a){
        ans = add(ans, _div(lcm, x));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4508
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {
        private void solve(InputReader inp, PrintWriter out) {
            int n = inp.nextInt(), k = inp.nextInt();
            int[] h = new int[n];
            for (int i = 0; i < n; i++) h[i] = inp.nextInt();

            int[] dp = new int[n];
            Arrays.fill(dp, Integer.MAX_VALUE);

            dp[0] = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 1; j <= k; j++)
                    if (i + j < n) {
                        dp[i + j] = Math.min(dp[i + j], dp[i] + Math.abs(h[i] - h[i + j]));
                    }
            }
            out.print(dp[n-1]);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32328
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main(){
  /*int t;
  cin >> t;
  for (int j = 0; j < t; j++){*/
  int n,r;
  cin >>n>>r ;
  if (n >= 10) cout << r << "\n";
  else cout << r + 100*(10-n) << "\n";
      
  //}
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 10 ** 10
    
    for i in range(-100, 101):
        tmp = 0
        for ai in A:
            x = (ai - i) ** 2
            tmp += x
        ans = min(ans, tmp)
        # print(ans)

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int n; cin >> n;
    vector<string> s(n);
    REP(i,n) cin >> s[i];
    ll c0=0,c1=0,c2=0,c3=0;
    REP(i,n) if(s[i] == "AC") c0++;
    REP(i,n) if(s[i] == "WA") c1++;
    REP(i,n) if(s[i] == "TLE") c2++;
    REP(i,n) if(s[i] == "RE") c3++;
    
    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
}

Measured memory_bytes: 6428
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        sc.close();

        boolean[] ans = new boolean[n];
        boolean[] ani = new boolean[n];
        for(int i=0; i<n; i++){
            ans[i] = s.charAt(i) == 'o';
        }

        ani[0] = true;
        ani[1] = true;
        if(setAndCheck(n, ans, ani)){
            print(n, ani);
            return;
        }

        ani[0] = true;
        ani[1] = false;
        if(setAndCheck(n, ans, ani)){
            print(n, ani);
            return;
        }

        ani[0] = false;
        ani[1] = true;
        if(setAndCheck(n, ans, ani)){
            print(n, ani);
            return;
        }

        ani[0] = false;
        ani[1] = false;
        if(setAndCheck(n, ans, ani)){
            print(n, ani);
            return;
        }

        System.out.println(-1);
    }

    static boolean setAndCheck(int n, boolean[] ans, boolean[] ani){
        boolean ret = true;
        for(int i=1; i<n-1; i++){
            if(ani[i] == ans[i]){
                ani[i+1] = ani[i-1];
            }else{
                ani[i+1] = !ani[i-1];
            }
        }

        if(ani[0] == ans[0]){
            ret = ani[1] == ani[n-1];
        }else{
            ret = ani[1] != ani[n-1];
        }
        if(!ret) return false;

        if(ani[n-1] == ans[n-1]){
            ret = ani[n-2] == ani[0];
        }else{
            ret = ani[n-2] != ani[0];
        }

        return ret;
    }

    static void print(int n, boolean[] ani){
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<n; i++){
            if(ani[i]){
                sb.append('S');
            }else{
                sb.append('W');
            }
        }
        System.out.println(sb.toString());
    }
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

std::string s;
int x, y;

int main() {
    std::cin >> s;
    std::cin >> x >> y;

    int ssize = s.size();

    VI advX, advY;
    advX.reserve(ssize);
    advY.reserve(ssize);
    
    bool f = true;
    int cnt = 0;
    for(char c: s) {
        if(c == 'F') {
            ++cnt;
        } else {
            if(cnt > 0) {
                if(f) {
                    advX.pb(cnt);
                } else {
                    advY.pb(cnt);
                }
            }
            cnt = 0;
            f = !f;
        }
    }
    if(cnt != 0) {
        if(f) {
            advX.pb(cnt);
        } else {
            advY.pb(cnt);
        }
    }

    std::set<int> dpx;
    if(s[0] == 'T') {
        dpx.insert(0);
        for(int i=0; i<advX.size(); ++i) {
            std::set<int> next;
            for(auto xx:dpx) {
                next.insert(xx + advX[i]);
                next.insert(xx - advX[i]);
            }
            dpx = next;
        }
    } else {
        dpx.insert(advX[0]);
        for(int i=1; i<advX.size(); ++i) {
            std::set<int> next;
            for(auto xx:dpx) {
                next.insert(xx + advX[i]);
                next.insert(xx - advX[i]);
            }
            dpx = next;
        }
    }

    std::set<int> dpy;
    dpy.insert(0);
    for(int i=0; i<advY.size();++i) {
        std::set<int> next;
        for(auto yy:dpy) {
            next.insert(yy + advY[i]);
            next.insert(yy - advY[i]);
        }
        dpy = next;
    }

    bool res = (dpx.count(x) != 0) && (dpy.count(y) != 0);
    std::cout << (res ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 768
#include<stdio.h>
 
int main(){
    int n,i,j,k=1,cnt,d[10][10];
 
    while(scanf("%d",&n),n){
        cnt=1;
        for(i=0;i<n*2;i++){
            if(i%2){
                for(j=0;j<n;j++){
					if(!(0<=i-j&&i-j<n))continue;
                    d[j][i-j]=cnt++;
                }
            }else{
                for(j=n-1;j>=0;j--){
					if(!(0<=i-j&&i-j<n))continue;
                    d[j][i-j]=cnt++;
                }
            }
            if(n*n<cnt)break;
        }
        printf("Case %d:\n",k++);
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                printf("%3d",d[i][j]);
            }
            puts("");
        }
    }
    return 0;
}

Measured memory_bytes: 620
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int d, r;
    double f;
    d = a / b;
    r = a % b;
    f = 1.00000 * a / b;
    cout << d << " " << r << " " ;
    //<< f << endl;
    printf("%.5f\n",f);
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 404;
const ll inf = 1e18;

int n;
ll a[maxn];
ll acc[maxn];

ll sum(int l, int r) {
    assert(l<=r);
    ll res=acc[r];
    if (l) res-=acc[l-1];
    return res;
}

ll dp[maxn][maxn];


ll solve(int l, int r) {
    assert(l<=r);
    if (l==r) return 0;
    if (l+1==r) return sum(l,r);
    if (~dp[l][r]) return dp[l][r];

    ll &res=dp[l][r]=inf;

    for (int i=l; i<r; i++) {
	res=min(res, solve(l,i)+solve(i+1,r));
    }

    res += sum(l,r);
    return res;
}
		       


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

    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }
    for (int i=0; i<n; i++) {
	acc[i]=a[i];
	if (i) acc[i]+=acc[i-1];
    }

    memset(dp,-1,sizeof(dp));
    cout<<solve(0,n-1)<<endl;
    
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 x(n);
  cin >> x;
  auto sx = x;
  sort(all(sx));
  rep(i, n) {
    if (x[i] <= sx[n / 2 - 1]) {
      cout << sx[n / 2] << '\n';
    } else {
      cout << sx[n / 2 - 1] << '\n';
    }
  }
}


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

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() {
  int a, b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,c=0,t=0,b,s=0,f,g,d=0,x=0;
    cin>>n;
    ll a[n+10];
    for(int i = 0;i < n;i++)
    {
        cin>>a[i];
        s += a[i];
    }

    f = ceil(s*1.0/n);
    //cout<<f<<endl;
    g = (s/n);
    //cout<<g<<endl;


    for(int i = 0;i < n;i++)
    {
        t = abs(f-a[i]);
        t = t*t;
        c += t;
        //cout<<c<<endl;
    }
    for(int i = 0;i < n;i++)
    {
        d = abs(g-a[i]);
        d = d*d;
        x += d;
        //cout<<c<<endl;
    }
    cout<<min(c,x)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
const int MAXN=1e6+10;
ll fac[MAXN],inv[MAXN];
ll n,sum;
void init()
{
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=(fac[i-1]*(ll)i)%mod;
	inv[0]=inv[1]=1;
	for (int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;	
	for (int i=2;i<=n;i++) inv[i]=(inv[i-1]*inv[i])%mod;
}
ll C(int x,int y)
{
	if (x<0||y<0||x<y) return 0;
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
	scanf("%lld",&n);
	init();
	ll ans=0;
    for (int i=1;i<n;i++)
    	 ans=(ans+(ll)i*((C(i-1,n-1-i)*fac[i]%mod*fac[n-1-i]%mod-C(i-2,n-i)*fac[i-1]%mod*fac[n-i]%mod+mod)%mod)%mod)%mod;
    cout << ans << endl; 
}

Measured memory_bytes: 15872
#coding: euc-jp
class Main
  def self.main
    h = {'A' => 'T', 'T' => 'A', 'G' => 'C', 'C' => 'G',}
    ins = read
    puts h[ins]
  end

  def self.read
    gets.chomp
  end
end

Main.main


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

int main() {

  int K, N;
  cin >> K >> N;

  vector<long long> A(N * 2);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      A[i + N] = K + A[i];
    } else {
      A[i + N] = A[i] + K; 
    }
  }

  vector<long long> D(N * 2 + 1);

  for (int i = 0; i < N * 2; i++) {
    if (i == 0) {
      D[0] = 0;
    } else {
      D[i] = A[i] - A[i - 1] + D[i - 1];
    }
  }

  long long answer = 1LL<<60;

  for (int i = 0; i < N; i++) {
    long long d  = D[i + N - 1] - D[i];
    answer = min(answer, d);
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 6528
using System;

class Program{
	static void Main(){
	int N,K;
      int c=1;
		N = int.Parse(Console.ReadLine());
      K=int.Parse(Console.ReadLine());
      for(int i=0;i<N;i++){
      if(c<K)c*=2;
        else c+=K;
      }
      Console.WriteLine(c+"\n");
	}
}

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

int main() {
  int N,A,B;
  A=1000000000;
  B=0;
  cin >> N;
  int a[N];
  for(int i=0; i<N; i++) {
    cin >> a[i];
  }
  for(int i=0; i<N; i++) {
    if(A>a[i]) {
      A=a[i];
    }
    if(B<a[i]) {
      B=a[i];
    }
  }
  cout << B-A << endl;
}
  
  


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    at = sum(A)
    if at >= N:
        print("Yes")
    else:
        print("No")
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 11604
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_v = max(dic.values())
ans = []
for k,v in dic.items():
    if v == max_v:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

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

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

int main(){
  int a, b;
  cin >> a >> b;
  string sa, sb;
  rep(i, b) sa += to_string(a);
  rep(i, a) sb += to_string(b);
  if (sa < sb) cout << sa << endl;
  else cout << sb << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int A, B, O, AB;
	public static void main(String[] args) {
		while(read()){

		}
		solve();
	}
	
	static boolean read(){
		if(!sc.hasNext())return false;
		
		String[] s = sc.next().split(",");
		
		if(s[1].equals("A")){
			A++;
		}else if(s[1].equals("B")){
			B++;
		}else if(s[1].equals("AB")){
			O++;
		}else if(s[1].equals("O")){
			AB++;
		}
		return true;
	}
	
	static void solve(){
		System.out.println(A);
		System.out.println(B);
		System.out.println(O);
		System.out.println(AB);
	}

}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define test int t; cin >> t; while (t--)
#define fast ios::sync_with_stdio(NULL); cin.tie(NULL)
#define mod 1000000007
#define endl "\n"
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/GCD(m,n))
#define all(v) v.begin(),v.end()
#define ll long long
typedef vector<ll> vecll;
typedef vector<int> veci;
typedef vector<char> vecc;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define time 1.0 * clock() / CLOCKS_PER_SEC


int main(){
    fast;
    // test{
    //     ll n,s=0;cin>>n;
    //     vecll a(n);
    //     set <ll> se;
    //     for(auto &x:a){cin>>x;s+=x;se.insert(x);}
    //     vecll pra,prb;
    //     pra.pb(a[0]),prb.pb(s);
    //     for(int i=1;i<n;i++){
    //         pra.pb(a[i]+pra[i-1]);
    //         prb.pb(prb[i-1]-a[i-1]);
    //     }
    //     ll c=0,z=1;
    //     for(auto x:se){
    //         if(x!=z){c=1;break;}
    //         z++;
    //     }
    //     if(c)cout<<0<<endl;
    //     else{
    //         vecll ans;
    //         for(int i=0;i<n-1;i++){
    //             if(s-pra[i] == ((n-i)*(n-i-1))/2 and pra[i]==((i+1)*(i+2))/2){ans.pb(i+1);}
    //         }   
    //         for(int i=n-1;i>=0;i--){
    //             if(s-prb[i] == ((n-i)*(n-i-1))/2 and prb[i]==((i+1)*(i+2))/2){ans.pb(i+1);}
    //         }
    //         cout<<ans.size()<<endl;
    //         for(auto x:ans)cout<<x<<" "<<n-x<<endl;
    //     }


    // }
    ll n,sum=0;cin>>n;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            for(int k=1;k<=n;++k){
                sum+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<sum;
    return 0;
}


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

int main() {


  string n;

  while(1) {
    cin >>n;
    
    int flg = 0;
    for(int i=0;i<4;i++) if(n[i] != '0') flg =1;
    if(flg == 0) break;
    
    int a[4];
    for(int i=0;i<4;i++) a[i] = n[i]-'0';
    int N=0;
    int t =1;
    for(int i=0;i<4;i++) N += a[3-i]*t,t*=10;
    int ans = 0;
    while(1) {
      if( N == 6174 || ans > 10000) break;
      ans++;
      sort(a,a+4);
      int maxn = 0;
      int minn = 0;
      t = 1;
      for(int i=0;i<4;i++) {
	maxn += a[i] * t;
	minn += a[3-i] * t;
	t*=10;
      }
      
      N = maxn - minn;
      t = N;
      for(int i=0;i<4;i++) a[i] = t%10, t/=10;
    }
    if(ans > 10000) cout <<"NA"<<endl; 
    else     cout << ans << endl;
  }

    
    return 0;    
    
    
}

Measured memory_bytes: 1200