akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;

namespace Contest
{
    class Program
    {
        private Scanner sc;
        public void Solve()
        {
            sc = new Scanner();
            int n = sc.NextInt();
            int[] d = sc.IntArray();
            Array.Sort(d);
            //(d[n/2 -1] ,d[n/2]]

            Console.WriteLine(d[n / 2] - d[n / 2 - 1]);


        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private readonly char _separator;
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 16864
solver::[Int]->[Int]->Bool
solver as bs = (maximum as) < (minimum bs)

main::IO()
main=do
  nmxy<-getLine
  let n:m:x:y:[]= map read (words nmxy) ::[Int]
  xsc<-getLine
  ysc<-getLine
  let xs = map read (words xsc) ::[Int]
  let ys = map read (words ysc) ::[Int]
  putStr (if (solver (x:xs) (y:ys)) then "No War\n" else "War\n")


Measured memory_bytes: 1020
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>


int N_in;
int X_in;

int out;

int main(int argc, char* argv[]){
    int i,j;
    long int stand=0;
    int high=0;
    int now=0;
    int before=0;
    scanf("%d",&N_in);
    //for(i=1;i<=N_in;i++){
    //    before = now;
    //    scanf("%d",&now);
    //    if(before>now){
    //        stand += before - now;
    //        now = before;
    //    }
    //}
    for(i=1;i<=N_in;i++){
        scanf("%d",&now);
        if(now>high){
            high = now;
        }else if(now<high){
            stand += high - now;
        }
    }
    
    printf("%ld",stand);
    
    return 0;
}

Measured memory_bytes: 1700
def combi(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N,K = list(map(int,input().split()))
mod = 1000000007

blue = K
red = N-K
for i in range(1,K+1):
  if red+1 >= i:
    print( (combi(red+1,i)*combi(blue-1,i-1)) %mod )
  else:
    print(0)

Measured memory_bytes: 49756
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<double> comd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bucnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

vector<pii> rotate(vector<pii> a) {
	while (!(a[0].fst < a[1].fst&&a[0].scn == a[1].scn)) {
		rep(i, a.size())	a[i] = mp(a[i].scn, -a[i].fst);
	}
	return a;
}

int main() {
	while(true){
		int n;	cin >> n;
		if (n == 0)	break;
		vector<pii> base;
		int cnt = 0;
		REP(i, n) {
			int m;	cin >> m;
			vector<pii> v(m, mp(0, 0));
			rep(j, m) {
				cin >> v[j].fst >> v[j].scn;
			}
			rrep(j, m) {
				v[j].fst -= v[0].fst;
				v[j].scn -= v[0].scn;
			}
			v = rotate(v);
			vector<pii> v2 = v;
			reverse(all(v2));
			rrep(j, m) {
				v2[j].fst -= v2[0].fst;
				v2[j].scn -= v2[0].scn;
			}
			v2 = rotate(v2);
			if (i == 0)	base = v;
			else if (base == v || base == v2)	cout << i << endl;
		}
		cout << "+++++" << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

struct Combinations {

    long long mod;
    vector< long long > inv;
    vector< long long > fact;
    vector< long long > inv_fact;

    Combinations (int n, int m) : inv(n), fact(n), inv_fact(n), mod(m) {
        inv[1] = 1;
        for (long long i = 2; i < n; i++) {
            inv[i] = inv[mod%i] * (mod - mod / i) % mod;
        }
        fact[0] = inv_fact[0] = 1;
        for (long long i = 1; i < n; i++) {
            fact[i] = (fact[i-1] * i) % mod;
            inv_fact[i] = (inv_fact[i-1] * inv[i]) % mod;
        }
    }

    long long nPr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return fact[n] * inv_fact[n-r] % mod;
    }

    long long nCr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return nPr(n,r) * inv_fact[r] % mod;
    }

    long long nHr(long long n, long long r) {
        return nCr(n+r-1,r);
    }

};

ll N,K;
const ll MOD = 1000000007LL;

int main ()
{
    cin >> N >> K;
    Combinations inst(10000, MOD);

    for (ll i = 1LL; i <= K; i++) {
        ll ans = inst.nCr(N - K + 1, i) * inst.nHr(i, K - i);
        if (N - K + 1 < i) {
            cout << 0 << endl;
            continue;
        }
        cout << ans % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;

int main() {
	long l;
	long double a,b;
	cin >> l;
	a = (long double)l / 3.0;
	b = pow(a, 3);
	cout << fixed;
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include <cstring>
using namespace std;
int main()
{
    char str[105];
    int t=1,i=0;;
    scanf("%s",str);
    while(str[i]!='\0')
    {
        if((i+1)%2&&str[i]=='L')
        {
            cout<<"No\n";
            t=0;
            break;
        }
        if(!((i+1)%2)&&str[i]=='R')
        {
            cout<<"No\n";
            t=0;
            break;
        }
        i++;
    }
    if(t)
        cout<<"Yes\n";
    return 0;
}



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

using namespace std;

using ll = long long;

int F (ll a, ll b) {
	int da = floor(log10((double)a));
	int db = floor(log10((double)b));
	return max(da, db) + 1;
}

int main () {
	ll N, f;
	cin >> N;
	int ans = 9999;
	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			f = F(i, N / i);
			//printf("F(%d, %d) = %d\n", i, N / i, f);
			if (f < ans) ans = f;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
main = do
  [n, y] <- map read . words <$> getLine
  let ans = [[a, b, c] | a <- [0..n]
                       , b <- [0..(n - a)]
                       , let c = n - a - b
                       , 10000 * a + 5000 * b + 1000 * c == y]
  putStrLn $ unwords $ map show $ if null ans then [-1, -1, -1] else head ans


Measured memory_bytes: 1020
#include <stdio.h>

int main(void)
{
	int i, j, n, taro_p = 0, hanako_p = 0;
	char taro[101], hanako[101];

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%s %s", taro, hanako);

		for (j = 0;; j++){
			if (taro[j] > hanako[j]){
				taro_p += 3;
				break;
			}
			else if (taro[j] < hanako[j]){
				hanako_p += 3;
				break;
			}
			else if (taro[j] + hanako[j] == 0){
				hanako_p++;
				taro_p++;
				break;
			}
		}
	}

	printf("%d %d\n", taro_p, hanako_p);

	return 0;
}


Measured memory_bytes: 2056
// https://beta.atcoder.jp/contests/abc077
// status:
// tag: [sort][binary_search]

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 100000;
int N;
int A[MAX_N], B[MAX_N], C[MAX_N];

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(6
3 14 159 2 6 53
58 9 79 323 84 6
2643 383 2 79 50 288
)");
    stringstream stream(program_input);
#endif
    stream >> N;
    for (int i = 0; i < N; ++i) stream >> A[i];
    for (int i = 0; i < N; ++i) stream >> B[i];
    for (int i = 0; i < N; ++i) stream >> C[i];

    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);

    ui64 ans = 0;
    for (auto i = 0; i < N; ++i) {
        auto na = distance(A, lower_bound(A, A + N, B[i]));
        auto nc = N - distance(C, upper_bound(C, C + N, B[i]));
        ans += na * nc;
    }

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

Measured memory_bytes: 1536
#ライブラリインポート
from collections import defaultdict, deque

INF = float("inf")
#入力受け取り
def getlist():
	return list(map(int, input().split()))


#処理内容
def main():
	N, M = getlist()
	outE = defaultdict(list)
	inE = defaultdict(int)	
	for i in range(M):
		a, b = getlist()
		outE[a - 1].append(b - 1)
		inE[b - 1] += 1

	Q = deque()
	for i in range(N):
		if inE[i] == 0:
			Q.append(i)

	cnt = 0
	while True:
		if not Q:
			break
		cnt += 1
		q = deque()
		while Q:
			u = Q.popleft()
			for v in outE[u]:
				inE[v] -= 1
				if inE[v] == 0:
					q.append(v)
		Q = q

	print(cnt - 1)


if __name__ == '__main__':
	main()

Measured memory_bytes: 42284
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    int ans;
    if(N > K) ans = K* X + (N - K)*Y;
    else ans = N * X;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 2e5 + 5;
 
vector <int> g[N];
vector <int> has;
ll a[N];
ll ans[N];
int n;
int st[N], ed[N];
int t = 0;
int q;
 
void dfs(int u, int p) {
  st[u] = ++t; has.push_back(u);
  for(auto v : g[u]) {
    if(v == p) continue;
    dfs(v, u);
  }
  ed[u] = t;
}
 
int main() {
  cin >> n >> q; has.push_back(-1);
  for(int i = 1; i < n; i++) {
    int u, v; cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  while(q--) {
    int p; cin >> p;
    ll x; cin >> x;
    a[st[p]] += x, a[ed[p] + 1] -= x;
  }
  //for(int i = 1; i <= n; i++) {
    //a[i] += a[i - 1];
  //}
  ll sum = 0;
  for(int i = 1; i <= n; i++) {
    sum += a[i]; ans[has[i]] = sum;
  }
  for(int i = 1; i <= n; i++) {
    cout << ans[i] << ' ';
  }
}

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

unsigned long long popcount(unsigned long long x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) +
      (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) +
      (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) +
      (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) +
      (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) +
      (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) +
      (x & 0x00000000ffffffffUL);
  return x;
}

long long n;
long long memo[20][2] = {0};

long long solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    long long tr = 0, fal = 0, x, y, a;
    cin >> a;
    for(int j = 0; j < a; ++j) {
      cin >> x >> y;
      --x;
      if(y)
        tr += 1LL << x;
      else
        fal += 1LL << x;
    }
    memo[i][1] = tr;
    memo[i][0] = fal;
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  int ans = 0;
  for(long long i = 0; i < (1LL << n); ++i) {
    bool ch = 1;
    for(int j = 0; j < n; ++j)
      if((i >> j) & 1) {
        if((i & memo[j][1]) != memo[j][1]) ch = 0;
        if((((1LL << n) - 1 - i) & memo[j][0]) !=
           memo[j][0])
          ch = 0;
      }
    if(ch) ans = max(ans, (int)popcount(i));
  }
  return ans;
}

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

graph=[set() for _ in range(N+1)]
for _ in range(M):
  a,b=map(int,input().split())
  graph[a].add(b)
  graph[b].add(a)
#print(graph)

high_list=[0]*(N+1)
for i in range(1,N+1):
  if high_list[i]==-1:
    continue
  
  h=hlist[i-1]
  for s in graph[i]:
    if h<=hlist[s-1]:
      high_list[i]=-1
    if h>=hlist[s-1]:
      high_list[s]=-1 
      
  if high_list[i]==0:
    high_list[i]=1

answer=0
for i in range(1,N+1):
  if high_list[i]==1:
    #print(i)
    answer+=1

print(answer)

Measured memory_bytes: 46008
N, M = map(int, input().split())
a = []
b = []
for i in range(M):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)

for i in range(N):
    r = 0
    r += a.count(i+1)
    r += b.count(i+1)
    print(r)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}
ll ans=-1000000000;



int main()
{
 ll n;
 cin>>n;
 vector<ll>v(n);
 rep(i,n)cin>>v[i];
 sort(v.rbegin(),v.rend());
 ll ans=0;
 rep(i,n){
     ll a=v[i];
     for(ll k=i+1;k<n;k++){
         ll b=v[k];
         for(ll l=k+1;l<n;l++){
             ll c=v[l];
             if(a>=c+b)break;
             ans++;
         }
     }
 }
 cout<<ans<<endl;

}



Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <map>
#include <queue>
#include <stack>
#include <set>
using namespace std;

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
            if(n>=k)
            {
                if(n%k==0)
                    printf("0\n");
                else
                    printf("1\n");
            }
            else
            {
                printf("1\n");
            }
    }
    return 0;
}


Measured memory_bytes: 256
/*
 * atcode154-c
 */

#include <stdio.h>
#include <stdlib.h>

int
comp_int(const void *p1, const void *p2)
{
  int *i1 = (int *)p1;
  int *i2 = (int *)p2;

  return (*i1 > *i2);
}

int
main(int argc, char *argv[])
{
  int *np;
  int n, i;

  scanf("%d", &n);
  np = (int *) malloc(n * sizeof (int));

  for (i = 0; i < n; i++) 
    scanf("%d", np+i);

  qsort(np, n, sizeof (int), comp_int); 

  for (i = 0; i < n - 1; i++) {
    if (np[i] == np[i+1]) {
      printf("NO\n");
      return (0);
    }
  }
  printf("YES\n");
  return (0);
}


Measured memory_bytes: 1788
import sys
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N = ii()
S = li()
K = ii()
st = S[K-1]
for i in range(N):
    if S[i] != st:
        S[i] = '*'

print(''.join(S))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

unsigned long long merge(	std::vector<int>::iterator left,
			std::vector<int>::iterator mid, 
			std::vector<int>::iterator right){

	unsigned long long cnt = 0;
	std::vector<int> L(mid-left),R(right-mid);

	for(std::vector<int>::iterator i=left; i!=mid; i++) L[i-left] = *i;
	L.push_back(1000000000);
	for(std::vector<int>::iterator i=mid; i!=right; i++) R[i-mid] = *i;
	R.push_back(1000000000);

	int ri = 0, li = 0;
	for(int k=0; k<right-left; k++){
		if(L[li]>R[ri]){
			*(left+k) = R[ri];
			if( (mid+ri)>(left+k) ) cnt += (mid+ri)-(left+k);
			ri += 1;
		}else{
			*(left+k) = L[li];
			li += 1;
		}
	}
	return cnt;
}

unsigned long long mergeSort(	std::vector<int>::iterator left, 
				std::vector<int>::iterator right ){
	unsigned long long cnt = 0;
	if(right-left>1){	
		int num = right - left;
		std::vector<int>::iterator mid = left + num/2;
		cnt += mergeSort(left,mid);
		cnt += mergeSort(mid,right);
		cnt += merge(left,mid,right);
	}
	return cnt;
}

int main(int argc, char const *argv[]){
	int n;
	unsigned long long cnt;
	std::cin >> n;
	std::vector<int> S(n);
	// for(int i=0; i<n; i++) S[i] = n-i;
	for(int i=0; i<n; i++) std::cin >> S[i];
	cnt = mergeSort(S.begin(),S.end());
	// for(int i=0; i<n; i++) std::cout << S[i] << ((i<n-1)?" ":"\n");
	std::cout << cnt << std::endl;
	return 0;
}


Measured memory_bytes: 5224
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int n;
int a[100001];

long long int solve()
{
	long long int sum = a[0];
	long long int ans = 0;
	for(int i = 1; i < n; i++){
		if(sum > 0 && sum + a[i] >= 0){
			ans += abs(-1 - sum - a[i]);
			sum = -1;
		} else if(sum < 0 && sum + a[i] <= 0){
			ans += abs(1 - sum - a[i]);
			sum = 1;
		} else {
			sum += a[i];
		}
	}
	return ans;
}

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	long long int tmp1 = 0, tmp2 = 0;
	int tmp = a[0];
	if(a[0] <= 0){
		tmp1 += 1 - a[0];
		a[0] = 1;
	}
	tmp1 += solve();
	a[0] = tmp;
	if(a[0] >= 0){
		tmp2 += a[0] + 1;
		a[0] = -1;
	}
	tmp2 += solve();
	// cout << tmp1 << " " << tmp2 << endl;
	cout << min(tmp1, tmp2) << endl;
}

Measured memory_bytes: 640
cards = list()
suits = ['S','H','C','D']
n = int(input())
for i in range(n):
    x,y = input().split()
    y = int(y)
    if x == 'S':
        cards.append(y+0)
    elif x == 'H':
        cards.append(y+13)
    elif x == 'C':
        cards.append(y+26)
    elif x == 'D':
        cards.append(y+39)
for i in range(1,53):
    if not(i in cards):
        print(suits[(i-1)//13],(i-1)%13+1)
        


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	cout << s.substr(0,sz(s)-8) << endl;

}



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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  ll A, B, N;
  cin >> A >>  B >> N;
  if(N < B){
    cout << (A*(N))/ B << endl;
  }
  else{
    cout << (A*(B-1))/ B << endl;
  }
  return 0;
}

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

int main(){

    int h,a;
    cin >> h >> a;

    if(h%a==0){
        cout << h/a << endl;
    }else{
        cout << h/a+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  simCity
//  Copyright © 2019 ITOOKASHIKI. All
#define vv(t) vector<vector<t>>
#define v(t) vector<t>
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for(int i=0; i<n; ++i)
#define FOR(i, m, n) for(int i=m; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#include <iostream>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
//cin.tie(0);
//sync_with_stdio(false);
template <class T = int>    T in(){ T x;  cin >> x;   return (x); }
template <class T>          void printn(T& x){ cout << x << '\n'; }
template <class T>          void print(T& x){ cout << x; }

int main(int argc, const char * argv[]) {
    int w, s, K;
    w = in();
    rep(i, 4){ s = in(); }
    K = in();
    cout << (s-w <= K ? "Yay!" : ":(") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<long>ar(n+1);
  ar[0]=0;
  for(int i=1; i<=n; i++){
    int tmp;
    cin >> tmp;
    ar[i] = ar[i-1] + tmp;
  }
  map<long, int>rcnt;
  for(int i=0; i<=n; i++)rcnt[ar[i]]++;
  long ret=0;
  for(pair<int, int>p : rcnt){
    long t = p.second;
    ret += (t*(t-1))/2;
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 14336
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		while ((line = br.readLine()) != null) {
			String[] arr = line.split(" ");
			if ("0".equals(arr[0]) && "0".equals(arr[1]))
				break;
			int a = Integer.parseInt(arr[0]);
			int b = Integer.parseInt(arr[1]);

			if (a > b)
				System.out.println(b + " " + a);
			else
				System.out.println(a + " " + b);
		}
	}
}

Measured memory_bytes: 24400
#include<bits/stdc++.h>
using namespace std;
long long arr[3005];
long long dp[3005][3005];
long long cdp[3005][3005];
int main()
{
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int n,s;
    cin>>n>>s;
    for (int i = 1; i <= n; i++) 
    cin >> arr[i];
    long long ans=0;
    for (int i = 1; i <= n; i++)
    {
        dp[i][arr[i]] = i;
        for (int j = arr[i] + 1; j < 3005; j++)
        dp[i][j] = cdp[i - 1][j - arr[i]];
        for (int j = 0; j < 3005; j++) 
        cdp[i][j] = (cdp[i - 1][j] + dp[i][j])%998244353;
        ans += (dp[i][s] * (n - i + 1))%998244353;
        ans%=998244353;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N;
    long long D, A;
    cin >> N >> D >> A;
    vector<pair<long long, long long>> X(N);
    for(int i=0; i<N; ++i) cin >> X[i].first >> X[i].second;
    sort(begin(X), end(X));

    long long res = 0;
    long long sum = 0;
    queue<pair<int, long long>> bomb;
    for(int i=0; i<N; ++i) {
        while(!bomb.empty() && bomb.front().first < X[i].first) {
            sum -= bomb.front().second;
            bomb.pop();
        }
        if(sum < X[i].second) {
            long long r = X[i].second - sum;
            long long cnt = (r + A - 1) / A;
            res += cnt;
            sum += A * cnt;
            bomb.emplace(X[i].first + 2 * D, A * cnt);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;
 
void unko(bool x) {
	if (x) cout << "unko" << endl;
}
 
int main() {
    int N, M; cin >> N >> M;
    vector<int> K(N);
    vector<vector<int> > S(N), H(N);
	int sumK = 0;
    for (int i = 0; i < N; i++) {
        cin >> K[i];
		sumK += K[i];
        for (int k = 0; k < K[i]; k++) {
            int s, h; cin >> s >> h;
            S[i].push_back(s);
            H[i].push_back(h);
        }
    }
	unko(sumK >= 4000 * 0.75 && M >= 200 * 0);
    double maxi = 0;
    for (int t = 0; t < N; t++) {
        vector<int> dp(M + 1, -INF);
        dp[M] = 0;
        for (int i = 0; i < N - 1; i++) {
            vector<int> _dp = dp;
            for (int j = 0; j <= M; j++) {
                int h = 0, v = 0;
                for (int k = 0; k < K[i]; k++) {
                    h += H[i][k];
                    v += S[i][k] * H[i][k];
                    if (v > j) break;
                    _dp[j - v] = max(_dp[j - v], dp[j] + h);
                }
            }
            dp = _dp;
        }
        for (int j = 0; j <= M; j++) {
            double h = dp[j], v = j;
            for (int k = 0; k < K[N - 1]; k++) {
                double dh = min((double)H[N - 1][k], v / S[N - 1][k]);
                h += dh; v -= S[N - 1][k] * dh;
            }
            maxi = max(maxi, h);
        }
        rotate(K.begin(), K.begin() + 1, K.end());
        rotate(S.begin(), S.begin() + 1, S.end());
        rotate(H.begin(), H.begin() + 1, H.end());
    }
    printf("%.20f\n", maxi);
}

Measured memory_bytes: 1272
import java.io.PrintWriter
import java.util.NoSuchElementException

fun main(args: Array<String>) = IO().exec {
    val s = string()
    val sb = StringBuilder(s.reversed())
    for (i in s.indices) {
        when {
            sb[i] == 'b' -> sb[i] = 'd'
            sb[i] == 'd' -> sb[i] = 'b'
            sb[i] == 'p' -> sb[i] = 'q'
            sb[i] == 'q' -> sb[i] = 'p'
        }
    }
    if (s == sb.toString()) println("Yes") else println("No")
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

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

using namespace std;


using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

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

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

long long int side[1002][1002], ver[1002][1002];

int main() {

  string input, s;

  long long int n;

  while( true ) {

    cin >> n;

    if ( n == 0 ) break;

    vector< string > map;
    s = "**";
    for ( long long int i = 0; i < n; i++ ) {
      s += "*";
    }
    map.push_back( s );
    for ( long long int i = 0; i < n; i++ ) {
      cin >> input;
      input = "*" + input + "*";
      map.push_back( input );
    }
    map.push_back( s );
    for ( long long int i = 1; i <= n; i++ ) {
      long long int cnt_s = 0;
      long long int cnt_v = 0;
      for ( long long int j = 1; j <= n; j++ ) {
	if ( map[i][j] == '*' ) {
	  cnt_s = 0;
	}else {
	  cnt_s++;
	}
	side[i][j] = cnt_s;
	if ( map[j][i] == '*' ) {
	  cnt_v = 0;
	}else {
	  cnt_v++;
	}
	ver[j][i] = cnt_v;
      }
    }
    long long int ans = 0;
    long long int x, y;
    for ( long long int i = 0; i < 2 * n - 1; i++ ) {
      if ( i < n ) {
	x = 1;
	y = n - i;
      }else {
	x = i - ( n - 2 );
	y = 1;
      }
      long long int cnt = 0;
      while( true ) {
	if ( side[y][x] > cnt && ver[y][x] > cnt ) {
	  cnt++;
	}else {
	  ans = max( ans, cnt );
	  cnt = min( side[y][x], ver[y][x] );
	}
	x++;
	y++;
	if ( x > n || y > n ) break;
      }
      ans = max( ans, cnt );
    }

    cout << ans << endl;

  }

  return 0;

}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;
ll n,k,pr[MAXN],pr1[MAXN],len,fr[MAXN];
string s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll i,j,cnt=0,ans=0,t=1;
    cin>>n>>k;
    cin>>s;
    if(n==1) ret(1)
    string r;
    char l='.';
    rep(i,0,n){
        if(s[i]!=l){ 
            if(i!=0) fr[len++]=cnt;
            r+=s[i],cnt=1,l=s[i];
        }
        else cnt++;
    }
    if(cnt>1 || n==1) fr[len++]=cnt;
    // trace(r,len);
    rep(i,0,len){
        if(r[i]=='0') pr[i]=1;
    }
    // parr(fr,len);
    // parr(pr,len);
    partial_sum(pr,pr+len,pr);
    partial_sum(fr,fr+len,fr);
    // parr(fr,len);
    // parr(pr,len);
    rep(i,0,len){
        ll pos=ubnd(pr+i,pr+len,pr[i]+k-(r[i]=='0'))-pr-1;
        ans=max(ans,fr[pos]-(i>0?fr[i-1]:0));
    }
    ret(ans)
    return 0;
}

Measured memory_bytes: 2176
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

let array;
let index = 0;
let n;
let m;
let answers = [];
while (line = lines.shift()) {
    if(index === 0){
        const test = line.split(' ').map(Number);
        n = test[0];
        m = test[1];
        index ++;
    } else {
        array = line.split(' ').map(Number);


        let answer = 0;
        for(let i = 0; i<n ;i++){
            for(let j = 0;j<n;j++){
                if(i === j){
                    continue;
                }
                const test = array [i] + array [j];
                if(test > answer && test <= m){
                    answer = test;
                }
            }
        }
        index = 0;
        answers.push(answer);

    }
}
answers.forEach(data => console.log(data ? data : 'NONE'))


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

ll find1(ll n, ll m) {
	ll N = n;
	n *= 2, m *= 2;
	ll res = 0;
	while (true) {
		m -= min(N, n);
		if (m <= 0) break;
		++res;
		n -= (m + 1) / 2;
		if (n <= 0) break;
		++res;
	}
	return res;
}

ll find2(ll n, ll m) {
	ll M = m;
	n *= 2, m *= 2;
	ll res = 0;
	while (true) {
		m -= (n + 1) / 2;
		if (m <= 0) break;
		++res;
		n -= min(M, m);
		if (n <= 0) break;
		++res;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	ll N, M;
	cin >> N >> M;
	cout << min(find1(N, M), find2(N, M)) << endl;
	return 0;
}



Measured memory_bytes: 3152
#include <iostream>
using namespace std;
int main()
{
	long A, B;
	char op;
	long ans;
	cin >> A >> op >> B;
	if (op=='+')
	{
		ans = A + B;
	}
	if (op=='-')
	{
		ans = A - B;
	}
	cout << ans << endl;
}

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

using namespace std;

long long dp [105] [100005], w [105], val[105]; 

long long f (long long pos,long long x) {
	if (pos == -1) return 0;
	//cout << pos << " " << x << " " << dp [pos] [x] << endl;
	if (dp [pos] [x]) return dp [pos] [x];
	if (x - w [pos] < 0) {
		dp [pos] [x] = f  (pos - 1, x);
		return dp [pos] [x];
	}
	dp [pos] [x] = max (f (pos - 1, x),f (pos - 1,x - w [pos]) + val [pos]);
	return dp [pos] [x];
}

int main  () {
	long long W,n,i;
	cin >> n >> W;
	for  (i = 0; i < n; i++) {
		cin >> w [i] >> val [i];
	}
	long long a = f (n-1,W);
	cout << a;
	return 0;
}



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

  int main()
  {
  long  int x;
    cin>>x;
    int a,b;
    for(a=-118;a<=119;a++)
      for( b=-118;b<=119;b++)
         if(pow(a,5)-pow(b,5)== x) 
         { cout<<a<<" "<<b; exit(0);}
   
    return 0;
  }


Measured memory_bytes: 4072
#include<stdio.h>
#include<algorithm>
char str[15];
int use[12];
bool solve(int a){
	if(a==0)return true;
	for(int i=0;i<9;i++){
		if(use[i]){
			if(use[i]>=3){
				use[i]-=3;
				bool res=solve(a-3);
				use[i]+=3;
				if(res)return true;
			}
			if(use[i]>=2&&a%3==2){
				use[i]-=2;
				bool res=solve(a-2);
				use[i]+=2;
				if(res)return true;
			}
			if(use[i]&&use[i+1]&&use[i+2]){
				use[i]--;
				use[i+1]--;
				use[i+2]--;
				bool res=solve(a-3);
				use[i]++;
				use[i+1]++;
				use[i+2]++;
				if(res)return true;
			}
			return false;
		}
	}
}
int main(){
	while(~scanf("%s",str)){
		for(int i=0;i<9;i++)use[i]=0;
		for(int i=0;i<13;i++)use[str[i]-'1']++;
		bool ok=false;
		for(int i=0;i<9;i++){
			if(use[i]==4)continue;
			use[i]++;
			if(solve(14)){
				if(ok)printf(" ");
				printf("%d",i+1);
				ok=true;
			}
			use[i]--;
		}
		if(!ok)printf("0");
		printf("\n");
	}
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define MX 100016

double dp[2*MX];

int main()
{
    //canhazfast();

    int n, k;
    double ans = 0.0;

    scanf("%d%d", &n, &k);
    for (int i = k; i <= max(2*k, n); ++i) dp[i] = 1.0;
    for (int i = k-1; i > 0; --i) dp[i] = 0.5*dp[2*i];
    for (int i = 1; i <= n; ++i) ans += dp[i];
    ans /= n;
    printf("%.10lf\n", ans);

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;


int main(void){
  int N;
  cin >> N;
  int div_count[110] = {0};
  int more_number[6] = {0};
  //素因数分解をしてリストをまとめる
  for(int i = 2; i <= N; i++){
    int temp_i = i;
    for(int j = 2; j <= i; j++){
      while(temp_i % j == 0){
        div_count[j]++;
        temp_i = temp_i / j;
      }
    }
  }
  //sort(div_count, div_count + 100, greater<int>());
  //約数の個数：(1, 75), (3, 25), (5, 15)の3つ
  //つまり各々以上の物の個数を数えて6個の配列に入れておく。
  for(int i = 0; i < 110; i++){
    if(div_count[i] >= 1){
      more_number[0]++;
    }
    if(div_count[i] >= 2){
      more_number[1]++;
    }
    if(div_count[i] >= 4){
      more_number[2]++;
    }
    if(div_count[i] >= 14){
      more_number[3]++;
    }
    if(div_count[i] >= 24){
      more_number[4]++;
    }
    if(div_count[i] >= 74){
      more_number[5]++;
    }
  }
  //3つの組み合わせについて，その数を求める。重複が存在するので，1引く必要があることに注意。
  int ans_cnt = 0;
  for(int i = 1; i < 3; i++){
    if(more_number[i] > 0){
      ans_cnt += (more_number[i] - 1)*more_number[5 - i];
    }
  }
  if(more_number[5] > 0){
    ans_cnt += more_number[5];
  }
  if(more_number[1] > 2 && more_number[2] > 1){
    ans_cnt += (more_number[1] - 2) * more_number[2] * (more_number[2] - 1) / 2;
  }
  /*
  for(int i = 0; i < 110; i++){
    cout << div_count[i] << " ";
    if(i % 10 == 0){
      cout << endl;
    }
  }
  */
  for(int i = 0; i < 6; i++){
    //cout << more_number[i] << " ";
  }
  cout << ans_cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

string tobin(ll a){
    string ret = "";
    while(a>0){
        if(a%2 == 0) ret += "0";
        else ret += "1";
        a /= 2;
    }
    reverse(all(ret));
    return ret;
}

ll add(ll n,ll a){
    //cout<<"in :"<<tobin(n)<<" "<<tobin(a)<<endl;
    ll i = 1;
    while(i<=a){
        if(a&i){
            if(!(n&i)){
                n += i;
            }
            else{
                if(n&(i<<1)){
                    n -= i;
                    n -= (i<<1);
                }
                else{
                    n -= i;
                    n = add(n,i<<1);
                    n = add(n,i<<2);
                }
            }
        }
        i <<= 1;
    }
    //cout<<"out :"<<n<<endl;
    return n;
}

int main(void) {
    ll n;
    cin>>n;
    string s = tobin(abs(n));
    reverse(all(s));
    if(n == 0){
        cout<<0<<endl;
    }
    else if(n < 0){
        n = abs(n);
        ll ans = 0;
        rep(i,s.size()){
            if(s[i] == '1'){
                if(i%2 == 0){
                    ans = add(ans,pow(2,i+1));
                }
                ans = add(ans,pow(2,i));
            }
        }
        cout<<tobin(ans)<<endl;
    }
    else{
        ll ans = 0;
        //cout<<tobin(ans)<<endl;
        rep(i,s.size()){
            if(s[i] == '1'){
                if(i%2 == 1){
                    //cout<<"i"<<i<<endl;
                    ans = add(ans,pow(2,i+1));
                }
                ans = add(ans,pow(2,i));
            }
            //cout<<tobin(ans)<<endl;
        }
        cout<<tobin(ans)<<endl;
    }
	return 0;
}


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  string X,Y;
  cin>>X>>Y;
  int m=X.length();
  int n=Y.length();
int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS  
  
   // Create a character array to store the lcs string 
  // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
  vector<char>ans;
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
           ans.push_back(X[i-1]); // Put current character in result 
          i--; j--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  reverse(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++)
    cout<<ans[i];
  return 0;
}

Measured memory_bytes: 35456