akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

// RDLU
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

struct Elem {
    int row, col, dir, cost;
    Elem(int r, int c, int d, int co) : row(r), col(c), dir(d), cost(co) {}
    bool operator<(const Elem &e) const {
        return cost > e.cost;
    };
};

int dist[35][35][4];
int solve_testcase() {
    int W, H; scanf("%d%d", &W, &H);
    if(H == 0 and W == 0) return 1;

    vector< vector<int> > board(H, vector<int>(W));
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            scanf("%d", &board[i][j]);
        }
    }

    vector<int> C(4);
    for(int i=0; i<4; i++) scanf("%d", &C[i]);

    fill(dist[0][0], dist[H][0], INF);
    priority_queue<Elem> que;
    que.emplace(0, 0, 0, 0);
    dist[0][0][0] = 0;
    while(que.size()) {
        Elem e = que.top(); que.pop();
        int r = e.row, c = e.col, d = e.dir, cost = e.cost;
        for(int i=0; i<4; i++) {
            int nr = r + dx[i], nc = c + dy[i], nd = i;
            if(nr < 0 or nr >= H or nc < 0 or nc >= W) continue;

            int ncost = cost;
            int dd = (nd - d + 4) % 4;
            if(board[r][c] != dd) ncost += C[dd];
            if(dist[nr][nc][nd] > ncost) {
                dist[nr][nc][nd] = ncost;
                que.emplace(nr, nc, nd, ncost);
            }
        }
    }

    int ans = INF;
    for(int i=0; i<4; i++) chmin(ans, dist[H-1][W-1][i]);
    printf("%d\n", ans);
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



Measured memory_bytes: 3260
H = int(input())
A = list(map(int, input().split()))

def MaxHeapify(a, i):
    li, ri = 2*i+1, 2*i+2
    if li < H and a[li] > a[i]:
        largest = li
    else:
        largest  = i
        
    if ri < H and a[ri] > a[largest]:
        largest = ri
        
    if a[largest] > a[i]:
        a[i], a[largest] = a[largest], a[i]
        MaxHeapify(a, largest)

def BuildMaxHeap(a):
    for i in range(H//2, -1, -1):
        MaxHeapify(a, i)
        
BuildMaxHeap(A)

print(' ', end='')
print(*A)

Measured memory_bytes: 65868
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#define PI	3.1415926535
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	ll a, b, x;
	double ans, h;
	cin >> a >> b >> x;
	double vol = a * a * b;

	if (x >= vol / 2) {
		h = 2.0*(vol - x) / (a*a);
		ans = atan(h/a) *(180 / PI);
	}
	else {
		h = 2.0 * x / (a * b);
		ans = atan(b/h) * (180 / PI);
	}
	printf("%.7f\n", ans);
	return 0;
}

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

int main(){
    long long int N;

    scanf("%lld", &N);

    int i;

    for(i = (int) (sqrt(N) + 1e-6); i >= 1; i --){
        if(N % i == 0){
            break;
        }
    }
    long long int j = N / i;

    printf("%lld\n", i + j - 2);
}

Measured memory_bytes: 128
def cost(a, b):
    c = 0
    for ai in a:
        c += (ai-b)**2
    return c

def findcmin(a):
    cmin = cost(a, 100)
    for b in range(-100, 100):
        if cost(a, b) < cmin:
            cmin = cost(a, b)
    return cmin

n = input()
a = [int(i) for i in input().split()]
print(findcmin(a))

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    int ans = 0;
    ans += x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

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

    int T, A, B;
    cin >> T >> A >> B;
    cout << min(A*T, B) << endl;
}


Measured memory_bytes: 892
n = int(input())
red = [[0,0] for _ in range(n)]
blue = [[0,0] for _ in range(n)]

for i in range(n):
    red[i][0], red[i][1] = map(int,input().split())
for i in range(n):
    blue[i][0], blue[i][1] = map(int,input().split())
    
red.sort(key = lambda x:-x[1])
blue.sort(key = lambda x:x[0])

flag = [True] * n

for i in range(n):
    for j in range(n):
        if flag[j] and red[j][0] < blue[i][0] and red[j][1] < blue[i][1]:
            flag[j] = False
            break

ans = 0
for i in range(n):
    if not flag[i]:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<queue>
#include<map>
#include<algorithm>
#include<iostream>
#define fs first
#define sc second
using namespace std;

typedef pair<int,int> P1;
typedef pair<P1,P1> P2;

int main(){
  bool t[20][20][4][101];
  int s[20][20],c[20][20][20][20];
  int k,m,n,l,sw,sh,gw,gh;
  char a,b,z;

  while(cin>>m>>n && (m || n)){
    cin >> k >> l;
    fill(&c[0][0][0][0],&c[m-1][n-1][m-1][n-1]+1,k);

    fill(&s[0][0],&s[m-1][n-1]+1,0);
    while(l--){
      cin>>a>>z>>sw>>k;
      s[a-'a'][sw-1] = k;
    }

    cin>>l;
    while(l--){
      cin>>a>>z>>sw>>b>>z>>gw;
      c[a-'a'][sw-1][b-'a'][gw-1] = c[b-'a'][gw-1][a-'a'][sw-1] = -1;
    }

    cin>>l;
    while(l--){
      cin>>a>>z>>sw>>b>>z>>gw>>k;
      c[a-'a'][sw-1][b-'a'][gw-1] += k;
      c[b-'a'][gw-1][a-'a'][sw-1] += k;
    }

    cin>>a>>z>>sw>>b>>z>>gw;
    sw--;gw--;
    sh = a-'a';gh = b-'a';

    fill(&t[0][0][0][0],&t[m-1][n-1][4][101]+1,false);
    t[sh][sw][0][0] = true;
    queue<P2> q;
    q.push(P2(P1(0,0),P1(sh,sw)));
    l = 1<<30;

    while(q.size()){
      P2 p=q.front();q.pop();
      int y = p.sc.fs,x = p.sc.sc;

      for(int dd=0;dd<4;dd++){
	if(dd==(p.fs.sc+2)%4)continue;
	int dy=y,dx=x,dt=p.fs.fs;
	if(dd==0)dx++;
	if(dd==1)dy++;
	if(dd==2)dx--;
	if(dd==3)dy--;
	if(dy<0 || dx<0 || m<=dy || n<=dx)continue;
	if(c[y][x][dy][dx]<0)continue;
	dt += c[y][x][dy][dx];
	if(dt>100)continue;
	k = s[dy][dx];
	if(k && ( ((dt/k)&1) == (dd&1) ) )continue;
	if(!t[dy][dx][dd][dt]){
	  if(dy==gh && dx==gw)l = min(l,dt);
	  t[dy][dx][dd][dt] = true;
	  q.push(P2(P1(dt,dd),P1(dy,dx)));
	}
      }
    }
    cout<<l<<endl;
  }
}

Measured memory_bytes: 0
import numpy as np
def solve(n, m, a, b):
    records = sorted(list(zip(a, b)), key=lambda _: _[0])
    cnt = 0
    res = 0
    for a_i, b_i in records:
        next = cnt + b_i
        if m <= next:
            c = m - cnt
            res += a_i * c
            break
        else:
            res += a_i * b_i
        cnt = next
    return res

n, m = map(int, input().split())
a, b = np.zeros(n, dtype=int), np.zeros(n, dtype=int)
for i in range(n):
    a[i], b[i] = map(int, input().split())
print(solve(n, m, a, b))

Measured memory_bytes: 29400
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, X, Y; cin >> N >> X >> Y;
    vector<int> ans(N);

    rrep (i, 1, N) {
        rrep (j, i, N) {
            if (i == j) continue;
            int dist = min(abs(i - X) + 1 + abs(Y - j), abs(j - i));
            ++ans[dist];
        }
    }

    rep (i, 1, ans.size()) cout << ans[i] << endl;
}

Measured memory_bytes: 256
N,T = map(int,input().split())
src = list(map(int,input().split()))

mincost = src[0]
maxgain = 0
sell = 0
buy = 1
for a in src[1:]:
    if a < mincost:
        mincost = a
        buy = 1
    elif a == mincost:
        buy += 1
    elif a > mincost + maxgain:
        maxgain = a - mincost
        sell = 1
    elif a == mincost + maxgain:
        sell += 1

print(max(sell,buy))


Measured memory_bytes: 14292
N=int(input())

ans=[0]*(10**5)

for x in range(1,10**2+1):
    for y in range(1,10**2+1):
        for z in range(1,10**2+1):
            now=x**2+y**2+z**2+x*y+y*z+z*x
            ans[now-1]+=1

for i in range(N):
    print(ans[i])


    if i==N-1:
        break

Measured memory_bytes: 69388
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Skip solver = new Skip();
        solver.solve(1, in, out);
        out.close();
    }

    static class Skip {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long x = in.nextLong();

            long[] city = new long[n];
            for (int i = 0; i < n; i++) {
                city[i] = Math.abs(x - Long.parseLong(in.next()));
            }
            long result = city[0];
            for (int i = 1; i < n; i++) {
                result = gcd(result, city[i]);
            }
            out.print(result);

        }

        static long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }

    }
}



Measured memory_bytes: 59528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

struct WarshallFloyd {
    int N;
    vector<vector<ll>> dis;
    void init(int n, int m) {
        N = n;
        dis.assign(n, vector<ll>(n, 1e18));
        for(int i = 0; i < n; i++) {
            dis[i][i] = 0;
        }
        for(int i = 0; i < m; i++) {
            int u, v, l;
            cin >> u >> v >> l;
            u--, v--;
            dis[u][v] = l;
            dis[v][u] = l;
        }
    }
    void build() {
        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++){
                for(int j = 0; j < N; j++) {
                    chmin(dis[i][j], dis[i][k]+dis[k][j]);
                }
            }
        }
    }
};


int main(){
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> t(r);
    for(int i = 0; i < r; i++) cin >> t[i], t[i]--;
    sort(t.begin(), t.end());
    WarshallFloyd g;
    g.init(n, m);
    g.build();

    ll ans = 1e18;

    do {
        ll now = 0;
        for(int i = 0; i < r-1; i++) {
            now += g.dis[t[i+1]][t[i]];
        }
        chmin(ans, now);
    }while(next_permutation(t.begin(), t.end()));

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>

int main()
{
    int r, D, x2000;

    std::cin >> r >> D >> x2000;

    int prev = x2000;
    for (int i = 0; i < 10; i++)
    {
        int now = r * prev - D;
        std::cout << now << std::endl;

        prev = now;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n,r;

  while(cin >> n >> r && n != 0 && r != 0){
    int card[51],temp[51],p,c;

    for(int i=1;i <= n;i++){
      card[i] =n + 1 - i;
    }

    while(r--){
      cin >> p >> c;
      int i;
      for(i=p;i < p+c;i++){
        temp[i-p+1] = card[i];
      }

      for(i=1;i<p;i++){
        temp[i+c] = card[i];
      }

      for(i=p+c;i < n+1;i++){
        temp[i] = card[i];
      }

      for(i=1;i<n+1;i++){
        card[i] = temp[i];
      }
    }

    cout << card[1] << endl;
  }

  return 0;
}   

Measured memory_bytes: 0
#include <stdio.h>
#include <inttypes.h>
#include <ctype.h>

int tokenNum;
int64_t tokens[256];

int yusen[8];

int exprNum;
int64_t expr[256];

void gotiusa(void) {
	int i;
	int stackNum = 0;
	int64_t stack[256];
	exprNum = 0;
	for (i = 0; i < tokenNum; i++) {
		switch (tokens[i]) {
			case -1: case -2: case -3:
				while (stackNum > 0 && yusen[-stack[stackNum - 1]] >= yusen[-tokens[i]]) {
					expr[exprNum++] = stack[--stackNum];
				}
				stack[stackNum++] = tokens[i];
				break;
			case -4:
				stack[stackNum++] = -4;
				break;
			case -5:
				while (stackNum > 0 && stack[stackNum - 1] != -4) {
					expr[exprNum++] = stack[--stackNum];
				}
				if (stackNum > 0) stackNum--;
				break;
			default:
				expr[exprNum++] = tokens[i];
				break;
		}
	}
	while (stackNum > 0) {
		expr[exprNum++] = stack[--stackNum];
	}
}

int64_t kinnmoza(void) {
	int i;
	int stackNum = 0;
	int64_t stack[256];
	for (i = 0; i < exprNum; i++) {
		switch (expr[i]) {
			case -1:
				if (stackNum >= 2) {
					stack[stackNum - 2] += stack[stackNum - 1];
					stackNum--;
				}
				break;
			case -2:
				if (stackNum >= 2) {
					stack[stackNum - 2] -= stack[stackNum - 1];
					stackNum--;
				}
				break;
			case -3:
				if (stackNum >= 2) {
					stack[stackNum - 2] *= stack[stackNum - 1];
					stackNum--;
				}
				break;
			default:
				if (expr[i] >= 0) stack[stackNum++] = expr[i];
				break;
		}
	}
	return stackNum > 0 ? stack[stackNum - 1] : 0;
}

int main(void) {
	char asumikana[256];
	int i;
	int64_t mizukinana = INT64_MIN;
	if (scanf("%255s", asumikana) != 1) return 1;
	for (i = 0; asumikana[i] != '\0'; i++) {
		switch (asumikana[i]) {
			case '+': tokens[tokenNum++] = -1; break;
			case '-': tokens[tokenNum++] = -2; break;
			case '*': tokens[tokenNum++] = -3; break;
			case '(': tokens[tokenNum++] = -4; break;
			case ')': tokens[tokenNum++] = -5; break;
			default:
				if (isdigit((unsigned char)asumikana[i])) {
					int64_t num = 0;
					while (isdigit((unsigned char)asumikana[i])) {
						num = num * 10 + (asumikana[i] - '0');
						i++;
					}
					i--;
					tokens[tokenNum++] = num;
				} else {
					puts("INVALID TOKEN");
					return 2;
				}
				break;
		}
	}
	for (yusen[1] = 1; yusen[1] <= 3; yusen[1]++) {
		
		for (yusen[2] = 1; yusen[2] <= 3; yusen[2]++) {
			for (yusen[3] = 1; yusen[3] <= 3; yusen[3]++) {
				int64_t mizuhasu;
				gotiusa();
				mizuhasu = kinnmoza();
				if (mizuhasu > mizukinana) mizukinana = mizuhasu;
			}
		}
	}
	printf("%" PRId64 "\n", mizukinana);
	return 0;
}



Measured memory_bytes: 2084
def main():
    k = int(input())
    a, b = map(int, input().split())
    ans = solve(k, a, b)
    print('OK' if ans else 'NG')


def solve(k, a, b):
    for i in range(a, b + 1):
        if not i% k:
            return True
    return False


if __name__ == '__main__':
    main()

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

typedef vector<int> V;

bool inv(int key, V v){
    for(V::iterator it = v.begin(); it != v.end(); it++){
        if( *it == key ) return true;
    }
    return false;
}

int main(){
    int p,q;
    while( cin >> p >> q ){
        V ldiv;
        V lrem;
        int d, r;
        lrem.push_back( p );
        while( true ){
            d = p*10/q;
            r = p*10%q;
            ldiv.push_back( d );
            if( !r || inv( r, lrem ) ) break;
            lrem.push_back( r );
            p = r;
        }
        for(V::iterator it = ldiv.begin(); it != ldiv.end(); it++)
            cout << *it;
        cout << '\n';
        if( r ){
            int f = 0;
            for(V::iterator it=lrem.begin(); it!=lrem.end() && f<2; it++){
                if( *it == r ) f++;
                if( f ) cout << '^';
                else cout << ' ';
            }
            cout << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 1220
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = True
        else:
            a[i][j] = False
a += [[a[0][i], a[1][i], a[2][i]] for i in range(3)]
a += [[a[i][i] for i in range(3)]] + [[a[0][2], a[1][1], a[2][0]]]
bingo = False
for i in a:
    if all(i):
        bingo = True
        break
if bingo:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
#define mn -
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define NEG(i,a,b) for (int i = b; i >= a; i--)
/**  '' "\n" ^ - **/
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int five=5;
int six=6;
int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n;
    sf(n);
    vector<pair<int,int> > a(n);
    in(i,n)
    {
        sf(a[i].first);
        a[i].second=i+1;
    }
    sort(a.begin(),a.end());
    in(i,n)
    {
        cout<<a[i].second;ps();
    }
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n)  for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define ld long double
#define ull unsigned long long int

void rayhan_solve()
{
	int count=0;
	string s,t;
	cin>>s;cin>>t;
	rep(i,0,s.size())
	{
		if(s[i]!=t[i])
			count++;
	}

	cout<<count<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);

rayhan_solve();

	return 0;
}

Measured memory_bytes: 3800
import math

import numpy as np
import scipy as scp

# 入力の受け取り
n = int(input())
# 配列入力の受け取り
arrA = np.array(input().split(),dtype=np.int64)

setA = set(arrA)

if len(arrA)==len(setA):
    ans = "YES"
else:
    ans = "NO"

print(ans)

Measured memory_bytes: 37220
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int> pii;

int h,w,a;
      
int main(){
  int ans = 0;
  cin >> h >> w;
  for(int i=0;i<h;i++){
    int num = 0;
    for(int j=0;j<w;j++){
      cin >> a;
      num += ((i==0)^(j==0||j==w-1))?(1-a):a;
    }
    if(w==1)ans += num;
    else if(num!=w)ans += num+1;
    else ans += num-1;
  }

  cout << ans << endl;
}
      

Measured memory_bytes: 1164
package main

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

func solve() {
	n, k := getInt(), getInt()
	s := getRunes()
	if s[0] == '1' {
		k++
	}

	ans := 0
	r := 0
	for l := 0; l < n; l++ {
		r = max(r, l)
		for r < n && k > 0 {
			if r+1 < n && s[r] == '1' && s[r+1] == '0' {
				k--
			}
			r++
		}
		ans = max(ans, r-l)

		if l+1 < n && s[l] == '0' && s[l+1] == '1' {
			k++
		}
	}

	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
int main(void){
  int i,j,st,e;
  char s[201000];
  scanf("%s",s);
  int n=strlen(s);
  for(i=0;i<n;i++){
    if(s[i]=='A'){
      st=i;
      break;
    }
  }
  for(i=n-1;i>=0;i--){
    if(s[i]=='Z'){
      e=i;
      break;  
    }
  }
  printf("%d",e-st+1);
  return 0;
}

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

int main(){
  int n; 
  cin >> n;
  vector<string> s(n);
  map<string,int> mem;
  for(int i = 0; i < n; i++){
    cin >> s.at(i);
    if(mem.find(s.at(i)) == mem.end()){//なかった
      mem.insert(make_pair(s.at(i),0));
    }else{
      mem.at(s.at(i))++;
    }
  }
  int max = 0;
  for(auto& x:mem){
    if(max < x.second){
      max = x.second;
    }
  }
  for(auto& x : mem){
    if(max == x.second){
      cout << x.first << endl;
    }
  }
} 


Measured memory_bytes: 26752
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

int N;
vi A;
map<int, int> m;

signed main()
{
	cin >> N;
	A.resize(N+1);
	rep1(i, N) cin >> A[i];

	int ans = 0;
	rep1(i, N) {
		ans += m[A[i] - i];
		m[-(A[i] + i)]++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 27396
def main():
    N, S = map(int, input().split())
    A = tuple(map(int, input().split()))

    MOD = 998244353

    dp = [[0]*(S+1) for _ in range(N+1)]
    dp[0][0] = 1

    # dp[i][j] : i番目の要素が右端である区間のうち，和がjになる整数列を持つ区間の個数
    for i, a in enumerate(A):            
        for j in range(S+1):
            if j == a:
                dp[i+1][j] += dp[i][j] + i + 1
                dp[i+1][j] %= MOD
            elif j > a:
                dp[i+1][j] += dp[i][j] + dp[i][j-a]
                dp[i+1][j] %= MOD
            else:
                dp[i+1][j] += dp[i][j]
                dp[i+1][j] %= MOD

            
    ans = sum([dp[i][S] for i in range(N+1)])
    ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()

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

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

    int x = 0, int_max = -INT_MAX;
    int_max = max(x, int_max);
    rep(i, n)
    {
        if (s[i] == 'I')
        {
            x++;
        }
        if (s[i] == 'D')
        {
            x--;
        }
        int_max = max(x, int_max);
    }

    cout << int_max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().solve();
    }

    private void solve() {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        System.out.println(Math.min(a, b) + Math.min(c, d));
    }
}

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

int main() {
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  long long t=0;
  long long m=0;
  if(k%2==0){
    t=k*a+(k-1)*(b+c);
    m=k*b+(k-1)*(a+c);
  }
  else{
    t=(k-1)*a+k*(b+c);
    m=(k-1)*b+k*(a+c);
  }
  if(abs(t-m)>1000000000000000000){
    cout<<"Unfair"<< endl;
  }
  else{
    cout<<t-m<< endl;
  }
}

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

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define mod 1000000007

using namespace std;

int main()
{
	//#ifdef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	std::ios_base::sync_with_stdio(false);

	ll n;
	cin>>n;
	cout<<ceil((float)n/2);
	
	return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [input().split() for l in range(N)]

ans = 0
for i in range(N):
	sum = 0
	for j in range(M):
		sum += int(A[i][j])*B[j]
	if sum + C > 0:
		ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;

int par[MAX_N + 1], ds[MAX_N + 1], ff_rank[MAX_N + 1];

void init(int n) {
    for (int i = 1; i <= n; i++) {
        par[i] = i;
        ds[i] = 0;
        ff_rank[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x)
        return x;
    int px = par[x];
    par[x] = find(par[x]);
    ds[x] += ds[px];
    return par[x];
}

bool unite(int _x, int _y, int d) {
    int x = find(_x), y = find(_y);
    if (x == y) {
        if (ds[_y] - ds[_x] != d)
            return false;
    } else {
        if (ff_rank[x] < ff_rank[y]) {
            par[x] = y;
            ds[x] = ds[_y] - ds[_x] - d;
        } else {
            par[y] = x;
            ds[y] = d - ds[_y] + ds[_x];
            if (ff_rank[x] == ff_rank[y])
                ff_rank[x]++;
        }
    }
    return true;
}

int main() {
    int n, m;
    cin >> n >> m;
    init(n);
    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        if (!unite(l, r, d)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 1536
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n, m, x; cin >> n >> m >> x;
  vector <int> c(n);
  vector <vector <int>> g(n);
  for(int i = 0; i < n; i++) {
    cin >> c[i];
    g[i].resize(m);
    for(int j = 0; j < m; j++) {
      cin >> g[i][j];
    }
  }
  int ans = 1e9;
  for(int i = 0; i < (1 << n); i++) {
    int cost = 0;
    vector <int> skill(m, 0);
    for(int j = 0; j < n; j++) {
      if(!((i >> j) & 1)) continue;
      cost += c[j];
      for(int k = 0; k < m; k++) {
        skill[k] += g[j][k];
      }
    }
    bool okay = 1;
    for(int k = 0; k < m; k++) {
      if(skill[k] < x) okay = 0;
    }
    if(okay) {
      ans = min(ans, cost);
    }
  } if(ans == 1000000000) ans = -1;
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}


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

int main() {
  int N, Q;
  string S;
  int l[110000], r[110000];  
  cin >> N >> Q >> S;
  for (int i = 0; i < Q; ++i) cin >> l[i] >> r[i];

  int sum[110000];

  sum[0] = 0;

  for (int i = 0; i < N - 1; ++i) {
    sum[i + 1] = sum[i];
    if (S[i] == 'A' && S[i + 1] == 'C') sum[i + 1]++;
  }
  for (int i = 0; i < Q; ++i) cout << sum[r[i] - 1] - sum[l[i] - 1] << endl;
}


Measured memory_bytes: 2304
n,m,*t=map(int,open(0).read().split())
e=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
    e[a].append(b)
    e[b].append(a)
f=[0]*-~n
f[1]=1
a=[1]
while 1:
    for v in e[a[-1]]:
        if not f[v]:
            f[v]=1
            a.append(v)
            break
    else:
        break
b=[1]
while 1:
    for v in e[b[-1]]:
        if not f[v]:
            f[v]=1
            b.append(v)
            break
    else:
        break
a=a[:0:-1]+b
print(len(a),*a)

Measured memory_bytes: 28000
#include <stdio.h>

int main(){
    long long int n;
    scanf("%lld", &n);

    long long int a[n];
    for(int i = 0;i < n;i++){
        scanf("%lld", &a[i]);
    }

    int nega = 0;
    for(int i = 0;i < n;i++){
        if(a[i] < 0){
            nega++;
        }
    }

    long long int r;
    long long int buffer = 1000000000;
    if(nega % 2 == 0){
        for(int i = 0;i < n;i++){
            if(a[i] >= 0){
                r += a[i];
            }else{
                r += (a[i] * -1);
            }
        }
    }else{
        for(int i = 0;i < n;i++){
            if(a[i] < 0){a[i] = a[i] * -1;}
            if(buffer > a[i]){buffer = a[i];}
        }
        for(int i = 0;i < n;i++){
            r += a[i];
        }
        r = r - (buffer * 2);
    }
    printf("%llu\n", r);
}

Measured memory_bytes: 896
#code
p=998244353
N,M,K=map(int,input().split())
power=[0 for i in range(N)]
power[0]=1
for i in range(1,N):
    power[i]=(power[i-1]*(M-1))%p
ans=M*power[N-1]
ans%=p
pre_compute=[0 for i in range(K+1)]
num = den = 1
for i in range(1,K+1):
    num*=(N-i)
    den*=i
    num%=p
    den%=p
    pre_compute[i]=(num * pow(den, p - 2, p)) % p 
for i in range(1,K+1):
    ans+=M*power[N-1-i]*pre_compute[i]
    ans%=p
print(ans)    

Measured memory_bytes: 82868
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] sozai = s.nextLine().split(" ");
        int num = Integer.parseInt(sozai[0]);
        int ryou = Integer.parseInt(sozai[1]);
        List<Integer> sozaiZenbu = new ArrayList<Integer>();
        for(int i = 0;i < num;i++) {
            int hituyou = Integer.parseInt(s.nextLine());
            ryou -= hituyou;
            sozaiZenbu.add(hituyou);
        }
        int min = Collections.min(sozaiZenbu);
        num += ryou/min;
        System.out.println(num);
    }
}

Measured memory_bytes: 25172
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  //for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 50 == 49) os << std::endl; }
  os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

ll H, W, K;

void solve()
{
  std::cin >> H >> W >> K;
  std::vector< std::string > grid(H, std::string(W, 'c'));
  std::vector< std::vector<ll> > ans(H, std::vector<ll>(W, 0LL));
  for (ll y = 0; y < H; y++) {
    std::cin >> grid[y];
  }

  std::string full(W, '$');
  std::string none(W, '.');
  ll cnt = +1;
  ll pre = -1;
  ll first = -1;
  for (ll y = 0; y < H; y++) {
    if (grid[y] == none) {
      if (pre != -1) {
        ans[y] = ans[pre];
        grid[y] = full;
        pre = y;
      }
    } else {
      ll pos = 0LL;
      first = first < 0 ? y : first;
      pre = y;
      for (ll x = 0; x < W; x++) {
        if (grid[y][x] == '#') {
          for (ll i = pos; i <= x; i++) { ans[y][i] = cnt; }
          pos = x + 1;
          cnt++;
        } else {
          ans[y][x] = cnt-1;
        }
      }
    }
  }

  for (ll y = 0; y < H; y++) {
    if (grid[y] == none) {
      ans[y] = ans[first];
      grid[y] = full;
    }
  }

  print(ans);

  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::ios::sync_with_stdio(false);

  solve();
  return 0;
}



Measured memory_bytes: 4768
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda f:f[2])
p=xyh[-1]
for cx in range(0,101):
  for cy in range(0,101):
    h=p[2]+abs(p[0]-cx)+abs(p[1]-cy)
    for u in xyh:
      if u[2]!=max(0,h-abs(u[0]-cx)-abs(u[1]-cy)):
        break
    else:
      print(cx,cy,h)
                     

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#define ll long long
using namespace std;
int read()
{
    int x=0,f=1;
    char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if (c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
const int N=3e5;
struct _
{
	int x,y;
}list[N*2];
int n,head[N],line=0,h[N];
ll mo=1e9+7,bln[N],s[N],son[N];
ll tmp[N*20],*f[N][3],*p=tmp;
void add(int x,int y)
{
	list[++line].x=head[x];
	list[line].y=y;
	head[x]=line;
}
void dfss(int x,int fa,int hi)
{
	s[hi]++;
	for(int i=head[x];i;i=list[i].x)
	{
		int y=list[i].y;
		dfss(y,x,hi+1);
		if(h[y]>h[x])
		h[x]=h[y],son[x]=y;
	}
	h[x]++;
}
void add(int x){f[x][0]=p,p+=(h[x]),f[x][1]=p,p+=(h[x]),f[x][2]=p,p+=(h[x]);}
void change(int x,int fa){f[x][0]=f[fa][0]+1,f[x][1]=f[fa][1]+1,f[x][2]=f[fa][2]+1;}
void dfs(int x,int fa)
{
	if(son[x])
	{
		change(son[x],x);
		dfs(son[x],x);
	}
//	if(x==1)
//	printf("%d %d\n",x,f[2][0][1]);
	f[x][1][0]=f[x][0][0]=1;
	int ma=0;
	for(int i=head[x];i;i=list[i].x)
	{
		int y=list[i].y;
		if(y==son[x])continue;
		add(y);
		dfs(y,x);
		ma=max(ma,h[y]);
		for(int j=1;j<=h[y];++j)
		{
			ll v0=f[x][0][j],v1=f[x][1][j],v2=f[x][2][j];	
			f[x][0][j]=v0*f[y][0][j-1]%mo;
			f[x][1][j]=(v0*f[y][1][j-1]+v1*f[y][0][j-1])%mo;
			f[x][2][j]=(v2*(f[y][0][j-1]+f[y][1][j-1])+v1*f[y][1][j-1])%mo;
		} 
	}
	for(int j=1;j<=ma;++j)f[x][0][j]=(f[x][0][j]+f[x][2][j])%mo,f[x][2][j]=0;
}
int main()
{
//	freopen("1.in","r",stdin);
	n=read();
	int x;
	for(int i=1;i<=n;++i)x=read(),add(x,i);
	dfss(0,0,0);
	add(0);
	dfs(0,0);
	ll ans=0;
	bln[0]=1;
	for(int i=1;i<=n+1;++i)bln[i]=bln[i-1]*2ll%mo;
	for(int i=0;i<h[0];++i)ans=(ans+f[0][1][i]*bln[n+1-s[i]])%mo;
//	printf("ss%lld\n",f[2][1][1]);
//	for(int i=0;i<h[0];++i)printf("%d %lld\n",i,f[0][1][i]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 42496
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define Min(a,b) (((a) < (b))?(a):(b))
#define Max(a,b) (((a) > (b))?(a):(b))
#define Abs(a) (((a) > 0)?(a):(-1)*(a))
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define SIZE 100010

vi adj[SIZE];

int dfs (int v, int p) {
   if (adj[v].size() == 1) {
      if (v != p) return 0;
      else return 1;
   }
   int x = 0;
   for (int i = 0 ; i < adj[v].size() ; ++i) {
      int t = adj[v][i];
      if (t == p) continue;
      x ^= (1 + dfs (t, v));
   }
   return x;
}

int main() {
   int n;
   cin >> n;
   for (int i = 1 ; i < n ; ++i) {
      int u, v;
      cin >> u >> v;
      adj[u].PB(v);
      adj[v].PB(u);
   }
   int t = dfs (1, 1);
   if (t == 0) cout << "Bob" << endl;
   else cout << "Alice" << endl;
   return 0;
}

Measured memory_bytes: 8832
#include<iostream>
using namespace std;
typedef long long ll;
ll lcm(ll a,ll b)
{
    ll key=max(a,b);
    ll teap=key;
     while(key%a!=0||key%b!=0)
     {
         key=key+teap;
     }
     return key;
}
int main()
{
    ll n;
    while(cin>>n)
        cout<<lcm(2,n)<<"\n";
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> es(n - 1);
  vector< vector<int> > g(n);
  for (int id = 0; id < n - 1; ++id) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    es[id] = u ^ v;
    g[u].push_back(id);
    g[v].push_back(id);
  }
  auto dfs = [&](auto&& self, int v, int pid) -> void {
    int c = 1;
    for (int id : g[v]) {
      if (id != pid) {
        int to = es[id] ^ v;
        c += c == es[pid];
        es[id] = c++;
        self(self, to, id);
      }
    }
  };
  dfs(dfs, 0, -1);
  cout << *max_element(begin(es), end(es)) << '\n';
  for (int e : es) {
    cout << e << '\n';
  }
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
ll a[10001];
int main() {
	// D , D , 앳코더 1회 ㄱ? 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	int ans = 0;
	rep(i, n) {
		cin >> a[i];
		if (a[i] & 1)continue;
		while (a[i] % 2 == 0 && a[i] > 0) {
			ans += 1;
			a[i] /= 2;
		}
	}
	cout << ans << '\n';




}

Measured memory_bytes: 384
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int n = cin.next!int;
  int nx, ny, nt;
  foreach (i; 0 .. n) {
    int t = cin.next!int - nt;
    int x = cin.next!int, y = cin.next!int;
    int d = abs(x - nx) + abs(y - ny);
    if (t < d) {
      writeln("No");
      return;
    }
    if (!(d % 2 == t % 2)) {
      writeln("No");
      return;
    }
  }
  writeln("Yes");
}


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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
  FAST();

  int n, i;
  set<string> abc;
  cin >> n;

  REP(i, 0, n){
  string str;
  cin >> str;
  abc.insert(str);
  }

  cout << abc.size() << endl;
  return 0;
}


Measured memory_bytes: 19248
#include <bits/stdc++.h>
#include <atcoder/convolution>

int main(){
    using namespace std;
    cout << []{
        using fp = atcoder::static_modint<998244353>;
        const unsigned long N{[]{unsigned long ret; cin >> ret; return ret;}()};
        const auto semifact{[&N]{
            vector<fp> ret(N + 1);
            ret[0] = 1;
            for(unsigned long i{1}; i <= N; ++i)ret[i] = ret[i - 1] * (2 * i - 1);
            return ret;
        }()};
        vector<fp> r{[&N, &semifact]{
            const auto fact{[&N]{
                vector<fp> ret(2 * N + 1);
                ret[0] = 1;
                for(unsigned long i{1}; i <= 2 * N; ++i)ret[i] = ret[i - 1] * i;
                return ret;
            }()};
            const auto ifact{[&N, &fact]{
                vector<fp> ret(2 * N + 1);
                ret.back() = 1 / fact.back();
                for(unsigned long i{2 * N}; i--; )ret[i] = ret[i + 1] * (i + 1);
                return ret;
            }()};
            const auto& binom{[&fact, &ifact](const unsigned long n, const unsigned long r) -> fp {
                return ifact[r] * ifact[n - r] * fact[n];
            }};
            const auto& comp{[](const vector<fp>& a, const vector<fp>& b) -> bool {
                return a.size() == b.size() ? &a < &b : a.size() > b.size();
            }};
            priority_queue<vector<fp>, vector<vector<fp>>, decltype(comp)> pq(comp, move([&N, &binom, &semifact]{
                vector<unsigned long> hist(100000);
                for(unsigned long i{0}, h; i < 2 * N; ++i){
                    cin >> h;
                    ++hist[h - 1];
                }
                vector<vector<fp>> ret;
                for(const auto& i : hist)if(i){
                    const auto& sz{i / 2 + 1};
                    vector<fp> tmp(sz);
                    for(unsigned long j{0}; j < sz; ++j)tmp[j] = binom(i, 2 * j) * semifact[j];
                    ret.emplace_back(move(tmp));
                }
                return ret;
            }()));
            while(pq.size() > 1){
                vector<fp> f{pq.top()};
                pq.pop();
                vector<fp> g{pq.top()};
                pq.pop();
                pq.emplace(move(atcoder::convolution(move(f), move(g))));
            }
            return pq.top();
        }()};
        fp ret{0};
        for(unsigned long i{size(r)}; i--;)ret = r[i] * semifact[N - i] - ret;
        return ret;
    }().val() << endl;
    return 0;
}


Measured memory_bytes: 10476
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

#define P 1000000007

long m(long a, int x){
	if(x==0) return 1;
	if(x%2==0){
		return m(a*a%P, x/2);
	}else{
		return m(a*a%P, x/2)*a%P;
	}
}

int r(int a){
	return m(a, P-2);
}

int kh[400001];

long c(int a, int b){
	// kh[a] / kh[b] / kh[a-b];
	return ((long)kh[a]) * r(((long)kh[b]) * kh[a-b] %P) %P;
}

int main(void){
	int n, k;
	scanf("%d%d", &n, &k);

	kh[0]=kh[1]=1;
	for(long i=1; i<=n*2; i++){
		kh[i+1] = kh[i] * (i+1) %P;
	}
	long ans=0;
	if(k>=n){
		ans=c(n*2-1, n-1);
	}else{
		for(int i=0; i<=k; i++){
			ans += c(n, i) * c(n-1, i) % P;
		}
	}
	ans %= P;
	printf("%d\n", ans);
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main()
{
    stack<char> s;
    ll n;
    cin>>n;
    while(n>0)
    {
        ll mush=n%26;
        if(mush==0)
        {
            s.push('z');
            n=(n/26)-1;
        }
        else
        {
            char ch='a'-1+(mush);
            n=n/26;
            s.push(ch);
        }
    }
    while(!s.empty())
    {
        cout<<s.top();
        s.pop();
    }
    return 0;
}


Measured memory_bytes: 3616