akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    string S, T;
    cin >> S >> T;
    ll n = S.size(), m = T.size(), i, j, ans = 1e5;
    rep(i,0,n-m+1){
        ll c = 0,i1 = i;
        rep(j,0,m){
            if(T[j] != S[i1])c++;
            i1++;
        }
        ans = min(ans,c);
    }
    cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



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

	ll h, w;
	cin >> h >> w;
	ll k; cin >> k;
	vector<string> s(h);
	rep(i, h)
	{
		cin >> s[i];
	}

	ll bith = (1LL << h) - 1LL;
	ll bitw = (1LL << w) - 1LL;

	ll ans = 0;

	for (ll i = 0; i <= bith; i++)
	{
		for (ll j = 0; j <= bitw; j++)
		{
			ll cnt = 0;
			ll tmph = i;
			ll hh = 0;
			ll tmpw = j;
			ll ww = 0;
			vector<string> ss = s;

			while (tmph)
			{
				if(tmph&1)
					for (ll k = 0; k < w; k++)
					{
						ss[hh][k] = 'r';
					}
				tmph >>= 1;
				hh++;
			}
			while (tmpw)
			{
				if(tmpw&1)
					for (ll k = 0; k < h; k++)
					{
						ss[k][ww] = 'r';
					}

				tmpw >>= 1;
				ww++;
			}

			for (ll ii = 0; ii < h; ii++)
			{
				for (ll jj = 0; jj < w; jj++)
				{
					if (ss[ii][jj] == '#')
						cnt++;
				}
			}
			if (cnt == k)
				ans++;

		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3640
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(0,A+1):
    Xa  = X - 500*a
    if Xa < 0:
        break
    for b in range(0,B+1):
        Xab = Xa - 100*b
        if Xab < 0:
            break
        for c in range(0,C+1):
            Xabc = Xab - 50*c
            if Xabc == 0:
                count += 1
                break
                
print(count)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cctype>
#include <queue>
using namespace std;

int read() {
	int x=0; char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=x*10+c-'0', c=getchar();
	return x;
}
int buf[42];
void write(long long n) {
	if(!n) { putchar('0'); return; }
	memset(buf, 0, sizeof(buf));
	int index=0;
	while(n) buf[++index]=n%10, n/=10;
	while(index>=1) putchar(buf[index--]+'0');
	return;
}
priority_queue <int> pq;

int main() {
	int n=read(), m=read();
	for(int i=0; i<n; i++) {
		int x=read();
		pq.push(x);
	}
	while(m--) {
		int maxi=pq.top(); pq.pop();
		pq.push(maxi>>1);
	}
	long long sum=0;
	while(pq.empty()==0) sum+=pq.top(), pq.pop();
	write(sum);
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N, D;
    cin >> N >> D;

    cout << ((N + (2*D+1) - 1) / (2*D+1)) << endl;


    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a,bbb=b;i<=bbb;++i)
#define repd(i,a,b) for(register int i=a,bbb=b;i>=bbb;--i)
#define reps(s) for(register int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define gmn(a,b) a=min(a,b)
#define gmx(a,b) a=max(a,b)
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
typedef long long ll;
typedef double db;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
//start!
int cnt;
int Get_Divisor(int n)
{
	cnt=0;
	for(int i=1;1ll*i*i<=n;i++)if(n%i==0){
		cnt++;
		if(i*i!=n) cnt++;
	}
	return cnt;
}
int main()
{
	ll ans=0;
	int n=qi();
	repi(i,1,n-1){
		int now=n-i;
		ans+=Get_Divisor(now);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3768
<?php 
fscanf(STDIN, "%d", $n);
$a = fgets(STDIN);
$b = fgets(STDIN);
$c = fgets(STDIN);

$aArr = explode(" ", $a);
$bArr = explode(" ", $b);
$cArr = explode(" ", $c);

$point = 0;
$prev = "";

foreach ($aArr as $num) {
  $point = $point + $bArr[$num-1];
  if($prev+1 == $num){
    $point = $point + $cArr[$num-2];
  }
  $prev = $num;
}
echo $point;
?>

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

int main() {

  int N;
  cin >> N;

  string S;
  vector<string> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> S;
    sort(S.begin(),S.end());
    vec.at(i) = S;
  }

  sort(vec.begin(), vec.end());

  long long ans = 0;
  int ctr = 0;

  for (int i = 1; i < N; i++) {
    if(vec.at(i - 1) == vec.at(i)) {
      ctr ++;
      ans += ctr;
    }
    else {
      ctr = 0;
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define endl "\n"
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=1e6+4;

int fa[N];

int main()                  
{
	int n; scn(n);

	int a[n+1];

	rep(i,1,n+1)
	scn(a[i]),fa[a[i]]++;

	for(int i=1;i<N;i++)
	{
		for(int j=2*i;j<N;j+=i)
		fa[j]+=fa[i];
	}

	int ans=0;

	rep(i,1,n+1)
	if(fa[a[i]]==1)
	ans++;

	pri(ans);
} 

Measured memory_bytes: 8408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;

int main() {

	ll n;
	cin >> n;
	ll m;
	cin >> m;
	vector<ll> a(m);
	rep(i, m) cin >> a.at(i);

	ll sum = 0;
	rep(i, m) {
		sum += a.at(i);
	}
	ll ans = n - sum;
	if (ans < 0) {
		cout << -1 << endl;
	}
	else if (ans == 0) {
		cout << ans << endl;
	}
	else {
		cout << ans << endl;
	}

   
	return 0;
	
}



Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
using namespace std;

int main(){
  string s;
  cin >> s;
  string t;
  cin >> t;
  bool f = true;
  if(s.size() != t.size()){
    if(s.size() > t.size()){
      cout << "GREATER" << endl;
      f = false;
    }
    else{
      cout << "LESS" << endl;
      f = false;
    }
  }
  else{
    for(int i = 0; i < s.size(); i++){
      if(s[i] > t[i]){
        cout << "GREATER" << endl;
        f = false;
        break;
      }
      if(s[i] < t[i]){
        cout << "LESS" << endl;
        f = false;
        break;
      }
    }
  }
  if(f){ cout << "EQUAL" << endl;}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define   LF      '\n'
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;


signed main()
{
  int N;
  int a[105];
  int ans = 0;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    ans += a[i];
  }

  sort(a, a+N);
  ans -= a[N-1];
  ans += a[N-1] / 2;

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 256
import sys
lst=[]
for i in range(3):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
for i in range(2):
  for j in range(2):
    if (lst[i][j+1]-lst[i][j])!=(lst[i+1][j+1]-lst[i+1][j]) or (lst[j+1][i]-lst[j][i])!=(lst[j+1][i+1]-lst[j][i+1]):
      print('No')
      sys.exit()
print('Yes')


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
int main(){
    int N;
    cin >> N;
    int sum = 0, count ,cnt=0;
    for(int i=0;i<N;i++){
        sum += (i+1);
        cnt++;
        if(sum>=N){
            break;
        }
    }
    count = sum - N;
    for(int i=0;i<cnt;i++){
        if(i+1!=count){
            cout << i+1 << endl;
        }
    }
}

Measured memory_bytes: 256
def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())

    N *= 4

    cost = [Q, H, S, D]
    # cost[pow] = 最小費用
    # Q:1=2**0
    # H:2=2**1
    # S:4=2**2
    # D:8=2**3

    for pow_i in range(3, 0, -1):
        cost[pow_i] = min(
            cost[pow_j] * (1 << (pow_i - pow_j))
            for pow_j in range(pow_i, -1, -1))

    ret = 0
    for pow in range(3, -1, -1):
        coef, N = divmod(N, 1 << pow)
        ret += coef * cost[pow]
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
   long long int a, n, i=1, max, min, sum;
    
    cin>> a >> n;
    sum=0;
    max=n;
    min=n;
    for (i=1;i<=a;i++)
    {
        sum=sum+n;
        if (n<min)
        {
        min=n;
        }
        if (n>max)
        {
            max=n;
        }
        cin >> n;
    }
     cout << min << " " << max  << " " << sum<< endl;
}


Measured memory_bytes: 3116
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List

-- [a,b) -> a .. f aがTrueとなる最大のa, f bはFalse
-- aとbは評価しないので、範囲が0..(n-1)のとき、(a,b)=(-1,n)で呼んで良い
bsearch f (a,b)
    | a+1 == b = a
    | f m  = bsearch f (m,b)
    | True = bsearch f (a,m)
    where m = (a + (b-a)`div`2)

f x a = ((a+1)`div`2 * 6 + a`div`2 * 5) < x

main=do
    x<-readLn::IO Int
    print $ (+) 1 $ bsearch (f x) (-1, 1000000000000000)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5+1;

int n, k;
V<pll> v;
V<ll> v2, v3;
ll s2[N], s3[N];
bool y[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n){
    int t, d;
    cin >> t >> d;
    t--;
    v.pb(mp(d, t));
  }
  sort(all(v), greater<pll>());
  for(pll a:v){
    if(!y[a.se]){
      y[a.se] = true;
      v2.pb(a.fi);
    }else{
      v3.pb(a.fi);
    }
  }
  FOR(i, 0, sz(v2)) s2[i+1] += s2[i] + v2[i];
  FOR(i, 0, sz(v3)) s3[i+1] += s3[i] + v3[i];
  int mink = max(0, k-sz(v3)), maxk = min(k, sz(v2));
  ll ans = 0;
  for(ll i = mink; i <= maxk; i++) maxs(ans, i*i + s2[i] + s3[k-i]);
  cout << ans << endl;
}

Measured memory_bytes: 4592
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <set>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

void solve(int test, istream &in) {
    int64_t n;
    in >> n;
    int sq = sqrt(n) + 0.5;
    vector<int> p, e;
    for (int i = 2; i <= sq; i++) {
        if (n % i == 0) {
            p.push_back(i);
            e.push_back(0);
            do {
                e.back() += 1;
                n /= i;
            } while (n % i == 0);
            sq = sqrt(n) + 0.5;
        }
    }
    if (n != 1) {
        p.push_back(n);
        e.push_back(1);
        n = 1;
    }
    int result = 0;
    for (int i = 0; i < p.size(); i++) {
        int k = 1;
        while (k * (k + 1) / 2 <= e[i])
            k++;
        k--;
        result += k;
    }
    printf("%d", result);
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
    ifstream f("in.txt");
#else
    istream &f = cin;
#endif
    int tests = 1;
    //f >> tests;
    for (int test = 0; test < tests; test++) {
        solve(test, f);
    }

    return 0;
}


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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x;
    cin>>x;
    for(int i=0;i<=1000;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(pow(i,5)-pow(j,5)==x)
            {
                cout<<i<<" "<<j<<endl;
                return 0;
            }
            else if(pow(i,5)+pow(j,5)==x)
            {
                cout<<i<<" "<<-j<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)(1 << 19);

int n, a[N];
set <pair <int, int> > dp[N];
set <pair <int, int> > cur;

set <pair <int, int> > Merge(set <pair <int, int> > a, set <pair <int, int> > b)
{
	cur.clear();
	for(auto to : a) cur.insert(mp(-to.F, to.S));
	for(auto to : b) cur.insert(mp(-to.F, to.S));
	a.clear();
	int cnt = 0;
	for(auto to : cur)
	{
		if(cnt == 2) break;
		a.insert(mp(-to.F, to.S));
		cnt++;
	}
	return a;
}                 

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	cin >> n;
	for(int i = 0; i < (1 << n); i++) cin >> a[i], dp[i].insert(mp(a[i], i));
	for(int mask = 0; mask < (1 << n); mask++)
		for(int i = 0; i < n; i++)	
			if((mask >> i) & 1) dp[mask] = Merge(dp[mask], dp[mask ^ (1 << i)]);
	int maxi = 0;
	for(int i = 1; i < (1 << n); i++) 
	{
		pair <int, int> v1 = *dp[i].begin();
		pair <int, int> v2 = *dp[i].rbegin();
		maxi = max(maxi, v1.F + v2.F);
		cout << maxi << '\n';
	}
}      

Measured memory_bytes: 54272
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int p, d, c;
  cin >> p >> d >> c;
  vector<int> e(p);
  rep(i, p) cin >> e.at(i);
  
  int ans = 0;
  repm(i, 1, d + 1){
    rep(j, p){
      if (i % e.at(j) == 1 || e.at(j) == 1) c++;
    }
  }
  ans = c;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int N;
	cin >> N;
	int A[N],ans[N];
	long long sum=0;
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	ans[0]=0;
	for(int i=1;i<N;i++){
		if(A[i-1]+ans[i-1]>A[i]){
			ans[i]=(A[i-1]+ans[i-1])-A[i];
		}
		else{
			ans[i]=0;
		}
	}
	for(int i=1;i<N;i++){
		sum+=ans[i];
	}

	cout << sum;
	
	return 0;
}

Measured memory_bytes: 5148
//Score	620
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
int n, m, p, MOD;
lint pow2[2505], ans;
inline int ask(int x1, int y1, int x2, int y2) {
	cout << "? " << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
	int ret = 0; cin >> ret; return ret;
}
inline int siz(int x1, int y1, int x2, int y2) {
	return (x2 - x1 + 1) * (y2 - y1 + 1);
}
inline void search(int x1, int y1, int x2, int y2, int las) {
	if (x1 == x2 && y1 == y2) {
		ans = (ans + pow2[x1 * m + y1]) % MOD;
	} else if (x2 - x1 < y2 - y1) {
		int mid = (y1 + y2) >> 1;
		int a1 = ask(x1, y1, x2, mid);
		int a2 = las - a1;
		if (a1) {
			if (a1 == siz(x1, y1, x2, mid)) {
				rep (i, x1, x2) {
					rep (j, y1, mid) {
						search(i, j, i, j, 1);
					}
				}
			} else {
				search(x1, y1, x2, mid, a1);
			}
		}
		if (a2) {
			if (a2 == siz(x1, mid + 1, x2, y2)) {
				rep (i, x1, x2) {
					rep (j, mid + 1, y2) {
						search(i, j, i, j, 1);
					}
				}
			} else {
				search(x1, mid + 1, x2, y2, a2);
			}
		}
	} else {
		int mid = (x1 + x2) >> 1;
		int a1 = ask(x1, y1, mid, y2);
		int a2 = las - a1;
		if (a1) {
			if (a1 == siz(x1, y1, mid, y2)) {
				rep (i, x1, mid) {
					rep (j, y1, y2) {
						search(i, j, i, j, 1);
					}
				}
			} else {
				search(x1, y1, mid, y2, a1);
			}
		}
		if (a2) {
			if (a2 == siz(mid + 1, y1, x2, y2)) {
				rep (i, mid + 1, x2) {
					rep (j, y1, y2) {
						search(i, j, i, j, 1);
					}
				}
			} else {
				search(mid + 1, y1, x2, y2, a2);
			}
		}
	}
}
int main() {
	cin >> n >> m >> p >> MOD;
	pow2[0] = 1;
	rep (i, 1, 2500) {
		pow2[i] = pow2[i - 1] * 2 % MOD;
	}
	//search(0, 0, n - 1, m - 1, p);
	for (int i = 0; i < 50; i += 5) {
		for (int j = 0; j < 50; j += 5) {
			search(i, j, i + 4, j + 4, ask(i, j, i + 4, j + 4));
		}
	}
	cout << "! " <<  ans << endl;
	return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int a;
	cin >> a;
	if (a == 3 || a == 5 || a == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int mx;
void solve(vector<int> a,vector<int> b)
{
  vector<int>ans;
  int t = 0;
  for(int i = 0 ; i < mx ; i++ )
    {
      ans.push_back((a[i] + b[i] + t)%10);
      if(a[i] + b[i] + t >= 10)t = 1;
      else t = 0;
    }
  if(t == 1)ans.push_back(1);
  if(ans.size() > 80){
    cout << "overflow" << endl;
  }else {
    for(int i = ans.size()-1 ; i >= 0 ; i-- ){
      cout << ans[i];
    } 
    cout << endl;
  }
}

int main(){
  int n;
  vector<int>ve1,ve2;
  cin >> n;
  while(n--){
    ve1.clear(),ve2.clear();
    string a,b;
    cin >> a >> b;
    mx = max(a.size(),b.size());
    for(int i = a.size()-1,j = 0 ; j < mx ; i--,j++ ){
      if(i < 0 )ve1.push_back(0);
      else ve1.push_back(a[i]-'0');
    }
    for(int i = b.size()-1,j = 0 ; j < mx ; i--,j++ ){
      if(i < 0 )ve2.push_back(0);
      else ve2.push_back(b[i]-'0');
    } 
    solve(ve1,ve2);
  }
  return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 2005;
int h, w, c[MX], ans, e, st[MX], hi[MX];
char s[MX][MX];
bool b[MX][MX];
int main(){
	scanf("%d%d", &h, &w);
	ans = max(h,w);
	rep(i,h) scanf("\n%s", s[i]);
	rep(i,h-1) rep(j,w-1) b[i][j]=!(s[i][j]^s[i+1][j]^s[i][j+1]^s[i+1][j+1]);
	rep(i,h-1){
		e = 0;
		rep(j,w){
			while(c[j]<i || b[c[j]][j]) c[j]++;
			if(e && hi[e-1]>c[j]){
				for(;e && hi[e-1]>c[j]; e--) ans = max(ans,(hi[e-1]-i+1)*(j-st[e-1]+1));
			}else st[e] = j;
			hi[e++] = c[j];
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 8064
while n = gets
if n == nil
  break 
  end
x = n.chomp.to_i
cnt = 0
a = 0
b = 0
c = 0
d = 0
 for a in (0..9)
  for b in (0..9)
    for c in (0..9)
      for d in (0..9)
	  if a+b+c+d == x
	  cnt += 1
	  end
	  end 
    end
  end
 end 
puts cnt
end

Measured memory_bytes: 6100
#include <stdio.h>
int main(){
  long long a,b,x;
  scanf("%lld%lld%lld",&a,&b,&x);
  if(a>0)
    printf("%lld",b/x-(a-1)/x);
  else 
    printf("%lld",b/x+1);
  return 0;
}

Measured memory_bytes: 128
import re

while True :
    n = int(input())
    if n == 0:break
    s = [input() for _ in range(n)]
    stack = []

    for n in reversed(s):
        if re.match("\.*(\+|\*)",n):
            ope = n[-1]
            depth = n.count(".") + 1
            if ope == "+":ans = 0
            else: ans = 1
            for i,a in enumerate(reversed(stack)):
                if re.match("\."*depth+"\d",a):
                    num = int(re.sub("\.*", "", stack.pop()))
                    if ope == "+":
                        ans += num
                    else:
                        ans *= num
            stack.append("."*(depth-1)+str(ans))
        else:
            stack.append(n)
    print(stack[0])


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

const int MOD = 1000000007;

//long long
using ll = long long;

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

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {

int X, Y, Z, K;
cin >> X >> Y >> Z >> K;

vector<ll> A(X), B(Y), C(Z);
REP(i, X) cin >> A.at(i);
REP(i, Y) cin >> B.at(i);
REP(i, Z) cin >> C.at(i);

    sort(all(A));
    sort(all(B));
    sort(all(C));
    reverse(all(A));
    reverse(all(B));
    reverse(all(C));

vector<ll>ans;
REP(i, X)REP(j, Y)REP(k, Z){
    if((i + 1) * (j + 1) * (k + 1) <= K) ans.push_back(A.at(i) + B.at(j) + C.at(k));
        else break;
}
   sort(all(ans));
    reverse(all(ans));
    REP(i, K) print(ans.at(i));

}

Measured memory_bytes: 1404
a,b=map(int,input().split())

def prime_factorization(n):
  if n==1:
    return [1]
  else:
    i=2
    ans=[]
    k=int(n**0.5)+1
    for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
    if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n]

A=prime_factorization(a)
B=prime_factorization(b)
#print(A)
#print(B)

print(len(set(A)&set(B)))



Measured memory_bytes: 9412
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#include <cmath>
#include <cstdlib>
#include <climits>


//#include <stdio.h>
//#include <stdlib.h>


using namespace std;

#define debug false

int main(int argc, char *argv[]){

  int sum = 0;
  char tmp;
  for(int i = 0; i < 3; i++){
    cin >> tmp;
    sum += atoi(&tmp);
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, a[maxn], val, mindiff = 1e9 + 10;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	int Max = *max_element(a + 1, a + n + 1);
	for(int i = 1; i <= n; ++i)
	{
		if(a[i] == Max) continue;
		if(abs(Max / 2 - a[i]) < mindiff)
		{
			mindiff = abs(Max / 2 - a[i]);
			val = a[i];
		}
	}
	printf("%d %d\n", Max, val);
	return 0;
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front 
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}
inline void sortsm(int &x, int &y) {int a = min(x, y), b = max(x, y); checkmin(x, a); checkmax(y, b);}
inline void sortbi(int &x, int &y) {sortsm(x, y); swap(x, y);}

const int maxn=1e5+10;

int n,m;
vi G[maxn],rG[maxn],order;
int dp[maxn];
int color[maxn];

void dfs(int x)
{
	color[x]=1;
	for(auto to : G[x])
	{
		if(color[to]==0)
		{
			dfs(to);
		}
	}
	color[x]=2;
	order.pb(x);
}

void toposort()
{
	for(int i=1;i<=n;i++)
	{
		if(color[i]==0)
		{
			dfs(i);
		}
	}
}

int main() {
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	G[a].pb(b);
    	rG[b].pb(a);
	}
	toposort();
	for(auto now : order)
	{
		for(auto prev : rG[now])
		{
			checkmax(dp[prev],dp[now]+1);
		}
	}
	cout<<*max_element(dp+1,dp+1+n)<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 14588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		System.out.println(N / 3);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

int bom[52][52];
char c[52][52];

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

	string t;

	vector<pair<int, int>> p;

	for (int i = 0; i < h; i++){
		cin >> t;
		for (int j = 0; j < w; j++){
			if(t[j]=='#'){
				p.push_back(make_pair(j, i));
			}
		}
	}

	for (int i = 0; i < p.size(); i++){
		int xi, yi;
		xi = p[i].first+1;
		yi = p[i].second+1;


			bom[xi - 1][yi - 1]++;
			bom[xi - 1][yi]++;
			bom[xi - 1][yi + 1]++;
			bom[xi][yi - 1]++;
			bom[xi][yi + 1]++;
			bom[xi + 1][yi - 1]++;
			bom[xi + 1][yi]++;
			bom[xi + 1][yi + 1]++;
		
	}



	for (int i = 0; i < p.size(); i++){
		c[p[i].first+1][p[i].second+1] = '#';
	}

	for (int i = 1; i < h+1; i++)
	{
		for (int j = 1; j < w+1; j++){
			if(c[j][i]!='#'){
				c[j][i] = '0' + bom[j][i];
			}
		}
	}

	for (int i = 1; i < h+1; i++){
		for (int j = 1; j < w+1; j++){
			cout << c[j][i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main(){
    ll a, b;
    cin >> a >> b;
    int ans = 1;
    while (2 * a <= b){
        ans++;
        a *= 2;
    }
    cout << ans << endl;
}

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

set<string> ids;
bool open = false;
int main(){
  int N,M;
  cin >> N;
  for(int i = 0;i < N;i++){
    string str;
    cin >> str;
    ids.insert(str);
  }
  cin >> M;
  for(int i = 0;i < M;i++){
    string str;
    cin >> str;
    if(ids.find(str) == ids.end()){
      cout << "Unknown " << str << endl;
    }
    else{
      if(open){
	cout << "Closed by " << str << endl;
      }
      else{
	cout << "Opened by " << str << endl;
      }
      open = !open;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
import sys
from collections import defaultdict
from heapq import heappush, heappop
from operator import itemgetter

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    td = [list(map(int, rl().split())) for _ in range(N)]
    
    td.sort(key=itemgetter(1), reverse=True)
    hq = []
    counter = defaultdict(int)
    t_set = set()
    d_sum = 0
    for i in range(K):
        ti, di = td[i]
        t_set.add(ti)
        counter[ti] += 1
        if 1 < counter[ti]:
            heappush(hq, di)
        d_sum += di
    
    ans = d_sum + len(t_set) * len(t_set)
    for i in range(K, N):
        ti, di = td[i]
        if ti in t_set:
            continue
        if not hq:
            break
        dj = heappop(hq)
        d_sum -= dj
        d_sum += di
        t_set.add(ti)
        ans = max(ans, d_sum + len(t_set) * len(t_set))
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 73308
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    cin>>n;
    vector< pair<int,int> > r(n),b(n);
    for(i=0;i<n;i++){cin>>r[i].second>>r[i].first;}
    for(i=0;i<n;i++){cin>>b[i].first>>b[i].second;}
    sort(r.begin(),r.end());
    sort(b.begin(),b.end());
    vector<int> a(n);
    int mj,ans=0;
    for(i=0;i<n;i++)
    {
        bool f=false;
        for(j=0;j<n;j++)
        {
            if(r[j].second<b[i].first&&r[j].first<b[i].second)
            {
                if(a[j]==0)
                {
                    f=true;
                    mj=j;
                }
            }
        }
        if(f)
        {ans++;a[mj]=1;}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

k, n = MAP()
a = LIST()
d = [a[i + 1] - a[i] for i in range(n - 1)]
d.append(a[0] + k - a[-1])
print(k - max(d))

Measured memory_bytes: 104608
n = int(input())

twoes = [0]
fives = [0]

if n % 2 == 1:
    print(0)
else:
    i = 0
    while 1:
        if n // (2 ** (i +1)) != 0:
            twoes.append(n // (2 ** (i + 1)))
            i += 1
        else:
            break
    i = 0
    while 1:
        temp5 = (n // (5** (i +1))) //2
        if temp5 != 0:
            fives.append(temp5)
            i += 1
        else:
            break
    print(min(sum(twoes), sum(fives)))    

Measured memory_bytes: 9108
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main() {
    vector<bool> good(100, false);
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            good[i * j] = true;
        }
    }
    int n;
    scanf("%d", &n);
    printf("%s\n", good[n] ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l=a+b, r=c+d;

    if(l>r) cout << "Left" << endl;
    else if(l<r) cout << "Right" << endl;
    else if(l=r) cout << "Balanced" << endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
uf = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)

#print(uf.parents)
print(uf.group_count()-1)



Measured memory_bytes: 75372
n=int(input())
a=list(map(int,input().split()))
print(" ".join(map(str,a)))
for i in range(1,n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    print(" ".join(map(str,a)))


Measured memory_bytes: 5596
import sys
input = sys.stdin.readline
class UnionFind(object):
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.rank = [0]*size
    def find(self, x):
        if self.parent[x] == x:
            return x
        # path compression
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    
    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        # union by rank
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

if __name__ == "__main__":
    N = int(input())
    vs = []
    for i in range(N):
        x,y = map(int,input().split())
        vs.append((x,y,i))
    vs.sort()
    edges = []
    for k in range(1, N):
        x,y,i = vs[k]
        a,b,j = vs[k-1]
        edges.append((i, j, min(abs(x-a),abs(y-b))))
    vs.sort(key=lambda x:x[1])
    for k in range(1, N):
        x,y,i = vs[k]
        a,b,j = vs[k-1]
        edges.append((i, j, min(abs(x-a),abs(y-b))))
    uf = UnionFind(N)
    edges.sort(key=lambda x:x[2])
    ans = 0
    for i,j,w in edges:
        if not uf.same(i,j):
            uf.unite(i,j)
            ans += w
    print(ans)

Measured memory_bytes: 54572
[X,Y,A,B,C] = [int(s) for s in input().rstrip().split(' ')]
L_p  = [int(s) for s in input().rstrip().split(' ')]
L_q  = [int(s) for s in input().rstrip().split(' ')]
L_r  = [int(s) for s in input().rstrip().split(' ')]
L_p.sort(reverse = True)
L_q.sort(reverse = True)
L = L_p[:X] + L_q[:Y] + L_r
L.sort(reverse = True)
print(sum(L[:X+Y]))

Measured memory_bytes: 23644
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        List<int> A = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToList();

        List<int> O = A.Select((o, p) => new[] { o, p + 1 }).OrderBy(o => o[0]).Select(o => o[1]).ToList();

        for (int i = 0; i < N; i++)
            Console.Write("{0} ", O[i]);
        Console.WriteLine();
    }
}

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

int main(){
    int N; cin>>N;
    vector<pair<int,int>> A(N);
    for(int i=0;i<N;i++){
        int a; cin>>a;
        A[i]=make_pair(a,i+1);
    }
    sort(A.begin(),A.end());
    for(int i=0;i<N;i++){
        if(i+1==A[N-1].second) cout<<A[N-2].first<<endl;
        else cout<<A[N-1].first<<endl;
    }
    
}

Measured memory_bytes: 3200
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	int box = 333 * 590 + 1;
	for (int i = 0; i < N; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		int bag = 0;
		bag += (a - 1) / 3 * 590;
		if (a % 3 == 0) {
			bag += 390;
			bag += (b - 1) * 20;
			bag += c;
		}
		else  {
			if (a % 3 == 2)bag += 195;
			for (int j = 1; j < b; j++) {
				if (j % 2)bag += 20;
				else bag += 19;
			}
			bag += c;
		}
		cout << box - bag << endl;
	}
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

bool mt[101][101];
int cnt[101][101];

int main(){
    int h, w;
    cin >> h >> w;
    rep1(i, h) {
        rep1(j, w) {
            char m;
            cin >> m;
            if (m=='.') mt[i][j] = true;
        }
    }
    for (int i=2; i<=w+h; i++) {
        for (int ch=1; ch<i; ch++) {
            int cw = i - ch;
            if (cw > w || ch > h) continue;
            if (ch==1&&cw==1) 
                cnt[ch][cw] = mt[ch][cw]?0:1;
            else if (ch==1) 
                cnt[ch][cw] = (mt[ch][cw-1]==true&&mt[ch][cw]==false)?(cnt[ch][cw-1]+1):cnt[ch][cw-1];
            else if (cw==1) 
                cnt[ch][cw] = (mt[ch-1][cw]==true&&mt[ch][cw]==false)?(cnt[ch-1][cw]+1):cnt[ch-1][cw];
            else {
                int right = (mt[ch][cw-1]==true&&mt[ch][cw]==false)?(cnt[ch][cw-1]+1):cnt[ch][cw-1];
                int height = (mt[ch-1][cw]==true&&mt[ch][cw]==false)?(cnt[ch-1][cw]+1):cnt[ch-1][cw];
                cnt[ch][cw] = min(right, height);
            }
        }
    }
    cout << cnt[h][w] << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int a,b,c,d;
scanf("%d%d%d",&a,&b,&c);
if(a>b){
d=a,a=b,b=d;
}
if(a>c){
d=c,c=b,b=a,a=d;
}
if(b>c){
d=c,c=b,b=d;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, a;
  cin >> n >> a;
  int rem = n - n/500*500;
  if (rem <= a) yn; 
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS = false	
#include <stdlib.h>;
#include <stdio.h>;
//#include "Main.h"
int main(void)
{
	// Your code here!
	char S[4];
	char T[4];
	int ans=0;

	scanf("%c%c%c\n", &S[0], &S[1], &S[2]);
	scanf("%c%c%c", &T[0], &T[1], &T[2]);
	for (int i = 0; i<3; i++)
	{
		//printf("%c", S[i]);
		//printf("%c\n", T[i]);
		if (S[i] == T[i])
		{
			ans = ans + 1;
		}
	}
	printf("%d", ans);
	//system("pause");
}


Measured memory_bytes: 128