akhauriyash/Code-Regression huggingface dataset:
/* 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define INF 1000000000
#define EPS 1e-20
#define pb push_back
constexpr double pi = 3.14159265358979323846;
/* 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ */

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int mi(INT_MAX), mx(0);
    vector<int> v(6);
    for (int i(0); i < 6; ++i) cin >> v[i];
    for (int i(0); i < 5; ++i) {
        mi = min(mi, v[i]);
        mx = max(mx, v[i]);
        if (abs(mi - mx) > v[5]) {
            cout << ":(";
            return 0;
        }
    }
    cout << "Yay!";
    cout << "\n"; /* new-line for VS code */
    return 0;
}

Measured memory_bytes: 256
// 
// 問題URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2180&lang=jp
// 中央*右
// 

#include <iostream>
#include <cmath>

using namespace std;

int N, s[86400+5], t[86400+5], u[86400+5];
double L;

bool one_day(double& left, double m){ //l:タンク容量の初期値, m: wpu(water per unit)
    int T = 0;
    for(int i = 0; i < N; i++){
        left = min(left+(s[i]-T)*m, L); //leftはLを超えない
        T = s[i];
        left = min(left+(t[i]-T)*(m-u[i]), L); //leftはLを超えない
		if(left < 0) return 0; //leftが0を切ればアウト
        T = t[i];
    }
    left = min(L, left + (86400-T)*m); //Tが余っていたらT=86400まで進める
    return true;
}

bool ok(double m){
    double left = L;
    if(!one_day(left, m)) return false;
    double left1 = left; //left=Lでの1日後の残り水量
    if(!one_day(left, m)) return false;

    if(abs(left1 - left) < 1e-9) return true; //1日後と2日後で水量に変化はないか?
    else{
        // printf("%f : false, left1 = %f, left2 = %f\n",m, left1, left);
        return false;
    } 
}

int main(){
    while(cin >> N >> L && N){
        for(int i = 0; i < N; i++){
            cin >> s[i] >> t[i] >> u[i];
        }
        double lo  = 0.0, hi=1e6;
        while (hi-lo>1e-9) {
            double m = (hi + lo)/2.0;
            if(ok(m)) hi = m;
            else{
                lo = m;
            } 
        }
        printf("%.12f\n", lo);   
        }
    }



Measured memory_bytes: 4160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fr front
#define fi first
#define sc second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
	IOS
	int n, ans = 0;
	string s;
	cin >> n >> s;
	
	map <char, int> ct;
	for(int i = 0; i < n; i++) ct[s[i]]++;
	
	for(int i = 0; i < n - ct['W']; i++){
		if(s[i] == 'W') ans++;
	}
	cout << ans << endl;
}

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

int main () {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if (x - r < 0) {
        cout << "No" << endl;
    }else if (x + r > W) {
        cout << "No" << endl;
    }else if (y - r < 0) {
        cout << "No" << endl;
    }else if (y + r > H) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    
    return 0;
} 


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int posa=-1, posz=s.size();
  for(int i=0;i<s.size();i++){
  	if(posa==-1&&s.at(i)=='A')posa=i;
  	if(s.at(i)=='Z')posz=i;
  }
  cout << posz-posa+1 << endl;
}

Measured memory_bytes: 640
using System;

	public class Class1
	{
		public static void Main(String[] args)
		{
			double r =double.Parse(Console.ReadLine());
			double b=2d*r*Math.PI;
			double a=r*r*Math.PI;
			Console.WriteLine("{0} {1}",a,b);
			
			
			
		}
	}

Measured memory_bytes: 9140
n, m, l = map(int, input().split())

INF = 1 << 30
g = [[INF] * n for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    g[a][b] = c
    g[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            g[i][j] = min(g[i][j], g[i][k] + g[k][j])

h = [[INF] * n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if g[i][j] <= l:
            h[i][j] = 1

for k in range(n):
    for i in range(n):
        for j in range(n):
            h[i][j] = min(h[i][j], h[i][k] + h[k][j])

q = int(input())
for _ in range(q):
    s, t = map(lambda x: int(x) - 1, input().split())
    if h[s][t] == INF:
        print(-1)
    else:
        print(h[s][t] - 1)


Measured memory_bytes: 79448
#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 long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

unsigned int randxor() {
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t;
  t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}




int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(D + 1, vector<int>(26, 0));
  vector<vector<int>> last_day(D + 1, vector<int>(26, 0));
  vector<int> t(D);
  rep(i,D) rep(j,26) cin >> s[i + 1][j];


  int score = 0;
  auto Scoring = [&](int d, int id, int oid) {
    score += s[d][id];
  
    if (oid != -1) {
      t[d - 1] = id;
      score -= s[d][oid];
      for (int i = d; i <= D; i++) {
        if (last_day[i][oid] != d) break;
        last_day[i][oid] = last_day[i - 1][oid];
        score += c[oid] * (i - d);
        score -= c[oid] * (i - last_day[i][oid]);
      }

      for (int i = d; i <= D; i++) {
        if (last_day[i][id] == i) break;
        score += c[id] * (i - last_day[i][id]);
        last_day[i][id] = d;
        score -= c[id] * (i - last_day[i][id]);
      }
    } else {
      last_day[d][id] = d;
      for (int i = 0; i < 26; i++) {
        if (i != id) last_day[d][i] = last_day[d - 1][i];
        score -= c[i] * (d - last_day[d][i]); 
      }
    }
  };

  auto xinit = [&](){
    score = 0;
    for (int i = 0; i <= D; i++) {
      for (int j = 0; j < 26; j++) last_day[i][j] = 0;
    }
  };


  auto init = [&](){
    auto tmp = last_day;
    int ret = -INF;
    auto s = t;
    for (int i = 0; i < 26; i++) {
      xinit();
      for (int j = 0; j < D; j++) {
        t[j] = (i + j) % 26;
        Scoring(i + 1, (i + j) % 26, -1);
      }
      if (ret < score) {
        ret = score;
        tmp = last_day;
        s = t;
      }
    }
    t = s;
    last_day = tmp;
    score = ret;
  };
  
  //初期解生成 
  init();
  
  rep(p, 5000000) {

    int d = randxor() % D;
    int change_q = randxor() % 26;    
    int old_q = t[d];
    int old_score = score;
    Scoring(d + 1, change_q, old_q);
    if (score < old_score) {
      Scoring(d + 1, old_q, change_q);
    }
  }
  
  rep(i,D) cout << t[i] + 1 << endl;
  return 0;
} 

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli a,b,t;
    cin>>a>>b>>t;
    lli te=t/a;
    cout<<te*b;




   	return 0;
 }

Measured memory_bytes: 256
[N, M] = map(int, input().split())
As = [int(input()) for _ in range(M)]

Bs = []
if len(As) == 0:
    Bs.append(N + 1)
else:
    Bs.append(As[0])
    for i in range(M-1):
        Bs.append(As[i+1] - As[i] - 1)
    Bs.append(N - As[-1])

count = [0, 1, 1]
for i in range(3, max(Bs)+1):
    count.append(count[i - 1] + count[i - 2])

res = 1
for b in Bs:
    res *= count[b]
    res %= 1000000007

print(res)


Measured memory_bytes: 460020
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int a,b,h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));


int main(){
    int N, M, L;
    cin >> N >> M >> L;
    vector<vector<int>> A(N, vector<int>(M)), B(M, vector<int>(L));
    vector<vector<ll>> C(N, vector<ll>(L));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++) cin >> A[i][j];
    }
    for(int i = 0; i < M; i++){
        for(int j = 0; j < L; j++) cin >> B[i][j];
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < L; j++){
            ll sum = 0;
            for(int k = 0; k < M; k++){
                sum += A[i][k]*B[k][j];
            }
            C[i][j] = sum;
        }
    }
    for(int i =0; i < N; i++){
        for(int j = 0; j < L; j++){
            cout << C[i][j];
            if(j != L - 1) cout << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  if(S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'R')cout << 3 << endl;
  else if(S.at(0) == 'R' && S.at(1) == 'R')cout << 2 << endl;
  else if(S.at(2) == 'R' && S.at(1) == 'R')cout << 2 << endl;
  else if(S.at(0) == 'R')cout << 1 << endl;
  else if(S.at(1) == 'R')cout << 1 << endl;
  else if(S.at(2) == 'R')cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3620
/*
AtCoder Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int sumDigits(int x){
    string s = to_string(x);
    int sum = 0;
    for(char c : s){
        sum += (int)(c - '0');
    }
    return sum;
}

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

    int N;
    cin >> N;

    int B;
    int minsum = pow(10, 7);
    for(int A = 1; A < N; A++){
        B = N - A;
        minsum = min(minsum, sumDigits(A) + sumDigits(B));
    }

    cout << minsum << endl;

    return 0;
}


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

int main() {
  int n, d, s = 0;
  cin >> n >> d;
  vector<vector<int>> v(n, vector<int>(d));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++)
      cin >> v.at(i).at(j);
  }
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      double r = 0;
      for(int k = 0; k < d; k++)
        r += pow(v.at(i).at(k) - v.at(j).at(k), 2.0);
      r = sqrt(r);
      if(r == floor(r))
        s++;
    }
  }
  
  cout << s << endl;
      
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  // printf("Hello World\n") // Your code here!
    int a , b , c ;

    cin >> a;
    cin >> b;
    cin >> c;
    
    if (a<b&&b<c){
   cout << "Yes";

} else {
   cout<< "No";
}
   
    cout << endl;
}



Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#include<numeric>
 
using namespace std;
  
int main() {	
	int n;
	cin >> n;
	vector<int> a;
	int k;
	for (int i = 1; i <= n; i++) {
		cin >> k;
		a.push_back(k - i);
	}
	sort(a.begin(), a.end());
	long long ans{ 0 };
	int i = 0;
	int j = n-1;
	while (j>i) {
		ans += a[j] - a[i];
		j--;
		i++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
using namespace std;
/*
bool sw[1000001];
int i;
 
void sws(int k){
        if(k==1){
                sw[i]=true;
                return;
        }
        if(k%2==0) sws(k/2);
        else if(k%3==0) sws(k/3);
        else if(k%5==0) sws(k/5);
        return;
}
*/
// korenisuru
int dp[1000001];
int f(int n){
        if(~dp[n]) return dp[n];
        int ans = 0;
        if(n%2==0) ans |= f(n/2);
        if(n%3==0) ans |= f(n/3);
        if(n%5==0) ans |= f(n/5);
        return dp[n] = ans;
}
 
int main() {
        int k,m,n;
        for(int i = 0 ; i <= 1000000 ; i++) dp[i] = -1;
        dp[1] = 1;
        /*
        for(int j=0;j<1000001;j++) sw[j]=false;
        for(i=1;i<1000001;i++) sws(i);
        while(cin >> m,m){
                int ans=0;
                cin >> n;
                for(int j=m;j<=n;j++) if(sw[j]==true) ans++;
                cout << ans << endl;
        }*/
        while(cin >> m && m){
                cin >> n;
                int ans = 0;
                for(int i = m ; i <= n ; i++) ans += f(i);
                cout << ans << endl;
        }
        return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c;
   int x,y,z,w;
   cin>>a>>b>>c;
   x=a+b;
   y=a+c;
   z=b+c;
   w=min(x,y);
   cout<<min(w,z);


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int m1,m2,d1,d2;
int m[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> m1 >> d1 >> m2 >> d2;
	if(m[m1] == d1) cout << 1;
	else cout << 0;
	cout << endl;	
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

int a,b,c;

int main(){
	cin>>a>>b>>c;
	if(c%gcd(a,b)==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
use proconio::input;
use std::collections::BTreeSet;
use std::ops::Bound::Excluded;
use std::ops::Bound::Unbounded;
use rand::Rng;

const C:usize = 26;
const N_ITER:usize = 2000000;

fn main() {

    input!{
        d:usize,
        c:[i32;C],
        s:[[i32;C];d],
    };
    let mut t:Vec<usize> = (0..d).map(|x|x%C).collect();
    let mut occs = vec![BTreeSet::<i32>::new();C];
    for occ in &mut occs {
        occ.insert(-1);
    }
    let mut ans = 0;
    for (day,&ti) in t.iter().enumerate() {
        ans += s[day][ti];
        occs[ti].insert(day as i32);
        for j in 0..26 {
            let sc = (c[j] as i32) * ((day as i32) -*occs[j].iter().last().unwrap());
            ans -= sc;
        }
    }
    for occ in &mut occs {
        occ.insert(d as i32);
    }    

    let sum_lr = |l,r,n| n*(l+r)/2;
    let mut rng = rand::thread_rng();
    
    for turn in 0..N_ITER {
        let d = rng.gen::<usize>()%d;
        let q = rng.gen::<usize>()%C;
        let pre_q = t[d];
        let pre_ans = ans;
        let mut try_change = |d:usize,q:usize|{
            let pre_q = t[d];
            ans-=s[d][pre_q];
            ans+=s[d][q];
            t[d]=q;
            let d = d as i32;
            // for pre_q
            let mut calc = |q:usize,is_ins:bool| {
                if is_ins {
                    occs[q].insert(d);
                }
                else {
                    occs[q].remove(&d);
                }
                let pre_d = *occs[q].range((Unbounded,Excluded(&d))).last().unwrap();
                let nex_d = *occs[q].range((Excluded(&d),Unbounded)).next().unwrap();
                let lbig = d - pre_d;
                let rbig = nex_d - pre_d -1;
                let lsml = 0;
                let rsml = nex_d-d-1;
                let sc = sum_lr(lbig,rbig,nex_d-d)-sum_lr(lsml,rsml,nex_d-d);
                sc
            };
            
            ans -= calc(pre_q,false)*c[pre_q];
            ans += calc(q,true)*c[q];
            ans
        };
        let now_ans = try_change(d,q);
        let x = rng.gen::<usize>()%N_ITER;
        if now_ans<=pre_ans && x<=turn {
            try_change(d,pre_q);
        }
    }

    for tv in t {
        println!("{}",tv+1);
    }
}



Measured memory_bytes: 2732
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
LL n, m;
LL ans = 0;
/**********************************************/

int main(){
    cin >> n >> m;
    m /= 2;

    if(m - n >= 0){
        ans += n;
        m -= n;
        m /= 2;
        ans += m;
    }else{
        ans += m;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint n,i,mto=0;cin>>n;
	vector<llint>za(n+2);
	for(i=1;i<=n;i++){cin>>za[i];}
	for(i=0;i<=n;i++){mto+=abs(za[i]-za[i+1]);}
	for(i=1;i<=n;i++){
		llint gen=mto;
		gen-=abs(za[i-1]-za[i]);
		gen-=abs(za[i+1]-za[i]);
		gen+=abs(za[i-1]-za[i+1]);
		cout<<gen<<endl;
	}
	return 0;
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main{
  	public static void main(String[] args){
  		Scanner sc = new Scanner(System.in);
  		int N = sc.nextInt();
  		int M = sc.nextInt();
  		int sum = 0;
  		for(int i = 0; i < M; i++){
  	    	int A = sc.nextInt();
  	    	sum += A;
    	}
  		int freeDays = N - sum;
  		if(freeDays < 0){
  	    	freeDays = -1;
    	}
  		System.out.println(freeDays);
    }
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    int n,d;
    cin >> n >> d;

    int x[11][11];

    REP(i,n){
        REP(j,d){
            cin >> x[i][j];
        }
    }

    int cou=0;
    REP(i,n-1){
        REAP(j,i+1,n){
            double sum=0.0;
            REP(k,d){
                sum+= pow(x[i][k]-x[j][k],2.0);
            }

            double sqr = sqrt(sum);
            int flo = floor(sqr);
            double t = sqr-flo;
            if(t < 0.0000001){
                cou++;
            }
        }
    }

    cout << cou << endl;


}


Measured memory_bytes: 256
"use strict";

/**
 * @see https://practice.contest.atcoder.jp/tasks/practice_1
 * @param  {string} input
 * @returns {string}
 */
var main = function(input) {
    let numbers = input.split("\n")[1].split(" ").map(x => parseInt(x));
    let operations = 0;
    while (true) {
        const canDivide = numbers.every(n => ((n % 2) === 0));
        if (canDivide) {
            numbers = numbers.map(n => n / 2);
            operations++;
        } else {
            return operations;
        }
    }
};

const output = main(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(output); // console.log outputs with trailing new line!


Measured memory_bytes: 7500
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<utility>
using namespace std;
 
typedef long long ll;
 
int main(){
  ll a,b;
  cin >> a >> b;
  if(a!=1 && b!=1){
  cout << ( (a+1)/2 ) * ((b+1)/2) + (a/2) * (b/2);
  }else{
  	cout << 1;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	string s;
	cin >> s;
	n = s.length();
	string last = "";
	int res = 0;
	for(int i=0;i<n;i++) {
		//cerr << last << endl;
		if (last == "") {
			last = "";
			last.push_back(s[i]);
			res++;
		} else {
			if (last.length() == 1) {
				//if (i == n-1) continue;

				string tmp = "";
				tmp.push_back(s[i]);
				if (last == tmp) {
					if (i == n-1) continue;
					last = "";
					last.push_back(s[i]);
					last.push_back(s[i+1]);
					res ++;
					i++;
				} else {
					res ++;
					last = "";
					last.push_back(s[i]);
				}
			} else {
				res ++;
				last = "";
				last.push_back(s[i]);
			}
		}
	}

	cout << res;
	return 0;
}


Measured memory_bytes: 720
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <math.h>
#include <string>
#include <iostream>
#include <functional>
using namespace std;
typedef long long ll;

const int MN = 2 * 1e5 + 5;
int arr[MN];
int main()
{
	int N;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) scanf("%d", arr + i);

	int ans = 0;
	priority_queue<int, vector<int>, greater<int> > PQ;
	for (int i = 1; i <= N; i++)
	{
		if (PQ.empty() || arr[i] <= PQ.top())
			ans++;
		PQ.push(arr[i]);
	}
	printf("%d", ans);

	return 0;
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.size() - 1; i++)
        if (S[i] != S[i + 1])
            ans++;
    cout << ans;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
  int A, B;
  scanf("%d %d", &A, &B);
  
  int i, j, k, count = 0, tmp;
  for(i=A/10000;i<=B/10000;i++){
    for(j=0;j<10;j++){
      for(k=0;k<10;k++){
	tmp = i*10000 + j*1000 + k*100 + j*10 + i;
	if((A <= tmp) && (tmp <= B))count++;
      }
    }
  }

  printf("%d\n", count);
  
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
  char s[10];
  scanf("%s", s);
  
  if(s[0]=='S'){
    printf("Cloudy");
  }
  else if(s[0]=='C'){
    printf("Rainy");
  }
  else if(s[0]=='R'){
    printf("Sunny");
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <ctype.h>

int main(void){
  char s[35];
  char ans[4];
  fgets(s, 35, stdin);
  ans[0] = s[0];
  ans[3] = '\0';
  int c = 0;
  int f = 0;
  while(f != 2){
    if(s[c] == ' ' && f == 1) {
      ans[2] = s[c + 1];
      f++;
    }
    if(s[c] == ' ' && f == 0) {
      ans[1] = s[c + 1];
      f++;
    }
    c++;
  }
  for(int i = 0; i < 3; i++){
    ans[i] = toupper(ans[i]);
  }
  printf("%s\n", ans);

  return 0;
}

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



int main() {
    int a,b,c;
    cin>>a>>b;
    for(int i=1;i<=3;i++)
    {
        if((a*b*i)%2==1) {cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int a,b,t;
scanf("%d%d",&a,&b);
if(a<b){
	t=a;
	a=b;
	b=t;
}
for(;;){
if(b==0)break;	
t=a%b;
a=b;
b=t;
}
printf("%d\n",a);
  return 0;
}



Measured memory_bytes: 2096
N = int(input())
A = [int(i) for i in input().split()]

L, R = [A[-1]], [A[-1]]
for i in range(1, N+1):
    L.append((L[-1]+1)//2+A[-1-i])
    R.append((R[-1]+A[-1-i]))
L = L[::-1]
R = R[::-1]

if L[0] >= 2:
    print(-1)
    exit()

ans = 1
p = 1
for i in range(1, N+1):
    ans += min(p*2, R[i])
    p = min(p*2, R[i])-A[i]
print(ans)


Measured memory_bytes: 98768
def solve(n, k, p_list):
    p_list_s = list(sorted(p_list))
    return sum(p_list_s[:k])


def main():
    n, k = map(int, input().split())
    p_list = list(map(int, input().split()))
    res = solve(n, k, p_list)
    print(res)


def test():
    assert solve(5, 3, [50, 100, 80, 120, 80]) == 210
    assert solve(1, 1, [1000]) == 1000


if __name__ == "__main__":
    test()
    main()


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

#define INF 1e18
#define fr first
#define sc second
#define mk make_pair
#define pb push_back

long long min(long long a, long long b){ return a < b ? a : b; }

int main(){
    long long n, s;
    long long ans = INF;
    scanf("%lld%lld", &n, &s);
    for(int i = 2; i <= 10000005; i++){
        long long temp = n;
        long long res = 0;
        while(temp){
            res += temp % i;
            temp /= i;
        }
        if(res == s) ans = min(i, ans);
    }
    for(long long x = 1; x <= min(s, 10000005); x++){
        long long y = s - x;
        long long b = (n - y) / x;

        if(b * x != n - y) continue;

        if(y >= b || x >= b || b == 1) continue;

        ans = min(b, ans);
    }
    if(ans == INF){
        if(n == s) printf("%lld", n + 1);

        else printf("-1");
    }
    else printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){

    static int a,b,k ;
    scanf ("%d%d%d",&a,&b,&k) ;
    
    if ( a+k-1<b-k+1 ){
        
        for (int i=0; i<k; i++ ){
            
            printf ("%d\n",a+i) ;
            
        }
        
        for (int i=0; i<k; i++ ){
            
            printf ("%d\n",b-k+i+1) ;
            
        }
        
    } else {
        
        for (int i=a; i<=b; i++){
            
            printf ("%d\n",i) ;
            
        }
        
    }
    
    return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll n;
  cin >> n;
  n--;
  string ans;
  while (n >= 0) {
    ll a = n % 26;
    n = n / 26;
    n--;
    ans.push_back('a' + a);
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Queue<Integer> q = new PriorityQueue<>(Collections.reverseOrder());

		for (int i = 0; i < N; i++) {
			q.add(sc.nextInt());
		}

		while (M != 0) {
			q.add(q.poll() / 2);
			M--;
		}

		long answer = 0;
		for (int item : q) {
			answer += item;
		}

		System.out.println(answer);

	}
}

Measured memory_bytes: 60904
def main():
  N=int(input())
  A=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(60):
    c=0
    for j in A:
      if j>>i&1:
        c+=1
    ans+=pow(2,i,mod)*c*(N-c)
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()

Measured memory_bytes: 50960
program abc129d
  implicit none
  character(2000),dimension(:),allocatable :: s
  integer :: h, w, i, j, c, ans
  integer,dimension(:,:,:),allocatable :: grid

  read *, h, w
  allocate(s(h),grid(2,w,h))
  grid = 0

  do i = 1,h
     read *, s(i)
     c = 1
     do j = 1,w
        if (s(i)(j:j)=='#') then
           c = 1
        else
           grid(1,j,i) = c
           c = c + 1
        end if
     end do
     do j = w-1,1,-1
        if (grid(1,j,i)==0.or.grid(1,j+1,i)==0) cycle
        grid(1,j,i) = grid(1,j+1,i)
     end do
  end do

  do j = 1,w
     c = 1
     do i = 1,h
        if (s(i)(j:j)=='#') then
           c = 1
        else
           grid(2,j,i) = c
           c = c + 1
        end if
     end do
     do i = h-1,1,-1
        if (grid(2,j,i)==0.or.grid(2,j,i+1)==0) cycle
        grid(2,j,i) = grid(2,j,i+1)
     end do
  end do

  ans = 0
  do i = 1,h
     do j = 1,w
        if (ans < sum(grid(:,j,i))) ans = sum(grid(:,j,i))
     end do
  end do
  print *, ans-1
end program abc129d


Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int k, x; cin >> k >> x;
    for(int i = x - k + 1; i < x; i++) {
        cout << i << " ";
    }   
    for(int i = x; i < x + k; i++) {
        cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin >> a;
    for(int i = 1; i < 4; i++){
        if(a[i] == a[i-1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
s, e = map(int, input().split())

if s < 0 and e < 0:
    print("Positive" if abs(e-s) %2 == 1 else "Negative")
elif (s < 0 and e > 0) or (s > 0 and e < 0):
    print("Zero")
elif s > 0 and e > 0:
    print("Positive")

Measured memory_bytes: 3060
using AtCoderBeginnerContest139.Questions;
using AtCoderBeginnerContest139.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest139.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var ab = inputStream.ReadIntArray();
            var a = ab[0];
            var b = ab[1];

            var receptacles = 1;
            var taps = 0;

            while (receptacles < b)
            {
                receptacles += a - 1;
                taps++;
            }

            yield return taps;
        }
    }
}


namespace AtCoderBeginnerContest139
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest139.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest139.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    long long n;
    cin >> n;

    long long ans = LLONG_MAX;
    for(long long a=1; a*a<=n; ++a){
        if(n % a != 0)
            continue;
        long long b = n / a;
        ans = min(ans, a + b - 2);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int a;
    int b;
    cin >> a >> b;
    if(b >= a) {
        cout << a << endl;
    } else {
        cout << a - 1 << endl;
    }
    return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  
  vector<int64_t> H(N);
  for(int i=0;i<N;++i){
    cin>>H[i];
  }
  
  vector<vector<int>> G(N);
  for(int i=0;i<M;++i){
    int a,b;
    cin>>a>>b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  int ans=0;
  for(int i=0;i<N;++i){
    int h=H[i];
    bool flag=true;
    for(auto j:G[i]){
      if(h<=H[j]){
      flag=false;
      break;
      }
    }
   if(flag) ++ans;
  }
  
  cout<<ans<<endl;
}


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

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define RESET(x) memset((x), 0, sizeof(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define ALL(x) (x).begin(), (x).end()
#define ALLSIZE(x,n) (x), (x)+(n)
#define SQR(x) ((x)*(x))
#define CUBE(x) (SQR(x)*(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main(){
	ll N;
	scll(N);
	ll cnt = 0;
	ll tmp;
	while (N--){
		scll(tmp);
		while (!(tmp & 1)){
			++cnt;
			tmp >>= 1;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define fi first
#define se second

int n,c;
pair<int,int> x[100005];
pair<int,int> lf[100005];
pair<int,int> rt[100005];
signed main(){
	cin >> n >> c;
	for(int i = 1 ; i <= n ; i ++)
		cin >> x[i].fi >> x[i].se;
	sort(x + 1, x + n + 1);
	int cur = 0, dis = 0, ans = 0;
	for(int i = 1 ; i <= n ; i ++){
		cur -= (x[i].fi - dis);
		cur += x[i].se;
		dis = x[i].fi;
		if(lf[i - 1].fi < cur) lf[i] = {cur, i};
		else lf[i] = lf[i - 1];
		ans = max(ans, lf[i].fi);
	}
	cur = 0, dis = 0;
	for(int i = n ; i >= 1 ; i --){
		cur -= (c - x[i].fi - dis);
		cur += x[i].se;
		dis = c - x[i].fi;
		ans = max(ans, cur - dis + lf[i - 1].fi);
	}
	cur = 0, dis = 0;
	for(int i = n ; i >= 1 ; i --){
		cur -= (c - x[i].fi - dis);
		cur += x[i].se;
		dis = c - x[i].fi;
		if(rt[i + 1].fi < cur) rt[i] = {cur, i};
		else rt[i] = rt[i + 1];
		ans = max(ans, rt[i].fi);
	}
	cur = 0, dis = 0;
	for(int i = 1 ; i <= n ; i ++){
		cur -= (x[i].fi - dis);
		cur += x[i].se;
		dis = x[i].fi;
		ans = max(ans, cur - dis + rt[i + 1].fi);
	}
	cout << ans;
}


Measured memory_bytes: 4992
import java.util.*;
import java.io.*;

public class Main {

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

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        
        int n = Integer.parseInt(sc.next());
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++){
            a.add(Integer.parseInt(sc.next()));
        }
        
        if(n < 3){
            out.println(Collections.max(a));
            out.flush();
            return;
        }
        
        ArrayList<Integer> left = new ArrayList<>();
        ArrayList<Integer> right = new ArrayList<>();
        
        left.add(a.get(0));
        right.add(a.get(n-1));
        
        for(int i = 1; i < n; i++){
            if(left.get(i-1) > a.get(i)){
                left.add(gcd(left.get(i-1), a.get(i)));
            } else {
                left.add(gcd(a.get(i), left.get(i-1)));
            }
            if(right.get(i-1) > a.get(n-1-i)){
                right.add(gcd(right.get(i-1), a.get(n-1-i)));
            } else {
                right.add(gcd(a.get(n-1-i), right.get(i-1)));
            }
        }
        Collections.reverse(right);
        
        ArrayList<Integer> g = new ArrayList<>();
        g.add(left.get(n-2));
        g.add(right.get(1));
        
        for(int i = 1; i < n-1; i++){
            int l = left.get(i-1);
            int r = right.get(i+1);
            if(l > r){
                g.add(gcd(l, r));
            } else {
                g.add(gcd(r, l));
            }
        }
        out.println(Collections.max(g));
        
        out.flush();
    }
}


Measured memory_bytes: 51104
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int n, m, s, t, x, y;
vector <vector <int> > adj;

void bfs () {
	queue <pii> q;
	q.push({s, 0});
	int d[int(1e5) + 1][3];
	d[s][0] = 0;
	bool visited[int(1e5) + 1][3];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++)
			visited[i][j] = false;
	visited[s][0] = true;
	while (!q.empty()) {
		pii p = q.front();
		q.pop();
		if (p.first == t and p.second == 0) {
			break;
		}
		int u = p.first;
		int par = p.second;
		// cerr << "Error " << u << ' ' << par << '\n';	
		for (auto v : adj[u]) {
		// cerr<< "U"<< u << "v" << v << '\n';
			if (!visited[v][(par + 1)%3]) {
				visited[v][(par + 1) % 3] = true;
				d[v][(par + 1) % 3] = d[u][par] + 1;
				q.push({v, (par + 1)%3});
			}
		}
	}
	if (!visited[t][0])
		cout << "-1\n";
	else
		cout << d[t][0]/3 << "\n";
}

int main () {
	cin >> n >> m;
	adj.assign(n, vector <int>());
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		x--, y--;
		adj[x].push_back(y);
	}
	cin >> s >> t;
	s--, t--;
	bfs();
	return 0;
}

Measured memory_bytes: 7168
#include<iostream>
#include<vector>
struct union_find{
  size_t n;
  std::vector<int> par;
  size_t group;
  union_find(){}
  union_find(size_t _n):n(_n),group(_n){
    par.resize(n,-1);
  }
  void reset(size_t _n){
    n = _n;
    group = n;
    par.clear();
    par.resize(n,-1);
  }
  int root(int k){
    if(par[k]<0)return k;
    return par[k] = root(par[k]);
  }
  int size(int k){
    k = root(k);
    return -par[k];
  }
  auto operator[](int k){
    return size(k);
  }
  bool unite(int a,int b){
    a = root(a);
    b = root(b);
    if(a==b)return false;
    if(size(a)<size(b))std::swap(a,b);
    group--;
    par[a] += par[b];
    par[b] = a;
    return true;
  }
  auto operator()(int a,int b){
    return unite(a,b);
  }
  bool same(int a,int b){
    return root(a) == root(b);
  }
};

int main(){
  using namespace std;

  int n,q;
  cin>>n>>q;
  union_find uni(n);
  while(q--){
    int t,u,v;
    cin>>t>>u>>v;
    if(t==0)uni(u,v);
    if(t==1)cout<<uni.same(u,v)<<endl;
  }
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
int n,m;
map<int,int>mp;
multiset<int>val;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)mp[i]=0,val.insert(0);
	for(int i=1;i<=n;i++){
		int L,R;scanf("%d%d",&L,&R);
		if(R!=m){
			auto it=mp.upper_bound(R+1);
			if(it!=mp.begin()){
				it--;
				if(it->first!=R+1){
					int v=it->second+(R+1-it->first);
					mp[R+1]=v;
					val.insert(v);
				}
			}
		}
		auto it=mp.lower_bound(L);
		while(it!=mp.end()&&it->first<=R){
			val.erase(val.find(it->second));
			it=mp.erase(it);
		}
		if(!val.empty())printf("%d\n",i+*val.begin());
		else puts("-1");
	}
}

Measured memory_bytes: 22496
#include <stdio.h>

int abs(int a){
	if(a>0) return a;
	else return -1*a;
}
int min(int a,int b){
	if(a<b) return a;
	else return b;
}

int main(void) {
	int N=0, K=0;
	scanf("%d%d",&N,&K);
	int step[N];
	for(int i=0;i<N;i++){
		scanf("%d",&step[i]);
	}
	int dp[N];
	int m;
	dp[0] = 0;
	//dp[1] = abs(step[0]-step[1]);
	for(int i=1;i<N;i++){
		  m = dp[i-1]+abs(step[i]-step[i-1]);
		//dp[i] = min(dp[i-1]+abs(step[i]-step[i-1]),dp[i-2]+abs(step[i]-step[i-2]));
		for(int j=min(i,K);j>0;j--){
		  m = min(m,dp[i-j]+abs(step[i]-step[i-j]));
		}
		dp[i] = m;
	}
	printf("%d",dp[N-1]);
	/*for(int i=0;i<N;i++){
		printf("%d\n",dp[i]);
	}*/
	return 0;
}

Measured memory_bytes: 896