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

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  int nn = s.length();
  
  for(int i = 0; i < nn; i++){
    int tmp = (int)s[i];
     
    int tt = tmp - 65 + 1;
    
    tt = tt + n;
    
    int ans = tt % 26;
    if(ans == 0) ans = 26;
    s[i] = char(ans + 65 - 1);
  }
  for(int i = 0; i < nn; i++){
    cout <<s[i];
  }
    }


Measured memory_bytes: 3604
from collections import defaultdict, deque
def main():
  N, M, *L = map(int, open(0).read().split())
  dic = defaultdict(list)
  par =  [None]*N
  cnt = [0]*(N+1)
  cnt[0] = 1
  for a,b in zip(*[iter(L)]*2):
    dic[a].append(b)
    cnt[b] += 1

  for i, m in enumerate(cnt):
    if m==0:
      q = deque([i])
      par[i-1] = 0
      break
  
  while q:
    m = q.popleft()
    for c in dic[m]:
      cnt[c] -= 1
      if cnt[c]==0:
        par[c-1] = m
        q.append(c)

  ans = '\n'.join(map(str,par))
  print(ans)
  
if __name__== '__main__':
  main()


Measured memory_bytes: 36844
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=2e5+5;

ll fac[N],inv[N];

void fill(ll N,ll p){
  fac[0]=inv[0]=1;
  for(int i=1;i<N;i++){
    fac[i]=fac[i-1]*i%p;
    inv[i]=powM(fac[i],p-2,p);
  }
}

ll c(ll a,ll b,ll p){
  if(b>a)return 0;
  return (fac[a]*inv[b]%p)*inv[a-b]%p;
}

int main()
{ 

IOS;

ll n,m;cin>>n>>m;

fill(N,M);

ll ans=1;

vl x;
ll cp=m;
for(ll i=2;i*i<=m;i++){
  if(cp%i==0){
    ll cnt=0;
    while(cp%i==0){
cp/=i;
cnt++;
    }
    x.pb(cnt);
  }
  if(cp==1)break;
}

if(cp!=1){
  x.pb(1);
}

for(auto d:x){
  (ans*=c(n+d-1,n-1,M))%=M;
}

cout<<ans;


//end_routine();

return 0;
 
 }


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

int main () {
    uint64_t N, A, B;
    cin >> N >> A >> B;
    uint64_t C = A + B;
    uint64_t ret = (N / C) * A;
    uint64_t rem = N % C;
    ret += ((rem < A) ? rem : A);
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<(f?YES:NO)<<"\n";

void solve(long long N){
    judge((( N/100 ) == ( N%10 )));
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 892
#include<iostream>

using namespace std;

int main(){

        int N, K;

        int d;
        int A[100] = {0};
        int index, sum_ppl = 0;

        cin >> N >> K;

        for (int n = 1; n <= N; n++)  A[n] = 1;

        for (int i = 1; i <= K; i++){

        cin >> d;
        for (int j = 1; j <= d; j++ ) {

        cin >> index;

        if ( A[index] == 1 ){ A[index] = 0; }

        }

        }

        for (int k = 1; k <= N ; k++){

                sum_ppl += A[k];

        }

        cout << sum_ppl << endl;

        return 0;

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, f[MAXN], dis[MAXN];
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while(!isdigit(t) && t != '-') t = getchar();
	if(t == '-')
	{
		_read(x);
		x *= -1;
		return ;
	}
	while(isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}
inline int getfa(int x)
{
	if(f[x] == x)
		return x;
	int fx = getfa(f[x]);
	dis[x] ^= dis[f[x]];
	return f[x] = fx;
}
inline void merge(int u, int v)
{
	int x = getfa(u), y = getfa(v);
	if(x == y) return;
	dis[y] = (dis[v] ^ dis[u] ^ 1), f[y] = x;
}
struct T
{
	int root, head[MAXN], cnt, to[MAXN], nxt[MAXN], son[MAXN];
	inline void ae(int u, int v)
	{
		++cnt, to[cnt] = v, nxt[cnt] = head[u], head[u] = cnt;
	}
	inline void init()
	{
		for(int i = 1, fa; i <= n; ++i)
		{
			_read(fa);
			if(fa == -1)
				root = i;
			else
				ae(fa, i), ++son[fa];
		}
	}
	inline int work(int u)
	{
		vector<int> tp;
		for(int i = head[u]; i; i = nxt[i])
			tp.push_back(work(to[i]));
		if(!(son[u] & 1))
			tp.push_back(u);
		sort(tp.begin(), tp.end());
		for(int i = 1; i < tp.size(); i += 2)
			merge(tp[i], tp[i + 1]);
		return tp[0];
	}
};
T A, B;
int main()
{
	_read(n);
	A.init(), B.init();
	for(int i = 1; i <= n; ++i)
	{
		f[i] = i, dis[i] = 0;
		if((A.son[i] & 1) != (B.son[i] & 1))
		{
			puts("IMPOSSIBLE");
			return 0;
		}
	}
	puts("POSSIBLE");
	A.work(A.root), B.work(B.root);
	for(int i = 1; i <= n; ++i)
		if(!(A.son[i] & 1))
			printf("%d ", (getfa(i), dis[i]) ? +1 : -1);
		else
			printf("%d ", 0);
	return 0;
}

Measured memory_bytes: 10112
#include <iostream>
using namespace std;
typedef long long ll;
ll n, a[100100], pro[100100], ans;
const ll mod = 1000000007;

ll pow(ll x, ll y){
    if (y == 0) return 1;
    if (y % 2){
        return pow(x, y - 1) * x % mod;
    } else {
        ll l = pow(x, y / 2);
        return l * l % mod;
    }
}

int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 1; i <= n; i++) cin >> a[i];
    for (ll i = 2; i <= n; i++){
        (pro[i] = pro[i - 1] + pow(i, mod - 2)) %= mod;
    }
    for (ll i = 1; i <= n; i++){
        (ans += (a[i] * ((1 + pro[n - i + 1] + pro[i]) % mod)) % mod) %= mod;
    }
    for (ll i = 1; i <= n; i++){
        (ans *= i) %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
vector<ll> A;

int main(){
  cin>>N;
  A.resize(N);
  rep(i,N) cin>>A[i];

  ll ans=A[0];
  int mal=0,mar=0;
  for(int l=0;l<N;l++){
      ll plus=0;
      for(int r=l;r<N;r+=2){
          ll res=A[r]+plus;
          if(l<r) res+=A[l];

          if(ans<res){
              ans=res;
              mal=l;
              mar=r;
          }
          if(l<r&&A[r]>0) plus+=A[r];
      }
  }

  vector<ll> B;
  for(int i=mal;i<=mar;i++) B.push_back(A[i]);

  vector<int> res;
  for(int i=N-1;i>mar;i--) res.push_back(i);
  for(int i=mal-1;i>=0;i--) res.push_back(0);

  int now=1;
  int n=B.size();
  while(now<n){
      if(now+1==n-1||B[now+1]>=0){
          res.push_back(1);
          now+=2;
      }else{
          res.push_back(2);
          now+=2;
      }
  }

  cout<<ans<<endl;
  cout<<(int)res.size()<<endl;
  for(int i=0;i<res.size();i++) cout<<res[i]+1<<endl;


  return 0;
}


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

const long long int INF = 1e18L +5 ;
int main()
{
	int n,W;
	cin >>n>>W;
	vector<vector<int> > v(n+1,vector<int>(2));
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>v[i][0]>>v[i][1];
		sum+=v[i][1];
	}

	vector<long long int> dp(sum+1,INF);
	for(int item=0;item<=n;item++)
	{
		dp[0]=0;
		for (int val = sum; val>=0 ;--val)
		{
			if (val>=v[item][1])
			{
				dp[val] = min(dp[val],dp[val-v[item][1]]+v[item][0]);
			}		
		}
	}
	long long int ans=0;
	for (int i=0;i<sum+1;i++)
	{
		if(dp[i] <= W)
			ans = max(ans,(long long int)i);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>



int main(){

	char N,M;

	std::cin >> N >> M;

	if(N<M){
	std::cout << "<" << std::endl;

	}else if(N==M){
	std::cout << "=" << std::endl;
	}else{
	std::cout << ">" << std::endl;
	}return 0;

} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<string> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int n = in();
    vint L = input_to_vector(n);
    sort(all(L));
    int ans = 0;
    rep(i, n-2){
        FOR(j, i+1, n-1){
            FOR(k, j+1, n){
                int a = L[i], b = L[j], c = L[k];
                if (a < b + c and b < a + c and c < a + b)
                    ans++;
            }
        }
    }
    print(ans);
}

Measured memory_bytes: 256
/*
 * main.cpp
 *
 *  Created on: 2020/04/08
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

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

	int x[N];
	for(int i = 0; i < N; i++){
		cin >> x[i];
	}

	int ans = 0;
	int A_leng, B_leng;
	for(int i = 0; i < N; i++){
		A_leng = x[i];
		B_leng = abs(x[i] - K);
		if(A_leng < B_leng){
			ans += A_leng * 2;
		}else{
			ans += B_leng * 2;
		}
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
#define N 3010
using namespace std;
ll dp[N][N], A[N];
ll fun(int a, int b){
	if(a > b)
		return 0;
	if(dp[a][b] != -1)
		return dp[a][b];
	ll maxi = -1e18;
	maxi = max(maxi, A[a] + min(fun(a + 2, b), fun(a + 1, b - 1)));
	maxi = max(maxi, A[b] + min(fun(a + 1, b - 1), fun(a, b - 2)));
	return dp[a][b] = maxi;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	ll sumi = 0;
	for(int i = 0; i < n; i++){
		cin >> A[i];
		sumi += A[i];
	}
	memset(dp, -1, sizeof(dp));
	ll x = fun(0, n - 1);
	cout << x - (sumi - x) << '\n';


}

Measured memory_bytes: 71168
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string N;
    cin >> N;
    for (auto c : N) {
        if (c == '7') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define _ << ' ' <<
#define in :
#define var auto&&
#define let const auto

#define pos first
#define life second

vector<pair<int, int>> v;

int imos[200200];
int n, d, a;

int lower_bound ( const int tar ) {
    int left = -1;
    int right = n;
    while ( right - left > 1 ) {
        int mid = (left + right) / 2;
        if ( tar <= v[mid].pos ) right = mid;
        else left = mid;
    }
    return right;
}

signed main ( ) {

    read n >> d >> a;
    v.resize(n);
    for ( var i in v ) read i.pos >> i.life;
    v.push_back({0x3f3f3f3f3f3f3f3fLL,0});
    sort(v.begin(), v.end());
    int ans = 0;
    int now = 0;
    for ( int i = 0; i < n; i++ ) {
        let pos = v[i].pos;
        now -= imos[i];
        let life = v[i].life - now*a;
        int low = lower_bound(pos+d+d);
        let cnt = (life+a-1)/a;
        if ( cnt <= 0 ) continue;
        if ( low != n && v[low].pos <= pos+d+d ) low++;
        imos[low] += cnt;
        now += cnt;
        ans += cnt;
    }

    echo ans fin;


    return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
using ll = long long;
using namespace std;
using pii = pair<int, int>;
using pdi = pair<double, int>;

int N;
int T, A;
vector<int> H;

int main() {
	cin >> N >> T >> A;
	for (int i = 0; i < N; i++)
	{
		int tmpH;
		cin >> tmpH;
		H.push_back(tmpH);
	}
	vector<pdi> s;
	for (int i = 0; i < N; i++)
	{
		const double t = abs(T - H.at(i) * 0.006 - A);
		s.push_back(pdi(t, i));
	}
	sort(s.begin(), s.end());

	cout << s.at(0).second + 1 << endl;
	return 0;
}


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

  		String str = sc.next(); 
      	int i = 0;
      	int count = 0;;
      	int count_commit = 0;
      
      	while(str.charAt(i) != 'A') i++;
     
        for(; i < str.length(); i++) {
          	count++;
        	if(str.charAt(i)=='Z'){
            	count_commit += count;
            	count = 0;
            }
        }
      
      	System.out.println(count_commit);
        
	}
}


Measured memory_bytes: 40268
n = int(input())
lis_a = list(map(int,input().split()))
dict_a = {}
ans = []

for i in range(n):
    dict_a[i] = lis_a[i]

dict_a = sorted(dict_a.items(), key=lambda x:x[1])

for i in range(n):
    ans.append(dict_a[i][0] +1)
    
print(*ans)

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

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

int father[100010];

void init(int n){
    for (int i = 1; i <= n; i++){
        father[i]=i;
    }
}

int get(int x){
    if(father[x]==x)return x;
    return father[x]=get(father[x]);
}

void merge(int x,int y){
    x=get(x);
    y=get(y);
    if(x!=y){
        father[y]=x;
    }
}

void solve() 
{
    int n,m,k;cin>>n>>m>>k;
    init(n);
    vector<int>G1[n+10];
    REP(i,m){
        int a,b;cin>>a>>b;
        merge(a,b);
        G1[a].push_back(b);
        G1[b].push_back(a);
    }
    vector<int>G2[n+10];
    REP(i,k){
        int c,d;cin>>c>>d;
        G2[c].push_back(d);
        G2[d].push_back(c);
    }
    vector<int>cnt(n+10,0);
    for (int i = 1; i <= n; i++){
        cnt[get(i)]++;
    }
    for (int i = 1; i <= n; i++){
        int dad=father[i];
        int count=0;
        REP(j,G2[i].size()){
            if(dad==father[G2[i][j]])count++;
        }
        cout<<cnt[dad]-G1[i].size()-count-1<<" ";
    }
    cout<<endl;
}

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

Measured memory_bytes: 12664
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in  range(K,N):
    print("Yes" if A[i]>A[i-K] else "No")


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

int main() {
  int64_t k;
  cin >> k;
  queue<int64_t> q;
  for(int i=1;i<10;i++){
    q.push(i);
  }
  
  for(int i=0;i<k-1;i++){
    int64_t x = q.front();
    int64_t y= x%10;
    if(y != 0) q.push(10*x+y-1);
    q.push(10*x+y);
    if(y != 9) q.push(10*x+y+1);
    q.pop();
  }
  
  int64_t y = q.front();
  
  cout << y <<endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
using namespace std;

int main(){
  int N;
  cin>>N;
  int tmp,ans;
  int v[N];
  for(int k=0;k<=N;++k){
    v[k]=0;
  }
  for(int i=1;i<=N;++i){
    tmp=i;
    for(int j=2;j<=N;++j){
      while(tmp%j==0&tmp!=1){
        tmp=tmp/j;
        v[j]+=1;
      }
      
    }
  }
  //ans 75,3-25,5-15,3-5-5;
  int ans_v[75];
  for(int i=2;i<75;++i){
    tmp=0;
    for(int k=0;k<=N;++k){
      if(v[k]>=i){
        tmp+=1;
      }
      ans_v[i]=tmp;
    }
  }
  ans=ans_v[74]+ans_v[24]*(ans_v[2]-1)+ans_v[14]*(ans_v[4]-1)+ans_v[4]*(ans_v[4]-1)*(ans_v[2]-2)/2;
  cout<<ans;
  return 0;
  }

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

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if (v <= w)
    cout << "NO" << endl;
  else if (t * abs(v - w) >= abs(a - b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

int main()
{
	int n, p = 0, cnt = 0;
	string str, key[] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	
	cin >> n;
	while (cin >> str) {
		for (char c : str) {
			n = c - '0';
			if (n) {
				cnt++;
			} else if (p != n) {
				cout << key[p][(cnt-1) % key[p].size()];
				cnt = 0;
			}
			p = n;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
const ll MOD = 10007;

struct Prim {
    int n;
    vll used;
    vector<vector<Pll>> E;

    Prim(int n): n(n), used(n, false), E(n) {};

    void add_edge(int s, int t, ll w) {
        // Undirected link
        E[s].eb(t, w);
        E[t].eb(s, w);
    }

    ll operator()() {
        used.assign(n, false);

        // {cost, node}
        priority_queue<Pll, vector<Pll>, greater<Pll>> q;
        q.emplace(0, 0);

        ll ret = 0;
        while(!q.empty()) {
            auto p = q.top(); q.pop();
            ll cost = p.fi, cur = p.se;

            if (used[cur]) continue;
            used[cur] = true;
            ret += cost;

            for (auto e: E[p.se]) {
                if(used[e.fi]) continue;
                q.emplace(e.se, e.fi);
            }
        }

        return ret;
    }
};

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int v, e; cin >> v >> e;

    Prim g(v);

    REP(i, e) {
        int s, t; ll w;
        cin >> s >> t >> w;
        g.add_edge(s, t, w);
    }

    print(g());
}


Measured memory_bytes: 10448
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
using namespace std;


int main(){
  string s;
  cin >> s;
  string tmp1 = s.substr(0, 2);
  int tmp2 = stoi(tmp1);
  tmp1 = s.substr(2, 2);
  int tmp3 = stoi(tmp1);

  if((tmp2 > 12 && (tmp3 <=12 && tmp3 >0)) ||(tmp2 == 0  && (tmp3 > 0 && tmp3 <= 12))){
    cout << "YYMM" << endl;
  } else if (((tmp2 <= 12 && tmp2 > 0) && tmp3 > 12) || ((tmp2 > 0 && tmp2 <= 12) && tmp3 == 0 )){
    cout <<"MMYY" << endl;
  } else if ((tmp2 <= 12 && tmp2 > 0) && (tmp3 <=12 && tmp3 >0)){
    cout << "AMBIGUOUS" << endl;
  } else {
    cout << "NA" << endl;
  }


}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
using namespace std;
template<class T>inline void rd(T &x) {
  x=0; int ch=getchar(),f=0;
  while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
  while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
  if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=3050;
const ll p=998244353;
ll n,s,a[maxn],f[maxn][maxn],sum[maxn];
int main()
{
  cin>>n>>s;
  rep(i,1,n) rd(a[i]);
  mst(sum,0);
  rep(i,1,n)
  {
    f[i][a[i]]=i;
    dep(j,s,1)
    {
      if(j<a[i]) continue;
      f[i][j]=(f[i][j]+sum[j-a[i]])%p;
      sum[j]=(sum[j]+f[i][j])%p;
    }
  }
  ll ans=0;
  rep(i,1,n) 
  {
    ans=(ans+f[i][s]*(n-i+1))%p;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int len = s.size();
    for(int i = 0; i < len; ++i){
        int x = (int)s[i] + n;
        if(x >= 91) x = x - 91 + 65;
        //cout << x << endl;
        cout << (char)x;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

h,w = map(int,input().split())
maze = [[False for _ in range(w)] for _ in range(h)]


for i in range(h):
    maze[i] = list(input())

#print(maze)

def bfs(x,y):
    seen = [[False for _ in range(w)] for _ in range(h)]
    dist = [[False for _ in range(w)] for _ in range(h)]
    
    if(maze[y][x] == "#"):
        return [[0]]
    
    dist[y][x] = 0
    d = deque()
    d.append(x + w*y)
    #print(d)
    while d:
        #print(d)
        base = d.popleft()
        #print(base)
        xx = base%w
        yy = base//w
        #print(*seen,sep='\n')
        #print("-------")
        if(seen[yy][xx] == True):
            continue
        else:
            seen[yy][xx] = True
        
        for px,py in [(-1,0),(1,0),(0,-1),(0,1)]:
            #print(xx+px,yy+py)
            if (0<= xx+px < w and 0<= yy+py < h):
                if(maze[yy+py][xx+px] == "." and seen[yy+py][xx+px] == False):
                    d.append(xx+px+(yy+py)*w)
                    dist[yy+py][xx+px] = dist[yy][xx] + 1
    
    return dist

#result = bfs(0,2)  

#print(*result,sep ="\n")
ans = 0
for j in range(h):
    for k in range(w):
        res = 0
        result = bfs(k,j)
        for i in result:
            res = max(max(i),res)
        ans = max(ans,res)
        


print(ans)


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

int main(int argc, char *argv[]) {
  string s;
  cin >> s;
  for(int i = 0; i < 3; i++) {
    if(s[i] == '1') {
      cout << '9';
    } else {
      cout << '1';
    }
  }
  cout << endl;
  return 0;
}

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

namespace Atc_0037
{
    class Program
    {
        static void Main(string[] args)
        {
            double a = 0.08;
            double b = 0.10;

            var s = Console.ReadLine();

            int A1 = int.Parse(s.Split(' ')[0]);
            int A2 = int.Parse(s.Split(' ')[1]);
            int A3 = int.Parse(s.Split(' ')[2]);

            List<int> ans = new List<int>();

            ans.Add(Math.Abs(A2 - A1) + Math.Abs(A3 - A2));
            ans.Add(Math.Abs(A3 - A2) + Math.Abs(A3 - A1));
            ans.Add(Math.Abs(A1 - A2) + Math.Abs(A3 - A1));

            Console.WriteLine(ans.Min());

        }
    }
}


Measured memory_bytes: 28264
/************************************************
 * Au: Hany01
 * Date: Aug 27th, 2018
 * Prob: [AGC016F] Games on DAG
 * Email: hany01dxx@gmail.com & hany01@foxmail.com
 * Inst: Yali High School
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
#define rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define x first
#define y second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define SZ(a) ((int)(a).size())
#define ALL(a) a.begin(), a.end()
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define count __builtin_popcount
#define y1 wozenmezhemecaia

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read() {
	static int _, __; static char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

const int maxn = 15, maxs = 1 << 15, MOD = 1e9 + 7;

int n, m, To[maxn], f[maxs];

inline int ad(int x, int y) { if ((x += y) >= MOD) return x - MOD; return x; }
#define chk(x) (!((x) & 3) || ((x) & 3) == 3)

int main()
{
#ifdef hany01
	freopen("agc016f.in", "r", stdin);
	freopen("agc016f.out", "w", stdout);
#endif

	static int uu, vv;

	n = read(), m = read();
	For(i, 1, m) uu = read() - 1, vv = read() - 1, To[uu] |= (1 << vv);

	f[0] = 1;
	For(A, 1, (1 << n) - 1) if (chk(A))
		for (int B = A, res, C; B; (-- B) &= A) if (chk(B)) {
			res = f[C = A ^ B];
			rep(i, n)
				if (B >> i & 1) res = (LL)res * (1 << count(To[i] & C)) % MOD;
				else if (C >> i & 1) res = (LL)res * ((1 << count(To[i] & B)) - 1) % MOD;
			f[A] = ad(f[A], res);
		}
	printf("%d\n", ad((1ll << (m >> 1)) % MOD * ((1ll << (m - (m >> 1))) % MOD) % MOD, MOD - f[(1 << n) - 1]));

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

struct Cube
{
	int f[6];
	Cube(){}

	void roll(int i,int j,int k,int l)
	{
		int t = f[i];
		f[i] = f[j];
		f[j] = f[k];
		f[k] = f[l];
		f[l] = t;
	}

	void roll_z() { roll(1,2,4,3); }
	void roll_y() { roll(0,2,5,3); }
	void roll_x() { roll(0,1,5,4); }

	void move(char c)
	{
		if(c == 'E') rep(i,3) roll_y();
		else if(c == 'W') roll_y();
		else if(c == 'N') roll_x();
		else if(c == 'S') rep(i,3) roll_x();
	}
};

bool equal_1(Cube c1,Cube c2)
{
	rep(i,6)
	{
		if(c1.f[i] != c2.f[i]) return false;
	}
	return true;
}

bool equal_2(Cube c1,Cube c2)
{
	rep(i,6)
	{
		rep(j,4)
		{
			if(equal_1(c1,c2)) return true;
			c1.roll_z();
		}
		if(i%2 == 0)
		{
			c1.roll_y();
		}
		else
		{
			c1.roll_x();
		}
	}
	return false;
}

int main()
{
	Cube c[100];

	int n;
	cin >> n;

	rep(i,n)
	{
		rep(j,6)
		{
			cin >> c[i].f[j];
		}
	}

	bool flag = true;
	rep(i,n-1)
	{
		REP(j,i+1,n)
		{
			if(equal_2(c[i],c[j]))
			{
				flag = false;
			}
		}
	}

	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int N, M;

const int MOD = 1000000007;
const int MAX = 2e5;

vector<long long> fac(MAX);
vector<long long> finv(MAX);

long long power_MOD(int a, int b){
  long long ans = 1;
  long long ab = a;
  while(b > 0){
    if(b&1) ans = (ans * ab) % MOD;
    ab = (ab * ab) % MOD;
    b = (b >> 1);
  }
  return ans;
}

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

int comb_MOD(int n, int r){
  if(n < r) return 0;
  if(n < 0 || r < 0) return 0;
  if(r == 0) return 1;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

int main(){
  
  comb_ini();
  cin >> N >> M;
  vector<int> fact;
  
  for(int i = 2; i <= M; i++){
    int pow = 0;
    while(M % i == 0) {
      M /= i;
      pow++;
    }
    if(pow) fact.push_back(pow);
    if(M == 1) break;
  }
  
  long long ans = 1;
  for(int i = 0; i < fact.size(); i++){
    ans *= comb_MOD(N + fact[i] - 1, N - 1);
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*300000
count=0
type=0
for i in range(N):
    B[A[i]]+=1

B.sort()

for i in range(len(B)):
    if B[i]!=0:
        type+=1
K=type-K
for i in range(len(B)):
    if K<=0:
        break
    if B[i]!=0:
        count+=B[i]
        K-=1

print(count)


Measured memory_bytes: 24748
#include<bits/stdc++.h>
using namespace std;
int main(){
	set<long>s;
	bool b=true;
	int a;
	cin>>a;
	int p;
	cin>>p;
	s.insert(p);
	for(int i=1;i<a;i++)
	{
		int len1=s.size();
		cin>>p;
		s.insert(p);
		int len2=s.size();
		if(len1==len2)
		b=false;
	}
	if(b)
	cout<<"YES";
	else
	cout<<"NO";
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
	const string X = "CODEFESTIVAL2016";

	string S;
	cin >> S;
	int count{};
	REP( i, (int)S.size() )
	{
		if( S[i] != X[i ])
		{
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
 
int main(void)
{
  int N,i;
  char S[100];
    
  scanf("%d\n",&N);
  scanf("%s\n",S);
  
  if(N%2)
  {
    printf("No");
    return 0;
  }
  
  for(i=0;i<(N/2);i++)
  {
    if(S[i]!=S[((N/2)+i)])
    {
      printf("No");
      return 0;      
    }   
    
  }
    
  printf("Yes");
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();

    for (int i = x; ; i++) {
      if (nextPrime(i)) {
        System.out.println(i);
        break;
      }
    }
  }

  public static boolean nextPrime(int x) {
    for (int i = 2; i < x; i++) {
      if (x % i == 0){
        return false;
      }
    }
    return true;
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using Graph = vector<vector<int>>;
using ll = long long;


int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
    if(A.size()==n+1){
        int now=0;
        rep(i,q){
            if(A[b[i]] - A[a[i]] == c[i]){
                now+=d[i];
            }
        }
        ans=max(now,ans);
        return;
    }

    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
    return;
}

int main() {
    cin>>n>>m>>q;
    a=b=c=d=vector<int> (q);
    ans=0;
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(vector<int> (1,1));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
n, m = [int(i) for i in input().split()]
ac = [0] * n
wa = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p)
    if ac[p-1] == 0:
        if s == "AC":
            ac[p-1] = 1
        elif s == "WA":
            wa[p-1] += 1

wa_sum = 0
for i in range(n):
    if ac[i] >= 1: wa_sum += wa[i]

print(sum(ac), wa_sum)

Measured memory_bytes: 4724
#include"iostream"
#include"vector"
using namespace std;

int main()
{
  int n;
  vector<int>list;
  int w=0;
  cin>>n;
  vector<vector<int> > A(n,vector<int>(n));
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
        {
          cin>>A[i][j];
        }
    }
  list.push_back(0);
  int mini=2001;
  while(list.size()<n)
    {
      mini=2001;
      int k,l;
      for(int i=0;i<list.size();i++)
        {
          for(int j=0;j<n;j++)
            {
              if(A[list[i]][j]>=0)
                {
                  if(A[list[i]][j]<mini)
                    {
                      int f=1;
                      for(int s=0;s<list.size();s++)
                        {
                          if(j==list[s])
                            {
                              f=0;
                              break;
                            }
                        }
                      if(f)
                        {
                          mini=A[list[i]][j];
                          k=j;
                          l=list[i];
                        }
                    }
                }
            }
        }
      list.push_back(k);
      w+=mini;
    }
  cout<<w<<endl;
  return 0;
}


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

map<string, string> change;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	change["Sunny"] = "Cloudy";
	change["Cloudy"] = "Rainy";
	change["Rainy"] = "Sunny";
	string s;
	cin >> s;
	cout << change[s] << '\n';
	return 0;
}	

Measured memory_bytes: 256
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
## math
DIVC = lambda x, y: -(-x//y)
DIVF = lambda x, y: x//y

def main():
    a,b,c,x = [II() for _ in range(4)]
    cnt = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if i*500+j*100+k*50 == x: cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
x = int(input())
y = input()
y = list(map(int, y.split()))
r = sorted(y)
c = 0
while y != r:
    for i, j in enumerate(y[:-1]):
        if y[i] > y[i+1]:
            y[i], y[i+1] = y[i+1], y[i]
            c += 1
print(*y)
print(c)

Measured memory_bytes: 7704
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int x;
        int ans;
        fori(i,5) {
            cin>>x;
            if(!x) ans = i+1;
        }
        cout<<ans;
    }
    
    return 0;
}

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

int main() {
	int a, b, N;
	cin >> a >> b;
	cin >> N;
	if (N == 0){
		cout << '0' << endl;
		return 0;
	}
	vector<int> s(N);
	vector<int> f(N);
	for (int i = 0; i < N; i++)
		cin >> s.at(i) >> f.at(i);

	for (int i = 0; i < N; i++){
		if (s.at(i) < a && a < f.at(i) || s.at(i) < b && b < f.at(i) || a < s.at(i) && s.at(i) < b || a < f.at(i) && f.at(i) < b || a == s.at(i) && b == f.at(i)){
			cout << '1' << endl;
			break;
		}
		if (i == N - 1)
			cout << '0' << endl;
	}
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, a, size, ans = 0;
	vector<int> p2;

	for (int i = 2; i <= 1000000000; i *= 2) p2.push_back(i);

	size = p2.size();

	cin >> N;
	rep(i, N) {
		cin >> a;

		rrep(i, size) {
			if (a % p2[i] == 0) {
				ans += i + 1;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");
        String arr03[] = mylist.get(2).split(" ");
        String arr04[] = mylist.get(3).split(" ");

        int a11 = Integer.valueOf(arr01[0]);
        int a12 = Integer.valueOf(arr01[1]);
        int a13 = Integer.valueOf(arr01[2]);

        int a21 = Integer.valueOf(arr02[0]);
        int a22 = Integer.valueOf(arr02[1]);
        int a23 = Integer.valueOf(arr02[2]);

        int a31 = Integer.valueOf(arr03[0]);
        int a32 = Integer.valueOf(arr03[1]);
        int a33 = Integer.valueOf(arr03[2]);

        int n = Integer.valueOf(arr04[0]);

        int array_data[][] = { { a11, a12, a13 }, { a21, a22, a23 }, { a31, a32, a33 } };
        Boolean array_result[][] = { { false, false, false }, { false, false, false }, { false, false, false } };

        for (int i = 4; i < 4 + n; i++) {
            String arr_temp[] = mylist.get(i).split(" ");
            int num = Integer.valueOf(arr_temp[0]);

            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (array_data[j][k] == num) {
                        array_result[j][k] = true;
                    }
                }
            }
        }

        if (array_result[0][0] && array_result[0][1] && array_result[0][2]
                ||
                array_result[1][0] && array_result[1][1] && array_result[1][2]
                ||
                array_result[2][0] && array_result[2][1] && array_result[2][2]
                ||
                array_result[0][0] && array_result[1][0] && array_result[2][0]
                ||
                array_result[0][1] && array_result[1][1] && array_result[2][1]
                ||
                array_result[0][2] && array_result[1][2] && array_result[2][2]
                ||
                array_result[0][0] && array_result[1][1] && array_result[2][2]
                ||
                array_result[2][0] && array_result[1][1] && array_result[0][2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


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

string makeCode(string &s, int k){
  set<char> vowel = {'a', 'i', 'u', 'e', 'o'};
  string res = s.substr(0, 1);
  for (int i = 0; i < s.length() - 1; i++) {
    if(vowel.find(s[i]) == vowel.end())continue;
    res += s[i + 1];
  }
  return res.substr(0, k);
}

int main(){
  int n;
  while(std::cin >> n, n){
    vector<string> s(n);
    int maxi = 0;
    for (int i = 0; i < n; i++) {
      std::cin >> s[i];
      maxi = max(maxi, (int)s[i].length());
    }
    int k = 0;
    bool f = true;
    while(f and k <= maxi){
      k++;
      f = false;
      set<string> ss;
      for (int i = 0; i < n; i++) {
        string code = makeCode(s[i], k);
        //std::cout << code << std::endl;
        if(ss.find(code) != ss.end())f = true;
        ss.insert(code);
      }
    }
    if(k <= maxi)std::cout << k << std::endl;
    else std::cout << -1 << std::endl;
  }
  return 0;
}

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

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int k;cin>>k;
  ll sum=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        sum+=gcd(gcd(i,j),l);
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}


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

int main()
{
    map<int,int>mp;
    int n,i,a;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>a;mp.insert(make_pair(a,i));
    }
    map<int,int>::iterator it;
    it=mp.begin();cout<<it->second;

    for(it=mp.find(2); it!=mp.end(); it++)
    {
        cout<<" "<<it->second;

    }
    cout<<endl;



    return 0;
}


Measured memory_bytes: 5504
#include <stdio.h>

int main(void)
{
	char c;
	
	while (scanf("%c", &c)){
		if (c == '\n'){
			break;
		}
		if ('a' <= c && c <= 'z'){
			printf("%c", c - 0x20);
		}
		else {
			printf("%c", c);
		}
	}
	
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 524
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<int,int> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=1e9;

int main(){
    string s;cin>>s;
    int n=(int)s.size();
    vector<int> cnt(n,0);
    int c=0;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='C'){
            if(i>0&&s[i-1]=='B'){
                c++;
                i--;
            }else c=0;
        }else if(s[i]=='A') cnt[i]=c;
        else c=0;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=cnt[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4448
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a != 1 && b != 1) {
    cout << 1 << endl;
  }
  if (a != 2 && b != 2) {
    cout << 2 << endl;
  }
  if (a != 3 && b != 3) {
    cout << 3 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

// int n;
// cin >> n;
// vector<int> v(n);
// REP(i, n) {
//   cin >> v[i];
// }
// cout << n << endl;

int main() {
    float n;
    cin >> n;
    vector<float> a(n);
    REP(i, n) {
    cin >> a[i];
    }
    float sita = 0;
    REP(i, n) {
        sita += 1 / a[i];
    }
    cout << 1/sita << endl;
}

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

using namespace std;
typedef long long ll;
int main()
{
    set<ll>s;
    int n;cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;cin>>x;
         if(s.count(x)) {
            cout<<"NO"<<endl;
            return 0;
         }
         s.insert(x);
    }

    cout<<"YES"<<endl;
    return 0;
}


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

int main() {
  int N, K, x;
  cin >> N >> K;

  int count = 0;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x > K / 2) {
      count += 2*(K - x);
    } else {
      count += 2 * x;
    }
  }
  cout << count << endl;
}

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

typedef int value_type; 
value_type med3(value_type x, value_type y, value_type z) {
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right){
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); 
        while (1) { 
            while (a[i] < pivot) i++; 
            while (pivot < a[j]) j--; 
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; 
            i++; j--;
        }
        quicksort(a, left, i - 1);  
        quicksort(a, j + 1, right); 
    }
}
int main(){
    int N, K, h[100001];
    scanf("%d %d\n", &N, &K);
    for(int i = 0; i < N; i++){
        scanf("%d\n", &h[i]);
    }
    quicksort(h, 0, N-1);
    int min = 1000000000;
    for(int i = 0; i <= N - K; i++){
        if(h[i+K-1]-h[i] < min){
            min = h[i+K-1]-h[i];
        }
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 640