akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;

void NotFoud() {
	string s;
	cin >> s;
	s.push_back('z' + 1);
	int n = s.size();
	sort(s.begin(), s.end());
	char c = 'a';
	if (s[0] != 'a') {
		cout << "a" << endl;
		return;
	}
	for (size_t i = 0; i < n; i++)
	{
		if (s[i] != c){
			c = c + 1;
			if (s[i] != c)
			{
				cout << c << endl;
				return;
			}
		}
		c = s[i];
	}

	cout << "None" << endl;
}

int main() {
	NotFoud();
	return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
 
using namespace std;

long long int N,K,counts;

int main(){
  cin>>N;
  int ans=0;
  if(N % 2 == 0){
  	ans = N/2;
  }else{
  	ans= N/2 + 1;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
X,N = list(map(int,input().split()))
if N != 0:
  p = list(map(int,input().split()))
else:
  p = [X+1]
def f(p):
  global X
  return p - X

p2 = list(map(f,p))

p3 = list(map(abs,p2))

OK = 2
j = 0


if min(p3) ==0:
  while(OK==2):
    j+=1
    OK = p3.count(min(p3)+j)
  if OK == 1:
    print(X-p2[p3.index(min(p3)+j)])
  else:
    print(X-j)
else:
  print(X)

Measured memory_bytes: 9228
n=int(input())
h=list(map(int,input().split()))

res=0
while 1:
    if max(h)==0: break
    i=0
    while i<n:
        if h[i]==0: i+=1
        else:
            res+=1
            while i<n and h[i]>0:
                h[i]-=1
                i+=1
print(res)

Measured memory_bytes: 39152
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
long long n,a[200010],x[200010],sum[200010],l,r,ans;
int main(){
	cin>>n;
	cin>>a[0];
	x[0]=a[0];
	sum[0]=a[0];
	for(int i=1;i<n;i++){
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
		x[i]=x[i-1]^a[i];
	}
	for(int r=0;r<n;r++){
		while((sum[r]-sum[l-1])!=(x[r]^x[l-1]))l++;
		ans+=r-l+1;
	}
	cout<<ans<<'\n';
	return 0;
}

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

signed main(){
	int q,h,s,d,n;cin>>q>>h>>s>>d>>n;
  int n2=min({8*q,4*h,2*s,d});
  int n1=min({4*q,2*h,s});
  int ans=(n/2)*n2+(n%2)*n1;
	cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
const int Mod = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator += (const mll& a) {
		if ((x += a.x) >= Mod) x -= Mod;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= Mod;
	}
};
int main() {
	int N;
	string S;
	cin >> N >> S;
	map<char, int>Nums;
	for (char c : S) Nums[c]++;
	mll ans = 1;
	for (const auto& p : Nums) ans *= (long long)p.second + 1;
	ans += -1;
	cout << ans.x << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <assert.h>
using namespace std;

int main()
{
  int n,k;
  cin >> n >> k;
  int d = (n - 1) * (n - 2) / 2 - k;
  if (d < 0){
    cout << -1 << endl;
    return 0;
  }
  cout << (n - 1) + d << endl;
  // (n - 1) * (n - 2) / 2 本のペアが存在する
  for(int i = 2; i <= n; ++i){
    cout << 1 << ' ' << i << endl;
  }
  int count = d;
  for(int i = 2; i <= n; ++i){
    for(int j = i+1; j <= n; ++j){
      if (count == 0){
        return 0;
      }
      count--;
      cout << i << ' '<< j << endl;
    }
  }
  assert("could not reach here");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
//const u32 P=;
//inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
//inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
//inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
//inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
//u64 power(u64 a, int b) {
//	u64 ans=1;
//	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
//	return ans;
//}
const int N=1e5+5;
int n, m, a[N], b[N], *order[N], pa[N];
s64 f[N], s[N];
std::vector<int> edge[N], child[N];
int find(int x) {return pa[x]==x?x:(pa[x]=find(pa[x]));}
void dp(int x) {
	f[x]=a[x];
	s[x]=b[x];
	for(int y: child[x]) {
		dp(y);
		cmin(f[x], std::max(0ll+a[x], f[y])-s[y]);
		s[x]+=s[y];
	}
	f[x]+=s[x];
}
int main() {
	n=rd(), m=rd();
	for(int i=1; i<=n; ++i) {
		a[i]=rd(), b[i]=rd();
		cmax(a[i]-=b[i], 0);
		order[i-1]=a+i;
	}
	for(int i=0; i<m; ++i) {
		int u=rd(), v=rd();
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	std::sort(order, order+n, [](int *a, int *b) {return *a<*b;});
	for(int i=0; i<n; ++i) {
		int x=order[i]-a;
		pa[x]=x;
		for(int y: edge[x]) if(pa[y]) {
			int z=find(y);
			if(x!=z) {
				pa[z]=x;
				child[x].push_back(z);
			}
		}
	}
	int r=order[n-1]-a;
	dp(r);
	printf("%lld\n", f[r]);
	return 0;
}


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

int main() {
  int N;
  int mmo=0;
  cin>>N;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
    if(i*j==N){
      mmo++;
    }
    }
  }
if(mmo){
cout<<"Yes";
}
  else{
    cout<<"No";
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 1
#define MOD 1000000007
#define min(a,b) (((a)<(b))?a:b)
int h,w,k;


int fibo[10]={1,1,2,3,5,8,13,21,34,55};
int f(int a,int b){
  if(a>b)return f(b,a);
  if(a<0 || b>w)return 0;
  return fibo[a-1]*fibo[w-b];
}

long int c[120][10];

int main(){

  scanf("%d%d%d",&h,&w,&k);
  int i,j;
  for(j=1;j<=w;j++){
    c[0][j]=(j==k)?1:0;
  }
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      c[i][j]=f(j-1,j)*c[i-1][j-1]+f(j,j)*c[i-1][j]+f(j+1,j)*c[i-1][j+1];
      c[i][j]%=MOD;
    }
  }

  printf("%ld",c[h][1]);
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 128
N,M=map(int,input().split())
sa=set()
sb=set()
for i in range(M):
    a,b=map(int,input().split())
    if a==1:sb.add(b)
    if b==N:sa.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")        

Measured memory_bytes: 19024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    ll c = a + b;
    ll r = n / c * a + min(n % c, a);

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
  int N,A[100];
  scanf("%d",&N);
  for(int i=0;i<N;i++) scanf(" %d",&A[i]);
  sort(A,A+N);
  printf("%d\n",A[N-1]-A[0]);
  return 0;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e2+5;

int a , b , c , d;

int main(){
    cin >> a >> b >> c >> d;
    if(a + b < c + d){
        cout << "Right";
    } else if(a + b == c + d){
        cout << "Balanced";
    } else {
        cout << "Left";
    }

}





Measured memory_bytes: 256
import sys


def dfs(s, links, dots, checked):
    q = [s]
    xs = set()
    ys = set()
    cnt = 0
    while q:
        v = q.pop()
        if checked[v]:
            continue
        checked[v] = True

        x, y = dots[v]
        xs.add(x)
        ys.add(y)
        cnt += 1
        q.extend(links[v])
    return max(0, len(xs) * len(ys) - cnt)


n = int(input())
dots = [tuple(map(int, line.split())) for line in sys.stdin]
xs = {}
ys = {}
links = [set() for _ in [0] * n]
for i, (x, y) in enumerate(dots):
    if x in xs:
        links[i].add(xs[x])
        links[xs[x]].add(i)
    else:
        xs[x] = i
    if y in ys:
        links[i].add(ys[y])
        links[ys[y]].add(i)
    else:
        ys[y] = i

checked = [False] * n
ans = 0
for i in range(n):
    if checked[i]:
        continue
    ans += dfs(i, links, dots, checked)
print(ans)


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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

main() {
  int n, a, b, ans = 0;
  //string s;
  cin >> a >> b;
  //vector<int> v(n), c(n);
  if(a >= b) rep(i, a) cout << b;
  else rep(i, b) cout << a;
  //for(int i = 0; i < n; i++){}
  cout << endl;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(ll, n);
  if (!n) {
    out(0);
    return 0;
  }
  string ans;
  ll bit = 1;
  while (n) {
    if (abs(n) % 2 == 1) {
      n -= 1;
      ans = '1' + ans;
    } else {
      ans = '0' + ans;
    }
    n /= -2;
    bit <<= 1;
  }
  out(ans);
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main()
{
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> a(m);
  for(int i=0;i<m;i++) cin >> a[i];

  int cnt = 0;
  for(int i=0;i<m;i++){
    if(x < a[i]){
      cnt++;
    }
  }

  cout << min(cnt,m-cnt) << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    int a,b,c = 0;
    cin  >> a >> b >> c;
    
    if (c >= a && c <= a + b) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
//135_c
#include <stdio.h>

typedef long long ll;
#define rep(i,a,b,c) for(ll i=(a);i<(b);i+=(c))


ll min(ll a, ll b){if(a<b)return a;else return b;}

int main(void){
    ll N,ans=0,power_i,power_j;
    scanf("%lld",&N);
    ll a[N+5],b[N+5];
    rep(i,0,N+1,1){
        scanf("%lld",&a[i]);
    }
    rep(i,0,N,1){
        scanf("%lld",&b[i]);
    }
    power_i=min(a[0],b[0]);
    power_j=min(a[1],b[0]-power_i);
    // printf("%lld %lld\n",power_i,power_j);
    ans=ans+power_i+power_j;
    rep(i,1,N,1){
        power_i=min(a[i]-power_j,b[i]);
        power_j=min(a[i+1],b[i]-power_i);
        ans=ans+power_i+power_j;
        // printf("%lld %lld\n",power_i,power_j);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3272
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int p,n;
  while(cin>>p>>n&&(p||n)){
    int nmn=n,dmn=1,nmx=1,dmx=n;
    for(i=1;i<n+1;i++){
      for(j=max(1,(int)(sqrt(p)*i)-1);j<min(n+1,(int)(sqrt(p)*i)+2);j++){
	if(0){
	}else if((double)j/i<sqrt(p)){
	  if((double)nmx/dmx<(double)j/i){
	    nmx=j;
	    dmx=i;
	  }
	}else if((double)j/i>sqrt(p)){
	  if((double)nmn/dmn>(double)j/i){
	    nmn=j;
	    dmn=i;
	  }
	}
      }
    }
    cout<<nmn<<"/"<<dmn<<" "<<nmx<<"/"<<dmx<<endl;
  }
  return 0;
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
using namespace std;
#define float long double
typedef vector<int> vi;
#define pb push_back
#define mod 1000000007
int dp[101][100000];


int32_t main(){
    int answer =0 ;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin >> n >> k ;
	int *arr = new int[n];
	for(int i = 0 ; i < n ; i++) cin >> arr[i];

	for(int i = 0 ; i <= k ; i++){
        if(i>arr[n-1]) dp[n-1][i] = 0;
        else dp[n-1][i] = 1;
	}
	if(n == 1){
        cout << dp[0][k] ;
        return 0;
	}
	for(int i = 1 ; i<=k;i++) dp[n-1][i] = (dp[n-1][i]%mod +(dp[n-1][i-1]%mod))%mod;

    for(int i = n-2;i>=0;i--){
        int val = arr[i];
        for(int j = 0 ;j <=k;j++){
            if(j<=arr[i]){
                dp[i][j] = dp[i+1][j];
            }
            else dp[i][j] = (dp[i+1][j]%mod - dp[i+1][j-val-1]%mod + mod)%mod;
        }
        if(i==0) break;
        for(int j = 1 ; j<=k;j++) dp[i][j]= (dp[i][j]%mod +dp[i][j-1]%mod)%mod;
    }

	cout << dp[0][k];

}


Measured memory_bytes: 39296
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
using namespace std;
long long a[200003];
long long b[200003];
main(){
  int n;
  cin>>n;
  for (int i=0;i<n;i++)
  	cin>>a[i];
  for (int i=0;i<n;i++)
    b[i]=a[i]-(i+1);
  sort (b,b+n);
  long long ans=0;
  for (int i=0;i<n;i++)
    ans+=abs(a[i]-(b[n/2]+i+1));
  cout<<ans;
}

Measured memory_bytes: 3328
n = int(input())

map_list = [[0,'abc',0] for i in range(n)]

for i in range(n):
    input_line = input().split()
    map_list[i]=[i,input_line[0],int(input_line[1])]

ans_li = sorted(map_list,key=lambda x:(x[1],-x[2]))
for ans in ans_li:
    print(ans[0]+1)



Measured memory_bytes: 3060
//
//  main.cpp
//  4
//
//  Created by RISHAV SINGH MEHTA on 19/01/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int T,i,j,k,l,N,a,b;
    cin>>N;
    
    ll int A[11][11]={0};
    a=0;
    for (i=1; i<=N; i++) {
        j=i;
        while (j) {
            a=j;
            j=j/10;
        }
        l=i%10;
        A[a][l]=A[a][l]+1;
        
    }
    ll int ans=0;
    for (i=1; i<10; i++) {
        
        for (j=1; j<=i; j++) {
            
            if (i != j) {
                ans =ans + 2*A[i][j]*A[j][i];
            }else{
            ans =ans + A[i][j]*A[j][i];
            }
            //cout<<"A["<<i<<"]["<<j<<"] = "<<A[i][j]<<"\t";
            //cout<<"A["<<j<<"]["<<i<<"] = "<<A[j][i]<<endl;
            //cout<<"the ans is="<<ans<<endl;
        }
        
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

using namespace std;

typedef long long ll;

ll ans;
int N;
int A[100005], B[100005], C[100005];
ll S[100005];

int main(void) {
    scanf("%d", &N);
    rep(i, 0, N) scanf("%d", &A[i]);
    rep(i, 0, N) scanf("%d", &B[i]);
    rep(i, 0, N) scanf("%d", &C[i]);

    sort(B, B+N);
    sort(C, C+N);

    rep(i, 0, N) {
        S[i+1] = S[i] + ((C+N) - upper_bound(C, C+N, B[i]));
    }

    rep(i, 0, N) {
        int p = upper_bound(B, B+N, A[i]) - B;
        ans += S[N] - S[p];
    }


  
    printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 2176
import copy
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
 
n = int(input())
a = [[] for i in range(n)]
war = [[] for i in range(n)]
for i in range(n):
    a[i] = list(map(int,input().split()))
war = copy.deepcopy(a)
for i in range(n):
    if a[i][i] != 0:
        print(-1)
        exit()
 
warshall_floyd(war)


res = 0
for i in range(n):
    for j in range(n):
        if war[i][j] < a[i][j]:
            print(-1)
            exit()
        elif war[i][j] == a[i][j]:
            judge = 1
            for h in range(n):
                if h != i and h != j and war[i][h]+war[h][j] == war[i][j]:
                    judge = -1
            if judge == 1:
                res += war[i][j]
print(res//2)

Measured memory_bytes: 56668
//https://vjudge.net/contest/383153#problem/B
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 85;
bool dp[N][N][N*N * 2];
int h,w;
pii a[N][N];



int main(){
    io;
    //freopen("input.txt", "r", stdin);
    cin >> h >> w;
    rep(i, 1, h){
        rep(j, 1, w){
            cin >> a[i][j].ff;
        }
    }
    rep(i, 1, h){
        rep(j, 1, w){
            cin >> a[i][j].ss;
        }
    }
    dp[1][1][abs(a[1][1].ss - a[1][1].ff)] = 1;
    rep(i, 1, h){
        rep(j, 1, w){
            rep(k, 0, N * N - 1){
                if(dp[i][j][k]){
                    int a1 = a[i + 1][j].ff, b1 = a[i + 1][j].ss;
                    dp[i + 1][j][k + abs(a1 - b1)] = 1;
                    dp[i + 1][j][abs(k - abs(a1 - b1))] = 1;
                    a1 = a[i][j + 1].ff, b1 = a[i][j + 1].ss;
                    dp[i][j + 1][k + abs(a1 - b1)] = 1;
                    dp[i][j + 1][abs(k - abs(a1 - b1))] = 1;
                }
            }
        }
    }
    rep(k, 0, N * N - 1){
        if(dp[h][w][k]){
            cout << k;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 66628
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  cout << (n==3||n==5||n==7?"YES":"NO") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    int ans1=0;
	    int ans2=0;
	    int ans3=0;
	    int ans4=0;
	    
	    for(long j=1;j<=n;j++) {
	    	 String s=sc.next();
	    	 
	    	 if(s.equals("AC"))ans1++;
	    	 else if(s.equals("WA"))ans2++;
	    	 else if(s.equals("TLE"))ans3++;
	    	 else if(s.equals("RE"))ans4++;
	    	 
	     }
	    
	    
	   System.out.println("AC x "+ans1);
	   System.out.println("WA x "+ans2);
	   System.out.println("TLE x "+ans3);
	   System.out.println("RE x "+ans4);
	}
}



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

int N;

void dfs (string s, char mx) {
    if(s.length() == N ) {
        printf("%s\n",s.c_str());
        return;
    }
    for (char c = 'a' ; c <= mx; c++) {
        dfs (s + c, c == mx ? (char) (mx + 1) : mx);
    }
}

int main () {
    cin >> N;
    dfs ("", 'a');
    return 0;
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<char> S(N);
  getchar();
  for (int i=0; i<N; i++) S[i]=getchar();
  S[K-1] = S[K-1] -'A' + 'a';

  for (int i=0; i<N; i++) cout << S[i];
  cout << "\n";
}

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

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        long N=cin.nextLong();
        long ans=0;
        for(int i=1;i<N;i++)
        {
            ans+=i;
        }
        Console.WriteLine(ans);
        
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 11092
target = int(input())
plus = target
range = input().rstrip().split(" ")
min = int(range[0])
max = int(range[1])
answer = 0
while target <= max:
    if target >= min:
        answer += 1
        break
    target += plus
if answer == 1:
    print("OK")
else:
    print("NG")  

Measured memory_bytes: 9128
#include <stdio.h>

int main(void)
{
	int i, n;
	int flag[30] = {0};
	
	for (i = 0; i < 28; i++) {
		scanf("%d", &n);
		flag[n - 1] = 1;
	}
	for (i = 0; i < 30; i++) {
		if (flag[i] == 0) {
			printf("%d\n", i + 1);
		}
	}
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define MAX 222222
using namespace std;
bool is_prim[MAX];

bool isPrim(int x){
  for(int i=2; i < sqrt(x); i++){
    if(x % i == 0)
      return false;
  }
  return true;
}

void init(void){
  for(int i=0; i < MAX; i++){
    is_prim[i] = true;
  }
  is_prim[0] = false;
  is_prim[1] = false;
  for(int i=2; i < MAX; i++){
    for(int j=i+i; j < MAX; j+=i){
      is_prim[j] = false;
    }
  }
}

int main(void){
  int N, P;
  init();
  while(cin >> N >> P, !(N == -1 && P == -1)){
    list<int> seq;
    //int i = 1;
    //while(P > 0){
    //  if(is_prim[i+N]){
    //    seq.insert(seq.end(), i+N);
    //    i++;
    //    P--;
    //  }else{
    //    i++;
    //  }
    //}
    for(int i=1, cnti=0;; i++){
      if(is_prim[i+N]){
        for(int j=i, cntj=0;; j++){
          if(is_prim[j+N]){
            seq.insert(seq.end(), i+N+j+N);
            if(cntj > P) break;
            cntj++;
          }
        }
        if(cnti > P) break;
        cnti++;
      }
    }
    seq.sort();
    list<int>::iterator it = seq.begin();
    for(int i=1; i < P; i++){
      ++it;
    }
    cout << *it << endl;
  }
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

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

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;

// your function is here

// your function finished

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here

	int n, a, b; cin >> n >> a >> b;

	if ((b - a) % 2 == 0) Print("Alice");
	else Print("Borys");

	// your code finished
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
//#define int long long
//#define _DEBUG
#include <queue>
#include <vector>
using namespace std;
int N, T[107][107], D[107]; //T[i][j]:i->T[i][j]の辺
int const infty = -1, none = -9;
queue<int> Q;
void solve(){
    Q.push(0);
    D[0] = 0;
    while(true){
#ifdef _DEBUG
        cout << "Q1 ";
        int length = Q.size();
        for(int k=0; k<length; k++){
            int qf = Q.front(); Q.pop();
            cout << qf << " ";
            Q.push(qf);
        }cout << endl; 
#endif
        int top = Q.front(); Q.pop();
#ifdef _DEBUG
        cout << "top " << top << endl << "Q2 ";
        length = Q.size();
        for(int k=0; k<length; k++){
            int qf = Q.front(); Q.pop();
            cout << qf << " ";
            Q.push(qf);
        }cout << endl; 
#endif
        for(int j=0; j<N; j++){
#ifdef _DEBUG
            cout << j << ", " << T[top][j] << endl;
            cout << "top " << top << endl << "Q3 ";
            length = Q.size();
            for(int k=0; k<length; k++){
                int qf = Q.front(); Q.pop();
                cout << qf << " ";
                Q.push(qf);
            }cout << endl; 
#endif
            if(T[top][j] == none)break;
            if(D[ T[top][j] ] != infty)continue;
            Q.push( T[top][j] );
            D[ T[top][j] ] = D[top]+1;
        }
#ifdef _DEBUG
        cout << "D " ;
        for(int k=0; k<N; k++) cout <<D[k]<<" ";
        cout << endl;
#endif
        if(Q.empty()) break;
    }
}
void get(){
    cin >> N;
    for(int i=0; i<N; i++){
        D[i] = infty;
        for(int j=0; j<N; j++){
            T[i][j] = none;
        }
    }
    for(int i=0; i<N; i++){
        int i_, k;
        cin >> i_ >> k;
        for(int j=0; j<k; j++){
            int vj;
            cin >> vj;
            T[i][j] = vj-1;
        }
    }
}

signed main(){
    get();
    
#ifdef _DEBUG
    for(int k=0; k<N; k++) cout << D[k] << " ";
    cout << endl;
    for(int k=0; k<N; k++){
        for(int l=0; l<N; l++){
            if(T[k][l] == none)break;
            cout << T[k][l] << " ";
        }
        cout << endl;
    }
#endif
    solve();
    for(int i=0; i<N; i++){
        cout << i+1 << " " << D[i] << endl;
    }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define eps 1e-9

using namespace std;

string con(ll n)
{
    string ans;

    while(n)
    {
        ans += (char)(n%26);

        if(n%26==0)
            n--;

        n/=26;
    }
    reverse(ans.begin(),ans.end());
    return ans;

}

int main()
{

    ll t,n,m,f,a,b,c,l,r,q,k,x,y,z,mn,mx,sum=0;
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    cin>>n;

    string exp,ans;

    exp = con(n);

    for(int i=0;i<exp.size();i++)
    {
        //cout<<(char)('a' + exp[i] - 1) ;

        if(exp[i])
        {
            cout<<(char)('a' + (int)exp[i] - 1) ;
        }
        else
        {
            cout<<'z';
        }
    }
    cout<<endl;




}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
typedef long long ll;
#define iof ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897
const ll mod =1000000007;
#define inf 100000
using namespace std;

int main()
{
  ll n; cin>>n;
  ll arr[n+1],brr[n];
  for(ll i=0;i<=n;i++)
    cin>>arr[i];
  for(ll i=0;i<n;i++)
    cin>>brr[i];
    ll ans=0;
  for(ll i=0;i<n;i++)
  {
      if(arr[i]>=brr[i])
        ans+=brr[i];
      else
      {
          ans+=arr[i];
          if(arr[i+1] >=(brr[i]-arr[i]))
          {
              ans+=brr[i]-arr[i];
              arr[i+1]=arr[i+1]-(brr[i]-arr[i]);
          }
          else
          {
              ans+=arr[i+1];
              arr[i+1]=0;
          }
      }
  }
  cout<<ans;
}


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

a = [0] * N
for i in range(M):
    K, *S = list(map(int, input().split()))
    for j in range(K):
        s = S[j]
        s -= 1
        # s番目のスイッチにi番目の電球が繋がっている
        a[s] |= 1 << i

expected = 0
P = list(map(int, input().split()))
for i in range(M):
    if P[i]:
        expected |= 1 << i

ans = 0
for s in range(1 << N):  # スイッチの状態
    tmp = 0
    for i in range(N):
        if s >> i & 1:
            tmp ^= a[i]
    if tmp == expected:
        ans += 1

print(ans)


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
F = li2(N)
P = li2(N)

B = 2**10

ans = -float('inf')
for i in range(1, B):
    pro = 0
    for j in range(N):
        cnt = 0
        for k in range(11):
            if (i & 1 << k) and F[j][k] == 1:
                cnt += 1
        pro += P[j][cnt]
    ans = max(ans, pro)

print(ans)

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15); 
    vector<int> a(3); 
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end()); 
    if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
        cout << "YES\n";    
    }   else {
        cout << "NO\n"; 
    }
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>
#include <random>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14


using namespace std;

class BinaryIndexedTree {
public:
    unsigned int n = 0; // (a.size() - 1)
    vector<long long> a;

    BinaryIndexedTree(unsigned int n) : n(n) {
        this->a = vector<long long>(n + 1, 0);
    }

    // sum[0, i)
    long long sum(int i) {
        assert(0 <= i && i <= this->n);

        long long s = 0;
        i -= 1;
        while (i >= 0) {
            s += this->a[i];
            i = (i & (i + 1)) - 1;
        }
        return s;
    }

    long long sum(int left, int right) {
        assert(left <= right);
        return this->sum(right) - this->sum(left);
    }

    // a[i] += x(0-origin)
    void add(int i, int x) {
        assert(0 <= i && i < this->n);

        while (i < this->n) {
            this->a[i] += x;
            i |= i + 1;
        }
    }
};



int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;

    BinaryIndexedTree bit(n);
    FOR(i, 0, q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            bit.add(x - 1, y);
        }
        else {
            cout << bit.sum(x - 1, y) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3496
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())
AB = []
for _ in range(N):
  AB.append(list(mi()))

#高い順に並ぶ
AB = sorted(AB, key=lambda x:x[0])

print(AB[-1][1] + AB[-1][0])



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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long H, long long W){

    lli ans = INF;
    REP(i,1,H){
        lli sa = i*W;
        lli leftS = H*W-sa;
        lli leftH = H-i;
        if(leftH%2 == 0)chmin(ans,abs(sa-leftS/2));
        else{
            if(W%2==0)chmin(ans,abs(sa-leftS/2));
            else{
                lli leftW = W - W/2;
                vector<lli> ss;
                ss.push_back(sa);
                ss.push_back(leftW*leftH);
                ss.push_back(leftS-leftW*leftH);
                SORT(ss);
                chmin(ans,abs(ss[0]-ss[2]));
            }
        }
    }

    swap(H,W);
    REP(i,1,H){
        lli sa = i*W;
        lli leftS = H*W-sa;
        lli leftH = H-i;
        if(leftH%2 == 0)chmin(ans,abs(sa-leftS/2));
        else{
            if(W%2==0)chmin(ans,abs(sa-leftS/2));
            else{
                lli leftW = W - W/2;
                vector<lli> ss;
                ss.push_back(sa);
                ss.push_back(leftW*leftH);
                ss.push_back(leftS-leftW*leftH);
                SORT(ss);
                chmin(ans,abs(ss[0]-ss[2]));
            }
        }
    }

    cout<<ans<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    func(H, W);
    return 0;
}


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

int n, a[10];

int dfs(int cnt, int mlt){
        if(cnt==n) return mlt%2==0;
        int ret = 0;
        for(int i=-1; i<2; i++){
                ret += dfs(cnt+1, mlt*(a[cnt]-i)%2);
        }
        return ret;
}

int main(){
        scanf("%d", &n);
        for(int i=0; i<n; i++) scanf("%d", &a[i]);
        printf("%d\n", dfs(0, 1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n){
        cin>>a;
        while(1){
            if(a%2==1)break;
            a/=2;
            ans++;
        }
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
const int MAXN = 200010;
int nowarn;

int n, in[MAXN];

namespace Graph {
	int head[MAXN], nxt[MAXN], to[MAXN], eidx = 0;
	void init() {
		memset( head, -1, sizeof(head) );
	}
	void adde( int u, int v ) {
		to[eidx] = v, nxt[eidx] = head[u], head[u] = eidx++;
	}
}

int loop[MAXN], lpidx = 0;
int onloop[MAXN] = {0};
void find_loop() {
	int u = 1;
	for( int i = 1; !onloop[u]; ++i )
		onloop[u] = i, loop[i] = u, u = in[u];
	for( int i = onloop[u]; loop[i]; ++i )
		loop[i-onloop[u]] = loop[i], lpidx = i+1-onloop[u];
	memset( onloop, 0, sizeof(onloop) );
	for( int i = 0; i < lpidx; ++i ) onloop[loop[i]] = 1;
}

int mex[MAXN], vis[MAXN] = {0};
void dfs( int u ) {
	using namespace Graph;
	if( mex[u] != -1 ) return;
	if( head[u] == -1 ) {
		mex[u] = 0;
		return;
	}
	for( int i = head[u]; ~i; i = nxt[i] )
		dfs( to[i] );
	for( int i = head[u]; ~i; i = nxt[i] )
		vis[mex[to[i]]] = u;
	for( int i = 0; ; ++i )
		if( vis[i] != u ) {
			mex[u] = i;
			break;
		}
}
void solve1() {
	memset( mex, -1, sizeof(mex) );
	for( int i = 1; i <= n; ++i ) {
		if( !onloop[i] )
			dfs(i);
		// printf( "mex[%d] = %d\n", i, mex[i] );
	}
}

bool check( int x ) {
	using namespace Graph;
	mex[loop[0]] = x;
	memset( vis, 0, sizeof(vis) );
	for( int i = 1; i < lpidx; ++i ) {
		int u = loop[i];
		for( int j = head[u]; ~j; j = nxt[j] ) {
			int v = to[j];
			vis[mex[v]] = u;
		}
		for( int j = 0; ; ++j )
			if( vis[j] != u ) {
				mex[u] = j;
				break;
			}
	}
	int u = loop[0];
	for( int i = head[u]; ~i; i = nxt[i] ) {
		int v = to[i];
		vis[mex[v]] = u;
	}
	for( int i = 0; ; ++i )
		if( vis[i] != u )
			return mex[u] == i;
}
void solve2() {
	using namespace Graph;
	int u = loop[0], mex2;
	for( int i = head[u]; ~i; i = nxt[i] ) {
		int v = to[i];
		if( onloop[v] ) continue;
		vis[mex[v]] = u;
	}
	for( int i = 0; ; ++i )
		if( vis[i] != u ) {
			mex[u] = i;
			break;
		}
	vis[mex[u]] = u;
	for( int i = 0; ; ++i )
		if( vis[i] != u ) {
			mex2 = i;
			break;
		}
	// printf( "mex2 = %d\n", mex2 );
	if( check(mex[u]) || check(mex2) ) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}

int main() {
	nowarn = scanf( "%d", &n );
	Graph::init();
	for( int i = 1; i <= n; ++i ) {
		nowarn = scanf( "%d", in+i );
		Graph::adde( in[i], i );
	}
	find_loop();
	solve1(), solve2();
	return 0;
}


Measured memory_bytes: 6400
class MinSlideWindow:
    def __init__(self,p):
        self.pos_list = []
        self.val_list = p
        self.start_idx = 0

    def put(self,pos):
        val = self.val_list[pos]

        while len(self.pos_list) > self.start_idx:
            pos1 = self.pos_list[-1]
            val1 = self.val_list[pos1]
            if val1 >= val:
                del self.pos_list[-1]
            else:
                break
        self.pos_list.append(pos)

    def get(self,pos):
        while len(self.pos_list) > self.start_idx:
            pos1 = self.pos_list[self.start_idx]
            if pos1 <= pos:
                self.start_idx += 1
            else:
                break

    def min(self):
        pos1 = self.pos_list[self.start_idx]
        val1 = self.val_list[pos1]
        return val1

class MaxSlideWindow:
    def __init__(self,p):
        self.pos_list = []
        self.val_list = p
        self.start_idx = 0
        
    def put(self,pos):
        val = self.val_list[pos]

        while len(self.pos_list) > self.start_idx:
            pos1 = self.pos_list[-1]
            val1 = self.val_list[pos1]
            if val1 <= val:
                del self.pos_list[-1]
            else:
                break
        self.pos_list.append(pos)

    def get(self,pos):
        while len(self.pos_list) > self.start_idx:
            pos1 = self.pos_list[self.start_idx]
            if pos1 <= pos:
                del self.pos_list[self.start_idx]
            else:
                break

    def max(self):
        pos1 = self.pos_list[self.start_idx]
        val1 = self.val_list[pos1]
        return val1




s = input().split(" ")
n = int(s[0])
k = int(s[1])
sp = input().split(" ")
p = [int(pstr) for pstr in sp]
num = 1
ident = True
rv_pos = -1

minw = MinSlideWindow(p)
maxw = MaxSlideWindow(p)

for i in range(k - 1):
    if p[i] > p[i + 1]:
        rv_pos = i
        ident = False
    
for i in range(k-1):
    minw.put(i)
    maxw.put(i)

for i in range(1,n - k + 1):
    
    maxw.put(i + k - 2)
    minw.put(i + k - 2)
    maxw.get(i-1)
    minw.get(i-1)

    """    
    for j in range(k - 1):
        if p[i + j] > p[i + j +1]:
            break
    else:
        if not ident:
            ident = True
            num += 1
        continue
    """
    if p[i + k - 2] > p[i + k - 1]:
        rv_pos = i + k - 2
        

    
    if rv_pos < i:
        if not ident:
            ident = True
            num += 1
        continue
            

    if p[i - 1] > minw.min() or p[i + k - 1] < maxw.max():
        num += 1

    
print(num)


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

int main() {
  int N;
  cin >> N;
  int becky=1;
  for(int i=2;i<N+1;i++){
    for(int j=2;j<i;j++){
      int x=j;
      for(int k=1;k<10;k++){
        x*=j;
        if(x==i)becky=i;
        if(x>i)break;
      }
    }
  }
  cout << becky;
  cerr << "kawatanienon";
}





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

typedef long long ll;
const int maxn=100010<<2;
int n, val[maxn];
ll l;
char s[maxn];
int Max;
int e=1, ch[maxn][2];

ll calc(ll x){
	ll ret=1;
	while( !(x&1) && x>0 ) x>>=1, ret<<=1;
	return ret;
}
void insert(char *s){
	int o=1;
	for(int i=0;i<strlen(s);i++){
		int c=s[i]-'0';
		if(!ch[o][c]) ch[o][c]=++e;
		o=ch[o][c];
	}
	val[o]=1;
}

ll ans;
void dfs(int x,int dep){
	int cnt=(bool)ch[x][0]+(bool)ch[x][1];
	if(ch[x][0]) dfs(ch[x][0],dep+1); if(ch[x][1]) dfs(ch[x][1],dep+1);
	if(cnt==1){ ans^=calc(l-dep); return; }
}

int main(){

	scanf("%d%lld",&n,&l); l++;
	for(int i=1;i<=n;i++){
		scanf("%s",s); 
		insert(s);
	}
	dfs(1,1);
	printf("%s\n", ans?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 6144
N = str(input())


if N[-1] == '2' or N[-1] =='4' or N[-1] =='5' or N[-1] =='7' or N[-1] =='9':
    print('hon')
elif N[-1] == '0' or N[-1] =='1' or N[-1] =='6' or N[-1] =='8':
    print('pon')
elif N[-1] == '3':
    print('bon')


Measured memory_bytes: 8956