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

vector<int64_t> ans;
vector<int> uf(100000, -1);

int root(int n)
{
  return uf.at(n) < 0 ? n : uf.at(n) = root(uf.at(n));
}

bool same(int a, int b)
{
  return root(a) == root(b);
}

int64_t unit_size(int n)
{
  return -1 * uf.at(root(n));
}

int64_t unite(int a, int b)
{
  if (same(a, b)) return 0;
  if (unit_size(a) < unit_size(b)) swap(a, b);
  int64_t n = unit_size(a) * unit_size(b);
  int ra = root(a);
  int rb = root(b);
  uf.at(ra) += uf.at(rb);
  uf.at(rb) = ra;
  return n;
}

int main()
{
  int64_t n, m;
  cin >> n >> m;

  vector<int> a(m);
  vector<int> b(m);

  for (int i = 0; i < m; i++) {
    cin >> a.at(i) >> b.at(i);
    a.at(i)--; b.at(i)--;
  }

  int64_t x = n * (n - 1) / 2;

  for (int i = m - 1; i >= 0; i--) {
    ans.push_back(x);
    x -= unite(a.at(i), b.at(i));
  }

  reverse(begin(ans), end(ans));

  for (const auto& e : ans) {
    cout << e << endl;
  }
}


Measured memory_bytes: 3444
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    retval = A[0]
    for i in range(1, N):
        retval = gcd(retval, A[i])
    print(retval)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62704
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n-1) cin >> b[i];
    int ans = 0;
    rep(i,n){
        a[i] = b[i];
        if(i>0){
            a[i] = min(b[i-1], b[i]);
        }
    }
    a[n-1] = b[n-2];
    rep(i,n) ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
    int n,min=1e13,q,s;
    cin>>n;
    s=sqrt(n);
    for(int i=1;i<=s;i++)
    {
        if(n%i==0)
        {
            q=n/i;
            if(i+q-2<min)
            {
                min=i+q-2;
            }
        }
    }
    cout<<min;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect, insort
def main():
    n = int(input())
    s = list(input())
    q = int(input())
    _is = {chr(i):[] for i in range(ord("a"), ord("a")+27)}
    for i, si in enumerate(s):
        _is[si].append(i)
    for _ in range(q):
        t, i, c = input().split()
        i = int(i)-1
        if t == "1":
            if s[i] != c:
                index = bisect_left(_is[s[i]], i)
                del _is[s[i]][index]
                insort(_is[c], i)
                s[i] = c
        else:
            c = int(c) - 1
            cnt = 0
            for _isi in _is.values():
                if _isi:
                    is_in = bisect(_isi, c)-bisect_left(_isi, i)
                    if is_in:
                        cnt += 1
            print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 28424
import numpy as np

n, m = map(int, input().split())
adj = np.zeros((n, n), dtype=np.bool)
for _ in range(m):
  s, t = map(int, input().split())
  adj[s-1, t-1] = True
deg = adj.sum(axis=1)

ev = np.zeros(n, dtype=np.float)
for i in range(n - 2, -1, -1):
  ev[i] = ev[adj[i]].mean() + 1.

prob = np.zeros(n, dtype=np.float)
prob[0] = 1.
for i in range(n - 1):
  prob[adj[i]] += prob[i] / deg[i]

decrease = 0.
for i in np.where(deg > 1)[0]:
  now = ev[adj[i]].mean()
  cut = (ev[adj[i]].sum() - ev[adj[i]].max()) / (deg[i] - 1)
  decrease = np.maximum(decrease, (now - cut) * prob[i])
    
print(ev[0] - decrease)

Measured memory_bytes: 12876
import java.util.*;
 
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		long[] b = new long[N];
		long sum =0;
		
		for (int i=0; i<N; i++) {
			a[i] = sc.nextInt();
			b[a[i]-1]++;
		}
		for (int i=0; i<N; i++) {
			sum += b[i]*(b[i]-1)/2;
		}
		for (int i=0; i<N; i++) {
			System.out.println(sum-(b[a[i]-1]-1));
		}
	}
}


Measured memory_bytes: 105440
# 解説を読んだ後の解答
# 省メモリの工夫をやめて、より単純にしてみた

Sushi = Struct.new(:position, :calorie)

n, c = gets.chomp.split.map(&:to_i)
sushis_default = n.times.map do
  xv = gets.chomp.split.map(&:to_i)
  Sushi.new(*xv)
end

# 何も食べない場合、スタート地点にある0kcalのバーチャル寿司を食べたことにする
def virtual_sushi
  Sushi.new(0, 0)
end
sushis_forward = [virtual_sushi] + sushis_default
sushis_backward = [virtual_sushi] + sushis_default.reverse.map do |sushi|
  Sushi.new(c - sushi.position, sushi.calorie)
end

half_c = c / 2
n_in_half_forward =
  sushis_default.lazy.take_while { |s| s.position <= half_c } .count
    # 後続処理を考えると、ちょうどc/2にある寿司はどっちにも入れないのがベストだが、
    # 面倒なのでforwardに入れちゃう。
count_in_half_forward = n_in_half_forward + 1   # バーチャル寿司を含む
count_in_half_backward = n - n_in_half_forward + 1

EatResult = Struct.new(:calorie, :eat_count)
def eat_a_way_results(sushis)
  sushis
    .each_with_index
    .with_object({ intake_calorie_sum: 0 })
    .map do |(sushi, i), hash|
      hash[:intake_calorie_sum] += sushi.calorie
      calorie = hash[:intake_calorie_sum] - sushi.position
      EatResult.new(calorie, i)
        # バーチャル寿司を食べた時は食べた数を0とする。
    end
end
def eat_and_return_results(sushis, count_in_half, a_way_results)
  sushis
    .take(count_in_half)  # 後続処理を踏まえ、半分の距離までしか計算しない
    .zip(a_way_results)
    .map do |sushi, a_way_result|
      calorie = a_way_result.calorie - sushi.position
      EatResult.new(calorie, a_way_result.eat_count)
    end
end
f_results = eat_a_way_results(sushis_forward)
b_results = eat_a_way_results(sushis_backward)
fr_results =
  eat_and_return_results(sushis_forward, count_in_half_forward, f_results)
br_results =
  eat_and_return_results(sushis_backward, count_in_half_backward, b_results)
sushis_forward = nil
sushis_backward = nil

def max_calories(eat_results)
  eat_results.each_with_object(
    { max_calorie: -Float::INFINITY }
  ).map do |r, hash|
    if r.calorie > hash[:max_calorie]
      hash[:max_calorie] = r.calorie
    end
    hash[:max_calorie]
  end
end
max_fr_calories = max_calories(fr_results)
fr_results = nil
max_br_calories = max_calories(br_results)
br_results = nil

def max_calorie(n, max_return_calories, a_way_results)
  a_way_half_count = n - max_return_calories.length + 2
  max_under_half_a_way =
    a_way_results.take(a_way_half_count).map {|r| r.calorie }.max +
    max_return_calories.last
  max_over_half_a_way =
    a_way_results[a_way_half_count...a_way_results.length]
      .map do |a_way_result|
        a_way_result.calorie + max_return_calories[n - a_way_result.eat_count]
      end.max || 0
  [max_under_half_a_way, max_over_half_a_way].max
end
max_frb = max_calorie(n, max_fr_calories, b_results)
max_brf = max_calorie(n, max_br_calories, f_results)

puts [max_frb, max_brf].max


Measured memory_bytes: 35420
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <cmath>

#include <set>

#include <map>

#include <string>

#include <numeric>

#include <cstdio>

#include <cstdlib>

#include <ctime>

#include <iterator>

#include <cstring>

using namespace std;


const int INF = 10000000;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)

//char maze[100][101];

int sx, sy;

int gx, gy;

int qqq;

//各座標までの最短距離

int d[100][100];


//移動方向のベクトル

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int ans = 0;
pair<int, int> red[101], blue[101];
//ll a[200000], b[20000];

/*
//ユークリッドの互除法
ll gcd(ll x, ll y) {
if (x < y) swap(x, y);
if (y == 0) return x;
return gcd(y, x%y);
}

int isPrime(int x) {
int i;
if (x < 2) return 0;
else if (x == 2) return 1;
if (x % 2 == 0) return 0;
for (int i = 3; i*i <= x; i += 2)
if (x%i == 0) return 0;
return 1;
}

int v_find(std::vector<int> vec, int number) {
auto itr = std::find(vec.begin(), vec.end(), number);
if (itr != vec.end()) { // 発見できたとき
return 1;
}
else { // 発見できなかったとき
return 0;
}
}

int ok = 1000; //解が存在する値
int ng = -1;   //解が存在しない値

ll BIG = 10000000000;

ll POW(ll a, ll b) {
ll c = 1;
for (int i = 0; i < b; ++i) {
c *= a;
}
return c;
}

int Kaijou(int a) {
if (a < 2) return 1;
return a * Kaijou(a - 1);
}


ll aa[51];

pair<int, int> Sc[50];

int MOD = 1000000007;
int imos[200001];
int br[100000];
int grid[1001][1001];
ll bigdp[1099][1099];
int used[1000][1000];

//逆元の計算用(pは素数のときb=p-2で逆元)
ll calc(int a, int b, int p) {
if (b == 0) return 1;
if (b % 2 == 0) {
ll d = calc(a, b/2,p);
return (d*d) % p;
}
else {
return (a*calc(a, b - 1, p)) % p;
}
}

int h, w;
ll dp[1000][1000];

ll f(int a, int b) {
if (dp[a][b]) return dp[a][b];
ll m = 1;
if (a) if(grid[a-1][b]>grid[a][b]) m =(m+f(a-1,b))%MOD;
if (b) if (grid[a][b-1]>grid[a][b]) m =(m+ f(a, b - 1))%MOD;
if (a != h - 1) if (grid[a + 1][b]>grid[a][b]) m =(m+ f(a + 1, b))%MOD;
if (b != w - 1) if (grid[a][b+1]>grid[a][b])  m =(m+ f(a, b + 1))%MOD;
dp[a][b] = m;
return m;
}
*/

int main() {
	int n;
	cin >> n;
	int b[200002] = { 0 };
	int x[200002] = { 0 };
	rep(i, n) {
		cin >> b[i];
		x[i] = b[i];
	}
	sort(b, b + n);
	int a2;
	rep(i, n) {
		if (b[n / 2] == x[i]) {
			a2 = i;
		}
	}
	rep(i, n) {
		if (x[i] > b[n / 2 - 1]) cout << b[n / 2 - 1] << endl;
		else cout << b[n / 2] << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);

lli sum[200005] = {};
lli rec(lli l, lli r)
// [l, r)
{
  return sum[r] - sum[l];
}
bool pivot(lli l, lli r, lli piv)
{
  //  assert(l <= piv + 1 && piv < r - 1);
  return rec(piv, r) - rec(l, piv) > 0;
}
lli calc(int l, int r, int piv)
{
  return rec(piv, r) - rec(l, piv);
}
int good(int l, int r, int piv1, int piv2)
{
  if (abs(calc(l, r, piv1)) < abs(calc(l, r, piv2)))
    return piv1;
  return piv2;
}
pair<lli, lli> calc(lli l, lli r)
{
  lli low = l, up = r;
  while (up - low > 1)
  {
    lli mid = (up + low) / 2;
    if (pivot(l, r, mid))
    {
      low = mid;
    }
    else
    {
      up = mid;
    }
  }
  int go = good(l, r, low, up);
  return make_pair(rec(l, go), rec(go, r));
}
void solve(long long N, std::vector<long long> A)
{
  rep(i, N) sum[i + 1] = sum[i] + A[i];
  lli ans = 1e18;
  for (int i = 2; i <= N - 2; i++)
  {
    // [0, i) , [i, N) に分割
    int ll = 0, lr = i;
    int rl = i, rr = N;
    auto ls = calc(ll, lr);
    auto rs = calc(rl, rr);
    chmin(ans, max({ls.first, ls.second, rs.first, rs.second}) - min({ls.first, ls.second, rs.first, rs.second}));
  }
  cout << ans << endl;
}

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  for(int i=0;i<N;i++){
    cin >> m[i];
  }
  int a=0;
  for(int i=0;i<N;i++){
    a += m[i];
  }
  sort(m.begin(),m.end());
  cout << N+(X-a)/m.at(0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int h, w;
string table = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string s[100][100];

int main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w)cin >> s[i][j];
	}
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == "snuke") {
				cout << table[j] << i + 1 << endl;
			}
		}
	}
}

Measured memory_bytes: 384
#include <cstdio>

using namespace std;

int dp[110][5][5];

int main()
{
	int n, k;
	
	scanf("%d %d", &n, &k);
	
	int A[110] = {0};
	for (int i = 0; i < k; i++){
		int day, pasta;
		scanf("%d %d", &day, &pasta);
		A[day] = pasta;
	}
	
	dp[0][0][0] = 1;
	
	//dp[i日目][昨日のパスタ][今日のパスタ]
	
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < 4; j++){
			for (int a = 0; a < 4; a++){
				for (int b = 1; b < 4; b++){
					//dp[i-1][j][a] dp[i][a][b]
					if ((j != a || a != b) && (A[i] == 0 || A[i] == b)){
						dp[i][a][b] += dp[i-1][j][a];
						dp[i][a][b] %= 10000;
						//printf("%d\n", dp[i][a][b]);
					}
				}
			}
		}
	}
	
	int sum = 0;
	
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 4; j++){
			sum += dp[n][i][j];
			sum %= 10000;
		}
	}
	
	printf("%d\n", sum);
	
	return (0);
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    string s,t;
    cin>>s>>t;
    ll n = s.length();
    ll m = t.length();
    ll dp[n+1][m+1];

    for (int i = 0; i < n+1; ++i)
    {
        for (int j = 0; j < m+1; ++j)
        {
            dp[i][j]=0;
        }
    }

    for (int i = 1; i < n+1; ++i)
    {
        for (int j = 1; j < m+1; ++j)
        {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(s[i-1]==t[j-1]){
                dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
            }
        }
    }

    ll ind = dp[n][m];
    ll i=n;
    ll j=m;
    string ans="";

    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else{
            j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans;

    return 0;
}

Measured memory_bytes: 74012
import java.util.*;
import java.math.*;
import java.util.Scanner;
import java.math.BigInteger;

public class Main {
	static final long mod = (int) (1e9 + 7);
	static final int inf = (int) (1e9);
	static final int maxn = (int) (1e5 + 10);

	static long ksm(long a, long b) {
		long ret = 1;
		while (b != 0) {
			if (b % 2 == 1) {
				ret = ret * a % mod;
			}
			b >>= 1;
			a = a * a % mod;
		}
		return ret;
	}

	static int n, q;
	static String s;
	static int sum[] = new int[maxn];

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		n = cin.nextInt();
		q = cin.nextInt();
		s = cin.next();
		for (int i = 1; i < n; i++) {
			sum[i+1] = sum[i];
			if (s.charAt(i) == 'C' && s.charAt(i - 1) == 'A') {
				sum[i+1]++;
			}
		}
		for (int i = 1; i <= q; i++) {
			int l = cin.nextInt(), r = cin.nextInt();
			int ans = sum[r] - sum[l];
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 67740
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/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;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,k;
 sc(n);sc(k);
 ll ans=n-k+1;
 pr(ans);
  
return 0;}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
vector<int> a;
int n;
double dp[900][610][305];
bool vis[900][610][305];

double recur(int a,int b,int c) {
    //printf("%d %d %d\n",a,b,c);
    if(vis[a][b][c]) return dp[a][b][c];
    if(a== 0 && b == 0 && c == 0) {
        return (double) 0.00;
    }
    double x = 1 - (1.00 - ((a+b+c)*1.00/n)) ;
    dp[a][b][c] = 0;
    if(a > 0) {
        double k = a*1.00/n;
        dp[a][b][c] += recur(a-1,b,c)*(k/x) + k/(x*x) ;
    }

    if(b > 0) {
        double k = b*1.00/n;
        dp[a][b][c] += recur(a+1,b-1,c)*(k/x) + (k/(x*x)) ;
    }

    if(c > 0) {
        double k = c*1.00/n;
        dp[a][b][c] += recur(a,b+1,c-1)*(k/x) + k/(x*x) ;
    }
    vis[a][b][c] = true;
    return dp[a][b][c];
}
int main() {
    cin>>n;
    a.resize(n);
    int cnt[4] = {0};
    for(int i = 0;i<n;i++) {
        cin>>a[i];
        cnt[a[i]]++;
    }
    cout<<setprecision(15)<<recur(cnt[1],cnt[2],cnt[3])<<"\n";

}

Measured memory_bytes: 492928
class DisjointSet:
    def __init__(self, n):
        self.p = list(range(n))
        self.rank = [0] * n

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

    def unite(self, x, y):
        self.__link(self.find_set(x), self.find_set(y))

    def __link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def find_set(self, x):
        if x != self.p[x]:
            self.p[x] = self.find_set(self.p[x])
        return self.p[x]


def main():
    n, q = map(int, input().split())
    ds = DisjointSet(n)
    for _ in range(q):
        com, x, y = map(int, input().split())
        if com == 0:
            ds.unite(x, y)
        elif com == 1:
            print(1 if ds.same(x, y) else 0)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6040
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pri 1000000007
using namespace std;
ll col[100001];
void dfs(ll st,vector <pair<ll,ll> > adj[],ll c,ll old){
	col[st]=c;
	for(auto x:adj[st]){
		if(x.ff==old)continue;
		ll w=x.ss;
		if(w%2==0){
			dfs(x.ff,adj,c,st);
		}
		else{
			ll e=1;
			dfs(x.ff,adj,(c^e),st);
		}
		
	}
	
}
void run(){
	ll n,k;
	cin>>n;

vector <pair<ll,ll> > adj[n+1];
	for(ll j=1;j<=n-1;j++)
	{ll u,v,w;
	cin>>u>>v>>w;
	adj[u].PB(MP(v,w));
	adj[v].PB(MP(u,w));
	}
	dfs(1,adj,0,-1);
for(ll i=0;i<n;i++){
	cout<<col[i+1]<<endl;
}
	
}
int main() {
	ll t=1;
	//cin>>t;
	for(ll j=0;j<t;j++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
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);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
int main()
{
	dhoom;
	int r , g;
	cin >> r >> g;
	cout << 2 * g - r << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		var h=new long[200001];
		for(int i = 0;i<n;i++) {
			h[a[i]]++;
		}
		long ans=0;
		for(int i = 0;i<h.Length;i++) {
			if(h[i]>1){
				ans+=h[i]*(h[i]-1)/2;
			}
		}
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<n;i++) {
			long p=h[a[i]],g=ans;
			g-=p*(p-1)/2;
			p--;
			g+=p*(p-1)/2;
			sb.Append(g+"\n");
		}
		Console.Write(sb);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 38192
#include <stdio.h>
int main(void)
{
    int n, i, cnt = 0;
    scanf("%d", &n);
    int p[n];
    for(i=0; i<n; i++){
        scanf("%d", &p[i]);
    }

    for(i=1; i<n-1; i++){
        if(p[i-1]<p[i] && p[i]<p[i+1] || p[i+1]<p[i] && p[i]<p[i-1])
        cnt++;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
int main(){

	int n,m;
	int dist[100001];
	while(cin>>n>>m&&!(n==0&&m==0)){
		memset(dist,0,sizeof(dist));
		int sumDist=0;
		for(int i = 1; i <= n; i++){
			dist[i]=sumDist;
			if(i==n)
				break;
			int t;
			cin>>t;
			sumDist+=t;
		}
		int cp=1;
		int movingDistance=0;
		for(int i = 0; i < m; i++){
			int dd;
			cin>>dd;
			cp+=dd;
			movingDistance+=abs(dist[cp]-dist[cp-dd]);
			movingDistance%=100000;
		}
		cout<<movingDistance%100000<<endl;
	}

	return 0;
}

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

void calc(string s) {
  int len = s.size();
  if (s.size() == 0) return;

  for (int i = 0; i < len; i++) {
    if (s[i] == '+') {
      num += stoll(s.substr(0, i));
      s.erase(s.begin(), s.begin() + i + 1);
      calc(s);
      return;
    }
  }
  num += stoll(s);
}

int main() {
  string s;
  cin >> s;
  int len = s.size();
  vector<string> ans;

  for (int bit = 0; bit < (1 << len - 1); bit++) {
    string temp = s;
    int count = 0;
    for (int i = 0; i < len - 1; i++) {
      if ((bit >> i) & 1) {
        temp.insert(i + 1 + count, "+");
        count++;
      }
    }
    ans.push_back(temp);
  }

  for (auto it = ans.begin(); it != ans.end(); it++) {
    calc(*it);
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 200

#define WHITE 0 
#define GRAY 5
#define BLACK -5



int array[N][N];
int d[N];
int f[N];
int color[N];
int time_count=0;
int number;


void depthsearch(int u){

  int i;
  
  color[u]=GRAY;
  d[u]=++time_count;

  for(i=0;i<number;i++){
   
    if(color[i]==WHITE && array[u][i]==1){depthsearch(i);}

  }

  color[u]=BLACK;
  f[u]=++time_count;

}







void depth( ){
 
  int i;
  
  //白の初期化
  for(i=0;i<number;i++){
    color[i]=WHITE;
   
  }


  for(i=0;i<number;i++){
    if(color[i]==WHITE){depthsearch(i);}

  }

  
  for(i=0;i<number;i++){
   
    printf("%d %d %d\n",i+1,d[i],f[i]);


  }
  


}


int main(){

  
  
  scanf("%d",&number);


  int me;
  int count;


  int i,j;
  int u;


for(i=0;i<number;i++){
    for(j=0;j<number;j++){
      array[i][j]=0;
    }
  }





 for(i=0;i<number;i++){
   scanf("%d",&me);
   scanf("%d",&count);
   
   for(j=1;j<count+1;j++){
     scanf("%d",&u);
     
     
     array[me-1][u-1]=1;
    
     
     
   }
 }



 
 
 depth();
 
  return 0;}



Measured memory_bytes: 2048
#include<iostream>
using namespace std;
main()
{
	int a,b;
	cin>>a>>b;
	if(a+b==4)
	{
		cout<<2<<endl;
	}
	if(a+b==3)
	{
		cout<<3<<endl;
	}
	if(a+b==5)
	{
		cout<<1<<endl;
	}
}


Measured memory_bytes: 3596
#include <stdio.h>

long f(long n, long x) {
    if (n >= 0) {
        return n / x + 1;
    }
    return 0;
}

int main(void)
{
    int res;

    long a, b, x;
    long n;

    // input
    res = scanf("%ld%ld%ld", &a, &b, &x);
    // output
    printf("%ld\n", f(b, x) - f(a - 1, x));

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001; const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int to, from, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};

string s;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> s;
  int a = 0;
  rep(i, 0, s.size()) if (s[i] == '2') a++;
  cout << a << endl;
  return 0;
}



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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> A(a,b-c);
  rep(i,c){
    int d;
    cin >> d;
    A.at(d-1)++;
  }
  rep(i,a) if(A.at(i) > 0) cout << "Yes" << endl; else cout << "No" << endl;
}

Measured memory_bytes: 1024
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n;
  cin >> n;
  ll x[n],y[n];
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
  }
  double gx,gy;
  gx = 0;
  gy = 0;
  double lambda = 0.999;
  ll ex,ey;
  double e = 0;
  ll count = 0;
  while(count < 1000000){
    e = 0;
    count++;
    for(int i=0;i<n;i++){
      if(pow(x[i]-gx,2)+pow(y[i]-gy,2) > e){
        e = pow(x[i]-gx,2)+pow(y[i]-gy,2);
        ex = x[i];
        ey = y[i];
      }
    }
    gx += (ex-gx)*lambda;
    gy += (ey-gy)*lambda;
    lambda *= 0.999;
  }
  cout << setprecision(20) << sqrt(e) << endl;
  return 0;
}


Measured memory_bytes: 256
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(arr[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;
#define ll long long 
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48,ch=getchar();}
	return x*f;
}
const int maxn = 200100;
struct edge{int to,next;}e[maxn*2];
int tot,head[maxn];
void add(int u,int v){
	e[++tot].to=v;
	e[tot].next=head[u];
	head[u]=tot;
}
int deep[maxn],f[maxn];
void dfs(int u,int fa){
	for(int i=head[u];i;i=e[i].next){
		int to=e[i].to;
		if(to==fa) continue;
		deep[to]=deep[u]+1;
		dfs(to,u);
	}
}
int main(){
	
	int n=read();
	for(int i=1;i<n;i++){
		int a=read(),b=read();
		add(a,b);add(b,a);
	}
	dfs(1,0);
	int mx=0;
	for(int i=1;i<=n;i++){
		if(deep[i]>deep[mx]) mx=i;
	}
	memset(deep,0,sizeof deep);
	deep[mx]=1;
	dfs(mx,0);
	int len=0;
	for(int i=1;i<=n;i++){
		if(deep[i]>len) len=deep[i];
	}
	
	f[0]=1,f[1]=1,f[2]=0;
	for(int i=3;i<=len;i++){
		if((f[i-1])&&(f[i-2])) f[i]=0;
		else f[i]=1;
	}
	if(f[len]) printf("First\n");
	else printf("Second\n");
	return 0;
}
  

Measured memory_bytes: 15104
n=int(input())
t=list(map(int,input().split(" ")))

t_max=max(t)

j=0
t_sum=0
while j<=n-1:
    t_sum+=t[j]
    j+=1
        
if t_sum>2*t_max:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();
		System.out.println((a<10&&b<10)? a*b:"-1");
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
#define Norma 1000000

int main(){
	while(1){
		long long sale[4001],a,b,c,i,j,n;
		int k=0;
		cin>>n;
		if(n==0)break;
		for(i=0;i<4001;i++){
			sale[i]=0;
		}
		for(i=0;i<n;i++){
			cin>>a>>b>>c;
			if(sale[a]>=0){
				sale[a]+=b*c;
				if(sale[a]>=Norma){
					cout<<a<<endl;
					sale[a]=-1;
					k++;
				}
			}
		}
		if(k==0){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1184
import math

a,b,h,m=map(int,input().split())
seconds=h*60+m
kaku=seconds*5.5
k_kaku=kaku%360
if k_kaku>180:
  g_kaku=360-k_kaku
else :
  g_kaku=k_kaku
p_kaku=math.radians(g_kaku)
cos=math.cos(p_kaku)
l=a**2+b**2-2*a*b*cos
len=math.sqrt(l)
print(len)


Measured memory_bytes: 9520
#include<bits/stdc++.h>
using namespace std;
string S;int a[3],i;
main(){
	cin>>S;if(S=="mewmew"){goto E;}
	for(i=0;i<S.size()-1;i++){
		if(S.substr(i,2)=="mw"){goto E;}
	}
	for(int i=0;i<S.size();i++){
		if(S[i]=='m'){a[0]++;}
		else if(S[i]=='e'){a[1]++;}
		else{a[2]++;}
		if(!(a[0]>=a[1]&&a[1]>=a[2])){goto E;}
	}
	cout<<"Cat"<<endl;goto F;
E:;
	cout<<"Rabbit"<<endl;
F:;
}

Measured memory_bytes: 1196
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

const int N = 100000 + 5;

int n;
int a[N];
int f[N];
vector<int> adj[N];

int cmp(const int &a, const int &b)
{
    return f[a] < f[b];
}

void dfs(int i)
{
    for(auto e: adj[i]) {
        dfs(e);
    }
    sort(adj[i].begin(), adj[i].end(), cmp);
    f[i] = 0;
    for(int j = 0; j < adj[i].size(); ++ j) {
        f[i] = max(f[i], f[adj[i][j]] + (int)adj[i].size() - j);
    }
}

void solve()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i < n; ++ i) {
        cin >> a[i];
        a[i]--;
        adj[a[i]].push_back(i);
    }
    dfs(0);
    cout << f[0] << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main() {
  string A,B,C;
  cin >> A >> B >> C;
  if(A.at(A.size() - 1) == B.at(0) && B.at(B.size() - 1) == C.at(0)) {
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

bool comp(pll &a, pll &b)
{
    if(a.second != b.second) return a.second < b.second;
    else a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    vpl xls;
    xls.resize(n);
    for(int i=0; i<n; i++)
    {
        ll x, l;
        cin >> x >> l;
        xls.at(i) = make_pair(x, l);
    }

    vpl sgs;
    for(auto &p : xls)
    {
        ll s = p.first - p.second;
        ll g = p.first + p.second;
        sgs.push_back(make_pair(s, g));
    }
    sort(sgs.begin(), sgs.end(), comp);
    // for(auto &p : sgs)
    // {
    //     cout << p.first << ", " << p.second << endl;
    // }

    int cnt = 1;
    ll k = sgs.at(0).second;
    for(auto &p : sgs)
    {
        if(k <= p.first)
        {
            cnt++;
            k = p.second;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

vector<ll> prime_factor(ll n){
    vector<ll> res;
  	ll m=n;
    for(ll i=2; i*i<=m; i++){
        if(n%i==0){
            ll k=0;
            while(n%i==0){
          	    n /= i;
                k++;
            }
            res.push_back(k);
        }
    }
  	if(n!=1) res.push_back(1); 
    return res;
}

ll check(ll k){
    if(1<=k && k<3) return 1;
    if(3<=k && k<6) return 2;
    if(6<=k && k<10) return 3;
    if(10<=k && k<15) return 4;
    if(15<=k && k<21) return 5;
    if(21<=k && k<28) return 6;
    if(28<=k && k<36) return 7;
    if(36<=k && k<45) return 8;
    if(45<=k && k<55) return 9;
    if(55<=k && k<66) return 10;
}

int main(){
    ll N;
    cin >> N;
  	vector<ll> res;
    res = prime_factor(N);
    ll ans=0;
    for(ll i=0; i<res.size(); i++){
        ans += check(res.at(i));
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3632
N=int(input())
X=input().split()
X=[int(x)for x in X]

min_d=100*10000
for P in range(1,101):
    sum_d=0
    for i in range(N):
        sum_d+=(X[i]-P)**2
    min_d=min(min_d,sum_d)

print(min_d)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {

	var n int
	fmt.Scan(&n)
	nums := make([]int, n)

	for i := 0 ; i < n ; i++ {
		fmt.Scan(&nums[i])
	}

	flag := true
	count := 0
	for flag {
		for  i := 0 ; i < n ; i++ {
			if nums[i] % 2 == 0 {
				nums[i] = nums[i] / 2
			}else{
				flag = false
				break
			}
		}
		if flag {
			count++
		}
	}
	
	fmt.Println(count)

}


Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
#include<cmath>
#define mod 1000000007
#define pa(a,b) make_pair(a,b)
#define LL  long long int
using namespace std;
int buf[50];
inline void write(int x)
{
	int p=0;
	do{
		buf[p++]=x%10;
		x/=10;
	}while(x>0);
	for(int i=p-1;i>=0;i--)putchar('0'+buf[i]);
}
long long int read_int(){
	char r;
	bool start=false,neg=false;
	long long int ret=0;
	while(true){
		r=getchar();
		if((r-'0'<0 || r-'0'>9) && r!='-' && !start){
			continue;
		}
		if((r-'0'<0 || r-'0'>9) && r!='-' && start){
			break;
		}
		if(start)ret*=10;
		start=true;
		if(r=='-')neg=true;
		else ret+=r-'0';
	}
	if(!neg)
		return ret;
	else
		return -ret;
}
int main()
{
    int  n ; int a[20020];
    cin>>n ; for(int i=0;i<n;i++)cin>>a[i]; sort(a,a+n);
    cout<<a[n-1]-a[0];
}


Measured memory_bytes: 256
<?php
list($a, $b, $c, $k) = explode(" ", trim(fgets(STDIN)));

if($k <= $a){
  echo $k;
  exit;
}
if($k <= ($a + $b)){
  echo $a;
  exit;
}

$sa = $k - ($a + $b);

echo $a - $sa;
exit;




Measured memory_bytes: 16244
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN=1e5+7;
int N,W,ans;
ll w[MAXN],v[MAXN],f[MAXN];
int main()
{
	cin>>N>>W;
	for(int i=1;i<=N;i++) cin>>w[i]>>v[i];
	memset(f,127,sizeof(f));
	f[0]=0;
	for(int i=1;i<=N;i++)
		for(int j=MAXN-1;j>=v[i];j--)
			f[j]=min(f[j],f[j-v[i]]+w[i]);
	for(int i=0;i<MAXN;i++)
		if(f[i]<=W) ans=max(ans,i);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int q;
    cin >> q;
    vector<int> l(q);
    vector<int> r(q);
    for(int i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i];
    }

    vector<int> s(100001);
    s[1] = 1;
    for(int i = 3; i <= 100000; i+=2)
    {
        int count = 0, counta = 0;
        for(int j = 2; j * j <= i; j++)
        {
            if(i % j == 0) count++;
        }
        int ii = (i+1) / 2;
        for(int j = 2; j * j <= ii ; j++)
        {
            if(ii % j == 0) counta++;
        }
        if(count == 0 && counta == 0)
        {
            s[i] = s[i-2] + 1;
        }
        else
        {
            s[i] = s[i-2];
        }
    }
    for(int i = 0; i < q; i++)
    {
        if(l[i] == 1)
        {
            cout << s[r[i]] - 1 << endl;
        }
        else
        {
        	cout << s[r[i]] - s[l[i]-2] << endl;
        }
    }
}


Measured memory_bytes: 1792
/*C - Sum of gcd of Tuples (Easy)*/
#include <bits/stdc++.h>
using namespace std;

using Long = long long;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int k;

	cin >> k;

	int ans = 0;

	for (int a = 1; a <= k; ++a)
	{
		for (int b = 1; b <= k; ++b)
		{
			for (int c = 1; c <= k; ++c)
			{
				int gcd = __gcd(a, b);
				gcd = __gcd(gcd, c);
				ans += gcd;
			}
		}
	}

	cout << ans;
	

	return 0;
}

Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main() {
  while (1) {
    int H, W;
    cin >> H >> W;
    if (H == 0 && W == 0) {
      break;
    }

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
          cout << "#";
        } else {
          cout << ".";
        }
      }

      cout << endl;
    }

    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3064
import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        double r = Double.parseDouble(sc.next());
        
        double area = r * r * Math.PI;
        double circle = 2 * r * Math.PI;
        
        System.out.println(String.format("%.8f",area) + " " + String.format("%.8f",circle));

    }

}



Measured memory_bytes: 26436
Q, H, S, D=map(int,input().split())
N=int(input())
Q_1liter=4*Q
H_1liter=2*H
S_1liter=S
min_QHS=min(Q_1liter,H_1liter,S_1liter)
min_QHS2=min(min_QHS*2,D)
if N%2==0:
    output=min_QHS2*(N//2)
    print(int(output))
else:
    output=((N//2)*min_QHS2+min_QHS)
    print(int(output))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k;
	cin>>m>>n;
	for(int i=0;i<n;i++){
		cin>>k;
		m-=k;
	}
	cout<<(m<=0?"Yes":"No")<<endl;
	return 0;
} 

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

using namespace std;

vector <int> D[100002], T;
int De[100002];

void dfs(int d, int p)
{
    for (int i = 0; i < D[d].size(); i++)
    {
        int a = D[d][i];
        if (a != p)
        {
            De[a] = De[d] + 1;
            dfs(a, d);
        }
    }
}

int main()
{
    int n, u, v, a, b, DeM=0;
    cin >> n >> u >> v;
    int g[n+1];
    for (int i = 0; i < n-1; i++)
    {
        cin >> a >> b;
        D[a].push_back(b);
        D[b].push_back(a);
    }
    for (int i = 1; i <= n; i++)
    {
        g[i] = 1;
    }
    De[v] = 0;
    dfs(v, -1);
    DeM = De[u];
    T.push_back(u);
    g[u] = 0;
    for (int i = 0; i < T.size(); i++)
    {
        a = T[i];
        for (int y = 0; y < D[a].size(); y++)
        {
            b = D[a][y];
            if (g[b] == 1 && De[b] > De[u]/2)
            {
                g[b] = 0;
                T.push_back(b);
                DeM = max(DeM, De[b]);
            }
        }
    }
    cout << DeM-1;
    return 0;
}


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

int main(){
  int w,a,b;
  cin>>w>>a>>b;
 if(a+w<b)
  {
    cout<<b-(a+w)<<endl;
  }
  else if(b+w<a)
  {
    cout<<a-(b+w)<<endl;
  }
  else
  {
    cout<<0<<endl;
  }
  
  
  
  }

Measured memory_bytes: 256
S,K=input().split()
K=int(K)
K=min(K,300)
mod=998244353
a=[]
val=0
for i in range(len(S)):
    if S[i]=="0":
        a.append(val)
        val=0
    else:
        val+=1

if val!=0:
    a.append(val)
m=len(a)
K=min(sum(a),K)

dp=[[[0 for i in range(K+1)] for j in range(K+1)] for k in range(m+1)]

for j in range(K+1):
    dp[m][j][j]=1

b=[a[i] for i in range(m)]
c=[a[i] for i in range(m)]
for i in range(1,m):
    b[i]+=b[i-1]
b=[0]+b
for i in range(m-2,-1,-1):
    c[i]+=c[i+1]
for i in range(m-1,-1,-1):
    for j in range(K+1):
        for k in range(min(b[i],K)+1):
            M=max(k-j,-a[i])
            dp[i][j][k]=sum(dp[i+1][j+l][k] for l in range(max(0,M),K-j+1))+sum(dp[i+1][j][k+l] for l in range(1,min(K-k,-M)+1))
            dp[i][j][k]%=mod

print(dp[0][0][0])


Measured memory_bytes: 109040
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll n;
    cin >> n;
    if (n % 10 == 3) {
        cout << "bon" << endl;
        return 0;
    }
    vll a = {2, 4, 5, 7, 9};
    for (auto x : a) {
        if (n % 10 == x) {
            cout << "hon" << endl;
            return 0;
        }
    }
    cout << "pon" << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200025,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,g[N][2],b[N],fa[N],ans[N];
vector<int> e[N];
struct segment_tree{
	int siz,root[N],f[N*40],ch[N*40][2];
	void add(int x,int l,int r,int pos){
		if (l==r) {f[x]++;return;}
		int mid=(l+r)>>1;
		if (pos<=mid){
			if (!ch[x][0]) ch[x][0]=++siz;
			add(ch[x][0],l,mid,pos);
		}
		else{
			if (!ch[x][1]) ch[x][1]=++siz;
			add(ch[x][1],mid+1,r,pos);
		}
	}
	void add(int x,int pos){
		if (!root[x]) root[x]=++siz;
		add(root[x],1,n,pos);
	}
	int merge(int x,int y,int l,int r){
		if (!x) return y;if (!y) return x;
		int cur=++siz,mid=(l+r)>>1;
		if (l==r){f[cur]=f[x]+f[y];return cur;}
		ch[cur][0]=merge(ch[x][0],ch[y][0],l,mid);
		ch[cur][1]=merge(ch[x][1],ch[y][1],mid+1,r);
		return cur;
	}
	void merge(int x,int y){root[x]=merge(root[x],root[y],1,n);}
	int count(int x,int val){
		if (!val) return 0;
		int l=1,r=n,mid;x=root[x];
		while (x&&(l!=r)){
			mid=(l+r)>>1;
			if (val<=mid) r=mid,x=ch[x][0];
			else l=mid+1,x=ch[x][1];
		}
		return f[x];
	}
}f[2];
void work(int x,int fa){
	if (x>g[fa][0]) g[x][0]=x,g[x][1]=g[fa][0];
	else if (x>g[fa][1]) g[x][0]=g[fa][0],g[x][1]=x;
	else g[x][0]=g[fa][0],g[x][1]=g[fa][1];
	b[x]=(g[x][0]==fa) ? x : b[fa];
	f[0].add(x,g[x][0]);
	f[1].add(x,g[x][1]);
	for (auto y : e[x])
	if (y!=fa){
		work(y,x);
		f[0].merge(x,y);
		f[1].merge(x,y);
	}
}
void calc(int x,int fath){
	fa[x]=fath;
	if (x==g[x][0]) ans[x]=ans[fa[x]]+f[1].count(x,g[x][1]);
	else{
		int y=g[x][0];
		ans[x]=ans[fa[y]]+f[0].count(b[x],y)+f[1].count(y,g[y][1])-f[1].count(b[x],g[y][1]);
	}for (auto y : e[x])
	if (y!=fath) calc(y,x);
}
int main(){
	n=read();
	for (int i=1;i<n;i++){
		int u=read(),v=read();
		e[u].push_back(v);
		e[v].push_back(u);
	}
	work(1,0);
	calc(1,0);
	for (int i=2;i<=n;i++) printf("%d ",ans[i]);
	printf("\n");
	return 0;
}

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

using namespace std;


#include <math.h> 


int main() {

	int N;

	cin >> N;

	map<string,int> a;

	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;

		a[s]++;


	}

	
	cout << "AC x " << a["AC"] << endl;
	cout << "WA x " << a["WA"] << endl;
	cout << "TLE x " << a["TLE"] << endl;
	cout << "RE x " << a["RE"] << endl;

	return 0;
}

Measured memory_bytes: 3624