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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    
    string ans = "NO";
    irep2(i, 1, b) {
        if(a*i % b == c) {
            ans = "YES"; 
        }
    }

    cout << ans << endl;
    
    return 0;
}   
/** atcoder **/


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

using namespace std;

#define For(i , a , b) for (int i = a , _b = b ; i <= _b ; ++i)
#define Ford(i , a  ,b) for (int i = a , _b = b : i >= _b ; --i)
#define Rep(i , n) for (int i = 0 , _n = n ; i < _n ; ++i)
#define sz(A) ((int)A.size())
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)

typedef pair<int , int> pt;

const int maxn = 1000000 + 123;
int n, a[maxn];

int nextInt() {
	int res = 0; char c = 0;
	while (c < '0' || c > '9') c = getchar();
	for (; c >= '0' && c <= '9'; c = getchar()) res = res * 10 + c - 48;
	return res;
}

void ReadData() {
	n = nextInt();
	For(i,1,n) a[i] = nextInt();
}


int toTang[maxn], toGiam[maxn];
int dp[maxn];

void Process() {
	For(i,1,n) {
		toTang[i] = 1;
		toGiam[i] = 1;
		if (a[i] >= a[i - 1]) toTang[i] = max(toTang[i], toTang[i - 1] + 1);
		if (a[i] <= a[i - 1]) toGiam[i] = max(toGiam[i], toGiam[i - 1] + 1);
	}
	For(i,1,n) {
		dp[i] = min(dp[i - toGiam[i]], dp[i - toTang[i]]) + 1;
	}
	cout << dp[n] << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	//freopen("input.inp" , "r" , stdin);
	ReadData();
	Process();

	return 0;

}			

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

class TSort{
public:
  int V;
  vector<unordered_set<int> > in,out;
  vector<int> tp;
  TSort():V(0){}
  TSort(int V):V(V),in(V),out(V){}
  
  void add_edge(int from,int to){
    assert(from >= 0 && to >= 0);
    assert(from < V && to < V);
    out[from].insert(to);
    in[to].insert(from);
  }

  vector<int> dfs(){
    vector<int> visited(V,0);
    
    function<void(int)> dfs = [&](int pos){
      if(visited[pos]++) return;
      for(int nx:out[pos]) dfs(nx);
      tp.push_back(pos);
    };
    
    tp.clear();
    for(int i=0;i<V;i++) dfs(i);
    reverse(tp.begin(),tp.end());
    return tp;
  }

  vector<int> bfs(){
    vector<unordered_set<int> > tmp = in;
    tp.clear();
    queue<int> Q;
    for(int i=0;i<V;i++)if(in[i].empty()) Q.push(i);
    
    while(!Q.empty()){
      int v = Q.front();Q.pop();
      tp.push_back(v);
      for(int nx:out[v]){
        if(in[nx].size() == 1) Q.push(nx);
        in[nx].erase(v);
      }     
    }
    swap(in,tmp);
    for(int i=0;i<V;i++) if(!tmp[i].empty()) tp.clear(); // exist loop
    return tp;
  }
};


int main(){
  int n,m;
  cin>>n>>m;
  TSort A(n);
  
  for(int i=0,a,b;i<m;i++)cin>>a>>b,A.add_edge(a,b);
  
  A.bfs();
  for(int i=0;i<n;i++)cout<<A.tp[i]<<endl;
  return 0;
}



Measured memory_bytes: 10656
n, m = map(int, input().split())
n += 1
a = [0]*n
for i in range(m):
    el = int(input())
    a[el] = 1
dp = [0]*n
dp[0] = 1

for i in range(1,n):
    if a[i] == 1: continue
    dp[i] += dp[i-1]
    if i - 2 >= 0:
        dp[i] += dp[i-2]
        dp[i] %= 1000000007
print(dp[n-1])

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

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

  int pos = 1;
  int ans = 1;
  for (int i = 1; i < N + 1; i++) {
    if (v[pos] == 2) {
      cout << ans << endl;
      return 0;
    } else {
      pos = v[pos];
      ans++;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 640
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    long k,a,b;
    scan(k, a, b);

    if (a >= k) {
        writeln(1);
        return;
    }

    if (a <= b) {
        writeln(-1);
    }
    else {
        long s = a - b;
        long ans = (k - a + s - 1) / s;
        ans = 2*ans + 1;
        writeln(ans);
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int a,b; cin>>a>>b;
    if(a==b)cout<<"Draw"<<endl;
    else if(a==1)cout<<"Alice"<<endl;
    else if(b==1)cout<<"Bob"<<endl;
    else if(a<b)cout<<"Bob"<<endl;
    else cout<<"Alice"<<endl;
}





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

int main (){
    int counter[4] = {1, 1, 1, 1};
    int total = 0;
    int N;

    cin >> N;
    char S[N];

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

    for (int i = 0; i < N; i++) {
        if (S[i] == 'P') {
        if (counter[0] == 1){
            total++;
            counter[0] = 0;
        }
        }
        else if (S[i] == 'W') {
            if (counter[1] == 1){
                total++;
                counter[1] = 0;
            }
        }
        else if (S[i] == 'G') {
            if (counter[2] == 1){
                total++;
                counter[2] = 0;
            }
        }
        else if (S[i] == 'Y') {
            if (counter[3] == 1){
                total++;
                counter[3] = 0;
            }
        }
        else {

        }
    }

    if (total == 3){
        cout << "Three" << endl;
    }
    if (total == 4){
        cout << "Four" << endl;
    }
}


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

int main(){
    long long x,a,b;
    cin >> x >> a >> b;
    if (a >= b){
        cout << "delicious" << endl;
    }else if (b-a <= x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n,q;
int a,b;
vector<int> v[MAXN];
int d[MAXN];

void dfs(int node, int add , int back)
{
	d[node] += add;

	for (int i = 0; i < v[node].size(); ++i)
	{
		int t = v[node][i];
		if(t != back)
			dfs(t, d[node], node);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> q;
	for (int i = 0; i < n-1; ++i)
	{
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}

	while(q--)
	{
		cin >> a >> b;
		d[a] += b;
	}

	for (int i = 1; i <= n; ++i)
		TRACE2(i,d[i]);

	dfs(1,0,-1);

	for (int i = 1; i <= n; ++i)
		cout << d[i] << " ";
}

Measured memory_bytes: 21760
#include <iostream>

int main () {
    int n, k;
    std::cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; ++i){
        std::cin >> a[i];
    }

    for (int i = k; i < n; ++i){
        if(a[i-k] < a[i]){
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }
    }
}

Measured memory_bytes: 4404
from collections import Counter
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
A_set = np.unique(A)
count_dict= Counter(A)
count_sum = np.sum([count_dict[i]*(count_dict[i]-1)/2 for i in A_set])

out = [int(count_sum-count_dict[i]+1) for i in A]
for i in out:
    print(i)

Measured memory_bytes: 34972
#include<iostream>

using namespace std;

int C[200000];

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

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

  int max = 0;
  for(int i = 0; i < 200000; i++) {
    if(max < C[i]) {
      max = C[i];
    }
  }
  cout << max << endl;

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  set<int> mochi;
  int temp;
  
  for (int i=0; i<N; ++i){
    cin >> temp;
    mochi.insert(temp);
  }
  
  cout << mochi.size() << endl;
  return 0;
}

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

const int MAXN = 100005;

int N;
int cnt[MAXN];
int mx, mn = MAXN;

void load() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
		mx = max(mx, x);
		mn = min(mn, x);
	}
}

bool solve() {
	if (mx - mn > 1)
		return false;
	if (mx == mn) 
		return mx == N - 1 || mx <= N / 2;
	return mx > cnt[mn] && mx - cnt[mn] <= cnt[mx] / 2;
}

int main() {
	load();
	puts(solve() ? "Yes" : "No");
	return 0;
}	

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, M;
  cin>>N>>M;
  ll A[N+1];
  A[0] = 0;
  for(int i=1;i<=N;++i) {
    cin>>A[i];
  }
  for(int i=1;i<=N;++i) {
    A[i] += A[i-1];
    A[i] %= M;
  }
  map<ll, ll> amap;
  vector<ll> arr;
  for(int i=0;i<=N;++i) {
    if(amap[A[i]]==0) arr.push_back(A[i]);
    amap[A[i]]++;
  }
  ll ans = 0;
  for(int i=0;i<arr.size();++i) {
    ans += amap[arr[i]]*(amap[arr[i]]-1)/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 8520
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){
    int k,a,b;
    cin >> k;
    cin >> a >> b;
    for (int i = 0; b>=k*i; i++)
    {
        if(k*i>=a){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout  << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    P.sort()
    answer = INF
    diff = INF
    for i in range(-100, 200):
        if i in P:
            continue
        if abs(X - i) < diff:
            answer = i
            diff = abs(X - i)
    print(answer)


if __name__ == "__main__":
    main()


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

int main(){
  int a,b;
  cin>>a>>b;
  for(int i=b*10;i<b*10+9;i++){
    int c = floor(i*.08);
    if(c==a){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;

  int ans = 0;
  if(a > 12) ans = b;
  else if(a >= 6) ans = b/2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define li long long
#define gc getchar()
#define pc putchar
inline li read(){
	li x = 0,y = 0,c = gc;
	while(!isdigit(c)) y = c,c = gc;
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ '0'),c = gc;
	return y == '-' ? -x : x;
}
inline void print(li q){
	if(q < 0){
		pc('-');
		q = -q;
	}
	if(q >= 10) print(q / 10);
	pc(q % 10 + '0');
}
li s1 = 19260817,s2 = 23333333,s3 = 998244853,srd;
inline li rd(){
	return srd = (srd * s1 + s2 + rand()) % s3;
}
int n,m;
inline void file(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
//const int mo = 998244353;
const int mo = 1000000007;
int a[200010],pre[200010],lst[200010];
li f[200010];
int main(){
	srand(time(0));rd();
	//file();
	int i,j;
	n = read();for(i = 1;i <= n;++i){
		a[i] = read();
		if(a[i] == a[i - 1]) --i,--n;
		else{
			pre[i] = lst[a[i]];lst[a[i]] = i;
		}
	} 
	f[0] = 1;
	for(i = 1;i <= n;++i) f[i] = (f[i - 1] + (pre[i] ? f[pre[i]] : 0)) % mo;//,cerr<<f[i]<<" ";
	print(f[n]);
	return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

pii pos[90050];

int sum[90050];
int main() {
	int H, W, D, i, j, k;
	scanf("%d %d %d", &H, &W, &D);
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			int t;
			scanf("%d", &t);
			pos[t] = pii(i, j);
		}
	}

	for (i = D + 1; i <= H*W; i++) sum[i] = sum[i - D] + abs(pos[i].first - pos[i - D].first) + abs(pos[i].second - pos[i - D].second);


	int Q;
	scanf("%d", &Q);
	while (Q--) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		printf("%d\n", sum[t2] - sum[t1]);
	}
	return 0;

}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    string s,t;
    cin >> s >> t;
    t.pop_back();
    if(s == t)yes;
    else no;
    return 0;
}


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

const int MX = 200005;
const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x( (x%mod + mod) % mod ) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ( (x += a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ( ( x += mod - a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        ( x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }


struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator() (int n, int k) {
        if ( k < 0 || k > n ) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
} comb(MX);

struct DP
{
    mint dp;
    int t;
    DP(mint dp = 1, int t = 0) : dp(dp), t(t) {}
    DP& operator+= (const DP& a) {
        dp *= a.dp;
        dp *= comb(t + a.t, t);
        t += a.t;
        return *this;
    }
    DP operator- (const DP& a) const {
        DP res(*this);
        res.t -= a.t;
        res.dp /= comb(res.t + a.t, res.t);
        res.dp /= a.dp;
        return res;
    }
    DP addRoot() {
        DP res(*this);
        res.t++;
        return res;
    }
};

vector<int> to[MX];
DP dp[MX];

void dfs(int v, int p=-1) {
    for (int u : to[v]) {
        if (u == p) continue;
        dfs(u,v);
        dp[v] += dp[u].addRoot();
    }
}

void bfs(int v, int p=-1) {
    for (int u : to[v]) {
        if (u == p) continue;
        DP d = dp[v] - dp[u].addRoot();
        dp[u] += d.addRoot();
        bfs(u,v);
    }
}
 
int main() {
  int n;
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs(0);
  bfs(0);
  rep(i,n) {
      cout << dp[i].addRoot().dp << endl;
  }
  return 0;
}

Measured memory_bytes: 21348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i  = a; i < b; i++)
typedef long long ll;
using P = std::complex<double>;
using ld = double;

const double eps = 1e-10;

ld cross(const P &l, const P &r) {
  return l.real() * r.imag() - l.imag() * r.real();
}

template <class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;

    assert(n >= 1);
    if (n == 1) {
        return {*left, ld(0)};
    }

    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated

    iter ps = left;
    using circle = std::pair<P, ld>;

    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
           S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r2 = std::norm(p - a);
        return {p, r2};
    };

    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (ld)2;
        ld r2 = std::norm(a - c);
        return {c, r2};
    };

    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}


int main(){
    int N; cin >> N;
    vector<P> p(N);
    rep(i, 0, N){
        int x, y;
        cin >> x >> y;
        p[i].real(x);
        p[i].imag(y);
    }

    cout << setprecision(10) <<  sqrt(min_ball(p.begin(), p.end()).second) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int h = Integer.parseInt(sc.next());
        int[] a = new int[h+1];
        for(int i = 1; i <= h; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 1; i <= h; i++){
            sb.append("node ").append(i);
            sb.append(": key = ").append(a[i]).append(", ");
            if(i >= 2){
                sb.append("parent key = ").append(a[i/2]).append(", ");
            }
            if(i*2 <= h){
                sb.append("left key = ").append(a[i*2]).append(", ");
            }
            if(i*2+1 <= h){
                sb.append("right key = ").append(a[i*2+1]).append(", ");
            }
            sb.append(System.lineSeparator());
        }
        
        System.out.print(sb);
    }
}


Measured memory_bytes: 26224
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N;
    std::string S, T;
    std::cin >> N >> S >> T;

    std::string ans;
    for (int64_t i = 0; i < N; ++i) {
        ans += S.at(i);
        ans += T.at(i);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();

        char[][] a = new char[H][W];
        boolean[] ha = new boolean[H];
        boolean[] wa = new boolean[W];

        for(int i = 0; i<H; i++) {
            String str = sc.next();
            for(int j = 0; j<W; j++) {
                a[i][j] = str.charAt(j);
            }
        }

        for(int i = 0; i<W; i++) {
            for(int j = 0; j<H; j++) {
                if(a[j][i] == '#') break;
                if(j==H-1) wa[i] = true;
            }
        }
        for(int i = 0; i<H; i++) {
            for(int j = 0; j<W; j++) {
                if(a[i][j] == '#') break;
                if(j==W-1) ha[i] = true;
            }
        }

        for(int i = 0; i<H; i++) {
            for(int j = 0; j<W; j++) {
                if(ha[i] == true || wa[j] == true) continue;
                System.out.print(a[i][j]);
            }
            System.out.println();
        }

    }
}

Measured memory_bytes: 25152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first

const int N=102000;
ll dp[N][4];
int a[N][4];
int n;
ll go(int idx,int t){
    if(idx==n)
        return 0;
    ll &ret = dp[idx][t];
    if(ret != -1)
        return ret;
    ret = 0;
    for(int i=0;i<3;i++){
        if(t!=i)
            ret = max(ret , go(idx+1,i)+a[idx][i]);
    }
    return ret;
}
int main(){
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
    }
    ll ans=0;
    ans=max(ans,go(0,0));
    ans=max(ans,go(0,1));
    ans=max(ans,go(0,2));
    cout<<ans<<endl;
}


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

int main() {
    int K;
    string S;
    cin >> K >> S;

    if (S.size() <= K) {
        cout << S << endl;
    } else {
        string subS = S.substr(0, K);
        cout << subS << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
 
int main(void) {
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
 
	d = a/b;
	r = a%b;

	printf("%d %d %f\n", d, r, (double)a/b);
 
	return 0;
}

Measured memory_bytes: 632
import java.util.Scanner;

public class Main {
    public static Scanner Scan = new Scanner(System.in);
    public static void main(String[] args) {
        String s;
        s = Scan.next();

        int cnt = 0, ans = 0;
        for(int i=0; i<s.length(); i++) {
            if(s.charAt(i) == 'R') cnt++;
            else cnt = 0;
            ans = Math.max(ans, cnt);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 35588
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
typedef int ll;

using namespace std;


int main() {
	
	const ll m = 2019;
	string s;
	cin >> s;
	s += '0';
	
	vector<ll> v(m, 0);
	
	
	ll p = 1;
	ll t = 0;
	for (ll i = s.length() - 1; i >= 0; i--)
	{
		ll d = s[i] - '0';
		t = (d * p + t) % 2019;
		p = (p * 10) % 2019;
		
		//printf("%2d %2d %4d\n", i, d, t);
		v[t] ++;
	}
	
	ll ans = 0;
	for (auto w :v)
		ans += (w * (w-1))/2;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3372
n = int(input())
alst = list(map(int, input().split()))
lst = [0 for _ in range(9)]
for num in alst:
    pos = min(num // 400, 8)
    lst[pos] += 1
cnt = 8 - lst[:-1].count(0)
print(max(cnt, 1), cnt + lst[-1])

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

vector<ll> v;
int main(void){
    ll k;
    cin>>k;
    ll ans,c=0;
    queue<ll> q;
    for(int i=1;i<=9;i++){
        q.push(i);
    }
    while(!q.empty()){
        c++;
        ll now=q.front();
        q.pop();
        if(now>3234566667) continue;
        v.push_back(now);
        if(now*10>3234566667) continue;
        if(now%10==0){
            q.push(now*10);
            q.push(now*10+1);
        }
        else if(now%10==9){
            q.push(now*10+8);
            q.push(now*10+9);
        }
        else{
            q.push(now*10+now%10-1);
            q.push(now*10+now%10);
            q.push(now*10+now%10+1);
        }
        if(c>300000) break;
    }
    sort(v.begin(),v.end());
    cout<<v[k-1];
}

Measured memory_bytes: 1784
// Problem : C - Tsundoku
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

template <class T> int binser(T const &ref, long long key)
{
    int low = 0;
    int high = ref.size();

    while (low < high)
    {
        int mid = low + (high - low) / 2;
        if (ref[mid] == key)
            return mid;
        else if (ref[mid] > key)
            high = mid - 1;
        else
            low = mid + 1;
    }
    return ref[low] > key && low != 0 ? low - 1: low;
}

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    for (auto &e : a)
        cin >> e;
    for (auto &e : b)
        cin >> e;

    vector<long long int> A, B;
    A.push_back(0);
    A.push_back(a[0]);
    B.push_back(0);
    B.push_back(b[0]);

    for (int t = 1; t < n; t++)
        A.push_back(A[A.size() - 1] + a[t]);

    for (int t = 1; t < m; t++)
        B.push_back(B[B.size() - 1] + b[t]);

    int ans = 0;
    for (int a = 0; a < n+1 && k >= A[a]; a++)
    {
    	int it = upper_bound(B.begin(), B.end(), k - A[a]) - B.begin();
    	it--;
        ans = max(ans, a + it);
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 9152
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   cin >> n;
   int d[110];
   rep(i,n) cin >> d[i];

   set<int> values;
   rep(i,n){
      values.insert(d[i]);
   }

   cout << values.size() << endl;


   return 0;
}

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

int main(void) {
    int a, b, sum, count;
    
    while(cin >> a >> b) {
        sum = a + b;
        count = 0;
        while(sum != 0) {
            sum /= 10;
            count++;
        }
        cout << count << endl;
    }
}


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


int main() {
  string s;
  cin >> s;
  int ans = 10000;
  rep(i, 26) {
    string t = s;
    int cnt = 0;
    while (true) {
      string u;
      bool flag = true;
      rep(j, t.size()-1) {
        if (t[j] == 'a' + i && t[j+1] == 'a' + i) u.push_back('a' + i);
        else if (t[j] == 'a' + i || t[j+1] == 'a' + i) {
          flag = false;
          u.push_back('a' + i);
        } 
        else {
          flag = false;
          u.push_back(t[j]);
        }
      }
      if (!flag) cnt++;
      else break;
      t = u;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math

n=int(input())

pos=[]
for _ in range(n):
    x,y=map(int,input().split())
    pos.append((x,y))
    
sum_diff=0
for i in range(n-1):
    for j in range(i+1,n):
        sum_diff+=math.sqrt((pos[i][0]-pos[j][0])**2+(pos[i][1]-pos[j][1])**2)*2*(n-2+1)*math.factorial(n-2)
    
print(sum_diff / math.factorial(n))

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin(){ll x;scanf("%lld",&x);return x;}

int main(){
    int a=in(),b=in();
    if(a==1)a=14;
    if(b==1)b=14;
    if(a>b)cout<<"Alice"<<endl;
    else if(a==b)cout<<"Draw"<<endl;
    else cout<<"Bob"<<endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashSet;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let (a, b) = (read::<String>(), read::<String>());
    let c: i32 = format!("{}{}", a, b).parse().unwrap();
    let mut v: HashSet<i32> = vec!().into_iter().collect();;
    for i in 1..317{
        v.insert(i*i);
    }
    println!("{}", if v.insert(c){"No"} else{"Yes"} )    
}

Measured memory_bytes: 4352
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve_test(istream &cin = std::cin, ostream &cout = std::cout)
{
}

void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	while (cin >> n)
	{
		vector<int> order(n * n);
		for (int &it : order)
		{
			cin >> it;
			--it;
		}

		vector<vector<int>> dist(n, vector<int>(n));
		vector<vector<int>> taken(n, vector<int>(n, 1));
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				dist[i][j] = min({i + 1, n - i, j + 1, n - j});

		ll ans = 0;
		for (const int seat : order)
		{
			const int row = seat / n, col = seat % n;
			assert(taken[row][col] == 1);
			/// we don't actually anger ourselves
			ans += dist[row][col] - 1;

			dist[row][col]--;
			taken[row][col] = 0;

			queue<pair<int, int>> q;
			q.emplace(row, col);

			while (!q.empty())
			{
				int r, c;
				tie(r, c) = q.front();
				q.pop();

				static array<int, 4> dr = {-1, +1, 0, 0}, dc = {0, 0, -1, +1};

				for (int d = 0; d < int(dr.size()); d++)
				{
					const int nr = r + dr[d], nc = c + dc[d];
					if (0 <= nr && nr < n && 0 <= nc && nc < n && dist[nr][nc] > dist[r][c] + taken[nr][nc])
					{
						dist[nr][nc] = dist[r][c] + taken[nr][nc];
						q.emplace(nr, nc);
					}
				}
			}
		}

		cout << ans << endl;
	}
}

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

#ifdef LOCAL
	auto st = clock();
	ifstream fin("../input.txt");
	solve(fin);

	cout << "clock: " << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}

Measured memory_bytes: 6040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 100000000099;

int n;

vector<vector<pair<ll,ll>>> v;
vector<bool> b,g;
void dfs(ll x){
    b.at(x)=true;
    for(int i=0;i < (ll)v.at(x).size();i++)
    {
        b.at(x)=true;
        if(b.at(v.at(x).at(i).fi)==false){
        if(v.at(x).at(i).se%2==0){
            g.at(v.at(x).at(i).fi)=g.at(x);
        }else{
            g.at(v.at(x).at(i).fi)= !g.at(x);
        }
        b.at(v.at(x).at(i).fi)=true;
        dfs(v.at(x).at(i).fi);
        }
    }
}

signed main(){
    cin>>n;
    
    b.resize(n,false);
    g.resize(n,false);
    v.resize(n,vector<pair<ll,ll>>());

    for(int i=0;i < n-1;i++)
    {
        ll u,w,z;
        cin>>u>>w>>z;
        
        v.at(u-1).pb({w-1,z});
        v.at(w-1).pb({u-1,z});
    }

    dfs(0);
    
    for(int i=0;i < n;i++)
    {
        if(g.at(i)){
            cout<<0<<endl;
        }else{
            cout << 1 << endl;
        }
    }
}

Measured memory_bytes: 10112
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
#include<numeric>
#include<functional>

using namespace std;
#define ll long long
#define ull unsigned long long
#define rrep(i,m,n) for(ll (i)=(ll)(m);(i)>=(ll)(n);(i)--)
#define rep(i,m,n) for(ll (i)=(ll)(m);i<(ll)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
constexpr long double m_pi = 3.1415926535897932L;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 61;
constexpr long double EPS = 1e-10;
template<typename T> using vector2 = vector<vector<T>>;
template<typename T> using vector3 = vector<vector2<T>>;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

	ll h, w;
	cin >> h >> w;
	vector<string> s(h);
	REP(i, h)cin >> s[i];
	Array used(20, 0);
	vector<string> t(h);
	auto check = [&]() {
		vector<string> tmp(w);
		REP(i, h)REP(j, w)tmp[j].push_back(t[i][j]);
		while (tmp.size() > 1) {
			bool flag = false;
			reverse(all(tmp.back()));
			REP(i, tmp.size() - 1) {
				if (tmp[i] == tmp.back()) {
					flag = true;
					tmp.pop_back();
					swap(tmp[i], tmp.back());
					tmp.pop_back();
					break;
				}
			}
			if (flag == false && tmp.size() % 2 == 1)tmp.pop_back();
			else if (flag == false)return false;
		}
		return true;
	};
	auto solve = [&](auto solve, ll a, ll b) {
		if (a == h)return check();
		if (used[a] == 1)return solve(solve, a + 1, b);
		t[b] = s[a];
		if (h % 2 == 1 && b == h / 2)return check();
		used[a] = 1;
		REP(i, h) {
			if (used[i] == 0) {
				used[i] = 1;
				t[h - b - 1] = s[i];
				if (solve(solve, a + 1, b + 1))return true;
				used[i] = 0;
			}
		}
		used[a] = 0;
		return false;
	};
	if (h % 2 == 1) {
		REP(i, h) {
			used[i] = 1;
			t[h / 2] = s[i];
			if (solve(solve, 0, 0) == true) {
				cout << "YES" << "\n";
				return 0;
			}
			used[i] = 0;
		}
		cout << "NO" << "\n";
		return 0;
	}
	if (solve(solve, 0, 0) == true)cout << "YES" << "\n";
	else cout << "NO" << "\n";
	
	return 0;
}


Measured memory_bytes: 256
N,M = map(int, input().split())
L = ['']*M
R = ['']*M

for i in range(M):
    L[i],R[i] = map(int, input().split())

id_l,id_r = max(L),min(R)
width = id_r - id_l + 1 if max(L)<=min(R) else 0

print(width)


Measured memory_bytes: 10868
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int h, w, d;
P at[90001];
ll cost[20][301][301];
int c[301][301];

int main(int argc, char const* argv[])
{
  cin >> h >> w >> d;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      int x;
      cin >> x;
      at[x] = mk(i, j);
      c[i][j] = x;
    }
  }
  for(int k = 0; k < 20; k++){
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(k == 0){
          if(c[i][j] + d <= h * w)cost[k][i][j] = abs(i - at[c[i][j] + d].first) + abs(j - at[c[i][j] + d].second);
        }else{
          cost[k][i][j] = cost[k - 1][i][j];
          if(c[i][j] + (ll)d * (1 << (k - 1)) <= h * w)cost[k][i][j] += cost[k-1][at[c[i][j] + (ll)d * (1 << (k - 1))].first][at[c[i][j] + (ll)d * (1 << (k - 1))].second];
        }
      }
    }
  }
  int q;
  cin >> q;
  for(int i = 0; i < q; i++){
    int l, r;
    cin >> l >> r;
    int tmp = (r - l) / d;
    int curr = 0;
    int si = at[l].first;
    int sj = at[l].second;
    ll res = 0;
    while(tmp){
      if(tmp % 2 == 1){
        res += cost[curr][si][sj];
        P p;
        if(c[si][sj] + (1 << curr) * (ll)d <= h * w)p = at[c[si][sj] + (1 << curr) * (ll)d];
        else p = mk(0, 0);
        si = p.first;
        sj = p.second;
      }
      curr++;
      tmp /= 2;
    }
    cout << res << endl;
  }
	return 0;
}


Measured memory_bytes: 16384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,ans=0; cin>>n;
    rep(i,n){
        int a; cin>>a;
        while(a%2==0){
            a/=2; ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import * as fs from "fs";

let [line1, ...lines] = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");

let [N, M] = line1.split(" ").map(Number);
let Graph: number[][] = new Array(N);

for(let i=0; i<N; i++) {
    Graph[i] = [];
}

for(let i=0; i<M; i++) {
    let [a, b] = lines[i].split(" ").map(Number);
    Graph[a-1].push(b-1);
    Graph[b-1].push(a-1);
}

let visited: boolean[] = new Array(N).fill(false);
let tin: number[] = new Array(N).fill(-1);
let tlow: number[] = new Array(N).fill(-1);
let timer: number = 0;
let bridges: number = 0;

function dfs(node:number, node_parent?: number): void {
    visited[node] = true;
    tin[node] = tlow[node] = timer++;
    for(let child of Graph[node]) {
        if (child == node_parent)
            continue
        if (visited[child]) {
            tlow[node] = Math.min(tlow[node], tlow[child]);
        } else {
            dfs(child, node);
            tlow[node] = Math.min(tlow[node], tlow[child]);
            if (tin[node] < tlow[child]) {
                bridges += 1;
            }
        }
    }
}

for(let i=0; i<N; i++) {
    if (!visited[i]) {
        dfs(i);
    }
}

console.log(bridges)


Measured memory_bytes: 29636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,ans=0,d=1,dist=0;cin>>x;
  while(dist<x) {
    dist+=d;
    ans++;d++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
N,M,C = map(int, input().split())
B = list(map(int, input().split()))
A = []
counter = 0
for i in range(N):
    A.append(list(map(int, input().split())))
    val = 0
    for j in range(M):
        val += A[i][j] * B[j]
    else:
        if val + C > 0:
            counter += 1 
print(counter)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < ((k)+(n)); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
template <class _Tv> inline string join(const _Tv &v,string sep=" "){
    ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef complex<D> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define X real()
#define Y imag()
#define EPS (1e-9)
#define DEQ(p1,p2) (abs((p1)-(p2)) < EPS)

#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,const _Tv _c,bool _p=false){
    ITER(_c) _it=_c.begin();
    if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{cout<<_n<<" = [ ";if(_c.size()){cout<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;}cout<<" ]"<<endl; }
}
ostream &operator<<(ostream &os, const pair<int,int> &p){return(os<<"("<<p.first<<","<<p.second<<")");}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

int main(){
    string s; int n,m;
    while(cin >> s >> n >> m){
        cout << s << " " << n+m << " " << n*200+m*300 << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

string ws,wk;
	while(getline(cin,ws)){
//		getline(cin,ws);
		if(cin.eof()) break;
		replace(ws.begin(),ws.end(),',',' ');
		replace(ws.begin(),ws.end(),'.',' ');
		stringstream zz;
		zz << ws;
		int ct=0;
		while(zz >> wk){
			if(wk.size()>=3 && wk.size()<=6){
				if(ct != 0 ) cout << " ";
				cout << wk ;
				ct++;
			}
		}
		cout << endl;

	}
	return 0;
	
}

Measured memory_bytes: 1196
#include<stdio.h>
#define minimum(a,b) ((a)>(b))?(b):(a)
int main(void){
    int i, j, n, o, p, q, r, tmp, test[100][100]={0};
    scanf(" %d ", &n);
    for( i = 0 ; i < n ; i++ ){
        scanf( " %d %d " , &o , &p );
        for( j = 0 ; j < p ; j++ ){
            scanf( " %d %d " , &tmp , &r );
            test[o][tmp] = r;
        }
    }
    for( i = 0 ; i < n ; i++ ){
        for( j = 0 ; j < n ; j++ ){
            if( (test[i][j] == 0) && (i != j) ){
                test[i][j]=100000000;
            }
        }
    }
                
    for( q = 0 ; q < n ; q++ ){
        for( i = 0 ; i < n ; i++){
            for( j = 0 ; j < n ; j ++){
                test[i][j] = minimum( test[i][j] , test[i][q] + test[q][j] );
            }
        }
    }            
    for( i = 0 ; i < n ; i++)
        printf( "%d %d\n", i , test[0][i] );
    return 0;
}

Measured memory_bytes: 1840
N =int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sati = B[A[0]-1]
for i in range(1,N):
  if A[i-1] + 1 == A[i] :
    sati += C[A[i-1]-1]
  sati += B[A[i]-1] 

print(sati)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
t = 1
c = [1-a[0]]+[1]*(n)
# print(c)
if n == 0 and a[0] > 1:
    print(-1)
    exit()
if a[0] == 1 and n >= 1:
    print(-1)
    exit()
for i in range(1,n+1):
    c[i] = c[i-1]*2-a[i]
    # print(i)
    if c[i] < 0:
        # print(c)
        print(-1)
        # print(c)
        exit()
# print(c)
c[n] = 0
m = a[n]
for i in range(n-1,-1,-1):
    # print(i)
    c[i] = min(c[i],m)
    m+=a[i]
# print(c)
print(sum(a)+sum(c))
# b = [0]*(n) + [a[-1]]
# for i in range(n-1,-1,-1):
#     b[i] = min(b[i+1]+a[i],2**(i))
# print(b)

Measured memory_bytes: 700476