akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (n, m, k) = readLine()!!.split(" ").map { it.toInt() }
    val arr = IntArray(n) { 0 }
    repeat(m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() - 1 }
        UnionFind.unite(a, b)
        arr[a]--
        arr[b]--
    }

    for(i in arr.indices) {
        arr[i] += UnionFind.size(i) - 1
    }

    repeat(k) {
        val (c, d) = readLine()!!.split(" ").map { it.toInt() - 1 }
        if (UnionFind.same(c, d)) {
            arr[c]--
            arr[d]--
        }
    }

    println(arr.joinToString(" "))
}

class UnionFind {
    companion object {
        val par = IntArray(100000) { -1 }
        fun root(x: Int): Int {
            if (par[x] < 0) return x
            else {
                par[x] = root(par[x])
                return par[x]
            }
        }

        fun same(x: Int, y: Int): Boolean {
            return root(x) == root(y)
        }

        fun unite(x: Int, y: Int) {
            var x = x
            var y = y
            x = root(x)
            y = root(y)
            if (x == y) return
            if (par[x] > par[y]) {
                val tmp = x
                x = y
                y = tmp
            }
            par[x] += par[y]
            par[y] = x
        }

        fun size(x: Int) : Int = -par[root(x)]
    }
}

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

//ライブラリ始まり

//定数
//円周率
const double pi = 3.1415926535897932384;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  long long ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

//ライブラリ終わり
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N, X;
  cin >> N >> X;
  int ans = N;
  int M = INF;
  for (int i = 0; i < N; i++) {
    int C;
    cin >> C;
    X -= C;
    M = min(M, C);
  }
  cout << ans + X / M << endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int mod = 1000000007; 
	int dp[310][310][310] = {}; // dp[i番目から左に見ていって][j番目で初めて2種類に][k番目で初めて3種類に]
	bool ng[310][310][310] = {}; 
	int N, M; cin >> N >> M; 
	for(int i = 0; i < M; i++){
		int L, R, X; cin >> L >> R >> X; 
		if(X == 1){
			for(int j = L; j < R; j++){
				for(int k = 0; k < j; k++){
					ng[R][j][k] = true; 
				}
			}
		} 
		if(X == 2){
			for(int j = 0; j < R; j++){
				for(int k = 0; k < R; k++){
					if(j < L || k >= L) ng[R][j][k] = true; 
				}
			}
		}
		if(X == 3){
			for(int k = 0; k < L; k++){
				for(int j = 0; j < R; j++){
					ng[R][j][k] = true; 
				}
			}
		}
	}
	if(!ng[1][0][0]) dp[1][0][0] = 3; 
	for(int i = 1; i < N; i++){
		for(int j = 0; j < i; j++){
			for(int k = 0; k <= j; k++){
				if(!ng[i+1][j][k]){
					dp[i+1][j][k] += dp[i][j][k]; 
					if(dp[i+1][j][k] >= mod) dp[i+1][j][k] -= mod; 
				}
				if(!ng[i+1][i][k]){
					dp[i+1][i][k] += dp[i][j][k]; 
					if(dp[i+1][i][k] >= mod) dp[i+1][i][k] -= mod; 
				}
				if(!ng[i+1][i][j]){
					dp[i+1][i][j] += dp[i][j][k]; 
					if(dp[i+1][i][j] >= mod) dp[i+1][i][j] -= mod;
				}
			}
		}
	}
	int ans = 0; 
	for(int j = 0; j <= N; j++){
		for(int k = 0; k <= j; k++){
			ans += dp[N][j][k]; 
			if(ans >= mod) ans -= mod; 
		}
	}
	cout << ans << "\n"; 
}

Measured memory_bytes: 149100
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
template<typename T> inline void read(T &x) { 
  x = 0; char c = getchar(); bool flag = false;
  while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); }
  while (isdigit(c)) { x = (x << 1 ) + (x << 3) + (c ^ 48); c = getchar(); }
  if (flag) x = -x; 
}
using namespace std;
multiset<string> st; 
int main() {
  int A, B, C; read(A), read(B), read(C);
  while (A) st.insert("a"), --A;
  while (B) st.insert("b"), --B;
  while (C) st.insert("c"), --C;
  while (st.size() != 1) {
    string smal = *(st.begin()), larg = *(--st.end());
    st.erase(st.find(smal)); st.erase(st.find(larg));
    st.insert(smal + larg);
  }
  cout << *st.begin() << endl;
  return 0;
}


Measured memory_bytes: 3128
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		String s = br.readLine();
		String t = br.readLine();
		
		char[] chs = s.toCharArray();
		char[] cht = t.toCharArray(); 
		int cnt = 0;
		for(int i=0; i<s.length(); i++) {
			if(chs[i] != cht[i])
				cnt++;
		}
		
		bw.write(cnt + "\n");
		bw.flush();
	}

}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    string S;
    cin >> S;
    int N = (int)S.size();

    Vi is_used(26);

    for (int i = 0; i < N; i++) {
        is_used[S[i] - 'a'] = 1;
    }

    if (N == 26) {
        string ans = S;
        bool ok = next_permutation(ans.begin(), ans.end());
        if (ok) {
            int idx = 0;
            while (idx < N && ans[idx] == S[idx]) ++idx;
            ans.erase(ans.begin() + idx + 1, ans.end());
            cout << ans << endl;
        }
        else {
            cout << -1 << endl;
        }
    }
    else {
        for (int i = 0; i < 26; i++) {
            if (is_used[i] == 0) {
                S += (char)('a' + i);
                break;
            }
        }
        cout << S << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vvi = vector<vector<int>> ;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
  int n; cin >> n;
  string s; cin >> s;
  bool fin;
  if(s[0] == 'o'){fin = true;}
  else{fin = false;}
  bool ans = true;
  

  vector<char> s1(n+1);
  s1[0] = 'W'; s1[1] = 'S';
  vector<char> s2(n+1);
  s2[0] = 'W'; s2[1] = 'W';
  vector<char> s3(n+1);
  s3[0] = 'S'; s3[1] = 'S';
  vector<char> s4(n+1);
  s4[0] = 'S'; s4[1] = 'W';

  while(true){
  bool f;
  for(int i = 2; i <= n; i++){
    f = true;
    if(s1[i-2] == 'W'){f = !f;}
    if(s1[i-1] == 'W'){f = !f;}
    if(s[i-1] == 'x'){f = !f;}
    if(f){s1[i] = 'S';}
    else{s1[i] = 'W';}
  }
  if(fin){if(s1[n-1] == 'W' && s1[0] == s1[n])  {rep(i, n){cout << s1[i];}ans = false; break;}}
  else{if(s1[n-1] == 'S' && s1[0] == s1[n])  {rep(i, n){cout << s1[i];}ans = false; break;}}
  for(int i = 2; i <= n; i++){
    f = true;
    if(s2[i-2] == 'W'){f = !f;}
    if(s2[i-1] == 'W'){f = !f;}
    if(s[i-1] == 'x'){f = !f;}
    if(f){s2[i] = 'S';}
    else{s2[i] = 'W';}
  }
  if(fin){if(s2[n-1] == 'S' && s2[0] == s2[n] ) {rep(i, n){cout << s2[i];}ans = false; break;}}
  else{if(s2[n-1] == 'W' && s2[0] == s2[n])  {rep(i, n){cout << s2[i];}ans = false; break;}}

  for(int i = 2; i <= n; i++){
    f = true;
    if(s3[i-2] == 'W'){f = !f;}
    if(s3[i-1] == 'W'){f = !f;}
    if(s[i-1] == 'x'){f = !f;}
    if(f){s3[i] = 'S';}
    else{s3[i] = 'W';}
  }
  if(fin){if(s3[n-1] == 'S' && s3[0] == s3[n]) {rep(i, n){cout << s3[i];} ans = false; break;}}
  else{if(s3[n-1] == 'W' && s3[0] == s3[n])  {rep(i, n){cout << s3[i];}ans = false;  break;}}

  for(int i = 2; i <= n; i++){
    f = true;
    if(s4[i-2] == 'W'){f = !f;}
    if(s4[i-1] == 'W'){f = !f;}
    if(s[i-1] == 'x'){f = !f;}
    if(f){s4[i] = 'S';}
    else{s4[i] = 'W';}
  }
  if(fin){if(s4[n-1] == 'W'  && s4[0] == s4[n])  {rep(i, n){cout << s4[i];} ans = false;break;}}
  else{if(s4[n-1] == 'S' && s4[0] == s4[n]) { rep(i, n){cout << s4[i];}ans = false; break;}}

  cout << -1;
  break;
  }
  cout << endl;
}       

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

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

Measured memory_bytes: 1160
//syntaxerorr
#include<bits/stdc++.h>
using namespace std;
#define i_am_speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lli long long int
#define f(i,a,b) for(i=a;i<b;i++)
#define r(i,a) for(i=a;i>=0;i--)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define ff first
#define sc second
#define mp make_pair
#define pb push_back
#define nl cout<<endl
#define full(v) v.begin(),v.end()
#define ms(a) memset(a,0,sizeof(a))
#define sz(a) a.size()
#define llu unsigned long long int
#define pi pair<int,int>
#define plli pair<lli,lli>
#define ppl pair<lli,pair<lli,lli> >
#define ppi pair<int,pair<int,int> >
#define vlli vector<lli> v;
#define vii vector<int> v;
#define vl(n) vector<lli> v[n];
#define fu fflush(stdout)
#define in(a,n) lli a[n]; for(lli i=0;i<n;i++)  cin>>a[i];
#define pv(v) for(auto it=v.begin(),v.end(),it++) cout<<*it<<" ";
#define ps(s) for(auto it=s.begin();it!=s.end();it++) cout<<*it<<" ";
#define mod 1000000007
#define mod2 998244353
#define msb(b) memset(b,true,sizeof(b))
#define msf(b) memset(b,false,sizeof(b))
#define MAXN 100005
// bool prime[1000000]; // 10**6
// lli pri[100000],x=0;
/*void sieve()
{
  msb(prime);
  prime[0]=prime[1]=false;
  for(int p=2;p*p<=1000000;p++)
  {
    if(prime[p])
    {
      for(int i=p*2;i<=1000000;i+=p)
        prime[i]=false;
      // a[x++]=p;
    }
  }
} */
/*lli gcd(lli a,lli b)
{
  if(b==0)
    return a;
  return gcd(b,a%b);
} */
/*lli minv(lli a,lli m) // modulo multiplicatve inverse
{
    lli m0 = m;
    lli y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        lli q = a / m;
        lli t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
} */
int main()
{
    i_am_speed;
    int t,n,i;
    cin >> n;
    if(n >= 30)
        cout << "Yes" <<endl;
    else    
        cout << "No" <<endl;
}


Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys


def solve(N: int):
    if N%2 == 0:
        print(N//2-1)
    else:
        print(N//2)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

int     main() {
	// N: Number of nodes
	// M: Number of links
	int N;
	cin >>N;
	// Data store
	// p: Original value for each position
	vector<int> p(N, -1);
	vector<vector<vector<int>>> L(N, vector<vector<int>> ());
	// Links
	// Each link connects nodes x and y
	// (Swap rules)
	int x, y, w;
	for (int i=0; i<N-1; i++) {
		cin >>x >>y >>w;
		L.at(x-1).push_back({y-1, w});
		L.at(y-1).push_back({x-1, w});
	}
	vector<int> Q(0);
	vector<bool> QD(N, false);
	p.at(0)=0;
	Q.push_back(0);
	QD.at(0)=true;
	int ix=0;
	vector<bool> CH(N, false);
	while(true) {
		while (ix<Q.size()) {
			int X=Q.at(ix);
			for (int i=0; i<L.at(X).size(); i++) {
				int Y=L.at(X).at(i).at(0);
				int W=L.at(X).at(i).at(1);
				if (!CH.at(Y)) {
					if (0==W%2) {
						p.at(Y)=p.at(X);
					} else {
						p.at(Y)=1-p.at(X);
					}
					if (!QD.at(Y)) {
						Q.push_back(Y);
						QD.at(Y)=true;
					}
				}
			}
			CH.at(X)=true;
			ix++;
		}
		if (N==Q.size())
			break;
		int XX=0;
		while (CH.at(XX))
			XX++;
		p.at(XX)=0;
		Q.push_back(XX);
		QD.at(XX)=true;
	}
	for (int i=0; i<N; i++)
		cout <<p.at(i) <<endl;
	return 0;
};


Measured memory_bytes: 16504
#include<iostream>
#include<stdlib.h>
using namespace std;

int main(){
    int n,h,w;
    cin>>n>>h>>w;
    int a[n],b[n],num=0;

    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        //cout<<a[i]<<" "<<b[i]<<endl;
        if(a[i]>=h){
            if(b[i]>=w){
                num++;
            }
        }
    }
    cout<<num;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
}









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

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

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

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <queue>
#include <cstring>
#define mp make_pair
#define pb push_back
#define p push

#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLl(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
#define MAXN 100005
using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;




int main(){
    IOS
    ll a , b, c ,d;
    cin >>a>>b>>c>>d;

    ll k =(a-1)-(a-1)/c-(a-1)/d+(a-1)/(c*d/__gcd(c,d));
    ll t = b-b/c-b/d+b/(c*d/__gcd(c,d));
    cout << t - k;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	char a,b; cin >> a >> b;
	string s = "",t = "";
	rep(i,b-'0') s += a;
	rep(i,a-'0') t += b;
	cout << min(s,t) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) {
        cout << S << endl;
        return 0;
    }
    rep(i, K) {
        cout << S[i];
    }
    cout << "..." << endl;
}

Measured memory_bytes: 3628
import sys

def maxHeapify(heap, i):
    h = len(heap) - 1 # 1 origin
    l = 2 * i
    r = 2 * i + 1
    if l <= h and heap[i] < heap[l]:
        largest = l
    else:
        largest = i
    if r <= h and heap[largest] < heap[r]:
        largest = r

    if largest != i:
        heap[i], heap[largest] = heap[largest], heap[i]
        maxHeapify(heap, largest)

def buildMaxHeap(heap):
    h = len(heap)  - 1 # 1 origin
    for i in range(h//2, 0, -1):
        maxHeapify(heap, i)

# sys.stdin = open('input.txt')

size = int(input())
heap = [i for i in map(int, input().split())]
heap = [0] + heap # 1 origin

buildMaxHeap(heap)
for i in range(1, len(heap)):
    print(' ', end='')
    print(heap[i], end='')
    if i == len(heap)-1:
        print('')


Measured memory_bytes: 63980
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
void println(){printf("\n");}

int main(){
    int n;scanf("%d",&n);
    int a[3*n];for(int i=0;i<3*n;i++)scanf("%d",&a[i]);

    qsort(a,3*n,sizeof(int),desc_cmp);
    
    ll ans=0; 
    for(int i=1;i<2*n;i+=2){
        ans+=a[i];
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 2556
#! -*- coding: utf-8 -*-

n = int(input())
line = input()

w = 0
for i in range(n):
    if line[i] == ".":
        w += 1
b = n-w

w_coutner = 0
b_counter = 0
ans = n
for i in range(n):
    if line[i] == ".":
        w_coutner += 1
    b_counter = i+1 - w_coutner
    wtob = b_counter
    btow = w - w_coutner
    ans_i = wtob + btow
    #print(i,ans_i)
    ans = min(ans,ans_i)

ans = min(w,b,ans)

print(ans)


Measured memory_bytes: 3500
n, k = [int(a) for a in input().split()]
ret = 0
for a in range(1, n + 1):
	cnt = 0
	tmp = a
	while(True):
		if tmp >= k:
			ret += 1/n * pow(1/2, cnt)
			break
		else:
			tmp *= 2
			cnt += 1
print(ret)

Measured memory_bytes: 3060
def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    n = len(s)
    m = len(t)

    dp = []
    for _ in range(n + 1):
        dp.append([0] * (m + 1))

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] + 1
    ans = []
    while n > 0 and m > 0:
        if dp[n][m] == dp[n][m - 1]:
            m -= 1
        elif dp[n][m] == dp[n - 1][m]:
            n -= 1
        else:
            ans.append(s[n - 1])
            n -= 1
            m -= 1
    print("".join(ans[::-1]))


if __name__ == '__main__':
    main()


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

int main()
{

	int  n, x, i = 0;

	cin >> n;
	while( ++i <= n ) {

		x = i;
		if( x % 3 == 0 ) cout << " " << i;
		else if( x % 10 == 3 ) cout << " " << i;
		else {
			while( x / 10 > 0 ) {

				x /= 10;
				if( x % 10 == 3 ) { cout << " " << i; break; }

			}
		}

	}

	cout << endl;

	return 0;

}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,ans;
  cin >> n >> k;
  ans=0;
  vector<int>h(n);
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
  }
  for(int j=0;j<n;j++){
    if(h.at(j)>=k){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
    int lmax,rmin=INT_MAX,n;
    int main() {
        int x,y;
        scanf("%*d%d",&n);
        for(register int i=1; i<=n; i++) {
            scanf("%d%d",&x,&y);
            lmax=max(lmax,x);
            rmin=min(rmin,y);
        }
        printf("%d\n",max(rmin-lmax+1,0));
        return 0;
    }

Measured memory_bytes: 3812
import math
n,d=map(int,input().split())
ls=[list(map(int,input().split())) for i in range(n)]

def distance(x,y,d):
    inner=0
    for i in range(d):
        inner+=(x[i]-y[i])**2
    return math.sqrt(inner)

ans=0
for i in ls:
    for j in ls:
        if distance(i,j,d).is_integer() and distance(i,j,d)!=0:
            ans+=1

print(int(ans/2))

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

class Main{
	public static void main(String[] args) {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		int impt=0;
		int beki_max=0;
		int keka=0;
		int moto=0;
		int keka_max=0;

		try {
			str=bfr.readLine();
			if(str.equals("")) {
				System.exit(0);
			}
			impt=Integer.parseInt(str);
			if(impt<=3) {
				System.out.println("1");
				System.exit(0);
			}
			if(impt==1000) {
				System.out.println("1000");
				System.exit(0);
			}
			beki_max=(int) ((Math.log(impt) / Math.log(2)));


			for(int i=2; i<=beki_max; i++) {
				keka=((int)Math.pow(impt,(double)1/i));

				moto=keka;
				for(int j=1; j<i; j++) {
					keka=keka*moto;
				}
				//System.out.println(keka);
				if(keka_max<keka && keka<=impt) {
					keka_max=keka;
				}
			}
			System.out.println(keka_max);
		}catch(IOException e) {

		}
		catch(NumberFormatException ee) {
			System.exit(0);
		}

		catch(NullPointerException eee) {
			System.exit(0);
		}

	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<double> a(n);
  REP(i, n)
  {
    cin >> a[i];
  }

  double ans = 0;
  REP(i, n)
  {
    ans += (1.0 / a[i]);
  }
  ans = (1.0 / ans);
  cout << fixed << setprecision(6) << ans << endl;
}


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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	vector<int> t(n);
	int sum=0;
	for(int i=0; i<n; i++){
		cin>>t[i];
		sum+=t[i];
	}
	int m;
	cin>>m;
	int maxi=0;
	vector<int> p(m), x(m);
	for(int i=0; i<m; i++){
		cin>>p[i]>>x[i];
		cout<<sum-t[p[i]-1]+x[i]<<endl;
	}

}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  Vec(Q,lli,N,0);
  rep(i,0,N){
    cin >> P[i];
    Q[i]=P[i];
  }
  rep(i,1,N)P[i]=gcd(P[i-1],P[i]);
  rrep(i,N-1,0)Q[i]=gcd(Q[i+1],Q[i]);
  sum=max(Q[1],P[N-2]);
  rep(i,1,N-1)chmax(sum,gcd(P[i-1],Q[i+1]));
  Out(sum);
}

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

typedef long long ll;
typedef long double ld;

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

    string a, b, c;
    cin >> a >> b >> c;

    if(a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {

	int K;
	cin >> K;

	int n = 0;
	for (int i = 2; i <= K; i += 2) {
		for (int j = 1; j <= K; j += 2) {
			++n;
		}
	}

	cout << n << endl;

	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 3e5 + 33, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[maxn], b[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m, q;
	int u = 1e9, v =1e9;
	cin >> n >> m >> q;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		u = min(a[i], u);
	}
	for(int i = 1; i <= m; i++) {
		cin >> b[i];
		v = min(b[i], v);
	}
	int ans = u+v;
	int x, y, c;
	while(q--) {
		cin >> x >> y >> c;
		ans = min(ans, a[x]+b[y]-c);
	}
	cout << ans;
}



Measured memory_bytes: 1024
from sys import stdin

def getMax(array):
    mx = mx2 = array[0]
    for i in array[1:]:
        mx2 = max(i, mx2 + i)
        mx = max(mx, mx2)
    return mx

for line in stdin:
    n = int(line)
    if n == 0:
        break
    array = []
    for line in stdin:
        line = int(line)
        array.append(line)
        if len(array) == n:
            break
    print(getMax(array))

Measured memory_bytes: 7724
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  long long n;
  double l;
  cin>>n>>l;
  double t[n];
  REP(i,n){
    cin>>t[i];
  }
  
  double ansx = 0, ansy = 0;
  double x,y;
  long long all_ = n*(n-1)*(n-2)/6LL;
  REP(i,n){
    for(int j = i+1; j<n; j++){
      x = y = 0;
      double mnum = j-i-1;
      double pnum = n-2-(j-i-1);
      x -= mnum*cos(PI*(t[i]+t[j])/l);
      //x += mnum*cos(PI*(t[i]+t[j]+l)/l);
      x += pnum*cos(PI*(t[i]+t[j])/l);
      y -= mnum*sin(PI*(t[i]+t[j])/l);
      //y += mnum*sin(PI*(t[i]+t[j]+l)/l);
      y += pnum*sin(PI*(t[i]+t[j])/l);
      x /= (double)all_;
      y /= (double)all_;
      
      ansx += x;
      ansy += y;
    }
  }
  
  cout<<fixed<<setprecision(15)<<ansx<<' '<<ansy<<endl;
  return 0;
}


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

int main() {
  int n;string s;cin>>n>>s;
  int ans=0;
  rep(i,1000){
    string t;int x=i;
    rep(j,3){
      t+='0'+x%10;
      x/=10;
    }
    int a=0;
    rep(j,n){
      if(s[j]==t[a]){
        a++;
        if(a==3){
          ans++;
          break;
        }
      }
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define lll __int128
#define ull unsigned long long
#define fi first
#define se second
#define db double
#define ld long double
#define lld __float128

/// order_of_key, find_by_order

template<class T, class COMP>
using custom_set = tree<T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T, class U>
using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd_64(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    string s; cin >> s;
    int ans = 0;
    bool prv = 0;
    char pr = 'a';
    for(int i = 0; i < s.size(); i++)
    {
        if(!prv || pr != s[i])
        {
            prv = 1; pr = s[i]; ans++;
        }
        else
        {   
            if(i == s.size()-1)
                break;
            ans++; prv = 0; i++;
        }
    }
    cout << ans << '\n';
}






































/// shche ne vmerla Ykraina


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/dsu>
#include <atcoder/segtree>
using namespace std;
using namespace atcoder;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}
int op(int a, int b){
    return max(a,b);
}
int e(){
    return -1;
}

int target;

bool f(int v) { 
//    cout<<"v:"<<v<<endl;
    return v < target; }

signed main(){
    int N; cin>>N;
    vec_int x(N), y(N);
    rep(i,N)cin>>x.at(i)>>y.at(i);

    dsu d(N);

    vector<T> vec_x(N);
    vector<T> vec_y(N);
    rep(i,N){
        vec_x.at(i)=make_tuple(x.at(i),y.at(i),i);
        vec_y.at(i)=make_tuple(y.at(i),x.at(i),i);
    }
    sort(vec_x.begin(), vec_x.end());
    sort(vec_y.begin(), vec_y.end());

//    reverse(vec_x.begin(), vec_x.end());
//    reverse(vec_y.begin(), vec_y.end());


    vec_int sorted_y(N);
    for(int i=0;i<N;i++){
        T temp  = vec_x.at(i);
        int x, y, pos; tie(x,y,pos) = temp;
        sorted_y.at(i) = y;
    }
    segtree<int,op,e> seg(sorted_y);
    
    vec_int connected(N,-1);
    vec_int visited_y(N,-1);
    for(int i=0;i<N;i++){
        T temp  = vec_x.at(i);
        int x, y, pos; tie(x,y,pos) = temp;

        if(connected.at(pos)!=-1)continue;
        connected.at(pos)=1;
        visited_y.at(y-1)=1;
        int index=0;

        int search_pos=i;
        target = y;
        while(true){
            search_pos = seg.max_right<f>(search_pos+1);
//            int search_pos = seg.max_right<f>(0);
            if(search_pos==N)break;
            T temp2 = vec_x.at(search_pos);
            int x2, y2, pos2 ; tie(x2,y2,pos2) = temp2;
            d.merge(pos,pos2);
            connected.at(pos2) = 1;
            index++;
        }

    }


/*
    vec_int connected(N,-1);
    rep(i,N){
        if(connected.at(i)!=-1)continue;
        for(int j=i+1;j<N;j++){
                if(connected.at(j)!=-1)continue;

            if((x.at(i)>x.at(j) && y.at(i)>y.at(j)) || (x.at(i)<x.at(j) && y.at(i)<y.at(j))){
                d.merge(i,j);
                connected.at(j) = 1;
            }
        }
    }

*/
    map<int, int> mm;
    rep(i,N){
        int num = d.leader(i);
        mm[num]++;
    }

    rep(i,N){
        int num = d.leader(i);
        cout<<mm[num]<<endl;
    }








    return 0;
}

Measured memory_bytes: 25708
# -*- coding: utf-8 -*-
# C - 2D Plane 2N Points
import sys 
from bisect import bisect,bisect_left
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
query = [(0,0)]*N*2
# 赤0 青1
for _ in range(N):
    a,b =map(int,readline().split())
    query[a] = (0,b)
for _ in range(N):
    a,b =map(int,readline().split())
    query[a] = (1,b)

A = []
ans = 0
for i in range(2*N):
    q,y = query[i]
    if q == 0:
        A.append(y)
        A = sorted(A)
    else:
        ind = bisect_left(A,y)
        if ind != 0:
            A.pop(ind-1)
            ans += 1
print(ans)

Measured memory_bytes: 9296
// 貪欲法
stdin.ReadLine() 
|> int64
|> fun x -> x / 500L , x % 500L
|> fun (x, y) -> x , y / 5L
|> fun (x, y) -> x * 1000L, y * 5L
|> fun (x, y) -> x+y
|> stdout.WriteLine

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k, a, b;
  cin >> k >> a >> b;
  if ((a - 1) / k != b / k) {
    cout << "OK\n";
  } else {
    cout << "NG\n";
  }
  return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


class UF{
private:
    vector<int> par,rank,elm;
public:
    int groups;
    
    UF(int __size):par(__size) , rank(__size,0) , elm(__size,1) , groups(__size){
        for(int i=0;i<__size;i++)par[i]=i;
    }
    
    int elements(int n){
        return elm[find(n)];
    }
    
    int find(int x){
        if(par[x]==x) {
            return x;
        }else{
            return par[x]=find(par[x]);
        }
    }
    
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        
        groups--;
        if(rank[x]<rank[y]){
            par[x]=y;
            elm[y]+=elm[x];
        }else{
            par[y]=x;
            elm[x]+=elm[y];
            if(rank[x]==rank[y])rank[x]++;
        }
    }
    
    bool isSame(int x,int y){
        return find(x)==find(y);
    }
};



int main(){
    int n,m;
    cin>>n>>m;
    
    vector<vector<int>> t(n);
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int l;
            cin>>l;
            l--;
            t[i].pb(l);
        }
    }
    
    
    vector<vector<int>> v(m);
    
    rep(i,n){
        rep(j,t[i].size()){
            v[t[i][j]].pb(i);
        }
    }
    
    UF uf(n);
    rep(i,m){
        rep(j,(int)v[i].size()-1){
            uf.unite(v[i][j],v[i][j+1]);
        }
    }
    
    
    if( uf.groups!=1 )cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    
    
    return 0;
    
}

Measured memory_bytes: 9720
#include <stdio.h>
int main ()

{
   int i,j;
   char X[10];
   for(i=0;i<10;i++)
   {
       scanf("%s",&X[i]);
       if(X[3]=='7')
       X[3]='8';
   }

   for(j=0;j<10;j++)
   {
       printf("%c",X[j]);
   }
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
using namespace  std;

const int nIMPOS = -1;
struct StDist
{
  int m_nDist;
  int m_nDone;

  StDist(int nDist) : m_nDist(nDist), m_nDone(0)
  { }
};

void fnInput(vector<vector<int>>& rvvnAdjcy, vector<StDist>& rvoDist)
{
  int nxSiz;
  cin >> nxSiz;

  rvvnAdjcy.resize(nxSiz + 1, vector<int>(nxSiz + 1, 0));
  for (int i = 0; i < nxSiz; ++i)
  {
    int nx, nySiz;
    cin >> nx >> nySiz;
    for (int j = 0; j < nySiz; ++j)
    {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
  StDist oDist(nIMPOS);
  rvoDist.resize(nxSiz + 1, oDist);
}

void fnBreadthFirstSearch(const vector<vector<int>>& cnrvvnAdjcy, 
                          queue<int>& rqnBFSrch, vector<StDist>& rvoDist)
{
  while (rqnBFSrch.size())
  {
    int nx = rqnBFSrch.front(); rqnBFSrch.pop();
    if (rvoDist[nx].m_nDist == nIMPOS)  continue;

    for (int ny = 1; ny < cnrvvnAdjcy[nx].size(); ++ny)
    {
      if (cnrvvnAdjcy[nx][ny] == 1  &&
          rvoDist[nx].m_nDone == 0)
      {
        int nDist = rvoDist[nx].m_nDist + 1;
        if (rvoDist[ny].m_nDist == nIMPOS)
          rvoDist[ny].m_nDist = nDist;
        else
          rvoDist[ny].m_nDist = min(rvoDist[ny].m_nDist, nDist);

        rqnBFSrch.push(ny);
      }
    }
    rvoDist[nx].m_nDone = 1;
  }
}

void fnResult(const vector<StDist>& cnrvoDist)
{
  for (int i = 1; i < cnrvoDist.size(); ++i)
    cout << i <<  " " << cnrvoDist[i].m_nDist << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;
  queue<int>  qnBFSrch;
  vector<StDist> voDist;

  fnInput(vvnAdjcy, voDist);

  voDist[1].m_nDist = 0;
  qnBFSrch.push(1);
  fnBreadthFirstSearch(vvnAdjcy, qnBFSrch, voDist);
  fnResult(voDist);

  return 0;
}

Measured memory_bytes: 3196
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int a[200000], sum[200001];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    sum[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << sum[i] << endl;
  }
}

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

set<int>pr;
void sieve(int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          pr.insert(p); 
} 


int main() {
	sieve(1000000);
	
	int x;
	cin>>x;
	
	cout<<*pr.lower_bound(x)<<endl;
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    int p = 1;
    while(p*p <= N){
        p++;
    }
    p--;
    cout << p*p << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
ll n,m;
ll mod=pow(10,9)+7;
char arr[1005][1005];
ll dp[1005][1005];
ll calc(ll x,ll y)
{
    if(x>n ||x<1 || y>m || y<1)
    {
        return 0;
    }
    if(arr[x][y]=='#')
    {
        return 0;
    }
    if(x==n && y==m)
    {
        return 1;
    }
    if(dp[x][y]!=-1)
    {
        return dp[x][y];
    }
    if(x==n)
    {
        return dp[x][y]=calc(x,y+1)%mod;
    }
    if(y==m)
    {
        return dp[x][y]=calc(x+1,y)%mod;
    }
    ll ans1=calc(x,y+1)%mod;
    ll ans2=calc(x+1,y)%mod;
    dp[x][y]=ans2+ans1;
    dp[x][y]%=mod;
    return dp[x][y];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    for(ll i=1;i<=n;++i)
    {
        for(ll j=1;j<=m;++j)
        {
            cin>>arr[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    cout<<calc(1,1)<<endl;
}






































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

ll n,x,y;
ll ans = 0;
vector<ll>adj[100005];
bool vis[100005];
map<pair<ll,ll>,ll>mp;

void DFS(ll s,ll prv)
{
    vis[s] = true;

    for(auto it:adj[s])
    {
        if(vis[it]) continue;
        prv = (prv + 1)%ans;
        mp[{s,it}] = prv;
        mp[{it,s}] = prv;
        DFS(it,prv);
    }
}

int main()
{
    memset(vis,false,sizeof vis);
    vector<pair<ll,ll>>edges;

    cin>>n;
    for(ll i=1;i<n;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
        edges.push_back({x,y});
    }

    for(ll i=1;i<=n;i++)    ans = max(ans,(ll)adj[i].size());

    DFS(1,-1);

    cout<<ans<<"\n";
    for(auto it:edges)  cout<<(mp[{it.first,it.second}]+1)<<"\n";

    return 0;
}


Measured memory_bytes: 20980
#include <bits/stdc++.h>
using namespace std;
const int N = 55;

string s[N];
int cnt [N][28];

int main ()
{
	int n;
	cin >> n;
	for (int i = 0 ;i < n ; i++) {
		cin >> s[i];
		for (int j = 0; j < (int)s[i].size(); j++)
		{
			cnt[i][s[i][j]-'a']++;
		}
	}
	
	//abbaga
	for (int j = 'a'-'a'; j <= 'z'-'a'; j++) {
		int minn = 1e9;
		for (int i = 0; i < n; i++) {
			int cntt = cnt[i][j];
			minn = min(minn, cntt);
		}
		for (int i = 0; i < minn; i++) {
			cout << char(j+'a');
		}
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a = 0;
  int b = 0;
  int n = 0;
  int cnt = 0;
  string s;
  cin >> s;
  for(int i=s.size()-1;i>=0;i--){
    a += s[i]-'0';
    b += (s[i]-'0') * pow(10,cnt);
    cnt += 1;
  }
  if(b%a == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	if(n % 1000 == 0) {
		cout << 0 << '\n';
	} else {
		cout << 1000 - n % 1000 << '\n';
	}
	return 0;
}


Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] inputs = scanner.nextLine().toCharArray();
		char[] outputs = new char[inputs.length];
		int oIndex = 0;
		for (int iIndex = 0; iIndex < inputs.length; iIndex++) {
			while (iIndex < inputs.length && inputs[iIndex] == 'B') {
				oIndex--;
				iIndex++;
			}
			if (iIndex >= inputs.length) break;
			if (oIndex < 0) oIndex = 0;
			outputs[oIndex++] = inputs[iIndex];
		}
		System.out.println(String.valueOf(Arrays.copyOf(outputs, oIndex)));
	}
}


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

map<string,int>a;

int main()
{
	int n,m=0,i;
	string s;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>s;
		m=max(m,++a[s]);
	}
	for(map<string,int>::iterator j=a.begin();j!=a.end();j++)
		if((*j).second==m)cout<<(*j).first<<"\n";
	return 0;
}

Measured memory_bytes: 25216
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
@k = gets.chomp.to_i + 1

@num = 0
def solve(num, keta, ketamoto)
  from = num[keta] - 1
  from = 0 if from < 0
  to = num[keta] + 1
  to = 9 if ketamoto == keta
  to = 9 if to > 9

  if keta == 8
    from.upto(to) do |i|
      @num += 1

      if @num == @k
        nnum = num.dup
        nnum[keta+1] = i
        puts nnum.join.to_i
        exit
      end
    end
  else
    from.upto(to) do |i|
      nnum = num.dup
      nnum[keta+1] = i
      if i == 0 && ketamoto == keta
        solve(nnum, keta+1, ketamoto + 1)
      else
        solve(nnum, keta+1, ketamoto)
      end
    end
  end
end

solve([0]*10, 0, 0)
solve([1] + [0]*9, 0, -1)
solve([2] + [0]*9, 0, -1)
solve([3] + [0]*9, 0, -1)

Measured memory_bytes: 3068
function Main(input){
  AB = input.split(' ').map(n=>parseInt(n));
  A = AB[0];
  B = AB[1];
  S = A > B ? A-- : B--;
  S += A > B ? A : B;
  console.log(S);
}

Main(require("fs").readFileSync("/dev/stdin","utf-8"));


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

int main() {
  int A,B,C,D,L,R;
  cin >>A>>B>>C>>D;
  L = A+B;
  R = C+D;
  if (L > R){
    cout << "Left" << endl;
  }else if (L==R){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

typedef struct {
    int index;
    int num;
} Num;

int my(const void *a, const void *b) {
  return (((const Num*)a)->num - ((const Num*)b)->num);
}

int main() {
    int n = ri();
    int a[n];
    INPUT(a);
    SORT(a);
    int r1 = a[n-1];
    int cur = INF;
    int r2;
    FOR(i,n-1) {
        int h = (r1%2)?r1/2+1:r1/2;
        if (abs(h-a[i]) < cur) cur = abs(h-a[i]), r2 = a[i];
    }
    
    cout << r1 << " " << r2 << endl;
 return 0;
}


Measured memory_bytes: 1020