akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define max 10013
#define nil -1

typedef struct {
  int parent;
  int left;
  int right;
} nd;

nd N[max];
int n,deep[max],high[max];

void deep_cal(int u,int d){
  if(u==nil) {return;}
  deep[u]=d;
  deep_cal(N[u].left,d+1);
  deep_cal(N[u].right,d+1);
}

int high_cal(int u){
  int h1=0,h2=0;
  if (N[u].left!=nil){
    h1=high_cal(N[u].left)+1;
  }
  if(N[u].right!=nil){
    h2=high_cal(N[u].right)+1;
  }
  return high[u]=( h1 > h2 ? h1:h2);
}

int sibling_cal(int u){
  if(N[u].parent==nil){
    return nil;
  }
  if(N[N[u].parent].left!=u && N[N[u].parent].left!=nil){
    return N[N[u].parent].left;
  }
  if(N[N[u].parent].right!=u && N[N[u].parent].right!=nil){
    return N[N[u].parent].right;
  }
  return nil;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",N[u].parent);
  printf("sibling = %d, ",sibling_cal(u));
  int deg=0;
  if(N[u].left!=nil){
    deg++;
  }
  if(N[u].right!=nil){
    deg++;
  }
  printf("degree = %d, ",deg);
  printf("depth = %d, ",deep[u]);
  printf("height = %d, ",high[u]);

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


int main(){
  int i,v,l,r,root=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    N[i].parent=nil;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    N[v].left=l;
    N[v].right=r;
    if(l!=nil){
      N[l].parent=v;
    }
    if(r!=nil){
      N[r].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(N[i].parent==nil){
      root=i;
    }
  }
  deep_cal(root,0);
  high_cal(root);
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}

	 



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

int main(){
    int n; cin >> n;
    vector<int> lis(n);
    for(int i = 0; i < n; i++){
        cin >> lis[i];
    }
    int k = lis[0];
    int ans = 1;
    for(int i = 1; i < n; i++){
        if(k < lis[i]){
            continue;
        }
        ans++;
        k = lis[i];
    }
    cout << ans <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];
	sort(v.begin(), v.end());

	double ret = (double)(v[0] + v[1]) / 2;
	for (int i = 2; i < N; i++) {
		ret = (double)(ret + v[i]) / 2;
	}

	cout << fixed << setprecision(10) << ret << endl;
}

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

int main() {
	string S,T,U;
	int A,B;
	cin >> S >> T >> A >> B >> U;
  if(S==U) A--;
	if(T == U) B--;
	cout << A << " " << B << endl;
}

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

	typedef long long ll;

	int main() {
		int n;
		cin >> n;
		unordered_map<string, int> mp; //to collect items in map <key, >, unordered 
		rep(i, n) {
			string s;
			cin >> s;
			sort(s.begin(), s.end());
			mp[s]++; //->map c++ if nothing exists zero=mp[s]
		}
		ll ans = 0;
		for(auto& p : mp) { //string, int pair
			int s = p.second;	//second -> int
			ans += (ll)s*(s-1)/2; // cast(ll) avoiding overflow
		}
		cout  << ans << endl;		
	    return 0;	
	}

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

struct edge
{
    ll to;
    ll cost;
};

int n, q, k;
vector<edge> v[100001];
ll d[100001];
bool fl[100001];
void dfs(ll node, ll cost)
{
    if (fl[node])
        return;
    d[node] = cost;
    fl[node] = true;
    for (int i = 0; i < v[node].size(); i++)
    {
        dfs(v[node][i].to, cost + v[node][i].cost);
    }
}

int main()
{
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        edge s;
        s.to = a;
        s.cost = c;
        v[b].push_back(s);
        s.to = b;
        v[a].push_back(s);
    }
    int q, k;
    cin >> q >> k;
    dfs(k, 0);
    for (int i = 0; i < q; i++)
    {
        int x, y;
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }
}

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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> l(n * 2);
    int ans = 0;
    REP(i, n * 2) cin >> l[i];
    sort(ALL(l));
    REP(i, n * 2) if (i % 2 == 0) ans += l[i];
    cout << ans << EOL;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll t;
	ll ans=0LL;
	cin >>n>>t;
	V p(n+1);
	rep(i,n){
		cin>>p[i];
	}
	p[n]=INFLL;
	rep(i,n){
		ans+=min(t,p[i+1]-p[i]);
		//clog<<ans<<endl;
	}
	cout<<ans<<endl;
}

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

int main(){
  string S;
  cin >> S;
  if(S.at(0)!=S.at(1) && S.at(1)!=S.at(2) && S.at(2)!=S.at(0)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
ba = []
for i in range(n):
    a,b = inm()
    ba.append((b,a))
ba.sort()
sum = 0
for i in range(n):
    b,a = ba[i]
    sum += a
    if sum>b:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 29820
import numpy as np


N = int(input())
AN = list(map(int, input().split()))
AN = np.array(AN)

AN2 = AN[AN % 2 == 0]

if AN2[AN2 % 3 == 0].size + AN2[AN2 % 5 ==0].size - AN2[AN2 % 15 ==0].size == AN2.size :
    print('APPROVED')

else:
    print('DENIED')


Measured memory_bytes: 12500
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
f=[b-a,c-b,d-c,e-d]
 
if((f[0]>k) or (f[1]>k) or (f[2]>k)or (f[3]>k)):
  print(':(')
elif(((f[0]+f[1])>k)or ((f[1]+f[2])>k)or ((f[2]+f[3])>k)):
  print(':(')
elif(((f[0]+f[1]+f[2])>k) or((f[1]+f[2]+f[3])>k)):
  print(':(')
elif((e-a)>k):
  print(':(')
else:
  print('Yay!')

Measured memory_bytes: 3064
while True:
    n=input()
    if n==0:break
    Taro=sorted(input() for i in range(n))
    Hana=[i for i in range(1,2*n+1) if i not in Taro]
    state=0
    while Taro!=[] and Hana!=[]:
        for i in range(len(Taro)):
            if Taro[i]>state:
                state=Taro[i]
                del Taro[i]
                break
        else:
            state=0
        if len(Taro)==0:
            break
        for i in range(len(Hana)):
            if Hana[i]>state:
                state=Hana[i]
                del Hana[i]
                break
        else:
            state=0
    print len(Hana)
    print len(Taro)

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    for(int i = 0; i < n; i++)
    {
        int b;
        cin >> b;
        a[b]++;
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i <= n - k; i++)
    {
        ans += a[i];
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    ll iti =abs(a-b);
    if(w>=v) cout<<"NO"<<endl;
    else {
        if(iti<=(v-w)*t) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int n,i,s,z;
	z=100000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		s=(z*5)/100;
		if(s%1000!=0){
			s=s/1000;
			s++;
			s=s*1000;
		}
		z=z+s;
	//	printf("%d\n",s);
	}
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 1e3+3;
int n, m, scc;
int w[maxn][maxn];
int dfn[maxn], low[maxn], vis[maxn], Index;
int belong[maxn], cnt[maxn];
int s[maxn], top;
vector<int> g[maxn], ss[maxn];
int ans, a, b;

void read()
{
    cin >> n >> m;
    int u, v;
    for(int i = 0; i < m; ++i)
    {
        cin >> u >> v;
        g[u].push_back(v);
        w[u][v] = 1;
        if(w[v][u])
        {
            ans = 2;
            a = u;
            b = v;
        }
    }
}

void tarjan(int u)
{
    dfn[u] = low[u] = ++Index;
    s[top++] = u;
    for(int i = 0; i < g[u].size(); ++i)
    {
        int v = g[u][i];
        if(!dfn[v])
        {
            tarjan(v);
            low[u] = min(low[u], low[v]);
        }
        else if(!vis[v])
            low[u] = min(low[u], dfn[v]);
    }
    if(low[u] == dfn[u])
    {
        ++scc;
        while(1)
        {
            int x = s[--top];
            vis[x] = 1;
            belong[x] = scc;
            ss[scc].push_back(x);
            ++cnt[scc];
            if(x == u)
                break;
        }
    }
}

bool cmp(int v1, int v2)
{
    if(g[v1].size() != g[v2].size())
        return g[v1].size() < g[v2].size();
    return v1 < v2;
}


int viss[maxn], p[maxn], pc;
bool flag = 0;
void dfs(int t, int u)
{
    if(flag) return;
    p[pc++] = u;
    viss[u] = 1;
    for(int i = pc-1; i >= 0; --i)
    {
        int v = p[i];
        if(w[u][v] && viss[v])
        {
            int j;
            for(j = pc-1; j >= 0; --j)
                if(p[j] == v)
                {
                    ans = pc-j;
                    break;
                }
            cout << ans << endl;
            for(int k = j; k < pc; ++k)
                cout << p[k] << endl;
            flag = 1;
            return;
        }
    }
    sort(g[u].begin(), g[u].end(), cmp);
    for(int i = 0; i < g[u].size(); ++i)
    {
        int v = g[u][i];
        if(belong[v] != t)
            continue;
        dfs(t, v);
        if(flag)
            return;
    }
}

void solve()
{
    if(ans)
    {
        cout << 2 << endl
             << a << endl
             << b << endl;
        return;
    }

    for(int i = 1; i <= n; ++i)
        if(!dfn[i])
            tarjan(i);
    
    int minscc = 0, mincnt = INF;
    for(int i = 1; i <= scc; ++i)
        if(cnt[i] > 2 && cnt[i] < mincnt)
        {
            minscc = i;
            mincnt = cnt[i];
        }
    if(!minscc)
    {
        cout << -1 << endl;
        return;
    }

    sort(ss[minscc].begin(), ss[minscc].end(), cmp);
    for(int i = 0; i < cnt[minscc]; ++i)
        if(!flag)
        {
            memset(viss, 0, sizeof(viss));
            memset(p, 0, sizeof(p));
            pc = 0;
            dfs(minscc, ss[minscc][i]);
        }
    if(!flag)
        cout << -1 << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    read();
    solve();
    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main() {
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    for (i = 0; i < n; i++) cin >> A[i];

    mergeSort(A, n, 0, n);

    for (i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << A[i];
    }

    cout << endl;

    cout << cnt << endl;

    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while (x->left != NIL)
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
while (x->right != NIL)
    x = x->right;
  return x;

}

Node treeSearch(Node u, int k){
  if((u == NIL)||(u->key == k))
    return u;
  if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  
  if(x->right != NIL)
    return treeMinimum(x->right);

  y = x->parent;
  while ((y != NIL)&&(x==y->right)){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->left;
  else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left  = x;
  else
    y->parent->right  = x;
    
  if(y!=z)
    z->key = y->key;
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;

  if (y == NIL)
    root = z;

  else if (z->key<y->key)
    y->left = z;
  else
    y->right = z;
}

void inorder(Node u){

  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);


  
}
void preorder(Node u){

  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20448
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int n;
	cin>>n;
	
	vi v(n+1);
	int sum=0;
	REP(i,n){
		cin>>v[i];
		sum+=v[i];
	}
	v[n]=0;
	sort(ALL(v));
	
	int tmp=sum;
	REP(i,n+1){
		if((sum-v[i])%10){
			tmp=v[i];
			break;
		}
	}
	
	cout<<sum-tmp<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
	int n,d1,x;
	scanf("%d%d%d",&n,&d1,&x);
	double a=d1*2+x,d=x*4,s=a/2+d*(n-1)/4;
	for(int i=n;--i;){
		a=a*(i+2)/(i+1)+d*(2*i+1)/(2*i+2);
		s+=(a*i+d*i*(i-1)/2)/(i*2);
	}
	printf("%.15lf\n",s);
}

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

#define ll long long;
#define rep(i, n) for(int i = 0; i < n; i++);
#define in(n) cin >> n;
#define ou(n) cout << n;
#define oe(n) cout << n << endl;
#define mod(n, k) n % k;

int main(){
  double n, a;
  in(n);
  a = n - double((int)n / 2);
  a = a / (double)n;
  cout << fixed << setprecision(7);
  oe(a);
}

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


int findMin(int a[], int b[], int c[], int n) {
	int cost[n][3];
	cost[0][0] = max(b[0], c[0]);
	cost[0][1] = max(a[0], c[0]);
	cost[0][2] = max(a[0], b[0]);

	for(int i=1; i<n; i++) {
		cost[i][0] = max(c[i] + cost[i-1][2], b[i] + cost[i-1][1]);
		cost[i][1] = max(a[i] + cost[i-1][0], c[i] + cost[i-1][2]);
		cost[i][2] = max(a[i] + cost[i-1][0], b[i] + cost[i-1][1]);
	}
	return max( max(cost[n-1][0], cost[n-1][1]), cost[n-1][2]);
}

int main() {
	int n, a[100000], b[100000], c[100000];
	cin>>n;
	for(int i=0;i <n; i++)
		cin>>a[i]>>b[i]>>c[i];


	cout<<findMin(a, b, c, n)<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    int n; cin >> n;
    int v1,v2;
    vector<pair<int,int> > s1;
    vector<pair<int,int> > s2;
    for(int i=0;i<n;i+=2){
        cin >> v1 >> v2;
        if(i==0){
            s1.push_back(make_pair(1,v1));
            s2.push_back(make_pair(1,v2));
            continue;
        }
        bool add=true;
        for(int j=0;j<s1.size();j++){
            if(s1[j].second==v1){
                s1[j].first++;
                add=false; break;
            }
        }
        if(add) s1.push_back(make_pair(1,v1));
        add=true;
        for(int j=0;j<s2.size();j++){
            if(s2[j].second==v2){
                s2[j].first++;
                add=false; break;
            }
        }
        if(add) s2.push_back(make_pair(1,v2));
    }
    sort(s1.begin(),s1.end(),greater<pair<int,int> >());
    sort(s2.begin(),s2.end(),greater<pair<int,int> >());
    for(int i=0;i<s1.size();i++){
        cerr << s1[i].first << "," << s1[i].second << endl;
    }
    for(int i=0;i<s2.size();i++){
        cerr << s2[i].first << "," << s2[i].second << endl;
    }
    if(s1[0].second!=s2[0].second){
        cout << n-s1[0].first-s2[0].first << endl;
    }else{
        int a=n-s1[0].first-s2[1].first;
        int b=n-s1[1].first-s2[0].first;
        if(a<=b){
            cout << a << endl;
        }else{
            cout << b << endl;
        }
    }
    return 0;
}


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

int main(){
    int E, Y;
    cin >> E >> Y;

    switch (E){
        case 0:
            if(Y>1988)
                cout << "H" << Y-1988 << endl;
            else if(Y>1925)
                cout << "S" << Y-1925 << endl;
            else if(Y>1911)
                cout << "T" << Y-1911 << endl;
            else 
                cout << "M" << Y-1867 << endl;
            break;
        
        case 1:
            cout << Y+1867 << endl;
            break;
        case 2:
            cout << Y+1911 << endl;
            break;
        case 3:
            cout << Y+1925 << endl;
            break;
        case 4:
            cout << Y+1988 << endl;
            break;
    }

    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    int odd_num = 0;
    rep(i, n) {
        int a = 0;
        cin >> a;
        if ( (a&1) ) {
            ++odd_num;
        }
    }
    if ( odd_num == 0 || !(odd_num&1) ) cout << "YES" << endl;
    else                                cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int p[11111],v[11111][3333];
string s;
stack<int> st;

int solve(int i){
	int j,n=0,ret=0;
	for(j=i+1; j<p[i]; ++j){
		if(s[j]=='['){
			v[i][n] = solve(j);
			++n;
			j = p[j];
		}else{
			while(j<p[i]){
				ret *= 10;
				ret += (s[j]-'0');
				++j;
			}
			return (ret+1)/2;
		}
	}
	sort(v[i],v[i]+n);
	for(j=0; j<(n+1)/2; ++j){
		ret += v[i][j];
	}
	return ret;
}

int main(void){
	int k,n,i,j;
	cin >> k;
	while(k--){
		cin >> s;
		n = s.l_ength();
		for(i=0; i<n; ++i){
			if(s[i] == '['){
				st.push(i);
			}else if(s[i] == ']'){
				j = st.top();
				st.pop();
				p[j] = i;
			}
		}
		cout << solve(0) << endl;
	}
	return 0;
}



Measured memory_bytes: 19904
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
dp = [0] * (500000)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            pe = x**2 + y**2 + z**2 + x*y + y*z + z*x
            dp[pe] += 1
print(*dp[1:n+1],sep='\n')


Measured memory_bytes: 77744
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <cmath>
#include <limits>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int pch(ll H) {
	ll i = 2;
	while (i * i <= H) {
		if (H % i == 0) {
			return -1;
		}
		i++;
	}
	return H;
}
ll kaizyo(ll N) {
	ll k = 1;
	rep(i, N-1) {
		k *= (i + 1);
	}
	return k;
}



int main() {
	ll N,s=0;
	double wa = 0;
	cin >> N;
	vector<double> x(N);
	vector<double> y(N);
	rep(i, N) {
		cin >> x.at(i) >> y.at(i);
	}
	for (ll i = 0; i < N; i++) {
		for (ll j = 0; j < N; j++) {
			wa += sqrt((x.at(i) - x.at(j)) * (x.at(i) - x.at(j))+ (y.at(i) - y.at(j)) * (y.at(i) - y.at(j)));
		}
	}
	cout << fixed << setprecision(10);
	cout <<(wa / N) << endl;
;
	
}





Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int m, n;
    cin >> n >> m;
    int a[n][m], b[m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        int tmp = 0;
        for (int j = 0; j < m; j++) {
            tmp += a[i][j] * b[j];
        }
        cout << tmp << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,p;
    ll ans;
    cin >> n >> p;
    int odd=0,even=0;
    rep(i,n){
        int a;
        cin >> a;
        if(a%2 == 0) even++;
        else odd++;
    }
    if(odd == 0){
        if(p == 0) ans = pow(2,n);
        else ans = 0;
    }
    else{
        ans = pow(2,n-1);
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		BigDecimal aa = new BigDecimal(a);
		BigDecimal bb =  new BigDecimal(sc.next());
		BigDecimal ans = aa.multiply(bb);
		long c = ans.longValue();


		System.out.println(c);



	}

	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0;i<n;++i) cin >> a[i];
  
  int ans = 0;
  while (1){
    bool odd=false;
    for (int i=0;i<n;++i){
       if (a[i]%2==1) {
         odd=true;
       }
    }
    if (odd) break;
    for (int i=0;i<n;++i) {
      a[i]/=2;
    }
      ans++;
  }
  cout << ans << endl;
  return 0;
}
    


Measured memory_bytes: 256
#include <stdio.h>

const int SIDE_MAX = 6;

class DICE {
public:
	DICE(void) {};
	void ReadSide(void);
	void Roll(char dimension);
	int GetSide(int side);
        int CheckSide(int side1, int side2);
private:
	int m_a_side[SIDE_MAX];
};

void DICE::ReadSide(void) {
	char tmp[2];
	for (int i = 0; i < SIDE_MAX; i++) {
		scanf("%d", &m_a_side[i]);
	}
	scanf("%c", &tmp);
	return;
}

void DICE::Roll(char dimension) {
	int* a_tmp[4 + 1];
	int tmp; a_tmp[0] = &tmp;

	switch (dimension) {
	case 'W':
		a_tmp[1] = &m_a_side[0]; a_tmp[2] = &m_a_side[2];
		a_tmp[3] = &m_a_side[5]; a_tmp[4] = &m_a_side[3];
		break;
	case 'N':
		a_tmp[1] = &m_a_side[0]; a_tmp[2] = &m_a_side[1];
		a_tmp[3] = &m_a_side[5]; a_tmp[4] = &m_a_side[4];
		break;
	case 'E':
		a_tmp[1] = &m_a_side[0]; a_tmp[2] = &m_a_side[3];
		a_tmp[3] = &m_a_side[5]; a_tmp[4] = &m_a_side[2];
		break;
	case 'S':
		a_tmp[1] = &m_a_side[0]; a_tmp[2] = &m_a_side[4];
		a_tmp[3] = &m_a_side[5]; a_tmp[4] = &m_a_side[1];
		break;
	}
	for (int i = 0; i < 4 + 1; i++) {//アドレスを入れ替える
		*a_tmp[i] = *a_tmp[(i + 1) % (1 + 4)];
	}
	return;
}

int DICE::GetSide(int side) {
	return m_a_side[side - 1];
}

int DICE::CheckSide(int side1, int side2){
        for(int i=0;i<=6*4;i++){
                if(m_a_side[0] == side1 && m_a_side[1] == side2) return m_a_side[2];
                Roll(i%4!=3 ? 'S' : ((i+4)/8)%2 ? 'E' : 'W');
        }
        return -1;
}

int main(void) {
	int n = 0; int a_tmp[2];
	DICE dice;

	dice.ReadSide();
	scanf("%d", &n);
        for(int i=0;i<n;i++){
                scanf("%d %d", &a_tmp[0], &a_tmp[1]);
                printf("%d\n", dice.CheckSide(a_tmp[0], a_tmp[1]));
        }
	return 0;
}


Measured memory_bytes: 2684
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] A = new int[N];
        ArrayList<int[]> xx = new ArrayList<int[]>();
        ArrayList<int[]> yy = new ArrayList<int[]>();
        for (int i=0;i<N;i++) {
            A[i] = Integer.parseInt(sc.next());
            int[] x = new int[A[i]];
            int[] y = new int[A[i]];
            for (int j=0;j<A[i];j++) {
                x[j] = Integer.parseInt(sc.next())-1;
                y[j] = Integer.parseInt(sc.next());
            }
            xx.add(x);
            yy.add(y);
        }

        int ans = 0;
        loop:for (int i=0;i<1<<N;i++) {
            int[] array = new int[N];
            int tmp = i;
            int sum = 0;
            for (int j=0;j<N;j++) {
                if ((tmp&1)==1) {
                    array[j]=1;
                    sum++;
                }
                tmp=tmp>>1;
            }
            // System.out.println(sum);
            // System.out.println(Arrays.toString(array));
            for (int k=0;k<N;k++) {
                int[] xxx = xx.get(k);
                int[] yyy = yy.get(k);
                if (array[k]==0) {
                    for (int l=0;l<A[k];l++) {
                        // if (array[xxx[l]]==yyy[l]) sum=0;
                    }
                } else { // array[k]=1
                    for (int l=0;l<A[k];l++) {
                        if (array[xxx[l]]!=yyy[l]) sum=0;
                    }
                }
            }
            ans = Math.max(ans, sum);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 25096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N+1);
    for(int i=1; i<=N; i++){
        cin >> A[i];
    }
    vector<ll> dist(N+1,-1);
    ll now = A[1];
    dist[now] = 1;
    K--;
    if(K == 1){
        cout << now << enld;
        return 0;
    }
    while(1){
        if(dist[A[now]] != -1){
            ll m = dist[now]+1 - dist[A[now]];
            K %= m;
            while(K > 0){
                now = A[now];
                K--;
            }
            break;
        }else{
            dist[A[now]] = dist[now] + 1;
            if(K == 0){
                break;
            }
            now = A[now];
            K--;
        }
    }
    cout << now << enld;
    return 0;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,M,a,b,x,y,c;
    cin>>A>>B>>M;
    std::deque<int> re;
    deque<int> ra;
    int minA=100001,minB=100001;
    for (int i=0;i<A;i++) {
        cin>>a;
        re.emplace_back(a);
        minA=min(minA,a);
    }
    for (int j=0;j<B;j++) {
        cin>>b;
        ra.emplace_back(b);
        minB=min(minB,b);
    }
    int ans=minA+minB;
    for (int k=0;k<M;k++) {
        cin>>x>>y>>c;
        ans=min(ans,re[x-1]+ra[y-1]-c);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string
	fmt.Scanf("%s", &S)

	s1, s2 := S[:2], S[2:]
	n1, _ := strconv.Atoi(s1)
	n2, _ := strconv.Atoi(s2)

	// YYMM
	var isYYMM bool
	if 1 <= n2 && n2 <= 12 {
		isYYMM = true
	}

	// MMYY
	var isMMYY bool
	if 1 <= n1 && n1 <= 12 {
		isMMYY = true
	}

	if isYYMM && isMMYY {
		fmt.Println("AMBIGUOUS")
	} else if isYYMM && !isMMYY {
		fmt.Println("YYMM")
	} else if !isYYMM && isMMYY {
		fmt.Println("MMYY")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final int N = scanner.nextInt();
		final int M = scanner.nextInt();
		boolean[] isAC = new boolean[N];
		int[] penalty = new int[N];
		int numAC = 0;
		int sumPenalty = 0;
		int p;
		String resultString;
		for (int i = 0; i < M; i++) {
			p = scanner.nextInt() - 1;
			resultString = scanner.next();
			if (!isAC[p]) {
				if (resultString.equals("AC")) {
					isAC[p] = true;
					numAC++;
					sumPenalty += penalty[p];
				} else {
					penalty[p]++;
				}
			}
		}
		System.out.println(numAC + " " + sumPenalty);

	}

}


Measured memory_bytes: 64640
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void naive_solve(long X) {
		for(long A = -1000; A <= 1000; A++) {
			for(long B = -1000; B <= 1000; B++) {
				final long A5 = A * A * A * A * A;
				final long B5 = B * B * B * B * B;
				
				if(A5 - B5 == X) {
					System.out.println(A + " " + B);
					return;
				}
			}
		}
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long X = sc.nextLong();
			
			naive_solve(X);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 36900
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

int f(int a, int b) {
  return 60 * a + b;
}

void solve() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << f(H2, M2) - f(H1, M1) - K << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, K;
	cin >> N >> K;
	vector<int>X(N);
	rep(i, N) {
		cin >> X[i];
	}
	int ans = 0;
	rep(i, N) {
		ans += min(abs(K - X[i]), X[i]) * 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut s = vec![];
    let mut t = vec![];
    for _ in 0..n {
        s.push(sc.read::<String>());
        t.push(sc.read::<usize>());
    }
    let x: String = sc.read();

    let mut ans = 0;
    let mut sleep = false;
    for i in 0..n {
        if sleep {
            ans += t[i];
        } else if s[i] == x {
            sleep = true;
        }
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static ConsoleReader;

class Program
{
    static void Main(string[] args)
    {
        var x = Read<int>();
        var n = Read<int>();
        var p = ReadArray<int>(n);
        var pSet = new HashSet<int>(p);
        var res1 = x;
        var res2 = x;
        while (true)
        {
            if (!pSet.Contains(res1))
            {
                Console.WriteLine(res1);
                return;
            }
            if (!pSet.Contains(res2))
            {
                Console.WriteLine(res2);
                return;
            }
            res1--;
            res2++;
        }
    }
}

public static class IntExtentions
{
    public static void Times(this int n, Action<int> action)
    {
        for (var i = 0; i < n; i++)
        {
            action(i);
        }
    }

    public static void Times(this (int n, int m) dimensions, Action<int, int> action)
    {
        var (n, m) = dimensions;
        n.Times(i => m.Times(j => action(i, j)));
    }
}

public static class ConsoleReader
{
    public static T Read<T>()
        where T : IConvertible
    {
        var inputBuffer = new StringBuilder();
        int currChar;

        while ((currChar = Console.Read()) != -1)
        {
            if (!char.IsWhiteSpace((char)currChar))
            {
                inputBuffer.Append((char)currChar);
            }
            else if (inputBuffer.Length != 0)
            {
                break;
            }
        }

        return (T)Convert.ChangeType(inputBuffer.ToString(), typeof(T));
    }

    public static T[] ReadArray<T>(int count)
        where T : IConvertible
    {
        if (count < 0)
        {
            throw new ArgumentOutOfRangeException(nameof(count), $"'{nameof(count)}' must be >= 0");
        }

        var result = new T[count];

        for (var i = 0; i < count; i++)
        {
            result[i] = Read<T>();
        }

        return result;
    }
}

Measured memory_bytes: 27832
N = int(input())
M = []
A = []
R = []
C = []
H = []
for _ in range(N):
    s = input()
    if s.startswith("M"):
        M.append(s)
    if s.startswith("A"):
        A.append(s)
    if s.startswith("R"):
        R.append(s)
    if s.startswith("C"):
        C.append(s)
    if s.startswith("H"):
        H.append(s)

m = len(M)
a = len(A)
r = len(R)
c = len(C)
h = len(H)
ans = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h
print(ans)

Measured memory_bytes: 16284
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		double ans = 0;

		//ダイス分回す
		for(int i = 1; i<= N; i++) {
			//確率
			double p = 1;
			//ダイスの目
			int x = i;
			//スコアが目標得点より小さい場合
			while(x < K) {
				p *= 0.5;
				x *= 2;
			}
			ans += p;
		}
		System.out.println(ans/N);
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;

struct Vertex {
	// edge information
	vector<int> edges_to; //to vertex number
	vector<ll> edges_cost; // edge cost
	
	//for dijkstra
	bool done; //conform or not
	ll cost; // now cost
	int from;
    int step;
	
	bool operator<(const Vertex& another) const { // priority --> min
        return another.cost < cost; // order(cost)
    }
	
	bool operator==(const Vertex& another) const {
        return another.cost == cost; // order(cost)
    }
};

const int n_MAX = 100000;

Vertex Aver[n_MAX];
Vertex Bver[n_MAX];

int main(){
	priority_queue<Vertex>Q;
    int n,m,s,t; // 0-indexed
	SCD2(n,m); SCD2(s,t);
	s--; t--;

    REP(i,n){
		Aver[i].done = false;
		Aver[i].cost = -1;
		Bver[i].done = false;
		Bver[i].cost = -1;
	}

	REP(i,m){
		int u,v;
		ll a,b;
		SCD2(u,v); u--; v--;
		SCLLD2(a,b);

		Aver[u].edges_to.PB(v);
		Aver[u].edges_cost.PB(a);
		Aver[v].edges_to.PB(u);
		Aver[v].edges_cost.PB(a);

		Bver[u].edges_to.PB(v);
		Bver[u].edges_cost.PB(b);
		Bver[v].edges_to.PB(u);
		Bver[v].edges_cost.PB(b);
	}
	
	//Dijkstra
	Aver[s].cost = 0; //start
	Q.push(Aver[s]);
	
	while (!Q.empty()){
		Vertex nowV = Q.top(); Q.pop();
		nowV.done = true;
		
		REP(i,nowV.edges_to.size()){
			int nto = nowV.edges_to[i];
			ll ncost = nowV.cost + nowV.edges_cost[i];
			if (((Aver[nto].cost) < 0) or (ncost < Aver[nto].cost)){  //not visited or required refresh
				Aver[nto].cost = ncost;
				Q.push(Aver[nto]);
			
			}
			
		}
	}

	Bver[t].cost = 0; //start
	Q.push(Bver[t]);
	
	while (!Q.empty()){
		Vertex nowV = Q.top(); Q.pop();
		nowV.done = true;
		
		REP(i,nowV.edges_to.size()){
			int nto = nowV.edges_to[i];
			ll ncost = nowV.cost + nowV.edges_cost[i];
			if (((Bver[nto].cost) < 0) or (ncost < Bver[nto].cost)){  //not visited or required refresh
				Bver[nto].cost = ncost;
				Q.push(Bver[nto]);
			
			}
			
		}
	}

	ll tcost = 10000000000000000;
	vector<ll> ans;

	REPr(i,n){
		tcost = min(tcost,Aver[i].cost + Bver[i].cost);
		ans.PB(1000000000000000-tcost);
	}

	REPr(i,n){
		PRINTLLD(ans[i]);
	}

}

Measured memory_bytes: 35072