akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


ll n,k,x,y;


//moddivとnCk
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(ll a,ll b,ll ar,ll br){
  return ar+(br-ar+b)%b*modinv(a,b)%b*a;
}
ll garner2(ll a,ll b,ll ar,ll br){
  ar%=a;
  br%=b;
  ll ret=(ar+  ( (br-ar)%b*moddiv(1,a,b)%b +b )%b *a+a*b)%(a*b);
  return ret;
}

ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0LL){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}





int main(){
  ll ans=0;
  cin >> n;

  if (n==1){
    cout<<1<<endl;
    return 0;
  }
  if (n%2==0){
    ans=2*n-1;
  }else{
    ans=n-1;
  }

  n*=2;
  for(ll i=2;i<=n+2;i++){
    if (i*i>n)break;
    if (n%i==0){
      ll val0=i;
      ll val1=n/i;
      if (val0==1)continue;
      if (val1==1)continue;
      if (gcd(val0,val1)==1){
        ll ans0=garner2(val0,val1,1,0)-1;
        ll ans1=garner2(val0,val1,0,1)-1;
        //ans0%=val0*val1;
        //ans1%=val0*val1;
        if (ans0>1)
          ans=min(ans,ans0);
        if (ans1>1)
          ans=min(ans,ans1);
      }
    }
  }


  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7076
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define MAPFOR(it,m) for( auto it = (m).begin(); it != (m).end() ; ++it )
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    char c;
    cin >> c;
    if(c-'a'>=0) cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    if(*(int *)a<*(int *)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    int l[n];
    for(int i=0;i<n;i++){
    scanf("%d",&l[i]);
    }
    qsort(l,n,sizeof(int),compare);
    int ans=0;
    for(int i=0;i<n-2;i++){
        int flag=0;
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]<l[j]+l[k]){
                    ans++;
                }else{
                    break;
                    }
            }
        }
    }
    printf("%d",ans);

    return 0;
}


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

int main() {
  int A, B, C;
  bool kawaiso = false;
  cin >> A >> B >> C;

  if (A == B) {
    if (A != C) {
      kawaiso = true;
    }
  } else {
    if (A == C || B == C) {
      kawaiso = true;
    }
  }

  if (kawaiso == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
    vector<int> zikan(3);
    for(int i=0;i<3;i++){
        cin >> zikan.at(i);
    }
    sort(zikan.begin(),zikan.end());
    cout << zikan.at(0)+zikan.at(1) << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(input())
D = list(map(int, input().split()))
D.sort()

num = N // 2
arc = 0
for _ in range(N):
    arc_first = D.pop()
    arc += 1
    if arc == num:
        break
abc_last = D.pop()

if abc_last == arc_first:
    # 同じ数にできない
    ans = 0
else:
    ans = arc_first - abc_last

print(ans)

Measured memory_bytes: 14396
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int a[111];

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

	int n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	int ans = 0;
	for (int rem = 0; rem <= k; rem++) {
		int take = min(n, k - rem);
		for (int l = 0; l <= take; l++) {
			multiset<int> hand;
			int sum = 0;
			for (int i = 1; i <= l; i++) {
				sum += a[i];
				hand.insert(a[i]);
			}
			for (int i = 1; i <= (take - l); i++) {
				sum += a[n - i + 1];
				hand.insert(a[n - i + 1]);
			}
			for (int i = 1; i <= rem; i++) {
				if (!hand.empty() and *hand.begin() < 0) {
					sum -= *hand.begin();
					hand.erase(hand.begin());
				} else {
					break;
				}
			}
			ans = max(ans, sum);
		}
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=(LL)1<<53;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

char ca[100];

int main(){
	LL n;
	int i,j,k;
	LL a,b,c;
	LL p,q,r;
	while(cin>>n){
		if(!n)break;
		cin>>ca;
		p=1;
		for(i=0;i<52;i++){
			p<<=1;
			if(ca[i]=='1')p++;
		}
		q=p,r=0;
		while(n){
			if(p==0)break;
			a=(MAX-q-1)/p;
			if(n<=a){
				q+=n*p;
				break;
			}
			n-=a+1;
			q+=p*(a+1);
			q>>=1,p>>=1,r++;
		}
		for(i=11;i>=0;i--){
			if(r%2==0)ca[i]='0';
			else ca[i]='1';
			r/=2;
		}
		for(i=63;i>=12;i--){
			if(q%2==0)ca[i]='0';
			else ca[i]='1';
			q/=2;
		}
		cout<<ca<<endl;
	}
}



Measured memory_bytes: 3108
#include<iostream>
#include<cmath>
#include<stdio.h>


int main() {

	for (;;) {
		int n,i,s[1000];
		double ave, std,sigma,sum;
		
		std::cin >> n;

		if (n == 0)break;
		
		sum = 0;
		for (i = 0; i < n; i++) {
			std::cin >> s[i];
			sum += s[i];
		}

		ave = sum / n;

		sum = 0;	
		for (i = 0; i < n; i++) {
			sum += pow(s[i] - ave,2);
		}

		sigma = sqrt(sum / n);

		printf("%8f\n", sigma);

		
	}
}


Measured memory_bytes: 3160
from collections import Counter

p = 2019
s = list(map(int, input()))

ans = 0

s = s[::-1]
power = 1
t = [0] * len(s)
t[0] = s[0] % p
for i in range(1, len(s)):
    power = power * 10 % p
    t[i] = (t[i-1] + s[i] * power) % p

counter = Counter(t)
for i in counter.values():
    ans += i * (i-1) // 2
ans += counter[0]
print(ans)


Measured memory_bytes: 17784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    ll x = N%10;
    if(x==3){
        cout<<"bon"<<endl;
    }else if(x==0 || x==1 || x==6 || x==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 3624
package main

import(
  "fmt"
)

func main() {
  var n int
  fmt.Scan(&n)
  a := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&a[i])
  }
  b := make([]bool, n)
  b[0] = true
  k := 0
  ok := false
  ans := 0
  for {
    ans += 1
    k = a[k] - 1
    if k == 1 {
      ok = true
      break
    }
    if b[k] {
      break
    }
    b[k] = true
  }
  if ok {
    fmt.Print(ans)
  } else {
    fmt.Print(-1)
  }
}

Measured memory_bytes: 5504
S = int(input())
dp = dict()
MOD = 1000000007
def rec(s):
    if s<3: return 0
    global dp
    if s in dp: return dp[s]
    res = 1
    for i in range(3, s-3+1):
        res += rec(i)
        res %= MOD
    dp[s] = res%MOD
    return dp[s]

print(rec(S))

Measured memory_bytes: 9352
// Created by Krishna Ashok
#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; 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Tree;

#define dbg(x) cout<<#x<<"="<<x<<'\n'
#define ll long long
#define pr pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define For(i,n) for(int i=0;i<(n);++i)
#define Forr(i,n) for(int i=n-1;i>=0;i--)
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#define fin ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define sz(a) (int)a.size()
#define Fill(a,b) memset(a,b,sizeof(a));
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
const int INF=1e9;

void solve(){
	int n;
	cin>>n;
	vector<double> p(n+1);
	For(i,n)cin>>p[i+1];
	vector<vector<double>> dp(n+1,vector<double>(n+1,0.0));
	dp[0][0]=1.00;
	for(int i=1;i<=n;i++){
		dp[0][i]=dp[0][i-1]*(1-p[i]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			//i is no of heads in first j coins
			dp[i][j]=dp[i-1][j-1]*p[j]+dp[i][j-1]*(1-p[j]);
		}
	}
	double tot=0.00;
	// for(auto x:dp){
	// 	for(auto i:x)cout<<i<<' ';
	// 	cout<<endl;	
	// }
	for(int i=(n+1)/2;i<=n;i++)tot+=dp[i][n];
	cout<<setprecision(11)<<tot<<endl;	
}



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

Measured memory_bytes: 73788
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) {
 if (a < b) { a = b; return true; } return false; 
 }
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll d=c-a-b;
  if(d<=0){
    COUT("No");
  }
  else if(4*a*b<d*d){
    COUT("Yes");
  }
  else{
    COUT("No");
  }
}

Measured memory_bytes: 256
#include <stdio.h>

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

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

// long long int lcms(long long int *a, int n) {
// 	int i;
// 	long long int ans;
// 	ans = 1;
// 	for (i=0; i<n; i++) {
// 		ans = lcm(ans, a[i]);
// 	}
// 	return ans;
// }

int main() {
	int n,i;
	scanf("%d", &n);
	long long int t[n];
	for (i=0; i<n; i++) {
		scanf("%lld", &t[i]);
	}
	long long int ans;
	ans = 1;
	for (i=0; i<n; i++) {
		ans = lcm(ans, t[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

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

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

double calc_dist(pair<double, double> p1, pair<double, double> p2){

  double dx = p1.first - p2.first;
  double dy = p1.second - p2.second;
  return sqrt(dx*dx + dy*dy);
};

int N;
vector<pair<double, double>> p;

double calc_cost(double x, double y){

  double res = 0.0;

  for(int i = 0; i < N; i++){
    chmax(res, calc_dist(make_pair(x, y), p[i]));
  }

  return res;
}


double g(double x){

  double l = 0.0;
  double r = 1000.0;
  double x1, x2;
  for(int i = 0; i <= 60; i++){

    x1 = (2*l + r) / 3.0;
    x2 = (l + 2*r) / 3.0;

    if(calc_cost(x, x1) <= calc_cost(x, x2)){
      r = x2;
    }else{
      l = x1;
    }
  }

  return calc_cost(x, (l+r)/2.0);
}

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

  cin >> N;

  double x, y;
  for(int i = 0; i < N; i++){
    cin >> x >> y;
    p.push_back(make_pair(x, y));
  }

  double l, r;
  l = 0.0;
  r = 1000.0;
  double x1, x2;
  
  for(int i = 0; i <= 60; i++){

    x1 = (2*l+r) / 3.0;
    x2 = (l+2*r) / 3.0;

    if(g(x1) <= g(x2)){
      r = x2;
    }else{
      l = x1;
    }
  }

  cout << setprecision(10) << g((l+r)/2.0) << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//子の数が分かるUnionFind
struct UFT {
private:
	vector<int> par, rank;
	vector<int> c_n; //子の数
	void init(int n = 1) {
		par.resize(n); rank.resize(n); c_n.resize(n);
		for (int i = 0; i < n; i++)par[i] = i, rank[i] = 0, c_n[i] = 1;
	}
	void update(int x) {
		if (par[x] == x)return;
		else {
			int r = root(par[x]);
			c_n[par[x]] += c_n[x];
			par[x] = r;
			return;
		}
	}
	int root(int x) {
		if (par[x] == x)return x;
		else {
			int r = root(par[x]);
			return par[x] = r;
		}
	}
public:
	UFT(int n = 1) {
		init(n);
	}
	int weight(int x) {
		return c_n[root(x)];
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)false;
		if (rank[x] < rank[y])swap(x, y);
		if (rank[x] == rank[y])rank[x]++;
		par[y] = x;
		update(y);
		return true;
	}
};

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	vector<pair<int, int>> F(M), B(K);
	map<int,vector<int>> F_, B_;
	for (int i = 0; i < M; i++) {
		cin >> F[i].first >> F[i].second;
		F_[F[i].first].push_back(F[i].second);
		F_[F[i].second].push_back(F[i].first);
	}
	for (int i = 0; i < K; i++) {
		cin >> B[i].first >> B[i].second;
		B_[B[i].first].push_back(B[i].second);
		B_[B[i].second].push_back(B[i].first);
	}

	UFT Friends(N+1), Blocks(N+1);
	for (int i = 0; i < M; i++) {
		Friends.merge(F[i].first, F[i].second);
	}
	for (int i = 0; i < K; i++) {
		Blocks.merge(B[i].first, B[i].second);
	}

	for (int i = 1; i <= N; i++) {
		int ans = Friends.weight(i)-1;
		ans -= F_[i].size();
		for (int j = 0; j < B_[i].size(); j++) {
			if (Friends.issame(i, B_[i][j]))ans--;
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 26616
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
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;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

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

class LazySegmentTree{
//区間加算・区間和クエリ
public:
    int n,sz;
    vector<ll> v,lazy;

    LazySegmentTree():n{0},sz{0}{}
    LazySegmentTree(int n_in):n{n_in},sz{1}{
        while(sz<n) sz*=2;
        v.assign(2*sz-1,0);
        lazy.assign(2*sz-1,0);
    }

    void init_u(){
        for(int i=sz-2;i>=0;i--)
        v[i]=v[2*i+1]+v[2*i+2];
    }

    void eval(int k,int l,int r){
        if(lazy[k]==0) return;
        v[k]+=lazy[k];
        if(r-l>1){
            lazy[2*k+1]+=lazy[k]/2;
            lazy[2*k+2]+=lazy[k]/2;
        }
        lazy[k]=0;
    }

    //add(a,b,x,0,0,s.sz); xは加算分
    void add(int a,int b,ll x,int k,int l,int r){
        eval(k,l,r);
        if(b<=l || r<=a) return;
        if(a<=l && r<=b){
            lazy[k]+=(r-l)*x;
            eval(k,l,r);
        }
        else{
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            v[k]=v[2*k+1]+v[2*k+2];
        }
    }

    //query(a,b,0,0,s.sz);
    ll query(int a,int b,int k,int l,int r){
        if(r<=a || b<=l) return 0;
        eval(k,l,r);
        if(a<=l && r<=b) return v[k];
        ll vl=query(a,b,k*2+1,l,(l+r)/2);
        ll vr=query(a,b,k*2+2,(l+r)/2,r);
        return vl+vr;
    }

    ll operator[](const int& idx) const{
        return v[idx+sz-1];
    }
};

int main(){
    ll n,q,ans; cin>>n>>q;
    ans=(n-2)*(n-2);
    set<int> sth,stw;
    sth.insert(n-2);
    stw.insert(n-2);
    LazySegmentTree lsth{n-2},lstw{n-2}; 
    rep(i,n-2) lsth.v[lsth.sz-1+i]=lstw.v[lstw.sz-1+i]=n-2;
    lsth.init_u();
    lstw.init_u();
    rep(_,q){
        int t,x; cin>>t>>x;
        x-=2;
        // w
        if(t==1){
            ans-=lstw.query(x,x+1,0,0,lstw.sz);
            stw.insert(x);
            if(*stw.begin()==x){
                int ne=*(++stw.begin());
                lsth.add(0,*sth.begin(),x-ne,0,0,lsth.sz);
            }
        }
        // h
        if(t==2){
            ans-=lsth.query(x,x+1,0,0,lsth.sz);
            sth.insert(x);
            if(*sth.begin()==x){
                int ne=*(++sth.begin());
                lstw.add(0,*stw.begin(),x-ne,0,0,lstw.sz);
            }
        }
    }
    cout<<ans<<endl;
}

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

vector<int> par;
vector<int> Rank;
vector<int> cnt;

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        cnt[i] = 1;
        Rank[i] = 0;
    }
}
int find(int x) {
    if (par[x] == x) {
        return x;
    }
    else {
        return par[x] = find(par[x]);
    }
}
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (Rank[x] < Rank[y]) {
        swap(x, y);
    }
    cnt[x] += cnt[y];
    par[y] = x;
    if (Rank[x] == Rank[y]) {
        Rank[x]++;
    }
}
bool same(int x, int y) {
    return find(x) == find(y);
}

signed main() {
    int N, M;
    cin >> N >> M;

    par.resize(N);
    Rank.resize(N);
    cnt.resize(N);

    init(N);

    vector<int> A(M), B(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        --A[i], --B[i];
    }

    vector<int> ans;
    for (int i = M - 1; i >= 0; i--) {
        if (same(A[i], B[i])) {
            ans.push_back(0);
        }
        else {
            ans.push_back(cnt[par[A[i]]] * cnt[par[B[i]]]);
            unite(A[i], B[i]);
        }
    }

    int sum = 0;
    for (auto it = ans.rbegin(); it != ans.rend(); it++) {
        sum += *it;
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 6132
n, a, b = map(int, input().split())
mod = 10**9 + 7
def c(x):
  out = 1
  for i in range(min(x, n-x)):
    out *= n-i
    out *= pow(i+1, mod-2, mod)
    out %= mod
  return out
ans = pow(2, n, mod) -1 -c(a)-c(b)
ans %= mod
print(ans)

Measured memory_bytes: 3316
# -*- coding: utf-8 -*-

A, B = [int(i) for i in input().split()]

coin = 0
if A>=B:
    coin += A
    A -= 1
else:
    coin += B
    B -= 1

if A>=B:
    coin += A
    A -= 1
else:
    coin += B
    B -= 1

print(coin)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define ll long long
const int INF = 2 << 27;

int main() {
  while(1){
    int n,m,s,g1,g2;
    cin >> n >> m >> s >> g1 >> g2;
    if(n == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0) break;
    s--;
    g1--;
    g2--;
    int cost[n][n];
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        if(i == j) {
          cost[i][j] = 0;
        }
        else {
          cost[i][j] = INF;
        }
      }
    }
    for(int i = 0; i < m; i++) {
      int b1,b2,c;
      cin >> b1 >> b2 >> c;
      cost[b1-1][b2-1] = c;
    }


    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        for (int k = 0; k < n; k++)
          cost[j][k] = std::min(cost[j][k], cost[j][i] + cost[i][k]);

    int ans = INF;
    for(int i = 0; i < n; i++) {
      ans = min(ans,cost[s][i] + cost[i][g1] + cost[i][g2]);
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 1196
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
r,s,p=map(int,input().split())
t=[i for i in input()]
tmp=0
for i in range(K):
    if t[i]=='s':
        tmp+=r
    elif t[i]=='p':
        tmp+=s
    else:
        tmp+=p   
    #print(tmp)
    #print('制約なしで勝ち')
flg=0
for i in range(K,N):
    if t[i]!=t[i-K]:
        if t[i]=='s':
            tmp+=r
            #print('グーで勝ち')
        elif t[i]=='p':
            tmp+=s
            #print('チョキで勝ち↓')
        else:
            tmp+=p
            #print('パーで勝ち')
    else:
        t[i]='w'
        #print('かぶった（1回目）')
        
            
    #print(tmp)
#print('ans='+str(tmp))
print(tmp)

Measured memory_bytes: 48624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int n;
int a[111111];
int b[111111];

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	n=read();
	ll sum=0;
	FOR(i,0,n+1){
		a[i]=read();
		sum+=a[i];
	}
	FOR(i,0,n)b[i]=read();
	for(int i=n-1;i>=0;--i){
		int c=min(a[i+1],b[i]);
		a[i+1]-=c;
		b[i]-=c;
		c=min(a[i],b[i]);
		a[i]-=c;
		b[i]-=c;
	}
	FOR(i,0,n+1){
		sum-=a[i];
	}
	cout<<sum<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int n;
vvl a;
vl dp;
vb seen;

long dfs(long v){
  if(seen[v]) return dp[v];
  seen[v] = true;
  int m = __builtin_popcount(v);
  if(m <= 1) return dp[v] = 0;
  long ret = 0;
  rep(i,n){
    REP(j,i+1,n){
      if(((1<<i) & v) && ((1<<j) & v)) ret += a[i][j];
    }
  }
  for(long t = ((v-1)&v) ; t>0; t=(t-1)&v){
    ret = max(ret, dfs(t) + dfs(t^v));
  }
  return dp[v] = ret;
}

int main(){
  cin >> n;
  a = vvl(n,vl(n));
  rep(i,n) rep(j,n) cin >> a[i][j];
  dp = vl(1<<n,0);
  seen = vb(1<<n,false);
  cout << dfs((1<<n)-1) << endl;
}

Measured memory_bytes: 3780
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  int n;
  cin >> n;
  vector<int> vi(n);
  for(auto& i:vi) cin>>i;
  int m,p,x,result;
  cin>>m;
  rep(i,m) {
    result=0;
    cin>>p>>x;
    rep(i, n) result+=(i==p-1?x:vi.at(i));
    cout<<result<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] ans = s.toCharArray();
        ans[5] = ' ';
        ans[13] = ' ';
        System.out.println(new String(ans));
    }
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, K; cin >> N >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll l=0, r=0;
    rep(i, N){
        rep(j, i){
            if(a[i] > a[j]) l++;
        }
        Rep(j, i+1, N){
            if(a[i] > a[j]) r++;
        }
    }

    ll res = modint(modint(K*(K-1))*modint(l)/modint(2) + modint(K*(K+1))*modint(r)/modint(2));

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
n,m,d=map(int,input().split())

if d==0:
    a=(1/n)*(m-1)
elif n>=d*2+1:
    a=((n-d*2)/n*(2/n)+2*d/n*(1/n))*(m-1)
else :
    a=(d/n)*(m-1)
#n%d==0
print(a)


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

// 小数点以下桁数
// fixed << setprecision(i)

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

int main()
{
  int n, m, max_l = 0, min_r, l, r;

  cin >> n >> m;
  min_r = n;
  for (int i = 0; i < m; i++)
  {
    cin >> l >> r;
    max_l = max(l, max_l);
    min_r = min(r, min_r);
  }
  cout << max(min_r - max_l + 1, 0) << endl;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.size(), ans = 0;
    for (int i = 0; i < N / 2; i++) {
        if (S[i] != S[N - i - 1]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef long long int ll;
typedef long double  ld;
using namespace std;
const int M=1e9+7;
ll factorial[3000005],inverse[3000005];
void factorial_find()
{
    factorial[1]=1;
    factorial[0]=1;
    for(ll i=2;i<=3000000;++i)
    {
        factorial[i]=(factorial[i-1]*i)%M;
    }
}
ll inverse_find(ll a,ll m)
{
    if(m==0)
    return 1;
    if(m==1)
    return a%M;

    ll ans=inverse_find(a,m/2);
    ans=ans*ans%M;

    if(m%2==1)
    ans*=a;
    
    return ans%M;

}
ll combination(ll a,ll b)
{
    ll ans=factorial[a]*inverse[b]%M;
    return ans*inverse[a-b]%M;
}
int main() {
    ios;
    factorial_find();
    inverse[3000000]=inverse_find(factorial[3000000],M-2);
    for(ll i=3000000-1;i>=0;--i)
    inverse[i]=(inverse[i+1]*(i+1))%M;

    ll r1,r2,c1,c2;
    cin>>r1>>c1>>r2>>c2;
    ll ans=0;

    for(ll i=c1;i<=c2;++i)
    {
        ll temp=(combination(r2+i+1,i+1)-combination(r1+i,i+1)+M)%M;
        ans=(ans+temp)%M;
    }
    cout<<ans<<endl;    
}

Measured memory_bytes: 47104
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    A = get_li()
    if n % 3 != 0:
        if any(a != 0 for a in A):
            print('No')
            return
    else:
        cnt = Counter(A)
        if len(cnt.items()) > 3:
            print('No')
            return
        elif len(cnt.items()) == 3:
            a, b, c = cnt.most_common(3)
            if a[0] ^ b[0] ^ c[0] != 0:
                print('No')
                return
        elif len(cnt.items()) == 2:
            a, b = cnt.most_common(2)
            if b[0] != 0:
                print('No')
                return
        else:
            a = cnt.most_common(1)[0]
            if a[0] != 0:
                print('No')
                return
        for v, c in cnt.items():
            if c % (n // 3) != 0:
                print('No')
                return
    print('Yes')
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


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

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

int main(void){
    int N,M;
    cin>>N>>M;
    
    vector<P> v(N);
    for(int i=0;i<N;i++){
        ll a,b;
        cin>>a>>b;
        v[i]=P(a,b);
    }
    
    sort(v.begin(),v.end());
    
    ll sum=0;
    int i=0;
    while(M>0){
        ll tmp=M;
        M-=v[i].second;
        if(M<0){
            sum+=tmp*v[i].first;
            break;
        }else{
            sum+=v[i].first*v[i].second;
            i++;
        }
        
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	int out=0;
	cin>>n;
	rep(i,n){
		int a;cin>>a;
		while(a%2==0){
			out++;
			a/=2;
		}
	}
	cout<<out<<endl;
}










Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
int main() {
	int n, m = 0;
	bool a[200000], ball[200000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		ball[i] = false;
	}
	for (int i = n; i > 0; i--) {
		int cnt = 0;
		for (int j = 1; j <= n / i; j++) {
			cnt += ball[i * j - 1];
		}
		if (cnt % 2 != a[i - 1]) {
			ball[i - 1] = true;
			m++;
		}
	}
	printf("%d\n", m);
	for (int i = 0; i < n; i++) {
		if (ball[i]) {
			printf("%d ", i + 1);
		}
	}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

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

const int N = 100100;

vector <pii> adj[N];

bool mark[N];
int dist[N];

void DFS(int v){
	
	mark[v] = 1;

	for(auto u : adj[v]){
	   int t = dist[v] + u.S;
	   if(!mark[u.F]){
		  dist[u.F] = t;
		  DFS(u.F);
	   }
	   else if(dist[u.F] != t){
		  cout << "No" << endl;
		  exit(0);
	   }
	}
	
	return;
}

int main(){

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

	int n , m , l , r , d;
	cin >> n >> m;

	for(int i = 0 ; i < m ; i++){
	   cin >> l >> r >> d;
	   adj[--l].pb({--r , d});
	   adj[r].pb({l , -d});
	}
	
	for(int i = 0 ; i < n ; i++)
	   if(!mark[i])
		  DFS(i);
	
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define ull long long
using namespace std;
 
const int nmax = 200100;
ull N;
ull a[nmax], b[nmax], c[nmax];
ull curmod = 0;
 
void read(){
    cin >> N;
    for(int i=0;i < N; ++i)cin >> a[i];
    for(int i=0;i < N; ++i)cin >> b[i];
}
ull bs(ull a, ull C, ull B, ull A)
{
    ull res = 0;
    int ind = lower_bound(c, c+N, C - a) - c;
    res = res - ind;
    ind = lower_bound(c, c+N, A - a) - c;
    res = res + ind;
    ind = lower_bound(c, c+N, B - a) - c;
    res = res + N - ind;
    return res;
}
 
void solve(){
    ull ans = 0;
    curmod = 1;
    for(int i = 0; i <= 28; ++i)
    {
        vector <ull> bmod;
        for(int j=0; j < N; ++j)
            c[j] = b[j] % (curmod<<1);
        sort(c, c+N);
        ull cnt = 0;
        for(int j=0;j<N; ++j)
        {
            cnt += bs(a[j] % (curmod << 1), curmod, 3 * curmod , curmod << 1);
            //cout << cnt << ' ' << a[j] << endl;
        }
        ans += (cnt & 1) * (curmod);
        //if(curmod==4)break;
        curmod <<=1;
        //cout << "---\n";
    }
    cout << ans << endl;
}
 
int main(){
    read();
    solve();
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;


const int INF = 1e8;

int n, k, dis[2010][2010];
vector < int > g[2010];

bool used[2010][2010], check;

vector < pair <int, int> > pos_ans;

void dfs(int orig, int v, int ct = 0) {

    used[orig][v] = 1;

    if(ct > k) {check = 1; return;}

    if(orig != v) {

        dis[orig][v] = ct;

        if(ct == k) {pos_ans.pb(mper(orig, v));}


    }




    for(auto to : g[v]) {

        if(!used[orig][to]) {

            dfs(orig, to, ct + 1);

        }

    }

}

int main(){



cin >> n >> k;



for(int i = 1, l, r; i < n; ++i) {

    cin >> l >> r;

    g[l].pb(r);
    g[r].pb(l);

}

for(int i = 1; i <= n; ++i) {
    dfs(i, i);
}


if(!check) {cout << 0;return 0;}


int ans = (int)1e8;

for(auto to : pos_ans) {

    int a = to.fe;
    int b = to.se;
    int ct = 0;



    for(int i = 1; i <= n; ++i) {

        if(i == a || b == i) {continue;}

        if(dis[a][i] == 0) {ct++;}
        else if(dis[b][i] == 0) {ct++;}

    }

    ans = min(ans, ct);

}

cout << ans;

return 0;
}

/*

2000 2


*/


Measured memory_bytes: 51296
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
	ll N;
	cin >> N;
	ll A[N];
	ll x = 0;
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 1) x++;}
	if (x % 2 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	}
	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for (long long i = (a); i <= (b); i++)
#define FORD(i,b,a) for (long long i = (b); i >= (a); i--)
#define endl "\n"
#define ll long long
#define x1 asdasdsaas
#define y1 cdaca1231
#define fi first
#define se second
#define pb push_back
#define ms(s, n) memset(s, n, sizeof(s))
#define all(a) (a).begin(), (a).end()
#define prec(n) fixed<<setprecision(n)
#define bitcount(n) __builtin_popcountll(n)
template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
const int MOD = 1e9 + 7;
const int MAXN = 1e6;
const int dx[4] = { -1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};

using namespace std;
inline int add(int x, int y) {
	return x + y >= MOD ? x + y - MOD : x + y;
}

inline int sub(int x, int y) {
	return x - y < 0 ? x - y + MOD : x - y;
}

inline int mul(int x, int y) {
	return (x * (ll)y) % MOD;
}
const int N = 2010;
int h, w;
char a[N][N];
int dp[N][N];
void solve() {
	cin >> h >> w;
	FOR(i, 1, h) FOR(j, 1, w) {
		cin >> a[i][j];
	}
	dp[0][1] = 1;
	dp[1][0] = 0;
	FOR(i, 1, h)
	FOR(j, 1, w) if (a[i][j] == '#') dp[i][j] = 0; 
	else dp[i][j] = add(dp[i - 1][j], dp[i][j - 1]);
	cout << dp[h][w];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 5e5 + 5;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg 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 << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

char ss[N];
int f[N], h[N], l[N], g[N], z[N], o[N];

int main() {
	reg n = read();
	scanf("%s", ss + 1);
	memset(h, 128, sizeof(h));
	memset(l, 128, sizeof(h));
	memset(g, 128, sizeof(g));
	memset(z, 128, sizeof(z));
	memset(o, 128, sizeof(o));
	fo(i, 1, n) {
		f[i] = f[i - 1];
		if(ss[i] == '1') {
			g[i] = f[i - 1];
			h[i] = _max(h[i - 1], f[i - 1]) + 1;
			o[i] = _max(o[i - 1], z[i - 1]) + 1;
			f[i] = _max(f[i], _max(l[i - 1], o[i]));
		} else {
			l[i] = h[i - 1];
			z[i] = g[i - 1];
		}
	} pr2(f[n]);
	return 0;
}



Measured memory_bytes: 12416
#include <stdio.h>
#include <stdlib.h>

void insertionSort(int *A,int N);
     
int main(){
  int i;
  int N;
  int A[100];
  scanf("%d",&N);
  if(1<=N && N<=100){
  for(i = 0;i < N;i++){
    scanf("%d",&A[i]);
    if(0 > A[i] && A[i] > 1000) exit(2);
  }
  }
  else exit(1);
  
  for(i = 0;i < N;i++){
    if(i)printf(" ");
    printf("%d",A[i]);
  }
  
  printf("\n");
  insertionSort(A,N);
  return 0;
}

void insertionSort(int *A,int N){
  int i,j,v;
  int c;
  for( i=1 ; i<=N-1 ; i++ ){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(c=0;c<N;c++){
      if(c)printf(" ");
      printf("%d",A[c]);
    }
    printf("\n");
  }
}



Measured memory_bytes: 2128
#include <iostream>
#include <string>

#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n)    for(uint i = 0; i < n; ++i)

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int main(){
    int n; cin >> n;
    int days, left; cin >> days >> left;
    int ans = left;
    int eat;

    REP(i, n){
        cin >> eat;
        ans += (days - 1) / eat + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
n,m=map(int,input().split())
h=input().split()
out=[]
ab=[0]*m
for i in range(m):
  ab[i]=input().split()
  if int(h[int(ab[i][0])-1])==int(h[int(ab[i][1])-1]):
    out.append(ab[i][0])
    out.append(ab[i][1])
  elif int(h[int(ab[i][0])-1])>int(h[int(ab[i][1])-1]):
    out.append(ab[i][1])
  else:
    out.append(ab[i][0])


out=set(out)
print(n-len(out))

Measured memory_bytes: 48780
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			StringBuilder ab = new StringBuilder();
			for(int i = 0 ; i < b ; i++) {
				ab.append(a);
			}
			StringBuilder ba = new StringBuilder();
			for(int i = 0 ; i < a ; i++) {
				ba.append(b);
			}
			PriorityQueue<String> q = new PriorityQueue<>();
			q.add(ab.toString());
			q.add(ba.toString());

			System.out.println(q.peek());
		}

	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int N;
  cin >> N;
  
  if (N <= 999) {
    cout << "ABC" << endl;
  }
  else {
    cout << "ABD" << endl;
  }
}

Measured memory_bytes: 256