akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
 
using namespace std;
typedef long long ll;


int main()
{
	int N, K;
	scanf("%d %d", &N, &K);
	
	int count = 0;
	while(N > 0){
		N = N / K;
		count++;
	}
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  int n = max(A,B);
  int count = 0;
  while(true) {
    if(A % n  == 0 && B % n == 0) {
      count++;
    }
    if(count == K) {
      cout << n << endl;
      break;
    }
    n--;
  }
  return 0;
}

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

int q;
string x, y;
int memo[1000][1000];

void init(){
  for(int i = 0; i < x.size(); i++){
    for(int j = 0; j < y.size(); j++){
      memo[i][j] = -1;
    }
  }
}

int lcs(int xp, int yp){
  if(xp < 0 || yp < 0) return 0;
  if(memo[xp][yp] >= 0) return memo[xp][yp];

  if(x[xp] == y[yp]){
    return memo[xp][yp] = lcs(xp - 1, yp - 1) + 1;
  }else{
    return memo[xp][yp] = max(lcs(xp - 1, yp), lcs(xp, yp - 1));
  }
}

int main(void){
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> x >> y;
    init();
    cout << lcs(x.size() - 1, y.size() - 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 5200
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
int main() {

	int N;
	double result=0;
	cin >> N;
	vector<double> A(N);

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

	for (int i = 0; i < N; i++)
	{
		result += 1 / A[i];
	}
	result = 1 / result;

	cout << result;
}

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

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

void process();
int main(){
    process();
    return 0;
}
void process(){
    int N;
    ULL *H;
    int i;

    cin >> N;
    H = new ULL[N];
    for(i=0;i<N;i++){
        cin >> H[i];
    }
    for(i=N-2;i>=0;i--){
        if( H[i+1] < H[i] ){
            H[i]--;
            if( H[i+1] < H[i]){
                cout << "No" << endl;
                return;
            }
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

ll M;

ll modpow(ll x,ll n){
  if(n==0)return 1;
  if(n%2)return (modpow(x,n-1)*x)%M;
  else{
    ll halfpow=modpow(x,n/2)%M;
    return (halfpow*halfpow)%M;
  }
}

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

  int N;
  cin>>N>>M;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  vector<ll>sum(N+1);
  sum[0]=0;
  for(int i=1;i<=N;i++)sum[i]=(sum[i-1]%M+A[i-1]%M)%M;
  // (sum[l]-sum[r])%M==0
  ll ans=0;

  map<ll,int>m;
  for(int i=0;i<=N;i++){
    ans+=m[sum[i]];
    m[sum[i]]++;
  }
  cout<<ans<<endl;

  return 0;
}


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

int N, M;
vector<vector<int>> switches(11);
vector<int> kiguu(11);
vector<bool> switchs(11);
int counter = 0;

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

  int N, M;
  cin >> N >> M;
  priority_queue<int, vector<int>, greater<int>> pq;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    pq.push(a);
  }
  vector<pair<int, int>> change(M);
  for(int i = 0; i < M; i++){
    int b, c;
    cin >> b >> c;
    pair<int, int> p = make_pair(c, b);
    change.at(i) = p;
  }
  sort(change.begin(), change.end());
  reverse(change.begin(), change.end());
  bool flag = false;
  for(int i = 0; i < M; i++){
    while(change.at(i).second > 0){
      if(pq.top() < change.at(i).first){
        pq.pop();
        pq.push(change.at(i).first);
        change.at(i).second--;
      } else{
        flag = true;
        break;
      }
    }
    if(flag){
      break;
    }
  }
  long long sum = 0;
  for(int i = 0; i < N; i++){
    sum += pq.top();
    pq.pop();
  }
  cout << sum <<endl;
}


Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>

using namespace std;

bool solve(long long a, long long b, long long c, long long d) {
    if (a < b || d < b)return false;
    if (b - 1 < c + 1)return true;

    long long x = __gcd(b, d);
    a %= b;
    return a + (b - a - 1) / x * x <= c;
}

int main() {
    int t;
    cin >> t;
    for (; t > 0; t--) {
        long long a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << (solve(a, b, c, d) ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    // input
    val (dice, limit) = readLine()?.let { it.split(" ") }!!.map { it.toInt() }
    val sum = (1..dice).map {
        var temp = 1.0 / dice
        var now = it
        while( now < limit ) {
            now *= 2
            temp /= 2
        }
        temp
    }.sum()
    println(sum)


}


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

const long long mod=998244353;

int main()
{
	int n,k;
	cin>>n>>k;
	
	long long DP[n];
	long long sum[n+1];
	
	sum[n]=0;
	DP[n-1]=sum[n-1]=1;
	
	int l[k],r[k];
	
	for(int i=0;i<k;i++)
	{
		cin>>l[i]>>r[i];
	}
	
	for(int i=n-2;i>=0;i--)
	{
		DP[i]=0;
		
		for(int j=0;j<k;j++)
		{
			if(i+l[j]<n)
			{
				int _l=i+l[j];
				int _r=min(n-1,i+r[j]);
				
				DP[i]=(DP[i]+sum[_l]-sum[_r+1] + mod)%mod;
			}
		}
		
		sum[i]=(sum[i+1]+DP[i])%mod;
	}
	
	cout<<DP[0]<<endl;
	
	return 0;
}

Measured memory_bytes: 6756
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a, b = map(int, input().split())
    ans = 0
    i = 0
    while i < 2:
        if a >= b:
            ans += a
            a -= 1
        else:
            ans += b
            b -= 1
        i += 1
    print(ans)
    
if __name__ == '__main__':
    main()

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;

    int n,x,y;
    cin>>n>>x>>y;

    vector<int> arr(n+1);

    for(int i=1;i<=n;i++) {
        for(int j=i+1;j<=n;j++) {
            arr[min({j-i,abs(x-i)+1+abs(j-y)})]++;
        }
    }
    
    for(int i=1;i<n;i++) {
        cout<<arr[i]<<endl;
    }
}




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

int main(void)
{
    string s;
    cin >> s;

    int win = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'o')
        {
            win++;
        }
    }

    cout << ((win + (15 - s.length())) > 7 ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
N=list(map(int,input().split()))

if N[0]==N[1]==N[2]:
    ans=0

N.sort()
x=N[2]-N[1]
y=N[1]-N[0]

if x%2==1 and y%2==0:
    ans=y//2+x
elif x%2==1 and y%2==1:
    ans=(x+y)//2+(x+1)//2+1
elif x%2==0 and y%2==0:
    ans=x//2+(x+y)//2
else:
    ans=x//2+(x+y+1)//2+1

print(ans)




Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#define MAX_N 200050

using namespace std;

int dp[MAX_N];

int main(){
  int n;
  cin >> n;
  int h[MAX_N];
  for(int i=0;i < n;i++) cin >> h[i];
  
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  
  for(int i=2;i < n;i++){  
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stack>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n; cin >> n;
    vector<int> a(n);
    int ami = 1000000000;
    int ama = -1000000000;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        ami = min(ami, a[i]);
        ama = max(ama, a[i]);
    }

    int mi = 1000000000;
    for(int i=ami; i<ama; i++) {
        int c=0;
        for(int j=0; j<n; j++) {
            c +=(i-a[j])*(i-a[j]);
        }
        mi = min(c, mi);
    }

    if (ami == ama)
        cout << 0 << endl;
    else 
        cout << mi << endl;

    return 0;
}

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

int main(){
  int x, y, z;
  cin >> x >> y >> z;
  
  int tmp;
  tmp=x;
  x=y;
  y=tmp;
  tmp = z;
  z=x;
  x = tmp;
  
  cout << x << " " << y << " " << z << endl;
  return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int x = 1;
  int tA=0,tB=0;
 
  for (int i = 0; i < N; i++){
    tA=2*x;
    tB=x+K;
    if(tA > tB){
      x=tB;
    }else{
      x=tA;
    }
  }
  cout << x << endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF 1e6
int N;
int i,j,k;
vector<int> tv[202020];
queue<int> tp;
int mk[202020],mx;
int dfs(int aa){
    
    if(mk[aa]==1)
        return 0;
        //printf("%d ", aa);
    mk[aa] = 1;
    int i, a1 = 0, a2 = 0;

    fornum(i,0,tv[aa].size()){
        int a = dfs(tv[aa][i]);
        if(a1<a){
            a2 = a1;
            a1 = a;
        }else if(a2<a){
            a2 = a;
        }
    }
    //printf("%d:%d,%d\n", aa, a1, a2);
    if(a1+a2+1>mx){
        mx = a1 + a2+1;
    }
    return a1 + 1;
}
int main(){
    scanf("%d", &N);
    fornum(i,1,N){
        int a, b;
        scanf("%d%d", &a,& b);
        tv[a].push_back(b);
        tv[b].push_back(a);
    }
    fornum(i,0,N){
        if(tv[i+1].size()==1){
            dfs(i + 1);
            break;
        }
    }
    //printf("%d\n", mx);
    if((mx+1)%3){
        printf("First");
    }else{
        printf("Second");
    }
    
    return 0;
}

Measured memory_bytes: 21376
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;


//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)

//----***定数***----
#define MOD 1000000000+7;
#define INF 100000000000000000;
#define EPS 1e-9;
#define ALL(vec) (vec).begin(),(vec).end()
//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


signed main(){
  int N,a,ans=0,sum=0;
  cin>>N;
  vector<int> S(N,0);
  REP(i,0,N){
    cin>>a;
    S[i]=a;
    sum+=a;
  }
  if(sum%10==0){
    sort(ALL(S));
    int mini=10000+7;
    REP(i,0,N){
      if(S[i]%10!=0){
        mini=S[i];
        break;
      }
    }
    ans=max(sum-mini,(ll)0);
  }
  else{
    ans=sum;
  }

  print(ans)


}


Measured memory_bytes: 256
#include<stdio.h>

main() {
	int a[6], i, j, count = 0, sum = 0;
	scanf("%d %d", &a[0], &a[1]);
	scanf("%d %d", &a[2], &a[3]);
	scanf("%d %d", &a[4], &a[5]);
	for (i = 0;i < 6;++i) {
		for (j = i + 1;j < 6;++j) {
			if (a[i] == a[j]) {
				count++;
				if (count >= 2) {
					++count;
					break;
					
				}
			}
		}
		sum += count;
		count = 0;

	}
	if (sum == 2)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll a, b; char op; cin >> a >> op >> b;
  if (op == '+') cout << a + b << endl;
  else cout << a - b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  map<int, bool> found;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    if (found[A]) {
      cout << "NO" << endl;
      return 0;
    } else {
      found[A] = true;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 9600
import math

a,b,h,m= map(int, input().split())

x=360*(m/60)
y=360*((h+m/60)/12)
rad=abs(x-y)
ans=pow(a,2)+pow(b,2)-2*a*b*math.cos(math.radians(rad))
print(pow(ans,0.5))

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

int main() {
	int n,t, a;;
	cin >> n >> t >> a;
	vector<double> h(n);
	vector<double> temp(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		temp[i] = t - h[i] * 0.006;
	}
	double ans = 1000;
	int num;
	for (int i = 0; i < n; i++) {
		if (ans>abs(temp[i]-a)){
		ans = abs(temp[i]-a);
		num = i+1;
		}
	}
	cout << num << endl;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
s_list = list()
ans = [0 for i in range(N)]
flag = True
for i in range(M):
    s,c = map(int,input().split())
    
    if s==1 and c==0 and N!=1:
        flag = False
        
    if s in s_list:
        if ans[s-1] != c:
            flag = False
    else:
        s_list.append(s)
        ans[s-1] = c
if flag ==False:
    print(-1)
else:
    if N != 1 and ans[0]==0:
        ans[0] = 1
    ans = [str(i) for i in ans]
    print(''.join(ans))

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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;}

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;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int x; cin >> x;
    int left = 200, right = 599;
    REP(i, 0, 10){
        if(left <= x && right >= x){
            cout << 8 - i << endl;
            return 0;
        }
        left += 200; right += 200;
    }
}

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



int main() {
  vector<int> dx={-1,0,1,-1,1,-1,0,1};
  vector<int> dy={-1,-1,-1,0,0,1,1,1};
  
  int H,W;
  cin >> H >> W;
  vector<string> s(H);
  for(int i=0; i<H; i++){
    cin >> s.at(i);
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(s.at(i).at(j) == '#') continue;
      
      
      
      int num = 0;
      for(int d=0; d<8; d++){
        
          int ni = i+dy.at(d);
          int nj = j+dx.at(d);
          
          if(ni < 0 or H <= ni) continue;
          if(nj < 0 or W <= nj) continue;
          if(s.at(ni).at(nj) == '#') num++;
        
      }
      s.at(i).at(j) = char(num + '0');
        
    }
    
  }
  for(int i=0; i<H; i++){
    cout << s.at(i) << endl;
  }
 
  
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
#define __TRUE "YES"
#define __FALSE "NO"
#define p(x) cout << (x) << endl
using namespace std;

int main() {
  int a,b,x;
  cin >> a >> b >> x;
  if(a<=x && x<=a+b) {
    p(__TRUE);
  }else {
    p(__FALSE);
  }
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int d, t, s;
	cin >> d >> t >> s;
	if (s * t >= d) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(1<<n);
    rep(i,0,1<<n)scanf("%d",&a[i]);
    sort(ALL(a));
    bool fl=1;
    vector<int> s; s.push_back(a.back()); a.back()=-1;
    rep(rot,0,n){
        vector<int> pre=s;
        sort(ALL(pre));
        int idx=(1<<n)-1;
        while(pre.size()&&idx>=0){
            if(a[idx]==-1){
                idx--; continue;
            }
            if(a[idx]<pre.back()){
                s.push_back(a[idx]);
                pre.pop_back();
                a[idx]=-1;
            }
            idx--;
        }
        if(pre.size()){
            fl=0; break;
        }
    }
    printf(fl?"Yes":"No");
    return 0;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

ll g[65536];
vector<int> B[65536];
ll a[16][16];
ll d[65536];
int n;

int main(){
    fio;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    for(int b = 0; b < (1<<n); b++){
        vector<int> V;
        for(int j = 0; j < n; j++){
            if(b >> j & 1){
                for(int u : V) g[b] += a[u][j];
                V.push_back(j);
                B[b].push_back(1<<j);
            }
        }
    }
    for(int b = 1; b < (1<<n); b++){
        d[b] = LLONG_MIN;
        for(int c = b; c; c = (c-1) & b){
            d[b] = max(d[b], g[c] + d[b^c]);
        }
    }
    cout << d[(1<<n)-1] << '\n';
}

Measured memory_bytes: 8448
import java.util.*;
import static java.lang.System.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        
        long n = sc.nextLong();
        long cnt = 0;
        long num = n;
        while(true) {
        	num = num / 2;
        	if (num > 0)
        		cnt++;
        	else 
        	break;
        }
        long ans = 2;
        for(long i = 0; i < cnt; i++) {
        	ans *= 2;
        }
        if (n == 1)
        	ans = 2;
        out.println(ans - 1);
              
    }
static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
int main(){
	int n, k; cin>>n>>k;
	cout<<(n < 4 ? 100000 * (4-n) : 0) + (k < 4 ? 100000 * (4-k) : 0) + 400000 * (n == 1 && k == 1);
	return 0;
}

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

int main()
{
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3668
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N)]
M=0
C_list=[]

for n in range(N,0,-1):
    K=N//(n)
    for m in range(K):
        if m==0:
            B[n-1]+=A[n-1]
        else:
            B[n-1]+=B[n-1+n*m]
    B[n-1]%=2
    if B[n-1]:
        C_list.append(n)
    M+=B[n-1]

S=" ".join(list(map(str,reversed(C_list))))
print(M)
print(S)


Measured memory_bytes: 20508
# -*- coding: utf-8 -*-
s = input();
charList=list(s);
result=0;
tmp=0;
for c in charList:
 if c=='A' or c=='T' or c=='G' or c=='C':
   tmp=tmp+1;
 else:
  if tmp>result:
   result=tmp;
  tmp=0;
if tmp>result:
 result=tmp;
print(result);


Measured memory_bytes: 2940
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<tuple>

using ll = long long;
using tp = std::tuple<int,int>;
int main(){
    int N,K;
    std::cin >> N >>K;
    std::cout << (N <= 5 ? 0 : (N<=12) ? K/2 : K) << std::endl;
  	return 0;
    std::cin >> N >> K;
    std::vector<int>deg(N,2);
    std::vector<tp>edge;
    if(N - 2 < K or (N-1)*(N-2)/ 2 < K)  return puts("-1") * 0;
    deg.front() = deg.back() = 1;
    K -= (N - 2);
    for(int i = 0; i < N - 1; ++i){
        edge.emplace_back(i,i+1);
    }
    while(K > 0){
        auto mind = std::min_element(deg.begin(),deg.end());
        auto maxd = std::max_element(deg.begin(),deg.end());
        int idx = (int)(mind - deg.begin());
        int midx = (int)(maxd - deg.begin());
        if(*maxd - *mind <= K){
            //if(*maxd - *mind <= 0) return puts("-1" * 0);
            K -= (*maxd - *mind);
            auto itEnd = std::remove_if(edge.begin(),edge.end(), [&](tp t){
                int u,v;
                std::tie(u,v) = t;
                return (u == idx or v == idx);
            });
            edge.erase(itEnd,edge.end());
            edge.emplace_back(idx,midx);
        }
    }
    std::cout << edge.size() << std::endl;
    for(auto tp : edge){
        int u,v;
        std::tie(u,v) = tp;
        std:: cout << std::min(u,v) + 1 << " " << std::max(u,v) + 1 << std::endl;
    }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0; char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return x;
}
main()
{
	long long n = read();
    long long ans = n;
	for (int i = 1; i < n; ++i)
	{
        long long u = read(), v = read();
		if (u > v) swap(u, v);
        ans += i * (n - i + 1);
        ans -= u * (n - v + 1);
	}
	printf("%lld\n", ans);
	
	return 0;
}


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

const int N = 20;

long long n, cnt, res;
string s;
string a, b;
long long dp[N][N];

void solve(int mask) {
	memset (dp, 0, sizeof dp);
	a = b = "";
	for (int i = 0; i < n; i++)
		if ((mask >> (n - i - 1)) & 1)
			a = s[i] + a;
		else
			b = s[i] + b;		
	dp[0][0] = 1;
	for (int i = 0; i <= b.size(); i++) {
		for (int j = 0; j <= a.size(); j++) {
			if (i < b.size() && s[s.size() - i - j - 1] == b[b.size() - i - 1])
				dp[i + 1][j] += dp[i][j];
			if (j < a.size() && s[s.size() - i - j - 1] == a[a.size() - j - 1])
				dp[i][j + 1] += dp[i][j];	
		}
	}
	res += dp[b.size()][a.size()];			
}

int main() {
	cin >> n;
	cin >> s;
	for (long long mask = 0; mask < (1 << n); mask++)
		solve(mask);
	cout << res;
}















Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
bool ok[305][305][305];
double d[305][305][305];
int n,a[5];
double get(int x,int y,int z){
    if(ok[x][y][z]) return d[x][y][z];
    ok[x][y][z]=1;
    double D=n;
    if(x)D+=get(x-1,y,z)*x;
    if(y)D+=get(x+1,y-1,z)*y;
    if(z)D+=get(x,y+1,z-1)*z;
    return d[x][y][z]=D/(x+y+z);
}
int main(){
    ok[0][0][0]=1;
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        int x;
        scanf("%d",&x);
        ++a[x];
    }
    printf("%.10lf\n",get(a[1],a[2],a[3]));
	//system("pause");
	return 0;
}


Measured memory_bytes: 246144
#include <iostream>
using namespace std;
typedef long long LL;
LL gcd(LL a, LL b) {return b?gcd(b, a%b):a; }

int main()
{
    LL a, b;
    while(cin>>a>>b)
    {
        LL t = gcd(a, b);
        cout<<t<<" "<<a/t*b<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 400010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

int a[maxn], b[maxn], deg[maxn], n, cnt = 0;
ll ans = 0;
bool vis[maxn];
vector<int> nxt[maxn];
priority_queue<pii, vector<pii>, greater<pii> > Q;
template <class T> void read (T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
int main() {
  read(n);
  for (int i = 1, u, v; i <= n - 1; i++) {
    read(u), read(v), nxt[u].pb(v), nxt[v].pb(u), deg[u]++, deg[v]++;
  }
  for (int i = 1; i <= n; i++) {
    read(a[i]);
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    Q.push({deg[i], i});
  }
  while (!Q.empty()) {
    pii x = Q.top();
    Q.pop();
    if (vis[x.se])
      continue;
    vis[x.se] = true, ans += 1LL * a[++cnt] * x.fi, b[x.se] = a[cnt];
    for (auto &v : nxt[x.se]) {
      if (!vis[v])
        Q.push({--deg[v], v});
    }
  }
  printf("%lld\n", ans);
  for (int i = 1; i <= n; i++) {
    printf("%d ", b[i]);
  }
  return 0;
}

Measured memory_bytes: 15232
#include <iostream>
#include<vector>
#include <cstring>
#include <cstdio>
#include<cstdint>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
int n;
int f[100][14];
int p[100][15];
int main(){
  cin>>n;
rep(i,n)rep(j,10)cin>>f[i][j];
rep(i,n)rep(j,11)cin>>p[i][j];
int max=-(1<<30);
    for(int bit=1;bit<(1<<10);bit++){
        int sum=0;
        for(int i=0;i<n;i++){
            int count=0;
        rep(j,10)if((bit>>j & 1) && f[i][j])count++;
        sum+=p[i][count];
        }
        if(sum>max)max=sum;
        }
        cout<<max<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;
int second[10];
int s[10];

void prepare(int N){
    second[0]=1;
    for(int i=0;i<N;i++){
        second[i+1]=second[i]*2;
    }
}

void encode(int x,int N){
int p=N;
while(p>=0){
    
    if(x>=second[p]){
        s[p]=1;
        x-=second[p];
    }
    else{
        s[p]=0;
    }
    p--;
}
return ;

}



int main(){

string sen;
cin>>sen;


int N=sen.size();
N--;
char zero='0';

prepare(N);
long long ans=0;

long long hun[10];
hun[0]=1;
rep(i,9)hun[i+1]=hun[i]*10;


for(int i=0;i<second[N];i++){
    encode(i,N);
    
    queue<int>q;
    for(int k=0;k<N;k++){
        if(s[k]){
            q.push(sen[k]-zero);
            long long tmp=0;
            while(!q.empty())
            {
                tmp+=hun[q.size()-1]*q.front();
                q.pop();
            }
            //cout<<tmp<<" ";
            ans+=tmp;
        }
        else{
            q.push(sen[k]-zero);
        }
    }   
        q.push(sen[N]-zero);
        long long tmp=0;
        while(!q.empty())
        {

                tmp+=hun[q.size()-1]*q.front();
                q.pop();
        }
        //cout<<tmp<<" ";
        ans+=tmp;
}

cout<<ans<<endl;

return 0;

}
/*
125

176

9999999999

12656242944
*/


Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll=long long;

int N,K;
int main(){
  cin>>N>>K;
  ll ans=0;
  for(int b=1;b<=N;b++){
    ans+=max(b-K,0)*(N/b);
    ans+=max(N%b-K+1,0);
  }
  if(K==0) ans-=N;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 888
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int M, D;

    static void input()
    {
        cin = new Scanner();
        M = cin.nextInt();
        D = cin.nextInt();
    }
    static void solve()
    {
        input();
        int ans = 0;
        for(int m = 1; m <= M; m++)
        {
            for(int d = 22; d <= D; d++)
            {
                if (d % 10 >= 2 && m == (d / 10) * (d % 10))
                    ans++;
            }
        }
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13140
from collections import deque

k = int(input())
q = deque()
q.append(1)
d = [float("inf")] * k
d[1] = 1
while q:
    n = q.popleft()
    l, r = (n * 10) % k, (n + 1) % k
    if d[l] > d[n]:
        d[l] = d[n]
        q.appendleft(l)
    if d[r] > d[n] + 1:
        d[r] = d[n] + 1
        q.append(r)
print(d[0])


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    bool color[8]={};
    int count=0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i]<3200){
            color[a[i]/400]=true;
        }
        else count++;
    }
    int weak=0;
    for(int i = 0; i < 8; i++) {
        if(color[i]) weak++;
    }
    if(weak==0) cout << "1" << " " << count << "\n";
    else        cout << weak << " " << weak+count << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=500005,INF=1<<30,D=2000;
int N,Q;
int A[MAX],cnt[MAX],ans[MAX];
int sum=0,l=-1,r=-1;

struct dat{
    int l;
    int r;
    int id;
};

vector<dat> S;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>Q;
    for(int i=0;i<N;i++) cin>>A[i];
    
    S.resize(Q);
    for(int i=0;i<Q;i++){
        cin>>S[i].l>>S[i].r;
        S[i].id=i;
        S[i].l--;S[i].r--;
    }
    
    sort(all(S),[](auto a,auto b){
        if(a.l/D==b.l/D) return a.r<b.r;
        return a.l/D<b.l/D;
    });
    
    for(int i=0;i<Q;i++){
        while(S[i].r<r){
            cnt[A[r]]--;
            if(cnt[A[r]]==0) sum--;
            r--;
        }
        while(S[i].r>r){
            cnt[A[r+1]]++;
            if(cnt[A[r+1]]==1) sum++;
            r++;
        }
        
        while(S[i].l<l){
            cnt[A[l-1]]++;
            if(cnt[A[l-1]]==1) sum++;
            l--;
        }
        while(S[i].l>l){
            cnt[A[l]]--;
            if(cnt[A[l]]==0) sum--;
            l++;
        }
        
        ans[S[i].id]=sum;
    }
    
    for(int i=0;i<Q;i++) cout<<ans[i]<<"\n";
}


Measured memory_bytes: 15472
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    string s;
    cin >> s;

    for (char c : s)
    {
        if (c != ',')
        {
            cout << c;
        }
        else
        {
            cout << ' ';
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxN 102
#define inf 1000000001
using namespace std;

int n, W;
map < int, vector < int > > V;

int Wmin;

long long sum[4][maxN], ans;

void compSum()
{
    for (int t = 0; t < 4; ++ t)
    {
        int sz = V[Wmin + t].size();
        sort(V[Wmin + t].begin(), V[Wmin + t].end());
        for (int i = 1; i <= sz; ++ i)
            sum[t][i] = sum[t][i - 1] + 1LL * V[Wmin + t][sz - i];
    }
}

int main()
{
    scanf("%d %d", &n, &W);
    Wmin = inf;
    for (int i = 1; i <= n; ++ i)
    {
        int w, v;
        scanf("%d %d", &w, &v);
        V[w].push_back(v);
        Wmin = min(Wmin, w);
    }
    compSum();
    for (int i = 0; i <= V[Wmin].size() && 1LL * i * Wmin <= W; ++ i)
        for (int j = 0; j <= V[Wmin + 1].size() && 1LL * i * Wmin + 1LL * j * (Wmin + 1) <= W; ++ j)
            for (int k = 0; k <= V[Wmin + 2].size() && 1LL * i * Wmin + 1LL * j * (Wmin + 1) + k * (Wmin + 2) <= W; ++ k)
            {
                int l = (W - i * Wmin - j * (Wmin + 1) - k * (Wmin + 2)) / (Wmin + 3);
                ans = max(ans, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]);
            }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    int a = (n + 1) / 2;
    int b = n / 2;
    cout << fixed << setprecision(10) << (double)a / n;
    return 0;
}

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

struct Node {int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
    if (u == NIL) return;
    D[u] = d;
    setDepth(T[u].left,  d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u) {
    int h1 = 0, h2 = 0;
    if (T[u].left != NIL)
        h1 = setHeight(T[u].left) + 1;
    if (T[u].right != NIL)
        h2 = setHeight(T[u].right) + 1;
    return H[u] = (h1 > h2 ? h1 : h2);
}

// 節点 u の兄弟を返す
int getSibling(int u) {
    if (T[u].parent == NIL) return NIL;
    if (T[T[u].parent].left != u && T[T[u].parent].left != NIL)
        return T[T[u].parent].left;
    if (T[T[u].parent].right != u && T[T[u].parent].right != NIL)
        return T[T[u].parent].right;
    return NIL;
}

void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg = 0;
    if (T[u].left != NIL) deg++;
    if (T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if (T[u].parent == NIL) {
        printf("root\n");
    } else if (T[u].left == NIL && T[u].right == NIL){
        printf("leaf\n");
    } else {
        printf("internal node\n");
    }
}

int main() {
    int v, l, r, root = 0;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i) T[i].parent = NIL;

    for (int i = 0; i < n; ++i) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if (l != NIL) T[l].parent = v;
        if (r != NIL) T[r].parent = v;
    }

    for (int i = 0; i < n; ++i) if (T[i].parent == NIL) root = i;

    setDepth(root, 0);
    setHeight(root);

    for (int i = 0; i < n; ++i) print(i);

    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
#define per(i, a, b) for (int (i) = (a); (i) >= (b); --(i))
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define ff first
#define ss second
#define sz(x) ((int) x.size())
#define rd(type, ...) type __VA_ARGS__; sc(__VA_ARGS__)
#define rda(a, n) rep(i, 0, n) cin >> a[i];
#define rdaa(a, n, m) rep(i, 0, n) rep(j, 0, m) cin >> a[i][j];
#define rdv(type, v, n) vector<type> v(n); rep(__ii, 0, n) cin >> v[__ii]
#define rdm(type, v, h, w) vector<vector<type>> v(h, vector<type>(w)); rep(__ii, 0, h) rep(__jj, 0, w) cin >> v[__ii][__jj]
#define rdv2(type, n, ...)std::vector<type> __VA_ARGS__;MACRO_rdv2_Init(n, __VA_ARGS__); for(int w_=0; w_<n; ++w_){MACRO_rdv2_Scan(w_, __VA_ARGS__);}
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "] : ", debug_out(__VA_ARGS__)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
void solve();
signed main() {ios::sync_with_stdio(false); cin.tie(0);
  cout << fixed; cout.precision(20); solve(); return 0;}
template<typename T> void chmin(T &a, T b) {if (a > b) a = b;}
template<typename T> void chmax(T &a, T b) {if (a < b) a = b;}
template<typename T> void MACRO_rdv2_Init(int n, T& t) { t.resize(n); }
template<typename First, typename... Rest> void MACRO_rdv2_Init(int n, First& first, Rest& ...rest) { first.resize(n); MACRO_rdv2_Init(n, rest...); }
template<typename T> void MACRO_rdv2_Scan(int p, T& t) { std::cin >> t[p]; }
template<typename First, typename... Rest> void MACRO_rdv2_Scan(int p, First& first, Rest& ...rest) { std::cin >> first[p]; MACRO_rdv2_Scan(p, rest...); }
template<typename T> void wrv(const vector<T> &v) {rep(__ii, 0, sz(v)) {if (__ii) cout << ' '; cout << v[__ii];} cout << '\n';} 
template<typename T> void wrm(const vector<vector<T>> &v) {rep(__ii, 0, sz(v)) {rep(__jj, 0, v[__ii].size()) {if (__jj) cout << ' '; cout << v[__ii][__jj];} cout << '\n';}}
template<typename T> void sc(T& x) {cin >> x;}
template<typename Head, typename... Tail> void sc(Head& head, Tail&... tail) {cin >> head; sc(tail...);}
template<typename T> void wr(const T& x) {cout << x << '\n';}
template<typename Head, typename... Tail> void wr(const Head& head, const Tail&... tail) {cout << head << ' '; wr(tail...);}
template<typename T> void wrf(const T& x) {cout << x << endl;}
template<typename Head, typename... Tail> void wrf(const Head& head, const Tail&... tail) {cout << head << ' '; wrf(tail...);}
template<typename T> void debug_out(const T& x) {cerr << x << '\n';}
template<typename Head, typename... Tail> void debug_out(const Head& head, const Tail&... tail) {cerr << head << ' '; debug_out(tail...);}
template<typename... T> void err(const T&... cod) {wr(cod...); exit(0);}

ll f(ll h) {
  if (h == 0) return 0;
  return 1 + 2 * f(h / 2);
}

void solve() {
  rd(ll, h);
  wr(f(h));
}

Measured memory_bytes: 256
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import permutations

def main():
    A, B, C, X = [int(input()) for _ in [0] * 4]

    cnt = 0
    for i in range(A+1):
        for j in range(B+1):
            n = i * 500 + j * 100
            if n == X:
                cnt += 1
            elif n < X:
                if X - n <= C * 50:
                    cnt += 1
    print(cnt)

main()


Measured memory_bytes: 3060