akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() { 
  int a;
  int b;
    
  cin >> a >> b;
  
  if (a * b % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }  
}



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

int main(){
  int X, A, B;
  cin >> X >> A >> B;

  int ans = A - B;
  X = -X;

  if (ans>=0){
    cout << "delicious" << endl;
  }
  else if (ans<0 && ans>=X){
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
ll a[100005];
int main()
{ 
ios_base::sync_with_stdio(false);

cin.tie(NULL);
//freopen("input.txt", "r", stdin);
//freopen("output.txt","w",stdout);
ll n;
cin>>n;
ll ans=0;
forn(i,n)
{
   ll x;
   cin>>x;
   while(x%2==0)
   {
   	x/=2;
   	ans++;
   }
}
cout<<ans;
return 0;
}       

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
mod = int(1e+9) + 7
def extgcd(a, b):
  if b == 0:
    return 1, 0
  else:
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
      x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
      k, l = l, k % l
    return x, y
def inved(x):
  a, b = extgcd(x, mod)
  return a % mod

fact = [1 for i in range(8001)]
finv = [0 for i in range(8001)]
for i in range(8000):
  fact[i+1] = (fact[i] * (i + 1)) % mod
finv[8000] = inved(fact[8000])
for i in range(8000, 0, -1):
  finv[i-1] = (finv[i] * i) % mod
Y = 0
for i in range(N):
  Y += (fact[2*(A[i][0]+A[i][1])]*finv[2*A[i][0]]*finv[2*A[i][1]])%mod
  Y %= mod
B = [[] for i in range(4001)]
for i in A:
  B[i[0]+i[1]].append(2000-i[0])
f = np.zeros(2000+2000+1,np.int64)
for b in B[::-1]:
  f[1:] += f[:-1].copy()
  np.add.at(f,b,1)
  f %= mod
X = (f * f[::-1] % mod).sum() % mod

print(((X-Y) * inved(2))%mod)

Measured memory_bytes: 71596
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue>
#include <vector>

using namespace std;

#define REP(I,A,B) for(int I = (A); I < (B); ++I)
#define REPN(I,A,B) for(int I = (A); I > (B); --I)
#define MAX(A,B) ((A) > (B) ? (A) : (B));

int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

int rb[200000];
int lb[200000];

int main () {
	const char * str= "CODEFESTIVAL2016";
	char * x = new char[20];
	cin >> x;
	int cnt = 0;
	REP(i, 0, 16) {
		if (x[i] != str[i])
			cnt++;
	}

	cout << cnt;
	return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#define INF 1000000000
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  map<st, int> S;
  rep(i, N){
    st a;
    ci(a);
    S[a] ++;
  }
  int c = 0;
  each(i, S){
    c++;
  }
  cout << c << endl;
}


Measured memory_bytes: 19260
import sys
y = input().split()
H = int(y[0])
W = int(y[1])
x = list()
for i in range(H):
    x.append(input())

flagH = list()
flagW = list()
for i in range(H):
    flagH.append(False)
for j in range(W):
    flagW.append(False)

for i in range(H):
    for j in range(W):
        if x[i][j] == "#":
            flagH[i] = True
            flagW[j] = True

for i in range(H):
    for j in range(W):
        if flagH[i] and flagW[j]:
            sys.stdout.write(x[i][j])
    if flagH[i]:
        print()

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
bool dic[13][1 << (2 * 12)];
int main()
{
    int n;
    cin >> n;

    char cmd[7], s[13];
    int p;
    for (int i = 0; i < n; i++)
    {
        scanf("%s %s", cmd, s);
        p = 0;
        for (int j = 0; j < strlen(s); j++)
        {
            p *= 4;
            if (s[j] == 'A')
                p += 0;
            if (s[j] == 'C')
                p += 1;
            if (s[j] == 'G')
                p += 2;
            if (s[j] == 'T')
                p += 3;
        }
        if (cmd[0] == 'i')
            dic[strlen(s)][p] = 1;
        else
            cout << (dic[strlen(s)][p] ? "yes" : "no") << endl;
    }
}


Measured memory_bytes: 4524
k=int(input())
t=[2]+[3]*8+[2]
g=[[1]+[0for i in range(9)]for j in range(100)]
def f(x,y):
    if g[x][y]!=0:
        return g[x][y]
    else:
        p=0
        for i in range(x-1,x+2):
            if 0<=i<10:
                p+=f(i,y-1)
        g[x][y]=p
        return p
c=0
for i in range(10):
    for j in range(1,10):
        if c+f(j,i)>=k:
            p=str(j)
            po=j
            for h in range(i-1,-1,-1):
                for w in range(po-1,po+2):
                    if 0<=w<10:
                        if c+f(w,h)>=k:
                            p+=str(w)
                            po=w
                            break
                        c+=f(w,h)
            print(p)
            exit()
        c+=f(j,i)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define intt long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define ii pair<intt,intt>
using namespace std;

int pref[200004];
int visit[200004];
int main()
{
    int n;

    int i;

    string s;
    cin>>s;
    n=s.length();
     bool ok=0;
     int idr=-1,idl=-1;
     int cntr=0,cntl=0;
     for(i=0;i<n;i++)
        cntr+=(s[i]=='R'),cntl+=(s[i]=='L');
    for(i=0;i<n;i++)
    {
        if(visit[i])
         continue;
        int j=i;
        int have=0;
        while(s[j]=='R')
            visit[j]=1,j++,have++;
        int f=j;
        while(s[f]=='L'&&f<n)
           visit[f]=1,f++,have++;
                    f--;
        if(have%2==0)
         pref[j-1]=have/2,pref[j]=have/2;

        else
        {
            for(int k=i;k<=j;k++)
            {
                if((j-k)%2==0)
                 pref[j]++;
                else
                pref[j-1]++;

            }
            for(int k=j+1;k<=f;k++)
            {
                if((k-j)%2==0)
                    pref[j]++;
                else
                    pref[j-1]++;
            }
        }
    }
    for(i=0;i<n;i++)
        cout<<pref[i]<<" ";

    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<queue>
#include<cmath>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007
#define MAX_V 2*100000+10

using namespace std;



bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second < right.second;
}
using namespace std;
lli k, n, m, e;


int main() {
	cin >> n;
	vector < lli>vec(n);
	
	cin >> vec[0];
	vec[0]--;
	rep1(i, n - 1) {
		cin >> vec[i];
		if (vec[i] > vec[i - 1])vec[i]--;
		if (vec[i] - vec[i - 1] < 0) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	
}




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

using namespace std;

int f(int x) {
    int cnt = 0;
    while (!(x % 2)) {
        cnt++;
        x /= 2;
    }
    return cnt;
}

int main() {
    int n, t, M = INT32_MAX;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> t;
        v.push_back(t);
    }
    for (int i = 0; i < v.size(); i++) {
        int temp = f(v[i]);
        if (temp < M)
            M = temp;
    }
    cout << M << endl;
}

Measured memory_bytes: 256
# ABC137D - Summer Vacation
from heapq import heappop, heappush

heappop_max = lambda heap: -heappop(heap)
heappush_max = lambda heap, x: heappush(heap, -x)


def main():
    N, M = map(int, input().split())
    all_jobs = tuple(tuple(map(int, input().split())) for _ in range(N))
    available_jobs = [[] for _ in range(M + 1)]
    for waiting_days, reward in all_jobs:
        if waiting_days <= M:
            available_jobs[waiting_days].append(reward)
    heap = []
    max_rewards = 0
    for jobs in available_jobs[1:]:
        for job in jobs:
            heappush_max(heap, job)
        if heap:
            max_rewards += heappop_max(heap)
    print(max_rewards)


if __name__ == "__main__":
    main()


Measured memory_bytes: 29452
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	string s, t;
	cin >> s >> t;
	s += t;
	int p = stoi(s);
	int x = sqrt(p);
	if (x * x == p) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
 	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  int path[n] = {0};
  int a, b;
  for(int i = 0; i < m; i++) {
    cin >> a >> b;
    path[a-1]++;
    path[b-1]++;
  }
  for(int i = 0; i < n; i++) {
    cout << path[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
	unsigned long long int n,m,r=0;
	scanf("%llu%llu",&n,&m);
	if(m <= 2*n){printf("%llu\n",m/2);}
	else{r+=n;m-=(2*n);r+=(m/4);printf("%llu\n",r);}
	return 0;
}

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

int main() {
    int N, ans=0;
    string s, t;
    bool flag=true;
    cin >> s;
    cin >> t;

    for(int i=0; i<s.size(); i++){
	if(s[i]!=t[i])
	    flag=false;
	
    }

    cout << (flag ? "Yes": "No") << endl;
} 




Measured memory_bytes: 3624
loop do
    switch_num, light_num, ope_num = gets.split.map(&:to_i)
    break if switch_num == 0
    alph = (?0..?9).to_a + (?A..?Z).to_a
    alph = alph[0..switch_num-1]

    candidates = (1..light_num).map { (1 << switch_num) - 1 }
    switch_state = 0
    ope_num.times do
        ope, light_state = gets.split.map{|s| s.to_i(2)}
        switch_state ^= ope
        (0..light_num-1).each do |i|
            if light_state[i] == 1
                candidates[i] &= switch_state
            else
                candidates[i] -= candidates[i] & switch_state
            end
        end
    end

    a = (0..light_num-1).map do |i|
        x = candidates[i]
        if x & (x - 1) == 0
            alph[- Math.log2(x).to_i - 1]
        else
            ??
        end
    end
    puts a.reverse.join
end

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

const int NRB = 60;
const int NMAX = 3e5 + 5;
const int MOD = 1e9 + 7;

int n;
int A[NMAX];
int P[NRB][NMAX];

void precalc() {
    for (int i = n; i >= 1; i--) {
        for (int bit = 0; bit < NRB; bit++) {
            P[bit][i] = P[bit][i + 1] + ((A[i] >> bit) & 1LL);
        }
    }
}

inline void add(long long &x, long long a) {
    x = (x + a) % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

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

    /*cout << P[0][n];
    return 0;*/

    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        long long aici = 0;
        for (int bit = 0; bit < NRB; bit++) {
            if (A[i] & (1LL << bit)) {
                add(aici, 1LL * (n - i - P[bit][i + 1]) * ((1LL << bit) % MOD) % MOD);
            }
            else {
                add(aici, 1LL * P[bit][i + 1] * ((1LL << bit) % MOD) % MOD);
            }
        }

        add(ans, aici);
        //cout << aici << " ";
    }

    cout << ans;


    return 0;
}

Measured memory_bytes: 143232
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100
#define MMAX 5001
int X, Y, Z, A[MAX], V[MAX], E[MAX];
void compute(){
float P[MMAX][MAX];
for ( int i = 0; i < MMAX; i++ ){
for ( int j = 0; j <= Y; j++ ) P[i][j] = 0;
}
P[0][0] = 1.0;
int np, nv;
for ( int j = 0; j < Y; j++ ){
for ( int i = 0; i < MMAX; i++ ){
if ( P[i][j] == 0 ) continue;
for ( int k = 0; k < X; k++ ){
np = min(Y, j + V[k]);
nv = i;
if ( E[np] == 1 ) {
np = min(Y, np + A[np]);
} else if ( E[np] == 2 ){
nv = i + A[np];
} else if ( E[np] == 3 ){
nv = max(0, i - A[np]);
}
P[nv][np] += P[i][j]*(1.0/X);
}
}
}
double ex = 0;
for ( int i = 0; i < MMAX; i++ ) ex += P[i][Y]*i;
cout << (int)ex << endl;
}
main(){
int n, e, a;
while(1){
cin >> X >> Y >> Z;
if ( X == 0 && Y == 0 && Z == 0 ) break;
for ( int i = 0; i <= Y; i++ ) A[i] = E[i] = 0;
for ( int i = 0; i < X; i++ ) cin >> V[i];
for ( int i = 0; i < Z; i++ ){
cin >> n >> e >> a;
A[n] = a;
E[n] = e;
}
compute();
}
}

Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }

int main(void) {
	int n; cin >> n;
	char str[105]; cin >> str;
	if (n % 2 != 0){
		cout << "No" << endl;
	return 0;
}
	char x[105];
	rep(i, n / 2) {
		x[i] = str[i];
	}
	bool y = 1;
	rep(i, n / 2) {
		if (x[i]!=str[i+n/2]) {
			y = 0;
			break;
		}
	}
	if (y)cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}



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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

string s;
int n,q;
int l[101010],r[101010];
int rec,ans;
int S[101010];
int main(){
  cin >> n >> q;
  cin >> s;
  S[0] = 0;
  for(int i = 1;i < n; i++){
    S[i] = S[i-1];
    if(s[i]=='C'&&s[i-1]=='A') S[i] = S[i-1]+1;
  }
  for(int i = 0; i < q; i++){
    cin >> l[i] >> r[i];
    cout << S[r[i]-1] - S[l[i]-1] <<endl;
  }
  return 0;
}

Measured memory_bytes: 2304
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  ll K;
  cin >> K;
  queue<ll> q;
  for(int i = 1;i < 10;i++){
    q.push(i);
  }
  while(K>0){
    K--;
    ll num = q.front();
    if(K == 0){
      cout << num << endl;
      return 0;
    }
    ll num_iti = num%10;
    for(ll i = -1;i <= 1;i++){
      if(num_iti + i >= 0 && num_iti + i <= 9)q.push(num*10 + num_iti + i);
    }
    q.pop();
  }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>

int main()
{
    std::size_t N;
    std::cin >> N;

    std::vector<std::vector<std::size_t>> buka(N);
    for(std::size_t i=1; i<N; ++i)
    {
        std::size_t joshi;
        std::cin >> joshi;
        joshi -= 1;
        buka.at(joshi).push_back(i);
    }

    for(const auto& b : buka)
    {
        std::cout << b.size() << std::endl;
    }

    return 0;


}


Measured memory_bytes: 13980
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n,k,q,i=0;
    cin>>n>>k>>q;
    vector <int> a(n+1,k);
    //for (int &i: a) cout << i << " ";
    while (i++<q){
      int x; cin>>x;
      a[x]++;
    }
    for (int i=1;i<=n;i++){
        if (a[i]-q>0) puts("Yes");
        else puts("No");
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void){
	int a,b,d,r;
	double f;

	scanf("%d %d",&a,&b);

	d=a/b;
	r=a%b;
	f=(double)a/b;

	printf("%d %d %.5lf\n",d,r,f);

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	ll A, B, M;
	cin >> A >> B >> M;
	vector<ll> a(A);
	vector<ll> b(B);
	vector<ll> x(M);
	vector<ll> y(M);
	vector<ll> c(M);
	rep(i, A) {
		cin >> a[i];
	}
	rep(i, B) {
		cin >> b[i];
	}
	rep(i, M) {
		cin >> x[i] >> y[i] >> c[i];
	}
	ll res = INF;
	rep(i, M) {
		ll sum = a[x[i]-1] + b[y[i]-1] - c[i];
		chmin(res, sum);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	chmin(res, a[0] + b[0]);
	cout << res << endl;
}

Measured memory_bytes: 4224
#include <iostream>

using namespace std;

typedef long long ll;

ll mod = 1000000007;

ll *Prime_Factorization(ll N, ll mod) {
    ll *fac = new ll[N+1];
    for (ll i = 2; i <= N; i++)
        fac[i] = 0;
    ll N_ = N;

    for (ll i = 2; i*i <= N; i++) {
        while (N_ % i == 0) {
            fac[i]++;
            N_ /= i;
        }
    }
    if (N_ > 1)
        fac[N_]++;
    return fac;
}

int main() {
    ll N;  cin >> N;

    ll ans = 1;
    ll *cnt = new ll[N+1];
    for (ll i = 0; i <= N; i++)
        cnt[i] = 0;

    for (ll n = 2; n <= N; n++) {
        ll *fac = Prime_Factorization(n, mod);
        for (ll i = 2; i <= n; i++) {
            cnt[i] += fac[i];
        }
    }

    for (ll i = 2; i <= N; i++) {
        ans *= cnt[i]+1;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4224
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define endl '\n';
#define all(v) ((v).begin()), ((v).end())
#define sz(s)               (int)s.size()
#define Ceil(x,y)             ((x+y-1)/y)
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define vi                    vector<int>
#define pii                 pair<int,int>
#define fx(n)           fixed<<setprecision(n)
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define forr(i, n) for (int i = 0; i < int(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef double dl;
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 1e7 + 5, MOD = 1e9 + 7;
using namespace std;
void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); }
int main()
{
	fast();
	int n;
	cin>>n;
	map<string,int>mp;
	string s;
	while(n--)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
int INF = 1000000000;
int prim(int v, vector< vector< pair<int,int> > > G){
  //v: ????????°, G: ??£??\?????????
  priority_queue< pair<int, int> > wait;
  int result = 0;
  vector<bool> connected(v,false);
  vector<int> cost(v,INF);
  wait.push(make_pair(0, 0));
  while(!wait.empty()){
    int nowpoint = wait.top().second;
    int nowcost = -wait.top().first;
    wait.pop();
    if(!connected[nowpoint]){
      result += nowcost;
      connected[nowpoint] = true;
      for(int i = 0; i < G[nowpoint].size(); ++i){
	int nextpoint = G[nowpoint][i].second;
	int nextcost = G[nowpoint][i].first;
	if(nextcost < cost[nextpoint]){
	  wait.push(make_pair(-nextcost, nextpoint));
	  cost[nextpoint] = nextcost;
	}
      }
    }
  }
  return result;
}
int main(){
  int V, E, s, t, w;
  cin >> V >> E;
  vector< vector<pii> > G(V);
  for(int i = 0; i < E; ++i){
    cin >> s >> t >> w;
    G[s].push_back(pii(w,t));
    G[t].push_back(pii(w,s));
  }
  cout << prim(V,G) << endl;
  return 0;
}

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

int main()
{
    double a,b;
    scanf("%lf%lf",&a,&b);

    int temp = ceil((100.0*a)/8.00);
    int ct=0;

    while(1)
    {
        int m = floor((10.0*temp)/100.0);
        if(m==b)
        {
            ct=1;
            break;
        }
        else
        {
            temp+=1;
            int q = floor((8.0*temp)/100.0);
            if(q!=a)
                break;

        }
    }
    if(ct==0)
        printf("-1\n");
    else
        printf("%d\n",temp);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,m,max1,max2;
	string a;
	int x[26],y[26];
	cin>>m;
	cin>>a;
	for(int i=0;i<26;i++)
	{
		x[i]=0;
		y[i]=0;
	}
	for(int i=0;i<m;i++)
	{
		y[a[i]-97]=y[a[i]-97]+1;
	}
	max1=0;
	for(int i=0;i<m;i++)
	{
		y[a[i]-97]=y[a[i]-97]-1;
		x[a[i]-97]=x[a[i]-97]+1;
		max2=0;
		for(int j=0;j<26;j++)
		{
			if((x[j]>0)&&(y[j]>0))
			{
				max2=max2+1;	
			}
		}
		if(max2>max1)
		{
			max1=max2;
		}
	}
	cout<<max1;
	return 0;	
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];

    map<ll, ll> mp;
    for (auto a : A)mp[a]++;

    ll res = 0;
    for (auto itr : mp) {
        ll cnt = itr.second;
        res += cnt * (cnt - 1) / 2;
    }
    for (ll a : A) {
        ll cnt = mp[a];
        ll tres = res;
        tres -= cnt * (cnt - 1) / 2;
        cnt--;
        if (cnt > 0) {
            tres += cnt * (cnt - 1) / 2;
        }
        cout << tres << endl;
    }
    return 0;
}


Measured memory_bytes: 11008
import sys,itertools as o,scipy.sparse as s;_,r,*t=[map(int,i.split())for i in sys.stdin];a,b,c=zip(*t);l=s.csgraph.dijkstra(s.csr_matrix((c,(a,b)),[201]*2),0);print(min(sum(int(l[i][j])for i,j in zip(a,a[1:]))for a in o.permutations(r)))

Measured memory_bytes: 26256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)

int main() {
	ll N; cin >> N;
	if (N % 2 == 1) {
		cout << "0" << endl; return 0;
	}
	ll d = 5, n5 = 0;
	while (1) {
		if (N / d == 0) break;
		n5 += (N/d) / 2;
		d *= 5;
	}
	d = 2; ll n2 = 0;
	while (1) {
		if (N / d == 0) break;
		n2 += N/d;
		d *= 2;
	}
	ll ans = min(n5, n2);
	cout << ans << endl;
}

Measured memory_bytes: 3572
n, k = map(int, input().split())
if k > (n - 1) * (n - 2) / 2:
    print(-1)
else:
    #頂点1を中心のスター型グラフを作る
    ans = []
    appended_edges = set()
    for i in range(2,n+1):
        ans.append([1,i])
        appended_edges.add((1,i))
    #そのあとで、いらない分だけ頂点をつなげばいい
    flag = False
    #いま、最短距離が2の頂点の数
    count = (n-1)*(n-2) / 2
    for i in range(2,n+1):
        for j in range(i,n+1):
            if k == count:
                flag = True
                break
            if (i,j) not in appended_edges and i != j:
                ans.append([i,j])
                appended_edges.add((i,j))
                count -= 1
        if flag:
            break
    print(len(ans))
    for i in range(len(ans)):
        print("{} {}".format(ans[i][0], ans[i][1]))


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

int main(){
    int m,f,b;
    cin>>m>>f>>b;
    if(m>=b){
        cout<<0<<endl;
        return 0;
    }
    else b-=m;
    if(f<b) cout<<"NA"<<endl;
    else cout<<b<<endl;
    return 0;
}



Measured memory_bytes: 3080
#include <stdio.h>
#include <string.h>

#define MAX 100
#define PGMAX 1001
#define WDMAX 31

typedef struct _index {
	int pgnum[PGMAX];
	int tm;
	char str[WDMAX];
} index_t;

void swap( int i, int j, index_t idx[MAX] )
{
	char tmp_str[WDMAX];
	int tmp_pgnum[PGMAX];
	int tmp_tm;

	strcpy( tmp_str, idx[i].str );
	for ( int k = 0 ; k < PGMAX ; k++ ) {
		tmp_pgnum[k] = idx[i].pgnum[k];
	}
	tmp_tm = idx[i].tm;

	strcpy( idx[i].str, idx[j].str );
	for ( int k = 0 ; k < PGMAX ; k++ ) {
		idx[i].pgnum[k] = idx[j].pgnum[k];
	}
	idx[i].tm = idx[j].tm;

	strcpy( idx[j].str, tmp_str );
	for ( int k = 0 ; k < PGMAX ; k++ ) {
		idx[j].pgnum[k] = tmp_pgnum[k];
	}
	idx[j].tm = tmp_tm;
}

int main()
{
	index_t idx[MAX];
	char tmp_str[WDMAX] = {};
	int tmp_pgnum = 0, rgnum = 0, i = 0, j = 0, flag = 0, k = 0;

	while ( scanf( "%s %d", tmp_str, &tmp_pgnum ) != EOF ) {
		flag = 1;
		i = 0;
		while ( i < rgnum ) {
			if ( strcmp( tmp_str, idx[i].str ) == 0 ) {
				// BEPO?$5$l$?J8;zNs$NCf$+$i, B:#2sF~NO$5$l$?J8;zNs$,EPO?$5$l$F$$$k$+3NG'$9$k
				idx[i].pgnum[tmp_pgnum] = 1;
				idx[i].tm++;
				flag = 0; // BF~NOJ8;zNs$,EPO?:Q$_$N>l9g
				break;
			}
			i++;
		}

		if ( flag ) {
			// BF~NOJ8;zNs$,EPO?$5$l$F$$$J$$>l9g
			idx[rgnum].pgnum[tmp_pgnum] = 1;
			idx[rgnum].tm++;
			strcpy( idx[rgnum].str, tmp_str );
			rgnum++;
		}
		
	}

	// BF~NOJ8;zNs$N@0Ns$r9T$&
	for ( i = 0 ; i < rgnum ; i++ ) {
		for ( j = i+1 ; j < rgnum ; j++ ) {
			if ( strcmp( idx[i].str, idx[j].str ) > 0 ) {
				swap( i, j, idx );
			}
		}
	}

	// B@0Ns:Q$_$NF~NOJ8;zNs$NG[Ns$KBP$7$F, B=P8=$7$?%Z!<%8HV9f$J$I$r=PNO$9$k
	for ( i = 0 ; i < rgnum ; i++ ) {
		printf( "%s\n", idx[i].str );
		k = 0;
		for ( j = 0 ; j < PGMAX ; j++ ) {
			if ( idx[i].pgnum[j] == 1 ) { 
				if ( k == idx[i].tm-1 ) {
					printf( "%d\n", j );
					break;
				} else {
					printf( "%d ", j );
					k++;
				}
			}
		}
	}

	return 0;	
}



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

using namespace std;

#define ll long long

const int N = 1e5+4;
const ll inf = 1e16;
int h[N], n;
ll dp[3][N];

ll f(int j, int t)
{
    if(j > n)
        return inf;

    if(dp[t][j] != -1)
        return dp[t][j];

    ll x = f(j + 1, 1), y = f(j + 2, 2);

    if(x == inf and y == inf)
        x = y = 0;

    return dp[t][j] = abs(h[j] - h[j - t]) + min(x, y);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;

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

    memset(dp, -1, sizeof dp);

    cout << f(1, 0) << '\n';

    return 0;
}


Measured memory_bytes: 9404
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}Qu;

Qu Q[LEN+1];
int head, tail, n;

void enqueue(Qu x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

Qu dequeue(){
  Qu x=Q[head];
  head=(head+1)%LEN;
  return x;
}

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


int main(){
  int total_t = 0, c_t;
  int i, q;
  Qu u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head=1; tail=n+1;
  
  while(head!=tail){
    u=dequeue();
    c_t=min(q,u.t);
    u.t-=c_t;
    total_t+=c_t;
    if(u.t>0)enqueue(u);
    else{
      printf("%s %d\n",u.name,total_t);
    }
  }
  return 0;
}



Measured memory_bytes: 11856
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int ans=0;


vector<int> dou(256,0);

void dfs(int n, int k, int flag,int num){
    if (n==0) {
        ans++;
        return;
    }
    if(k<=0 or n<0 or num > 4) return;
    if (flag>0) {
        if (dou[k]<=n and dou[k]>=1) {
            dfs(n-dou[k], k,-100,num+1);
        }else{
            return;
        }
    }else{
        if (dou[k]<=n and dou[k]>=1) {
            dfs(n-dou[k], k,flag,num+1);
            if(flag == -100) {
                dfs(n, k-1,flag,num);
            }
        }else{
            dfs(n, k-1,flag,num);
        }
    }
}


int main(){
    rep(i, 256) dou[i] = i*i;
    while (true) {
        ll n;
        cin >> n;
        if(!n)break;
        int k=0;
        ans = 0;
        for (int i=1; i<256; i++) {
            if (dou[i]<=n) {
                k++;
            }else{
                break;
            }
        }
        for (int i=1; i<=k; i++) {
            dfs(n,i,n+i,1);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1196
#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 a, b, c;
    cin >> a >> b >> c;
    if (a >= b && a >= c) {
        cout << a * 10 + b + c;
    }
    else if (b >= c) {
        cout << b * 10 + a + c;
    }
    else {
        cout << c * 10 + a + b;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

//最大のやつらを集めて，その中の一番番号若いやつを使って次に大きいやつらにそろえる．
//バグ取り小宮
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;cin>>n;
    vector<ll> a(n);
    priority_queue<pair<ll,int>> q;
    rep(i,n){
        cin>>a[i];
        q.push(make_pair(a[i],-i));
    }
    vector<ll> cnt(n);
    int mugen=0,idx=INF;ll num=q.top().first;
    while(!q.empty()){
        while(!q.empty()&&(q.top()).first==num){
            idx=min(idx,-q.top().second);
            q.pop();mugen++;
        }
        ll nextnum=q.empty()?0ll:q.top().first;
        cnt[idx]+=(num-nextnum)*mugen;
        num=nextnum;
    }
    for(auto x:cnt)cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 4208
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
 
// random generator
// mt19937 rndm(time(0));
 
ll gcd(ll a, ll b)
{
    while (b>0)
    {
        ll tmp = a;
        a = b;
        b = tmp%b;
    }
    return a;
}
 
 
// long long gcd(long long a, long long b) {
//  return a? gcd(b % a, a) : b;
// }
 
 
const int M=1e9+7;
ll powmod(ll a,ll b, ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}/* a^b%mod */
const int N=1e5+10;




int main() {
   
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 	
    ll k, a, b;
    cin>>k>>a>>b;
    ll bis=1, yen=0;
    ll rem=a-1;
    if(rem<=k) {
        k-=rem;
        bis+=rem;

        if((b-a)>=2) {
            ll rr=(k/2)*(b-a);
            if(k%2)rr++;
            bis+=max(rr, k);
        }
        else {
            bis+=k;
        }
    }
    else {
        bis+=k;
        k=0;
    }
    cout<<bis<<endl;
    return 0;
}





Measured memory_bytes: 256
program swap_and_flip
  implicit none
  integer, parameter :: inf = 1e9
  integer :: n, a(0:17) = 0, b(0:17) = 0, i, j, k, x, u, v
  integer, allocatable :: dp(:,:)
  read(*,*) n
  read(*,*) a(0:n-1)
  read(*,*) b(0:n-1)
  u = lshift(1,n)-1
  allocate(dp(0:u,0:50))
  dp = inf
  dp(0,0) = 0
  do k = 0, u
    do i = 1, 50
      dp(k,i) = min(dp(k,i),dp(k,i-1))
    end do
    x = popcnt(k)
    do i = 0, n-1
      if (btest(k,i)) cycle
      v = merge(b(i),a(i),modulo(x-i,2) == 1)
      j = ibset(k,i)
      dp(j,v) = min(dp(j,v),dp(k,v)+popcnt(rshift(k,i)))
    end do
  end do
  x = minval(dp(u,:))
  write(*,'(i0)') merge(-1,x,x == inf)
end program swap_and_flip

Measured memory_bytes: 52480
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0) break;
			List<Integer> list = new ArrayList<Integer>();
			int idx = m - 1;
			for(int i = 0; i < n; i++) {
				list.add(i + 1);
			}
			while(list.size() > 1){
				int l = list.size();
				idx = idx % l;
				list.remove(idx);
				idx += m - 1;
			}
			System.out.println(list.get(0));

		}
		sc.close();
	}
}


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

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

    if (c == 'A')
        cout << "T\n";
    else if (c == 'T')
        cout << "A\n";
    else if (c == 'C')
        cout << "G\n";
    else if (c == 'G')
        cout << "C\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main()
{
  int N, K;
  std::cin >> N >> K;
  int ret = 0;

  for(int i=0; i<N; i++) {
    int x;
    std::cin >> x;
    ret += std::min(x, std::abs(x-K));
  }

  std::cout << 2 * ret << std::endl;
  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <vector>

int main()
{
    int n, q;
    std::string s;
    std::cin >> n >> q >> s;
    std::vector<int> cnt(n, 0);
    for (int i=1; i<n; ++i)
    {
        cnt[i] = cnt[i-1];
        if (s[i-1] == 'A' && s[i] == 'C')
        {
            cnt[i]++;
        }
    }
    std::vector<int> ans;
    for (int i=0; i<q; ++i)
    {
        int l, r;
        std::cin >> l >> r;
        l--; r--;
        std::cout << cnt[r] - cnt[l] << std::endl;
    }
}

Measured memory_bytes: 1408
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val s = sc.next()
    println(problem084b(a, b, s))
}

fun problem084b(a: Int, b: Int, s: String): String {
    val regex = Regex("[0-9]+")
    return if (s.length == a + b + 1 && s[a] == '-' && regex.matches(s.take(a) + s.takeLast(b))) "Yes" else "No"
}

Measured memory_bytes: 31516
#include<stdio.h>

void PrintRectangle(int H ,int W)
{
	int i,j;

	for(i=1;i<=W;i++){
		printf("#");
	}
	printf("\n");
	for(i=2;i<H;i++){
		printf("#");
		for(j=2;j<W;j++){
			printf(".");
		}
		printf("#");
		printf("\n");
	}
	for(i=1;i<=W;i++){
		printf("#");
	}
	printf("\n\n");
}


int main(void)
{
	int H,W;
	int i,j;
	
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0){
			break;
		}
		PrintRectangle(H,W);
	}
	return 0;
}

Measured memory_bytes: 588
#include "bits/stdc++.h"

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

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
	
	int n, a;
	cin >> n >> a;

	cout << n * n - a << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split(" ").map(&:to_i)
as = as.sort{|a,b| b <=> a}

$a = 0
$b = 0

def org
  b = [$a, $b].min
  a = [$a, $b].max
  $a = a
  $b = b
end

while !as.empty?
  tmp1 = as[0]
  tmp2 = as[1]
  if tmp1 == tmp2
    org()
    c = as.shift(2)[0]
    $b = [$b, c].max
  else
    as.shift
  end
end

puts $a * $b

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

int main()
{
    int x, y, z;
    cin >> x >> y >> z;

    int m;

    //swap a b
    m = x;
    x = y;
    y = m;
    //swap a c
    m = x;
    x = z;
    z = m;
    
    cout << x << ' ' << y << ' ' << z;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
    
    int a, i, x, y, z;
    int res[100001] = {};
    
	scanf("%d", &a);
    
	for (x = 1; x * x + 2 * x < a; x++) {
        for (y = 1; y * y + 2 * y < a; y++) {
            for (z = 1; z * z + 2 * z < a; z++) {
                res[x * x + y * y + z * z + x * y + y * z + z * x]++;
            }
        }
    }
    
	for (i = 1; i <= a; i++) {
        printf("%d\n", res[i]);
	}
        
	return 0;
}

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

int main() {
  int K, X;
  cin >> K >> X;
  
  int min_edge = X - (K-1);
  int max_edge = X + (K-1);
  
  if(min_edge < -1000000)
    min_edge = -1000000;
  if(max_edge > 1000000)
    max_edge = 1000000;
  
  for(int itr = min_edge; itr <= max_edge; itr++)
  {
      cout << itr << " ";
  }
  cout << endl;
}

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

int main() {
  int S;
  cin >> S;
  string ans;
  int S2 = S % 100;
  int S1 = (S - S2) / 100;
  if (1 <= S1 && S1 <= 12) {
    if (1 <= S2 && S2 <= 12)
      ans = "AMBIGUOUS";
    else
      ans = "MMYY";
  }
  else {
    if (1 <= S2 && S2 <= 12)
      ans = "YYMM";
    else
      ans = "NA";
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s == u) a--;
  else b--;
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
ll dp[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
       ll n,k;
       cin>>n>>k;
       ll h[100005];
       for(int i=1;i<=n;i++)
       cin>>h[i];
       for(int i=1;i<=n;i++)
       	dp[i]=hell;
       dp[1]=0;
       for(ll i=2;i<=n;i++)
       {
       	  for(ll j=1;j<=min(k,i-1);j++)
       	  {
       	  	 dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
       	  }
       }
       cout<<dp[n];   
    }
    return 0;
}

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

struct time_check {
    int find_time, end_time;
};

int G[101][101] = {0};
time_check t[101];
int elapsed = 0, n;
stack<int> S;

void dfs(int start) {
    S.push(start);
    while (! S.empty()) {
        elapsed++;
        int u = S.top();
        for (int i = 1; i <= n + 1; i++) {
            if (G[u][i] == 1 && t[i].find_time == 0) {
                t[i].find_time = elapsed;
                G[u][i] = 0;
                S.push(i);
                break;
            }
            if (i == n + 1) {
                t[u].end_time = elapsed;
                S.pop();
            }
        }
    }
}

int main() {
    for (int i = 1; i <= 100; i++) t[i].end_time = 0;

    int u, v, k;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            G[u][v] = 1;
        }
    }

    for (int i = 1; i <= n; i++) {
        if (t[i].end_time == 0) {
            t[i].find_time = ++elapsed;
            dfs(i);
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << i << " " << t[i].find_time << " " << t[i].end_time << endl;
    }

    return 0;
}

/*
#include<iostream>
#include<stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BRACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

// uに隣接するvを番号順に取得
int next(int u) {
    for (int v = nt[u]; v < n; v++) {
        nt[u] = v + 1;
        if (M[u][v]) return v;
    }
    return -1;
}

// スタックを用いた深さ優先探索
void dfs_visit(int r) {
    for (int i = 0; i < n; i++) nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while (! S.empty()) {
        int u = S.top();
        int v = next(u);
        if (v != -1) {
            if (color[v] == WHITE) {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        } else {
            S.pop();
            color[u] = BRACK;
            f[u] = ++tt;
        }
    }
}

void dfs() {
    // 初期化
    for (int i = 0; i < n; i++) {
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    // 未訪問のuを始点として深さ優先探索
    for (int u = 0; u < n; u++) {
        if (color[u] == WHITE) dfs_visit(u);
    }
    for (int i = 0; i < n; i++) {
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main() {
    int u, k, v;

    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) M[i][j] = 0;
    }

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}
*/


Measured memory_bytes: 3104
n = int(input())
a = list(map(int,input().split()))

ans = 0
while 1:
    for i in range(len(a)):
        if a[i]%2 == 0:
            a[i] = a[i]/2
            ans += 1
    cnt = 0
    for i in range(len(a)):
        if a[i]%2 != 0:
            cnt += 1
    if cnt == len(a): break
print(ans)

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

int main() {
  int H,W;
  cin >> H >> W;
  char A[H+2][W+2],B[H][W];
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      A[i][j]='#';
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> B[i][j];
      A[i+1][j+1]=B[i][j];
    }
  }
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      cout << A[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256