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

int main() {
	int n;
	int *x,*y;
	double minkow1=0,minkow2=0,minkow3=0,minkowinf=0;
	
	cin>>n;
	x = new int[n];
	y = new int[n];
	
	for(int i=0;i<n;++i)cin>>x[i];
	for(int i=0;i<n;++i)cin>>y[i];
	
	
	for(int i=0;i<n;++i){
		minkow1 += fabs(x[i]-y[i]);
	}
	
	for(int i=0;i<n;++i){
		minkow2 += (x[i]-y[i])*(x[i]-y[i]);
	}
	minkow2 = sqrt(minkow2);
	
	for(int i=0;i<n;++i){
		minkow3 += pow((fabs(x[i]-y[i])),3);
	}
	minkow3 = pow(minkow3,1.0/3);
	
	for(int i=0;i<n;++i){
		if( fabs(x[i]-y[i]) > minkowinf )minkowinf = fabs(x[i]-y[i]);
	}
	cout<<fixed<<setprecision(6)<<minkow1<<endl<<minkow2<<endl<<minkow3<<endl<<minkowinf<<endl;
}

Measured memory_bytes: 1300
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  if (s == "xxx")
    cout << "700";
  else if (s == "oxx")
    cout << "800";
  else if (s == "xox")
    cout << "800";
  else if (s == "xxo")
    cout << "800";
  else if (s == "oox")
    cout << "900";
  else if (s == "oxo")
    cout << "900";
  else if (s == "xoo")
    cout << "900";
  else if (s == "ooo")
    cout << "1000";
}

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

using namespace std;

int main(void)
{
    int H, W, K;
    cin >> H >> W >> K;

    int c[6][6];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            char temp;
            cin >> temp;
            c[i][j] = (temp == '.' ? 0 : 1);
            }
    }

    int bitHmax = 1 << H;
    int bitWmax = 1 << W;
    int ans = 0;
    for(int ph = 0; ph < bitHmax; ph++){
        for(int pw = 0; pw < bitWmax; pw++){
            int count = 0;
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    if((ph >> i)&1 || (pw >> j)&1) continue;
                    if(c[i][j] %2 == 1){
                        count++;
                    }
                }
            }
            if(count == K)  
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

    int n; cin >> n;
    int x[n+1];

    for(int i=0;i<n+1;i++){
        if(i==0)continue;
        else cin >> x[i];
    }

    if(n==2){
        if(x[2]<x[1])swap(x[1], x[2]);

        for(int i=1;i<=x[1];i++){
            if(x[1]%i==0 && x[2]%i==0)cout << i << endl;
        }
    }

    if(n==3){
        if(x[2]<x[1])swap(x[1], x[2]);
        if(x[3]<x[1])swap(x[1], x[3]);

        for(int i=1;i<=x[1];i++){
            if(x[1]%i==0 && x[2]%i==0 && x[3]%i==0)cout << i << endl;
        }
    }
}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[n][n];
  int dp[n][n];
  int mex = -100000000;
  rep(i,n)rep(j,n)
    {
      cin >> a[i][j];
      mex = max(mex,a[i][j]);
    }
  if(n == 1)
    {
      cout << a[0][0] << endl;
      return 0;
    }

  rep(i,n)
    {
      dp[i][0] = a[i][0];
      REP(j,1,n)
	{
	  dp[i][j] = dp[i][j-1] + a[i][j];
	  mex = max(mex,dp[i][j]);
	}
    }

  REP(i,1,n)rep(j,n)dp[i][j] = dp[i][j] + dp[i-1][j],mex = max(mex,dp[i][j]);

  for(int i=n-1;i>=0;i--)
    {
      for(int j=n-1;j>=0;j--)	
	{
	  for(int y=i;y>=0;y--)
	    {
	      for(int x=j;x>=0;x--)
		{
		  int a,b,c;
		  a = x-1>=0?dp[i][x-1]:0;
		  b = y-1>=0?dp[y-1][j]:0;
		  c = (x-1>=0 && y-1>=0)?dp[y-1][x-1]:0;
		  int area = dp[i][j] - (a+b) + c;
		  mex = max(area,mex);		  
		}
	    }
	}
    }


  cout << mex << endl;  
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int calc(vector<int> rsp, char c) {
	if (c == 'r') {
		return rsp[2];
	} else if (c == 's') {
		return rsp[0];
	} else {
		return rsp[1];
	}
}

int main() {
	IOS;
	int n, k;
	cin >> n >> k;
	vector<int> rsp(3);
	REP(j, 3) {
		cin >> rsp[j];
	}
	string t;
	cin >> t;
	int res = 0;
	for (int i = 0; i < k; ++i) {
		for (int j = i; j < n; j+=k) {
			if (j < k) {
				res += calc(rsp, t[j]);
			} else {
				if (t[j] == t[j - k]) {
					t[j] = 'x';
				} else {
					res += calc(rsp, t[j]);
				}
			}
		}
	}
	put(res);
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main{

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int hold10 = sc.nextInt();
			int hold100 = sc.nextInt();
			int max10 = sc.nextInt();

			int [][] data = new int[n][2];
			for(int i = 0; i < n; i++){
				data[i][0] = sc.nextInt();
				data[i][1] = sc.nextInt();
			}

			int nowMoney = 0;
			int ans = -1;
			for(int i = 0;; i++){
				int ind = i % n;
				if(data[ind][0] > 0){
					data[ind][0]--;
					nowMoney += 10;
					hold10++;
					if(hold10 > max10){
						ans = ind;
						break;
					}
				}
				else if(data[ind][1] > 0){
					data[ind][1]--;
					nowMoney += 100;
					hold100++;
				}
				else{
					ans = ind;
					break;
				}
				
				if(nowMoney >= 90){
					nowMoney -= 90;
					int num100 = -1;
					for(int j = 0; j <= hold100; j++){
						if(nowMoney < j * 100) break;
						if((nowMoney - 100 * j) / 10 <= hold10){
							num100 = j;
							break;
						}
					}
					if(num100 == -1){
						ans = ind;
						break;
					}
					data[ind][0] += (nowMoney - 100 * num100) / 10;
					data[ind][1] += num100;
					hold100 -= num100;
					hold10 -= (nowMoney - 100 * num100) / 10;
					
					nowMoney = 0;
				}
			}
			System.out.println(ans + 1);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 20304
from sys import exit
def judge_line(card):
    for i in range(0,9,3):
        for j in range(3):
            if card[i+j] != 0:
                break
            else:
                if j == 2:
                    print("Yes")
                    exit(0)
                else:
                    None
        
        
def judge_row(card):
    for i in range(3):
        for j in range(i,9,3):
            if card[j] != 0:
                break
            else:
                if j == 6 or j == 7 or j == 8:
                    print("Yes")
                    exit(0)
                else:
                    None

def judge_rightslanting(card):
    if card[0] == 0 and card[4] == 0 and card[8] == 0:
        print("Yes")
        exit(0)

def judge_leftslanting(card):
    if card[2] == 0 and card[4] == 0 and card[6] == 0:
        print("Yes")
        exit(0)


card = []

for _ in range(3):
    card += [int(x) for x in input().split()]

N = int(input())
for i in range(N):
    b = int(input())
    try:
        ind = card.index(b)
        card[ind] = 0
    except ValueError:
        None
    
    judge_line(card)
    judge_row(card)
    judge_rightslanting(card)
    judge_leftslanting(card)

print("No")

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

#define fi first
#define se second
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)

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

int N;
vector<pii> V;
pii D[200010];
pii MAX,MIN;
ll res,res1,res2;
ll ans;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%lld%lld",&D[i].fi,&D[i].se);
        V.pb(mk(D[i].fi,i));
        V.pb(mk(D[i].se,i));
    }
    sort(V.begin(),V.end());
    MAX = V[N * 2 - 1];
    MIN = V[0];
    res1 = res2 = 0;
    for(int i = 0; i < N; i++)
    {
        res1 = max(res1,abs(MAX.fi - max(D[i].fi,D[i].se)));
        res2 = max(res2,abs(MIN.fi - min(D[i].fi,D[i].se)));
    }
    ans = res1 * res2;
    if(MAX.se != MIN.se)
    {
        res = 1000000000000000000;
        int mem[200010] = {0};
        int l,r;
        int sum = 0;
        l = 0;
        for(int r = 1; r < N * 2 - 1; r++)
        {
            mem[V[r].se]++;
            if(mem[V[r].se] == 1)sum++;
            if(sum == N)
            {
                while(1)
                {
                    l++;
                    mem[V[l].se]--;
                    if(mem[V[l].se] == 0)
                    {
                        sum--;
                        res = min(res,V[r].fi - V[l].fi);
                        break;
                    }
                }
            }
        }
        ans = min(ans,(V[N * 2 - 1].fi - V[0].fi) * res);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 12396
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f;
int n;
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i;
	for(i=1;i<=5;i++)
	{
		int x;
		scanf("%d",&x);
		if(x==0) cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 3764
package main

import (
	"fmt"
)

func main() {
	var a string
	fmt.Scan(&a)

	var strs = map[rune]int{}

	for _, v := range a {
		strs[v]++
	}

	count := 0
	for v := range strs {
		if strs[v] != 2 {
			count++
		}
	}
	if count == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


const int ma=1e5+5;
vector<int> edges[ma];
int dist[ma]={0};
bool vis[ma]={false};
int indegree[ma]={0};

void dfs(int a)
{ 
  //assert(!vis[a]);
    vis[a]=true;
    for(int b: edges[a])
    {
      //indegree[b]--;
      //if(indegree[b]==0)
      if(!vis[b])
      dfs(b);

    dist[a]=max(dist[a],dist[b]+1);
    }
  
}

int32_t main()
{
    fast

   int test=1;
   //cin>>test;

  while(test--)
  {
  int n,m,x,y;
  cin>>n>>m;

  for(int i=1;i<=m;i++)
  {
    cin>>x>>y;
    edges[x].pb(y);
    //indegree[y]++;
  }

  for(int i=1;i<=n;i++)
  {
    if(!vis[i] )dfs(i);
  }

  int ans=0;
  for(int i=1;i<=n;i++)ans=max(ans,dist[i]);

    cout<<ans;

  //while loop ending 
  }



return 0;
}

Measured memory_bytes: 8704
var primeNxt = new Array(1000000);

function primeGenerator()
{
    var p, fact, m;
    var maxN = 9999999;
    var primePrv = new Array(1000000);

    // Initial
    for(p=2;p<=maxN;++p){
        primeNxt[p] = p + 1;
        primePrv[p] = p - 1;
    }
    primePrv[2] = 0;
    primeNxt[maxN] = 0;
    
    // Make prime table (primeNxt)
    for(p=2;p*p<=maxN;p=primeNxt[p]){
        for(fact=p;p*fact<=maxN;fact=primeNxt[fact]){
            for(m=p*fact;m<=maxN;m*=p){
                primeNxt[primePrv[m]] = primeNxt[m];
                primePrv[primeNxt[m]] = primePrv[m];
            }
        }
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
 
process.stdin.on('data', function(input){
    primeGenerator();
    input.trim().split('\n').forEach(function(val){
        var N = parseInt(val);
        var cnt = 1;
        if( N == 1 ){
            console.log(0);
        }
        else if( N == 2 ){
            console.log(1);
        }
        else{
            for(var i=3;i<=N;i=primeNxt[i]){
               ++cnt;
            }
            console.log(cnt);
        }
    });
});

Measured memory_bytes: 254648
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ints = new int[n];
		long sum = 0;
		int min = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;
		for (int i=0; i<n; i++) {
			ints[i] = sc.nextInt();
			sum += ints[i];
			min = Math.min(min,ints[i]);
			max = Math.max(max,ints[i]);
		}
		System.out.println(min+" "+max+" "+sum);
	}
}



Measured memory_bytes: 42712
# b棟f階r番目の部屋にv人追加
doms = [[[0 for i in range(10)] for j in range(3)]for k in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = input().split()
    doms[int(b) - 1][int(f)-1][int(r)-1] += int(v)

for i, tou in enumerate(doms):
    for floor in tou:
        # print("floor : {}".format(floor))
        for room in floor:
            print(" {}".format(room), end="")
        print()
    if i < 3:
        print("#" * 20)



Measured memory_bytes: 5624
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]

def has_N_digit(target):
	if len(target) != N:
		return False
	return True

def s_is_c(target):
	for i in range(M):
		if target[sc[i][0]-1] != str(sc[i][1]):
			return False
	return True
	
def solve():
	for i in range(1000):
		if has_N_digit(str(i)) and s_is_c(str(i)):
			return str(i)
	return "-1"

print(solve())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

ll n;
vector<ll>a;
map<ll,ll>s;
ll solve(){
   ll ans=0;

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

    cin>>n;
    a.resize(n);
    rep(i,n){
        cin>>a[i];
        s[a[i]]++;
        }
    sort(all(a));
    ll mx=a[n-1];
    ll ans=0;
    set<ll>se;
    rep(i,n){
        if(s[1]>1){
            cout<<0<<endl;
            return 0;
        }
        if(s[1]==1){
            cout<<1<<endl;
            return 0;
        }
        if(se.count(a[i])!=0)continue;
        for(ll cur=a[i];cur<=mx;cur+=a[i]){  
            se.insert(cur);
        }
           if(s[a[i]]==1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 55568
n, m = list(map(int, input().split()))

num_without_s = m/4
num_with_s = 0
m_tmp = m
n_tmp = n
""" while m_tmp > 1 and n_tmp > 0:
    num_with_s += 1
    m_tmp = m_tmp - 2
    n_tmp = n_tmp - 1
 """

if m >= (2 * n):
    num_with_s = n
    if (m_tmp - 2*n) > 3:
        num_with_s = num_with_s + int(((m_tmp - 2*n) / 4))
else:
    num_with_s = int(m/2)

if num_with_s > num_without_s:
    print(int(num_with_s))
else:
    print(int(num_without_s))
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define piii pair<int,pair<int,int> >
#define pii pair<int,int>
#define ll long long
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.length();i++){
        int an=1;
        for(int j=0;j<a.length();j++){
            if(a[(i+j)%a.length()]!=b[j]){
                an=0;
                break;
            }
        }
        if(an){
            cout<<"Yes"<<'\n';
            return 0;
        }
    }
    cout<<"No"<<'\n';
    return 0;
}


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

int main() {
  int n;
  cin >>n;
  vector<int>a(2*n);
  for(int i=0;i<2*n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  long long sum=0;  
  for(int i=0;i<n;i++){
    sum+=min(a[2*i],a[2*i+1]);
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vector<vpl> G(101010);
vl deg(101010,0);
vpl ans;
vl rest(101010,0);
vb visit(101010,false);

void dfs(ll u){
	for(auto v : G[u]){
		if(visit[v.second]) continue;
		if(rest[v.first] <= 0) continue;
		visit[v.second] = true;
		dfs(v.first);
		if(rest[v.first] == 1){
			if(deg[v.first] & 1){
				ans.emplace_back(v.first,u);
				deg[v.first]++;
			}else{
				ans.emplace_back(u,v.first);
				deg[u]++;
			}
		}else{
			if(rest[u] == 1){
				if(!(deg[u] & 1)){
					ans.emplace_back(v.first,u);
					deg[v.first]++;
				}else{
					ans.emplace_back(u,v.first);
					deg[u]++;
				}
			}else{
				ans.emplace_back(u,v.first);
				deg[u]++;
			}
		}
		rest[u]--;
		rest[v.first]--;
	}
}

int main(){
	ll n,m; cin >> n >> m;
	rep(i,m){
		ll a,b; cin >> a >> b; a--; b--;
		G[a].emplace_back(b,i);
		G[b].emplace_back(a,i);
		rest[a]++; rest[b]++;
	}
	if(m & 1){
		cout << -1 << endl;
		return 0;
	}
	dfs(0);
	rep(i,n){
		if(deg[i] & 1){
			cout << -1 << endl;
			return 0;
		}
	}
	for(auto i : ans) print2(i.first+1,i.second+1);
}

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

int main()
{
	int a, b;

	cin >> a >> b;

	if (a > b){
		cout << "a > b\n";
	}
	else if (a < b){
		cout << "a < b\n";
	}
	else{
		cout << "a == b\n";
	}
	
	return 0;
}


Measured memory_bytes: 1124
import sys
sys.setrecursionlimit(10**8)
#from collections import deque

n, m = map(int, input().split())
depth = [0 for _ in range(n)]
chil = [[] for _ in range(n)]
rank = [0 for _ in range(n)]
parent = [-1 for _ in range(n)]
#visited = [False for _ in range(n)]
for _ in range(n+m-1):
	a, b = map(int, input().split())
	chil[a-1].append(b-1)
	rank[b-1] += 1

#print(chil)
for i in range(n):
	if rank[i] == 0:
		par = i
		break

parent[par] = -1

#def bfs(x):
#	que = deque([[x, 0]])
#	while que:
#		l = que.pop()
#		y, d = l[0], l[1]
#		print(y, d)
#		if d < depth[y]:
#			continue
#		for c in chil[y]:
#			if depth[c] == -1:
#				depth[c] = d+1
#				parent[c] = y
#				que.appendleft([c, d+1])
#			elif depth[c] < d+1:
#				depth[c] = d+1
#				parent[c] = y
#				que.appendleft([c, d+1])
#
#	return

#bfs(par)

def dfs(x):
	true_chil = []
	for c in chil[x]:
		if rank[c] == 1:
			true_chil.append(c)
		else:
			rank[c] -= 1
	for t in true_chil:
		parent[t] = x
		dfs(t)

	return

dfs(par)

for p in parent:
	print(p+1)

Measured memory_bytes: 289944
fun main(args: Array<String>) {
    a99(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}


fun a99(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    println(if (args[0].toInt() >= 1000) "ABD" else "ABC")
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 1e9;
    rep(si, s.size()) {
        if (si + t.size() > s.size()) break;
        int cnt = 0;
        rep(i, t.size()) {
            if (s[si+i] != t[i]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    d = II()
    print("Christmas",end="")
    for _ in range(25 - d):
        print(" Eve", end="")
    print()
    return

#B
def B():
    n = II()
    p = IR(n)
    p.sort()
    print(sum(p) - p[-1] // 2)
    return

#C
def C():
    n, k = LI()
    h = IR(n)
    h.sort()
    ans = inf
    for i in range(n - k + 1):
        ans = min(ans, h[i + k - 1] - h[i])
    print(ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 43868
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    int z=a/k;
    int z1=b/k;
    for(int i=z;i<=z1+1;i++)
    {
        int res=i*k;
        if(res>=a&&res<=b)
        {
            cout<<"OK"<<endl;
            break;
        }
        if(res>b)
        {
           cout<<"NG"<<endl;
           break;
        }
    }



    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> a(2 * n);
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  int max = 0;
  for (int i = 0; i < n; i++) {
    int score = 0;
    for (int j = 0; j < 2 * n; j++) {
      score += a[j];
      if (j == i) {
        j += n - 1;
      }
    }
    if (score > max) {
      max = score;
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int data[516][516]={0};

int main(){
	data['A']['B']=1;
	data['A']['D']=1;
	
	data['B']['A']=1;
	data['B']['E']=1;
	data['B']['C']=1;
	
	data['C']['B']=1;
	data['C']['F']=1;
	
	data['D']['A']=1;
	data['D']['E']=1;
	data['D']['G']=1;
	
	data['E']['B']=1;
	data['E']['D']=1;
	data['E']['F']=1;
	data['E']['H']=1;
	
	data['F']['C']=1;
	data['F']['E']=1;
	data['F']['I']=1;
	
	data['G']['D']=1;
	data['G']['H']=1;
	
	data['H']['G']=1;
	data['H']['E']=1;
	data['H']['I']=1;
	
	data['I']['F']=1;
	data['I']['H']=1;
	
	
	string s;
	while(cin>>s){
		int f=1;
		for(int i=1;i<s.size();i++){
			if(data[s[i-1]][s[i]]==0)f=0;
		}
		
		if(f)cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 1192
n = int(input())
a = list(map(int, input().split()))

ans = 10**9
for i in range(n):
    tmp = 0
    for j in range(10 ** 9):
        if a[i] % 2 == 0:
            a[i] //= 2
            tmp += 1
        else:
            ans = min(ans, tmp)
            break
print(ans)


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, t, a;
int h[1010];

int solve() {
    int D = inf;
    int res = -1;
    for (int i = 0; i < n; i++) {
        int d = abs(a*1000 - (t*1000-h[i]*6));
        if (d < D) {
            D = d;
            res = i;
        }
    }
    return res+1;
}

void input() {
    cin >> n >> t >> a;
    for (int i = 0; i < n; i++) cin >> h[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        int N = sc.nextInt();
	        long[] a = new long[N];
	        int[] m = new int[1000000];
	        long sum=0;
	        for (int i=0 ; i<N; i++) {
	        	a[i] = Long.parseLong(sc.next());
	            sum=sum^a[i];
	        }
	        long[] ans = new long[N];
	        for(int i=0;i<N;i++) {
	        	ans[i]=sum^a[i];
	        	 System.out.println(ans[i]);
	        }
	        
	       
	    }
	}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}
signed main(){
    int A,B;
    scanf("%lld%lld",&A,&B);
    if(A<=5)cout<<0<<endl;
    else if(A<=12)cout<<B/2<<endl;
    else cout<<B<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
a = [int(input()) for _ in range(N)]

a.sort()
def calc(m):
    if m == 1:
        dqa = deque(a[1:])
        dq = deque([a[0]])
        cnt = 0
    else: 
        dqa = deque(a[:N-1])
        dq = deque([a[-1]])
        cnt = 2

    while len(dq) < N:
        if cnt == 0:
            q = dqa.pop()
            dq.append(q)
        elif cnt == 1:
            q = dqa.pop()
            dq.appendleft(q)
        elif cnt == 2:
            q = dqa.popleft()
            dq.append(q)
        else:
            q = dqa.popleft()
            dq.appendleft(q)
            cnt = -1
        cnt += 1

    ans = 0
    for i in range(1, N):
        ans += abs(dq[i] - dq[i-1])
    return ans
        
print(max(calc(0), calc(1)))


Measured memory_bytes: 8888
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n;
cin >> n;
ll ans=0;
for(ll i=1;i<=n;i++){
    if(i%15==0)continue;
    else if(i%3==0)continue;
    else if(i%5==0)continue;
    else ans+=i;
}
cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void ans(ll a, ll b)
{
    cout << a << ' ' << b << endl;
    exit(0);
}
unsigned long long p5(unsigned long long x)
{
    return x * x * x * x * x;
}
bool in(double p, ll x)
{
    if (p <= x || abs(p - x) <= 100)
        return true;
    return false;
}
void gao(ll d, ll x)
{
    if (abs(pow(d, 5) - x) < 100 && p5(d) == x)
        ans(d, 0);
    /*
    {
        vector<ll> tmp;
        for (int i = 0; i < 20; ++i) {
            tmp.push_back(p5(i + d) - p5(i));
            cerr <<tmp.back()  << ' ';
        }
        cerr <<endl;
        assert(is_sorted(tmp.begin(), tmp.end()));
    }*/
    ll p = 1;
    while (in(pow(p + d, 5) - pow(p, 5), x) && p5(p + d) - p5(p) <= x)
        p *= 2;
    //cerr << "p " << p << endl;
    ll ret = 0;
    for (; p; p /= 2) {
        ll B = ret + p;
        if (in(pow(B + d, 5) - pow(B, 5), x) && p5(B + d) - p5(B) <= x)
            ret = B;
    }
    if (p5(ret + d) - p5(ret) == x)
        ans(ret + d, ret);
    ll l = 0, r = d/2;
    while (l <= r) {
        ll b = (l + r) / 2;
        ll a = d - b;
        if (in(pow(a, 5) + pow(b, 5), x) && p5(a) + p5(b) <= x)
            r = b - 1;
        else
            l = b + 1;
    }
    ll b = l;
    ll a = d - b;
    if (in(pow(a, 5) + pow(b, 5), x) && p5(a) + p5(b) == x)
        ans(a, -b);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x;
    cin >> x;
    for (ll d = 1; d * d <= x; ++d)
        if (x % d == 0) {
            //cerr << "d " << d << ' ' << x /d  << endl;
            gao(d, x);
            gao(x / d, x);
        }
}


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


using namespace std;


using ll = long long;

int main(void) {
    ll A;
    string B;
    cin >> A >> B;

    ll ans = 0;
    ll pi = B.find(".");
    ll B_int = atoll(B.substr(0, pi).c_str());
    ll B_deci = atoll(B.substr(pi + 1).c_str());

    ans += A * B_int;
    ans += A * B_deci / 100;
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	map<int, int> v;
	//tmpの数を増やす
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		v[tmp]++;
	}
	//昇順PQを生成
	priority_queue<int> q;
	//valueを入れてソート
	for (auto i : v) {
		q.push(-1* i.second);
	}

	int H = q.size();
	int ans = 0;
	for (int i = 0; i < H - K; i++) {
		ans +=-1* q.top(); q.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10748
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    vector< vector<int> > source;
    int n, m, c;
    vector< int > b;
    int ans = 0;

    
    scanf("%d %d %d", &n, &m, &c);

    source.resize(m);
    for(int i=0;i<m;i++){
        source[i].resize(n);
    }
    b.resize(m);

    

    for(int i = 0; i<m;i++){
        int temp = 0;
        scanf("%d" ,&temp );
        b[i] = temp;

    }
    for(int k=0;k<n;k++){
        int eq = 0;
        for(int s = 0;s<m;s++){
            int temp;
            scanf("%d", &temp);
            eq += temp*b[s];
            
        }
        eq += c;
        if(eq >0){
            
            ans++;
        }

        
    }



        
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;

    if (s == "Sunny")
        cout << "Cloudy" << endl;
    else if (s == "Cloudy")
        cout << "Rainy" << endl;
    else if (s == "Rainy")
        cout << "Sunny" << endl;
        
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    
    private static int[] getSieve(int max) {
        int[] sieve = new int[max + 1];
        sieve[1] = 1;
        
        for (int i = 2; i <= max; i++) {
            if (0 < sieve[i]) {
                continue;
            }
            
            int j = i;
            while (j <= max) {
                sieve[j] = i;
                j += i;
            }
        }
        return sieve;
    }
    
    private static Set<Integer> factorize(int n, int[] sieve) {
        Set<Integer> factors = new HashSet<>();
        
        while (1 < n) {
            int p = sieve[n];
            factors.add(p);
            n /= p;
        }
        
        return factors;
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final int[] A = new int[N];
        
        int max = 0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            if (max < A[i]) {
                max = A[i];
            }
        }
        final int[] sieve = getSieve(max);
        
        Set<Integer> fs0 = factorize(A[0], sieve);
        int count = fs0.size();
        Set<Integer> sum = new HashSet<>(fs0);
        Set<Integer> prod = new HashSet<>(fs0);
        
        for (int i = 1; i < N; i++) {
            Set<Integer> fs = factorize(A[i], sieve);
            count += fs.size();
            sum.addAll(fs);
            prod.retainAll(fs);
        }
        
        if (sum.size() == count) {
            System.out.println("pairwise coprime");
            
        } else if (prod.size() == 0) {
            System.out.println("setwise coprime");
            
        } else {
            System.out.println("not coprime");
        }
    }
}


Measured memory_bytes: 71860
a = list(input())
b = list(input())
c = list(input())
check = "a"
while True:
    if check == "a":
        if len(a) == 0:
            print("A")
            break
        else:
            check = a[0]
            a.pop(0)
    if check == "b":
        if len(b) == 0:
            print("B")
            break
        else:
            check = b[0]
            b.pop(0)
    if check == "c":
        if len(c) == 0:
            print("C")
            break
        else:
            check = c[0]
            c.pop(0)

Measured memory_bytes: 9112
def input_from_console():
    n = int(input())
    a_list, b_list = [], []
    for i in range(n - 1):
        data = input()
        a, b = map(int, data.split())
        if b > a:
            a, b = b, a  # swap smaller one.
        a_list.append(a)
        b_list.append(b)
    c_list = list(map(int, input().split()))
    return n, a_list, b_list, c_list


def solve(n, a_list, b_list, c_list):
    edge = [[] for i in range(n)]  # 0 based list of list.
    for i in range(len(a_list)):
        a, b = a_list[i] - 1, b_list[i] - 1  # convert to 0 based index.
        edge[a].append(b)
        edge[b].append(a)
    c_list.sort(reverse=True)

    vertices = [None] * n
    vertices[0] = c_list.pop(0)

    graph_value = sum(c_list)  # edge should have the value except the maximum.

    search_path = []
    search_path.extend(edge[0])

    while search_path:
        node = search_path.pop(0)
        if vertices[node] is None:
            vertices[node] = c_list.pop(0)
            search_path.extend(edge[node])
    return "{:d}\n{}".format(graph_value, ' '.join(map(str, vertices)))


def main():
    n, a_list, b_list, c_list = input_from_console()
    print(solve(n, a_list, b_list, c_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Measured memory_bytes: 6648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, k);
    Cin(string, s);
    if(s.size() <= k) Return(s);
    For(i, k) cout << s[i];
    Cout("...");
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
    int n;
    bool bingo[3][3] = {
         false, false, false,
         false, false, false,
         false, false, false
     };
    map<int, int> pb;
    for(int i =0; i < 9; i++) {
        cin >> pb[i];
    }

    cin >> n;
    set<int> b;
    for(int i=0; i<n; i++) {
        int x;
        cin >> x;
        b.insert(x);
    }

    for(auto i = pb.begin(); i != pb.end(); ++i){
        if(b.find(i->second) != b.end()) {
            if(i->first <3)
                bingo[0][i->first%3] = true;
            else if(i->first < 6)
                bingo[1][i->first%3] = true;
            else
                bingo[2][i->first%3] = true;
        }
    }
    if(
        (bingo[0][0] && bingo[0][1] && bingo [0][2]) || 
        (bingo[1][0] && bingo[1][1] && bingo [1][2]) || 
        (bingo[2][0] && bingo[2][1] && bingo [2][2]) || 
        (bingo[0][0] && bingo[1][0] && bingo [2][0]) || 
        (bingo[0][1] && bingo[1][1] && bingo [2][1]) || 
        (bingo[0][2] && bingo[1][2] && bingo [2][2]) || 
        (bingo[0][0] && bingo[1][1] && bingo [2][2]) || 
        (bingo[0][2] && bingo[1][1] && bingo [2][0]) 
    ) cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int func(int x)
{
    int count = 0;

    while(x % 2 == 0) {
        count++;
        x /= 2;
    }

    return count;
}

int main()
{
    int n;
    cin >> n;

    int ans = 0;

    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans += func(a);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define OUT(x) cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

signed main() { 
        int n;
        cin >> n;
        vector<int> a(n);
        int m = -1;
        rep(i, n) { 
                cin >> a[i];
                amax(m, a[i]);
        }
        m --;
        bool equ = true;
        bool ans = true;
        rep(i, n) if (a[i] != m + 1 && a[i] != m) ans = false;
        if (ans) {
                rep(i, n) if (a[i] != m + 1) equ = false;
                if (!equ) {
                        int cnt = 0;
                        rep(i, n) {
                                if (a[i] == m) cnt ++;
                        }
                        if (m + 1 - cnt > 0 && n - cnt >= 2 * (m + 1 - cnt)) ans = true;
                        else ans = false;
                } else {
                        if (n - 1 == m + 1 || n >= 2 * (m + 1)) ans = true;
                        else ans = false;
                }
        }
        cout << (ans ? "Yes" : "No") << endl;
        return 0;
}               


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

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

void dump(const VI &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

void dump2D(const VI &v, int w, int h)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

struct Matrix{
	ll w, h;
	VL A;
	Matrix(ll w_, ll h_) : w(w_), h(h_), A(w * h) {}
	ll get(ll x, ll y) const { return A[y * w + x]; }
};

void input(Matrix &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

Matrix prod(const Matrix &a, const Matrix &b)
{
	Matrix m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

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

	Matrix A(m, n);
	Matrix B(l, m);

	input(A);
	input(B);

//	dump(A);
//	dump(B);

	Matrix C = prod(A, B);

	dump(C);

	return 0;
}



Measured memory_bytes: 3280
A,B = map(float,input().split())

# 1-1250円
A1 = A / 0.08
A2 = (A+1)/0.08
B1 = B / 0.1
B2 = (B+1) / 0.1

Flag = True
for i in range(1,1251):
    if (A1 <= i) and (i < A2) and (B1 <= i) and (i < B2):
        print(i)
        break
    if i == 1250:
        Flag = False

if (not Flag):
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


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

  REP(i, 3) if (S[i] == S[i + 1]) {
    cout << "Bad" << endl;
    return 0;
  }
  cout << "Good" << endl;


  return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));

		int numberS = Integer.parseInt(br.readLine());

		String[] progressionS = br.readLine().split(" ");

		int[] S = new int[numberS];

		for (int i = 0; i < numberS; i++) {
            S[i] = Integer.parseInt(progressionS[i]);
		}

		int numberT = Integer.parseInt(br.readLine());

		String[] progressionT = br.readLine().split(" ");

		int[] T = new int[numberT];

		for (int i = 0; i < numberT; i++) {
			T[i] = Integer.parseInt(progressionT[i]);
		}

		int equalCount = 0;
		for(int i = 0; i < numberT; i++) {

			int start = 0;
			int end = numberS - 1;

			while(start <= end) {
				int target = start + (end - start) / 2;

				if(T[i] == S[target]) {
					equalCount++;
					break;
				} else if(T[i] > S[target]) {
					start = target + 1;
				} else if(T[i] < S[target]) {
					end = target - 1;
				}
			}
		}
		System.out.println(equalCount);
	}
}

Measured memory_bytes: 52252
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a = inpl()
print(a[2],a[0],a[1])

Measured memory_bytes: 63980