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

int main() {
  int N,K,a,b,min=1;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
  	if((a=min*2)<(b=min+K)){
    	min = a;  
    }else{
    	min = b;
    }
  }
  
  cout << min << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x, t; cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << '\n';
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void){


    int i, j, k, array[5];
    for(i = 0; i < 5; i++){
        scanf("%d", &array[i]);
    }
    scanf("%d", &k);

    for(i = 4; i > 0; i--){
        for(j = i - 1; j >= 0; j--){
            if(array[i] - array[j] > k){
                printf(":(");
                return 0;
            }
        }

    }

    printf("Yay!");
    return 0;



}

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

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.size(); ++i){
        if(S[i] == '+'){
            ++ans;
        }else{
            --ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;


int main(){
    ll a;
    double b;
    cin>>a>>b;
    ll c=b*100+0.1;
    ll d=(a*c)/100;
    cout<<d<<endl;
    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	string s; cin >> s;
	string ans;
	if(s.size() == 1) { cout << s[0] - '0' << endl; return 0;}
	if(s[0] == '1'){
		if(s.size() == 1) { cout << 1 << endl; return 0;}
		else{
			bool all9 = true;
			for(int i = 1; i < s.size(); i++)	{
				if(s[i] != '9') all9 = false;
			}
			if(all9) ans = s;
			else {
				for(int i = 1; i < s.size(); i++) ans += '9';
			}
		}
	}
	else{
		bool all9 = true;
		for(int i = 1; i < s.size(); i++){
			if(s[i] != '9') all9 = false;
		}
		if(all9) ans = s;
		else{
			for(int i = 0; i < s.size(); i++){
				if(i == 0) ans += s[0] - 1;
				else ans += '9';
			}
		}
	}
	int cnt = 0;
	for(int i = 0; i < ans.size(); i++) {
		cnt += ans[i] - '0';
	}
	cout << cnt << endl;
	return 0;	
}

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

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
          
				var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var H = inputArray[0];
			var N = inputArray[1];

			var hissatsuArray = retreiveLongArray();

			if (hissatsuArray.Sum()>= H) {
				Console.WriteLine("Yes");

			}
			else {
				Console.WriteLine("No");

			}



		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 20960
import numpy as np
n, m, c = map(int, input().split())
B = np.array(list(map(int, input().split())))

count = 0
for i in range(n):
    A = np.array(list(map(int, input().split())))
    if np.sum(A * B) + c > 0:
        count += 1
print(count)

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

int main()
{
	std::set<long> s;
	long n, m;

	cin >> n;

	for (long i = 0; i < n; i++) {
		long t;
		cin >> t;
		s.insert(t);
	}

	cin >> m;

	for (long i = 0; i < m; i++) {
		long t;
		cin >> t;
		if (s.find(t) != s.end())
			s.erase(t);
		else
			s.insert(t);
	}

	for (std::set<long>::iterator itr = s.begin(); itr != s.end(); itr++)
		cout << *itr << endl;

	return 0;
}


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

int main(void){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans =max(a*c,max(a*d,max(b*c,b*d)));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
import java.io.*;

class Main {
    public static void main(String[] args)throws IOException{ 
    	InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader read = new BufferedReader(in);
    	   	                                                 
    	String str = read.readLine();
        String fixed = str;
        String fixeD;
        
        
        int item = Integer.parseInt(read.readLine());

        for(int count = 0; count < item; count++){
            String line = read.readLine();
            String [] spli = line.split(" ");          //???????????????

            if(spli [0].equals("print")){            	
            	fixeD = fixed.substring(Integer.parseInt(spli [1]), Integer.parseInt(spli [2])+1);         
                System.out.println(fixeD);            	
            } 
            else if(spli [0].equals("replace")){
                String left = fixed.substring(0, Integer.parseInt(spli [1]));
                String right = fixed.substring(Integer.parseInt(spli [2])+1, fixed.length());
                fixed = left + spli[3] + right;
            } 
            else{
                String part1 = fixed.substring(0, Integer.parseInt(spli [1]));
                String part2 = fixed.substring(Integer.parseInt(spli [2])+1, fixed.length());
                String reversing = fixed.substring(Integer.parseInt(spli [1]), Integer.parseInt(spli [2])+1);
                StringBuffer reversinG = new StringBuffer(reversing);
                reversinG.reverse();
                fixed = part1 + reversinG +part2; 
                
            }
        }
    }
}

Measured memory_bytes: 25092
# -*- coding: utf-8 -*-
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
#一度も取らなかったときを考えて0を代入しておく
asum,bsum=[0],[0]
#a,bの合計値の全パターンをリストに入れておく
for i in range(n):
  asum.append(asum[i]+a[i])
for i in range(m):
  bsum.append(bsum[i]+b[i])
#カウント数とbの冊数の最大値
ans,j=0,m
for i in range(n+1):
  if asum[i]>k:
    break
  while bsum[j]>k-asum[i]:
    j-=1
  ans=max(ans,i+j)
print(ans)  

Measured memory_bytes: 47592
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    X=LI()
    
    ans=10**10
    
    for i in range(1,101):
        temp=0
        for j in range(N):
            temp+=abs(i-X[j])**2
        ans=min(ans,temp)
        
    print(ans)
        

main()


Measured memory_bytes: 65100
#include<bits/stdc++.h>
using namespace std;
int GCD(int a,int b)
{
	if(b==0)
	{
		return a;
	}
	return GCD(b,a%b);
}
int LCN(int a,int b)
{
	return a*b/GCD(a,b);
}
int main()
{
	int n;
	scanf("%d",&n);
	printf("%d",LCN(2,n));
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
grid = [list(input()) for i in range(h)]

x = [-1, 0, 1]
y = [-1, 0, 1]
around = [(i, j) for i in y for j in x if i != 0 or j != 0]

for i in range(h):
    for j in range(w):
        if grid[i][j] == '#':
            continue
        cnt = 0
        for x, y in around:
            if 0 <= i + y <= h - 1 and 0 <= j + x <= w - 1 and grid[i + y][x + j] == '#':
                cnt += 1
        grid[i][j] = str(cnt)

for i in range(h):
    for j in range(w):
        print(grid[i][j], end='')
    print()


Measured memory_bytes: 3572
#include <string>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
 
using namespace std;

  
int main(){

	int cntData = 0;
	int vSum = 0;
	int nSum = 0;

	int v, n;

	while(~scanf("%d,%d", &v, &n)){
		cntData++;
		vSum += v*n;
		nSum += n;
	}

	int nAve;
	nAve = nSum*10;
	nAve /= cntData;
	if(nAve%10 > 4){
		nAve+=10;
	}
	nAve/=10;

	cout << vSum << endl;
	cout << nAve << endl;

	return 0;
}

Measured memory_bytes: 1204
n = int(input())
dict_par = dict()
for i in range(1,10):
    i = str(i)
    for k in range(1,10):
        k = str(k)
        dict_par[i+k] = 0
        for num in range(1, n+1):
            num = str(num)
            if (num[0] == i) & (num[-1] ==k):
                dict_par[i+k] +=1
ans = 0
for i in range(1,10):
    i = str(i)
    for k in range(1,10):
        k = str(k)
        ans+= dict_par[i+k] * dict_par[k+i]
print(ans)

Measured memory_bytes: 40812
#![allow(unused_macros, unused_imports, dead_code)]

use std::io;
use std::process;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! read {
    ($($t:ty),+) => {
        {
            let line = read_line();
            let mut it = line.trim().split_whitespace();
            let result = (
                $(it.next().unwrap().parse::<$t>().unwrap(),)+
            );
            assert!(it.next().is_none());
            result
        }
    };
}

fn read_vec() -> Vec<i64> {
    let line = read_line();
    let it = line.trim().split_whitespace();
    it.map(|s| s.parse().unwrap()).collect()
}

fn dist((x, y): (i32, i32), (z, w): (i32, i32)) -> i32 {
    (z - x).abs() + (w - y).abs()
}

fn main() {
    let (N,) = read!(usize);
    let (mut s, mut z, mut w) = (0, 0, 0);
    for _ in 0..N {
        let (t, x, y) = read!(i32, i32, i32);
        let (dt, d) = (t - s, dist((x, y), (z, w)));
        if dt < d || (d - dt) % 2 != 0 {
            println!("No");
            process::exit(0);
        }
        s = t;
        z = x;
        w = y;
    }

    println!("Yes");    
}

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unicode/utf8"
)

func lib_CopyBool(values []bool) []bool {
	dst := make([]bool, len(values))
	copy(dst, values)
	return dst
}
func lib_IntToBits(value int, minDigits int) (bits []bool) {
	bin := fmt.Sprintf("%b", int(value))
	digits := utf8.RuneCountInString(bin)
	for _, b := range bin {
		bits = append(bits, b == '1')
	}
	remainBitNums := lib_TernaryOPInt(minDigits > digits, minDigits-digits, 0)
	return append(lib_ReverseBool(bits), make([]bool, remainBitNums)...)
}
func lib_JoinInt(values []int, sep string) string {
	if len(values) == 0 {
		return ""
	}
	var sb strings.Builder
	for i := 0; i < len(values)-1; i++ {
		sb.WriteString(fmt.Sprint(values[i]))
		sb.WriteString(sep)
	}
	sb.WriteString(fmt.Sprint(values[len(values)-1]))
	return sb.String()
}
func lib_PowInt(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}
func lib_ReverseBool(values []bool) []bool {
	newValues := lib_CopyBool(values)
	for i, j := 0, len(values)-1; i < j; i, j = i+1, j-1 {
		newValues[i], newValues[j] = values[j], values[i]
	}
	return newValues
}
func lib_TernaryOPInt(ok bool, v1, v2 int) int {
	if ok {
		return v1
	}
	return v2
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	a := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
	}
	fmt.Println(solve(N, a))
}
func solve(N int, a []int) string {
	var bitsList [][]bool
	for _, ai := range a {
		bitsList = append(bitsList, lib_IntToBits(ai, 30))
	}
	var bits []bool
	for i := 0; i < 30; i++ {
		bitCount := 0
		for n := 0; n < N; n++ {
			if bitsList[n][i] {
				bitCount++
			}
		}
		bits = append(bits, bitCount%2 == 0)
	}
	var answers []int
	for n := 0; n < N; n++ {
		answer := 0
		for i := 0; i < 30; i++ {
			if bits[i] == bitsList[n][i] {
				answer += lib_PowInt(2, i)
			}
		}
		answers = append(answers, answer)
	}
	return lib_JoinInt(answers, " ")
}


Measured memory_bytes: 41724
#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 yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int x;
	cin>>x;
	if(x==7){
		cout<<"YES"<<endl;
	}else if(x==5){
		cout<<"YES"<<endl;
	}else if(x==3){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  stack<char> q;
  for(int i=0;i<s.length();i++)
  {
     if(s[i]=='0' || s[i]=='1')
       q.push(s[i]);
     else if(!q.empty() && s[i]=='B')
       q.pop();
  }string k;
   while (!q.empty()) 
    { 
       k+=q.top();
     q.pop();
    } 
  reverse(k.begin(),k.end());
  cout<<k;
  return 0;
    
}

Measured memory_bytes: 3620
//codeforces
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
#include <set>
#include <map>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<bitset>
#include <climits>
#include<tr1/unordered_set>
#include<tr1/unordered_map>


#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1e9+7;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

using namespace std;

class TrieNode{
    public:
    bool isword;
    char c;
    map<char,TrieNode*> m;
    string word;
    public:
    TrieNode(){}
    TrieNode(char ch){
        c=ch;
        isword=false;
    }
};

void insert(TrieNode* root,string word){
    TrieNode* temp=root;
    for(char c:word){
        if(temp->m.find(c)==temp->m.end())
            temp->m[c]=new TrieNode(c);
        temp=temp->m[c];
    }
    temp->isword=true;
    temp->word=word;
}

#pragma GCC optimize ("Ofast")
static auto _ = [] { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); std::cerr.tie(0); return 0; } ();

int main() {
    int n;
    cin>>n;
    vector<int> dp(3,0),ndp(3);
    vector<int> v(3);
    for(int i=0;i<n;i++){
        for(int i=0;i<3;i++)
            cin>>v[i];
        ndp[0]=max(dp[1],dp[2])+v[0];
        ndp[1]=max(dp[0],dp[2])+v[1];
        ndp[2]=max(dp[1],dp[0])+v[2];
        dp=ndp;
    }

    cout<<*max_element(dp.begin(),dp.end());
    return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <algorithm>
#define il inline
#define rgi register int
#define sp putchar(32)
#define el putchar(10)
#define is_digit(o4) (o4>47&&o4<58)
using namespace std;
il int ri()
{
	register int o1=0;
	register char o3=getchar();
	while(!is_digit(o3))
		o3=getchar();
	while(is_digit(o3))
		o1=(o1<<1)+(o1<<3)+(o3^48),o3=getchar();
	return o1;
}
il void wi(rgi o1)
{
	rgi o2=o1/10;
	if(o2)
		wi(o2);
	putchar((o1-(o2<<1)-(o2<<3))^48);
}
int n,a[2005],book[1005],s[1005],ans;
signed main()
{
	n=ri();
	for(rgi i=1;i<=n;++i)
		a[i]=ri(),++book[a[i]];
	for(rgi i=1;i<=1000;++i)
		s[i]=s[i-1]+book[i];
	sort(a+1,a+n+1);
	for(rgi i=1;i<=n;++i)
		for(rgi j=i+1;j<=n;++j)
		{
			int k=upper_bound(a+j+1,a+n+1,a[i]+a[j]-1)-a-1;
			ans+=k-j;
		}
	wi(ans);
	return 0;
}


Measured memory_bytes: 128
int main(){
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    puts(x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
    using namespace std;
    # define LL long long
    # define int long long
    #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    # define mo 998244353
    # define pi acos(-1)
    //vector<pair<int,int>> v;
    //int x0=INT_MAX,y0=INT_MAX;
    /*int crossprod(pair<int,int> a,pair<int,int> b,pair<int,int> c)
    {
        int x1 = a.first-b.first;
        int x2 = a.first-c.first;
        int y1 = a.second-b.second;
        int y2 = a.second-c.second;
        return x1*y2 - y1*x2;
    }
    int direction(pair<int,int> a,pair<int,int> b,pair<int,int> c) {
       int val = (b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y);
       if (val == 0)
          return 0;     //colinear
       else if(val < 0)
          return 2;    //anti-clockwise direction
          return 1;    //clockwise direction
    }*/

signed main()
{

   gok

 int k,n;
 cin>>k>>n;
 int a[n];
 for(int i=0;i<n;i++)
    cin>>a[i];
 int ma=0;
 for(int i=1;i<n;i++)
    ma = max(ma,a[i]-a[i-1]);
 ma = max(ma,a[0]+k-a[n-1]);
cout<<k-ma;























	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define mod 1000000007
int main() { 
    int k;
    cin >> k;
    if (k % 7 == 0) k /= 7;
    if ((k % 5 == 0)||(k % 2 == 0)) cout << -1 << endl;
    else {
        ll n = 1;
        int count = 1;
        while (n % k) {
            n = n % k;
            count++;
            n = n * 10 + 1;
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import java.lang.Math.abs
import java.lang.Math.min

fun main(args: Array<String>) = ABC160D2.main()

object ABC160D2 {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    val N: Int
    val X: Int
    val Y: Int

    init {
        val (n, x, y) = readInts()
        N = n
        X = x
        Y = y
    }

    fun main() {
        val combinations = (1..N).combination(2)
            .map { it.first() to it.last() }
        val distances = combinations.map { minDist(it.first, it.second) }

        // k -> count
        val distCounts = distances.toList().bucketCount()
        (1..N - 1).forEach { k ->
            val ans = distCounts[k] ?: 0
            println(ans)
        }
    }

    fun minDist(i: Int, j: Int): Int {
        val choice1 = abs(i - j)
        val choice2 = abs(i - X) + 1 + abs(Y - j)
        val choice3 = abs(i - Y) + 1 + abs(X - j)
        return min(choice1, min(choice2, choice3))
    }

    /*####################################################################################*/

    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }

    fun <T> List<T>.bucketCount(): Map<T, Int> {
        val bucket = hashMapOf<T, Int>()
        this.forEach {
            val current = bucket[it] ?: 0
            bucket[it] = current + 1
        }
        return bucket
    }

    fun IntRange.combination(k: Int): Sequence<List<Int>> = this.toList().combination(k)
    fun <T> List<T>.combination(k: Int): Sequence<List<T>> = Combination<T>().generate(this, k)
    class Combination<T> : BasicCombinator<T>() {
        override fun List<T>.chooseRemains(i: Int): List<T> = this.drop(i + 1)
    }

    abstract class BasicCombinator<T> {
        abstract fun List<T>.chooseRemains(i: Int): List<T>

        fun generate(items: List<T>, k: Int): Sequence<List<T>> {
            when {
                (k < 0) ->
                    throw IllegalArgumentException()
                (k == 0) ->
                    return emptySequence()
                (k == 1) ->
                    return items.asSequence().map { listOf(it) }
                else ->
                    return items.asSequence().mapIndexed { index, first ->
                        val remains = items.chooseRemains(index)
                        generate(remains, k - 1).map { first + it }
                    }.flatten()
            }
        }

        private operator fun T.plus(other: List<T>): List<T> {
            val list = mutableListOf(this)
            list.addAll(other)
            return list
        }
    }
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#define INF numeric_limits<int>::infinity()
#pragma endregion


int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    string turn = "a";

    while(true) {
        if (turn=="a") {
            if (a.length()==0) {
                P("A");
                return 0;
            }
            turn = a[0];
            a.erase(a.begin()+0);
        }
        else if (turn=="b") {
            if (b.length()==0) {
                P("B");
                return 0;
            }
            turn = b[0];
            b.erase(b.begin());
        }
        else {
            if (c.length()==0) {
                P("C");
                return 0;
            }
            turn = c[0];
            c.erase(c.begin());
        }
    }
    return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    if A[i] < B[i]:
        ans += A[i]
        if A[i+1] >= (B[i] - A[i]):
            A[i+1] -= B[i] - A[i]
            ans += B[i] - A[i]
        else:
            ans += A[i+1]
            A[i+1] = 0
print(ans)


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

int main() {
  int N,K; // N:回数, K：足す値
  cin >> N >> K; 
  
  int value = 1;
  for (int i=0; i<N; i++) {
  	if (value*2 <= value+K) {
    	value *= 2;
  	} else {
    	value += K;
    }
  }
  cout << value << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		for (;;) {
			int H = sc.nextInt();
			if (H == 0) {
				return;
			}
			int[][] input = new int[5][H];
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < 5; j++) {
					input[j][i] = sc.nextInt();
				}
			}
			@SuppressWarnings("unchecked")
			ArrayList<Integer>[] list = new ArrayList[5];
			for (int i = 0; i < 5; i++) {
				list[i] = new ArrayList<Integer>();
			}
			for (int i = 0; i < 5; i++) {
				for (int j = 0; j < H; j++) {
					list[i].add(input[i][H - 1 - j]);
				}
			}
			int score = 0;
			boolean go = true;
			while (go) {
				go = false;
				for (int i = H; i >= 0; i--) {
					for (int j = 0; j < 5; j++) {
						int start = j;
						int cnt = 0;
						while (j + 1 < 5 && list[j].size() > i
								&& list[j + 1].size() > i
								&& list[j].get(i) == list[j + 1].get(i)) {
							j++;
							cnt++;
						}
						if (cnt >= 2) {
							int add = list[start].get(i) * (cnt + 1);
							score += add;
							for (int k = start; k <= start + cnt; k++) {
								list[k].remove(i);
							}
							go = true;
						}
					}
				}
			}
			System.out.println(score);
		}

	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] A = Console.ReadLine().Split(' ');
            int A1, A2, A3;

            A1 = int.Parse(A[0]);
            A2 = int.Parse(A[1]);
            A3 = int.Parse(A[2]);

            if (A1 + A2 + A3 >= 22) {
                Console.WriteLine("bust");
            } else {
                Console.WriteLine("win");
            }

        }
    }
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    ll a,b;
    cin >> a >> b;
    if(a>=1){
        cout << "Positive" << endl;
    }else{
        if(b>=0){
            cout << "Zero" << endl;
        }else{
            if(abs(a+b)%2==0){
                cout << "Negative" << endl;
            }else{
                cout << "Positive" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> 
#include <vector>     

#define INF 1000000000
using namespace::std;




long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

bool c;
int N,C,H, M,K,W,a[10],ltl[26],g,k;
string S,s;

int main() {
	cin >> N;
	W = 1;
	K = 1;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		W = W * 3;
		if (a[i] % 2 == 1) {
			k++;
		}
		else {
			g++;
			K = K * 2;
		}
	}

	
cout <<W-K<<endl;
	return 0;
}




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

int main() {
  string s;
  cin>>s;
  if(s.at(0)=='S') cout<<"Cloudy"<<endl;
  else if(s.at(0)=='C') cout<<"Rainy"<<endl;
  else cout<<"Sunny"<<endl;
  return 0;
}


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

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> d;

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

        if (s[i-1] != s[i])
            d.emplace_back(i+1);
        if (i == n-1)  
            d.emplace_back(i+2);
    }
    
    int m = d.size();
    if (m < k*2+1) {
        cout << n << endl; 
        return 0;
    }
    
    int ans = 0;
    int tmp = 0;

    for(int i = 0; i < m - k*2; i++)
    {
        if ((s[d[i]-1]=='1') && (i+k*2+1 < m))
            tmp = d[i+k*2+1] - d[i];
        else 
            tmp = d[i+k*2] - d[i];
        
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    bool jud = true;
    if(x < r) jud = false;
    if(y < r) jud = false;
    if(w - x < r) jud = false;
    if(h - y < r) jud = false;
    if(jud) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {
    int N;
    int sum = 0;
    cin >> N;
    
    for(int i = N; i > 0 ; i /= 10){
        sum += i % 10;
    }
    
    if(N % sum == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

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

	if (a < b){
		cout << "a < b";
	}else if(a == b){
		cout << "a == b";
	}else{
		cout << "a > b";
	}

	cout << endl;
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i = 0; i < N; i++) cin >> p[i];
  sort(p.begin(),p.end());
  int ans = 0;
  for(int i = 0; i < K; i++) ans += p[i];
  cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  if(N==1){
    cout << "Hello World" << "\n";
  }else{
    int A,B;
    cin >> A >> B;
    cout << A+B << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
open Scanf
open Printf

let flip f x y = f y x

let range a b =
  let rec f acc a b = if a > b then acc else f (b::acc) a (b-1) in
  f [] a (b-1)

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = Array.init n (fun _ -> read_int ())

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)
let rec for_some_iter a b f = if a >= b then false else f a || for_some_iter (a+1) b f
let rec for_all_iter a b f = if a >= b then true else f a && for_all_iter (a+1) b f

let inf = 20202020202020

let () =
  let n = read_int () in
  let mtx = Array.init n (fun _ -> read_ints n) in

  let mtx' = Array.init n (fun i -> Array.copy mtx.(i)) in
  for_iter_ 0 n (fun k -> for_iter_ 0 n (fun i -> for_iter_ 0 n (fun j ->
    mtx'.(i).(j) <- min mtx'.(i).(j) (mtx'.(i).(k) + mtx'.(k).(j)))));

  let valid = for_all_iter 0 n (fun i ->
    for_all_iter 0 n (fun j ->
      mtx.(i).(j) = mtx'.(i).(j))) in
  if not valid then (print_endline "-1"; exit 0);

  let edges =
    let res = Array.make (n*(n-1)/2) (-1,-1,-1) in
    let rec f i a b =
      if a >= n then ()
      else if b >= n then f i (a+1) (a+2)
      else (res.(i) <- (a, b, mtx.(a).(b)); f (i+1) a (b+1)) in
    f 0 0 1;
    Array.stable_sort (fun (_,_,w0) (_,_,w1) -> w0-w1) res;
    res in

  Array.map (fun (u, v, w) ->
    let flag = for_some_iter 0 n (fun i ->
      i <> u && i <> v && mtx.(u).(i) + mtx.(i).(v) = mtx.(u).(v)) in
    if flag then 0 else w) edges
  |> Array.fold_left (+) 0
  |> printf "%d\n"


Measured memory_bytes: 7040
N = int(input())
S = input()
left = 0
right = 0
score = 0
for i in range(len(S)):
    if(S[i] is "("):
        if(score < 0):
            left -= score
            score = 1
        else:
            score += 1
    else:
        score -= 1

if(score < 0):
    left -= score
else:
    right += score

for i in range(left):
    S = "(" + S
for i in range(right):
    S = S + ")"
print(S)


Measured memory_bytes: 3064
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , k ;
    cin >> n >> k ;
    int R , P , S ; 
    cin >> R >> S >> P ;
    string t;
    cin >> t ;
    string first = "" ;
    int ans = 0 ;
    for(int i = 0; i < k; i++){
        if ( t[i] == 'r' ) {
            first.push_back('p');
            ans += P ;
        }
        else if ( t[i] == 's' ) {
            first.push_back('r') ;
            ans += R ;
        }
        else if ( t[i] == 'p' ){
            first.push_back('s') ;
            ans += S ;
        }
    }
    debug() << imie(ans) ;
    for(int i = k; i < n; i++){
        if ( t[i] == 'r' ) {
            if ( first[i - k] != 'p' ) {
                first.push_back('p');
                ans += P ;
            }
            else{
                first.push_back('?');
            }
        }
        else if ( t[i] == 's' ) {
            if ( first[i - k] != 'r' ) {
                first.push_back('r');
                ans += R ;
            }
            else{
                first.push_back('?');
            }
        }
        else if ( t[i] == 'p' ){
            if ( first[i - k] != 's' ) {
                first.push_back('s');
                ans += S ;
            }
            else{
                first.push_back('?');
            }
        }
    }
    debug() << imie(first) ;
    cout << ans << endl ;
    return 0; 
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, W; cin >> n >> W;
  vll w(n), v(n);
  REP(i, n) {
    cin >> w[i] >> v[i];
  }

  vector<map<int, ll>> dp(n);
  dp[0][w[0]] = v[0];
  REP(i, n-1) {
    MFOR(j, dp[i]) {
      dp[i+1][j->first] = max(dp[i+1][j->first], j->second);
      if(j->first + w[i+1] <= W) dp[i+1][j->first + w[i+1]] = max(dp[i+1][j->first + w[i+1]], j->second + v[i+1]);
    }
    dp[i+1][w[i+1]] = max(dp[i+1][w[i+1]], v[i+1]);
  }

  ll ma = 0;
  MFOR(j, dp[n-1]) {
    if(j->first > W) break;
    ma = max(ma, j->second);
  }
  cout << ma << endl;
}


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

int main(void){
    ll n,k; cin >> n >> k;
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll tmp; cin >> tmp;
        if(k <=tmp) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<int> w(n+2, 0), e(n+2, 0);
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'W') w[i]++;
    else if(s[i] == 'E') e[i+2]++;
  }
  for(int i = n; i >= 1; i--) w[i] += w[i+1];
  for(int i = 1; i <= n; i++) e[i] += e[i-1];
  int maxseen = 0;
  for(int i = 1; i <= n; i++) maxseen = max(maxseen, w[i]+e[i]);
  cout << n-maxseen-1 << endl;
  
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> P;
#define MOD 1000000007
#define INF 1000000000
#define int long long
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int modpow(int a,int b){
    if(!b)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int fac(int a){
    int Ans=1;
    for(int i=1;i<=a;i++){
        Ans*=i;
        Ans%=MOD;
    }
    return Ans;
}//kaijo
int comb(int a,int b){
    return fac(a)*modpow(fac(a-b),MOD-2)%MOD*modpow(fac(b),MOD-2)%MOD;
}
int n,k;
int a[114514];
signed main(){
	cin>>n>>k;
	int mem;
	rep(i,n)cin>>a[i];
	if(n==2)cout<<n-1<<endl;
    else cout<<(n+k-3)/(k-1)<<endl;
	return 0;
}


Measured memory_bytes: 1024
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #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> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  int n;
  cin >> n;
  int ans = 0;
  forn(i,n) {
    int a;
    cin >> a;
    while (a % 2 == 0){
      a /= 2;
      ans++;
    }
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 


*/

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


int A[100000+7];

int main() {

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

    for(int i=1;i<=n;i++) cin >> A[i];

    int mx=INT_MAX;

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

        if(A[i+k-1]<0) mx=min(mx,-A[i]);
        if(A[i]>0)     mx=min(mx,A[i+k-1]);
        if(A[i]<=0&&A[i+k-1]>=0) mx=min(mx,min(-A[i],A[i+k-1])+A[i+k-1]-A[i]);
    }

    cout << mx << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;

bool is_kaibun(string s){
  string t(s.rbegin(),s.rend());
  return s == t;
}

int main(){
  string s;
  cin >> s;
  int n = s.size();
  if( is_kaibun(s) && is_kaibun(s.substr(0,(n-1)/2)) && is_kaibun(s.substr((n+1)/2)))cout << "Yes" << endl;
  else cout << "No" << endl;
 return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;
const int N = 1E5 + 10;

int n;
int ans;

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n ; i ++)
    {
        int x;
        scanf("%d", &x);
        ans ^= x;
    }
    if(ans == 0) puts("Yes");
    else         puts("No");
    
    return 0;
}


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

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

	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < s.size(); j++) {
			string tmp = s.substr(i, s.size() - j);
			bool flag = true;
			for (int tmpI = 0; tmpI < tmp.size(); tmpI++) {
				if (tmp[tmpI] != 'A' && tmp[tmpI] != 'C' && tmp[tmpI] != 'G' && tmp[tmpI] != 'T') {
					flag = false;
				}
			}
			if (flag) {
				if (tmp.size() > ans) {
					ans = tmp.size();
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	char buf[400];
	int checkTable[14],tmp,sum;

	while(true){
		fgets(buf,400,stdin);
		if(buf[0] == '0')break;

		for(int i= 1; i <= 13; i++){
			checkTable[i] = 0;
		}

		sum = tmp = 0;
		for(int i=0; buf[i] != '\n' && buf[i] != '\0'; i++){
			if(buf[i] >= '0' && buf[i] <= '9'){
				tmp = 10*tmp + (buf[i] - '0');

				if(buf[i+1] == '\n' || buf[i] == '\0'){
					checkTable[tmp]++;
				}
			}else{
				checkTable[tmp]++;
				tmp = 0;
			}
		}

		for(int i=10; i <= 13; i++)sum += 10*checkTable[i];
		for(int i= 9; i >= 2; i--)sum += i*checkTable[i];

		if(sum > 21)printf("0\n");
		else{
			if(checkTable[1] == 0)printf("%d\n",sum);
			else{
				if(sum + checkTable[1] > 21){
					printf("0\n");
				}else if(sum >= 11){
					printf("%d\n",sum+checkTable[1]);
				}else{
					int zero,one;

					zero = sum + checkTable[1];
					one = sum + 11 + checkTable[1]-1;
					if(one > 21)one = 0;

					sum = max(zero,one);

					printf("%d\n",sum);
				}
			}
		}
	}

    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll n, k;

    cin >> n >> k;

    ///deque<ll> dq(n + 1, 1);
    ///deque<ll> p(n + 1, 1);
    deque<ll> dq = {0};
    deque<ll> p = {0};

    for(ll i = 1; i <= n; i++)
    {
        ll inp;

        cin >> inp;

        dq.push_back(inp);
        p.push_back(p.back() + dq.back());
    }

    for(ll i = k + 1; i <= n; i++)
    {
        //cout << "   " << p[i - 1] / p[i - k - 1] << " " << p[i] / p[i - k] << endl;

        if(p[i] - p[i - k] > p[i - 1] - p[i - k - 1])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

	return 0;
}



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

int main() {
	int n ;
	cin >> n ;
	pair<int,int> a[n] ;
	for(int i = 0 ; i < n ; i++){ cin >> a[i].first ;
	a[i].second = i ;}
	sort(a,a+n) ;
	int max = a[n-1].second ;
	for(int i = 0 ; i < n ; i++){
		if(i == max){
			cout << a[n-2].first << '\n' ;
		}else{
			cout << a[n-1].first << '\n';
		}
	}
	return 0;
}

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

using namespace std;
int main(){
	int n,m,i,j,k;
	bool f1,f = true;
	char s[52][52];
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin >> s[i][j];
		}
	}
	for(i=1;i<=n&&f==true;i++){
		for(j=1;j<=m&&f==true;j++){
			if(s[i][j]=='#'){
				f1 = false;
				if(s[i - 1][j]=='#')f1=true;
				if(s[i][j - 1]=='#')f1=true;
				if(s[i][j + 1]=='#')f1=true;
				if(s[i + 1][j]=='#')f1 = true;
				if(f1==false)f = false;
			}	
		}
	}
	if(f==true)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256