akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //long n = long.Parse(Console.ReadLine());
            long[] inputLongArray1 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long[] inputLongArray2 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long sum = inputLongArray2.Sum();
            long result;
            if(inputLongArray1[0] < sum)
            {
                result = -1;
            }
            else
            {
                result = inputLongArray1[0] - sum;
            }

            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            sw.Write(result);
            Console.SetOut(sw);
            Console.Out.Flush();
        }
    }
}

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

bool check(string &s){
	char st[128],t;
	int sp=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='('){
			st[sp++]=s[i];
		}else if(s[i]=='['){
			st[sp++]=s[i];
		}else if(s[i]==')'){
			if(sp==0 || st[--sp]!='(')return false;
		}else if(s[i]==']'){
			if(sp==0 || st[--sp]!='[')return false;
		}
	}
	if(sp)return false;
	return true;
}
int main(){
	string s;
	while(1){
		getline(cin,s);
		if(s[0]=='.')break;
		cout<<(check(s)?"yes":"no")<<endl;
	}
	return 0;
}

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

int main(){
    vector<int> vec(5);
    int k;
    for(int i=0;i<5;i++){
        cin >> vec.at(i);
    }
    cin >> k;
    if(vec.at(4)-vec.at(0)>k){
        cout << ":(" << endl;
    }
    else cout << "Yay!" << endl;

return 0;    
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {
    int parent, left, right;
};
struct Node T[MAX];
int n;

//前序遍历
void preParse(int u) {
    if (u == NIL) return;
    printf(" %d", u);
    preParse(T[u].left);
    preParse(T[u].right);
}

//中序遍历
void inParse(int u) {
    if (u == NIL) return;
    inParse(T[u].left);
    printf(" %d",u);
    inParse(T[u].right);
}

//后序遍历
void postParse(int u) {
    if (u == NIL) return;
    postParse(T[u].left);
    postParse(T[u].right);
    printf(" %d", u);
}

int main() {
    int u, l, r, root;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) T[i].parent = NIL;

    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &u, &l, &r);
        T[u].left = l;
        T[u].right = r;
        if (l != NIL) T[l].parent = u;
        if (r != NIL) T[r].parent = u;
    }

    for (int i = 0; i < n; i++) {
        if (T[i].parent == NIL) root = i;
    }
    
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 2704
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll i,s=0,n;cin>>n;vi v(n);map<ll,ll>mp;
	for(i=0;i<n;i++) cin>>v[i],mp[v[i]]++;
	for(auto i:mp) s+=i.se*(i.se-1)/2;
	for(i=0;i<n;i++){
		ll c=s-mp[v[i]]*(mp[v[i]]-1)/2+(mp[v[i]]-1)*(mp[v[i]]-2)/2;
		cout<<c<<endl;
	}
}



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

int main(){
  string s;
  cin>>s;
  int count=0;
  int a=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
        a++;
    }
    else{
      count=max(a,count);
      a=0;
    }
  }
  count=max(a,count);
  cout<<count<<endl;
}

Measured memory_bytes: 256
import collections,bisect
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for i in range(M)]
a=collections.defaultdict(list)
for city,year in sorted(PY):a[city]+=[year]
for city,year in PY:
    z=bisect.bisect(a[city],year)
    print("%06d%06d"%(city,z))

Measured memory_bytes: 43332
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int arr[100001]={0};
int s[100001];
int isPrime(int num)//素数判断
{
    for(int i=2;i<=sqrt(num);i++)
    {
        if(num%i==0)
            return 0;
    }
    return 1;
}
void judge()//把是素数的对应位置设置为1
{
    for(int i=3;i<=100001;i++)
    {
        if(isPrime(i)&&isPrime((i+1)/2))
            arr[i]=1;
    }
    return ;
}
int main(){
    int q,l,r;
    cin>>q;
    judge();
    s[0]=arr[0];
    for(int i=1;i<100001;i++)//计算该数以前的素数个数
        s[i]=s[i-1]+arr[i];
    for(int i=0;i<q;i++)
    {
        cin>>l>>r;
        cout<<s[r]-s[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if(a<b){
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else if (a == b){
			System.out.println("a == b");
		}
	}
}

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

int main()
{
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1] << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int a[200010];
    int b[200010];
    cin >> n;
    imfor(i, n) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b + n, greater<int>());
    int max = b[0];
    int max2 = b[1];
    imfor(i, n) {
        if (a[i] == max) {
            cout << max2 << endl;
        }
        else {
            cout << max << endl;
        }
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;

void Main(){

  int N; cin>>N;

  int ct=0;
  int temp=0;

  int H[N];
  rep(i,N){
    cin>>H[i];
  }

  reps(i,1,N){
    if(H[i-1]>=H[i]){
      temp++;
      maxi(ct,temp);
    }
    else{
      temp=0;
    }
  }

  cout<< ct<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 640
#include <iostream>
#include <string.h>

using namespace std;

int main () {
  string s1;
  string s2;
  cin >> s1 >> s2;
  for (int i = 0; i < s1.size(); i++) {
      string s3 = s1.substr(i, s1.size() - i);
      string s4 = s2.substr(0, s1.size() - i);
      string s5 = s1.substr(0, i);
      string s6 = s2.substr(s1.size() - i , i);
      
      // cout << s3 << " " << s4 << " "<< s5 << " " << s6 << std::endl;

      if (
        s3 == s4
        &&
        s5 == s6
      ) {
      cout << "Yes" << std::endl;
      break;  
    }  
    if (i == (s1.size() - 1)) {
      cout << "No" << std::endl;  
    }
  }  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> V;
const long long MOD=1000000007LL;
const long long INFL=1LL << 60;
const int INF=1<<29;
const int MAX = 10000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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


int main() {
    COMinit();
    int N,K;
    cin >>N>>K;
    for(int i=1;i<=K;i++){
        if(i<=N-K+1)cout<<COM(N-K+1,i)*COM(K-1,i-1)%MOD<<endl;
        else cout<<0<<endl;
    }

        

    return 0;
}

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


#define ll int
#define ld long double
#define mod 1000000007
#define big 1e18+100000000
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}




void solve() {
            
            ll n;
            cin >> n;
            
            ll A[n + 1];
            ll B[n + 1];
            
            for(ll i = 1; i <= n; i++) {
                    cin >> A[i];
            }
            
            for(ll i = 1; i <= n; i++) {
                    cin >> B[i];
            }
            
            for(ll i = 1; i <= (n / 2); i++) {
                    ll t = B[i];
                    B[i] = B[n - i + 1];
                    B[n - i + 1] = t;
            }
            
            ll l = n + 1;
            ll r = 0;
            
            for(ll i = 1; i <= n; i++) {
                    if(A[i] == B[i]) {
                            l = i;
                            break;
                    }
            }
            
            for(ll i = n; i >= 1; i--) {
                    if(A[i] == B[i]) {
                            r = i;
                            break;
                    }
            }
            
            
            ll l1 = l;
            ll r1 = r;
            
            for(ll i = 1; i < l; i++) {
                    if(l1 <= r1) {
                            if(A[i] != A[l1] && B[i] != B[l1]) {
                                    swap(B[i], B[l1]);
                                    l1++;
                            }
                    }
            }
            
            for(ll i = n; i > r; i--) {
                    if(l1 <= r1) {
                            if(A[i] != A[l1] && B[i] != B[l1]) {
                                    swap(B[i], B[l1]);
                                    l1++;
                            }
                    }
            }
            
            if(l1 <= r1) {
                    cout << "No" << endl;
            } else {
                    cout << "Yes" << endl;
                    for(ll i = 1; i <= n; i++) {
                            cout << B[i] << " ";
                    }
                    cout << endl;
            }
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 5236
inf=10**10

d,g=map(int,input().split())
g//=100
p=[];c=[]
for i in range(d):
    a,b=map(int,input().split())
    b//=100
    p.append(a)
    c.append(b)
ans=inf

for i in range(1<<d):
    cnt=0
    sum=0
    for j in range(d):
        if(i&(1<<j)):
            cnt+=p[j]
            sum+=(j+1)*p[j]+c[j]
    for j in range(d)[::-1]:
        if(i&(1<<j)):continue
        if(sum>=g):break
        if(sum+(j+1)*(p[j]-1)<=g):
            cnt+=p[j]-1
            sum+=(j+1)*(p[j]-1)
        else:
            cnt+=(g-sum+j)//(j+1)
            sum=inf
            
    if(sum>=g):ans=min(ans,cnt)
    #print(i,cnt,sum)
print(ans)
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 3005;
int N;
int A[MAX_N];

int dp[MAX_N][MAX_N];

int solve(int l, int r, int turn) 
{
  if(dp[l][r] != INF_LL) {
    return dp[l][r];
  }

  if(l>r) {
    return 0;
  }

  // cerr << l << " " << r << endl;

  int nextTurn = (turn+1)%2;
  int ret = A[l] - solve(l+1,r,nextTurn);
  ret = max(ret, A[r] - solve(l,r-1,nextTurn));
  return dp[l][r] = ret;
}

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> A[n];
  }

  REP(n,MAX_N) {
    REP(m,MAX_N) {
      dp[n][m] = INF_LL;
    }
  }
  
  cout << solve(0,N-1,0) << endl;

  return 0;
}


Measured memory_bytes: 71040
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = Integer.parseInt(sc.next());
        int g = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int ans = r * 100 + g * 10 + b;
        System.out.println(ans % 4 == 0 ? "YES" : "NO");
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;

int a[maxn];
ll dp[maxn][2];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int ls = s.size();
    for (int i = 0; i < ls; ++i) a[i + 1] = (s[i] == '0' ? 0 : 1);
    if (a[1] == 1){
        dp[1][0] = 1;
        dp[1][1] = 2;
    }else{
        dp[1][0] = 0;
        dp[1][1] = 1;
    }
    for (int i = 2; i <= ls; ++i){
        if (a[i] == 1){
            dp[i][0] += dp[i - 1][1];
            dp[i][0] += 3 * dp[i - 1][0];
            dp[i][1] += 2 * dp[i - 1][1];
        }else{
            dp[i][0] += 3 * dp[i - 1][0];
            dp[i][1] += dp[i - 1][1];
        }
        dp[i][0] %= mod;
        dp[i][1] %= mod;
    }
    cout << (dp[ls][0] + dp[ls][1]) % mod << endl;
    return 0;
}


Measured memory_bytes: 2384
using System;
using System.Collections.Generic;
using System.Linq;

class A
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int h = a[0], w = a[1];
		var t = new int[h].Select(_ => Console.ReadLine().Select(x => x == '#' ? 0 : -1).ToArray()).ToArray();

		var q = new Queue<P>();
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				if (t[i][j] == 0) q.Enqueue(new P(i, j));

		var r = 0;
		Func<P, P[]> nexts = p => Array.FindAll(new[] { new P(p.i, p.j - 1), new P(p.i, p.j + 1), new P(p.i - 1, p.j), new P(p.i + 1, p.j) }, x => 0 <= x.i && x.i < h && 0 <= x.j && x.j < w && t[x.i][x.j] == -1);
		while (q.Any())
		{
			var p = q.Dequeue();
			foreach (var np in nexts(p))
			{
				r = t[np.i][np.j] = t[p.i][p.j] + 1;
				q.Enqueue(np);
			}
		}
		Console.WriteLine(r);
	}

	struct P
	{
		public int i, j;
		public P(int _i, int _j) { i = _i; j = _j; }
	}
}


Measured memory_bytes: 36816
n,k=map(int,input().split())
d=set(map(int,input().split()))
d_=set((1,2,3,4,5,6,7,8,9,0))
abl=d_-d
ans=''
a0=True
a1=True
for i in str(n):
  if a0 and int(i) in abl:
    ans+=str(i)
  elif a0:
    b=[ai for ai in abl if int(i)<ai]
    if len(b)==0:
      a1=False
      break
    b.sort()
    ans+=str(b[0])
    a0=False
  else:
    ans+=str(min(abl))
if a1==False:
  print(str(min(abl-{0}))+str(min(abl))*len(str(n)))
else:
  print(ans)


Measured memory_bytes: 38416
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
     mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
    ll n,k;
    cin>>n>>k;
    mint ans=0;
    V<mint> memo(k+1,0); 
    for( ll i=k;i>=1;i--){
       ll d=k/i;
       mint res=mint(d).pow(n);
       for(ll j=2;i*j<=k;j++)res-=memo[i*j];
       memo[i]=res;
       ans+=res*mint(i);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 50952
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int main() {
	int n;
	scanf("%d", &n);
	n--;
	int answer;
	vector<int> num(n);
	REP(i, n) {
		scanf("%d", &num[i]);
	}
	scanf("%d", &answer);
	ll dp[102][21] = {};
	dp[1][num[0]] = 1;
	REP(i,n) {
		REP(j, 21) {
			if (dp[i][j]) {
				if((j+num[i])<=20)
					dp[i + 1][j + num[i]] += dp[i][j];
				if ((j - num[i]) >= 0)
					dp[i + 1][j - num[i]] += dp[i][j];
			}
		}
	}
	printf("%lld\n", dp[n][answer]);
	return 0;
}

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

using namespace std;

int main(){
	int n,s=0,i,j;
	int x[100];
	int min = INT_MAX;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i]; 
	}
	for (i=1;i<=100;i++){
		s = 0;
		for(j=0;j<n;j++){
			s += (x[j]-i)* (x[j]-i); 
		}
		if (s < min) min = s;
	}
	cout << min;
	return 0;
}


Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []a = new int [n];
		
		for(int i = 0; i < n ; i++) {
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		
		
		int h = 0;
		int w = 0;
		int count = 0;
		
		for(int i = n-1; i >= 1 ; i--) {
			if(a[i] == a[i-1]){
				count++;
				if(h == 0) {
					h = a[i];
				}
				if(count == 3) {
					w = a[i];
				}
				if(h != 0 && a[i] < h) {
					w = a[i];
				}
			}
		     else {
					count = 0;
				}
				
			if(h != 0 && w != 0) {
				break;
			}
		}
		
		System.out.println((long)h*w);
	}

}


Measured memory_bytes: 50448
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int[] num = new int[3];
    boolean flag = true;
    for(int i=0;i<3;i++) num[i]=scan.nextInt();
    for(int j=1;j<=num[1];j++){
        if((j*num[0])%num[1] == num[2]){
          flag = false;
           System.out.println("YES"); break;
         }
    }
    if(flag) System.out.println("NO");

  }
}


Measured memory_bytes: 23892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int width,height,x,y,r;
		String buf = br.readLine();
		String[] spl = buf.split(" ");
		width =Integer.parseInt(spl[0]);
		height =Integer.parseInt(spl[1]);
		x =Integer.parseInt(spl[2]);
		y =Integer.parseInt(spl[3]);
		r =Integer.parseInt(spl[4]);

		//???????????????
		if((x<r)){
			System.out.println("No");
			return;
		}else if(x>(width-r)){
			//???????????????
			System.out.println("No");
			return;
		}else if(y<r){
			System.out.println("No");
			return;
		}else if(y>(height-r)){
			System.out.println("No");
			return;
		}else{
			System.out.println("Yes");
		}




	}
}

Measured memory_bytes: 24328
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>

#include <algorithm>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <string>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define INF 1 << 29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout << #x << ": " << x << endl
#define _DDEBUG(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x, y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  if (!v.empty()) {
    out << '[';
    copy(v.begin(), v.end(), ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}

/* template end */

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

  int h, w;
  cin >> h >> w;

  string table[h];
  bool check[h][w];
  for (int i = 0; i < h; i++) {
    cin >> table[i];
    for (int j = 0; j < w; j++) {
      check[i][j] = true;
    }
  }

  vector<int> wv(w);
  for (int i = 0; i < h; i++) {
    bool t = true;
    for (int j = 0; j < w; j++) {
      if (table[i][j] == '#') {
        t = false;
      }
      wv[j] += table[i][j] == '.' ? 1 : 0;
    }
    if (t) {
      for (int j = 0; j < w; j++) {
        check[i][j] = false;
      }
    }
  }

  for (int i = 0; i < w; i++) {
    if (wv[i] == h) {
      for (int j = 0; j < h; j++) {
        check[j][i] = false;
      }
    }
  }

#if DEBUG
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << check[i][j] << ' ';
    }
    cout << endl;
  }

  cout << "** RESULT **" << endl; // debug
#endif

  for (int i = 0; i < h; i++) {
    bool f = false;
    for (int j = 0; j < w; j++) {
      if (check[i][j]) {
        cout << table[i][j];
        f = true;
      }
    }
    if (f) {
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

require 'prime'

_n = gets.to_i
a = gets.split(' ').map(&:to_i)
b = a.map { |p| Prime.prime_division(p).select { |e| e.first == 2 }&.first&.last }

if !b.select(&:nil?).empty?
  puts 0
else
  puts b.min
end


Measured memory_bytes: 2428
#!/usr/bin/perl -w
use strict;

my $str = 'CODEFESTIVAL2016';

my $S = <STDIN>;
my $ite =0;
my $i=0;
for (0..length($str)-1){
    
    if (substr($S, $_, 1) ne substr($str, $_, 1)) {
        $ite++;
    }
}

print "$ite \n";

Measured memory_bytes: 512
#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> P;
constexpr int mod = 1000000007;

int main() {
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
    ll A, B;
    cin >> A >> B;
    if((A + B) % 2 != 0){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << (A + B) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    for (int i=0;i<s.size();i++) {
        char c=s.at(i)+n;
        if (s.at(i)+n>90) {
            c=s.at(i)+n-26;
        }
        cout<<c;
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

vi x,y;
vp v;
int main(){
    ll n;cin>>n;
    v=vp(n);
    x=vi(n);y=vi(n);
    rep(i,n)cin>>x[i]>>y[i];
    rep(i,n){
        x[i]--;y[i]--;
    }
    rep(i,n)v[i]=P(x[i],i);
    sort(all(v));
    vp d(1);
    d[0]=P(0,y[v[0].se]);
    REP(i,1,n){
        ll id=i,k=id,mi=y[v[id].se];
        while(true){
            if(d.size()==0||y[v[id].se]<d.back().se){
                d.eb(k,mi);
                break;
            }
            k=d.back().fi;chmin(mi,d.back().se);
            d.pop_back();
        }
    }
    vi ans(n);
    rep(i,d.size()){
        if(i==d.size()-1)REP(j,d[i].fi,n)ans[j]=n-d[i].fi;
        else REP(j,d[i].fi,d[i+1].fi)ans[j]=d[i+1].fi-d[i].fi;
    }
    vi res(n);
    rep(i,n)res[v[i].se]=ans[i];
    for(ll x:res)out(x);
}

Measured memory_bytes: 12704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100009
int n;
ll m;
vector <int> ad[N];
vector <ll> pf[N],sf[N];
map <int,int> mp[N];
ll fs[N],gs[N];
int par[N]={0};

ll f(int p,int x){
	if(fs[x]!=-1)
		return fs[x];
	par[x]=p;
	ll sum=1;
	for(int i=0;i<ad[x].size();i++){
		mp[x][ad[x][i]]=i;
		if(ad[x][i]==p)
			continue;
		sum=(sum*(f(x,ad[x][i])+1))%m;
	}
	pf[x].resize(ad[x].size());
	sf[x].resize(ad[x].size());
	for(int i=0;i<ad[x].size();i++){
		if(ad[x][i]==p)
			pf[x][i]=1;
		else
			pf[x][i]=(f(x,ad[x][i])+1);
		sf[x][i]=pf[x][i];
	}
	for(int i=1;i<ad[x].size();i++)
		pf[x][i]=(pf[x][i-1]*pf[x][i])%m;
	for(int i=ad[x].size()-2;i>=0;i--)
		sf[x][i]=(sf[x][i+1]*sf[x][i])%m;
	fs[x]=sum;
	return sum;
}
ll g(int x){
	if(gs[x]!=-1)
		return gs[x];
	ll sum=1;
	int p=par[x];
	int i=mp[p][x];
	if(i>0)sum=(sum*(pf[p][i-1]))%m;
	if(i<(ad[p].size()-1))sum=(sum*(sf[p][i+1]))%m;
	sum=(sum*(g(p)+1))%m;
	gs[x]=sum;
	return sum;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cin >> n >> m;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin >> x >> y;
		ad[x].push_back(y);
		ad[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		fs[i]=-1;
		gs[i]=-1;
	}
	gs[1]=0;
	f(0,1);
	for(int i=1;i<=n;i++)
		cout << (f(par[i],i)*(g(i)+1))%m << endl;
}

Measured memory_bytes: 43520
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
using namespace std;
int main(){
	int l;
	scanf("%d", &l);
	double s = l/3.0;
	printf("%.10lf\n", s*s*s);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 30005;
#define pb push_back
#define pii pair<int,int>

int t;
int n,m;
pii A[MN];
int f[MN];
int main()
{
	memset(f,0,sizeof f);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d%d",&A[i].first,&A[i].second);
//	sort(A+1,A+1+n);
	sort(A+1,A+1+n,[](pii x,pii y){if(x.first==y.first) return x.second>y.second; return x.first<y.first;});
//	for(int i=1;i<=n;++i) printf("(%d,%d,%d)\n",i,A[i].first,A[i].second);
	for(int i=1;i<=n;++i)
	{
		int a = A[i].first, b = A[i].second;
		for(int j=m-1;j>=0;--j)
		{
			f[j+a] = max(f[j+a],f[j]+b);
		}
	}
	int ans = 0;
	for(int i=0;i<6001;++i) 
	{
		ans = max(ans,f[i]);
//		printf("%d\n",f[i]);
	}
	printf("%d\n",ans);
}

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

int n;
vector<int> a;

int main() {
  cin >> n;
  int buff, ma = 0;
  while (cin >> buff) {
    ma = max(ma, buff);
    a.push_back(buff);
  }
  if (n == 2) {cout << ma << " " << min(a[0],a[1]);}
  else {
      int l = ma/2, r = ma/2 + 1, c = ma;
  if (ma & 1) {
    for (int i: a) {
      int dif = min(abs(c-l),abs(c-r));
      if (dif > min(abs(i-l), abs(i-r))) c = i;
    }
  } else {
    for (int i: a) {
      int dif = abs(c-l);
      if (dif > abs(i-l)) c = i;
    }
  }
  cout << ma << " " << c;
  }
}


Measured memory_bytes: 892
num = input()
s1 = [2,4,5,7,9]
s2 = [0,1,6,8]
if int(num[int(len(str(num)))-1]) in s1:
  print("hon")
elif int(num[int(len(str(num)))-1]) in s2:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,flag=0;
  cin>>n;
  int arr[n+5];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    if(arr[i]%2==0 && flag==0)
    {
      if(arr[i]%3!=0 && arr[i]%5!=0 )
        flag=1;
    }
  }
  if(flag==0)
    cout<<"APPROVED\n";
  else
    cout<<"DENIED\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

int main() {
  ll N,K;
  cin >> N >> K;
  vector<ll> x(N);
  rep(i,N){
    cin >> x[i];
  }
  vector<ll> t;
  for(int i = 0;i<=N-K;i++){
    ll l = i;
    ll r = l+K-1;
    ll tl = x[r]-x[l] +abs(x[l]);
    t.push_back(tl);
    ll tr = x[r]-x[l] + abs(x[r]);
    t.push_back(tr);
  }
  sort(t.begin(),t.end());
  cout << t[0] << endl;
 
}

Measured memory_bytes: 2168
#include<stdio.h>

int main(void){
    int n,b,f,r,v;
    int i,j,k;
    int room[4][3][10];
    for ( i = 0 ; i < 4 ; i++ ){
        for ( j = 0 ; j < 3 ; j++ ){
            for ( k = 0 ; k < 10 ; k++ ){
                room[i][j][k]=0;
            }
        }
    }
    scanf("%d", &n);
    for ( i = 0 ; i < n ; i++ ) {
        scanf("%d %d %d %d", &b, &f, &r, &v );
        room[b-1][f-1][r-1] += v;
    }
    for ( i = 0 ; i < 4 ; i++ ){
        for ( j = 0 ; j < 3 ; j++ ){
            for ( k = 0 ; k < 10 ; k++ ){
                printf(" %d", room[i][j][k] );
            }
            printf("\n");
            if ( j == 2 && i != 3 ) printf("####################\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2128
#include<iostream>

using namespace std;


int main() {
	char String[1200];

	cin.getline(String, sizeof(String));

	for (int i = 0; String[i] != '\0'; i++) {
		if ('a' <= String[i] && String[i] <= 'z') {
			String[i] += 'A' - 'a';
		}
		else if ('A' <= String[i] && String[i] <= 'Z') {
			String[i] += 'a' - 'A';
		}
	}

	cout << String << endl;

	return 0;
}

Measured memory_bytes: 1128
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;

ll A,B;
ll C,D;

int GCD(int a,int b) {
	if(b==0)return a;
	return GCD(b,a%b);
}

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
	ll t1=B/C-(A-1)/C;
	ll t2=B/D-(A-1)/D;
	ll g=C*D/GCD(C,D);
	ll t3=B/g-(A-1)/g;
	printf("%lld",(B-A+1)-t1-t2+t3);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0,d;
  ll x,y;
  string s;
  cin >> n >> d;
  rep(i,n){
    cin >> x >> y;
    
    if(x*x+y*y <= d*d) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define sync_off ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) ;
#define cinti cin.tie(NULL) ;
#define endl '\n';
int cnt;
long long sum;
int main() {
    sync_off;
    int n,m,c;
    int b[m+1],a[m+1];
    cin >> n >> m >> c;
    for(int i=0;i<m;i++) {
        cin >> b[i];
    }
    cnt =0;
    for(int i=0;i<n;i++) {
            sum=0;
        for(int j=0;j<m;j++) {
            cin >> a[j];
            sum+= a[j]*b[j];
        }

        if(sum+c>0) {cnt++;}

    }
    cout << cnt;

return 0;
}




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

//const int INF = 1001001001;
//const ll INF = 1000000000000000000;

double dist(pair<int,int> a, pair<int,int> b){
	double dx, dy;
	dx = a.first - b.first;
	dy = a.second - b.second;
	return sqrt(dx*dx + dy*dy);
}

int main() {
	int n;
	cin >> n;
	vector<int> p(n), q(n);
	rep(i,n) cin >> p[i];
	rep(i,n) cin >> q[i];

	vector<int> one_case(n);
	rep(i,n) one_case[i] = i + 1;
	int ans = 0, cnt = 0;
	do {
		cnt++;
		if (p == one_case) ans += cnt;
		if (q == one_case) ans -= cnt;
	} while(next_permutation(one_case.begin(), one_case.end()));
	ans = abs(ans);
	cout << ans << endl;
	return 0;
} 


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    wcS = collections.defaultdict(int)
    wcT = collections.defaultdict(int)
    for c in S:
        wcS[c] += 1
    for c in T:
        wcT[c] += 1
    cS = collections.defaultdict(int)
    cT = collections.defaultdict(int)
    for key in wcS:
        cS[wcS[key]] += 1
    for key in wcT:
        cT[wcT[key]] += 1
    representable = True
    if len(cT.keys()) > len(cS.keys()):
        temp = cT
        cT = cS
        cS = temp
    for key in cS:
        if cT[key] != cS[key]:
            representable = False
    print(YES if representable else NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4076
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/abc100/tasks/abc100_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 ================================================================
 */
ll solve(){
    ll res = 0;
    ll N; cin >> N;
    vector<ll> a(N); for(auto& in:a) cin >> in;
    for(auto v:a){ while(v%2==0){res++; v/=2;}}
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    map<string, int> s;
    for(int i = 0; i < n; i++){
        string ss;
        cin >> ss;
        s[ss]++;
    }
    int mx = 0;
    for(auto e : s){
        mx = max(mx, e.second);
    }
    for(auto it = begin(s); it != end(s); it++){
        if(it->second == mx){
            cout << it->first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n,k;
  cin>>n>>k;
  double sum=0;
  for(int i=1;i<=n;i++){
    if(i>=k) sum+=1.0;
    else{
      int temp=i;
      double bunbo=1.0;
      for(int j=0;;j++){
        if(temp>=k) break;
        temp*=2;
        bunbo*=2.0;
      }
      sum+=1.0/bunbo;
    }
  }
  cout<<fixed<<setprecision(9)<<sum/(double)n<<endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var K = FL();
		var N = 50;
		var a = new long[N];
		for (var i = 0; i < N; i++) a[i] = i + (K / N) - (K % N);
		for (var i = N * (K / N); i < K; i++) a[i % N] += N + 1;
		Console.WriteLine(N);
		Console.WriteLine(string.Join(" ", a));
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define rd(x) cin >> x;
#define rda(a,n) for(int i=1;i<=n;i++) cin >> a[i];
#define wr(x) cout << x << ' ';
#define wrl(x) cout << x << '\n';
#define wra(a,n) for(int i=1;i<=n;i++) cout << a[i] << ' '; cout << '\n';
#define lg length()
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
struct comp{
    bool operator()(int a, int b){
        return a>b;
    }
};

///________CODE_STARTS_HERE________\\\

int n,x,cnt;

int main(){
    ios_base :: sync_with_stdio(0); cin.tie(NULL);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> x;
        if(x%2) cnt++;
    }
    if(cnt%2) cout << "NO";
    else cout << "YES";

}


Measured memory_bytes: 256
//Print a Chessboard
#include<stdio.h>
int main()
{
    int H,W;
    while(scanf("%d%d",&H,&W),H+W)
    {
        for (int i = 1; i <= H; i++)
        {
            for (int j = 1; j <= W; j++)
            {
                if(i%2==0) putchar((i+j)%2==0?'#':'.');
                else putchar((i+j)%2==0?'#':'.');
            }
            puts("");
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 2056
import java.util.*;
import java.text.*;

public class Main {
    static long MOD = (long)1e9+7;
    static String s;
    static int n, D;
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        s = in.next();
        D = in.nextInt(); n = s.length();
        long[][] ways = new long[D][1+n];
        ways[0][0] = 1;
        for(int c = 0; c < n; c++)
            for(int di = 0; di < D; di++)
                for(int nxt = 0; nxt < 10; nxt++)
                    ways[(di+nxt)%D][c+1] = (ways[(di+nxt)%D][c+1]+ ways[di][c])%MOD;
                    
        System.out.println((calc(ways, 0, 0)+MOD-1)%MOD);
    }
    static int digitSum(int x){
        int sum = 0;
        while(x>0){
            sum += x%10;
            x/=10;
        }
        return sum;
    }
    static long calc(long[][] ways, int idx, int rem){
        if(idx == s.length())return rem == 0?1:0;
        int dig = s.charAt(idx)-'0';
        long ans = 0;
        for(int di = 0; di < dig; di++){
            int digits = n-idx-1;
            int remainder = (D-(rem+di)%D)%D;
            ans += ways[remainder][digits];
            if(ans >= MOD)ans -= MOD;
        }
        ans += calc(ways, idx+1, (rem+dig)%D);
        if(ans >= MOD)ans -= MOD;
        return ans;
    }
}

Measured memory_bytes: 33236
N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))
B = list(map(int, input().rstrip().split()))
C = list(map(int, input().rstrip().split()))

A.sort()
C.sort()

def bin_search_withR(vlist, targ):
    lb = -1
    ub = len(vlist)
    while ub - lb > 1:
        mid = (lb + ub) // 2
        if vlist[mid] >= targ:
            ub = mid
        else:
            lb = mid
    return ub, lb

def bin_search_withL(vlist, targ):
    lb = -1
    ub = len(vlist)
    while ub - lb > 1:
        mid = (lb + ub) // 2
        if vlist[mid] > targ:
            ub = mid
        else:
            lb = mid
    return ub, lb

total = 0
for b in B:
    a_ub, a_lb = bin_search_withR(A, b)
    c_ub, c_lb = bin_search_withL(C, b)
    total += a_ub * (N - c_ub)

print(total)


Measured memory_bytes: 24012
#include <iostream>
#include <string>
int main() {

  std::string S;

  std::cin >> S;

  std::string s1;
  std::string s2;
  std::string s3;

  s1 = S.substr(0, 4);
  s2 = S.substr(5, 2);
  s3 = S.substr(8, 2);

  if (std::stoi(s1) <= 2019 && std::stoi(s2) <= 4 && std::stoi(s3) <= 30) {
    std::cout << "Heisei" << std::endl;
  } else {
    std::cout << "TBD" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
const ll MOD=1e9+7;
using namespace std;

int main(){
    ll N;
    cin>>N;
    if(N<=6) cout<<"1"<<endl;
    else if(N%11>6) cout<<N/11*2+2<<endl;
    else if(N%11==0) cout<<N/11*2<<endl;
    else cout<<N/11*2+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    int N ; 
    cin >> N ;
    if(N % 10 ==3){
        cout <<"bon" << endl;
    }else if(N % 10 ==0){
        cout <<"pon" << endl;
    }else if(N % 10 ==1){
        cout <<"pon" << endl;
    }else if(N % 10 ==6){
        cout <<"pon" << endl;
    }else if(N % 10 ==8){
        cout <<"pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    return 0 ;
}

 


Measured memory_bytes: 3636
/*
* All my senses intensify
* Whenever you and I, we dive
*/
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define inf ((ll)1e18)
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;
int main()
{
    // fast();
    string s;
    cin>>s;
    for(ll i = 0 ; i < s.length() ; i++ )
    	cout<<'x';
}


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

using LL = long long;
using ULL = unsigned long long;

using namespace std;

int main()
{
    string a, b, d;
    int x;

    cin >> a >> b;

    d = a + b;

    x = stoi(d);

    for (int i = 0; i <= x; ++i)
    {
        if (i * i == x)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256