akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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;
}
int main() {
    vector<vector<int>> V(3,vector<int>(3));
    vector<vector<int>> V_r(3,vector<int>(3));
    
    rep(i,3){
        rep(j,3){
            int a;cin>>a;
            V[i][j]=a;
            V_r[j][i]=a;
        }
    }
    int n;cin>>n;
    rep(f,n){
        int b;cin>>b;
        rep(i,3){
        rep(j,3){
            if(V[i][j]==b)V[i][j]=100000;
            if(V_r[j][i]==b)V_r[j][i]=100000;
        }
    }
    }
    bool ok=0;
    vector<int> d{100000,100000,100000};
    rep(i,3){
        if(V[i]==d){ok=1;break;}
        if(V_r[i]==d){ok=1;break;}
    }
    if(V[0][0]==100000 && V[1][1]==100000 && V[2][2]==100000){
        ok=1;
    }
    if(V[0][2]==100000 && V[1][1]==100000 && V[2][0]==100000){
        ok=1;
    }
    if(ok){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
{
  const main = (input: string): void | string | number => {
    const r = _reader(input)
    const n = r.n()
    const a = r.nls()

    const uf = _unionFind(n)

    a.forEach((v, i) => {
      uf.merge(v - 1, i)
    })
    if (!uf.issame(0, 1)) {
      return -1
    }

    let i = 0
    let now = 0

    while (now !== 1) {
      now = a[now] - 1
      i++
      if (i >= n) {
        return -1
      }
    }
    return i
  }

  const _unionFind = n => {
    const par: number[] = Array.from(Array(n).keys())
    const siz: number[] = Array(n).fill(1)

    // 根の検索
    const root = (x: number): number => {
      while (par[x] !== x) x = par[x] = par[par[x]]

      return x
    }
    const merge = (x: number, y: number): boolean => {
      x = root(x)
      y = root(y)
      if (x === y) return false
      if (siz[x] < siz[y]) [x, y] = [y, x]
      // merge technique（データ構造をマージするテク．小を大にくっつける）
      siz[x] += siz[y]
      par[y] = x
      return true
    }
    const issame = (x: number, y: number) => root(x) === root(y)
    const size = (x: number) => siz[root(x)]

    return { root, merge, issame, size }
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
}


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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int i,j,k,x,n;
	int arr[10005]={0};
	cin >> n;
	for(i=1;i<100;i++)
	{
		for(j=1;j<100;j++)
		{
			for(k=1;k<100;k++)
			{
				x = i*i+j*j+k*k+i*j+j*k+k*i;
				if(x>n)
					break;
				arr[x]++;
			}
		}
	}
	for(i=1;i<=n;i++)
		cout << arr[i] << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long
#define MOD 1000000007

using namespace std;

int main(){
  int n;cin>>n;
  ll result=1;

  rep(i,n){
    result *= (i+1);
    result %= MOD;
  }
  cout<<result;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

int main()
{
    ll x;
    cin >> x;
    ll a = 100;
    ll n = 1;
    while (true)
    {
        a *= 1.01;
        if (a >= x)
        {
            cout << n << endl;
            return 0;
        }
        n += 1;
    }

    return 0;
}


Measured memory_bytes: 3584
H,W,D=map(int, input().split())
A=[]
for h in range(H):
    a=list(map(int, input().split()))
    A.append(a)

idx=[0]*(H*W)
for h in range(H):
    for w in range(W):
        num=A[h][w]
        idx[num-1]=[h+1,w+1]
acum=[0]*(H*W+1)
for i in range(1,H*W+1):
    if i-D<=0:
        acum[i]=sum(idx[i-1])
    else:
        prex,prey=idx[i-1-D]
        nexx,nexy=idx[i-1]
        acum[i]=acum[i-D]+abs(nexx-prex)+abs(nexy-prey)
#print(acum)


Q=int(input())
for i in range(Q):
    l,r=map(int, input().split())
    print(acum[r]-acum[l])


Measured memory_bytes: 22804
from typing import List


class DSU:
    def __init__(self, n: int) -> None:
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a <= self._n
        assert 0 <= b <= self._n
        x, y = self.leader(a), self.leader(b)
        if x == y:
            return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a <= self._n
        assert 0 <= b <= self._n
        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n
        if self.parent_or_size[a] < 0:
            return a
        while self.parent_or_size[a] >= 0:
            a = self.parent_or_size[a]
        return a

    def size(self, a: int) -> int:
        assert 0 <= a <= self._n
        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> List[List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]
        group_size = [0] * self._n
        for i in leader_buf:
            group_size[i] += 1
        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)
        result = [i for i in result if i]
        return result


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = DSU(n)
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        print(int(uf.same(u, v)))
    else:
        uf.merge(u, v)


Measured memory_bytes: 76592
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    while(m--){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0) uf.unite(x, y);
        else cout << uf.issame(x, y) << endl;
    }
}


Measured memory_bytes: 3188
#include<stdio.h>
const int MAX_V = 10000;
int main(void){
    int i,k,n,p1,q1;
    int prime[MAX_V+1];
    for(i = 2; i <= MAX_V; i ++){
        prime[i] = 1;
    }
    for(i = 2; i * i <= MAX_V; i ++ ){
        if(prime[i]){
            for(k = 2 * i; k <= MAX_V; k += i){
                prime[k] = 0;
            }
        }
    }
    while(1){
        scanf("%d",&n);
        if(n == 0)break;
        for(i = n; i >= 2; i --){
            if(prime[i] == 1 && prime[i-2] == 1){
                q1 = i;
                p1 = i - 2;
                printf("%d %d\n",p1,q1);
                break;
            }
        }
    }
    return 0;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var A = cin.ReadInt;
            var B = cin.ReadInt;

            Console.WriteLine(Math.Ceiling((float)(B - 1)/ (float)(A - 1)));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector> 
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

struct SegmentTree {
  vector<pair<int, int> > Tree[22];

  void init() {
    for(int i=0;i<22;++i) {
      Tree[i].resize((1<<i));
      for(int j=0;j<Tree[i].size();++j) Tree[i][j] = mp(-1, -1);
    }
    return;
  }

  void eval(int pos1, int pos2) {
    if(Tree[pos1][pos2].se==-1) return;
    if(pos1+1<22) {
      Tree[pos1+1][2*pos2].se = max(Tree[pos1+1][2*pos2].se, Tree[pos1][pos2].se);
      Tree[pos1+1][2*pos2+1].se = max(Tree[pos1+1][2*pos2+1].se, Tree[pos1][pos2].se);
    }
    Tree[pos1][pos2].fi = max(Tree[pos1][pos2].fi, Tree[pos1][pos2].se);
    Tree[pos1][pos2].se = -1;
    return;
  }

  void update(int ql, int qr, int x, int pos1=0, int pos2=0, int sl=0, int sr=(1<<21)) {
    eval(pos1, pos2);
    if(sr<=ql || qr<=sl) return;
    if(ql<=sl && sr<=qr) {
      Tree[pos1][pos2].se = x;
      eval(pos1, pos2);
      return;
    }
    update(ql, qr, x, pos1+1, 2*pos2, sl, (sl+sr)/2);
    update(ql, qr, x, pos1+1, 2*pos2+1, (sl+sr)/2, sr);
    return;
  }

  int find(int ql, int qr, int pos1=0, int pos2=0, int sl=0, int sr=(1<<21)) {
    eval(pos1, pos2);
    if(qr<=sl || sr<=ql) return -1;
    if(ql<=sl && sr<=qr) return Tree[pos1][pos2].fi;
    return max(find(ql, qr, pos1+1, 2*pos2, sl, (sl+sr)/2), find(ql, qr, pos1+1, 2*pos2+1, (sl+sr)/2, sr));
  }

  void check() {
    for(int i=17;i<22;++i) {
      for(int j=0;j<(1<<(i-17));++j) {
        cout<<"("<<Tree[i][j].fi<<" "<<Tree[i][j].se<<")"<<" ";
      }
      cout<<endl;
    }
  }
};

int main() {
  int N, K;
  cin>>N>>K;
  int A[N];
  for(int i=0;i<N;++i) {
    cin>>A[i];
  }
  vector<int> ans(N);
  for(int i=0;i<N;++i) ans[i] = 0;
  int index;
  SegmentTree tree;
  tree.init();
  for(int i=0;i<N;++i) {
    index = tree.find(A[i], A[i]+1);
    if(index==-1) ans[i] = 1;
    else ans[i] = index+1;
    tree.update(max(0, A[i]-K), min(A[i]+K+1, (1<<21)), ans[i]);
  }
  sort(ans.begin(), ans.end(), greater<int>());
  cout<<ans[0]<<endl;
}



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

int main () {
	std::string S;
	std::cin >> S;
	std::reverse(S.begin(), S.end());

	std::string sub[] = {"maerd", "remaerd", "esare", "resare"};
	int i = 0;
	while(i < (int) S.length()) {
		bool flg = false;
		for(auto s : sub) {
			if(S.substr(i, s.length()) == s) {
				i += s.length();
				flg = true;
				break;
			}
		}
		if(not flg) break;
	}

	std::string ans;
	if(i < (int) S.length()) ans = "NO";
	else ans = "YES";
	std::cout << ans << std::endl;
}


Measured memory_bytes: 512
// abc057_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


ll manhattan(ll a, ll b, ll c, ll d){
    return abs(a - c) + abs(b - d);
}


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;
    vector<ll> A(N), B(N), C(M), D(M);
    REP(i, N) cin >> A[i] >> B[i];
    REP(i, M) cin >> C[i] >> D[i];

    REP(i, N){
        ll min_d = (ll)1e20;
        int min_id = 0;
        REP(j, M){
            ll d = manhattan(A[i], B[i], C[j], D[j]);
            if (d < min_d){
                min_d = d;
                min_id = j+1;
            }
        }
        print(min_id);
    }

    return 0;
}


Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val s = readLine()!!
    println(if(isAc(s)) "AC" else "WA")
}


fun isAc(s:String):Boolean {
    if(s[0] != 'A') {
        return false
    }
    if(s.substring(2 until s.length-1).count { it == 'C' } != 1) {
        return false
    }
    if(s.count { it == 'C' } != 1) {
        return false
    }
    if(s.substring(1).filter { it != 'C' }.all { it in ('a'..'z') }) {
        return true
    }
    return false
}

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

int main(){
  int x, y; cin >> x >> y;
  
  map<int, int> group =
  {
    {1, 0},
    {3, 0},
    {5, 0},
    {7, 0},
    {8, 0},
    {10, 0},
    {12, 0},
    {4, 1},
    {6, 1},
    {9, 1},
    {11, 1},
    {2, 2},
  };
  
  if (group.at(x) == group.at(y)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

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

typedef long long ll;
typedef long long int64;

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

  vector<int> w(n);
  for(int& val: w) cin >> val;

  int min = 999999;

  for(int t=0; t<=n; t++){
    int tmp = 0;
    for(int i=0; i<n; i++){
      if(i < t) tmp += w[i];
      else tmp -= w[i];
    }
    if(min > abs(tmp)){
      min = abs(tmp);
    }
  }

  cout << min << endl;

  return 0;
}


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

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    string S;cin >> S;
    int count1=0,count2=0;
    int N = S.length();
    rep(i,N){
        if(i%2==0){
            if(S[i]=='0')count1++;
        }else{
            if(S[i]=='1')count1++;
        }
    }

    rep(i,N){
        if(i%2==0){
            if(S[i]=='1')count2++;
        }else{
            if(S[i]=='0')count2++;
        }
    }
    cout << min(count1,count2) << endl;
    return 0;
}

Measured memory_bytes: 3720
n, p = map(int, input().split())
ps = []
for i in range(n):
    ps.append(input().split())
    ps[i][1] = int(ps[i][1])
t = 0
while len(ps) > 0:
    if ps[0][1] > p:
        ps.append([ps[0][0], ps[0][1] - p])
        t += p
        ps.pop(0)
    else:
        t += ps[0][1]
        print("{0} {1}".format(ps[0][0], t))
        ps.pop(0)


Measured memory_bytes: 16852
#include<stdio.h>
#include<string.h>

long num;
char s[100001];
char dream[7]={'d','r','e','a','m','e','r'};
char erase[6]={'e','r','a','s','e','r'};

int search(long i){
	long j;
	if(i==num) return 1;
	if(s[i]==dream[0]){
		for(j=1;j<7;j++){
			if(i+j==num) break;
			if(s[i+j]!=dream[j]) break;
		}
		if(j==7){
			if(search(i+7)) return 1;
		}
		if(j>4){
			if(search(i+5)) return 1;
		}
	}else if(s[i]==erase[0]){
		for(j=1;j<6;j++){
			if(i+j==num) break;
			if(s[i+j]!=erase[j]) break;
		}
		if(j==6){
			if(search(i+6)) return 1;
		}
		if(j>4){
			if(search(i+5)) return 1;
		}
	}
	return 0;
}

int main(){
	scanf("%s",s);
	num=strlen(s);
	if(search(0)){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, L, R;
  
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if ( L > R ) {
    cout << "Left" << endl;
  }
  else if ( L == R ) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int comp(const void *a, const void *b) {
	if( (*(unsigned long*)(a)) < (*(unsigned long*)(b))) {
		return -1;
	}
	if( (*(unsigned long*)(a)) > (*(unsigned long*)(b))) {
		return 1;
	}
	return 0;
}
int main() {
    unsigned long N, K;
	cin >> N >> K;
    if(N<K) {
		cout << "0" << endl;
		return 0;
	}
    unsigned long *H;
     H = (unsigned long*)malloc(N*sizeof(unsigned long));
    for(unsigned long i=0;i<N;i++) {
		cin >> H[i];
	}
    qsort(H, N, sizeof(unsigned long), comp);
    unsigned long total = 0;
    for(unsigned long i=0;i<N-K;i++) {
		total += H[i];
	}
    cout << total << endl;
	return 0;
}


Measured memory_bytes: 3324
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import Control.Monad.Primitive
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic.Mutable as VGM
import Data.STRef


rInt :: StateT BSL.ByteString Maybe Int
rInt = StateT $ BSL.readInt . BSL.dropWhile (<'!')


main :: IO ()
main = do
  s <- BS.getLine
  t <- BS.getLine
  putStrLn $ query s t



query :: BS.ByteString -> BS.ByteString -> String
query s t = go [] (BS.length s - 1) (BS.length t - 1)
  where
    go !str x y | x < 0 || y < 0 = str
                | s `BS.index` x == t `BS.index` y
                  = go (s `BS.index` x : str) (x-1) (y-1)
                | x == 0 = go str x (y-1)
                | y == 0 = go str (x-1) y
                | lcslengths VU.! ind (x-1) y >= lcslengths VU.! ind x (y-1)
                   = go str (x-1) y
                | otherwise = go str x (y-1)
    sqsize = BS.length s * BS.length t
    ind x y = BS.length t * x + y
    lcslengths = VU.create $ do
      vec <- VUM.new sqsize
      forM_ [0 .. BS.length s - 1] $ \x -> do
        forM_ [0 .. BS.length t - 1] $ \y -> do
          v_xm1ym1 <- if x > 0 && y > 0
                      then VUM.unsafeRead vec $ ind (x-1) (y-1)
                      else return (0::Int)
          v_xm1y <- if y > 0
                    then VUM.unsafeRead vec $ ind x (y-1)
                    else return 0
          v_xym1 <- if x > 0
                    then VUM.unsafeRead vec $ ind (x-1) y
                    else return 0
          VUM.unsafeWrite vec (ind x y)
            $ if s `BS.index` x == t `BS.index` y
              then v_xm1ym1 + 1
              else max v_xm1y v_xym1
      return vec


Measured memory_bytes: 71932
#include<bits/stdc++.h>
#define int long long
#define scf(n) scanf("%lld",&n)
#define rep1(n) for(int i=1;i<=n;i++)
#define prf(n) printf("%lld",n)
#define sci(n) scanf("%lld",&n)
#define pri(n) printf("%lld",n)

#define nl printf("\n")
#define spc printf(" ")
#define file freopen("in.txt","rt",stdin)
#define pii pair<int,int>
#define piii pair<pii,int>
#define MOD 10000007
using namespace std;

/*bool sortBySec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/
void faster(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
/******************************************/

/***********************************/
int n;
int arr[100009];
int B[100009];


int32_t main()
{


    /***********************************/
//#ifdef ONPC
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//#endif
//    //faster();

    /*********************************/
    sci(n);
    for(int i=0; i<n+1; i++)
    {
        sci(arr[i]);
    }
    for(int i=0; i<n; i++)
    {
        sci(B[i]);
    }
    int ans = 0;
    for(int i=0; i<n; i++)
    {
        if(arr[i]<=B[i])
        {
            ans+=arr[i];
            B[i]-=arr[i];
        }
        else
        {
            ans+=B[i];
            continue;
        }
        if(arr[i+1]<=B[i])
        {
            ans+=arr[i+1];
            arr[i+1] = 0;
            B[i]-=arr[i+1];
        }
        else
        {
            ans+=B[i];
            arr[i+1] = arr[i+1] - B[i];
        }

    }
    pri(ans),nl;
    return 0;
}



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

using namespace std;

int a,b;

int main() {
	scanf("%d %d",&a,&b);
	if(a>=b)
		for(; a; --a) putchar(b+48);
	else for(; b; --b) putchar(a+48);
	putchar('\n');
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,k;
  cin >> n >> k;
  k--;
  string s;
  cin >> s;
  if(s[k]=='A') s[k] = 'a';
  if(s[k]=='B') s[k] = 'b';
  if(s[k]=='C') s[k] = 'c';

  cout <<s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int a, b, c;
	int i;
	int count = 0;

	scanf("%d %d %d", &a, &b, &c);

	for (i = a; i < b + 1; i++){
		if (c%i == 0){
			count++;
		}
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;


int main() {
	
	string s;

	cin >> s;

	if (s == "A") {
		cout << "T" << endl;
	}
	else if (s == "T") {
		cout << "A" << endl;
	}
	else if (s == "C") {
		cout << "G" << endl;
	}
	else {
		cout << "C" << endl;
	}

	return 0;

}


Measured memory_bytes: 256
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector< pair<ll, ll> >
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto &i : a)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
//endregion

int main() {
    io();
    ll n, m;
    cin >> n;
    m = round(sqrt(n));
    while (n%m) --m;
    cout << m + (n/m) - 2;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i+=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF INT_MAX
#define mod 1000000007
#define print1(a) cout<<a<<"\n";
#define print2(a,b) cout<<a<<" "<<b<<"\n";
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define mt make_tuple
#define eb emplace_back

typedef unsigned long long int ll;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> State;

void solve(){
    string s,t;cin>>s>>t;
    int l=s.length();
    if(t.length()>=l && s==t.substr(0,l)) cout<<"Yes";
    else cout<<"No";
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
    return 0;
}

Measured memory_bytes: 3652
res = 0
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007


    N,M = map(int, input().split())
    g = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int, input().split())
        g[a-1].append(b-1)
        g[b-1].append(a-1)

    visited = [0]*N

    def dfs(node):
        global res
        visited[node]=1
        if all(visited):
            res += 1
            return
        for n_node in g[node]:
                if not visited[n_node]:
                    dfs(n_node)
                    visited[n_node] = 0
    dfs(0)
    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int main()
{

    int N;

    cin >> N;


    int a =N%10;


    if(a==3){

        cout << "bon" << endl;
    }
    else if (a==0 || a==1 || a==6 || a==8){

        cout << "pon" << endl;
    }
    else{

        cout << "hon" << endl;
    }
    

    

    
    return 0;
}

Measured memory_bytes: 3592
(r, c) = [int(i) for i in input().split()]

table = []
for rc in range(r):
    table.append([int(i) for i in input().split()])

table.append([0 for _ in range(c + 1)])

for rc in range(r):
    row_total = 0
    for cc in range(c):
        table[r][cc] += table[rc][cc]
        row_total += table[rc][cc]

    table[rc].append(row_total)
    table[r][c] += row_total

for row in table:
        print(' '.join([str(column) for column in row]))

Measured memory_bytes: 6732
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n, m;
	cin >> n >> m;

	for (ll i = 0; i < m; i++)
	{
		ll a;
		cin >> a;

		n -= a;
	}

	if (n < 0)
	{
		n = -1;
	}

	println(n);
}

Measured memory_bytes: 3636
(let* ((n (read))
       (d (read))
       (r (loop with d2 = (* d d)
                for i from 1 to n
                for x = (read)
                for y = (read)
                when (<= (+ (* x x) (* y y)) d2)
                count t)))
  (format t "~A~%" r))

Measured memory_bytes: 77100
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

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

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  char s; cin >> s;
  if('a' <= s && s <= 'z'){cout << "a" << endl;}
  else{cout << "A" << endl;}
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
 
int main(){
    int n;
     
    bool l[4][13];
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            l[i][j] = false;
        }
    }
 
    cin >> n;
 
    for(int i = 0; i < n; i++){
        char mark;
        int number;
        cin >> mark >> number;
        switch(mark){
            case 'S': l[0][number-1] = true; break;
            case 'H': l[1][number-1] = true; break;
            case 'C': l[2][number-1] = true; break;
            case 'D': l[3][number-1] = true; break;
        }
    }
 
    //0:S
    for(int j = 0; j < 13; j++){
        if(l[0][j] == false){
            cout << "S " << j+1 << endl;
        }
    }
 
    //1:H
    for(int j = 0; j < 13; j++){
        if(l[1][j] == false){
            cout << "H " << j+1 << endl;
        }
    }
 
    //2:C
    for(int j = 0; j < 13; j++){
        if(l[2][j] == false){
            cout << "C " << j+1 << endl;
        }
    }
 
    //3:D
    for(int j = 0; j < 13; j++){
        if(l[3][j] == false){
            cout << "D " << j+1 << endl;
        }
    }
 
    return(0);
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for(ll i=a;i <= b;i++)
#define fast_io ios_base::sync_with_stdio(false)
#define pb push_back
#define fir first
#define sec second
#define tr(it,x) for(it = x.begin();it != x.end();it++)
#define mp make_pair
#define sz(x) (ll)x.size()
#define rep(i,n) for(ll i=0;i<n;i++)
#define double long double
#define accuracy ll precision = numeric_limits<double>::digits10
#define pll pair<ll,ll>
#define N 1005

vector<ll> edg[N];

int main() {
	// freopen("input.txt", "r", stdin); 
	// freopen("output.txt", "w", stdout);
	fast_io;	 
	accuracy;
	ll n; cin >> n;
	ll k = -1;
	fr(i,1,1000) {
		if( ((i * (i-1)) /2ll) == n ) {
			k = i;
			break;
		}
	}
	if(k == -1) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		cout << k << endl;
		ll ind = 1;
		fr(i,1,k) {
			fr(j,i+1,k) {
				edg[i].pb(ind);
				edg[j].pb(ind);
				ind++;
			}
		}
		fr(i,1,k) {
			cout << sz(edg[i]) << " ";
			rep(j,sz(edg[i])) cout << edg[i][j] << " ";
			cout << endl;
		}
	}
}

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

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

const long long MOD = 1000000007;

void prime_factorize(int n,set<int> &prime){
    if(n<=1) return;
    int l=sqrt(n);
    for(int i=2;i<=l;i++){
        if(n%i==0){
        prime_factorize(i,prime);prime_factorize(int(n/i),prime);return;
        }
    }
    prime.insert(n);
    return;
}

int main(){
  int n,a;
  cin >> n;
  vector<int> p(1e6+1);
  int ans=0;
  
  rep(i,n){
    cin >> a;
    set<int> pr;
    
    prime_factorize(a,pr);
    for(auto x:pr){
      //cout << x << endl;
      p.at(x)++;
    }
  }
  
  for(int i=2;i<1e6+1;i++){
    ans=max(ans,p.at(i));
  }
  
  if(ans<=1) cout << "pairwise coprime" << endl;
  else if(ans < n) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
}


Measured memory_bytes: 7284
package main

import "fmt"

func main(){
	var H, N int;
	fmt.Scan(&H, &N);

	A := make([]int, N);

	for i:=0 ;i < N ;i++{
		fmt.Scan(&A[i]);
	}
	for i:=0 ; i < N ; i++ {
		H -= A[i];
	}
	if H <= 0 {
		fmt.Println("Yes");
	}else {
		fmt.Println("No");
	}
}

Measured memory_bytes: 5504
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 110
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};


//=============================================ASIFAZAD==============================================
int32_t  main()
{
    io;
    string s;
    cin>>s;
    int n = s.size();
    ll ans = 0;
    ll dp[n+1][2];
    dp[0][0] = 0;
    dp[0][1] = 1;
    for(int i = 1; i<= n; i++)
    {
        int k= s[i-1] - '0';
        dp[i][0] = min(dp[i-1][0]+k, dp[i-1][1] + 10-k);
        dp[i][1] = min(dp[i-1][0] + k + 1, dp[i-1][1] + 10 - k - 1);
    }
    cout<<dp[n][0];
    return 0;
}

Measured memory_bytes: 19884
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		v[i] -= i;
	}
	sort(v.begin(), v.end());
	int p = 0;
	int m = 0;
	for (auto i : v) {
		if (i > 0)p++;
		if (i < 0)m++;
	}
	int z = N - p - m;
	while (z) {
		if (p < m) {
			p++;
			z--;
		}
		else {
			m++;
			z--;
		}
	}
	if (p - m > 1) {
		long long int add = 0;
		int cnt = 0;
		for (auto i : v) {
			if (i > 0) {
				cnt++;
				add = -i;
				if (cnt * 2 >= p - m) {
					break;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			v[i] += add;
		}
	}
	if (m - p > 1) {
		long long int add = 0;
		int cnt = 0;
		for (int i = N - 1; i >= 0; i--) {
			if (v[i] < 0) {
				cnt++;
				add = -v[i];
				if (cnt * 2 >= m - p) {
					break;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			v[i] += add;
		}
	}
	long long int ans = 0;
	for (auto i : v)ans += abs(i);
	vector<long long int>box;
	long long int ap = MOD*MOD;
	long long int am = -MOD * MOD;
	for (auto i : v) {
		ap = min(ap, i);
		am = max(am, i);
	}
	box.push_back(ap);
	box.push_back(am);
	for (auto i : box) {
		long long int ret = 0;
		for (int j = 0; j < N; j++) {
			v[j] -= i;
			ret += abs(v[j]);
		}
		ans = min(ans, ret);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
using namespace std;
typedef long long ll;
const int N = 3000;
const ll INF = 1e18;

int a[N];
int main() {
	int n;
	while(~scanf("%d", &n)) {
		int sum = 0;
		for(int i = 0; i < n; ++i) {
			scanf("%d", &a[i]);
			sum += a[i] - 1;
		}
		printf("%d\n", sum);
	}
	return 0;
}

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

using namespace std;

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

using ll = long long;
using ull = unsigned long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ll h;
  cin >> h;

  ll idx = 1;

  ll ans = 0;

  while (h > 0) {
    ans += idx;
    idx = idx << 1;
    h = h >> 1;
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
N, X, Y = [int(i) for i in input().split()]

X -= 1
Y -= 1

a = [0] * N
for i in range(N - 1):
    for j in range(i + 1, N):
        a[min((j-i), abs(i-X)+1+abs(j-Y))] += 1

for k in range(1, N):
    print(a[k])


Measured memory_bytes: 3572
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  ll ans=0;
  ll n;cin>>n;
  ll a[n+10],b[n+10],c[n+10];
  rep(i,0,n)cin>>a[i];
  rep(i,0,n)cin>>b[i];
  rep(i,0,n)cin>>c[i];

  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);

  ll l,r;
  rep(i,0,n){
    l=lower_bound(a,a+n,b[i])-a;
    r=upper_bound(c,c+n,b[i])-c;
    ans += l*(n-r);
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.Scanner;

//Programming Contest Challenge Book
public class Main{

	int n;
	long res;
	long[] a;
	boolean[] u;
	
	void first(int k){
		if(k<5 || a[k-1]+a[k-2]<=a[k] || a[k]+a[k-1]+a[k-2]+a[k-3]+a[k-4]+a[k-5]<=res)return;
		u[k] = true;
		for(int i=k-1;i>=0&&2*a[i]>a[k];i--){
			long best = 0;
			for(int j=k;j>=k-5&&j>=0;j--)best+=a[j];
			if(best<=res)break;
			u[i] = true;
			for(int j=i-1;j>=0&&a[i]+a[j]>a[k];j--){
				u[j] = true;
				int f = k-1;
				long r = -1;
				while(f>=2&&r==-1&&res < a[k]+a[i]+a[j]+3*a[f]){
					if(!u[f])r = second(f);
					f--;
				}
				if(r!=-1)res = Math.max(res, a[i]+a[j]+a[k]+r);
				u[j] = false;
			}
			u[i] = false;
		}
		u[k] = false;
	}
	
	long second(int k){
		long sum = 0;
		int c = 0;
		for(int i=k-1;i>=0&&c<2;i--)if(!u[i]){
			c++; sum+=a[i];
		}
		return c<2 || sum<=a[k]?-1:(sum+a[k]);
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new long[n];
		u = new boolean[n];
		res = 0;
		for(int i=0;i<n;i++)a[i]=sc.nextLong();
		Arrays.sort(a);
		for(int i=n-1;i>4;i--)first(i);
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, D;
    cin >> N >> D;
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        if(x*x+y*y <= D*D) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
object Main {
  def main(args:Array[String]){
    val sc=new java.util.Scanner(System.in)
      while(true){
       val x=sc.nextInt;val kigo=sc.next;val y=sc.nextInt
       kigo match{
         case "+"=>println(x+y)
         case "-"=>println(x-y)
         case "*"=>println(x*y)
         case "/"=>println(x/y)
         case _=>return
       }
     }
  }
}

Measured memory_bytes: 44980
import java.util.Scanner;
 
public class Main {
 
	static final int INF = Integer.MAX_VALUE;
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try(Scanner scan = new Scanner(System.in)){
			int N = Integer.parseInt(scan.next());
			int K = Integer.parseInt(scan.next());
			int[] h = new int[N];
			int[] dp = new int[N];
 
			for(int i=0; i<N; i++) {
				h[i] = Integer.parseInt(scan.next());
				dp[i] = INF;
			}
 
			dp[0] = 0;
			dp[1] = Math.abs(h[1] - h[0]);
 
			for(int i=2; i<N; i++) {
				for(int j=1; j<=K; j++) {
                  if(i-j < 0){ continue;}
					dp[i] = Math.min(dp[i], dp[i-j] + Math.abs(h[i] - h[i-j]));
				}
			}
			System.out.println(dp[N-1]);
		}
	}
 
}

Measured memory_bytes: 48500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int hour = 0;
		int minute = 0;

		int second = Integer.parseInt(br.readLine());
		if((second > 0) && (86400 > second)){

			if(second >= 60){
				minute = second / 60;
				second %= 60;
			}
			if(minute >= 60){
				hour = minute / 60;
				minute = minute % 60;
			}
		}

		System.out.println(hour + ":" + minute + ":" + second);
	}
}

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

int main() {
    int n,a;
    cin>>n;
    long long count=0;
    for(int i=0; i<n; i++) {
        cin>>a;
        while(a%2 == 0) {
            count++;
            a /= 2;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, P>;
#define FOR(t, a, b) for (int t = (a); t < (b); ++t)
#define REP(t, n) FOR(t, 0, n)

int main()
{
    int m, n;
    cin >> m;
    n = m;
    int ans = 0;
    while (1)
    {
        ans += n % 10;
        n = n / 10;
        if (n == 0)
        {
            break;
        }
    }
    if (m % ans == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dat[200005];
int dif[200005];
bool check(){
	for(int i=1;i<=n;i++){
		if(dat[i]<n){
			return false;
		}
	}
	return true;
}
void did(int x){
	int L = max(1,x-dat[x]);
	int R = min(n , x+dat[x]);
	dif[L]++;
	dif[R+1]--;
}
void update(){
	for(int i=1;i<=n;i++){
		dat[i] = dat[i-1] + dif[i];
	}
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>dat[i];
	
	while(1 and k>0){
		for(int i=1;i<=n;i++) did(i);
		k--;
		if(check()) break;
		update();
		memset(dif,0,sizeof(dif));
	}
	
	if(k>0) {
		for(int i=0;i<n;i++) cout<<n<<" ";
	}
	else for(int i=1;i<=n;i++) cout<<dat[i]<<" ";
	cout<<'\n';
	return 0;
}

Measured memory_bytes: 5148
import java.util.*;

public class Main{

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

        // input
        long k = scan.nextLong();
        long a = scan.nextLong();
        long b = scan.nextLong();

        // search
        if(b - a <= 2 || a  > k){
            System.out.println(k + 1);
        } else {
            long exchange = (k - a + 1) / 2;
            System.out.println(1 + (k - exchange * 2) + exchange * (b - a));
        }
        
    }
}

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

using namespace std;

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

    int sum = 0;
    for (int i = 0; i < c; i++) {
        int x;
        cin >> x;
        sum += x;
    }

    n++;
    int ret = sum / n;
    if (sum % n > 0)ret++;

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3108