akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(long long*)a > *(long long*)b){
        return -1;
    }else if (*(long long*)a == *(long long*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int ng, mid, ok;
    ng = -1, ok = n-1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (key <= a[mid]){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if (a[ok] >= key)return ok;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]);
        }
    }
}*/
long long mod = 1000000007;

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}





long long INF = 1000000000000000;
int head[100005];
int to[200005];
int next[200005];
long long cost[200005];
int n;
int q;
int k;
int x[100005];
int y[100005];
long long v[100005];

int dfs(int crt){
    int edge = head[crt];
    while (edge != -1){
        if (v[to[edge]] > v[crt] + cost[edge]){
            v[to[edge]] = v[crt] + cost[edge];
            dfs(to[edge]);
        }

        edge = next[edge];
    }

    return 0;
}


int main(void){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        head[i] = -1;
        v[i] = INF;
    }
    int a, b;
    long long c;
    for (int i = 0; i < (n-1)*2; i += 2){
        scanf("%d %d %lld", &a, &b, &c);
        next[i] = head[a];
        head[a] = i;
        to[i] = b;
        cost[i] = c;
        next[i+1] = head[b];
        head[b] = i+1;
        to[i+1] = a;
        cost[i+1] = c; 
    }
    scanf("%d %d", &q, &k);
    for (int i = 0; i < q; i++){
        scanf("%d %d", &x[i], &y[i]);
    }
    v[k] = 0;
    dfs(k);

    for (int i = 0; i < q; i++){
        printf("%lld\n", v[x[i]]+v[y[i]]);
    }

}


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

int main(){
  string s;
  int numB = 0;
  int numW = 0;
  int ans = 0;

  cin >>s;

  for(int i = 0; i < (int)(s.length()) ;i++){
      if(i%2 == 0){
          if(s[i] != '0')numB++;
      }else{
          if(s[i] != '1')numB++;
      }
  }

  for(int i = 0; i < (int)(s.length()) ;i++){
      if(i%2 == 0){
          if(s[i] != '1')numW++;
      }else{
          if(s[i] != '0')numW++;
      }
  }

  

  

    ans = min(numW,numB);
    cout <<ans<<endl;

  
  return 0;
  }

Measured memory_bytes: 512
S = input()
if S[0] == 'A':
    if S[1] != 'C' and S[-1] != 'C':
        if S.count('C') == 1:
            S = S.lstrip('A')
            S = S.replace('C','c')
            if S.islower():
                print("AC")
                exit(0)
 
print('WA')

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#define ll long long
#define N 2000010
using namespace std;
const int p = 1000000007;
int jie[N],ni[N];
const int inf = 2000005;
int c(int m,int n)
{
    return 1LL*jie[n]*ni[m]%p*ni[n-m]%p;
}
ll ans;
int ss(int x1,int y1,int x2,int y2,int x3,int y3)
{
    int as=0;
    for(int i=y1;i<=y2;i++)
    {
        (as+=1LL*c(x3-x2-1,x3-x2-1+y3-i)*c(x2-x1,x2-x1+i-y1)%p*(x2-x1+1+i-y1)%p)%=p;
    }
    for(int i=x1;i<=x2;i++)
    {
        (as+=1LL*c(y3-y2-1,y3-y2-1+x3-i)*c(y2-y1,y2-y1+i-x1)%p*(y2-y1+1+i-x1)%p)%=p;
    }
    return as;
}
int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
int calc(int a1,int b1,int a2,int b2)
{
    int as=0;
    as+=ss(a1,b1,x4,y4,a2,b2);
    as+=ss(a1,b1,x3-1,y3-1,a2,b2);as%=p;
    as-=ss(a1,b1,x3-1,y4,a2,b2);
    as-=ss(a1,b1,x4,y3-1,a2,b2);
    return (as%p+p)%p;
}
int solve(int x,int y)
{
    int as=0;
    as+=calc(x,y,x6+1,y6+1);as+=calc(x,y,x5,y5);as%=p;
    as-=calc(x,y,x6+1,y5);as-=calc(x,y,x5,y6+1);
    return (as%p+p)%p;
}
int main()
{
    jie[0]=ni[0]=ni[1]=1;
    for(int i=1;i<=inf;i++)jie[i]=1LL*jie[i-1]*i%p;
    for(int i=2;i<=inf;i++)ni[i]=1LL*(p-p/i)*ni[p%i]%p;
    for(int i=2;i<=inf;i++)ni[i]=1LL*ni[i-1]*ni[i]%p;
    scanf("%d%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5,&x6);
    scanf("%d%d%d%d%d%d",&y1,&y2,&y3,&y4,&y5,&y6);
    ans+=solve(x1-1,y1-1);
    ans+=solve(x2,y2);
    ans-=solve(x1-1,y2);
    ans-=solve(x2,y1-1);
    ans=(ans%p+p)%p;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll num;
    cin>>num;
    ll x;
    vll p,n,z;
    vpl ans;
    ll value=0;
    for(ll i=0;i<num;i++)
    {
        cin>>x;
        if(x>0)
            p.pb(x);
        else if(x<0)
            n.pb(x);
        else
            z.pb(x);
    }
    if((z.size())>0||((p.size())>0)&&((n.size()>0)))
    {
        ll f=0;
        for(ll i=1;i<(z.size());i++)
        {
            ans.pb(mp(0,0));
        }
        if((z.size())==0)
        {
            value=n[0];
            n.erase(n.begin());
        }
        for(ll i=1;i<(p.size());i++)
        {
            f=1;
            ans.pb(mp(value,p[i-1]));
            value-=p[i-1];
        }
        n.pb(value);
        ll pos=p.size();
        if(pos>0)
        value=p[pos-1];
        for(ll i=0;i<(n.size());i++)
        {
            if(n[i]==0)
                continue;
            ans.pb(mp(value,n[i]));
            value-=n[i];
        }
    }
    else
    {
        if(n.size()>0)
        {
            sort(n.begin(),n.end());
            ll pos=n.size();
            value=n[pos-1]-n[pos-2];
            ans.pb(mp(n[pos-1],n[pos-2]));
            for(ll i=0;i<pos-2;i++)
            {
                ans.pb(mp(value,n[i]));
                value-=n[i];
            }
        }
        else
        {
            sort(p.begin(),p.end());
            ll pos=p.size();
            if(pos==2)
            {
                ans.pb(mp(p[1],p[0]));
                value=p[1]-p[0];
            }
            else
            {
                value=p[0]-p[1];
                ans.pb(mp(p[0],p[1]));
                for(ll i=2;i<pos-1;i++)
                {
                    ans.pb(mp(value,p[i]));
                    value-=p[i];
                }
                ans.pb(mp(p[pos-1],value));
                value=p[pos-1]-value;
            }
        }
    }
    cout<<value<<endl;
    for(auto i:ans)
    {
        cout<<i.ff<<' '<<i.ss<<endl;
    }
}

Measured memory_bytes: 5232
#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int mod = 1000000007;
int n;
int a[300000];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	int ans = 0;
	rep(i, 60) {
		int one = 0;
		rep(j, n) if ((a[j] >> i) & 1) one++;
		int zero = n - one;
		int res = zero * one % mod;
		
		ans += ((1LL << i) % mod) * res % mod;
		ans %= mod;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import sys
from collections import deque

H,W=map(int,input().split())
si,sj=[int(x)-1 for x in input().split()]
ti,tj=[int(x)-1 for x in input().split()]
A=list(sys.stdin)

dirs=[-2,-1,0,1,2]
dist=[[float('inf')]*W for _ in range(H)]
dist[si][sj]=0
dq=deque()
dq.append((0,si,sj))
ok=False
while dq:
    k,i,j=dq.popleft()
    if i==ti and j==tj:
        ok=True
        break
    for di in dirs:
        for dj in dirs:
            if di==dj==0:
                continue
            ni,nj=i+di,j+dj
            if not (0<=ni<H and 0<=nj<W):
                continue
            if A[ni][nj]=='#':
                continue
            if abs(di)+abs(dj)==1:
                append=dq.appendleft
                nk=k
            else:
                append=dq.append
                nk=k+1
            if k>=dist[ni][nj]:
                continue
            dist[ni][nj]=nk
            append((nk,ni,nj))
      
if ok:
    ans=dist[ti][tj]
else:
    ans=-1

print(ans)


Measured memory_bytes: 226144
a, b = [int(x) for x in input().split()]

if b > 3:
    if a <= 1:
        s_c = 1
    else:
        s_c = 0

    a_keta = len(str(bin(a))) - 2
    b_keta = len(str(bin(b))) - 2
    m_a = (2 ** a_keta - a) % 4
    m_b = (b - (2 ** (b_keta-1)) + 1) % 4
    #print(m_a)
    #print(m_b)

    if m_a == 0:
        s_a = 0
    elif m_a == 1:
        s_a = a
    elif m_a == 2:
        s_a = 1
    elif m_a == 3:
        s_a = a - 1

    if m_b == 0:
        s_b = 0
    elif m_b == 1:
        s_b = b
    elif m_b == 2:
        s_b = 1
    elif m_b == 3:
        s_b = b + 1
    print(s_a ^ s_b ^ s_c)
else:
    if a == 0 and b == 0:
        print(0)
    if a == 0 and b == 1:
        print(1)
    if a == 0 and b == 2:
        print(3)
    if a == 0 and b == 3:
        print(0)
    if a == 1 and b == 1:
        print(1)
    if a == 1 and b == 2:
        print(3)
    if a == 1 and b == 3:
        print(0)
    if a == 2 and b == 2:
        print(2)
    if a == 2 and b == 3:
        print(1)
    if a == 3 and b == 3:
        print(3)


Measured memory_bytes: 3064
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, char> P;

class T{
  public:
    char kind; int value;
    T(){}
    T(char k, int v) { kind = k; value = v; }
    bool operator < (T &t) const { return value < t.value; }
    bool operator != (T &t) const { return !(value == t.value && kind == t.kind); }
};

void display(vector<T> &v){
  cout <<v[0].kind <<v[0].value;
  FOR(i, 1, v.size()) cout <<" " <<v[i].kind <<v[i].value;
  cout <<endl;
}

void bubbleSort(vector<T> &v){
  REP(i, v.size()) for(int j = (int)(v.size()) - 1; j >= i + 1; --j) if(v[j] < v[j - 1]) swap(v[j], v[j - 1]);
  display(v);
}

void selectionSort(vector<T> &v){
  REP(i, v.size()){
    int idx = i;
    FOR(j, i, v.size()) if(v[j] < v[idx]) idx = j;
    swap(v[i], v[idx]);
  }
  display(v);
}

bool isStable(vector<T> &v, vector<T> &origin){
  int num_cnt = 0;
  REP(i, v.size()){
    num_cnt = (i > 0 && v[i].value == v[i - 1].value ? num_cnt + 1 : 0);
    int cnt = 0;
    for(int j = 0; j < origin.size() && v[i] != origin[j]; ++j) if(v[i].value == origin[j].value) ++cnt;
    if(cnt > num_cnt) return false;
  }
  return true;
}
 
int main() {
  int N; cin >>N;
  vector<T> v(N);
  REP(i, N) cin >>v[i].kind >>v[i].value;
  vector<T> origin = v;
  bubbleSort(v);
  cout <<(isStable(v, origin) ? "Stable" : "Not stable") <<endl;
  v = origin;
  selectionSort(v);
  cout <<(isStable(v, origin) ? "Stable" : "Not stable") <<endl;
  return 0;
}

Measured memory_bytes: 1208
n=int(input())
dt,dx,dy=0,0,0
for i in range(n):
  t,x,y=map(int,input().split())
  if abs(x-dx) + abs(y-dy) > t-dt or (x+y)%2!=t%2:
    print("No")
    break
  dt,dx,dy=t,x,y
else:
  print("Yes")

Measured memory_bytes: 69188
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
using namespace std;

#define MAX 300000
int main() {
    int n,i,j,xw=0,xe=0,temp,ans=MAX;
    string s;

    cin>>n>>s;
    vector<int> iw(n);

    for(i=0;i<n;i++){
      if(s[i]=='E')xe++;
      else xw++;
    }
    temp=xe;
    if(s[0]=='E')temp--;
    ans=temp;
    for(i=1;i<n;i++){
        if(s[i-1]=='W')temp++;
        if(s[i]=='E')temp--;

        if(temp<ans)ans=temp;
    }


    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1796
<?php
  list($a, $b, $h, $m) = explode(" ", trim(fgets(STDIN)));

  if($h==6 && $m==0){
    echo $a+$b;
    exit;
  }
  if($h==0 && $m==0){
    echo abs($a-$b);
    exit;
  }

  $h_degree = (30 * $h) + (30 * $m / 60);
  $m_degree = 6 * $m;

  $degree = abs($h_degree-$m_degree);

  $ans = $a*$a + $b*$b - 2*$a*$b*cos(deg2rad($degree));
                                     
  echo sqrt($ans);

Measured memory_bytes: 16684
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e5+5,LG=19,SM=600+5,inf=1e18+1;
ll mod=1e9+7;

ll n,c,k;
ll a[M];

int main()
{
	ios::sync_with_stdio(0);
    cin >> n >> c >> k;
    ll pst=-inf;
    ll cap=0;
    ll res=0;
    For(i,0,n)
    {
        cin >> a[i];    
    }  
    sort(a,a+n);
    For(i,0,n)
    {
        if (cap==c || pst+k<a[i])
        {
            res++;
            cap=1;
            pst=a[i];
        }
        else
        {
            cap++;
        }
    }
    RET(res);
}    

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vector<double> v(n); rep(i, n) cin >> v[i];
	sort(all(v), greater<int>());
	while(v.size() > 1){
		double a = v.back(); v.pop_back();
		double b = v.back(); v.pop_back();
		v.pb((a + b) / 2);
	}
	printf("%.20f\n", v[0]);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 10000

int A[2000001],B[2000001];


void CountingSort(int n,int k){
  int i,C[N],j;
  
  for(i = 0; i <= k; i++){
    C[i] = 0;
  }

  for(i = 0; i < n;i++){
    C[A[i]]++;
  }
  for(i = 1;i <= k; i++){
    C[i] = C[i] + C[i-1];
  }

  for(j = n-1; j >=0 ; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

}

int main()
{
  int i,k=0,n;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
    if(A[i] > k) k = A[i];
  }
  CountingSort(n,k);
  for(i = 1; i < n; i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);
  return 0;
}



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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<tuple<int, int, bool>> ps(2 * N);
  REP(i, 2 * N) {
    int x, y;
    cin >> x >> y;
    ps[i] = {x, y, i < N};
  }
  sort(ps.begin(), ps.end());
  set<int> red;
  int count = 0;
  REP(i, 2 * N) {
    auto [x, y, is_red] = ps[i];
    if (is_red) {
      red.insert(y);
    } else if (red.size()) {
      auto it = red.upper_bound(y);
      if (it == red.begin()) continue;
      --it;
      if (*it < y) {
        ++count;
        red.erase(it);
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3616
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int n ,m ,x;
	cin >> n >> m >> x;
	vector<int> a(m);
	for(int i = 0; i < m; i++){
		cin >> a[i];
	}

	int toZero = 0;
	int toN = 0;
	for(int i = 0; i < m; i++){
		if(a[i] < x){
			toZero++;
		} else {
			toN++;
		}
	}

	cout << min(toZero, toN) << endl;

}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N, A;
int B[51];
ll DP[51][5010];

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

  cin >> N >> A;
  int x;
  rep(i, N){
    cin >> x;
    B[i] = A - x; 
  }
  DP[0][N*A] = 1ll;
  rep(i, N){
    rep(j, 2*N*A){
      if (DP[i][j]>0){
        DP[i+1][B[i]+j]+=DP[i][j];
        DP[i+1][j]+=DP[i][j];
      }
    }
  }

  cout << DP[N][N*A] -1 << "\n"; // 何も選ばなかった場合をのぞく
  return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <unistd.h>
#include <utility>
#include <vector>
#define int ll
#define dbc(x) //cerr << x << '\n'
#define dbn(x) //cerr << #x << " == " << x << '\n'
#define pb push_back
#define endl '\n'

using namespace std;

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

//
int bitat(int n, int pos) {
	return (n >> pos) & 1;
}

ll brute(string s) {
	int n = s.size();
	int resp = 0;

	if (n == 1) return stoll(s);

	for (int i=0; i<=(1 << (n-1))-1; i++) {
		string t = s;

		for (int j=n-1; j>=1; j--) {
			if (bitat(i,j-1) == 1) {
				t.insert(j, "+");
			}
		}

		int num = 0;
		int nn = 0;
		dbn(t);
		for (char c : t) {
			if (c == '+') {
				num += nn;
				nn = 0;
			} else {
				nn = 10 * nn + (c - '0');
			}
		}

		dbn(num + nn);

		resp += (num + nn);
	}

	return resp;
}

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

	string s; cin >> s;

	cout << brute(s) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[102],str1[102],ans[102];
int sam(int ma1,int ma2)
{
int co,carry=0,a,b;
for(int i=0;ma1-i>=0||ma2-i>=0||carry==1;i++){
if(ma1-i>=0&&ma2-i>=0){
a=str[ma1-i]-'0';
b=str1[ma2-i]-'0';
if(a+b+carry>=10){
ans[i]=a+b+carry-10+'0';
carry=1;
}
else {
ans[i]=a+b+carry+'0';
carry=0;
}
}
else if(ma1-i>=0){
a=str[ma1-i]-'0';
if(a+carry>=10){
ans[i]=a+carry-10+'0';
carry=1;
}
else {
ans[i]=a+carry+'0';
carry=0;
}
}
else if(ma2-i>=0){
b=str1[ma2-i]-'0';
if(b+carry>=10){
ans[i]=b+carry-10+'0';
carry=1;
}
else {
ans[i]=b+carry+'0';
carry=0;
}
}
else {
ans[i]='0'+1;
return i;
}
co=i;

}
return co;

}
int main()
{
int a,b,n;
cin>>n;
for(int i=0;i<n;i++){
cin>>str>>str1;
a=strlen(str);
b=strlen(str1);
a=sam(a,b);
if(a>80)cout<<"overflow"<<endl;
else {
for(int j=a;j>0;j--)cout<<ans[j];
cout<<endl;
}
}

}


Measured memory_bytes: 3068
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 2e5+2;


void solve()
{
    int n, k;
    cin >> n >> k;

    vl pref(n, 0), a(n);

    rep(i, 0, n)
    cin >> a[i];

    pref[0] = a[0];

    rep(i, 1, n)
    pref[i] = a[i] + pref[i - 1];

    ll last = pref[k - 1];

    int c = 0;

    rep(i, k, n) {
        ll now = pref[i] - pref[c ++];
        puts(now > last? "Yes": "No");

        last = now;
    }
}

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

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

int main(){

int H, W;
  cin >> H >> W;
string S[H];
  for(int i = 0;i < H;i++) cin >> S[i];
  
char c[H+2][W+2];
  for(int i = 0;i <= W + 1;i++) c[0][i] = '.';
  for(int i = 0;i <= W + 1;i++) c[H+1][i] = '.';
  for(int i = 1;i <= H;i++) c[i][0] = '.';
  for(int i = 1;i <= H;i++) c[i][W+1] = '.';
  
  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
    c[i+1][j+1] = S[i].at(j);
    }  
  }

    for(int i = 1;i <= H;i++){
      for(int j = 1;j <= W;j++){
        int cnt = 0;
        if(c[i][j] == '.'){
          if(c[i-1][j-1] == '#') cnt++;
          if(c[i-1][j] == '#') cnt++;
          if(c[i-1][j+1] == '#') cnt++;
          if(c[i][j-1] == '#') cnt++;
          if(c[i][j+1] == '#') cnt++;
          if(c[i+1][j-1] == '#') cnt++;
          if(c[i+1][j] == '#') cnt++;
          if(c[i+1][j+1] == '#') cnt++;         
        cout << cnt;
        }
        else cout << c[i][j];
        
        if(j == W) cout << endl;
      }
    }

return 0;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

	vector<int> tako;
	tako.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		int d;
		cin >> d;
		tako.emplace_back(d);
	}

	long long sum = 0;

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (i == j)
			{
				continue;
			}

			sum += static_cast<long long>(tako.at(i)) * tako.at(j);
		}
	}
	sum /= 2;
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define endl endl;cf
#define be begin()
#define sz size()
#define en end()
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define ro return 0
#define rngx mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define cf cout.flush()
int main()
{
    ios;
    string s;
    cin >> s;
    ll diff=  3e18;
    for(ll i = 0 ; i < s.length()-2;++i){
        ll x = int(s[i]) - 48;
        ll y = int(s[i+1]) - 48;
        ll z = int(s[i+2]) - 48;
        ll ans = x*100 + y * 10 + z;
        diff = min(diff , abs(ans - 753));
    }
    cout << diff <<endl;
    ro;
}


Measured memory_bytes: 256
import math
N=input()
A=[ 2 for _ in range(N+1)]
A[0]=0
A[1]=1

for cur in range(2,N+1):
    for i in range(cur*2,N+1,cur):
        A[i]+=1

ans=0
for i in range(1,N+1):
    ans+=i*A[i]
print ans


Measured memory_bytes: 156532
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
 
int main() {
	ll n;
	cin>>n;
	ll a[n];
	int h=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==h){
			h++;
		}
	}
	if(h==1){
		cout<<-1;
	}
	else{
		cout<<n-h+1;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
void HIT(void);
void HOMERUN(void);
void OUT(void);

int main(void){
    int data, score, out, first, second, third;
    string event;
    
    cin >> data;
    for(int i=0; i<data; i++){
        out=0;
        score=0;
        first=0;
        second=0;
        third=0;
        
        while(out<3){
            cin >> event;
            if(event=="HIT"){
                if(third==1){
                    third=0;
                    score++;
                }
                if(second==1){
                    third=1;
                    second=0;
                }
                if(first==1){
                    second=1;
                    first=0;
                }
                first=1;
            }
            else if(event=="HOMERUN"){
                int count=0;
                if(first==1) count++;
                if(second==1) count++;
                if(third==1) count++;
                score += count+1;
                first=0;
                second=0;
                third=0;
            }
            else if(event=="OUT"){
                out++;
            }
        }
        cout << score << endl;
    }
    return 0;
}



Measured memory_bytes: 3144
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int D;
  cin >>D;
  if(D==25) cout << "Christmas" <<endl;
  else if(D==24) cout << "Christmas" <<" "<<"Eve" << endl;
  else if(D== 23) cout << "Christmas" <<" "<<"Eve" << " "<<"Eve" <<endl;
  else cout << "Christmas" <<" "<<"Eve" << " "<<"Eve"<<" "<< "Eve"<< endl;
}


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

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    if (A == B || B == C || C == A){
        if (A == B && B == C && C == A) cout << "No" << endl;
        else cout << "Yes" << endl;
        
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	string s;
	cin >> s;
	string h = "2019/04/30";

	if (s <= h) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	long long int a, b;
	cin >> a >> b;
	long long int k;
	cin >> k;
	vector<int> ans;
	for (int i = a; i <= min(b, a + k - 1); i++) {
		ans.push_back(i);
	}
	for (int i = max(a,b-k+1); i <=b; i++) {
		ans.push_back(i);
	}
	sort(ans.begin(), ans.end());
	cout << ans[0] << endl;
	for (int i = 1; i < ans.size(); i++) {
		if (ans[i - 1] != ans[i]) {
			cout << ans[i] << endl;
		}
	}
}

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

using ll = long long;

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main(){
    string S;
    cin >> S;
    int leng = S.length();
    vector<ll> aa(leng+1, 0);
    vector<ll> bb(leng + 1, 0);
    int i = 1;
    for(char xx : S){
        if(xx =='<'){
            aa.at(i) = 0;
            bb.at(i) = bb.at(i - 1) + 1;
            // aa.at(i) = aa.at(i-1) +1;
        }else{
            aa.at(i) = aa.at(i-1) - 1;
            bb.at(i);
        }
        i++;
    }

    ll ans = 0;
    ll counter = 0;
    ll plus = 0;
    for(int j = leng; j>=0;j--){
        if(counter == 0){
            if(aa.at(j) <0){
                plus = -aa.at(j);
                counter = plus +1;

                aa.at(j) +=plus;
                counter--;
            }
        }else{
            aa.at(j) +=plus;
            counter--;
        }
    }
    for(int k = 0; k<leng+1;k++){
        ans += max(aa.at(k), bb.at(k));
    }

    cout << ans << endl;

    // for (ll a : aa)
    // {
    //     cout << a << ' ';
    //     ans -= a;
    //     if(a !=0){
    //         ans--;
    //     }
    // }
    // cout << endl;

    // for (ll b : bb)
    // {
    //     cout << b << ' ';
    //     ans += b;
    // }

    // cout << endl;
    // cout << ans << endl;
    // sort(aa.begin(), aa.end());
    // ll max = -(aa.at(0) *(leng+1));
    // for(ll a : aa){
    //     cout << a << ' ';
    //     max += a;
    // }
    // cout << endl;
    // cout << max << endl;
}

Measured memory_bytes: 8708
#include <stdio.h>
#define N 100
#define INFTY 100000000
#define Free 0
#define Full 1


int n, M[N][N];

int prim(){
    int u,minv;
    int d[N],p[N],color[N];
    
    for(int i=0; i<n; i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=Free;
    }
    
    d[0]=0;
    
    while (1) {
        minv=INFTY;
        u=-1;
        for(int i=0; i<n; i++){
            if(minv>d[i] && color[i] != Full){
                u=i;
                minv=d[i];
            }
        }
        
        if(u==-1) break;
        color[u]=Full;
        for(int v=0; v<n; v++){
            if(color[v] != Full && M[u][v] != INFTY){
                if(d[v] > M[u][v]){
                    d[v]=M[u][v];
                    p[v]=u;
                    
          }
            }
        }
    }
    
    int sum =0;
    for(int i=0; i<n; i++){
        if(p[i] != -1) 
        sum+= M[i][p[i]];
    }
    return sum;
}

int main(){
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            int e;
            scanf("%d",&e);
            if(e == EOF)
            M[i][j] = INFTY;
            else{
                M[i][j] = e;
            }
            
        }
    }
    printf("%d\n", prim());
    return 0;
}


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

int main() {
	double l;
	cin >> l;

	double length = l / 3;

	l -= length;

	double breadth = l / 2;

	double height = l - breadth;

	cout << setprecision(9) << (length * breadth * height)  << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

   int x,h,m,s;

   scanf ("%d",&x);

   h = x / 3600;
   m = ( x % 3600) / 60;
   s = x % 60;

   printf ("%d:%d:%d\n", h , m , s);

   return 0;

}
  

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

int main() {
  
  // 方眼の一辺 N , 白に塗るマスの数 A
  int N, A;

  cin >> N >> A;

  // 方眼のマスの数は N*N 
  //  白が A マスに塗られているので
  cout << N*N - A << endl;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

typedef vector<int> vec;
typedef vector<vec> mat;

mat mul(const mat& A, const mat& B)
{
  mat C(A.size(), vec(B[0].size()));
  for(int i = 0; i < (int)A.size(); i++) {
    for(int j = 0; j < (int)B.size(); j++) {
      for(int k = 0; k < (int)B[0].size(); k++) {
	(C[i][k] += A[i][j] * B[j][k]) %= 2;
      }
    }
  }
  return C;
}

mat pow(mat A, int n)
{
  mat B(A.size(), vec(A.size()));
  for(int i = 0; i < (int)A.size(); i++) B[i][i] = 1;
  while(n > 0) {
    if(n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}

void gauss_jordan(const mat& A, const vec b)
{
  int n = A.size();
  // テヲツ仰。テ・ツ、ツァテ、ツソツづヲツ閉ーティツ。ツ古・ツ按?
  mat B(n, vec(n + 1));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) B[i][j] = A[i][j];
  }
  for(int i = 0; i < n; i++) B[i][n] = b[i];

  // ティツァツ」テヲツウツ?
  for(int i = 0; i < n; i++) {
    int pivot = i;
    for(int j = i; j < n; j++) {
      if(B[j][i]) {
	pivot = j;
	break;
      }
    }
    swap(B[i], B[pivot]);
    if(B[i][i] == 0) continue;
    // テ」ツδ氾」ツδ愿」ツδε」ツδ暗、ツソツづヲツ閉ーテ」ツ?ァテゥツ卍、テァツョツ?
    //for(int j = i+1; j < n+1; j++) B[i][j] /= B[i][i];
    // テヲツ篠ε」ツ?催・ツ?コテ」ツ??
    for(int j = 0; j < n; j++) {
      if(i != j && B[j][i]){
	for(int k = 0; k < n+1; k++) (B[j][k] += B[i][k]) %= 2;
      }
    }
  }

  rep(i, n) {
    bool flag = false;
    rep(j, n) if(B[i][j]) flag = true;
    if(!flag) {
      if(B[i][n]) {
	cout << "none" << endl;
	return;
      }
    }
  }

  rep(i, n) {
    bool flag = false;
    rep(j, n) if(B[i][j]) flag = true;
    if(!flag) {
      if(!B[i][n]) {
	cout << "ambiguous" << endl;
	return;
      }
    }
  }

  // ティツァツ」
  for(int i = 0; i < n; i++) {
    if(i) cout << " ";
    cout << B[i][n];
  }
  cout << endl;
}


signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  mat A(N, vec(N));
  rep(i, N) rep(j, N) cin >> A[i][j];

  vec b(N);
  rep(i, N) cin >> b[i];

  int T;
  cin >> T;

  gauss_jordan(pow(A, T), b);

  return 0;
}

Measured memory_bytes: 5852
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int A = sc.nextInt();
    int k = 0;
    if(H%A == 0){
        System.out.println(H/A);
        return;
    }else{
        System.out.println(H/A +1);
    }
        }    
}


Measured memory_bytes: 22356
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x = I()
if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)

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


int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll sum = 0;
    sum += min(a, k);
    k -= a;
    k -= b;
    if (k > 0) sum -= k;
    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char a[54],b[54];
int main()
{
    scanf("%s",a+1);
    scanf("%s",b+1);
    int l=strlen(a+1)+strlen(b+1);
    int cnt1=0,cnt2=0;
    for(int i=1;i<=l;i++)
    {
        if(i&1)
            printf("%c",a[++cnt1]);
        else
            printf("%c",b[++cnt2]);   
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5;
double mx[300],st[300],ed[300];
int t[300],v[440];
double get_s(double u,double t)
{

    double d= u*t+t*t/2;
//    cout<<"d = "<<d<<endl;
    return d;
}
double bs(int i,double mx,double tt)
{
    double l=st[i],r=mx;
    double tol=0.0000000001;
    while(l<=r)
    {
//        cout<<l<<" "<<r<<endl;
        double v=(l+r)/2;
        double t1=fabs(v-st[i]);
        double t2=fabs(v-ed[i]);
        double t3=(tt-t1-t2);

        if(t3>=0)l=v+tol;
        else r=v-tol;
    }
//    cout<<"val for "<<i<<" "<<r<<endl;
    double t1=r-st[i];
    double t2=fabs(ed[i]-r);
    double t3=tt-fabs(t1)-fabs(t2);
    double x=get_s(st[i],t1);
    double y=get_s(min(r,ed[i]),t2);
    double res=x+y+r*t3;
//    cout<<"res = "<<t1<<"  "<<x<<" "<<t2<<" "<<y<<" "<<t3<<endl;
    return res;
}
int main()
{
    cout<<setprecision(10);
    int n;cin>>n;
    for(int i=0;i<n;i++)cin>>t[i];
    for(int i=0;i<n;i++)cin>>mx[i];
//    int sum=0,ind=1;
    for(int i=n-1;i>=0;i--)
    {
        ed[i]=min(mx[i],st[i+1]);
        st[i]=min(mx[i],ed[i]+t[i]);
    }
//    for(int i=0;i<n;i++)cout<<st[i]<<" "<<ed[i]<<endl<<endl;
    for(int i=0;i<n;i++)
    {
        if(i==0)st[i]=0;
        else st[i]=ed[i-1];
        ed[i]=min(ed[i],st[i]+t[i]);
    }
//    for(int i=0;i<n;i++)cout<<st[i]<<" "<<ed[i]<<endl;
    double ans=0;
    for(int i=0;i<n;i++)
    {
        double temp=bs(i,mx[i],t[i]);
        ans+=temp;
    }
    cout<<ans<<endl;
}
/*
2
1 2
1 2

5
6 3 3 2 3
9 8 9 2 5

*/


Measured memory_bytes: 256
a = []
a[0] = gets.to_i
i = 1
while true
  a[i] = a[i - 1] / 2 if a[i - 1].even?
  a[i] = 3 * a[i - 1] + 1 if a[i - 1].odd?
  
  if a.uniq.length != a.length
    puts i + 1
    exit
  end
  i += 1
end

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int main(){
  int a,b;
  while(~scanf("%d %d",&a,&b)){
    printf("%d\n",a-b);
  }
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int personNumber = int.Parse(Console.ReadLine());
            string hatData = Console.ReadLine().Trim();
            int redHatNum = 0;
            int blueHatNum = 0;
            string result = string.Empty;

            for(int i = 0; i < hatData.Length; i++)
            {
                if (hatData[i].Equals('R')) redHatNum++;
                if (hatData[i].Equals('B')) blueHatNum++;
            }

            Console.WriteLine(result = blueHatNum < redHatNum ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
# C
import bisect
n = int(input())
al = map(int, input().split())
bl = map(int, input().split())
cl = map(int, input().split())
al = sorted(al)
bl = sorted(bl)
cl = sorted(cl)

total = 0
for blnum in bl:
    alcnt = bisect.bisect_left(al, blnum)
    clcnt = n - bisect.bisect_right(cl, blnum)
    total += alcnt*clcnt
print(total)

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

void  fun(char c,string s,int n) { 
	if (n==0) { 
		cout << s << endl; 
		return; 
	} 
	for (char i='a';i<=c;i++){ 
		fun(max(c,(char)(i+1)),s+i,n-1); 
	} 
} 
 
inline void solve(){ 
    int n; cin>>n; 
    fun('a',"",n); 
    return; 
} 

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


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL n, ans;
int main()
{
	cin >> n;
	ans = n - 1;
	LL cnt = sqrt(n);
	for(int i = 1; i <= cnt; ++i) {
		if(n % i == 0 ) 
			ans = min(ans, i - 1 + n / i - 1);	
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N+1);
    rep(i,N) cin >> A[i+1];
    ll M = 0;
    rrep(i,N+1){
        if(i == 0) break;
        ll cnt = 0;
        for(ll j = 0;j * i <= N;j++){
            cnt += B[i*j];
        }
        if(A[i] % 2 != cnt % 2){
            B[i]++;
            M++;
        }
    }
    cout << M << endl;
    rep(i,N+1){
        if(B[i] > 0) cout << i << endl;
    }
}


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

int cmp(const void *a,const void *b)
{
  return *(int *)a - *(int *)b;
}

int main()
{
  int i,N,median;
  long int sum = 0;

  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    A[i] -= i + 1;
  }
  
  qsort(A,N,sizeof(int),cmp);

  median = A[N/2];

  for(i=0;i<N;i++){
    sum += abs(A[i] - median);
  }

  printf("%ld\n",sum);

  return 0;
}

Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        int l = sc.nextInt();

        int[] apple = new int[n];

        int sum1 = 0;
        for (int i =1;i<=n;i++){
            apple[i-1] = l+i-1;
            sum1 += apple[i-1];
        }

        int res = 0;
        int abs = Integer.MAX_VALUE;
        for (int i=0;i<n;i++){
            int tmpSum = 0;
            for (int k=0;k<n;k++){
                if (i != k) {
                    tmpSum += apple[k];
                }
            }
            int abtmp = Math.abs(sum1 - tmpSum);
            if (abtmp < abs) {
                abs = abtmp;
                res = tmpSum;
            }
        }

        out.println(res);
        out.flush();
    }

    //    public static void calcD(Map<Integer, Integer> dic, int index, )

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 20564