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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

using P = pair<int, int>;

int main() {
    ll H, W, N;
    cin >> H >> W >> N;
    map<P, int> mp;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        for (int dy = -1; dy <= 1; dy++) {
            for (int dx = -1; dx <= 1; dx++) {
                int x = b + dx;
                int y = a + dy;
                if (x < 1 || W - 1 <= x || y < 1 || H - 1 <= y) continue;
                mp[P(x, y)]++;
            }
        }
    }

    ll black = 0;
    vector<ll> ans(10);
    for (auto m: mp) {
        ans[m.second]++;
        black++;
    }
    ans[0] = (H - 2) * (W - 2) - black;
    
    rep(i, 10) cout << ans[i] << endl;
}


Measured memory_bytes: 58496
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i, n)         for(int i=0; i<n; i++)
#define fo(i, k, n)     for(int i=k; i<n; i++)
#define forr(i, a, b)   for(int i=a; i<=b; i++)
#define rf(i,n)         for(int i=n;i>=0;i--)
typedef unsigned long long ull;
typedef pair<int ,int> pr;
#define MAX 100005
#define INF 1000000009
#define   sq(n)         (n*n)
#define p(n) cout<<n<<endl
#define pb push_back
#define py cout<<"YES"<<endl;
#define pn cout<<"NO"<<endl;
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll lcm ( ll a, ll b )
{
    return ( a / __gcd ( a, b ) ) * b;
}

int bin_ser(int *a,int n,int x)
{
    int l=0;
    int h=n-1;
    while(l<=h)
    {
        int mid=l+((h-l)/2);
        if(a[mid]==x)
        {
          return mid;
        }
        else if(a[mid]<x)
        {
            l=mid+1;
        }
        else
        {
            h=mid-1;
        }
    }
}

int main()
{
    __FastIO;

      int a,b,c;
      cin>>a>>b>>c;
      float d=a/(float)c;
      if(d<=b)
      {
            cout<<"Yes"<<endl;
      }
      else
      {
          cout<<"No"<<endl;
      }

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	int dp[n][3];
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for (int i = 1; i < n; i++) {
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][1], dp[i - 1][0]);
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u)	a--;
	else if (t == u)	b--;
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b;
string x,y,z;
int32_t main(){
CODE_START;
cin>>x>>y;
cin>>a>>b;
cin>>z;
if(z==x){
    cout<<a-1<<' '<<b<<endl;
}else cout<<a<<' '<<b-1<<endl;
}




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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(a) "(" << #a << ": " << (a) << ")"

template<typename T>
void chmin(T &x, T y) { x = min(x, y); }

template<typename T>
void chmax(T &x, T y) { x = max(x, y); }

typedef long long int lli;
typedef long double ld;
typedef tuple<int,int> P;

const int INF = INT_MAX/2 - 1;
const double EPS = 1e-14;
const int dx[4] = {0, 1, 0, -1}; // {-1,  0,  1, -1, 1, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0}; // {-1, -1, -1,  0, 0,  1, 1, 1};

int solve(int n, int k, int mim) {
  if (n == 0) return 1;
  if (k == 0) return 0;
  int sum = 0;
  for (int m = mim; m * m <= n; ++m) {
    sum += solve(n - m * m, k - 1, m);
  }
  return sum;
}

int main() {
  cout << fixed << setprecision(10);
  int n;
  while (cin >> n and n) {
    cout << solve(n, 4, 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 2980
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while(true) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }

    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	scanf("%d", &n);
	vector<vector<double> > dp(n + 1, vector<double>(n + 1, 1));
	fill(dp[n].begin(), dp[n].begin() + n / 2 + 1, 0);
	for (int i = n - 1; i >= 0; --i) {
		double p;
		scanf("%lf", &p);
		for (int j = 0; j <= i; ++j)
			dp[i][j] = dp[i + 1][j + 1] * p + dp[i + 1][j] * (1 - p);
	}
	printf("%.9lf\n", dp[0][0]);
	return 0;
}

Measured memory_bytes: 70656
#include <stdio.h>
#include <string.h>
int main(){
  char s[100 + 1];
  scanf("%s",s);
  int n=strlen(s);
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(s[i]=='L'){
        puts("No");
        return 0;
      }
    }else{
      if(s[i]=='R'){
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 a, b;
	std::string s;
	std::cin >> a >> b >> s;
	bool f = 1;
	rep(i, 0, s.length()) {
		if (i == a) {
			if (s[i] != '-') {
				f = 0;
			}
		}
		else {
			if ('0' > s[i] || s[i] > '9') {
				f = 0;
			}
		}
	}
	std::cout << (f ? "Yes" : "No") << "\n";
	return 0;
}

Measured memory_bytes: 256
import itertools


n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
perm = [i for i in range(1, n+1)]
a = 0
b = 0
for i, x in enumerate(itertools.permutations(perm)):
    if x == p:
        a = i
    if x == q:
        b = i
print(abs(a - b))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

const ll MOD = 998244353;
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;

    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll d[n];
    rep(i, n){
        cin >> d[i];
    }
    ll vmax = *max_element(d, d+n);
    ll cnt[vmax+1] = {};

    rep(i, n){
        cnt[d[i]]++;
    }

    ll vmin = *min_element(cnt, cnt+vmax+1);
    if(vmin == 0){
        cout << 0 << endl;
        return 0;
    }

    if(d[0] != 0){
        cout << 0 << endl;
        return 0;
    }

    reps(i, 1, n){
        if(d[i] == 0){
            cout << 0 << endl;
        return 0;
        }
    }

    ll ans = 1;
    reps(i, 1, vmax+1){
        ans = (ans * mod_pow(cnt[i-1], cnt[i], MOD)) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){

int p;
char r;
char Q;
r='A';
while(1){

scanf("%c",&Q);
if(Q=='#')break;
if(Q=='\n')
{
if(r=='B')printf("Yes\n");
else printf("No\n");

r='A';
}


else if(r=='A')
{if(Q=='0')r='X';
else if(Q=='1')r='Y';
else r='H';}

else if(r=='X')
{
if(Q=='1')r='Z';
else r='H';}

else if(r=='Y')
{if(Q=='0')r='X';
else r='H';}

else if(r=='Z')
{if(Q=='0')r='W';
else if(Q=='1')r='B';
else r='H';}

else if(r=='W')
{if(Q=='0')r='B';
else if(Q=='1')r='Y';
else r='H';}

else if(r=='B')
{if(Q=='0')r='Y';
else if(Q=='1')r='X';
else r='H';}




}

return 0;
}

Measured memory_bytes: 944
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,w,ans=0;
vector<vector<int>> a,dp;
signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 cin>>n>>w;
 dp=vector<vector<int>>(n+5,vector<int>(w+5,0));
 a=vector<vector<int>>(n+5,vector<int>(2));
 for(int i=1;i<=n;i++)
 {
      cin>>a[i][0]>>a[i][1];
 }
 
 for(int i=1;i<=n;i++)
 {
      for(int j=0;j<=w;j++)
      {
           if(j>=a[i][0])
           dp[i][j]=dp[i-1][j-a[i][0]]+a[i][1];
           dp[i][j]=max(dp[i-1][j],dp[i][j]);
      }
 }
 for(int i=0;i<=w;i++)
 ans=max(ans,dp[n][i]);
 cout<<ans;
 
} 

Measured memory_bytes: 83328
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}

map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
int main() {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a);
    vector<ll> sum;
    vector<ll> q(b);
    vector<ll> r(c);
    REP(i, a) { cin >> p[i]; }
    REP(i, b) { cin >> q[i]; }
    REP(i, c) { cin >> r[i]; }
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());
    REP(i, x) { sum.push_back(p[i]); }
    REP(i, y) { sum.push_back(q[i]); }
    REP(i, c) { sum.push_back(r[i]); }
    sort(sum.rbegin(), sum.rend());
    ll ans = 0;
    REP(i, x + y) { ans += sum[i]; }
    cout << ans << endl;
}

Measured memory_bytes: 9776
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int l=0,r,n,m;
  cin>>n>>m;
  r=n;
  while(m--)
  {
    int a,b;
    cin>>a>>b;
    l=max(l,a);
    r=min(b,r);
  }
  cout<<max(0,r-l+1)<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<utility>
#include<string.h>
#include<queue>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int n,a,b,c,x;
    int y[105]={};
    int ran[10005]={};
    while(1==1)
    {
        scanf("%d %d %d %d %d\n",&n,&a,&b,&c,&x);
        if(n==0&& a==0&&b==0&&c==0&&x==0)return 0;
        REP(i,105)y[i]=-1;
        REP(i,n)scanf("%d",&y[i]);
        ran[0]=x;
        REP(i,10004)ran[i+1]=(ran[i]*a+b)%c;
        int poi=0;
        int ypo=0;
        while(poi<=10000)
        {
            if(y[ypo]==ran[poi])
            {
                ypo++;
            }
            if(ypo==n)break;
            poi++;
        }
        if(ypo!=n)printf("-1\n");
        else printf("%d\n",poi);
    }
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    int a,b;
    int c[3];
    cin>>a>>b;
    c[0]=a+b;
    c[1]=a-b;
    c[2]=a*b;
    sort(c,c+3);
    cout<<c[2];
 
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
	double x1,y1;
	double x2,y2;
	double distance;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	distance=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
	printf("%.8f\n",distance);
	return 0;
}

Measured memory_bytes: 656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int my_sort(const void *v1, const void *v2)
{
    return( *(long long*)v1 - *(long long*)v2 );
}

int main(int argc, void **arg)
{
    long long n, i;
    long long v[50];
    double x = 0;

    scanf("%lld", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%lld", &v[i]);
    }

    qsort(v, n, sizeof(long long), my_sort);

    x = v[0];
    for (i = 1; i < n; i++)
    {
        x = (x+(double)v[i])/2.0;
    }
    printf("%lf\n", x);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
  int i, j, k, n, ans = -10e8;
  scanf("%d", &n);
  int f[n][10], p[n][11];
  for(i = 0; i < n; ++i) for(j = 0; j < 10; ++j) scanf("%d", &f[i][j]);
  for(i = 0; i < n; ++i) for(j = 0; j < 11; ++j) scanf("%d", &p[i][j]);
  for(i = 1; i < 1024; ++i) {
    int tmp = 0;
    for(j = 0; j < n; ++j) {
      int cnt = 0;
      for(k = 0; k < 10; ++k) {
        if((1 & i >> k) && f[j][k]) cnt++;
      }
      tmp += p[j][cnt];
    }
    if(tmp > ans) ans = tmp;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
use proconio::{input, fastout};
use proconio::marker::Usize1;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        hhh: [usize; n],
        ab: [(Usize1, Usize1); m],
    }
    let mut heights = vec![1u64; n];
    for (a, b) in ab {
        if hhh[a] <= hhh[b] { heights[a] = 0; }
        if hhh[a] >= hhh[b] { heights[b] = 0; }
    }
    let ans: u64 = heights.iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 7172
def f(n):
    return 2**(n+2)-3
def g(n):
    return 2**(n+1)-1
def p(x,n):
    if x==1:
        return 0
    if n==1:
        if 2<=x<=4:
            return x-1
        elif x>4:
            return 3
    if x==f(n-1)+2:
        return g(n-1)+1
    if x>=2*f(n-1)+2:
        return 2*g(n-1)+1
    if x<f(n-1)+2:
        return p(x-1,n-1)
    if x<2*f(n-1)+2:
        return g(n-1)+1+p(x-f(n-1)-2,n-1)
N,X = map(int,input().split())
print(p(X,N))

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, D[101000], M;
vector<int>E[101000];
bool Pos(int a, int pp) {
	int i;
	for (i = 0; i < E[a].size(); i++) {
		if (E[a][i] == pp)continue;
		if (!Pos(E[a][i], a))return false;
	}
	vector<int>TP;
	for (i = 0; i < E[a].size(); i++) {
		if (E[a][i] != pp)TP.push_back(D[E[a][i]] + 1);
	}
	sort(TP.begin(), TP.end());
	if (!TP.empty() && TP.back() > M)return false;
	int sz = TP.size();
	if (sz%2 == 0) {
		for (i = 0; i <sz; i++) if (TP[i] + TP[sz - i - 1] > M)break;
		if (i == sz) {
			D[a] = 0;
			return true;
		}
		else {
			if (!pp)return false;
			int b = 0, e = sz - 2, mid, rr = -1;
			while (b <= e) {
				mid = (b + e) >> 1;
				for (i = 0; i < sz - 2; i++) {
					int b = i, e = sz - i - 2;
					if (b >= mid)b++;
					if (e <= mid)e--;
					if (TP[b] + TP[e] > M)break;
				}
				if (i == sz - 2)rr = mid, e = mid - 1;
				else b = mid + 1;
			}
			if (rr == -1)return false;
			D[a] = TP[rr];
			return true;
		}
	}
	else {
		int b = 0, e = sz - 1, mid, rr = -1;
		while (b <= e) {
			mid = (b + e) >> 1;
			for (i = 0; i < sz - 1; i++) {
				int b = i, e = sz - i - 1;
				if (b >= mid)b++;
				if (e <= mid)e--;
				if (TP[b] + TP[e] > M)break;
			}
			if (i == sz - 1)rr = mid, e = mid - 1;
			else b = mid + 1;
		}
		if (rr == -1)return false;
		D[a] = TP[rr];
		return true;
	}
}
int main() {
	int i, a, b, S = 0;
	scanf("%d", &n);
	for (i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	for (i = 1; i <= n; i++) {
		S += (E[i].size() - 1) / 2;
	}
	int  e = n, r = 0;
	b = 1;
	while (b <= e) {
		M = (b + e) >> 1;
		if (Pos(1, 0)) {
			r = M;
			e = M - 1;
		}
		else b = M + 1;
	}
	printf("%d %d\n", S + 1, r);
}

Measured memory_bytes: 16768
A, B, K = map(int, input().split())
if B - A + 1 <= 2*K:
    for i in range(A, B+1):
        print(i)
else:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)

Measured memory_bytes: 3060
// Author: wlzhouzhuan
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define rint register int 
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = (x << 3) + (x << 1) + op - '0'; op = getchar(); }
  return neg * x;
}

int N, a, opt, target, ans;

int main(){
    scanf("%d", &N);
    for(int i=1; i<=N; i++){
        scanf("%d", &opt);
        a=log2(opt);
        if((1<<a)<opt){
            if(target>a)   target=a;
            else        a++;

        }
        if(a>target)   ans+=a-target, target=a;
        if(a<target)   target=a;
    }
    printf("%d", ans);
    return 0;
}

/*
const int N = 100005;
const int mod = 1e9 + 7;
int a[N], n, ans;
int inv[N];

ll fac(int n) {
  ll res = 1;
  for (rint i = 1; i <= n; i++) {
    res = 1ll * res * i % mod;
  }
  return res;
}

int main() {
  n = read();
  inv[1] = 1;
  for (rint i = 2; i <= n; i++) {
    inv[i] = 1ll * inv[mod % i] * (mod - mod / i) % mod;
  }
  for (rint i = 2; i <= n; i++) {
    inv[i] = (inv[i] + inv[i - 1]) % mod;
  }
  for (rint i = 1; i <= n; i++) {
    a[i] = read();
    if (i > 1) {
      ans += 1ll * (a[i] - a[i - 1]) * inv[i - 1] % mod;
      if (ans > mod) ans -= mod;
    }
  }
  printf("%lld\n", 1ll * ans * fac(n - 1) % mod);
  return 0;
}*/ 

Measured memory_bytes: 512
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
   ll r;
   cin >> r;
   cout << 2*3.14*r << endl;
}

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


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
ll a[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    for(ll i=1;i<=n;i++)cin>>a[i],a[i]-=i;
    sort(a+1,a+n+1);
    ll b = a[(n+1)/2];
    ll ans = 0;
    for(ll i=1;i<=n;i++)ans+=abs(a[i]-b);
    cout<<ans;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
char data[8][8];


struct P{
	P(){};
	P(int a,int b){
		x=a;
		y=b;
	}
	int x,y;
};

bool input(){
	for(int i=0;i<8;i++){
		if( scanf( "%s",data[i] ) == EOF )return false;
	}
	return true;
}
int main(){
	
	while(input()){
		P o=P(-1,-1);
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(data[i][j]=='1'){
					o=P(j,i);
					goto suc;
				}
			}
		}
		suc:;
		{
			for(int i=0;i<2;i++){
				for(int j=0;j<2;j++){
					if(o.y+i>=8 || o.x+j>=8)goto fail1;
					if(data[o.y+i][o.x+j]!='1')goto fail1;
				}
			}
			cout<<"A"<<endl;
			continue;
			fail1:;
		}
		{
			for(int i=0;i<4;i++){
				if(o.y+i>=8)goto fail2;
				if(data[o.y+i][o.x]!='1')goto fail2;
			}
			cout<<"B"<<endl;
			continue;
			fail2:; 
		}
		{
			for(int i=0;i<4;i++){
				if(o.x+i>=8)goto fail3;
				if(data[o.y][o.x+i]!='1')goto fail3;
			}
			cout<<"C"<<endl;
			continue;
			fail3:;
		}
		{
			if(o.y+2>=8 || o.x-1<0)goto fail4;
			if(data[o.y+1][o.x]!='1')goto fail4;
			if(data[o.y+1][o.x-1]!='1')goto fail4;
			if(data[o.y+2][o.x-1]!='1')goto fail4;
			cout<<"D"<<endl;
			continue;
			fail4:;
		}
		{
			if(o.x+2>=8 || o.y+1>=8)goto fail5;
			if(data[o.y][o.x+1]!='1')goto fail5;
			if(data[o.y+1][o.x+1]!='1')goto fail5;
			if(data[o.y+1][o.x+2]!='1')goto fail5;
			cout<<"E"<<endl;
			continue;
			fail5:;
		}
		{
			if(o.x+1>=8 || o.y+2>=8)goto fail6;
			if(data[o.y+1][o.x]!='1')goto fail6;
			if(data[o.y+1][o.x+1]!='1')goto fail6;
			if(data[o.y+2][o.x+1]!='1')goto fail6;
			cout<<"F"<<endl;
			continue;
			fail6:;
		}
		{
			if(o.x!=-1)cout<<"G"<<endl;
		}
	}
}	

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n,k,x,sum=0;
    cin>>n>>k;
    for (int i=0;i<n;i++) {
        cin>>x;
        if (x*2<(k-x)*2) {
            sum=sum+x*2;
        } else {
            sum=sum+(k-x)*2;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define mp(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define all(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
	int n, ct, k;
	vec<int> v;
	
	ct = 0;
	cin >> n;
	v.rs(n);
	rep(i,n)
		cin >> v[i];
	k = 1;
	rep(i,n){
		if(v[i] == k)	k++;
		else ct++;
	}
	if(ct == n)	cout << -1;
	else cout << ct << '\n';
}




Measured memory_bytes: 1024
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pob pop_back
#define ft first
#define sc second
#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define ctz __builtin_ctz
typedef pair<int, int> pii;
const int maxn = 1e6;
 
	int n ,a[maxn] ,res;	  
int main()
{FAST;
        cin >> n;
        forp(i ,0 ,n)
        cin >> a[i] ,res += ctz(a[i]);
        out(res);
    return 0;
}
 












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

int main()
{
  int ans = 0;
  string S, T;
  cin >> S >> T;
  rep(i, S.size())
  {
    if(!(S[i] == T[i]))
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3920
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  ds <- replicateM n readLn :: IO [Int]
  print . length . duplicateDelete $ sort ds

duplicateDelete :: [Int] -> [Int]
duplicateDelete [] = []
duplicateDelete (a:ns) = case ns of
  [] -> [a]
  (b:ns')  | a == b -> duplicateDelete (a:ns')
           | otherwise -> a : duplicateDelete (b:ns')


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

namespace AtCoder.Abc
{
    class A_163_Circle_Pond
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            int r = int.Parse(Console.ReadLine());

            double result = 2 * r * Math.PI;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27540
#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    // printf("%d %d",a,b);
    if (a == b)
        printf("a == b\n");
    else if (a < b)
        printf("a < b\n");
    else if (a > b)
        printf("a > b\n");
    return (0);
}


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

int main(){
  int64_t n,m;
  int64_t k;
  cin >>n>>m>>k;
  vector<int64_t>a(n);
  vector<int64_t>b(m);
  vector<int64_t>as(n+1,0);
  vector<int64_t>bs(m+1,0);
  for(int64_t i=0;i<n;i++){
    cin>>a.at(i);
    as.at(i+1)=as.at(i)+a.at(i);
  }
  for(int64_t i=0;i<m;i++){
    cin>>b.at(i);
    bs.at(i+1)=bs.at(i)+b.at(i);
  }
  int64_t tmp=m;
  int64_t ans=0;
  for(int64_t i=0;i<n+1;i++){
    if(as.at(i)>k)break;
    for(int64_t j=tmp;j>=0;j--){
      if(as.at(i)+bs.at(j)<=k){
        ans=max(ans,i+j);
        tmp=j;
        break;
      }
    }
  }
  cout <<ans<<endl;
}

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

using namespace std;

// void get_from_key(multimap<string, int> m, string key) {
//   auto p = m.equal_range(key);
//   for (auto itr = p.first; itr != p.second; itr++) {
//     cout << itr->second << endl;
//   }
// }

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

  int n;
  cin >> n;

  multimap<string, int> m;

  int cmd, val;
  string lhd, rhd;
  string key;

  for (int i = 0; i < n; i++) {
    cin >> cmd;

    switch (cmd) {
      case 0:
        cin >> key >> val;
        // m[key] = val;
        m.insert(make_pair(key, val));
        break;

      case 1: {
        cin >> key;
        // get_from_key(m, key);
        multimap<string, int>::iterator itr = m.lower_bound(key);
        multimap<string, int>::iterator end = m.upper_bound(key);

        for (; itr != end; itr++) {
          cout << itr->second << endl;
        }

        break;
      }

      case 2:
        cin >> key;
        m.erase(key);
        break;

      case 3: {
        cin >> lhd >> rhd;

        multimap<string, int>::iterator end = m.upper_bound(rhd);
        for (auto itr = m.lower_bound(lhd); itr != end; itr++) {
          cout << itr->first << " " << itr->second << endl;
        }
        break;
      }
    }
  }
}




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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef pair<int, int> P;

int main(){
  int n,x,t;
  cin>>n>>x>>t;
  
  int c=dup(n,x);
  
  cout<<c*t;
  
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define inf 1e9
void solve(){
	int n,k;
	cin>>n>>k;
	int a[n];
	rep(i,0,n){
		cin>>a[i];
	}
	sort(a,a+n);
	ll sum=0;
	rep(i,0,n-k){
		sum+=a[i];
	}
	cout<<sum<<endl;
}

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

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100010],num[3][100010];
int pos[3][100010],b[100010];
bool cmp(int x,int y) {return b[x]>b[y];}
int main()
{
	scanf("%d",&n);
	int ans=n+1;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int tot[3];tot[1]=tot[2]=0;
	for(int k=1;k<=2;k++)
	{
		for(int i=k;i<=n;i+=2)
		{
			tot[k]++;num[k][a[i]]++;
		}
	}
	for(int k=1;k<=2;k++) for(int i=1;i<=1e5;i++) pos[k][i]=i;
	int N=1e5;
	for(int i=1;i<=1e5;i++) b[i]=num[1][i];
	//printf("%d\n",b[1]);
	sort(pos[1]+1,pos[1]+N+1,cmp);
	for(int i=1;i<=1e5;i++) b[i]=num[2][i];
	//printf("num:%d %d %d\n",b[1],num[2][1],num[2][0]);
	sort(pos[2]+1,pos[2]+N+1,cmp);
	//printf("%d %d\n",pos[1][1],pos[2][1]);
	for(int i=1;i<=2000;i++)
		for(int j=1;j<=2000;j++)
		{
			if(pos[1][i]!=pos[2][j])
			{
				//printf("%d %d %d\n",ans,i,j);
				ans=min(ans,(tot[1]-num[1][pos[1][i]])+(tot[2]-num[2][pos[2][j]]));
			}
		}
	printf("%d",ans);
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  string s;
  cin >> s;
  int ans = 0;
  rep (i, s.size()) {
    if (s[i] == '+') ans++;
    else ans--;
  }
  P(ans);

  return 0;
}



Measured memory_bytes: 256
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

int poww(int a, int b){
    a%=MOD;
    int res=1;
    while(b>0){
        if(b&1)res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

int ncr(int n,int r){
    if(r>n-r)r=n-r;
    int ans=1;
    for(int i=1;i<=r;i++){
        ans=((ans*(n-i+1)%MOD)*poww(i,MOD-2))%MOD;
    }
    return ans;
}

int sub_mod(int a, int b) {
    a %= MOD, b %= MOD;
    a -= b;
    if (a < 0)a += MOD;
    return a;
}

int add_mod(int a, int b) {
    a %= MOD, b %= MOD;
    return (a + b) % MOD;
}

int mul_mod(int a, int b) {
    a %= MOD, b %= MOD;
    return (a * b) % MOD;
}

int div_mod(int a, int b) {
    a %= MOD, b %= MOD;
    return mul_mod(a , poww(b, MOD - 2));
}

const int nax = 1e6+5;
int pow8[nax], pow2[nax];

signed main() {
	tezz
 

	int n;
	cin >> n;
	pow8[0] = pow2[0] = 1;
	for(int i=1; i<=n; i++){
		pow8[i] = (pow8[i-1] * 8)%MOD;
		pow2[i] = (pow2[i-1] * 2)%MOD;
	}
	if(n==1){
		cout << 0 << endl;
	}
	else{
		int ans = 0, ncr=n;
		for(int i=2; i<=n; i++){
			ncr = mul_mod(ncr, n-i+1);
			ncr = div_mod(ncr, i);
			ans = add_mod(ans, mul_mod(ncr, mul_mod(pow8[n-i], sub_mod(pow2[i], 2))));
		}
		cout << ans << endl;
	}
 
	return 0;
}  

Measured memory_bytes: 19196
#include <cstdio>
#include <algorithm>
#include <vector>

int n, k;
int a[200010];
std::vector<int> v;

int main(){
	scanf("%d %d", &n, &k);
	for(int i=0; i<n; ++i) scanf("%d", &a[i]);
	std::sort(a, a+n);
	int t = 0;
	for(int i=0; i<n; ++i){
		if(t != a[i]) v.push_back(1);
		else ++v[v.size()-1];
		t = a[i];
	}
	std::sort(v.begin(), v.end());
	int ans = 0;
	for(int i=0; i<(int)v.size()-k; ++i)
		ans += v[i];
	printf("%d\n", ans);
}

Measured memory_bytes: 2168
n = int(input())
ans = 10
i = 1


def dig(n):
    ret = 0
    while n > 0:
        ret += 1
        n //= 10
    return ret


while i*i <= n:
    if n % i == 0:
        ans = min(ans, max(dig(i), dig(n//i)))
    i += 1

print(ans)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
        int d = sc.nextInt();
        int x = c-a;
        int y = d-b;
		StringBuilder sb = new StringBuilder();
        
        for(int i=0;i<x;i++){sb.append("R");
                            }
        for(int i=0;i<y;i++){sb.append("U");
                              }
        for(int i=0;i<x;i++){sb.append("L");
                            }
        for(int i=0;i<y;i++){sb.append("D");
                             }
        sb.append("D");
        x++;
        y++;
        for(int i=0;i<x;i++){sb.append("R");
                            }
        for(int i=0;i<y;i++){sb.append("U");
                             }
        sb.append("LU");
        for(int i=0;i<x;i++){sb.append("L");
                            }
        for(int i=0;i<y;i++){sb.append("D");
                             }
        sb.append("R");
        String s = sb.toString();
		System.out.println(s);
	}
}


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

int main()
{
  int m ,ans;
  string s;
  cin >> s;
  for(m=0;m<6;m++){
  if(s.at(m) >= 'a' && s.at(m) <= 'z')
  ans ++ ;}
  
  if(s.at(2) == s.at(3) && s.at(4) == s.at (5) && s.size() == 6 && ans == 6 ){
       	cout << "Yes" ;}
    else
      cout << "No" << endl ;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double 	a[100005];
int main(){
	int n,k;
	double win;
    cin>>n>>k;
    a[0]=1;
    for(int i=1;i<=n;i++){
		a[i]=a[i-1]*0.5;
	}
    for(int i=1;i<=n;i++){
        double pi=1.0/n;
        int cur=i;	
        while(cur<k){
			cur*=2;
			pi*=0.5;
		}
        win+=pi;
    }
    printf("%.12f",win);
	return 0;
}


Measured memory_bytes: 1024
function Main(input){
  var inp = input.split('\n');
  var N = parseInt(inp[0]);
  var A = inp[1].split(' ').map((i) => { return parseInt(i); });

  var count = 0;
  while(isPlume(A)){
    count++;
    A = A.map((i) => {
      return Math.floor(i / 2);
    });
  }

  function isPlume(A){
    var flag = true;
    for(var i of A){
      (i % 2 === 0) ? '' : flag = false;
    }
    return flag;
  }
  console.log(count);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main()
{
  int m, d, ans = 0;
  cin >> m >> d;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= d; j++)
      if (j / 10 >= 2 && j % 10 >= 2)
        ans += (j / 10 * (j % 10) == i);
  cout << ans << endl;
}


Measured memory_bytes: 256
import math

n, k = list(map(int, input().split()))

ans = 0
for i in range(1, n+1):
    ans += 1 / (2 ** int(math.log2((k-1)//i)+1 if (k-1)//i != 0 else 0))

print('{:.9}'.format(ans / n))

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

int main(){
  int N;
  cin >> N;
  bool a = false;
  for(int i = 0; i <= N; i++){
    if((int)(i * 1.08) == N){
      a = true;
      cout << i << endl;
      break;
    }
  }
  if(!a) cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll dp[310][310][310];

int main()
{
	int n,m;cin >> n >> m;
	
	dp[0][n-1][1] = 1;
	
	REP(i,m)
	{
		REP(j,n+1)
		{
			REP(k,n+1)
			{
				if(j > 0)
				{
					dp[i+1][j-1][k] = (dp[i+1][j-1][k] + j*dp[i][j][k])%MOD;
				}
				
				if(j+k < n)
				{
					dp[i+1][j][n-j] = (dp[i+1][j][n-j] + k*dp[i][j][k])%MOD;
					dp[i+1][j][k] = (dp[i+1][j][k] + (n-j-k)*dp[i][j][k])%MOD;
				}
				else
				{
					dp[i+1][j][k] = (dp[i+1][j][k] + k*dp[i][j][k])%MOD;
				}
			}
		}
//		SHOW2d(dp[i+1],n+1,n+1);
	}

	cout << dp[m][0][n] << endl;
	
	
	return 0;
}

Measured memory_bytes: 226816
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

print((II()+II())*II()//2)


Measured memory_bytes: 9132
#include <iostream>

using namespace std;
 
    
    
int main(){
  int n;
  cin>>n;
  int num[n-1];

  for (int i = 0; i < n-1; i++)
  {
    cin>>num[i];
  }
  
  int buka[n]={};
 for (int i = 0; i < n-1; i++)
  {
    buka[num[i]-1]=buka[num[i]-1]+1;
  }
 
  for (int i = 0; i < n; i++)
  {
    cout<<buka[i]<<endl;
  }
  
    return 0;
}

Measured memory_bytes: 5176
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int K = sc.nextInt();

        System.out.println(solve(N, K));
    }

    private static long solve(int N, int K) {
        long sum = 0;

        for (int i=K; i<=N+1; i++) {
            long count = (long)i * ((2*N-i+1) - (i-1)) /2 + 1;
            sum += count%MOD;
            sum %= MOD;

            // System.err.println(i + ": " + sum);
        }


        return sum;
    }
}

Measured memory_bytes: 35920
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)
#define size size()

int main(){
    int n;
    cin >> n;
    vi b(n+1);
    int max=0,ans;
    rp(i,n+1){
        int j=i;
        b.at(i)=0;
        while(j%2==0&&j>0){
            j/=2;
            b.at(i)++;
        }
        if(b.at(i)>max){
            max=b.at(i);
            ans=i;
        }
    }
    
    cout << (ans>0?ans:1) << endl;

    return 0;
}





Measured memory_bytes: 256
#include"bits/stdc++.h"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n)cin >> a[i];
    int sum = 0;
    REP(i, n) {
        if ((i + 1) % 2 == 1 && a[i] % 2 == 1)sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3576
n = int(input())
ans = True
for i in range(n):
    t,x,y = map(int,input().split())
    if (x+y)%2 != t%2:
        ans = False
    if x+y>t:
        ans = False
 
if ans:
    print("Yes")
else:
    print("No") 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
#define INF 0x3f3f3f3f
typedef long long ll;
typedef pair<int, int> ii;

int main(void) {
	ios_base::sync_with_stdio(false);

	int n; cin >> n;

	priority_queue<int> pq;
	while (n--) {
		int x; cin >> x;
		pq.emp(x);
	}

	int a = 0, b = 0;
	bool f = 1;
	while (!pq.empty()) {
		if (f) a += pq.top();
		else b+=pq.top();
		pq.pop();
		f ^=1;
	}
	cout <<a-b << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    n = int(input())
    XY = [tuple(map(int,input().split())) for i in range(n)]
    XY.sort()
    ans = 0
    SXY = [[0,0,0] for i in range(n)]
    for i in range(n):
        SXY[i][0] = XY[i][0] + XY[i][1] 
        SXY[i][1] = XY[i][0]
        SXY[i][2] = XY[i][1]
    SXY.sort()
    ans = abs(SXY[0][1]-SXY[-1][1])+abs(SXY[0][2]-SXY[-1][2]) 
    SXY = [[0,0,0] for i in range(n)]
    for i in range(n):
        SXY[i][0] = XY[i][1] - XY[i][0] 
        SXY[i][1] = XY[i][0]
        SXY[i][2] = XY[i][1]
    SXY.sort()
    ans = max(ans,abs(SXY[0][1]-SXY[-1][1])+abs(SXY[0][2]-SXY[-1][2])) 
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 83956
$N=<>;
$==hex 5x8;
for(-31..0){
	$=/=2;
	if($_%2){
		$%+=($|=$%-$=>$N)&&-(1<<-$_);
	}else{
		$%+=($|=$%+$=<$N)&&1<<-$_;
	}
	$s.=$|
}
print$s=~s/^0*\B//r


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<double> x(n);
  vector<double> y(n);
  for (int i = 0;i < n;i++){
    cin >> x[i] >> y[i];
  }
  vector<int> v(n);
  for (int i = 0;i < n;i++){
    v[i] = i;
  }
  
  double sum = 0;
  
  int f = 1;
  for (int i = 0;i < n;i++){
    f *= i+1;
  }
  
  //cout << f << endl;
  for (int i = 0;i < f;i++){
    for (int j = 0;j < n-1;j++){
      sum += sqrt((x[v[j+1]]-x[v[j]])*(x[v[j+1]]-x[v[j]]) + (y[v[j+1]]-y[v[j]])*(y[v[j+1]]-y[v[j]]));
    }
    next_permutation(v.begin(), v.end());
    //cout << sum << endl;
  }
  
  cout << fixed << setprecision(10);
  cout << sum/f << endl;
    
}

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

typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
const int INF=2012345678;
const ll LLINF=4012345678012345678LL;
const ll MOD=998244353; //1000000007
const ld PI=3.1415926535898;
const ld EPS=1e-9;
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(b==0)return a;return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll expo(ll b,ll p,ll m){ll res=1; while(p){if(p&1)res=(res*b)%m; b=(b*b)%m; p>>=1;} return res;}
inline ll modinv(ll a,ll m){return expo(a,m-2,m);}

int main(){
	int n,w;
	scanf("%d%d",&n,&w);
	ll a[n],b[n];
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
	}
	ll dp[100005]; dp[0]=0; for(int i=1;i<=w;i++)dp[i]=-LLINF;
	for(int i=0;i<n;i++){
		for(int j=w;j>=a[i];j--){
			dp[j]=max((dp[j-a[i]]<=-LLINF?-LLINF:dp[j-a[i]]+b[i]),dp[j]);
		}
	}
	ll ans=0;
	for(int i=1;i<=w;i++)ans=max(ans,dp[i]);
	printf("%lld",ans);
}


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

int main(){
  int y,m,d;
  char c1,c2;
  cin>>y>>c1>>m>>c2>>d;
  if(m>=5){
    cout<<"TBD"<<endl;
  }else{
    cout<<"Heisei"<<endl;
  }
}


Measured memory_bytes: 256
a = [input() for _ in range(5)]
ans = 0
n = 10
N = 0
for i in range(5):
  if int(a[i]) % 10 == 0:
    ans += int(a[i])
  else:
    if n > int(a[i][-1]):
      n = int(a[i][-1])
      if N != 0:
        ans += N + 10 - N%10
        N = int(a[i])
      else:
        N = int(a[i])
    else:
      ans += int(a[i]) + 10 - int(a[i][-1])
print(ans + N)

Measured memory_bytes: 3064
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>

int root[8][8]={},pass[8]={},ans=0,cnt=0;

void deep(int x,int n){
    pass[x]=1;
    cnt++;
    for(int i=0;i<n;i++){
        if(cnt==n){
            ans++;
            break;
        }
        if(root[x][i]==1&&pass[i]==0){
            deep(i,n);
            cnt--;pass[i]=0;
        }
    }
}

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

Measured memory_bytes: 256
#include <stdio.h>
     
    int main(void)
    {
     int A, B, C;
     
     scanf("%d", &A);
     scanf("%d", &B);
     scanf("%d", &C);
    
     if (C >= A && C <= B) puts("Yes");
     else puts("No");
     //else printf("%d\n", A + B);
     
     
     return 0;
     
    }

Measured memory_bytes: 128
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0]);
  const X = input[1].split(" ").map(v => parseInt(v));
  t = X.reduce((p, c) => p + c);
  av = Math.round(t / N);
  total = 0;
  X.forEach(v => {
    total += Math.pow(v - av, 2);
  });
  console.log(total);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064