akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;
int ans[200010];
int cur[2][200010];
int bitcount(int n){
   int ans =0;
   while(n!=0){
      ans++;
      n&=n-1;
   }
   return ans;
}
int rec(int n){
   if(ans[n]!=-1) return ans[n];
   int b = bitcount(n);
   return ans[n]=1+rec(n%b);
}
int main(){
   int N;
   string X;
   cin >> N >> X;
   int count = 0;
//   cout << X.size() << endl;

   for(int i = 0 ; i < N;i++){
      if(X[i]=='1') count++;
   }
   int o1=1;
   int o2=1;
   int S[2];
   memset(S,0,sizeof(S));
   for(int i = N-1; i>=0; i--){
      cur[0][i]=o1;
      cur[1][i]=o2;
//      cout << o1 <<" "<< o2 << endl;
      if(X[i]=='1'){
         //cout << o1 << endl;
         S[0]+=o1;
         S[0]%=(count+1);
         if(count!=1){
            S[1]+=o2;
            S[1]%=(count-1);
         }
      }
      o1*=2;
      o1%=(count+1);
      if(count!=1){
         o2*=2;
         o2%=(count-1);
      }
   }
//   cout << S[0] << " " << S[1]<<endl;

   memset(ans,-1,sizeof(ans));
   ans[0]=0;
   for(int i=0;i<N;i++){
      if(X[i]=='1'){
         int nxt = S[1]+(count-1)-cur[1][i];
         if(count==1){
            cout << 0 << endl;
         }
         else{
            nxt %= (count-1);
            //cout << "nxt:" << nxt << endl;
            cout << 1+rec(nxt)<<endl;
         }
      }
      else{
         int nxt = S[0]+(count+1)+cur[0][i];
//         cout << S[0] << " " << count+1 << " " << cur[0][i];
         nxt %= (count+1);
         //cout << "nxt: " << nxt << endl;
         cout << 1+rec(nxt)<<endl;         
      }
   }
   return 0;
}


Measured memory_bytes: 6088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
ll fac[N];
ll ksm(ll a,ll n){
	ll ans=1;
	while(n){
		if(n&1) ans=ans*a%mod;
		a=a*a%mod;
		n>>=1; 
	}
	return ans;
}
ll C(ll n,ll m){
	if(n<m||n<0||m<0) return 0;
	return fac[n]*ksm(fac[m]*fac[n-m]%mod,mod-2)%mod;
}
int main(){
	int h,w,a,b;
	scanf("%d%d%d%d",&h,&w,&a,&b);
	fac[0]=1;
	for(int i=1;i<=1e6+5;i++)
		fac[i]=i*fac[i-1]%mod;
	ll ans=0;
	for(int i=b+1;i<=w;i++){
		ans+=C(h-a+i-2,i-1)*C(a+w-i-1,w-i)%mod;
		ans%=mod;
	}
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 11596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "Yes";
const string NO = "No";

void solve(std::string Str)
{
    bool N = false, E = false, W = false, S = false;

    for (int i = 0; i < Str.size(); i++)
    {
        if (Str[i] == 'N')
            N = true;
        if (Str[i] == 'E')
            E = true;
        if (Str[i] == 'W')
            W = true;
        if (Str[i] == 'S')
            S = true;
    }

    if (N == S && E == W)
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

int main()
{
    std::string Str;
    std::cin >> Str;
    solve(Str);
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc095/tasks/abc095_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << 700 + count(ALL(s), 'o') * 100 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
int c[100];

int length(int i, int j) {
    return c[10 * i + j];
}

typedef struct Node {
    int number;
    bool done;
    int cost;
} Node;

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    for (int i = 0; i < 100; i++) scanf("%d", c + i);

    int costs[10] = {0};

    for (int j = 0; j < 10; j++) {
        if (j == 1) continue;
        Node nodes[10];
        for (int i = 0; i < 10; i++) {
            Node node = {.number = i, .done = false, .cost = -1};
            nodes[i] = node;
        }

        nodes[j].cost = 0;

        while (true) {
            Node doneNode = {.number = -1, .done = false, .cost = -1};
            for (int i = 0; i < 10; i++) {
                Node node = nodes[i];
                if (node.done || node.cost < 0) {
                    continue;
                }
                if (doneNode.number == -1 || node.cost < doneNode.cost) {
                    doneNode = node;
                }
            }
            if (doneNode.number == -1) {
                break;
            }
            nodes[doneNode.number].done = true;
            for (int i = 0; i < 10; i++) {
                if (doneNode.number == i) continue;
                int cost = doneNode.cost + length(doneNode.number, i);
                if (nodes[i].cost < 0 || cost < nodes[i].cost) {
                    nodes[i].cost = cost;
                }
            }
        }

        costs[j] = nodes[1].cost;
    }

    int ans = 0;
    for (int i = 0; i < h * w; i++) {
        int a;
        scanf("%d", &a);
        if (a != -1) ans += costs[a];
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 7496
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

class RollingHash{
    const ll mod = 1e9+7;
    const ll base = 1007;
    V<> hash, power;
public:
    RollingHash(const V<> &s){
        ll n = SZ(s);
        hash.assign(n+1, 0);
        power.assign(n+1, 1);
        REP(i,n){
            hash[i+1] = (hash[i] * base + s[i]) % mod;
            power[i+1] = (power[i] * base) % mod;
        }
    }
    inline ll get(ll l, ll r) const {
        ll res = hash[r] - hash[l] * power[r-l] % mod;
        if(res < 0) res += mod;
        return res;
    }
    inline ll s_hash(){return get(0, SZ(hash) - 1);}
    inline ll getLCP (ll a, ll b) const {
        ll len = min(SZ(hash)-a, SZ(hash)-b);
        ll ok = 0, ng = len;
        while(abs(ok-ng) > 1){
            ll mid = (ok+ng) / 2;
            if(get(a, a+mid) != get(b, b+mid)) ng = mid;
            else ok = mid;
        }
        return ok;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n; cin >> n;
    V<> a(n), b(n), c(n), d(n);
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> b[i];
    a.pb(a[0]);
    b.pb(b[0]);
    REP(i,n) c[i] = a[i] ^ a[i+1];
    REP(i,n) d[i] = b[i] ^ b[i+1];
    REP(i,n) c.pb(c[i]);
    RollingHash RH(c), p(d);
    ll z = p.s_hash();
    REP(i,n) if(RH.get(i, n + i) == z) cout << i << " " << (a[i] ^ b[0]) << endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst<<": "; dbg(rst...); }

//1000000000000001
int main()
{
	const double PI = acos(-1);
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, k;
	cin >>n;
	

	string res;
	while(n>0){
			int c= n%26;
			if(c==0){ res += 'z'; n--;}
			else res += char(c-1+'a');
			n /=26; 
	}
	reverse(all(res));
	cout <<res <<"\n";
	return 0;
}


Measured memory_bytes: 3652
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B = readline().decode('utf8').split()
print('>' if A > B else '=' if A == B else '<')


Measured memory_bytes: 3060
#include<iostream>
#include<string>

using namespace std;

int main(){

	string str;
	getline(cin,str);

	for(int i=0;i<(int)str.length();i++){
		if((str[i] >='A')&&(str[i] <= 'Z'))
			str[i] -= 'A'-'a';
		else if((str[i] >='a')&&(str[i] <= 'z'))
			str[i] += 'A'-'a';
	}
	cout << str << endl;

	return 0;
}



Measured memory_bytes: 3168
/*
 * FileName:     B
 * CreatedDate:  2020-04-26 21:05:19 +0900
 * LastModified: 2020-04-26 21:10:57 +0900
 */

#include <stdio.h>

int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int flag=0;
    for(int i=0;a>0||c>0;i++){
        if(i%2==0){
            c=c-b;
            flag=0;
        }
        else{
            a=a-d;
            flag=1;
        }
    }
    if(flag==0){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1660
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



// -----------------------------------------------------------------------

int arr[3000000];
void input(int n){
	for(int i=0;i<n;++i)
	cin>>arr[i];
}

// -----------------------------------------------------------------------



void solve(){
	
	int n,k;
	cin>>n>>k;
	int up=1;
	int rem=n-up;
	int ans=1;
	for(int i=0;i<up;++i)
	ans*=k;
	
	for(int i=0;i<rem;++i)
	ans*=(k-1);
		
	cout<<ans;
}


// -----------------------------------------------------------------------


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 256
from collections import deque
H, W = map(int,input().split())
grid = [list(input()) for _ in range(H)]
w_cnt = 0
for i in range(H):
    w_cnt += grid[i].count('.')


inf = float('inf')
d = [[inf]*W for _ in range(H)]
dx = [0,1,0,-1]
dy = [1,0,-1,0]


d[0][0] = 0
que = deque()
que.append([0,0])
while len(que) != 0:
    p = que.popleft()
    if p[0] == W-1 and p[1] == H-1:break
    for i in range(4):
        nx = p[0] + dx[i]
        ny = p[1] + dy[i]
        #print(nx,ny)
        if 0 <= nx <= W-1 and 0 <= ny <= H-1 and grid[ny][nx] == '.' and d[ny][nx] == inf:
            que.append([nx,ny])
            d[ny][nx] = d[p[1]][p[0]] + 1

# print(d)
# print(d[H-1][W-1])
if d[H-1][W-1] == inf:
    print(-1)
else:
    print(w_cnt-d[H-1][W-1]-1)


Measured memory_bytes: 3316
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a=Integer.parseInt(sc.next());
int b=Integer.parseInt(sc.next());
int c=Integer.parseInt(sc.next());
Set<Integer>s=new HashSet();
s.add(a);
s.add(b);
s.add(c);
System.out.println(s.size());

}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int a[110];
int main()
{
	int n,i,ans=0,x;
	scanf("%d",&n);
	for(i=1;i<=2*n;i++) scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	for(i=1;i<=2*n;i++) if(i&1) ans+=a[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>

namespace AtCoder {
	using Input = std::vector<std::string>;
	using Num = std::vector<int>;

	Input input(void) {
		Input result;
		{
			std::string buf = "", row = "";
			std::getline(std::cin, buf);
			for (unsigned int i = 0; i < buf.size(); i++) {
				if (' ' == buf[i]) {
					result.push_back(row);
					row = "";
				} else {
					row += buf[i];
				}
			}
			result.push_back(row);
		}
		return result;
	}

	Num replaceToInteger(Input original = { "" }) {
		Num result;
		for (unsigned int i = 0; i < original.size(); i++) {
			result.push_back(atoi(original[i].c_str()));
		}
		return result;
	}
}

int main(void) {

	AtCoder::Num s = AtCoder::replaceToInteger(AtCoder::input());

	int r = 0, d = 0, x = 0;

	r = s[0];
	d = s[1];
	x = s[2];

	for (int i = 1; i < 11; i++) {
		int ans = r * x - d;
		x = ans;
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int q = Integer.parseInt(br.readLine());
        int[] count_2017like = new int[500005];
        count_2017like[0] = 0;
        count_2017like[1] = 0;
        count_2017like[2] = 0;
        
        boolean prime = true;
        for (int i = 3; i <= 500000; i += 2) {
            for (int j = 2; j <= Math.sqrt(i); j++) {
                if (i % j == 0) {
                    prime = false;
                    break;
                }
            }
            if (prime) {
                for (int k = 2; k <= Math.sqrt((i+1)/2); k++) {
                    if ((i+1)/2 % k == 0) {
                        prime = false;
                        break;
                    }
                }
                if (prime) {
                    count_2017like[i] = count_2017like[i-2] + 1;
                }
            }
            if (!prime) {
                count_2017like[i] = count_2017like[i-2];
            }
            prime = true;
        }
        
        /*System.out.println(count_2017like[5]);
        System.out.println(count_2017like[7]);
        System.out.println(count_2017like[9]);
        System.out.println(count_2017like[11]);
        System.out.println("");*/
        
        for (int i = 0; i < q; i++) {
            String[] lr = br.readLine().split(" ");
            int l = Integer.parseInt(lr[0]);
            if (l < 2) l++;
            int r = Integer.parseInt(lr[1]);
            if (r < 2) r++;
            System.out.println(count_2017like[r]-count_2017like[l-2]);
            //System.out.println(count_2017like[3]);
        }
    }
}


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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD   = 1e9 + 7;
const double PI = acos(-1.0);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
const int INF   = 1e18;

#define fastio            ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define rsz resize
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define f first
#define s second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define spc " "
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){

    int n;
    cin >> n;
    vi a(n);
    rep(i, n){
        cin >> a[i];
    }
    int all = 0;
    rep(i, n){
        all ^= a[i];
    }

    rep(i, n){
        cout << (all ^ a[i]) << spc;
    }
    
}

signed main(){
    fastio;

    solve();

    return 0;
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e5+10;
ll a[maxn],s[maxn],c[maxn];
int main(){
	int n;
	cin>>n;
	for(int i=1,tmp;i<=n;i++) {
	  cin>>tmp;
	  c[tmp]++;
	}
	int tot=0;
	for(int i=1;i<=n;i++){
		if(c[i]!=0){
			a[++tot]=c[i];
		}
	}
	sort(a+1,a+tot+1);
	for(int i=1;i<=n;i++) s[i]=s[i-1]+a[i];
	for(int i=1;i<=n;i++){
	 ll l=0,r=n;
	 while(l<=r){
	 	ll mid=l+r>>1;
		ll pos=upper_bound(a+1,a+1+tot,mid)-a;
		pos--;
		if(s[pos]+(tot-pos)*mid<mid*i)
		 r=mid-1;
		else l=mid+1;
	}
	cout<<r<<'\n';
 }
}

Measured memory_bytes: 7808
#include <iostream>
#include <stack>
using namespace std;
stack<int> q;
string s;
int ans = 0;

int main(){
  cin >> s;
  int len = s.length();
  for (int i = 0; i < len; i++){
    if (q.empty()) q.push(s[i] - '0');
    else {
      int a = s[i] - '0';
      int v = q.top();
      if (!v == a) ans+=2, q.pop();
      else q.push(a);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
     
int main(void) {
 
int X,A,B;
   scanf("%d%d%d", &X, &A, &B);
 
   if(A-B >= 0){
      printf("delicious\n");
   }else if(B-A < X+1){
      printf("safe\n");
   }else {
      printf("dangerous\n");
   }
 
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#define MAX 500000
//#define INFINITY 200000000
using namespace std;

void merge(int[],int,int,int,int);
void mergeSort(int[],int,int,int);
//int n,S[MAX];
int L[MAX/2+2],R[MAX/2+2];
int cnt;

int main(){
  int i,n;
  cnt = 0;
  int A[MAX];
  cin >> n;
  //scanf("%d",&n);
  for(i = 0; i < n; i++){
    cin >> A[i];
    //scanf("%d",&A[i]);
    //mergeSort(S[i],0,i);
  }
  mergeSort(A,n,0,n);
  for(i = 0; i < n; i++){
    if(0 < i){
      cout << " ";
      //printf(" ");
    }
      cout << A[i];
      //printf("%d",A[i]);
  }
  cout << endl << cnt << endl; /**/
  //printf("\n%d\n",cnt);
  return 0;
}
void merge(int A[],int n,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  /*L[0...n1],R[0...n2]?????????*/
  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFINITY;
  R[n2] = INFINITY;
  //L[n1] = SMAX;
  //R[n2] = SMAX;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    cnt++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}
void mergeSort(int A[], int n, int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

Measured memory_bytes: 6900
#include <iostream>

using namespace std;

int main(){
    int N,X;
    int m[110];
    cin>>N>>X;
    int res = X;
    int min = 1000;
    for(int i=0;i<N;i++){
        cin>>m[i];
    }for(int i=0;i<N;i++){
        res = res-m[i];
        if(min > m[i]){
            min = m[i];
        }
    }
    int n = res/min;
    cout<<N+n<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

const int MOD = 1000000007;

signed main() {
    int N, M;
    cin >> N >> M;

    if(abs(N-M)>1) cout << 0 << endl;
    else {
        int res = 1;
        FOR(i, 1, N+1) {
            res *= i;
            res %= MOD;
        }
        FOR(i, 1, M+1) {
            res *= i;
            res %= MOD;
        }

        if(N==M) {
            res *= 2;
            res %= MOD;
        }

        cout << res << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#define ll long long
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if(n>m)
    {
        cout<<"safe"<<endl;
    }
    else
    {
        cout<<"unsafe"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3592
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())
Hs = list(mi())

ans = 0
#全てが0になるまで続ける
while 1:
  #全ての高さをチェックし、「0以外の区間」を探す
  nowinsection = 0 #一個前の高さが「0以外」なら1にしておく
  sectioncnt = 0 #0以上の区間を数える
  for i, h in enumerate(Hs):
    if h == 0:
      nowinsection = 0
    elif nowinsection == 0: #0から1以上に変わった瞬間
      nowinsection = 1
      sectioncnt += 1
      Hs[i] = h - 1 #ループを増やさないよう、ここで高さを減らしておく
    else: #1以上から1以上が引き続いた場合、区間は続くのでsectioncntは増やさない
      Hs[i] = h - 1 #ループを増やさないよう、ここで高さを減らしておく
  if sectioncnt == 0:
    print(ans)
    exit()
  else:
    ans += sectioncnt




Measured memory_bytes: 39920
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    vector<ll> sum(N + 1);
    rep(i, N) sum[i + 1] = sum[i] + a[i];

    vv<ll> dp = vvec(N, N, LINF);
    rep(i, N) dp[0][i] = 0;
    rep(l, 1, N) rep(i, N - l) {
        rep(j, l) dp[l][i] = min(dp[l][i], dp[j][i] + dp[l - j - 1][i + j + 1] + sum[i + l + 1] - sum[i]);
    }

    write(dp[N - 1][0]);
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }else{
        return false;
    }
}

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

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<lint> a(n);
    LLP maxi = {-IINF, -1}, mini = {IINF, -1};
    bool flag = true;
    rep(i, n){
        cin >> a[i];
        LLP tmp = {a[i], i};
        chmax(maxi, tmp);
        chmin(mini, tmp);
        flag &= a[i] >= 0LL;
    }

    vector< P > ans;
    if(maxi.first * mini.first < 0){
        if(abs(maxi.first) >= abs(mini.first)){
            rep(i, n){
                ans.push_back({maxi.second, i});
            }
            flag = true;
        }else{
            rep(i, n){
                ans.push_back({mini.second, i});
            }
            flag = false;
        }
    }

    if(flag){
        rep(i, n - 1){
            ans.push_back({i, i + 1});
        }
    }else{
        repr(i, n - 1){
            ans.push_back({i + 1, i});
        }
    }

    cout << ans.size() << endl;
    rep(i, ans.size()){
        cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
    }

    return 0;

}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    sort(all(h));
    if(k >= n) {
        cout << 0 << endl;
    } else {
        int sum = 0;
        rep(j, n - k) {
            sum += h[j];
        }
        cout << sum << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()

n = n%1000

ans = 1000-n

if ans==1000:
	ans = 0

print(ans)

Measured memory_bytes: 9452
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <tuple>
#include <functional>

using namespace std;

#define ll long long

ll a[200050] = {};
ll b[200050] = {};

int main() {
	ll n;
	ll no_1 = 0;
	ll no_2 = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}

	sort(b, b + n, greater<ll>());

	no_1 = b[0];
	no_2 = b[1];

	for (int i = 0; i < n; i++) {
		if (a[i] == no_1) {
			cout << no_2 << endl;
		}
		else {
			cout << no_1 << endl;
		}
	}
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);

#define debug(x) (#x " : " + to_string(x))
#define debug_cout(x) (cout << #x << " : " <<  to_string(x) << endl)
//#define debug_cout(x) ( )
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair((a), (b));
using namespace std;
using ll = long long;
//#define int long long
template<class T> bool chmax(T& a, T& b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T& b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 2e9;

/*****/


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

	bool isYes = false;

	int n1t, n5t, n10t;
	for (n10t = 0; n10t <= N && n10t * 10000 <= Y; n10t++)
	{
		for (n5t = 0; n5t + n10t <= N && n5t * 5000 + n10t * 10000 <= Y; n5t++)
		{
			n1t = N - (n5t + n10t);

			if (!isYes && n1t * 1000 + n5t * 5000 + n10t * 10000 == Y)
			{
				cout << n10t << " ";
				cout << n5t << " ";
				cout << n1t << endl;

				isYes = true;
			}
		}
	}

	if (!isYes)
	{
		cout << "-1 -1 -1" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,K = LI()

i = 0
while 1:
    if K**(i-1) <= N < K**i:
        print(i)
        exit()
    else:
        i += 1

Measured memory_bytes: 38256
#define w vector
#define z double
#define q int
#include<iostream>
#include<vector>
#include<algorithm>
#include<limits>
using namespace std;z inf=numeric_limits<z>::infinity();q main(){q n,m,r;cin>>n>>m>>r;w<w<z>>d=w<w<z>>(n,w<z>(n,inf));w<q>v;for(q i=0;i<r;i++){q l;cin>>l;v.push_back(l-1);}
sort(v.begin(),v.end());for(q i=0;i<m;i++){q a,b,c;cin>>a>>b>>c;d[a-1][b-1]=c;d[b-1][a-1]=c;}
for(q k=0;k<n;k++)for(q i=0;i<n;i++)for(q j=0;j<n;j++){d[i][j]=min(d[i][j],d[i][k]+d[k][j]);}
long min_dist=1e9;do{long dist=0;for(q i=0;i<v.size()-1;i++){dist+=d[v[i]][v[i+1]];}min_dist=min(min_dist,dist);}while(next_permutation(v.begin(),v.end()));cout<<min_dist<<endl;}


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

int main()
{
	string s;
	cin >> s;
	if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
	
}



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

int main(){
  int n;
  set<string> s;

  cin >> n;
  for(int i=0;i<n;i++){
    string tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 19200
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
X = [int(v) for v in input().split()]
lx = len(X)

# N=10^5, M=10^5ならO(NM)は間に合わない

if N >= M:
    print(0)
else:
    # 動的計画法M個の地点を1~N個のコマで回ることを考える。

    X.sort()    # 昇順にソート
    coma = [0] * N
    # n=1
    diff = [x2-x1 for x2, x1 in zip(X[1:], X[:-1])]
    diff.sort() # 昇順にソート
    coma[0] = sum(diff)

    # n >= 2
    for i in range(1, N):
        coma[i] = coma[i-1] - diff[-1]
        del diff[-1]

    print(coma[-1])


Measured memory_bytes: 13196
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 4 * 1e18;

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

    vector<long long int> x(n), y(n);
    vector<pair<long long int, long long int>> point(n);
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i];
        point[i] = make_pair(x[i],y[i]);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    long long int ans = INF;
    for(int i=0; i<n; i++){// left
        for(int j=i+1; j<n; j++){// right
            for(int l=0; l<n; l++){// lower
                for(int m=l+1; m<n; m++){// upper
                    int count = 0;
                    for(int p=0; p<n; p++){// points
                        if(x[i] <= point[p].first  && point[p].first  <= x[j]
                        && y[l] <= point[p].second && point[p].second <= y[m]){
                            count += 1;
                        }
                    }
                    if(count == k) ans = min(ans, (x[i] - x[j]) * (y[l] - y[m]));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python
# coding: utf-8
# 

from itertools import *
import sys


#################### library ####################


#################### naive ####################


#################### process ####################

def read_input():
	[N, M] = map(int, raw_input().split())
	v = []
	for k in range(M):
		a, b = map(int, raw_input().split())
		cs = [ int(e) for e in raw_input().split() ]
		flag = reduce(lambda x, y: x | (1 << (y-1)), cs, 0)
		v.append((a, flag))
	return (N, v)

def proc():
	N, v = read_input()
	
	L = 1 << N
	memo = [10**9] * L
	memo[0] = 0
	for n in range(L-1):
		for a, flag in v:
			n1 = n|flag
			memo[n1] = min(memo[n1], memo[n] + a)
	
	if memo[L-1] == 10**9:
		return -1
	else:
		return memo[L-1]


#################### main ####################

print proc()


Measured memory_bytes: 33768
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>

using namespace std;

int main() {
	string s; cin >> s;
	for (int i = 0; i < s.size() - 8; i++) {
		cout << s[i];
	}
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc142/tasks/abc142_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N,K; cin>>N>>K;
    vector<ll> hn(N);
    ll ans=0;
    for(auto&&h:hn){
        cin>>h;
        if(h>=K)++ans;
    }
    cout<<ans<<endl;    
    return 0;
}

Measured memory_bytes: 1024
/*******************­************\
 Name: MD ASHRAFUZZAMAN KHAN |
 School: COMILLA UNIVERSITY |
 CSE (5TH BATCH) |
 ********************­************/

#include <bits/stdc++.h>

#define ll long long int
#define inf 1<<30
#define Pi 2*acos(0,0)
#define pi acos(-1)
#define PI 3.1415926535897932384626433832795
#define mem(x,y) memset(x,y,sizeof(x))
#define pf printf
#define sf scanf
#define MAX 50

///template < class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template < class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T ncr(T n,T r){return n*(n-1)/r;}

using namespace std;


int main()
{

   ios_base::sync_with_stdio(0);

    string s;
    cin>>s;
    cout<<"2018";
    for(int i=4;i<s.length();i++)
        cout<<s[i];
   ///cin.get(); cin.get();
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    int ans=2*n;
    for(int i=0;i<n;i++)
    {
        int e=0;
        for(int u=i;u<n&&e==0;u++)
        {
            if(s[u]!=t[u-i])e=1;
        }
        if(e==0){ans=i+n;break;}
    }
    cout<<ans<<endl;




}


Measured memory_bytes: 256
# AGC 013 A - Sorted Arrays

n = int(input())
a = list(map(int, input().split()))
up, down = 0, 0
ans = 0

for i in range(1, n):
    if a[i] > a[i-1]:
        up += 1
    if a[i-1] > a[i]:
        down += 1
    if up * down > 0:
        ans += 1
        up = 0
        down = 0
print(ans + 1)

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N, C, K;
    cin >> N >> C >> K;

    vector<int> T;
    for (int i = 0; i < N; i++) {
        int Ti;
        cin >> Ti;
        T.push_back(Ti);
    }
    sort(T.begin(), T.end());

    int bus = 1;
    int c = 0;
    int tmpTi;
    for (int i = 0; i < N; i++) {
        if (c == 0) {
            tmpTi = T[i];
            c++;
        }
        else if (c < C && T[i] <= tmpTi + K) {
            c++;
        }
        else if (c >= C || T[i] > tmpTi + K) {
            c = 1;
            tmpTi = T[i];
            bus++;
        }
    }
  
    cout << bus << endl;
  
    return 0;
}

Measured memory_bytes: 892
import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	void run() {
		MyScanner sc = new MyScanner();

		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int ans = 0;
			for (int i = 0; i < 200; i++) {
				if (n < i*i) break;
				for (int j = i; j < 200; j++) {
					if (n < i*i + j*j) break;
					for (int k = j; k < 200; k++) {
						if (n < i*i + j*j + k*k) break;
						for (int l = k; l < 200; l++) {
							if (n < i*i + j*j + k*k + l*l) break;
							if (i*i + j*j + k*k + l*l == n) {
								ans++;
							}
						}
					}
				}
			}

			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

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

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

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

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}

}

Measured memory_bytes: 18988
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n,k; cin>>n>>k;
	VL h(n);
	rep(i,n) cin>>h[i]; sort(ALL(h));
	ll ans = 0;
	rep(i,n-k) ans+=h[i];
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


struct UnionFind {
	VI par;
	UnionFind(int N) :par(N) {
		REP(i, N)par[i] = i;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	int A, B, C; cin >> A >> B >> C;
	int i = 1;
	while (i < 1000000) {
		if (A*i%B == C) {
			cout << "YES" << endl;
			return 0;
		}
		i++;
	}
	cout << "NO" << endl;
	return 0;
}



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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

int main()
{
	char S[200001];
	char T[200001];

	cin >> S;
	cin >> T;

	vector<char> RS(26), RT(26);

	fill(ALL(RS), -1);
	fill(ALL(RT), -1);

	int N = strlen(S);

	FOR(i, 0, N){
		char s = S[i] - 'a';
		char t = T[i] - 'a';

		if(RS[s] < 0){
			RS[s] = t;
		}
		else{
			if(RS[s] != t){
				cout << "No" << endl;
				return 0;
			}
		}

		if(RT[t] < 0){
			RT[t] = s;
		}
		else{
			if(RT[t] != s){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(int argc, char const* argv[]) {
    int N;
    cin >> N;
    uint32_t ma = 0;
    uint32_t mi = 1000000001;
    for (int i = 0; i < N; ++i) {
        int temp;
        cin >> temp;
        if (temp < mi) {
            mi = temp;
        }
        if (temp > ma) {
            ma = temp;
        }
    }
    cout << ma - mi << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(void){
	int n,k,i,j;
	
	scanf("%d %d",&n,&k);

	unsigned long h[n],sum=0,temp;

	for(i=0;i<n;i++){
		scanf("%lu",&h[i]);
	}

	qsort(h,n,sizeof(unsigned long),compare_int);

	if(n>k){
		for(i=0;i<n-k;i++){
			sum+=h[i];
		}
	}

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

	return 0;
}

Measured memory_bytes: 3324
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();
        Stack<Character> characters = new Stack<>();

        for (int i = 0; i < word.length(); i++) {
            if (word.charAt(i) == 'B' && !characters.isEmpty()){
                characters.pop();
            }else if (word.charAt(i) == '1' || word.charAt(i) == '0'){

                characters.push(word.charAt(i));
            }
        }

        StringBuilder out = new StringBuilder();

        for (int i = 0; i < characters.size(); i++) {
            out.append(characters.get(i));
        }

        System.out.println(out);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int n;
  db x,ans=0;
  string s;
  cin>>n;
  fr(i,n){
    cin>>x>>s;
    if(s=="BTC") x*=380000;
    ans+=x;
  }
  printf("%.12f\n",ans);
}

Measured memory_bytes: 256
n = int(input())
k = int(input())

x = list(map(int, input().split()))
sum = 0

for i in range(n):
    if(x[i] - 0 <= abs(k - x[i])):
        sum += 2 * x[i]
    else:
        sum += 2 * abs(k-x[i])

print(sum)

Measured memory_bytes: 3060