akhauriyash/Code-Regression huggingface dataset:
let () = Scanf.scanf "%d\n%s\n%s\n%s" @@ fun n a b c ->
  Printf.printf "%d\n" @@ Array.fold_left ( + ) 0 @@ Array.init n @@ fun i ->
    pred @@ List.length @@ List.sort_uniq compare [a.[i]; b.[i]; c.[i]]



Measured memory_bytes: 384
/*
    Solution by Abil
*/

#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define int long long

using namespace std;

const long long N = (1e6 + 12);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 123);

int dp[N], arr[N], pr[N];
main(){
    int n, k;
    cin >> n >> k;
    for(int i = 1;i <= n; i++){
        cin >> arr[i];
        dp[i] = inf;
    }
    dp[1] = 0;
    for(int i = 2;i <= n; i++){
        for(int j = i - 1;j >= max(i - k, 1ll); j--){
            dp[i] = min((abs(arr[j] - arr[i]) + dp[j]),dp[i]);
        }
    }
    cout << dp[n];
}


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

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

    long long count = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;

        count += i;
    }

    cout << count << endl;
}

Measured memory_bytes: 3672
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var i = int.Parse(ReadLine());
        var ast = ReadLine().Split();
        var a = new int[i];
        for(var j = 0; j < i; j++)
        {
            a[j] = int.Parse(ast[j]);
        }

        //var b = new List<int>();
        for(var j = a.Length - 1; j > 0; )
        {
            //b.Add(a[j]);
            Write(a[j]+" ");
            j -= 2;
        }

        for(var j = 0;j < a.Length - 2;)
        {
            //b.Add(a[j]);
            Write(a[j] + " ");
            if (j == 0 && a.Length % 2 == 1)
            {   j++;
                Write(a[j] + " ");
            }
            j += 2;
        }
        
        if(i != 1 && i != 3)
        WriteLine(a[a.Length - 2]);

        if (i == 1) WriteLine(a[0]);
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

typedef long long ll;

const int MAX_A=55555;

bool flg[MAX_A+1];
vector<int> pri;

void era(){
	memset(flg,true,sizeof(flg));
	FOR(i,2,MAX_A+1){
		if (flg[i]){
			if (i%5==1) pri.push_back(i);
			for(int j=i*2;j<=MAX_A;j+=i){
				flg[j]=false;
			}
		}
	}
}

int main(){
	int A,B;
	cin>>A>>B;
	if (A<=B){
		cout<<A<<endl;
	}else{
		cout<<A-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//ALDS1_6_A_CountingSort.cpp
#include<bits/stdc++.h>
using namespace std;
const int INF=2E9;
typedef pair<int,int> Pair;
typedef long long LL;
int cnt=0;


int main(){
    int n;
    cin >> n;
    int C[10010]={};
    int tmp;
    int maxV=-1;
    for(int i=0;i<n;i++){
        scanf("%d",&tmp);
        C[tmp]++;
        maxV=max(maxV,tmp);
    }
    int cnt=0;
    for(int i=0;i<=maxV;i++){
        for(int j=0;j<C[i];j++){
            printf("%d",i);
            cnt++;
            if(cnt==n) printf("\n");
            else printf(" ");
        }   
    }
    return 0;
}



Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
int ans=0;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		for(int c=i;c<s.size();c++)
		{
			if(i==0&&c==(s.size()-1))
				continue;
			string s2="",s3="",s4="";
			for(int v=i;v<c;v++)
				s2+=s[v];
			for(int v=0;v<s2.size()/2;v++)
				s3+=s2[v];
			for(int v=s2.size()/2;v<s2.size();v++) 
				s4+=s2[v];
			int u=s2.size();
			if(s3==s4)
				ans=max(ans,u);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  ll a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}

Measured memory_bytes: 3624
$N = gets.chomp.to_i

$res = {}

$N.times do
  d = gets.chomp
  $res[d] ||= 0
  $res[d] += 1
end

$M = gets.chomp.to_i

$M.times do
  d = gets.chomp
  $res[d] ||= 0
  $res[d] -= 1
end

b = $res.max_by { |_, a| a }[1]
puts b < 0 ? 0 : b

Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {
            String cards = sc.next();

            if (cards.equals("-"))
                break;

            int m = sc.nextInt();
            
            while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            }

            System.out.println(cards);
        }

    }
    private static String shuffle(String cards, int h) {
        return cards.substring(h) + cards.substring(0, h);
    }
}



Measured memory_bytes: 26580
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string N;
	cin >> N;
	reverse(N.begin(), N.end());
	N += '0'; //番兵

	int ans = 0;
	bool carry = false;
	for (int i = 0; i < N.size(); i++) {

		int now = N[i] - '0' + carry;

		if (now == 5) {
			ans += 5;
			if (N[i + 1] - '0' >= 5) carry = true;
			else carry = false;
		}
		else if (now > 5) {
			ans += 10 - now;
			carry = true;
		}
		else {
			ans += now;
			carry = false;
		}

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1948
import java.util.Scanner;

public class Main {
	int n;
	int ary[];
	int cnt;
	public static void main(String args[]) {
		new Main().run();
	}

	Main() {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		ary = new int[n];
		for (int i = 0; i < n; i++) {
			ary[i] = scan.nextInt();
		}
	}

	void run() {
		mergeSort(ary,0,n);
		for (int i = 0; i < n; i++) {
			System.out.print((i!=0?" ":"") + ary[i]);
		}
		System.out.println();
		System.out.println(cnt);
	}
	void mergeSort(int[] ary, int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right ) / 2;
			mergeSort(ary, left, mid);
			mergeSort(ary, mid, right);
			merge(ary, left, mid, right);
		}
	}
	void merge(int[] ary, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		int l[] = new int[n1+1];
		int r[] = new int[n2+1];
		for (int i = 0; i < n1; i++) {
			l[i] = ary[left + i];
		}
		for (int i = 0; i < n2; i++) {
			r[i] = ary[mid + i];
		}
		l[n1] = Integer.MAX_VALUE;
		r[n2] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		for (int k = left; k < right; k++) {
			if (l[i] <= r[j]) {
				ary[k] = l[i];
				i++;
			} else {
				ary[k] = r[j];
				j++;
			}
			cnt++;
		}
	}
}


Measured memory_bytes: 170872
n=int(input())
t,a=map(int,input().split())
h=[int(x) for x in input().split()]
new=[]
for i in range(n):
  temp=t-h[i]*0.006
  new.append(temp)
new2=[]
for j in range(n):
  sub=abs(a-new[j])
  new2.append(sub)
num=min(new2)
print(new2.index(num)+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

// DAME: 

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; }

// ２で割り切れる回数 
int f(int x){
    int res = 0;
    while(x%2==0){
        x/=2;
        res++;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    // 偶数かの確認
    rep(i, n){
        if(a[i]%2==1){
            cout << 0 << endl;
            return 0;
        }
        a[i] /= 2;
    }

    // 2で割り切れる回数は全て同じ
    int t = f(a[0]);
    rep(i, n){
        if(f(a[i]) != t){
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= t; // a[i] /= 2^t
    }

    m >>= t; // 切り捨て m/(2^t)は偶数であるべき

    ll l = 1;
    rep(i, n){
        l=lcm(l, a[i]);
        if (l>m){
            cout << 0 << endl;
            return 0;
        }
    }

    m /= l;
    int ans = (m+1)/2; // 切り上げ 奇数の数を数えてる
    cout << ans << endl;
    return 0;
}

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

typedef struct element {
    struct element *next;
} element;

typedef struct {
    int n;
    element *head;
    element *tail;
} set;

int *l;
set **f;

element *elements;

void initialize(int n) {
    int i;

    l = calloc(n + 1, sizeof(int));
    f = calloc(n + 1, sizeof(set *));
    elements = calloc(n + 1, sizeof(element));

    for (i = 1; i <= n; i++) {
        f[i] = NULL;
    }
}

void new_pair(int x, int y) {
    set *s = malloc(sizeof(set));

    f[x] = f[y] = s;

    elements[x].next = &elements[y];
    elements[y].next = NULL;

    s->n = 2;
    s->head = &elements[x];
    s->tail = &elements[y];
}

void merge(set *s1, set *s2) {
    element *e;

    if (s1->n < s2->n) {
        merge(s2, s1);
        return;
    }

    /** s2が小さいのでs1に寄せる */
    for (e = s2->head; e; e = e->next) {
        f[e - elements] = s1;
    }

    s1->n += s2->n;
    s1->tail->next = s2->head;
    s1->tail = s2->tail;
}

void insert(int x, set *s) {
    f[x] = s;
    element *e = &elements[x];
    e->next = s->head;
    s->head = e;
    s->n++;
}

void add_pair(int x, int y) {
    set *f_x, *f_y;

    if ((f_x = f[x])) {
        if ((f_y = f[y])) {
            if (f_x != f_y) {
                merge(f_x, f_y);
            }
        } else {
            insert(y, f_x);
        }
    } else {
        if ((f_y = f[y])) {
            insert(x, f_y);
        } else {
            new_pair(x, y);
        }
    }
}

int movable(int from, int to) {
    if (from == to) {
        return !0;
    }

    return f[from] && f[to] && f[from] == f[to];
}

int main()
{
    int i;
    int n, m;
    int x, y;
    int r;

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

    initialize(n);

    for (i = 1; i <= n; i++) {
        scanf("%d", &l[i]);
    }

    for (i = 1; i <= m; i++) {
        scanf("%d %d", &x, &y);
        add_pair(x, y);
    }

    r = 0;
    for (i = 1; i <= n; i++) {
        if (movable(i, l[i])) {
            r++;
        }
    }

    printf("%d\n", r);
    return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

int compare_int(const void *a, const void *b){//qsort 整数比較<
	return *(int*)a - *(int*)b;
}
int compare_int2(const void *a, const void *b){//qsort 整数比較>
	return *(int*)b - *(int*)a;
}

int main(void){
	long long int n,ans=1;
	long long int x[10000010]={1};
	int i;
	int temp;

	scanf("%I64d",&n);
	for(i=2;i<=n;i++){
		for(temp=1;i*temp<=n;temp++){
			x[i*temp]++;
		}
	}
	for(i=2;i<=n;i++){
		ans+=(x[i]+1)*i;
	}
	printf("%lld",ans);

	return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll H, N, A[1010], B[1010];
ll dp[10101];
ll i, j, k;
int main(){
    scanf("%lld%lld", &H, &N);
    fornum(i,0,N){
        scanf("%lld%lld", &A[i], &B[i]);
    }
    
    fornum(i,0,H+2){
        dp[i] = 1e18;
    }
    dp[0] = 0;
    fornum(i,0,N){
        fornum(j,0,H){
            dp[min(j + A[i], H)] = min(dp[min(j + A[i], H)], dp[j] + B[i]);
        }
    }
    printf("%lld", dp[H]);
    return 0;
}

Measured memory_bytes: 384
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,arr[100005],byk[100005];
ll tot;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        byk[arr[i]]++;
        tot+=arr[i];
    }
    int q;
    cin>>q;
    for(int i=1;i<=q;i++){
        int x,y;
        cin>>x>>y;
        ll sel=y-x;
        tot+=(byk[x]*sel);
        byk[y]+=byk[x];
        byk[x]=0;
        cout<<tot<<endl;
    }

}

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

const int INF = 1e8;
 
int main(){ 
  int H, W;
  vector<vector<int>> C(10, vector<int>(10));
  vector<vector<int>> A(210, vector<int>(210));

  cin >> H >> W;
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      cin >> C[i][j];
    }
  }

  for(int k=0; k<10; k++){
    for(int i=0; i<10; i++){
      for(int j=0; j<10; j++){
        C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
      }
    }
  }

  int ans = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> A[i][j];
      if(A[i][j] != -1) ans += C[A[i][j]][1];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

count = 0
for i in range(n):
    for j in range(i+1, n):
        sq = 0
        for k in range(d):
            sq += (x[i][k]-x[j][k])**2
        if math.sqrt(sq).is_integer():
            count += 1

print(count)


Measured memory_bytes: 3060
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		unordered_map<string,int> mp;
		while(n--)
		{
			string s;
			cin>>s;
			mp[s]++;
		}
		cout<<"AC x "<<mp["AC"]<<"\n";
		cout<<"WA x "<<mp["WA"]<<"\n";
		cout<<"TLE x "<<mp["TLE"]<<"\n";
		cout<<"RE x "<<mp["RE"]<<"\n";	
    }
    return 0;
}


Measured memory_bytes: 3604
def main():
    A,B = [int(i) for i in input().split()]
    list=[]
    sum=A+B
    sub=A-B
    multi=A*B
    list.append(sum)
    list.append(sub)
    list.append(multi)
    print(max(list))

if __name__ == "__main__":
    main()

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

int B[105];
int main(void){
    // Your code here!
    int N;
    cin >> N;
    
    for(int i = 0; i < N-1; i++){
        cin >> B[i];
    }
    
    int ans = 0;
    ans += B[0];
    ans += B[N-2];
    
    for(int i = 0; i < N - 2; i++) {
        ans += min(B[i], B[i+1]);
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];
    
    vector<long long> dp(H+1, INF);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= H; ++j) {
            chmin(dp[min(j+A[i], H)], dp[j] + B[i]);
        }
    }
    cout << dp[H] << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;


int main(void) {
    int n, m; cin >> n >> m;
    vector<long long > a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<long long >());
    vector<long long > b(m);
    vector<long long > c(m);
    vector< pair<long long , long long > > p(m);
    for(int i=0; i<m; i++) {
      cin >> b[i] >> c[i];
      p[i].first = -c[i];
      p[i].second = -b[i];
    }
    long long int sum = 0;
    sort(p.begin(), p.end());

    int x = 0;
    int pp = 0;
    int aa = 0;
    while(true) {
      if(x >= n) break;
      // cerr << -p[pp].first << " " << a[aa] << endl;
      if(-p[pp].first > a[aa]) {
        for(int i=0; i< -p[pp].second; i++) {
          x++;
          sum += -p[pp].first;
          if(x >= n) break;
        }
        pp++;
      }else if(-p[pp].first == a[aa]) {
        for(int i=0; i<= -p[pp].second; i++) {
          x++;
          sum += -p[pp].first;
          if(x >= n) break;
        }
        pp++;
        aa++;
      }else {
        x++;
        sum += a[aa];
        aa++;
      }
      // cerr << sum << endl;
    }
    
    cout << sum << endl;
    

    return 0;
}



// EOF


Measured memory_bytes: 4224
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
li = [I() for _ in range(6)] #n行に１つずつ入力される整数
if (li[4] - li[0]) <= li[5]:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long

int sa[26];
int ta[26];

int main(void){
	string s;
	string t;
	cin >> s >> t;
	long long ans = 0;
	//sをめっちゃ連結させて、左から必要な要素だけを取り出すと
	//tになるかどうかを調べたい
	//まずsに含まれるアルファベットを調べる
	vector<vector<int>> v(26);
	// v[0][0] には aが最初に出現する場所が入っている
	for(int i=0;i<s.size();i++){
		sa[s[i]-'a']++;
		v[s[i]-'a'].emplace_back(i);
	}
	for(int i=0;i<t.size();i++){
		ta[t[i]-'a']++;
	}
	bool ok = 1;
	for(int i=0;i<26;i++){
		if(ta[i]>0 && sa[i]==0)ok = 0;
	}
	if(ok){
		//cout << "作れます" << endl;
		//作れる場合はtの先頭からsの何番目に出現するかを調べる
		int cur = 0;
		int p = -1;
		while(cur != t.size()){
			int now = (int)t[cur]-(int)'a';//今見なきゃいけないアルファベット
			//v[now] に now の座標が入っている
			
			auto are = upper_bound(v[now].begin(),v[now].end(),p);
			if(are == v[now].end()){
				ans += s.size()- 1 - p;
				p = -1;
				continue;
			}else{
				int soezi = are - v[now].begin();//v[now][0]= 6みたいな感じで出現する番号的な
				ans += v[now][soezi] - p;
				p = v[now][soezi];
				//cout << p << endl;
			}
			cur ++;
		}
		cout << ans << endl;
	}else{
		cout << -1 << endl;
	}
}

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

int main(){

  string S = "";
  cin >> S;

  if (S == "SUN") {
    cout << "7" << endl;
  } else if (S == "MON") {
    cout << "6" << endl;
  } else if (S == "TUE") {
    cout << "5" << endl;
  } else if (S == "WED") {
    cout << "4" << endl;
  } else if (S == "THU") {
    cout << "3" << endl;
  } else if (S == "FRI") {
    cout << "2" << endl;
  } else if (S == "SAT") {
    cout << "1"<< endl;
  }

  return 0;
}

Measured memory_bytes: 760
s = input()
n = len(s)
dp = [1] + [0]*2019
now = 0
i = 1

for c in reversed(s):
    now = (now+i*int(c))%2019
    dp[now] += 1
    i = (i*10)%2019

ans = sum([i*(i-1)/2 for i in dp])
print(int(ans))

Measured memory_bytes: 9368
import java.util.Scanner;

/*
各要素が2で何回割れるか
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        int res = 0;
        for(int i = 0; i < N; i++) {
            int tmp = arr[i];
            while(tmp > 0) {
                if(tmp%2 == 0) {
                    res++;
                    tmp /=2;
                } else {
                    break;
                }
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 48688
A = list(input())
B = list(input())
C = list(input())
x = 'a'
ans = 0
for i in range(len(A) + len(B) + len(C)):
    if x == 'a':
        if len(A) == 0:
            ans = 'A'
            break
        else:
            x = A.pop(0)
    if x == 'b':
        if len(B) == 0:
            ans = 'B'
            break
        else:
            x = B.pop(0)
    if x == 'c':
        if len(C) == 0:
            ans = 'C'
            break
        else:
            x = C.pop(0)
print(ans)

Measured memory_bytes: 3064
import sys
n = int(input())
a = list(map(int, input().split()))
d = max(a)-min(a)
if d == 0:
    print(0)
    sys.exit()
m = 0
for i in a:
    m += (d-i) ** 2
for i in range(d):
    c = min(a) + i
    cost = 0
    for j in a:
        cost += (c-j) ** 2
    if m > cost:
        m = cost
print(m)

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

int main(void){
  string s1,s2,s3;
  string S[3];
  cin >> s1 >> s2 >> s3;
  S[0] = s1.front();
  S[1] = s2.front();
  S[2] = s3.front();
  for(int i = 0;i < 3;i++){
    if(S[i] == "a"){
      S[i] = "A";
    }
    else if(S[i] == "b"){
      S[i] = "B";
    }
    else if(S[i] == "c"){
      S[i] = "C";
    }
    else if(S[i] == "d"){
      S[i] = "D";
    }
    else if(S[i] == "e"){
      S[i] = "E";
    }
    else if(S[i] == "f"){
      S[i] = "F";
    }
    else if(S[i] == "g"){
      S[i] = "G";
    }
    else if(S[i] == "h"){
      S[i] = "H";
    }
    else if(S[i] == "i"){
      S[i] = "I";
    }
    else if(S[i] == "j"){
      S[i] = "J";
    }
    else if(S[i] == "k"){
      S[i] = "K";
    }
    else if(S[i] == "l"){
      S[i] = "L";
    }
    else if(S[i] == "m"){
      S[i] = "M";
    }
    else if(S[i] == "n"){
      S[i] = "N";
    }
    else if(S[i] == "o"){
      S[i] = "O";
    }
    else if(S[i] == "p"){
      S[i] = "P";
    }
    else if(S[i] == "q"){
      S[i] = "Q";
    }
    else if(S[i] == "r"){
      S[i] = "R";
    }
    else if(S[i] == "s"){
      S[i] = "S";
    }
    else if(S[i] == "t"){
      S[i] = "T";
    }
    else if(S[i] == "u"){
      S[i] = "U";
    }
    else if(S[i] == "v"){
      S[i] = "V";
    }
    else if(S[i] == "w"){
      S[i] = "W";
    }
    else if(S[i] == "x"){
      S[i] = "X";
    }
    else if(S[i] == "y"){
      S[i] = "Y";
    }
    else if(S[i] == "z"){
      S[i] = "Z";
    }
  }
  cout << S[0]+S[1]+S[2] << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void){
   
	int S,h,m,s;

	scanf("%d",&S);
	
	h = S/3600 ;
	m = (S%3600) / 60 ;
	s = S % 60;

	printf("%d:%d:%d\n",h,m,s);
	 
     return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

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

    int ans = n-k;
    if (k == 1) ans = 0;

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

Measured memory_bytes: 256
// @problemURL url.com
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func nt(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

func ni(s *bufio.Scanner) int {
	return atoi(nt(s))
}

func atoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	var in = bufio.NewReader(os.Stdin)
	s := bufio.NewScanner(in)
	s.Split(bufio.ScanWords)

	// Code
	fmt.Println(2.0 * math.Pi * float64(ni(s)))
}


Measured memory_bytes: 1756
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;

int main() {
   ll X, Y;
   cin >> X >> Y;

   int ans = 0;
   for (;;) {
      X *= 2;
      if (X <= Y) ans++;
      else break;
   }
   cout << ans + 1 << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int x; cin >> x;
	if(x < 1200)printf("ABC\n");
	else printf("ARC\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	char str[30];
	int i;

	scanf("%[^\n]",str);
	i=0;
	while(str[i]!='\0'){
		i++;
	}
	while(i!=0){
		printf("%c",str[i-1]);
		i--;
	};
	printf("\n");

	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int d[5005][5005];

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

	memset(d, 0, sizeof(d));

	rep(i, m) {
		int a, b, x;
		cin >> a >> b >> x;

		a--;
		b--;

		d[a][b]++;
		d[a][b+1]--;

		d[a+x+1][b]--;
		d[a+x+2][b+1]++;

		d[a+x+1][b+x+2]++;
		d[a+x+2][b+x+2]--;
	}

	rep(i, n) {
		rep(j, i+1) d[i][j+1] += d[i][j];
	}

	rep(i, n) {
		rep(j, i+1) d[i+1][j] += d[i][j];
	}

	rep(i, n) {
		rep(j, i+1) d[i+1][j+1] += d[i][j];
	}

	int ans = 0;
	rep(i, n) {
		rep(j, i+1) {
			if(d[i][j]) ans++;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 99020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC122A
{
    class Program
    {
        static void Main(string[] args)
        {
            string a, b;
            a = Console.ReadLine();
            if (a == "A")
                b = "T";
            else if (a == "C")
                b = "G";
            else if (a == "T")
                b = "A";
                else
                b="C ";
            Console.WriteLine(b);
            Console.ReadKey();
                       }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



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

	ll S;
	cin>>S;
	
	ll x1=ll(sqrt(S));
	while ((x1+1)*(x1+1)<=S) x1++;
	ll y2=S/x1;
	ll x2=0,y1=0,x3=0,y3=0;
	if (x1*y2<S) {
		x2=-1;
		y1=S-x1*y2;
		
		x1++;
		x2++;
		x3++;
	}
	
	assert(abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))==S);
	assert(x1>=0 && x1<=int(1e9));
	assert(y1>=0 && y1<=int(1e9));
	assert(x2>=0 && x2<=int(1e9));
	assert(y2>=0 && y2<=int(1e9));
	assert(x3>=0 && x3<=int(1e9));
	assert(y3>=0 && y3<=int(1e9));
	cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define INF 1000000000
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
  int x = 0, p = 1; char c = getchar();
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
const int mod = 1e9 + 7;
inline void reduce(int &x) { x += x >> 31 & mod; }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
//ruogu_alter
const int N = 15;
int n, m, k;
int c[N], a[N][N], val[N];
//
int main() {
  n = getint(); m = getint(); k = getint();
  rep(i, n) {
    c[i] = getint();
    rep(j, m) a[i][j] = getint();
  }
  int res = INF;
  rep(mask, 1 << n) {
    memset(val, 0, sizeof(val));
    int ans = 0;
    rep(i, n) if (mask >> i & 1) {
      rep(j, m) val[j] += a[i][j];
      ans += c[i];
    }
    bool fg = true;
    rep(j, m) if (val[j] < k) { fg = false; break; }
    if (fg) res = min(res, ans);
  }
  if (res == INF) res = -1;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int h, w, n;
char ss[305][305];
int s[305][305];
int i, j, k, q;
int sm[305][305], an[305][305];
int ma;
int zuo, you, shang, xia, tot;
int main() {
	cin >> h >> w >> n;
	for(i = 1; i <= h; ++i)
		for(j = 1; j <= w; ++j)
			cin >> ss[i][j];
	for(i = 1; i <= h; ++i)
		for(j = 1; j <= w; ++j)
			if(ss[i][j] == '#')	s[i][j] = 1;
	/*for(i = 1; i <= h; ++i) {
		for(j = 1; j <= w; ++j)
			cout << s[i][j];
		cout << endl;
	}*/
	for(i = 1; i <= w; ++i) 
		for(j = 1; j <= h; ++j) {
			sm[i][j] = sm[i][j - 1] + s[j][i];
			if(sm[i][j]) ma = max(ma, i);
		//	cout << i << " " << j << " " << sm[i][j] << endl;
		}//cout << ma << endl;
	zuo = 1;
	for(i = 1; i < ma; ++i) {
		if(!sm[i][h]) continue; 
		shang = 1;
		for(j = 1; j <= h; ++j) {
			if(!s[j][i]) continue;
			++tot;
			xia = j;
			if(sm[i][j] == sm[i][h]) xia = h;
			//if(i == 1 && j == 1 ) cout << shang << " " << xia << endl;
			//cout << tot << " a " << shang << " " << xia << endl;
			for(k = shang; k <= xia; ++k) {
				for(q = zuo; q <= i; ++q) {
					an[k][q] = tot;
				}
			}
			shang = j + 1;
			if(xia == h) break;
		}
		zuo = i + 1;
	}
	shang = 1;
	you = w;
	for(j = 1; j <= h; ++j) {
		if(!s[j][i]) continue;
		++tot;
		xia = j;
		if(sm[i][j] == sm[i][h]) xia = h;
		for(k = shang; k <= xia; ++k) {
			for(q = zuo; q <= you; ++q) {
				an[k][q] = tot;
			}
		}
		shang = j + 1;
		if(xia == h) break;
	}	
	for(i = 1; i <= h; ++i) {
		for(j = 1; j <= w; ++j)
			cout << an[i][j] << " ";
		cout << endl;	
	}
	return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    int r, g, b;
    cin >> r >> g >> b;

    int num = r * 100 + g * 10 + b;
    if (num % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}


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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

X,Y = inputIL()

if (X+Y) % 3 != 0 or X>2*Y or Y>2*X:
  print(0)
  exit()
  
n = (X+Y)//3

x = n*2-Y
y = n-x

print(nCr(x+y,x))

Measured memory_bytes: 111212
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

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

    int i;

    if(S.length() <= K){cout << S << endl; return 0;}
    else{
        for(i=0;i<K;i++){
            cout << S[i];
        }
        cout << "..." << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n;
    cin>>n;
    map<ll,ll> m;
    ll ans=0;
    rep(i,n){
        ll a;
        cin>>a;
        ans+=a;
        m[a]++;
    }

    int q;
    cin>>q;
    rep(i,q){
        ll b,c;
        cin>>b>>c;
        ans+=(c-b)*m[b];
        m[c]+=m[b];
        m[b]=0;
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 9444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int t,x;
    cin >> t >> x;
    cout << setprecision(10) << (double)t/x << "\n";
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A, B = LI()
    P = LI()

    ans = [0] * 3
    for i in P:
        if i <= A:
            ans[0] += 1
        elif A + 1 <= i <= B:
            ans[1] += 1
        else:
            ans[2] += 1

    print(min(ans))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10064
#include <iostream>
#include <stack>
#include <complex>

using namespace std;

typedef complex<int> P;

int main() {
	int W, H;
	while (cin >> W >> H, W || H) {
		int sx, sy; cin >> sx >> sy; --sx, --sy;
		int gx, gy; cin >> gx >> gy; --gx, --gy;
		int n; cin >> n;

		int board[100][100] = {0};
		for (int i = 0; i < n; ++i) {
			int c, d, x, y; cin >> c >> d >> x >> y; --x, --y;
			int lx = x, ly = y;
			int rx, ry;

			if (d == 0) rx = x + 4, ry = y + 2;
			else rx = x + 2, ry = y + 4;

			for (y = ly; y < ry; ++y)
				for (x = lx; x < rx; ++x)
					board[y][x] = c;
		}

		bool f = false;
		P goal = P(gx, gy);
		int color = board[sy][sx];

		if (color == 0) {
			cout << "NG" << endl;
			continue;
		}

		stack<P> S; S.push( P(sx, sy) );
		while ( !S.empty() ) {
			P p = S.top(); S.pop();

			if (p.real() < 0 || p.real() >= W || p.imag() < 0 || p.imag() >= H) continue;
			if (board[p.imag()][p.real()] != color) continue;
			board[p.imag()][p.real()] = 0;

			if ( p == goal ) {
				cout << "OK" << endl;
				f = true;
				break;
			}

			S.push( p + P(1, 0) );
			S.push( p + P(-1, 0) );
			S.push( p + P(0, 1) );
			S.push( p + P(0, -1) );
		}
		if (f) continue;

		cout << "NG" << endl;
	}
}

Measured memory_bytes: 0
using System;
using System.Linq;

namespace A___Restricted
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_B = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(A_B.Sum() < 10 ? A_B.Sum().ToString() : "error");
        }
    }
}


Measured memory_bytes: 13396
def resolve():
    #n=int(input())
    #a,b=map(int,input().split())
    #x=list(map(int,input().split()))
    #a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)]
    a,b,c,d=map(int,input().split())
    print(max(a*c,a*d,b*c,b*d))

if __name__ == '__main__':
    resolve()

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  for(int i = k; i < n; i++){
    if(a.at(i-k) >= a.at(i)) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
ll dp[109][109][500];
signed main(){
	int n,w;
	cin>>n>>w;
	vector< pair<int,int> > v;
	v.pb(mp(0,0));
	for(int i=1;i<=n;i++){
		int x,y;
		cin>>x>>y;
		v.pb(mp(x,y));
	}
	int st = v[1].first;
	for(int i=1;i<=n;i++){
		int cw = v[i].first-st;
		int cv = v[i].second;
		for(int j=0;j<=100;j++){
			for(int k=0;k<=350;k++){
				dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][k]);
				dp[i][j+1][k+cw]=max(dp[i][j+1][k+cw],dp[i-1][j][k]+cv);
			}
		}
	}
	ll ans = -1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=3*n;j++){
			//cout<<i<<" "<<j<<" "<<dp[n][i][j]<<endl;
			if( i*st + j <= w && ans < dp[n][i][j]){
				ans = dp[n][i][j];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 42752
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_f)
b = gets.chomp.split.map(&:to_f)

def distance(a, b, p)
  return (a.zip(b).inject(0){|result, item| result + (item.inject(:-).abs)**p}) ** (1.0/p)
end

def chibishefu(a, b)
  return a.zip(b).map{|item| item.inject(:-).abs}.max
end

puts distance(a,b,1)
puts distance(a,b,2)
puts distance(a,b,3)
puts chibishefu(a,b)

Measured memory_bytes: 6192
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N, M = map(int, input().split())
    friend = [[] for _ in range(N + 1)]
    for _ in range(M):
        a,b = map(int, input().split())
        friend[a].append(b)
        friend[b].append(a)
    notchecked = set(list(range(1, N+1)))
    group = [0]*(N+1)
    nowgroup = 1
    while len(notchecked) > 0:
        now = collections.deque([notchecked.pop()])
        while len(now) > 0:
            d = now.popleft()
            group[d] = nowgroup
            notchecked.discard(d)
            for f in friend[d]:
                if f in notchecked:
                    group[f] = nowgroup
                    now.append(f)
                else:
                    continue
        nowgroup += 1
    countdic = {}
    for i in group:
        if i not in countdic:
            countdic[i] = 1
        else:
            countdic[i] += 1
    ans = max(countdic.values())
    print(ans)


if __name__ == '__main__':
    solve()

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

int main(){
  string S;
  cin >>  S;
  int total = 0;
  for(int i=0;i<S.size();i++){
    if(S.at(i) == 'o') total+=100;
  }
  cout << 700+total << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k,ans=-114514114514114514,c[5001],p[5001];
signed main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&p[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&c[i]);
		ans=max(ans,c[i]);
	}
	for(int i=1;i<=n;i++)
	{
		int sum=0,dis=0,j=i;
		do
		{
			sum+=c[j];
			j=p[j];
			dis++;
		}while(j!=i);
		int r=k>=2*dis?2*dis+k%dis:k;
		int base=((k-r)/dis)*max(sum,0ll);
		int add=-114514114514114514;
		sum=0;
		for(int l=1;l<=r;l++)
		{
			sum+=c[j];
			j=p[j];
			add=max(add,sum);
		}
		ans=max(ans,base+add);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	int N,M;
	cin>>N>>M;
	int sum = 0;
	if(N>0)
		sum += N*(N-1)/2;
	if(M>0)
		sum += M*(M-1)/2;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  rep(i, n){
    cin >> a[i];
    mp[a[i]]++;
  }
  ll sum=0;
  for(auto p: mp){
    ll mm=p.second;
    sum+=mm*(mm-1)/2;
  }
  rep(i, n){
    ll ans=sum;
    int m=mp[a[i]];
    ans-=m*(m-1)/2;
    m--;
    ans+=m*(m-1)/2;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 9788
#include <iostream>

using namespace std;

int n,k,rest,sol,cat;

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

    if (k==2)
    {
        cout << n-1;
        return 0;
    }

    cat=n/(k-1);
    rest=n%(k-1);
    sol=cat;
    if (rest>1)
    {
        ++sol;
    }

    cout <<sol;


    return 0;
}


Measured memory_bytes: 256
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1);n(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3),i=n(5);t.exports=function(t){var e=new r(t);i(e)}},function(t,e,n){"use strict";var r=n(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){for(var e=t.inr(),n=e.length,r=0,i=0;i<n;i++)e[i]!=e[n-1-i]&&r++;console.log(r/2)}}]);


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

int main(void) {
  int N;
  cin >> N;
  vector<int> a(N), b(N), c(N);
  int i = 0;
  for(; i < N; i++) cin >> a[i] >> b[i] >> c[i];
  for(i = 0; i < N; i++) {
    if(a[i] * a[i] == b[i] * b[i] + c[i] * c[i] || b[i] * b[i] == c[i] * c[i] + a[i] * a[i] || c[i] * c[i] == a[i] * a[i] + b[i] * b[i]) cout << "YES";
    else cout << "NO";
    cout << endl;
  }
}


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

import sys
import copy

sys.setrecursionlimit(1000000)


# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N = int(input())

AB = []

for i in range(N):
    AB.append(list(map(int, input().split())))

AB.sort(key=lambda x: x[1])


sumV = 0

for i in range(N):
    sumV += AB[i][0]
    if sumV > AB[i][1]:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 54224
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
l = [A[0]]

for Ai in A[1:]:
    l.append(Ai)
    l.append(Ai)
    
print(sum(l[:N-1]))

Measured memory_bytes: 122368
N, *A = map(int, open(0).read().split())
print(' '.join(list(map(str, A))))
for i in range(1, N):
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(' '.join(list(map(str, A))))


Measured memory_bytes: 5608