akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    long long int K;
    int Q;
    cin >> N >> K >> Q;
    
    vector<long long int> score(N, 0);
    for(int i=0; i<Q; i++) {
        int A;
        cin >> A;
        score[A-1]++;
    }
    
    for(int i=0; i<N; i++) {
        if(score[i]+K>Q) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    
    

    return 0;
    
}

Measured memory_bytes: 1408
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def i(n: Int): Int = ints(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]) {
    def read(): Unit = {
      val ns: Seq[Int] = readLine.ints
      if (!ns.forall(_ == 0)) {
        println(ns.sorted.mkString(" "))
        read()
      }
    }
    read()
  }
}

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

int main() {
  char q; cin>>q;
  if(q=='A')cout<<'T'<<endl;
  else if(q=='T')cout<<'A'<<endl;
  else if(q=='C')cout<<'G'<<endl;
  else cout<<'C'<<endl;

}

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

ll up(double x){
    if( x - (ll)x > 0 ) return (ll)x + 1;
    else return x;
}

bool check(ll a[], ll n, ll m, ll k){
    ll tot=0;
    forr(i,n) {
       if( a[i] > m )  tot += up((double)a[i]/m) - 1;
    }
    return tot<=k;
}

void _sol(){
    ll k; ll n; cin >> n >> k;
    ll a[n];
    forr(i,n) cin >> a[i];
    ll s = 1 , e = 1e10 , ans = -1;
    while(s <= e ){
        ll mid = (s+e)/2.0;
        if(check( a ,n ,mid,k )) ans = mid , e = mid-1;
        else s = mid+1;
    }
    cout << ans;
}

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


Measured memory_bytes: 5160
#include<bits/stdc++.h>
#include <ext/numeric>
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))
#define     pii       pair<int,int>
#define     N         3000000
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n,k;

    cin >> n>>k;
    if(k>1)
    cout << (n-(k-1))-1;

    else cout << 0;

    return 0;
}


Measured memory_bytes: 256
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){ int sz = a.size();
for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

struct event{

  long long x;
  long long hp;
  int mon;

  event(ll x,int mon,ll hp):x(x),mon(mon),hp(hp){}

  bool operator<(const event a) const{
    if(x != a.x)return this->x > a.x;
    else return this->mon > a.mon;
  }
  void print(){
  	cerr << x << ' ' << hp << ' ' << mon << '\n';
  }
};

int main(int argc, char const *argv[])
{
  ioboost();

  ll n,d,a;cin >> n >> d >> a;
  vector<pl> m(n);

  priority_queue<event> q;

  rep(i,n){
    cin >> m[i].first >> m[i].second;
    event e(m[i].first,1,m[i].second);
    q.push(e);
  }

  long long ans = 0;
  long long dam = 0;

  while(q.size()){
    event e = q.top();q.pop();

    if(e.mon){

      ll cnt = max(0LL,(e.hp - dam + a - 1) / a);

      ans += cnt;
      dam += cnt * a;

      if(cnt){
      	event bomb(e.x + 2*d + 1,0,-cnt*a);
      	q.push(bomb);
      }

    }else{

      dam += e.hp;

    }
  }

  cout << ans << '\n';


  return 0;
}


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

int main() {
    int M,D;
    cin >> M >> D;

    int seki = 0;

    for(int i=1;i<=M;i++){
        for(int j=1;j<=D;j++){
            if(j/10>=2&&j%10>=2&&int(j/10)*(j%10)==i) seki++;
        }
    }

    cout << seki << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long int
int main()
{

    ll  arr[5 ];
    for(ll i =0;i<5 ;i++)
        cin>>arr[i] ;

        for(ll i =0;i<5;i++)
        {

            if(arr[i]==0 )
            {

            cout<<i+1<<endl ;
            return  0 ;

            }
        }

}


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

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int b[10];
		int left = 0, right = 0;
		bool avail = true;
		for (int j = 0; j < 10; j++)
			cin >> b[j];
		for (int j = 0; j < 10; j++) {
			if (b[j] > left) left = b[j];
			else if (b[j] > right) right = b[j];
			else avail = false;
		}
		cout << (avail ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> pr; // val, id
int N;
ll A[200001],B[200001];
 
int getPrev(int x){
    return (x-1+N)%N;
}
int getNext(int x){
    return (x+1)%N;
}
set<pr> tmp;
ll cnt=0;
int main(void){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    
    for(int i=0;i<N;i++){
        cin >> B[i];
        if (B[i] < A[i]){
            cout << -1 << endl;
             return 0;
        }
        if (B[i]!=A[i]) tmp.insert({B[i], i});
    }
    int lastId = N+1;
    ll lastVal = 2e9+1;
    ll op = 0;
    while(tmp.size()>0){
        op++;
        if (op>1e7){
            cout << -1 << endl;
            return 0;
        }
        auto it = tmp.end();
        it--;
        int id = it->second;
        ll val = it->first;
        if (id == lastId && val == lastVal){
            cout << -1 << endl;
            return 0;
        }
        lastId = id;
        lastVal = val;
        // auto previt = tmp.lower_bound({val,id});
        ll nxtval = A[id];
        
        // if (previt!=tmp.begin()){
        //     previt--;
        //     nxtval =max(previt->first, nxtval);
        //     assert(nxtval<val);
        // }
        tmp.erase(it);
        int prev = getPrev(id);
        int nxt = getNext(id);
        nxtval = max(nxtval, B[prev]);
        nxtval = max(nxtval, B[nxt]);
        ll incre = (B[id]-nxtval)/(B[prev]+B[nxt]);
        B[id] = (B[id]-nxtval)%(B[prev]+B[nxt]) + nxtval;
        
        if (B[id] > nxtval){
            B[id] -= (B[prev] + B[nxt]);
            incre++;
        }
        if (incre==0){
            B[id] -= (B[prev] + B[nxt]);
            incre++;
        }
        cnt += incre;
        if (B[id] < A[id]){
            cout << -1 << endl;
            return 0;
        }
        if (B[id] > A[id]){
            tmp.insert({B[id], id});
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 17792
n = int(input())
a = input().split()
count = 0
p = 0

a = [int(m) for m in a]

while p != len(a):
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] = a[i] / 2
            count += 1
        else:
            p += 1
    if p != len(a):
        p = 0

print(count)

Measured memory_bytes: 4148
import numpy as np
import collections
n = int(input())
a = list(map(int,input().split()))
t = [0 for i in range (100001)]
max = 0
ac = collections.Counter(a)
for i in range(1,100000):
    max = np.maximum(max,ac[i-1]+ac[i]+ac[i+1])
print(max)

Measured memory_bytes: 23508
#include<stdio.h>

int main (){

  int a,b,t,s;
  int i;
  scanf("%d %d" ,&a,&b);
  int y[a],u[a];
  t=b;
  s=b;
  for(i=1;i<a;i++){
    
    t+=1;
    s-=1;
    y[i-1]=t;
    u[i-1]=s;
    
  }
  
  
for(i=a-1;i>=1;i--){
  printf("%d ",u[i-1]);
}
printf("%d ",b);
for(i=1;i<a;i++){
    printf("%d ",y[i-1]);
  }
  
  
  return 0;
    
  }


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
template<class Type> class UnionFind
{
  public:
    vector<Type> data;
    int grope;
    UnionFind(int sz)
    {
        data.assign(sz, -1);
        this->grope = sz;
    }
    bool unite(Type x, Type y)
    {
        x = find(x), y = find(y);
        if (x == y) return (false);
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        grope--;
        return (true);
    }
    Type find(Type k) {
        if (data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    Type size(Type k) { return (-data[find(k)]); }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    UnionFind<int> uf(n);
    for(int i = 0; i < m; i++)
    {
        int x, y, z; cin >> x >> y >> z;
        x--, y--;
        uf.unite(x, y);
    }
    cout << uf.grope << endl;
    return 0;
}



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

using namespace std;

int main(void){
    int n,d;
    cin >> n >> d;
    float ansf = (float)n/(float)(2*d+1);
    if(ansf > n/(2*d+1)){
        cout << n/(2*d+1) + 1 << endl;
    }else{
        cout << n/(2*d+1) << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;


int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double area = w * h;
    double ans = area / 2.;
    cout << fixed << setprecision(9) << ans << " ";
    cout << ((w / 2. == x && h / 2. == y) ? 1 : 0) << endl;
}


Measured memory_bytes: 256
def main():

    n = int(input())
    a = int(input())

    if n >= 500:
        if n%500-a <= 0:
            print('Yes')
        else:
            print('No')
    else:
        if n-a <= 0:
            print('Yes')
        else:
            print('No')



if __name__ == "__main__":
    main()



Measured memory_bytes: 2940
from operator import itemgetter
N = int(input())
AB = [[int(x) for x in input().split()] for i in range(N)]
AB = sorted(AB, key=itemgetter(1, 0))

tmp = 0
for i in range(N):
  A,B = AB[i]
  tmp+=A
  if tmp > B:
    print('No')
    break
else:
  print('Yes')

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

int main(){
  int n;
  string s;
  cin >> n >> s;
 
  int sum_R=0,sum_B=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      sum_R++;
    }else{
      sum_B++;
    }
  }
  
  if(sum_R>sum_B){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  lb  lower_bound
#define  ub  upper_bound
#define  F   first
#define  S   second
const int N=2e5+2;
ll a[N];
int main()
{
    ft
    ll i,j,n,m,l,r,s=0;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n,greater<ll>());
    for(i=m;i<n;i++)
    {
        s+=a[i];
    }
    cout<<s<<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
	int n;
	cin>>n;
	
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	int cnt=0,k=1;
	for(int i=0;i<n;i++){
		if(a[i]!=k)
		cnt++;
		
		else{
			k=k+1;
			continue;
		}
	}
	
	if(cnt<n)
	cout<<cnt;
	
	else
	cout<<-1;	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, p[100010];
    cin >> n;
    reps(i, 1, n){
        cin >> p[i];
    }

    int res = 0;
    reps(i, 1, n-1){
        if(p[i] == i){
            swap(p[i], p[i+1]);
            res++;
        }
    }
    if(p[n] == n){
        res++;
    }
    cout << res << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back


ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

ll modinv(ll a, ll m)
{
    return modpow(a, m - 2, m);
}

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    vec C(60, 0);
    REP(i,0,N) {
        REP(j,0,60) C[j] += ((A[i] >> j) & 1);
    }

    ll sum = 0;
    REP(i,0,N) {
        REP(j,0,60) {
            if((A[i] >> j) & 1) sum = (sum + modpow(2, j, MOD) * (N - C[j])) % MOD;
            else sum = (sum + modpow(2, j, MOD) * C[j]) % MOD;
        }
    }
    PR((sum*modinv(2,MOD))%MOD);

    return 0;
}

/*



*/

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


int main() {
  
  vector<int> p(9);
  
  rep(i,9) {
  cin >> p[i];
  } 
  
  int n;
  cin >> n;
  
  rep(i,n) {
  int x;
  cin >> x;
    rep(j,9) {
    if(x==p[j]) p[j]=0;
    }
  }
  
  cout << (p[0]==0 && p[1]==0 && p[2]==0 ||
           p[3]==0 && p[4]==0 && p[5]==0 ||
           p[6]==0 && p[7]==0 && p[8]==0 ||
           p[0]==0 && p[3]==0 && p[6]==0 ||
           p[1]==0 && p[4]==0 && p[7]==0 ||
           p[2]==0 && p[5]==0 && p[8]==0 ||
           p[0]==0 && p[4]==0 && p[8]==0 ||
           p[2]==0 && p[4]==0 && p[6]==0? "Yes":"No");  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
arr<int> G, rG;
int v, e;
vector<bool> seen;
vector<int> backed;
vector<int> setnum;

void dfs1(int n){
    seen[n] = true;
    for(auto i: G[n]){
        if(seen[i]) continue;
        dfs1(i);
    }
    backed.push_back(n);
}

void dfs2(int n, int g){
    seen[n] = true;
    setnum[n] = g;
    for(auto i: rG[n]){
        if(seen[i]) continue;
        dfs2(i, g);
    }
}

int main()
{
    cin >> v >> e;
    G.resize(v);
    rG.resize(v);
    seen.resize(v, false);
    setnum.resize(v);
    rep(i, e){
        int f, t; cin >> f >> t;
        G[f].push_back(t);
        rG[t].push_back(f);
    }
    rep(i, v){
        if(seen[i]) continue;
        dfs1(i);
    }

    // prvec(backed);

    seen.assign(v, false);
    int group=0;
    for(int i=v-1; i>=0; i--){
        if(seen[backed[i]]) continue;
        dfs2(backed[i], group++);
    }

    // prvec(setnum);

    int q; cin >> q;
    int s, t;
    rep(i, q){
        cin >> s >> t;
        if(setnum[s]==setnum[t]) pr(1);
        else pr(0);
    }
    return 0;}


Measured memory_bytes: 4748
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double x = 0;
        double result = 0;
        boolean err = true;
        // 税抜き価格xに1.08をかけて小数を切り捨てた値がnになるxがあるか全探索で調べる
        for (int i = 1; i < n + 1; i++) {
            x = (double) i;
            result = Math.floor(x * 1.08);
            if((int)result == n){
                System.out.println(i);
                err = false;
                break;
            }
        }
        if(err){
            System.out.println(":(");  
        }
        sc.close();
    }
}

Measured memory_bytes: 35944
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cstdio>//"scanf("%lf",&(double));printf("%f",(double));"
//#include<numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include<cassert>//"assert(cond);": error if cond doesn't hold.
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert//also use as v.is(v's it,w's it,w's it);
#define ps push//stack,(priority) queue,.
#define fr front//queue//for priority, use top()..
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> edge;
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

void print_edge(edge e){
	printf("%d %d %d\n",1+e.fi.fi, 1+e.fi.sc, e.sc);
}

int main(){
 	int l;
	scanf("%d",&l);
	int m=0;
	vector<int> v;
	for(int cnt = 0, l0 = l;l0>0; ++cnt){
		if(l0% 2 == 1){
			m = cnt;
			v.pb(cnt);
		}
		l0 /= 2;
	}
	vector<edge> e;
	for(int i=0;i<=m-1;++i){
		e.pb(mp(mp(i, i + 1), 1<<(m-1-i)));
		e.pb(mp(mp(i, i + 1), 0));
	}
	int cnt = 1<<m;
	for(int i=v.size()-2;i>=0;--i){
		e.pb(mp(mp(0, m - v[i]), cnt));
		cnt+=(1<<v[i]);
	}
	printf("%d %d\n", m+1, e.size());
	for(int j=0;j<e.size();++j) print_edge(e[j]);
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

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

const int INF = 100000002;

int main(){
	ll a, b, n; cin >> a >> b >> n;
	if(n>=b){
		ll ans = a*(b-1)/b - a * floor((b-1)/b);
		cout << ans << endl;
	}else{
		ll num = n%b;
		ll ans = floor(a*num/b) - a * floor(num/b);
		cout <<ans << endl; 
	}
}

Measured memory_bytes: 3600
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int x[114514];
bool sumi[114514];
int n;
/*bool cal(vector<int> a){
	memset(sumi,false,sizeof(sumi));
	rep(i,n){
		int sum=0,f=0;
		rep(j,a[i]){
			if(sumi[j]) continue;
			sum++;if(sum*2>=x[j]+2) f=1;
		}
		if(f>0) return false;
		sumi[a[i]]=true;
	}
	return true;
}*/
int main()
{
	lint out=1,mo=1000000007;
	cin>>n;
	rep(i,n) cin>>x[i];
	/*if(n>8) return 0;
	vector<int> v;rep(i,n) v.pb(i);
	while(1){
		if(cal(v)) out++;
		if(!next_permutation(All(v))) break;
	}*/
	//memset(sumi,false,sizeof(sumi));
	int sum=0,f=0;
	rep(i,n){
		sum++;
		if(sum*2>=x[i]+2){
			out*=sum;out%=mo;sum--;
		}
	}
	REP(i,1,sum+1){
		out*=i;out%=mo;
	}
	cout<<out<<endl;
}


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

int main() {
    double N, M;
    cin >> N >> M;
    vector <int> A(N);
    double sum=0;
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
        sum += A.at(i); 
    }
    int cnt=0;
    for (int i=0; i<N; i++) {
        if ((1/(4*M)<=(A.at(i)/sum))) cnt++;
    }
    if (cnt>=M) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
int main() {
	int n;
	std::string s;
	std::cin >> n >> s;
	std::vector<int> right(s.size(), 0);
	std::vector<int> left(s.size(), 0);
	for (auto i = 0; i < s.size(); ++i) {
		switch (s[i]) {
		case 'E': ++right[i]; break;
		default: ++left[i]; break;
		}
	}
	for (auto i = 1; i < s.size(); ++i) {
		right[i] += right[i - 1];
		left[i] += left[i - 1];
	}
	for (auto i = 0; i < s.size(); ++i) {
		right[i] = right[s.size() - 1] - right[i];
		if (s[i] == 'W') --left[i];
	}
	int min = s.size();
	for (auto i = 0; i < s.size(); ++i) {
		if (min > left[i] + right[i]) min = left[i] + right[i];
	}
	std::cout << min << std::endl;
}

Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  int n=s.length();
  string r=s;
  reverse(ALL(r));
  string mae=s.substr(0,(n-1)/2);
  string ato=s.substr((n+1)/2,(n-1)/2);
  bool flag=true;
  rep(i,n){
    if(s[i]!=r[i])flag=false;
  }
  rep(i,(n-1)/2){
    if(mae[i]!=mae[(n-1)/2-1-i])flag=false;
    if(ato[i]!=ato[(n-1)/2-1-i])flag=false;
  }
  if(flag){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
table = {
    'AC'=> 0,
    'WA'=> 0,
    'TLE' => 0,
    'RE' => 0
}

n.times do
    judge = gets.chomp
    table.has_key?(judge) && table[judge]+=1
end

['AC','WA','TLE','RE'].each{|j|
    puts "#{j} x #{table[j]}"
}


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

int main(){
	int N;
	cin >> N;
	
	string str;
	cin >> str;
	
	int M;
	cin >> M;
	
//		cout << str.at(M-1) <<endl;
	
	for(int i=0;i<N;i++){
		if(!(str.at(M-1)==str.at(i))){
			str.at(i)='*';
		}
	}
	
	cout << str <<endl;
	
	
}

Measured memory_bytes: 256
package main

import (
  "fmt"
  "math"
)

func slove(x int) int {
  deposit := 100.0
  for i:=1;;i++ {
    deposit = math.Floor(deposit * 1.01)
    if float64(x) <= deposit {
      return i
    }
  }
}

func main() {
  var x int
  fmt.Scan(&x)
  
  fmt.Println(slove(x))
}

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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      final int numMax = 999_999;
      String line;
      int num;
      int result;

      int[] prime = new int[100_000];
      prime[0] = 2;
      for ( int i=3, j=1; i != numMax; i+=2 ) {
        if( isPrime(i,prime) ) {
          prime[j++] = i;
        }
      }

      while(true) {

        if( ((line = br.readLine()) == null) || line.isEmpty() ) break;

        num = Integer.parseInt(line);
        if( num == 0 || num == 1) {
          result = 0;
          System.out.println(result);
          continue;
        }
        
        result = 1;
        for ( int i = 3; i <= num; i+=2 ) {
          if( isPrime(i,prime) ) {
            result += 1;
          }
        }
        System.out.println(result);
      }
    }
  }

  public static boolean isPrime(int num,int[] prime) {
    int k = Double.valueOf( Math.sqrt(num) ).intValue();
    for(int i: prime) {
      if ( num % i == 0 ) return false;
      if ( i > k ) return true;
    }
    return true;
  }
}


Measured memory_bytes: 26012
n, k = list(map(int, input().split()))
al = list(map(int, input().split()))
flag = True
for a in al:
    if a >= k:
        flag = False
if flag:
    print('IMPOSSIBLE')
    exit()
# a,bの最大公約数


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


t = al[0]
for i in range(1, n):
    t = gcd(t, al[i])


for a in al:
    if abs(k-a) % t == 0:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


Measured memory_bytes: 62576
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
int s[N];
int main(){
	int n;sc(n);
	fr(i, 0, n-1) sc(s[i]);
	//skip = a-b
	ll res = 0;
	auto solve = [&](int skip){
		ll tmp = 0;
		set<int> vis;
		for(int k=1;k*skip < n;k++){
			vis.insert(k*skip);
			tmp += s[n-1-k*skip]+s[k*skip];
			int a=n-1-k*skip;
			int b=a-skip;
			if(b<1||b>=a) continue;
			if (vis.find(a)!=vis.end()) continue;
			res = max(res, tmp);
		}
	};
	fr(skip, 1, n-1) solve(skip);
	lpr(res);n_l;
    return 0;
}



Measured memory_bytes: 8836
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
typedef long long ll;
using namespace std;
int main()
{
	int N; cin >> N;
  	vector<int> W(N);
  	int sum = 0;
  	for (int i = 0; i < N; i++){
    	cin >> W[i];
      	sum += W[i];
    }
  	int left = 0;
   	int right = sum;
  	int minans = 999;
  	for (int i = 0; i < N - 1; i++){
    	left += W[i];
      	right -= W[i];
      	if (minans > abs(right - left)) {
        	minans = abs(right - left);
        }
    }
  	cout << minans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;

const int N=1e5+5;
ll r,c,n;

bool isImportant(int x,int y){
	bool flagx=(x==0)||(x==r);
	bool flagy=(y==0)||(y==c);
	return flagx||flagy;
}

ll w(int x,int y){
	if(x==0) return y;
	if(y==c) return c+x;
	if(x==r) return 2*c+r-y;
	return 2*c+2*r-x;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>r>>c>>n;
	vector<P> p;
	for(int i=0;i<n;++i){
		int xa,ya,xb,yb;
		cin>>xa>>ya>>xb>>yb;
		if(isImportant(xa,ya)&&(isImportant(xb,yb))){
			ll x=w(xa,ya);
			ll y=w(xb,yb);
			p.emplace_back(x,i);
			p.emplace_back(y,i);
		}
	}
	sort(p.begin(),p.end());
	stack<ll> s;
	for(P i:p){
		if(s.empty()||s.top()!=i.second) s.push(i.second);
		else s.pop();
	}
	if(s.empty()) puts("YES");
	else puts("NO");
}




Measured memory_bytes: 7432
#include <bits/stdc++.h>
using namespace std;
int main() {
  typedef long long ll;
  ll M, rd, rr, cd, cr;
  cin >> M >> rd >> rr >> cd >> cr;
  ll a = cd * 100 / rd + (cd * 100 % rd > 0);
  ll b = cr * 100 / rr + (cr * 100 % rr > 0);
  cout << (M - a - b < 0 ? -1 : M - a - b) << endl;
  return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    if(a > 12)
        cout << b << '\n';
    else if(a < 6)
        cout << 0 << '\n';
    else
        cout << b / 2 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;

int main(){
  int n;
  cin >> n;
  cout << 800 * n - (n / 15) * 200 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long [] a = new long[n + 1];
        for (int i = 1; i <= n; ++i) {
            a[i] = scanner.nextLong();
        }
        long [] sum = new long[n];
        long [] minus = new long[n];
        for (int i = 1; i <= n; ++i) {
            sum[i - 1] = a[i] + i;
            minus[i - 1] = a[i] - i;
        }
        Arrays.sort(sum);
        Arrays.sort(minus);
//        System.out.println("=============sum: ");
//        for (int i = 0; i < n; ++i) {
//            System.out.print(sum[i] + " ");
//
//        }
    //    System.out.println("==============minus: ");
//        for (int i = 0; i < n; ++i) {
//            System.out.print(minus[i] + " ");
//        }
        long ans = 0;
        for (int i = 1; i <= n; ++i) {
            long findSum = i - a[i];
            long findMinus = -a[i] - i;
            long currentSum = a[i] + i;
            long currentMinus = a[i] - i;
//            System.out.println("-----------");
//            System.out.println("i: " + i);
//            System.out.println("findSum: " + findSum);
//            System.out.println("findMinus: " + findMinus);
//            System.out.println("currentSum: " + currentSum);
//            System.out.println("currentMinus: " + currentMinus);

            int sumLeft = lowerBound(sum, -1, sum.length, findSum);
            int sumRight = lowerBound(sum, -1, sum.length, findSum + 1);
            int minusLeft = lowerBound(minus, -1, minus.length, findMinus);
            int minusRight = lowerBound(minus, -1, minus.length, findMinus + 1);

//            System.out.println("sumLeft: " + sumLeft + " sumRight: " + sumRight);
//            System.out.println("minusLeft: " + minusLeft + " minusRight: " + minusRight);
            ans += sumRight - sumLeft;
            ans += minusRight - minusLeft;
            if (currentSum == findSum) {
                --ans;
            }
            if (currentMinus == findMinus) {
                --ans;
            }
         //   System.out.println("ans: " + ans);
        }
        ans /= 2;
        System.out.println(ans);
    }

    public static int lowerBound(long [] arr, int l, int r, long key) {
   //     System.out.println("key: " + key);
        while (r - l > 1) {
            int mid = (l + r) / 2;
        //    System.out.println("mid: " + mid +  " arr[mid]: " + arr[mid]);
            if (arr[mid] >= key) {
                r = mid;
            } else {
                l = mid;
            }
       //     System.out.println("l: " + l + " r: " + r);
        }
        return r;
    }
}


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

using namespace std;

typedef long long ll;

const ll mod = 1e9+7;
const int N = 2e5;

ll iv[N+1];
ll po(ll b, ll p){
    ll r = 1;
    for(; p; b=b*b%mod, p/=2)
        if(p&1)
            r = r*b%mod;
    return r;
}
ll nck(ll n, ll k){
    ll ans = 1;
    for(ll i=1; i<=k; i++)
        ans = ans*(n-i+1)%mod*iv[i]%mod;
    return ans;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    iv[1] =1;
    for(ll i=2;i<=N; i++)
        iv[i]=mod-mod/i*iv[mod%i]%mod;
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = po(2, n)-1;
    cout << (ans+(2*mod)-nck(n, a)-nck(n, b)+mod)%mod;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main(){
    char *op;
    char ch;
    op=&ch;
    int Ans[1000];
    int i=0;
    
    while(scanf("%c",op),*op!='\n'){
        
        if(*op=='+'){
            Ans[i-2]=Ans[i-2]+Ans[i-1];
            i--;
            continue;
        }else if(*op=='-'){
            Ans[i-2]=Ans[i-2]-Ans[i-1];
            i--;
            continue;
        }else if(*op=='*'){
            Ans[i-2]=Ans[i-2]*Ans[i-1];
            i--;
            continue;
        }else if(*op!=' '){
            Ans[i]=atoi(op);
            while(1){
                scanf("%c",op);
                if(*op==' '){
                    i++;
                    break;
                }
                Ans[i]=Ans[i]*10+atoi(op);
            }
        }
    }
    
    printf("%d\n",Ans[0]);
    return 0;
    
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

ll gcd(ll x, ll y) {
    if(x<y) gcd(y,x);
    while(y>0) {
        ll tmp = x%y;
        x = y;
        y = tmp;
    }
    return x;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    ll a = m/n + m%n, b = m/n;
    ll ans = 0;
    while(ans==0) {
        if(a%b==0) ans = b;
        a += n-1;
        -- b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }
    //let v = a.iter().map(|v| f64::log2(*v as f64)).collect::<Vec<_>>();
    let mut ans: i64 = 0;
    for mut v in a {
        loop {
            if v % 2 == 0 {
                ans += 1;
                v /= 2;
            } else {
                break;
            }
        }
    }
    println!("{}", ans);
}


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

constexpr int MaxN = 100;

int Color(int rate)
{
	return rate / 400;
}

int main()
{
	int N;
	cin >> N;
	
	int check = 0;
	int num_rainbow = 0;

	for (int i = 0; i < N; ++i)
	{
		int a;
		cin >> a;

		int k = Color(a);
		
		if (k > 7)
		{
			++num_rainbow;
		}
		else
		{
			check |= (1 << k);
		}
	}

	int num_color = 0;
	for (; check > 0; check >>= 1)
	{
		if ((check & 1) != 0)
		{
			++num_color;
		}
	}

	cout << max(num_color, num_rainbow == 0 ? 0 : 1) << " " << num_color + num_rainbow << endl;

	return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce
 
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
 
N,X =[int(i) for i in input().split()]
c = [int(i) for i in input().split()]
 
for i in range(N):
    c[i] = abs(c[i] - X)
 
print(gcd_list(c))

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

using namespace std;

#define LL long long
#define FOE(i, s, t) for (int i = s; i <= t; i++)

#define K 200001

int n;
vector<int> nxt[K];

int m;

int dfs[K], sig, eve, bip, bi, col[K];

void DFS(int u, int co){
        dfs[u] = 1;
        col[u] = co;
        for (int i = 0; i < nxt[u].size(); i++) if (!dfs[nxt[u][i]])
                DFS(nxt[u][i], 1 - co);
        else if (col[nxt[u][i]] == col[u]) bip = 0;
}

int pp[51][51];

int aa[61][61];

void DD(int u, int v){
        pp[u][v] = 1;
        for (int i = 1; i <= n; i++)
                FOE(j, 1, n){
                        if (aa[u][i] && aa[v][j] && !pp[i][j]) DD(i, j);
                }
}

int main(){
        scanf("%d%d", &n, &m);
        FOE(i, 1, m){
                int c, d; scanf("%d%d", &c, &d);
                nxt[c].push_back(d);
                nxt[d].push_back(c);
        }

        FOE(i, 1, n) if (!dfs[i]){
                bip = 1;
                DFS(i, 0);
                if (nxt[i].size() == 0) sig++; else if (bip) bi++; else eve++;
        }

        long long ret = 0;


        //printf("%d %d %d\n", sig, eve, bi);

        // 1: same sig com
        // 2: sig - eve
        //
        ret = ret + (long long)sig * n * 2 - (long long)sig * sig;
        //printf("%lld\n", ret);

        // 3: sig - sig, same

        // 4: sig - sig, diff
        ret = ret + (long long) eve;
        ret = ret + (long long) eve * (eve - 1);
        ret = ret + (long long) bi * 2;
        ret = ret + (long long) bi * (bi - 1) * 2;
        ret = ret + (long long) eve * bi * 2;


//      printf("%lld\n", ret);

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

}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

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

  priority_queue<ll> que;
  ll a;
  REP(i, n){
    cin >> a;
    que.push(a);
  } 
  
  REP(i, m){
    a = que.top();
    que.pop();
    que.push(a/2);
  }

  ll ans = 0;
  while(!que.empty()){
    ans +=  que.top();
    que.pop();
  }

  cout << ans << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    int n, k ;
    cin >> n >> k ; 
    ll min = 0 ;
    ll max = 0 ;
    ll ans = 0 ;
    rep(i, k - 1){
        min += i ;
        max += (n - i) ;
    }
    for(int i = k; i <= n + 1; i++){
        min += (i - 1) ;
        max += (n - i + 1) ;
        ans += max - min + 1 ;
        ans %= (1000000000 + 7) ;
    }
    cout << ans << endl ;
}  

Measured memory_bytes: 3612
use std::io::*;
use std::str::*;
use std::collections::*;

fn main() {
    let N : i32 = read();
    let W : usize = read();
    let mut dp = vec![0 as usize; W + 1];
    for i in 0..N {
        let w : i32 = read();
        let v : usize = read();
        for j in (0..W+1).rev() {
            let pj = j as i32 - w;
            if pj < 0 { break; }
            let pj = pj as usize;
            dp[j] = std::cmp::max(dp[j], dp[pj] + v);
        }
    }
    println!("{}", dp[W]);
}

fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin 
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N, M;
int d[110000];

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

  Rep(i, M) {
    int a, b;
    cin >> a >> b;
    d[a]++; d[b]++;
  }

  bool ans = true;
  rep(i, N) {
    if (d[i] % 2 != 0) {
      ans = false;
      break;
    }
  }

  cout << (ans ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 640
//Author: Mohit Hotwani
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    SPEED;
    int testCases = 1;
    //cin >> testCases;
    while (testCases--) {
        ll n;
        cin >> n;
        ll sum = 0;
        for (ll i = 0; i < n; i++) {
            ll temp;
            cin >> temp;
            sum += temp;
        }
        cout << sum-n << endl;
    }
    return 0;   
}

Measured memory_bytes: 3620
from collections import deque

h, w = map(int, input().split())
inf = 10 ** 6
a = [[0] * (w + 2)] + [[0] + [inf] * w + [0] for _ in range(h)] + [[0] * (w + 2)]
d = deque()

for i in range(h):
    for j, k in enumerate(input()):
        if k == "#":
            a[i + 1][j + 1] = 0
            d.append((i + 1, j + 1))

stp = ((0, 1), (0, -1), (1, 0), (-1, 0))
res = 0

while d:
    x, y = d.popleft()
    for k, l in stp:
        nx, ny = x + k, y + l
        if a[x][y] + 1 < a[nx][ny]:
            a[nx][ny] = a[x][y] + 1
            res = max(res, a[nx][ny])
            d.append((nx, ny))
print(res)


Measured memory_bytes: 85340