akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 20:51:04 2019

@author: Yamazaki Kenichi
"""

N = int(input())
mod = 10**9+7

res = [[0 for j in range(14)] for i in range(N+1)]
res[1][0],res[1][1],res[1][2],res[1][3] = 1,1,1,1


for i in range(2,N+1):
    res[i][0] = sum(res[i-1]) - (res[i-1][0]+res[i-1][6]+res[i-1][8]+res[i-1][9]
    )-res[i-1][2]-res[i-1][4]-res[i-1][11]-res[i-1][12]-res[i-1][13]
    res[i][1] = sum(res[i-1]) - (res[i-1][0]+res[i-1][6]+res[i-1][8]+res[i-1][9]
    )-res[i-1][4]-res[i-1][10]-res[i-1][11]-res[i-1][12]-res[i-1][13]
    res[i][2] = sum(res[i-1]) - (res[i-1][0]+res[i-1][6]+res[i-1][8]+res[i-1][9]
    )-res[i-1][4]-res[i-1][7]-res[i-1][12]-res[i-1][5]
    res[i][3] = sum(res[i-1]) - (res[i-1][0]+res[i-1][6]+res[i-1][8]+res[i-1][9]
    )-res[i-1][4]-res[i-1][12]
    res[i][4] = res[i-1][0]            +res[i-1][8]+res[i-1][9]
    res[i][5] = res[i-1][0]+res[i-1][6]
    res[i][6] = res[i-1][0]+res[i-1][6]+res[i-1][8]+res[i-1][9]
    res[i][7] = res[i-1][0]+res[i-1][6]+res[i-1][8]+res[i-1][9]
    res[i][8] = res[i-1][2]+res[i-1][11]+res[i-1][13]
    res[i][9] = res[i-1][4]+res[i-1][12]
    res[i][10] = res[i-1][4]+res[i-1][12]
    res[i][11] = res[i-1][4]+res[i-1][12]
    res[i][12] = res[i-1][6]
    res[i][13] = res[i-1][7]

print(sum(res[-1])%mod)

Measured memory_bytes: 3300
import itertools
import math
import fractions
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, d = map(int, input().split())


def func(n, c, d):
    x = n//c
    y = n//d
    z = n//((c * d) // fractions.gcd(c, d))
    zz = (x+y)-z
    return zz


tmp = b-func(b, c, d)
tmp2 = (a-1)-func(a-1, c, d)
print(tmp-tmp2)
#print('test', func(6, 2, 3))


Measured memory_bytes: 64108
N = int(input())
A = list(map(int, input().split()))

flg = 1
ans = 0
mini = float("inf")
for a in A:
  if a < 0:
    flg *= -1
  elif a == 0:
    flg = 0
  ans += abs(a)
  mini = min(abs(a),mini)

if flg == -1:
  ans -= 2* mini
print(ans)

Measured memory_bytes: 14412
fun main(args : Array<String>) {
    val s = readLine()!!

    if (s.length < 26) {
        for (c in 'a'..'z') {
            if (!s.contains(c)) {
                println("$s$c")
                return
            }
        }
    }

    val stocks = mutableListOf<Char>()
    for (i in 25 downTo 0) {
        val c = stocks.filter { it > s[i] }.min()
        if (c != null) {
            println("${s.take(i)}$c")
            return
        } else {
            stocks.add(s[i])
        }
    }

    println(-1)
}

Measured memory_bytes: 36688
#include <stdio.h>

int main(){
    int H,W;
    int i=0;
    int j=0;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0)
        break;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                printf("#");
            }
            printf("\n");
        }
       printf("\n");
    }
    return  0;
}

Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,x,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        x=(n/i);
        sum=sum+i*((x*(x+1))/2);
    }
    cout<<sum<<"\n";
}


Measured memory_bytes: 3624
from scipy.misc import comb


def solve(string):
    n, k = map(int, string.split())
    ans = []
    for i in range(1, k + 1):
        base = comb(n - k + 1, i, exact=True)
        var = comb(k - 1, i - 1, exact=True)
        ans.append(str(base * var % (10**9 + 7)))
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve(input()))


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

int main() {

  int N; cin >> N;
  vector<int> B(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> B.at(i);
  }
  int sum;
  sum = B.at(0);
  for (int i = 0; i < N - 2; i++) {
    sum += min(B.at(i), B.at(i + 1));
  }
  sum += B.at(N - 2);
  cout << sum << endl;

}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s;
int main() {
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,t,n;
  for(i=0;i<4;++i){
    cin>>t>>n;
    switch(t){
    case 1:
      cout<<n*6000<<endl;
      break;
    case 2:
      cout<<n*4000<<endl;
      break;
    case 3:
      cout<<n*3000<<endl;
      break;
    case 4:
      cout<<n*2000<<endl;
      break;
    }
  }
  return 0;
}

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

int M = 1e9, x[100005], p[100005], zp;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b, n, q, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
		if (x[i] >= 0 && !zp) zp = i;
	}
	if (!zp) zp = n + 1;
	for (int i = 2; i <= n; i++)
		p[i] = p[i - 1] + (x[i] - x[i - 1]);
	for (int i = 1; i <= n - k + 1; i++) {
		if (i >= zp) {
			M = min(M, p[i + k - 1] - p[i] + x[i]);
		} else if (i + k - 1 < zp) {
			M = min(M, p[i + k - 1] - p[i] - x[i + k - 1]);
		} else {
			M = min({M, -x[i] * 2 + p[i + k - 1] - p[zp] + x[zp], x[i + k - 1] * 2 - x[i]});
		}
	}
	cout << M << '\n';
}


Measured memory_bytes: 1792
n=int(input())
num=int(n**0.5)+1
mini=float('inf')
for k in range(1,num+1):
    i=k
    j=0
    if n%i==0:
        j=n//i

    if j!=0 and mini>=i+j-2:
        mini=i+j-2

print(mini)


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

using namespace std;

int main()
{
    int n, w;
    cin >> n >> w;
    long long wt[n + 1];
    int v[n];
    int maxv = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> wt[i] >> v[i];
        maxv = max(maxv, v[i]);
    }
    vector<vector<long long>> dp(n + 1, vector<long long>(n * maxv + 1, LLONG_MAX));
    for (int i = 0; i <= n; i++)
    {
        dp[i][0] = 0;
    }
    for (int i = 1; i <= n; i++)
    {
        //cout << "i " << i << "\n";
        for (int j = 0; j <= n * maxv; j++)
        {
            // cout << "j: " << j << "\n";
            if (dp[i - 1][j] != LLONG_MAX)
            {
                // cout << "in " << dp[i - 1][j] << "\n";
                dp[i][j] = min(dp[i - 1][j], dp[i][j]);
                if (j + v[i] <= n * maxv)
                {
                    dp[i][j + v[i]] = min(dp[i - 1][j] + wt[i], dp[i][j + v[i]]);
                    // cout << "in : " << dp[i][j + v[i]] << "\n";
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= n * maxv; i++)
    {
        //cout << i << " " << dp[n][i] << "\n";
        if (dp[n][i] <= w)
        {
            ans = i;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
int main(){
  string k; cin >> k;
  if(k[0]=='7'||k[1]=='7'||k[2]=='7') cout << yes;
  else cout << no;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define rmin(r, x) r = min(r, x);
#define rmax(r, x) r = max(r, x);
#define ends ' '
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int maxn = 2e5 + 10;

int n, m;
int p[maxn];

int fnd(int x) {
    if(p[x] < 0)    return x;
    return p[x] = fnd(p[x]);
}

void uni(int a, int b) {
    a = fnd(a), b = fnd(b);
    if(a == b)  return;
    p[a] += p[b];
    p[b] = a;
}

int main(void) {
    fastio;
    cin >> n >> m;
    memset(p, -1, sizeof(p));
    for(int i = 1; i <= m; ++i) {
        int a, b;   cin >> a >> b;
        uni(a, b);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i) rmax(ans, -p[fnd(i)]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 5276
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else: re += 1
print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int N;
string S;

// 1 : Sheep, 2 : Wolf, 0 : Unknown

bool dfs(vector<int> &ans, vector<int> &ret, int idx) {
    if (idx == N - 1) {
        if ((ret[idx] == 1 && S[idx] == 'o') || (ret[idx] == 2 && S[idx] == 'x')) {
            if (ret[idx - 1] == ret[0]) {
                ans = ret;
                return true;
            } else {
                return false;
            }
        } else if ((ret[idx] == 2 && S[idx] == 'o') || (ret[idx] == 1 && S[idx] == 'x')) {
            if (ret[idx - 1] != ret[0]) {
                ans = ret;
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }

    int p = (N + idx - 1) % N, n = idx + 1;
    if ((ret[idx] == 1 && S[idx] == 'o') || (ret[idx] == 2 && S[idx] == 'x')) {
        if (ret[p] && ret[n]) {
            if (ret[p] == ret[n]) return dfs(ans, ret, idx + 1);
            else return false;
        } else if (ret[p]) {
            ret[n] = ret[p];
            return dfs(ans, ret, idx + 1);
        } else if (ret[n]) {
            ret[p] = ret[n];
            return dfs(ans, ret, idx + 1);
        } else {
            vector<int> ret1 = ret, ret2 = ret;
            ret1[p] = ret1[n] = 1;
            ret2[p] = ret2[n] = 2;
            return dfs(ans, ret1, idx + 1) || dfs(ans, ret2, idx + 1);
        }
    } else if ((ret[idx] == 2 && S[idx] == 'o') || (ret[idx] == 1 && S[idx] == 'x')) {
        if (ret[p] && ret[n]) {
            if (ret[p] != ret[n]) return dfs(ans, ret, idx + 1);
            else return false;
        } else if (ret[p]) {
            ret[n] = ((ret[p] == 1) ? 2 : 1);
            return dfs(ans, ret, idx + 1);
        } else if (ret[n]) {
            ret[p] = ((ret[n] == 1) ? 2 : 1);
            return dfs(ans, ret, idx + 1);
        } else {
            vector<int> ret1 = ret, ret2 = ret;
            ret1[p] = ret2[n] = 1;
            ret2[p] = ret1[n] = 2;
            return dfs(ans, ret1, idx + 1) || dfs(ans, ret2, idx + 1);
        }
    } else {
        vector<int> ret1 = ret, ret2 = ret;
        ret1[idx] = 1; ret2[idx] = 2;
        return dfs(ans, ret1, idx) || dfs(ans, ret2, idx);
    }
}

int main() {
    cin >> N >> S;
    vector<int> ans, ret(N, 0);
    if (dfs(ans, ret, 0)) {
        for (auto a : ans) {
            if (a == 1) cout << 'S';
            else cout << 'W';
        }
        cout << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 23152
/* ~ Programmer >> Tushar Mahajan */
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL); 

int main() {
	ios;
    string s;
    string t;
    ll uncommon = 0;
    cin>>s;
    cin>>t;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        {
            uncommon++;
        }
    }
    cout<<uncommon<<endl;
	return 0;
}


Measured memory_bytes: 3776
#include <iostream>

using namespace std;
#define MOD 1000000007
#define MAX 1000000


long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int X,Y;
  cin >> X >> Y;
  bool flag=(X>Y);
  int n,m,k;
  n=(2*Y-X)/3;
  m=(2*X-Y)/3;
  k=(X+Y)/3;
  if((X+Y)%3 !=0 || n<0 || m<0){
    cout << 0;
    return 0;
  }


  COMinit();
  cout << COM(k,n);
}


Measured memory_bytes: 23808
import heapq

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

Q = []
heapq.heappush(Q, (-1*(A[0]+B[0]+C[0]), 0, 0, 0))
registered = set()
registered.add((0, 0, 0))
for _ in range(K):
    s, ai, bi, ci = heapq.heappop(Q)
    print(-s)

    if ai+1 < X and (ai+1, bi, ci) not in registered:
        heapq.heappush(Q, (-1*(A[ai+1]+B[bi]+C[ci]), ai+1, bi, ci))
        registered.add((ai+1, bi, ci))
    if bi+1 < Y and (ai, bi+1, ci) not in registered:
        heapq.heappush(Q, (-1*(A[ai]+B[bi+1]+C[ci]), ai, bi+1, ci))
        registered.add((ai, bi+1, ci))
    if ci+1 < Z and (ai, bi, ci+1) not in registered:
        heapq.heappush(Q, (-1*(A[ai]+B[bi]+C[ci+1]), ai, bi, ci+1))
        registered.add((ai, bi, ci+1))


Measured memory_bytes: 4976
/******* all required header files *******/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;

/*****All definitions*******/
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define mp make_pair
#define ll long long int
#define pb push_back
#define F first
#define S second
/***************************/

int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

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

    int n, k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
    {
        cin>>v[i];
    }
    sort(v.begin(), v.end(), greater<>());
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        if(v[i] >= k)
        {
            cnt++;
        }
            
        if(v[i] < k)
        {
            break;
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 640
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		
		long ans = 1;
		for (int i = 1; i <= n; i++) {
			ans = (ans * i) % 1000000007;
		}

		System.out.println(ans);
	}
}

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

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

    if(S[K-1] == 'A') {
        S[K-1] = 'a';
    }
    else if(S[K-1] == 'B') {
        S[K-1] = 'b';
    }
    else if(S[K-1] == 'C') {
        S[K-1] = 'c';
    }

    cout << S;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {


	ll s;

	cin >> s;


	int k = s / 500;
	int fv = (s - (500 * k)) / 5;

	cout << 1000 * k + fv * 5 << endl;
}




Measured memory_bytes: 888
// atcoder/cf16-final/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, m;
  while (cin >> n >> m) {
    vec<int> x(n);
    cin >> x;

    map<int, int> freq;
    each (i, x) ++freq[i];

    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    map<int, vec<int>> y;
    each (i, x) y[i % m].push_back(freq[i]);

    each (i, x) i %= m;
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());

    map<int, int> z;
    each (i, y) each (j, i.second) z[i.first] += j;

    int r = (z[0] / 2);
    z.erase(0);
    y.erase(0);
    if (m % 2 == 0) {
      r += (z[m / 2] / 2);
      z.erase(m / 2);
      y.erase(m / 2);
    }

    // cout << y << endl;
    // cout << z << endl;
    // cout << x << endl;

    each (_i, x) {
      if (_i == 0 || _i * 2 == m) continue;
      int i = _i;
      int j = m - _i;
      unless (z[i] < z[j]) swap(i, j);
      int p = (z[j] - z[i]) / 2;
      r += z[i];
      // cout << make_pair(i, j) << ", " << make_pair(z[i], z[j]) << ' ' << p << endl;
      z[j] -= z[i];
      z.erase(i);
      y.erase(i);
      each (k, y[j]) {
        int mn = min(p, k / 2);
        p -= mn;
        r += mn;
        z[j] -= mn * 2;
        k -= mn * 2;
      }
    }

    cout << r << endl;
  }

  return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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 ll MRINF = 5000000000000000;

int main() {

    ll N; cin >> N;
    vector<ll> A(N);
    REP(i, N)cin >> A[i];

    sort(A.rbegin(), A.rend());
    vector<ll> A_;
    REP(i, N){
        A_.push_back(A[i]);
        if(i!=0)A_.push_back(A[i]);
    }
    ll ans = 0;
    REP(i, N-1){
        ans += A_[i];
    }

    cout << ans << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 9016
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in [0]*n]
M=0
for i in range(2):
    for j in range(2):
        for k in range(2):
            t=sorted(l,key=lambda x:(-2*i+1)*x[0]+(-2*j+1)*x[1]+(-2*k+1)*x[2])[:m]
            M=max(M,abs(sum(x[0] for x in t))+abs(sum(x[1] for x in t))+abs(sum(x[2] for x in t)))
print(M)

Measured memory_bytes: 3316
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

char buffer[51];

bool IsPalindromic(const int32_t num) {
  snprintf(buffer, sizeof(buffer), "%d", num);
  const string str = string(buffer);
  const int32_t length = static_cast<int32_t>(str.length());
  int32_t start = 0;
  int32_t end = length - 1;
  bool is_palindromic = true;
  while (start < end) {
    if (str.c_str()[start] != str.c_str()[end]) {
      is_palindromic = false;
    }
    ++start;
    --end;
  }
  return is_palindromic;
}

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

  int32_t N;
  cin >> N;
  vector<int32_t> H(N);
  vector<int32_t> to_right(N, 0);
  for (int32_t i = 0; i < N; ++i) {
    cin >> H[i];
  }
  int32_t max_move = 0;
  for (int32_t i = N - 2; i >= 0; --i) {
    if (H[i] >= H[i + 1]) {
      to_right[i] = to_right[i + 1] + 1;
    } else {
      to_right[i] = 0;
    }
    if (to_right[i] > max_move) {
      max_move = to_right[i];
    }
  }
  cout << max_move << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
constexpr long long INF = 1LL << 60;
constexpr long long MOD = 1e9 + 7;

long long a[2020], cnt1[2020], cnt2[2020];

long long mod_pow(long long x, long long m) {
    long long ret = 1;
    while(m) {
        if(m&1) ret = ret*x%MOD;
        x = x*x%MOD;
        m >>= 1;
    }
    return ret;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    long long N, K; cin >> N >> K;
    for(int i = 0; i < N; ++i) cin >> a[i];

    long long ans = 0;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            if(i == j) continue;
            if(a[i] > a[j]) ++cnt1[i];
        }
    }

    for(int i = 0; i < N; ++i) {
        for(int j = i + 1; j < N; ++j) {
            if(a[i] > a[j]) ++cnt2[i];
        }
    }

    for(int i = 0; i < N; ++i) {
        ans = (ans + cnt2[i] * K % MOD + cnt1[i] * K % MOD * (K-1) % MOD * mod_pow(2, MOD-2) % MOD ) % MOD;
    }


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

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
 Scanner sc = new Scanner(System.in);
 int n=sc.nextInt();
 int i=1;
 do{
  int x=i;
  if(x%3==0){
   System.out.print(" "+i);
  }else{
   do{
    if(x%10==3){
     System.out.print(" "+i);
     break;
    }
    x/=10;
   }while(x!=0);
  }
 }while(++i<=n);
 System.out.println();
 }
}

Measured memory_bytes: 28584
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll ex = 0;
    while (n % i == 0) {
      n /= i;
      ex++;
    }
    ret.push_back(make_pair(i, ex));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  ll n;
  cin >> n;
  auto primes = my::primeFac(n);

  int ans = 0;
  for (auto &primesi : primes) {
    int exp = primesi.second;
    int i = 1;
    while (exp - i >= 0) {
      exp -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
N, M = map(int, input().split())


length = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
  length[i].insert(2,i)
length = sorted(length)
ans_list =[0]*M
count = 1
for i in range(M):
  if i == 0:
    ans = str(length[i][0]).zfill(6) + str(count).zfill(6)
    ans_list[i] = [length[i][2],ans]
  elif i >= 1 and length[i][0] == length[i-1][0]:
    count += 1
    ans = str(length[i][0]).zfill(6) + str(count).zfill(6)
    ans_list[i] = [length[i][2],ans]
  elif i >= 1 and length[i][0] != length[i-1][0]:
    count = 1
    ans = str(length[i][0]).zfill(6) + str(count).zfill(6)
    ans_list[i] = [length[i][2],ans]
ans_list.sort(key=lambda x: x[0])
for i in range(M):
  print(ans_list[i][1])


Measured memory_bytes: 45612
#include<bits/stdc++.h>
using namespace std ;
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define lli long long int
	#define ulli unsigned long long int
	#define ff first
	#define ss second
	#define mp make_pair
	#define pb push_back
	#define pf pop_front()
	#define lb lower_bound
	#define ub upper_bound
	#define bs binary_search
	#define rep(i,a,b) for(lli i=a;i<b;i++)
	#define repe(i,a,b) for(lli i=a;i<=b;i++)
  #define per(i,a,n) for (int i=n-1;i>=a;i--)
	#define all(v) v.begin(), v.end()
	#define mod 1000000007
	#define inf 100000000000000000
	#define lld long double
	#define pll pair<long long int,long long int>
	#define pii pair<int,int>
	#define vll vector<lli>
	#define vii vector<int>
	#define endl '\n'
	#define pie  acosl(-1.0);
	#define setp(k, x) fixed << setprecision(k) << (x)
	#define deb(x) cerr << #x << ": " << x << " " << endl;
	#define debug(x) cout << "m here-" <<#x<<" ..."<<"\n";
	#define printa(a,n) for(lli i=0;i<n;i++) cout<<a[i]<<" "; cout<<"\n";
  #define printv(a) for(lli i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<"\n";
	bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) //sort on basis of column //use- sort(vect.begin(), vect.end(),sortcol);
      { return v1[1] < v2[1]; }//[] o based indexing in column
	bool sortpair(const pair<lli, lli> &a, const pair<lli, lli> &b)
			{return a.second < b.second;}
	struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

//////////////////////////////////////////////////////////////////////////////////////////////
void solve();
//////////////////////////////////////////////////////////////////////////////////////////////


int main ()
{
	// fastio
 	// lli  t;
 	// cin>>t;
 	// while(t--)
 	{
	solve();

 	}
}
///////////////////////////////////////////
void solve()
{
	lli n,i,d,b,c,j,k;

  lli W;
	cin>>n>>W;
	lli a[n+1],w[n+1],tt=0;
	rep(i,1,n+1){
		cin>>w[i]>>a[i];
		tt+=a[i];

	}
//	cout<<tt<<endl;
	lli dp[tt+1];
	rep(i,1,tt+1)
	dp[i]=inf;

	dp[0]=0;
	rep(i,1,n+1)
	{
		per(j,a[i],tt+1)
		{
			dp[j]=min(dp[j],dp[j-a[i]]+w[i]);

		//	cout<<dp[j]<<" ";
		}
	//2	cout<<endl;
	}
	per(i,0,tt+1)




	{
		if(dp[i]<=W)
		{
			cout<<i<<endl;
			break;
		}
	}







}


Measured memory_bytes: 1024
# coding: utf-8
# Your code here!

while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    a=[int(input()) for _ in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))


Measured memory_bytes: 11704
program main
  implicit none
  
  integer ::i,j,n,h(100000)=0,k,he=0
  read(*,*)n
  read(*,*)(h(i),i= 1,n)
  
  do i = 1, n-1
    k = 0
    do j = i, n-1
      if (h(j) >= h(j+1)) then
        k = k + 1
      else
        exit
      end if
    end do
    if (k > he) then
      he = k
    end if
    if (he >= (n-i-1)) then
      exit
    end if
  end do
  
  write(*,'(i0)')he
end program main

Measured memory_bytes: 1152
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

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

N = getN()

dist = [[] for i in range(N)]
edges = {}
for i in range(N - 1):
    a, b = getNM()
    dist[a - 1].append(b - 1)
    dist[b - 1].append(a - 1)
    edges[(a - 1, b - 1)] = i
    edges[(b - 1, a - 1)] = i

color = [-1] * N
color[0] = 0
ans = [0] * (N - 1)
pos = deque([0])

while pos:
    u = pos.popleft()
    j = 1
    for i in dist[u]:
        if color[i] != -1:
            continue
        if j == color[u]:
            j += 1
        color[i] = j
        ans[edges[(i, u)]] = j
        pos.append(i)
        j += 1

print(max(ans))
for i in ans:
    print(i)

Measured memory_bytes: 125872
#include <bits/stdc++.h>
using namespace std;
 
int main() {

string a;
cin >> a;
  int n;
  n=a.size();
  int k;
  k=1;
  for(int i=0;i<n/2;i++)
  {if(a.at(i)!=a.at(n-1-i)){k=0;}}
for(int i=0;i<(n-1)/2/2;i++)
  {if(a.at(i)!=a.at((n-1)/2-1-i)){k=0;}}
  for(int i=(n+3)/2-1;i<n;i++)
  {if(a.at(i)!=a.at(n-1-i+(n+3)/2-1)){k=0;}}
if(k==0){cout<<"No"<<endl;}
      else{cout<<"Yes"<<endl;}
      }

Measured memory_bytes: 256
D=int(input())
C=list(map(int, input().split()))
S=[list(map(int,input().split())) for i in range(D)]

#T=[]
#for i in range(D):
#  T.append(int(input()))

#M=int(input())
#dq=[list(map(int,input().split())) for i in range(M)]

def dissat(day):
  dissat = 0
  for i in range(26):
    if T[day-1]-1 == i:
      continue
    dissat += C[i]*(day-lastdays[i])

  return dissat    
    
def last(day):
  lastdays[T[day-1]-1] = day

# 
def calcscore(D):
  sat = 0
  for i in range(D):
    # dayi
    last(i)
    sat += S[i][T[i]-1] - dissat(i+1)
  #print(sat)
  return sat

# main
#lastdays = [0]*26
#calcscore(D)


# change contenst
#for i in range(M):
#  T[dq[i][0]-1] = dq[i][1]
#  lastdays = [0]*26
#  calcscore(D)

#
import random
T = [0]*D
for i in range(D):
  T[i] = random.randrange(1,26)

lastdays = [0]*26
oldscore = calcscore(D)

count = 0
while count < 30:
  count += 1
  d=random.randrange(1,D)
  q=random.randrange(1,26)
  old = T[d-1] # 後で戻せるように元の値を記憶しておく
  T[d-1] = q
  lastdays = [0]*26
  if calcscore(D) < oldscore:
    T[d-1] = old

for i in range(D):
  print(T[i])

Measured memory_bytes: 84320
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String[]S= new String[N];
    ArrayList<String>c = new ArrayList<>();

    for(int i=0; i<N; i++){
    S[i] = sc.next();
    if(!c.contains(S[i])){
        c.add(S[i]);
    }
}
    if(c.size()==3){
		System.out.println("Three");
	}else{
        System.out.println("Four");
	}
}
}


Measured memory_bytes: 35588
#include<stdio.h>

int main(){
  int cards[4][13]={};
  int all,num;
  char mark;
  int i,j;

  scanf("%d",&all);
  for(i=0;i<all;i++){
    scanf(" %c%d",&mark,&num);
    if(mark=='S') cards[0][num-1]=1;
    if(mark=='H') cards[1][num-1]=1;
    if(mark=='C') cards[2][num-1]=1;
    if(mark=='D') cards[3][num-1]=1;
  }
  
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(i==0 && cards[i][j]==0) printf("S %d\n",j+1);
      if(i==1 && cards[i][j]==0) printf("H %d\n",j+1);
      if(i==2 && cards[i][j]==0) printf("C %d\n",j+1);
      if(i==3 && cards[i][j]==0) printf("D %d\n",j+1);
    }
  }
  return 0;
}

Measured memory_bytes: 1852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=2e5,M=1e9+7;
int dp[10][10];
int n;
long long resp;

int rm(int x){
    while(x>=10)x/=10;
    return x;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        dp[rm(i)][i%10]++;
    }
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            resp+=dp[i][j]*dp[j][i];
        }
    }
    cout<<resp;
}

Measured memory_bytes: 256
N,M,C = gets.chomp.split.map(&:to_i)
B = gets.chomp.split.map(&:to_i)

cnt = 0
N.times do
  a = gets.chomp.split.map(&:to_i)
  score = 0
  M.times do |i|
    score += B[i] * a[i]
  end
  cnt += 1 if score + C > 0 
end
puts cnt


Measured memory_bytes: 1916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] a = sc.IntArray();

        List<int> left = new List<int>();
        List<int> right = new List<int>();

        for (int i = 0; i < n; i++)
        {
            if (i % 2 == 0)
            {
                right.Add(a[i]);
            }
            else
            {
                left.Add(a[i]);
            }
        }

        string answer = "";
        if (a.Count() % 2 == 0)
        {
            left.Reverse();
            answer += string.Join(" ", left);
            if (left.Count > 0)
            {
                answer += " ";
            }
            answer += string.Join(" ", right);
        }
        else
        {
            right.Reverse();
            answer += string.Join(" ", right);
            if (right.Count > 0)
            {
                answer += " ";
            }
            answer += string.Join(" ", left);
        }



        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

int main(void) {
  string s;
  int a = 0, b = 0;

  cin >> s;

  for(int i = 0; i < s.length(); i++){
    if (s[i] == 'A'){
      a = i;
      break;
    }
  }

  for(int i = s.length() - 1; i >= 0; i--){
    if (s[i] == 'Z'){
      b = i;
      break;
    }
  }

  if (a < b) cout << (b - a + 1) << endl;

  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  char a;
  int c[26],i;
  //syokika
  for(i=0;i<26;i++){
    c[i]=0;
  }
  //
  while(scanf("%c",&a)!=EOF){

    if(a>='A'&&a<='Z')a+=32;

    if(a>='a'&&a<='z'){
      int num = a - 'a';
      c[num]++;
    }
  }
  for(i=0;i<26;i++){
    printf("%c : %d\n",i+'a',c[i]);
  }
  return 0;
}

Measured memory_bytes: 968
#include<iostream>
using namespace std;
int main(){
    int n,flug=1;
    cin >> n;
    int a[n];
    for(int i=0;i< n;i++)
        cin >> a[i];
    for(int i=0;i<n;i++){
        if(a[i]%2==0&&!(a[i]%3==0||a[i]%5==0)){
            flug=0;
            break;
        }
    }
    if(flug)cout << "APPROVED\n";
    else cout << "DENIED\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

char X[1001], Y[1001];
int a[1001][1001];
int n, m;


void Length(){
  int i, j;
  m = strlen(X);
  n = strlen(Y);
  
  for(i = 1; i <= m; i++){
    a[i][0] = 0;
  }

  for(j = 0; j <= n; j++){
    a[0][j] = 0;
  }
  
  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(X[i - 1] == Y[j - 1])
	a[i][j] = a[i - 1][j - 1] + 1;
      
      else if(a[i - 1][j] > a[i][j - 1])
	a[i][j] = a[i - 1][j];
      
      else a[i][j] = a[i][j - 1];
    }
  }
}

main(){
  int i, j;
  
  scanf("%d",&j);
  
  for(i = 0; i < j; i++){
    scanf("%s", X);
    scanf("%s", Y);
    Length();
    printf("%d\n", a[m][n]);
  }
  
  return 0;
}

Measured memory_bytes: 4516
// Example program
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int a[n];
    for (int i=0; i<n; i++) cin >> a[i];
    
    int dp[n];
    for (int i=0; i<n; i++) dp[i] = 1e9;
    
    dp[0] = 0;
    
    for (int i=0; i<n; i++) {
        dp[i + 1] = min(dp[i + 1], abs(a[i + 1] - a[i]) + dp[i]);
        dp[i + 2] = min(dp[i + 2], abs(a[i + 2] - a[i]) + dp[i]);
    }
    
    cout << dp[n - 1] << endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
  vector<ll>p(a), q(b), r(c);
  rep(i, a)cin>>p[i];
  rep(i, b)cin>>q[i];
  rep(i, c)cin>>r[i];

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.begin(), r.end());

  priority_queue<ll, vector<ll>, greater<ll>>pq1,pq2;
  rep(i, x)pq1.push(p[i]);
  rep(i, y)pq2.push(q[i]);

  priority_queue<ll>pq3;
  rep(i, c)pq3.push(r[i]);

  while(pq3.size() && ((pq1.size() && pq1.top()<=pq3.top()) || (pq2.size() && pq2.top() <=pq3.top())) ){
//cout<<pq3.top()<<' '<<pq2.top()<<' '<<pq1.top()<<endl;
    if(pq1.top() <= pq2.top()){
      pq1.pop();
      pq1.push(pq3.top());
      pq3.pop();
    }else{
      pq2.pop();
      pq2.push(pq3.top());
      pq3.pop();
    }
  }

  ll result=0;
  while(pq1.size()){
    result += pq1.top();
    pq1.pop();
  }

  while(pq2.size()){
    result += pq2.top();
    pq2.pop();
  }

  cout<<result<<endl;

  return 0;
}

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


int main() {
  int N; cin >> N;
  int a[N];
  int ans = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    if(a[i]%2==0){
      while(a[i]%2==0){
        a[i] /= 2;
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


bool seen[100];
void dfs(const vector<VE> &G, int v) {
	seen[v] = true;
	for (auto next_v : G[v]) {
		if (seen[next_v]) continue;
		dfs(G, next_v); // 再帰的に探索
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	VE a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i]; a[i]--; b[i]--;
	}
	int ans = 0;
	rep(i, m) {
		vector<VE>G(n);
		rep(j, m) {
			if (i != j) {
				G[a[j]].push_back(b[j]);
				G[b[j]].push_back(a[j]);
			}
		}
		// 全頂点が訪問済みになるまで探索
		int count = 0;
		rep(j, n)seen[j] = false;
		for (int v = 0; v < n; ++v) {
			if (seen[v]) continue; // v が探索済みだったらスルー
			dfs(G, v); // v が未探索なら v を始点とした DFS を行う
			++count;
		}
		if (count != 1)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	var sum, max int
	for i := 0; i < N; i++ {
		L := nextInt()
		sum += L
		max = MaxOf(max, L)
	}
	if max < sum-max {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


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

typedef struct node{
	struct node*oya,*ko[2];
	char key[30];
	int val,p;
}node;

void rot(node*v,int d){
	node*nnn=v->ko[d];
	
	v->ko[d]=nnn->ko[d^1];
	if(v->ko[d])v->ko[d]->oya=v;
	
	v->oya->ko[v->oya->ko[1]==v]=nnn;
	nnn->oya=v->oya;
	
	nnn->ko[d^1]=v;
	v->oya=nnn;  
}
void ins(node*v,node*oya,int dir,node*n){
	if(!v){
		n->oya=oya;
		oya->ko[dir]=n;
	}else{
		int d=strcmp(v->key,n->key)<0;
		ins(v->ko[d],v,d,n);
		if(v->ko[d]->p > v->p)rot(v,d);
	}
}
node*find(node*v,char*s){
	if(!v)return 0;
	int flag=strcmp(v->key,s);
	if(!flag)return v;
	return find(v->ko[flag<0],s);
}
void del(node*v){
	while(v){
		if(v->ko[0]){
			if(v->ko[1])rot(v,v->ko[1]->p > v->ko[0]->p);
			else rot(v,0);
		}else{
			if(v->ko[1])rot(v,1);
			else v=v->oya->ko[v->oya->ko[1]==v]=0;
		}
	}
}
void f(node*v,char*s,char*t){
	if(!v)return;
	if(strcmp(s,v->key)<0)f(v->ko[0],s,t);
	if(strcmp(s,v->key)<=0&&strcmp(v->key,t)<=0)printf("%s %d\n",v->key,v->val);
	if(strcmp(v->key,t)<0)f(v->ko[1],s,t);
}

node root;
int main(){
	int q;
	scanf("%d",&q);
	while(q--){
		int t;
		char s[30];
		scanf("%d%s",&t,s);
		if(t==0){
			int x;
			scanf("%d",&x);
			node*crr=find(root.ko[0],s);
			if(crr){
				crr->val=x;
			}else{
				node*v=calloc(1,sizeof(node));
				memcpy(v->key,s,20);
				v->val=x;
				v->p=rand();
				ins(root.ko[0],&root,0,v);
			}
		}else if(t==1){
			node*v=find(root.ko[0],s);
			printf("%d\n",v?v->val:0);
		}else if(t==2){
			del(find(root.ko[0],s));
		}else{
			char t[30];
			scanf("%s",t);
			f(root.ko[0],s,t);
		}
	}
}


Measured memory_bytes: 17316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    ll ans = (N - 1 + K - 1 - 1) / (K - 1);

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


Measured memory_bytes: 1024