akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int k[200000];

void sort(int leftsta, int rightsta) {

    int left = leftsta, right = rightsta, Ftmp, pivot;
    int i;

    pivot = k[(left + right) / 2];

    //クイックソート(昇順)
    //*適応度が低いほど答えに近づく
    while (1) {
        while (k[left] < pivot) {
            //軸にあたるまで右側へ
            left++;
        }
        while (k[right] > pivot) {
            //軸にあたるまで左側へ
            right--;
        }
        if (left >= right) {
            //軸が交差したら終了
            break;
        }

        Ftmp = k[left];
        k[left] = k[right];
        k[right] = Ftmp;

        left++;
        right--;
    }

    //軸の左側ソート
    if (leftsta < left - 1) {
        sort(leftsta, left - 1);
    }
    //軸の右側ソート
    if (right + 1 < rightsta) {
        sort(right + 1, rightsta);
    }
}

int main()
{
    int N,countb,judge=0,mid;
    long ans,min;
    cin >> N;
    
    for (int i = 0; i < N;i++) {
        cin >> k[i];
        k[i] -= (i + 1);
    }

    sort(0,N-1);

    mid = k[N/2];
    ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(k[i] - (mid));
    }
    min = ans;
    ans = 0;
    mid = k[N / 2-1];
    for (int i = 0; i < N; i++) {
        ans += abs(k[i] - (mid));
    }
    if (min > ans) {
        min = ans;
    }
    ans = 0;
    mid = k[N / 2+1];
    for (int i = 0; i < N; i++) {
        ans += abs(k[i] - (mid));
    }
    if (min > ans) {
        min = ans;
    }
    
    /*while (N >= countb) {
        ans = 0;
        for (int i = 0; i < N; i++) {
            ans += abs(k[i] - (countb + i + 1));
        }
        if (countb == ((-1)*N)) {
            min = ans;
        }

        if ((min < ans)&&(judge != 0)) {
            break;
        }
        else if ((min < ans)&&(judge == 0)) {
            
        }
        else {
            min = ans;
            judge = 1;
        }
        countb++;
    }*/

    cout << min;
        
    cout << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

ll n, a, b;

int main()
{
	cin >> n >> a >> b;
	ll max = (n - 1) * b + a;
	ll min = (n - 1)*a + b;

	if (n == 1) {
		if (a == b) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
		return 0;
	}

	if (a > b) {
		cout << 0 << endl;
		return 0;
	}

	cout << max - min + 1 << endl;

	return 0;
}


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

int main(void){
    int n, k;
    cin >> n >> k;
    int x, ans = 0;
    for(int i=1; i<=n; i++){
        cin >> x;
        ans += 2*min(x, k-x);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n;

  scanf("%d",&n);

  vector<int> a;
  int input;

  for (int i=0;i<n;i++) {
    scanf("%d",&input);
    a.push_back(input);
  }

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

  int exist=1;
  
  if (n%2==1) {
    if (a[0]!=0) {
      exist=0;
    }
    for (int i=1;i<n-1;i+=2) {
      if (a[i]!=a[i+1] || a[i]!=i+1) {
	exist=0;
      }
    }
  } else {
    for (int i=0;i<n-1;i+=2) {
      if (a[i]!=a[i+1] || a[i]!=i+1) {
	exist=0;
      }
    }
  }

  if (exist==0) {
    printf("0\n");
  } else {
    int ans=1;
    for (int i=1;i<=n/2;i++) {
      ans*=2;
      ans%=1000000007;
    }
    printf("%d\n",ans);
  }
  
  return 0;
}


Measured memory_bytes: 892
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int a[][18],int x,int y,int m,int n){
  int sm=0;
  if(a[x][y])
    return 0;
  if(x==m&&y==n)
    return 1;
  sm+=f(a,x+1,y,m,n);
  sm+=f(a,x,y+1,m,n);
  return sm;
}
int main(){
  int i,j;
  int a[18][18],m,n,o,p,q;
  memset(a,1,sizeof(a));
  while(cin>>m>>n&&m+n){
    cin>>o;
    for(i=1;i<n+1;i++)
      for(j=1;j<m+1;j++)
	a[j][i]=0;
    for(i=0;i<o;i++){
      cin>>p>>q;
      a[p][q]=1;
    }
    cout<<f(a,1,1,m,n)<<endl;
  }
  return 0;
}

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

int main() {
  int i, N, K, count=0, A=0, B=0;

  
  cin >> N >> K;
  
  vector<string> l(N);
  rep(i,N) cin >> l[i];
  
  sort(l.begin(),l.end());
  
  rep(i,N) cout << l[i];
  
}

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

int main()
{
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>arr[i][j];
		}
	}
	
	int dp[n][3];
	memset(dp,0,sizeof(dp));
	//filling last row
for(int i=0;i<3;i++)
{
	dp[n-1][i]=arr[n-1][i];
}
	
	for(int i=n-2;i>=0;i--)
	{
		dp[i][0]=max(dp[i+1][1],dp[i+1][2])+arr[i][0];
		
		dp[i][1]=max(dp[i+1][0],dp[i+1][2])+arr[i][1];
		dp[i][2]=max(dp[i+1][1],dp[i+1][0])+arr[i][2];
	}
	
	int mx=max(dp[0][0],max(dp[0][1],dp[0][2]));
	
	cout<<mx;
	return 0;
}

Measured memory_bytes: 2560
ans = 0
y = []
z = []
for i in range(5):
    X = int(input())
    if X % 10 != 0:
        y.append(10 - X%10)
    z.append(X)

if len(y)>0:
    print(sum(z) + sum(y) - max(y))
else:
    print(sum(z))

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll a,b;
    cin >> a >> b;
    double x=a,y=b;
    cout << a/b << ' ' << a%b << ' ';
    printf("%.8f\n",x/y);
}


Measured memory_bytes: 3224
N = int(input())

M = N
while M % 2 == 0 :
    M //= 2
    
if M == 1 or N < 3 :
    print('No')
else :
    print('Yes')
    print(3, 1)
    print(1, 2)
    print(2, 3 + N)
    print(3 + N, 1 + N)
    print(1 + N, 2 + N)
        
    for i in range(4, N, 2) :
        print(1, i + 1)
        print(i + 1, i)
        print(1, N + i)
        print(N + i, N + i + 1)
        
    if N % 2 == 0 :
        i = 1
        while True :
            if N >> i & 1 :
                break
            i += 1
        print((1 << i) + 1, N)
        print(2 * N - (1 << i), 2 * N)

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

using namespace std;



#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<string> vstr;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    int num = 1;

    rep(i, n){
        if(num+k<num*2)
            num += k;
        else
            num *= 2;

    }
    cout << num << endl;









    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int co=0;
	int l, i=0, a[10];
    while(cin>>l){
        a[i] = l;
        i++;
    }
  int t=a[0];
while(t>=a[1]){
  t/=a[1];
  co++;
}
  co++;
  cout<<co;

}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{

    string s;
    cin>>s;
    if(s=="SUN") cout<<7<<"\n";
    else if(s=="MON") cout<<6<<"\n";
    else if(s=="TUE") cout<<5<<"\n";
    else if(s=="WED") cout<<4<<"\n";
    else if(s=="THU") cout<<3<<"\n";
    else if(s=="FRI") cout<<2<<"\n";
    else cout<<1<<"\n";
    
}

Measured memory_bytes: 3556
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
 
  vector<ll> p(n);
  map<ll,ll> q;
  
  rep(i,n){
  cin>>p[i];
    if(q.count(p[i])) q.at(p[i])++;
    else q[p[i]]=1;
  }
  
  int m;
  cin >> m;
  
  vector<ll> r(m);
  map<ll,ll> s;
  
  rep(i,m){
  cin>>r[i];
    if(s.count(r[i])) s.at(r[i])++;
    else s[r[i]]=1;
  } 
  
  for(auto x : s){
    if(!(q.count(x.fi) && q.at(x.fi)>=x.se)) {
    cout << "NO" << endl;
    return 0;
    }
  }
  
  cout << "YES" << endl;
}


Measured memory_bytes: 28416
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

const double g=10.0,eps=1e-12;
const int N=200000+10,maxn=200000+10,inf=0x3f3f3f3f;


int main()
{
    ll x,y;
    scanf("%lld%lld",&x,&y);
    int ans=1;
    while(2*x<=y)
    {
        x*=2;
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}
/********************

********************/


Measured memory_bytes: 256
//
//  ABC071B-NotFound.cpp
//  programing
//
//  Created by 毛利源 on 2019/01/29.
//
#include <cstdio>
 
char S[101010];
 
int main()
{
	scanf("%s", S);
 
	bool app[26];
	for (int i = 0; i < 26; ++i) {
		app[i] = false;
	}
	for (int i = 0; S[i] != '\0'; ++i) {
		app[S[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; ++i) {
		if (!app[i]) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}
	puts("None");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	char t1 = 0, t2 = 0, t3 = 0;
	char w1 = 0, w2 = 0, w3 = 0;
	
	int ans = 0;

	cin >> t1 >> t2 >> t3;
	cin >> w1 >> w2 >> w3;

	if (t1 == w1) {
		ans++;
	}
	if (t2 == w2) {
		ans++;
	}
	
	if (t3 == w3) {
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
head="MARCH"
count=[0]*5
answer=0

for i in range(N):
 S=input()
 for j in range(5):
  if S[0]==head[j]:
   count[j]+=1


for i in range(5):
 for j in range(i):
   for k in range(j):
     answer+=count[i]*count[j]*count[k]

print(answer)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int a = sc.nextInt();

        int sumTaxi = sc.nextInt();

        int sumTrain = n * a;

        if (sumTaxi < sumTrain) {
            System.out.println(sumTaxi);
        } else {
            System.out.println(sumTrain);
        }

    }
}


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

int N, M, K;
set<int> comb;

int get_split_cnt(int x, int y) {
  return (x+1) * (y+1) + (N-1-x) * (M-1-y);
}

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

  int total = N * M;

  if (K % N == 0 || K % M == 0) {
    cout << "Yes" << endl;
    return 0;
  }

  for(int i = 0; i < N/2; i++) {
    for (int j = 0; j < M/2; j++) {
      int num = get_split_cnt(i, j);
      // cout << num << endl;
      // cout << total - num << endl;
      comb.insert(num);
      comb.insert(total - num);
    }
  }

  if (comb.count(K)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 13056
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    s64 a;
    s64 cnt[60][2];
    rep (i, 60) rep (j, 2) cnt[i][j] = 0;
    rep (i, n)
    {
        cin >> a;
        rep (j, 60)
        {
            cnt[j][a & 1] = (cnt[j][a & 1] + 1) % MOD;
            a >>= 1;
        }
    }

    s64 pow2[61];
    pow2[0] = 1;
    rep (i, 60)
    {
        pow2[i + 1] = (pow2[i] << 1) % MOD;
    }

    s64 ans = 0;
    rep (i, 60)
    {
        ans = (ans + ((cnt[i][0] * cnt[i][1] % MOD) * pow2[i] % MOD)) % MOD;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
void dfs(vector<vector<ll>> &G, vector<bool> &judge, int v){
    judge[v]=true;
    for(int nv: G[v]){
        if(judge[nv]) continue;
        dfs(G, judge, nv);
    }
}

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N, M;
    cin >> N >> M;
    VLL a(M), b(M);
    rep(i,M){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    ll count=0;
    rep(i,M){
        vector<vector<ll>> G(N);
        vector<bool> judge(N, false);
        rep(j,M){
            if(i!=j){
                G[a[j]].push_back(b[j]);
                G[b[j]].push_back(a[j]);
            }
        }
        dfs(G, judge, 0);
        auto result=find(all(judge), false);
        if(result==judge.end()){
            continue;
        }
        else{
            count++;
        }
    }
    cout << count << endl;
}

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

typedef pair<int,int> pii;
typedef long long ll;
#define fi first
#define se second

int uf[256];
int rk[256];

void uf_init() {
	for(int i = 0; i < 256; i++) {
		uf[i] = i;
		rk[i] = 0;
	}
}

int uf_find(int x) {
	if(uf[x] == x)
		return x;
	return uf[x] = uf_find(uf[x]);
}

bool uf_same(int a, int b) {
	return uf_find(a) == uf_find(b);
}

void uf_merge(int a, int b) {
	int aa, bb;
	aa = uf_find(a);
	bb = uf_find(b);
	if(aa == bb)
		return;
	if(rk[aa] < rk[bb]) {
		uf[aa] = bb;
	}
	else {
		if(rk[aa] == rk[bb])
			rk[aa]++;
		uf[bb] = aa;
	}
}

struct edge {
	pii p; // テ」ツδ堙」ツつ「
	ll b; // テヲツイツ暗」ツつ?ヲツ卍づゥツ鳴?
	ll c; // テ」ツつウテ」ツつケテ」ツδ?
};

bool cost_cmp(const edge & a, const edge & b) {
	return a.c < b.c;
}
bool time_cmp(const edge & a, const edge & b) {
	return a.b < b.b;
}

int main() {
	int N, M;
	while(cin >> N >> M, N || M) {
		vector<pii> h;
		vector<edge> eg;
		h.resize(N);
		for(int i = 0; i < N; i++) {
			cin >> h[i].fi;
			h[i].se = i;
		}
		for(int i = 0; i < M; i++) {
			int a, b, c;
			edge e;
			cin >> a >> b >> c;
			a--; b--;
			if(a > b) swap(a,b);
			e.p = pii(a,b);
			e.b = min(h[a].fi, h[b].fi);
			e.c = c;
			eg.push_back(e);
		}
		sort(eg.begin(), eg.end(), time_cmp);
		sort(h.begin(), h.end());

		int T = -1;
		for(int i = 0; i < h.size(); i++) {
			uf_init();
			for(int j = 0; j < eg.size(); j++) {
				if(eg[j].b < h[i].fi)
					continue;
				edge e;
				e = eg[j];
				uf_merge(e.p.fi, e.p.se);
			}
			bool flg = true;
			int tmp = uf_find(h[i].se);
			for(int j = i; j < h.size(); j++) {
				if(tmp != uf_find(h[j].se))
					flg = false;
			}
			if(flg == false) {
				break;
			}
			T = h[i].fi;
			while(i < h.size()-1 && h[i].fi == h[i+1].fi) i++;
		}
		ll res = 0;
		uf_init();
		while(T >= 0) {
			vector<edge> v;
			ll nex_t = -1;
			for(int i = 0; i < eg.size(); i++) {
				if(T <= eg[i].b)
					v.push_back(eg[i]);
				else
					nex_t = max(nex_t, eg[i].b);
			}
			sort(v.begin(), v.end(), cost_cmp);
			for(int i = 0; i < v.size(); i++) {
				edge e = v[i];
				if(!uf_same(e.p.fi, e.p.se)) {
					res += e.c;
					uf_merge(e.p.fi, e.p.se);
				}
			}
			T = nex_t;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 2900
#include <stdio.h>

#define MAX 500001

int A[MAX];
int n;

void maxHeapify(int i) {
  int l = i*2;
  int r = i*2+1;
  int largest, tmp;

  if (l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if (r <= n && A[r] > A[largest]) largest = r;

  if (largest != i) {
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap() {
  int i;
  for (i = n/2; i >= 1; i--) {
    maxHeapify(i);
  }
}

int main() {
  int i;

  scanf("%d\n", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }
  buildMaxHeap();

  for (i = 1; i <= n; i++) {
    printf(" %d", A[i]);
  }
  printf("\n");

  return 0;
}

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


int a, b, c; 

int main() { 
  scanf("%d %d %d", &a, &b, &c);
  if (b > a && b > c) {
    b *= 10; 
  } else if (c > b && c > a) {
    c *= 10; 
  } else {
    a *= 10; 
  } 
  cout << a + b + c;
  return 0;
} 

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	long INF=Long.MAX_VALUE/2;
	int n,q,k;
	int[]a;
	int[]b;
	long[]c;
	int[]x;
	int[]y;
	ArrayList<Edge>[] tree;
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		a=new int[n];
		b=new int[n];
		c=new long[n];
		tree=new ArrayList[n];
		for(int i=0;i<n;i++){
			tree[i]=new ArrayList<Edge>();
		}
		for(int i=0;i<n-1;i++){
			a[i]=sc.nextInt()-1;
			b[i]=sc.nextInt()-1;
			c[i]=sc.nextInt();
			tree[a[i]].add(new Edge(b[i],c[i]));
			tree[b[i]].add(new Edge(a[i],c[i]));
		}
		q=sc.nextInt();
		k=sc.nextInt();
		x=new int[q];
		y=new int[q];
		for(int i=0;i<q;i++){
			x[i]=sc.nextInt()-1;
			y[i]=sc.nextInt()-1;
		}
		d=new long[n];
		dijkstra(k-1);
		
		for(int i=0;i<q;i++){
			System.out.println(d[x[i]]+d[y[i]]);
		}
		
	}
	
	long[]d;
	
	void dijkstra(int s){
		Queue<Edge> pq=new PriorityQueue<Edge>();
		Arrays.fill(d, INF);
		d[s]=0;
		pq.add(new Edge(s,0));
		
		while(!pq.isEmpty()){
			Edge e=pq.poll();
			int v=e.to;
			if(d[v]<e.cost){
				continue;
			}
			for(int i=0;i<tree[v].size();i++){
				Edge ei=tree[v].get(i);
				if(d[ei.to]>d[v]+ei.cost){
					d[ei.to]=d[v]+ei.cost;
					pq.add(new Edge(ei.to,d[ei.to]));
				}
			}
		}
	}
	
	
	public class Edge implements Comparable<Edge>{
		int to;
		long cost;
		
		Edge(int to, long cost){
			this.to=to;
			this.cost=cost;
		}
		
		public int compareTo(Edge o){
			return (int)(this.cost-o.cost);
		}
	}
	
	
}


Measured memory_bytes: 176080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(a)  (a).begin(),(a).end()

int main(){
int N;
cin >> N;
vector<int> l(N);
rep(i,N)
cin >> l.at(i);
int a, b, c;
long long int ans =0;
  int sk=0;
  int kari=0;

sort(l.begin(), l.end());
  rep(i,N-2){
  rep2(j, i+1, N-1){
  int  su= l[i]+l[j];
  auto pl = lower_bound(ALL(l),su)-l.begin();
    ans+=pl-j-1;
  } 
  }
cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,b,c;
    cin>>a>>b>>c;
    if(a==b) {if(b!=c) cout<<"Yes\n";
                else cout<<"No\n";
                return 0;
    }

    if(b==c) {
            if(a!=c) cout<<"Yes\n";
            else cout<<"No\n";
                return 0;

    }

    if(a==c) {
            if(b!=c) cout<<"Yes\n";
            else cout<<"No\n";
                return 0;


    }
    if(a!=b && b!=c) cout<<"No\n";



    return 0;
}


Measured memory_bytes: 384
import math
ALPHABET = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
result = []

def alphabet_decimal(v):
    quotient = math.floor(v / len(ALPHABET))
    surplus = v % len(ALPHABET)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(ALPHABET) if surplus == 0 else surplus
    result.append(surplus)
    if len(ALPHABET) < quotient:
        alphabet_decimal(quotient)
    elif len(ALPHABET) < v:
        result.append(quotient)
    return "".join([ALPHABET[i - 1] for i in reversed(result)])

n = int(input())
#s = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
print(alphabet_decimal(n))

Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=1; i<=N; i++) {
        vec[i-1]=i;
    }

    vector<int> P(N), Q(N);
    for(int n=0; n<N; n++) {
        cin >> P[n];
    }
    for(int n=0; n<N; n++) {
        cin >> Q[n];
    }
    
    long long int p, q;
    long long int cnt=1;
    do {
        bool fp=true, fq=true;
        for(int i=0; i<N; i++) {
            if(vec[i]!=P[i]) {
                fp=false;
            }
            if(vec[i]!=Q[i]) {
                fq=false;
            }
        }
        if(fp) {
            p = cnt;
        }
        if(fq) {
            q = cnt;
        }
        cnt++;
    } while(next_permutation(vec.begin(), vec.end()));
    
    cout << abs(p-q) << endl;


    return 0;
    
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, m, a[1010], b[1010], c[1010];
void solve(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	
	i64 ans = 0;
	for(int i = 0; i < 8; i++){
		int bb[3] = {};
		for(int j = 0; j < 3; j++){
			bb[j] = (i>>j&1);
		}
		i64 p[1010];
		for(int j = 0; j < n; j++){
			i64 cnt = (1-2*bb[0])*a[j];
			cnt += (1-2*bb[1])*b[j];
			cnt += (1-2*bb[2])*c[j];
			p[j] = cnt;
		}
		sort(p,p+n,greater<i64>());
		i64 cc = 0;
		for(int j = 0; j < m; j++){
			cc += p[j];
		}
		chmax(ans,cc);
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
a,b = map(int,input().split())
x=max(a,b)
y=min(a,b)

def gcd(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z

ans=a*b/gcd(a,b)
print(int(ans))




Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (int i = 0; i < m; i++) {
        cin >> v[i];
    }
    vsort(v);
    
    vector<int> diff(m-1);
    for (int i = 0; i < m - 1; i++) {
        diff[i] = abs(v[i] - v[i+1]);
    }
    vsort(diff);
    int sum = 0;
    for (int i = 0; i < m - n; i++) {
        sum += diff[i];
    }
    cout << sum << endl;
}


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

int digit(int64_t N, int i)
{
  return (N / (int64_t)pow(10, i - 1) % 10);
}

int n_digit(int64_t N)
{
  int count = 0;
  while (N)
  {
    N /= 10;
    count++;
  }
  return count;
}

int main()
{
  int K, n, count = 9;
  vector<int> a(64);
  int64_t ans = 10;

  cin >> K;
  if (K < 10)
  {
    cout << K << endl;
    return (0);
  }
  while (count < K)
  {
    n = n_digit(ans);
    a[0] = digit(ans, n);
    for (int i = 0; i < n - 1; i++)
    {
      a[i + 1] = digit(ans, n - i - 1);
      if (abs(a[i] - a[i + 1]) <= 1)
      {
        if (i == n - 2)
        {
          count++;
          ans++;
        }
        continue;
      }
      else if (a[i] < a[i + 1])
        ans += (int64_t)((10 - a[i + 1]) * pow(10, n - i - 2));
      else
        ans += (int64_t)((a[i] - 1) * pow(10, n - i - 2));
      break;
    }
  }
  cout << ans - 1 << endl;
}

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

using namespace std;

int sacrifice(int n, int m)
{
    if (n == 1) return (0);
    return ((sacrifice(n - 1, m) + m) % n);
}

int main()
{
    int n, k, m;
    
    while (scanf("%d %d %d", &n, &k, &m) && n){
        printf("%d\n", (sacrifice(n - 1, k) + m) % n + 1);
    }
    
    return (0);
}

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

#define ull unsigned long long

static const ull MOD=1000000007LL;

int n;
char s[100005];
uint64_t dp[100005][13];

int main(){
    int i,j,ki;
    ull res=0;
    scanf("%s",s);
    n=strlen(s);
    dp[0][0]=1;
    for (i=0;i<n;i++) {
        int c;
        if (s[i]=='?') c=-1;
        else c=s[i]-'0';

        for (j=0;j<10;j++) {
            if (c!=-1 && c!= j) continue;
            for (ki=0;ki<13;ki++){
                dp[i+1][(ki*10+j)%13]+=dp[i][ki];
            }
        }
        for (j=0;j<13;j++) dp[i+1][j]%=MOD;
    }
    res=dp[n][5];
    printf("%llu\n",res);
    return 0;
}


Measured memory_bytes: 10496
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    string s = read!string;
    int[char] d;
    foreach (c; s) {
        d[c]++;
    }

    bool ok = d.values.all!(e => e == 2);
    writeln(ok ? "Yes" : "No");
}


Measured memory_bytes: 256
import java.math.BigDecimal
//

fun main() {
    abc169b()
}

fun abc169b() {
    val n = readLine()!!.toInt()
    val a  = readLine()!!.split(" ").map { it.toLong() }
    val lim = BigDecimal(1000000000000000000L)
    var base = BigDecimal(a[0])
    if (a.count { it == 0L } > 0) {
        println(0)
        return
    }
    for (i in 1 until n) {
        base = base.multiply(BigDecimal(a[i]))
        if (base > lim) {
            println(-1)
            return
        }
    }
    println(base.toLong())
}


Measured memory_bytes: 63480
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

ll k,x;
ll res=0,ans=0,sum=0;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>k>>x;
    if(k==1)
    {
        cout<<x;
        return 0;
    }
    k--;
    ans=x-k;
    sum=x+k;
    for(ans;ans<=sum;ans++)
    {
        cout<<ans<<" ";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
ll a[100005];
ll b[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n + 1) {
    cin >> a[i];
  }

  ll sum = 0;
  REP(i, n) {
    cin >> b[i];
  }

  ll d = 0;
  REP(i, n) {
    if(a[i] - (d + b[i]) >= 0) {
      sum += d + b[i];
      d = 0;
    } else {
      if(a[i] - d >= 0) d = b[i] - (a[i] - d);
      else d = b[i];
      sum += a[i];
    }
  }
  if(a[n] - d >= 0) sum += d;
  else sum += a[n];

  cout << sum << endl;
}


Measured memory_bytes: 1792
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
# dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
	for j in range(V + 1):
		# i+1番目を選ぶ場合
		if j - v[i] >= 0:
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
		# i+1番目を選ばない場合
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# dp[N][j]がW以下であるようなjの最大値が答えになる
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)


Measured memory_bytes: 311632
using System;
using System.Linq;

namespace ITP1_4_D
{
    class Program
    {
        static void Main()
        {
            Console.ReadLine();
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            Console.WriteLine("{0} {1} {2}", x.Min(), x.Max(), x.Sum());
        }
    }
}


Measured memory_bytes: 20516
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var p = new Point[n[0]].Select(x => new Point()).ToArray();
        for(int i = 0; i < n[1]; i++)
        {
            var s = ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            p[s[0]].path.Add(s[1]);
            p[s[1]].path.Add(s[0]);
        }
        for(int i = 0; i < n[0]; i++)
        {
            WriteLine(p[i].path.Count);
        }
    }

    public class Point
    {
        public List<int> path = new List<int>(); 
    }
}


Measured memory_bytes: 19156
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    

    
    a, b = mi()
    ans = 0

    def push():
        nonlocal a, b, ans
        if a > b:
            ans += a
            a -= 1
        else:
            ans += b
            b -= 1
    push()
    push()

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


inline double det(const P &a, const P &b) {
	return (conj(a) * b).imag();
}

int main() {
	double x[4], y[4];
	char c;
	for (; cin >> x[0] >> c >> y[0] ; ) {
		rep (i, 3) cin >> c >> x[i + 1] >> c >> y[i + 1];
		double s = 0.0;
		//rep(i, 4) x[i] += 200, y[i] += 200;
		rep (i, 4) s += det(P(x[i], y[i]), P(x[(i + 1) % 4], y[(i + 1) % 4])) / 2.0;
		s = fabs(s);
		double sub_s = 0;
		rep(j, 4) {
			double ss = 0.0;
			rep(i, 4) if (i != j) {
				int idx = (i + 1) % 4;
				if (idx == j) idx = (i + 2) % 4;
				ss += det(P(x[i], y[i]), P(x[idx], y[idx])) / 2.0;
			}
			ss = fabs(ss);
			sub_s = max(sub_s, ss);
		}
		cout << (s >= sub_s ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <bitset>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<long long int,long long int> 
#define ff first
#define pb push_back
#define ss second
#define ll long long 
#define ull unsigned long long
#define vi vector<long long int>
#define vii vector<pii>
#define vvi vector <vi>
#define rep(x,a,b,c) for(int x=a;x<=b;x+=c)
#define repp(x,a,b) rep(x,a,b,1)
#define rev(x,a,b,c) for(int x=a;x>=b;x-=c)
#define revv(x,a,b) rev(x,a,b,1)
#define OO (int)2e9
#define INF (ll)1e18
 
using namespace std;

int a[5],b[5];
int hit,blow;

int main()
{
	while(scanf("%d %d %d %d",&a[1],&a[2],&a[3],&a[4])!=EOF)
	{
		hit=0;
		blow=0;
		scanf("%d %d %d %d",&b[1],&b[2],&b[3],&b[4]);
		repp(x,1,4)
		{
			repp(y,1,4)
			{
				if(b[x]==a[y])
				{
					if(x==y)hit++;
					else
					blow++;
				}
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

Measured memory_bytes: 3120
from sys import stdin

n = int(stdin.readline().rstrip())
a = [int(stdin.readline().rstrip()) for _ in range(n)]

a_s = sorted(a)
m1 = a_s[-1]
m2 = a_s[-2]

for i in a:
    if i == m1:
        print(m2)
    else:
        print(m1)

Measured memory_bytes: 14112
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>m;
    cout<<(500*n>=m?"Yes":"No")<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int N = 2005, MOD = 1e9 + 7;

int dp[N][N], ds[N][N], fac[N], inv[N];

int fpow(int a, int b) {
  int ans = 1;
  for(; b > 0; b >>= 1, a = 1ll * a * a % MOD) {
    if(b & 1) {
      ans = 1ll * ans * a % MOD;
    }
  }
  return ans;
}

void add(int &x, int y) {
  x += y;
  if(x >= MOD) x -= MOD;
}

int C(int n, int m) {
  if(n < m) return 0;
  return 1ll * fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}

void Main() {
  fac[0] = 1;
  for(int i = 1; i < N; i++) {
    fac[i] = 1ll * fac[i - 1] * i % MOD;
  }
  inv[N - 1] = fpow(fac[N - 1], MOD - 2);
  for(int i = N - 2; i >= 0; i--) {
    inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
  }
  dp[0][0] = 1;
  for(int i = 0; i < N; i++) {
    ds[0][i] = 1;
  }
  for(int i = 1; i < N; i++) {
    for(int j = 1; j < N; j++) {
      dp[i][j] = ds[i - 1][j - 1];
    }
    for(int j = 1; j < N; j++) {
      ds[i][j] = ds[i][j - 1];
      add(ds[i][j], dp[i][j]);
    }
  }
  int n, k; cin >> n >> k;
  for(int i = 1; i <= k; i++) {
    int cur = 0;
    for(int j = 0; j <= n - k; j++) {
      // debug(i - 1, j, dp[i - 1][j]);
      add(cur, 1ll * dp[i - 1][j] * (n - k - j + 1) % MOD);
    }
    cur = 1ll * cur * C(k - 1, i - 1) % MOD;
    cout << cur << "\n";
  }
}


Measured memory_bytes: 31744
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,cnt;
	while(scanf("%d%d%d",&a,&b,&c)!=EOF)
	{
		cnt=0;
		while(1)
		{
			if(a&1||b&1||c&1)
			{
				printf("%d\n",cnt);
				break;
			}
			if(a==b&&b==c)	
			{
				printf("-1\n");
				break;
			}
			int aa,bb,cc;
			aa=b/2+c/2;
			bb=a/2+c/2;
			cc=a/2+b/2;
			a=aa;
			b=bb;
			c=cc;
			cnt++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1 << 30)

N = read()
edges = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = reads()
  a, b = a-1, b-1
  edges[a].append(b)
  edges[b].append(a)

def dist(u, d):
  for v in edges[u]:
    if d[v] >= 0:
      continue
    d[v] = d[u] + 1
    dist(v, d)
  return d

distf = dist(0, [0]+[-1]*(N-1))
dists = dist(N-1, [-1]*(N-1)+[0])

numf = sum(distf[i] <= dists[i] for i in range(N))
nums = N - numf

if numf > nums:
  print("Fennec")
else:
  print("Snuke")

Measured memory_bytes: 208684
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

bool match(string &s1,string &s2){
    if(s1.size()<s2.size())
        return false;
    int idx=0;
    for(int i = 0; i <= s1.size()-s2.size(); i++){
        if(s1[i]==s2[0]){
            bool f=true;
            for(int j = 0; j < s2.size(); j++){
                if(s1[i+j]!=s2[j]){
                    f=false;
                    break;
                }
            }
            if(f)
                return true;
        }
    }
    return false;
}

int main(){

    int n;
    while(cin>>n&&n!=0){
        vector<string> ss;
        vector<string> tmp;
        int a[11];
        int matchSize[11][11];
        string matchStr[11][11];

        memset(matchSize,0,sizeof(matchSize));
        for(int i = 0; i < n; i++){
            string s;
            cin>>s;
            tmp.push_back(s);
        }
        bool ok[21];
        fill(ok,ok+21,true);
        for(int i = 0; i < n; i++){
            if(!ok[i])continue;
            for(int j = 0; j < n; j++){
                if(i==j)continue;
                if(match(tmp[i],tmp[j])){
                    ok[j]=false;
                }
            }
        }
        for(int i = 0; i < n; i++)
            if(ok[i])
                ss.push_back(tmp[i]);
        n=ss.size();
        for(int i = 0; i < ss.size(); i++)
            a[i]=i;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i==j)
                    continue;
                matchStr[i][j]=ss[j];
                for(int k = min(ss[i].size(),ss[j].size()); k >= 1; k--){
                    if(ss[i].substr(ss[i].size()-k,k)==ss[j].substr(0,k)){
                        matchSize[i][j]=k;
                        matchStr[i][j]=ss[j].substr(k);
                        break;
                    }
                }
            }
        }
        int maxSize=1000000;
        string res;
        do{
            int sumSize=ss[a[0]].size();
            for(int i = 1; i < n; i++)
                sumSize+=ss[a[i]].size()-matchSize[a[i-1]][a[i]];
            if(maxSize>sumSize){
                maxSize=sumSize;
                // resツづーツ青カツ青ャ
                string s=ss[a[0]];
                for(int i = 1; i < n; i++)
                    s+=matchStr[a[i-1]][a[i]];
                res=s;
            }
            else if(maxSize==sumSize){
                string s=ss[a[0]];
                for(int i = 1; i < n; i++)
                    s+=matchStr[a[i-1]][a[i]];
                if(res>s)
                    res=s;
            }
        }while(next_permutation(a,a+n));
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int MAX=100;
const int INF=(1<<21);
const int W=0;
const int G=1;
const int B=2;
int n,m[MAX][MAX];
int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];
  for(int i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=W;
  }
  d[0]=0;
  while(1){
    minv=INF;
    u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i] && color[i]!=B){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=B;
    for(int v=0;v<n;v++){
      if(color[v]!=B && m[u][v]!=INF){
	if(d[v]>m[u][v]){
	  d[v]=m[u][v];
	  p[v]=u;
	  color[v]=G;
	}
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(p[i]!=-1) sum+=m[i][p[i]];
  }
  return sum;
}

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e;
      scanf("%d",&e);
      m[i][j]=(e==-1)?INF:e;
    }
  }
  printf("%d\n",prim());
  return 0;
}
  


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w;
  cin >> h >> w;
  vector<char> a(h*w);
  for(int i = 0; i < h*w; i++){
    cin >> a.at(i);
  }
  for(int i = 0; i < w+2; i++){
    cout << "#";
  }
  cout << endl;
  for(int i = 0; i < h; i++){
    cout << "#";
    for(int j = 0; j < w; j++){
      cout << a.at(i*w+j);
    }
    cout << "#" << endl;
  }
  for(int i = 0; i < w+2; i++){
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
while n = gets
  n = n.to_i
  break if n == 0
  word_hash = Hash.new([])
  output = Array.new()
  n.times do
  	before, after = gets.chomp.split
  	word_hash.store(before, after)
  end
  m = gets.to_i
  m.times do
  	word = gets.chomp
  	word_hash.each{|key, value|
  	  if word == key
  	  	word = value
  	  	break
  	  end
    }
    output << word
  end
  
  puts output.join
end

Measured memory_bytes: 8616