akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        int[] num = new int[i];
        for(int j=0;j<i;j++){
            num[j]=sc.nextInt();
        }
        int cnt=0;
        for(int l=0;l<i-1;l++){
            int minj=l;
            for(int m=l+1;m<i;m++){
                if(num[m]<num[minj]){
                    minj=m;
                }
            }
            if(l!=minj){
                int t=num[l];
                num[l]=num[minj];
                num[minj]=t;
                cnt++;
            }
        }

        for(int k=0;k<i-1;k++){
            System.out.printf("%d ",num[k]);
        }
        System.out.printf("%d\n%d\n",num[i-1],cnt);
        sc.close();
    }
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

bool islike(char c, vector<int>&d){
    int n = c-'0';
    for(int a:d){
        if(a==n)return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;

    vector<int> d(k);
    REP(i,k)cin >> d[i];


    while(1){
        bool flg=true;
        string s = to_string(n);
        for(char c:s){
            if(!islike(c,d)){
                flg=false;
                break;
            }
        }
        if(flg){
            cout << n << endl;
            break;
        }
        n++;
    }

}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  int64 N, Q;
  while (cin >> N >> Q && N+Q) {
    vector<string> era(N);
    vector<int64> ey(N), wy(N);
    REP(i, N) {
      cin >> era[i] >> ey[i] >> wy[i];
    }
    REP(i, Q) {
      int64 y;
      cin >> y;
      bool ok = 0;
      REP(j, N) {
        if (wy[j] < y) continue;
        if (wy[j] - ey[j] < y) {
          cout << era[j] << " " << ey[j] - abs(y-wy[j]) << endl;
          ok = 1;
          break;
        }
      }
      if (!ok) {
        cout << "Unknown" << endl;
      }
    }
  }
}



Measured memory_bytes: 3228
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

void print(vector<int> v) {
    for (int i=0; i<(int)v.size(); ++i) {
        cout << (i==0 ? "" : " ") << v[i];
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; ++i) {
        cin >> A[i];
    }

    int ans = 0;
    for (int i=0; i<N; ++i) {
        for (int j=N-1; j>i; --j) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                ans ++;
            }
        }
    }

    print(A);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
vector<string> ans;
char str[25];
//int V[100005];
void small(int i, int j, int k) {
	sprintf(str, "< %d %d %d", i, j, k);
//	V[k] = V[i] < V[j];
	ans.push_back(str);
}
void plu(int i, int j, int k) {
	sprintf(str, "+ %d %d %d", i, j, k);
//	V[k] = V[i] + V[j];
	ans.push_back(str);
}
int main() {
//	V[0] = 5;
//	V[1] = 5;
	plu(0, 1, 3);
	small(4, 3, 4);
	const int ONE = 4;
	auto getBinary = [&](int v, int X) {
		plu(v, ONE, X - 3);
		for (int i = 29; i >= 0; --i) {
			plu(X - 1, X - 1, X - 1);
			plu(X - 1, ONE, X - 2);
			for (int j = 0; j < i; ++j) {
				plu(X - 2, X - 2, X - 2);
			}
//			db3(i, V[X - 1], V[X - 2]);
			small(X - 2, X - 3, X + i);
			plu(X - 1, X + i, X - 1);
		}
	};
	int AB = 100, BB = 200, Z = 300;
	getBinary(0, AB);
	getBinary(1, BB);
	for (int i = 58; i >= 0; --i) {
		plu(2, 2, 2);
		for (int j = 0; j <= 29; ++j) {
			int k = i - j;
			if (k < 0 || k > 29) continue;
			plu(AB + j, BB + k, Z);
			small(ONE, Z, Z + 1);
			plu(Z + 1, 2, 2);
		}
	}
	printf("%d\n", ans.size());
	for (auto& a : ans) printf("%s\n", a.c_str());
}


Measured memory_bytes: 3824
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n, l = getList()
#
# if l >= 0:
#     ans = sum([l + i for i in range(1,n)])
#
# elif l >= -(n+1):
#     ans = sum([l+i for i in range(n)])
#
# else:
#     ans = sum([l+i for i in range(n-1)])
#
# print(ans)

aji = [l + i for i in range(n)]
if 0 in aji:
    print(sum(aji))

elif min(aji) > 0:
    print(sum(aji[1:]))

else:
    print(sum(aji[:-1]))


Measured memory_bytes: 38384
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    map<int, ll> z;
    int i;
    for(i=0; i<n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        z[b]+=a;
    }

    ll sum=0;
    auto it=z.begin();
    for(; it!=z.end(); ++it) {
        sum += it->second;
        if(sum>it->first) {
            printf("No\n"); return 0;
        }
    }
    printf("Yes\n");

    return 0;
}


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


int main(){


int n,m;
cin >> n >> m ;
int r[m];
int l[m];

for(int i=0;i<m;i++){
  cin >> l[i] >> r[i];
}

int maxl = 1;
int minr = n;

rep(i,m){
maxl = max(maxl,l[i]);
minr = min(minr,r[i]);
}


int ans = minr-maxl +1;
ans = max(ans,0);

if(ans<0) cout << 0 << endl;
else cout << ans << endl;

return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }

    return 0;
}

Measured memory_bytes: 256
while True:
    h, w = map(int,input().split())
    if h == 0 and w == 0:
        break
    square = [['#' for i in range(w)] for j in range(h)]
    for i in range(1, h - 1):
        for j in range(1, w - 1):
            square[i][j] = '.'
    [print(''.join(i)) for i in square]
    print('')




Measured memory_bytes: 5868
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k, t = map(int, input().split())
    A = list(map(int, input().split()))
    B = []
    for i in range(t):
        B.append([i + 1, A[i]])
    B = sorted(B, key=lambda x: x[1])

    if t == 1:
        print(k - 1)
        exit()

    res = 0
    pre = 0
    for i in range(k):
        if pre != B[-1][0]:
            pre = B[-1][0]
            B[-1][1] -= 1
            B = sorted(B, key=lambda x: x[1])
        else:
            if B[-2][1] != 0:
                pre = B[-2][0]
                B[-2][1] -= 1
                B = sorted(B, key=lambda x: x[1])
            else:
                B[-1][1] -= 1
                res += 1

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 41068
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for t in range(n):
    if h[t] >= 1:
        break
for cx, cy in itertools.product(range(101), range(101)):
    H = h[t] + abs(x[t] - cx) + abs(y[t] - cy)
    if H < 1:
        continue
    for i in range(n + 1):
        if i == n:
            break
        if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
            break
    if i == n:
        break
print("{} {} {}".format(cx, cy, H))


Measured memory_bytes: 3064
def main():
    N = int(input())
    S = input()

    B = [0]
    cnt = 0
    for s in S:
        if s == '#':
            cnt += 1
        B.append(cnt)

    W = [0]
    cnt = 0
    for s in reversed(S):
        if s == '.':
            cnt += 1
        W.append(cnt)
    W.reverse()

    min = 10 ** 9
    for w, b in zip(W, B):
        if w+b < min:
            min = w+b
    print(min)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12696
N = int(input())
import math
def is_prime(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False

    # 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    num_sqrt = math.sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step

    return True
  
def make_prime_list(num):
    if num < 2:
        return []

    prime_list = []
    for prime in range(2, num + 1):
        if is_prime(prime):
            prime_list.append(prime)
    return prime_list
  
num = N
prime_list = make_prime_list(num)
pcount={}
for p in prime_list:
    pcount[p]=0
for nn in range(2,num+1):
    for p in prime_list:
        n=nn
        if n<p:
            break
        while n%p==0:
            n//=p
            pcount[p]+=1
            
ans = 1
for i in pcount.values():
    ans *= (i + 1)
print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
using ll = long long;

int main() {
	ll h, w;
	cin >> h >> w;
	
	if (h == 1 || w == 1) cout << "1\n";
	else cout << (h * w + 1) / 2 << '\n';
	
	return 0;
}

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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ld long double
const int MxN = 200001 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)
const int MOD = 1e9 + 7 ; 

/* VARIABLES */
int k ;  
/* END OF VARIABLES */



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

	cin >> k ; 
	if(k % 2 == 0) {
		cout << -1 ;
		return 0 ; 
	}
	bool ok1 = false , ok2 = false ;
	if(k % 7 == 0) 
		ok1 = true ;  
	int powof10 = 1 ; 
	int n = 1e6 ; 
	int r = 0 ; 
	FOR(i,1,n) {
		r += (7 * powof10 ) % k ;
		//cout << r  << " " << powof10 << endl ;
		r = r % k ;  
		if(r == 0 ) {
			cout << i ;
			return 0 ;  
		}
		powof10 = (powof10 * 10) % k ; 

	}

	cout << "-1" ; 
	return 0 ; 
}



Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	S := nextLine()
	fmt.Println(S[0:3])
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1792
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;
const int MAXQ=200000;

typedef struct Seg {
	ll glob; char c; int n;
	void inc(ll x) {
		glob+=x;
		//printf("%c: inc(%lld)\n",c,x);
	}

	ll sval[4*MAXN];
	void init(int x,int l,int r) {
		if(l==r) { sval[x]=LLONG_MAX; return; }
		int m=l+(r-l)/2;
		init(2*x+1,l,m); init(2*x+2,m+1,r);
		sval[x]=min(sval[2*x+1],sval[2*x+2]);
	}
	void init(char _c,int _n) { c=_c,n=_n; glob=0; init(0,0,n-1); }
	ll get(int x,int l,int r,int L,int R) {
		if(L<=l&&r<=R) return sval[x]==LLONG_MAX?LLONG_MAX:sval[x]+glob;
		int m=l+(r-l)/2;
		ll ret=LLONG_MAX;
		if(L<=m) ret=min(ret,get(2*x+1,l,m,L,R));
		if(m+1<=R) ret=min(ret,get(2*x+2,m+1,r,L,R));
		return ret;
	}
	ll get(int L,int R) {
		ll ret=get(0,0,n-1,L,R);
		//printf("%c: get(%d,%d)=%lld\n",c,L,R,ret);
		return ret;
	}
	void set(int x,int l,int r,int IDX,ll VAL) {
		if(l==r) { sval[x]=min(sval[x],VAL-glob); return; }
		int m=l+(r-l)/2;
		if(IDX<=m) set(2*x+1,l,m,IDX,VAL); else set(2*x+2,m+1,r,IDX,VAL);
		sval[x]=min(sval[2*x+1],sval[2*x+2]);
	}
	void set(int IDX,ll VAL) {
		//printf("%c: set(%d,%lld)\n",c,IDX,VAL);
		set(0,0,n-1,IDX,VAL);
	}
} Seg;


Seg z; // z[i]=minimal cost to get one piece on position i and the other on the previous position
Seg p; // p[i]=minimal cost (to get one piece on position i and the other on the previous position) + i
Seg m; // m[i]=minimal cost (to get one piece on position i and the other on the previous position) - i

int n,nq,A,B;
int x[MAXQ];

void run() {
	scanf("%d%d%d%d",&n,&nq,&A,&B); --A,--B;
	REP(i,nq) scanf("%d",&x[i]),--x[i];

	p.init('P',n); m.init('M',n); z.init('Z',n);
	p.set(A,abs(x[0]-B)+A); m.set(A,abs(x[0]-B)-A); z.set(A,abs(x[0]-B));
	p.set(B,abs(x[0]-A)+B); m.set(B,abs(x[0]-A)-B); z.set(B,abs(x[0]-A));
	FOR(i,1,nq) {
		ll pcost=p.get(x[i],n-1),mcost=m.get(0,x[i]); if(pcost!=LLONG_MAX) pcost-=x[i]; if(mcost!=LLONG_MAX) mcost+=x[i];
		//printf("%d: pcost=%lld mcost=%lld\n",x[i],pcost,mcost);
		ll changecost=min(pcost,mcost);
		ll dx=abs(x[i]-x[i-1]);
		p.inc(dx); m.inc(dx); z.inc(dx);
		p.set(x[i-1],changecost+x[i-1]); m.set(x[i-1],changecost-x[i-1]); z.set(x[i-1],changecost);
	}
	ll ret=z.get(0,n-1);
	printf("%lld\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    vector<pair<long long, long long> >prime_list = prime_factorize(N);
    int count = 0;
    int ps = prime_list.size();
    for (int i=0; i < ps; i++) {
        pair<long long, long long> w = prime_list[i];
        long long num = w.first;
        long long ex = w.second;
        int minus_count = 1;
        while (ex >= 1) {
            ex = ex - minus_count;
            if (ex >= 0) {
                count += 1;
                minus_count += 1;
            }
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3632
/**
 *    author:  morato
 *    created: 13.09.2020 10:01:15
**/
#include <bits/stdc++.h>

using namespace std;

int mhn(pair<int, int> a, pair<int, int> b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for (auto& x : v)
    cin >> x.first >> x.second;
  vector<int> mark(n);
  int id1 = 0, id2 = 0;
  int maior = -2e9;
  for (int i = 0; i < n; i++) {
    if (v[i].first + v[i].second > maior) {
      maior = v[i].first + v[i].second;
      id1 = i;
    }
  }
  int menor = 2e9;
  for (int i = 0; i < n; i++) {
    if (v[i].first + v[i].second < menor) {
      menor = v[i].first + v[i].second;
      id2 = i;
    }
  }
  int id3 = 0, id4 = 0;
  maior = -2e9;
  for (int i = 0; i < n; i++) {
    if (v[i].first - v[i].second > maior) {
      maior = v[i].first - v[i].second;
      id3 = i;
    }
  }
  menor = 2e9;
  for (int i = 0; i < n; i++) {
    if (v[i].first - v[i].second < menor) {
      menor = v[i].first - v[i].second;
      id4 = i;
    }
  }
  cout << max(mhn(v[id1], v[id2]), mhn(v[id3], v[id4])) << '\n';
  return 0;
}

Measured memory_bytes: 5552
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

    int a;
    cin >> a;
    int ara[a];
    for(int i = 0 ; i < a; i++){
        cin >> ara[i];
    }
    sort(ara,ara+a);
    cout << ara[a-1] - ara[0] << endl;


    return 0;
}


Measured memory_bytes: 3560
#include<iostream>
using namespace std ;
#define ll long long int
#include<vector>
#include<algorithm>

int main()
{

    ll n ; cin>> n ;
    vector<ll>arr(n)  ;


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

      sort(arr.rbegin() , arr.rend() )  ;
        vector<ll>values(n) ;

        for(ll i=0;i<n;i++)
        {

        if(i==0)
            values[i ] = 1 ;
        else
            values[i] = 2 ;


        }

        n--  ;
        ll ans =0 ;
        ll itr = 0 ;
        while(n)
        {

            if(values[itr]==0)
            {

                itr++ ;
                continue  ;
            }

            ans+=  arr[itr] ;
            values[itr]-- ;

            n-- ;
        }

        cout<<ans<<endl ;


}


Measured memory_bytes: 6428
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
#include<iostream>
#include<vector>
#include<cmath>
using namespace __gnu_pbds;
using namespace std;
typedef  tree<int, null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
  PBDS;
int main()
{  int n ;
 cin>>n;
  vector<int> height(n+1);
    for(int a=1;a<=n;a++)
    { cin>>height[a];
	}
   vector<long long int > dp(n+1,0);
     dp[1]=0;
       dp[2]=abs(height[2]-height[1]);
        if(n<=2)
         { cout<<dp[n]<<endl;
		 }
		 else
		 { for(int a=3;a<=n;a++)
		    {  int take = min(dp[a-2]+abs(height[a]-height[a-2]),dp[a-1]+abs(height[a]-height[a-1]));
		      dp[a]= take;
			}
			  cout<<dp[n]<<endl;
		 }
return 0;
}


Measured memory_bytes: 1536
#include <cmath>
#include <iostream>

#define ull unsigned long long

using namespace std;

long long n , a , b;

int main(){
	cin >> n >> a >> b;
	if(a % 2 == b % 2)
		cout << (b - a) / 2 << endl;
	else
		cout << min((ull)(n * 2 - a - b + 1) , (ull)(a + b - 1)) / 2 << endl;
	return 0;
}

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

int main(void){
  string S;
  cin >> S;
  if(S.length() % 2 != 0){
    cout << "No";
    return 0;
  }
  else{
    int i = 0;
    while( i < S.length()){
      if(S[i] == 'h' && S[i + 1] == 'i'){
        i += 2;
      }
      else{
        cout << "No";
        return 0;
      }
    }
    cout << "Yes";
  }
  
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    string s, t;
    cin >> s >> t;

    vector<char > ss;
    vector<char > tt;

    for(ll i = 0; i < s.length(); i++){
        ss.push_back(s[i]);
    }
    sort(ss.begin(), ss.end());

    for(ll i = 0; i < t.length(); i++){
        tt.push_back(t[i]);
    }
    sort(tt.rbegin(), tt.rend());

    string tmp1;
    string tmp2;

    for(ll i = 0; i < s.length(); i++){
        tmp1 += ss[i];
    }

    for(ll i = 0; i < t.length(); i++){
        tmp2 += tt[i];
    }  

    //cout << tmp1 << " " << tmp2 << endl;

    if(tmp1 < tmp2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(mod[0]==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    if 2019<=mod[1]-mod[0]:
        answer = 0
        break
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
    if count == 2018:
        break
    count = count + 1
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long llo;
#define a first
#define  b second
#define endl "\n"
vector<llo> adj[100001];
llo col[100001];
llo inf;
llo par[1000000];
pair<llo,llo> ran[100001];
void dfs(llo no,llo parr=-1,llo l=-1,llo r=-1){
	if(col[no]!=-1){
		l=col[no];
		r=col[no];
	}
	ran[no]=mp(l,r);
	par[no]=parr;
	for(auto j:adj[no]){
		if(j==parr){
			continue;
		}
		dfs(j,no,l-1,r+1);
	}
//	cout<<no<<" "<<ran[no].a<<" "<<ran[no].b<<endl;
}
pair<llo,llo> dfs2(llo no,llo parr){
	llo l,r;
	if(col[no]==-1){
		l=-inf;
		r=inf;
	}
	
	else{
		l=col[no];
		r=col[no];
	}
	//cout<<no<<" "<<l<<" "<<r<<endl;
	for(auto j:adj[no]){
		if(j==parr){
			continue;
		}
		pair<llo,llo> xx=dfs2(j,no);
	//	cout<<l<<"/"<<r<<endl;
		l=max(l,xx.a-1);
		r=min(r,xx.b+1);
	//	cout<<l<<"/"<<r<<endl;
	//	cout<<xx.a-1<<":"<<xx.b+1<<":"<<no<<endl;
	}

	
	ran[no].a=max(ran[no].a,l);
	ran[no].b=min(ran[no].b,r);
	if(col[no]>-1){
		ran[no].a=max(ran[no].a,col[no]);
		ran[no].b=min(ran[no].b,col[no]);
	}
//	cout<<no<<" "<<ran[no].a<<" "<<ran[no].b<<endl;
	return ran[no];
}
void dfs3(llo no,llo parr,llo co){
	if(col[no]==-1){
		col[no]=co;
	}
	else{
		co=col[no];
	}
	for(auto j:adj[no]){
		if(j==parr){
			continue;
		}
		
		if(co+1<=ran[j].b and co+1>=ran[j].a){
			dfs3(j,no,co+1);
		}
		else{
			dfs3(j,no,co-1);
		}

	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	inf=1000000;
	llo n,k;
	cin>>n;
	llo aa,bb;
	memset(col,-1,sizeof(col));
	for(llo i=0;i<n-1;i++){
		cin>>aa>>bb;
		adj[aa-1].pb(bb-1);
		adj[bb-1].pb(aa-1);
	}

	cin>>k;
	llo st;
	for(llo i=0;i<k;i++){
		cin>>aa>>bb;
		st=aa;
		col[aa-1]=bb;
	}
	aa-=1;
//	cout<<aa<<endl;
	dfs(aa);
	dfs2(aa,-1);
	llo ss=1;
	for(llo i=0;i<n;i++){
		if(ran[i].a>ran[i].b){
			ss=0;

		}
	}	
	if(ss==0){
		cout<<"No"<<endl;
	}
	else{
		//cout<<"Yes"<<endl;
		dfs3(aa,-1,col[aa]);
		for(int i=0;i<n;i++){
			if(abs(col[par[i]]-col[i])!=1 and par[i]!=-1){
				ss=0;
			}
		}
		if(ss==0){
			cout<<"No"<<endl;
			return 0;
		}
		cout<<"Yes"<<endl;
		for(llo i=0;i<n;i++){
			cout<<col[i]<<endl;
		}

	}















	return 0;
}

Measured memory_bytes: 20224
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

int main(){
    int N;
    int sum = 0;
    scanf("%d", &N);

    int p[N];

    for(int i=0; i<N; i++){
        scanf("%d", &p[i]);
    }

    sort(p, p+N, greater<int>());

    p[0] = p[0]/2;

    for(int j=0; j<N; j++){
        sum += p[j];
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> b(m);

	REP(i, m){
		int tmp;
		cin >> tmp;
		cin >> tmp;
		b[i] = tmp;
	}

	sort(ALL(b));
	
	int ans = 0;
	int count = 0;
	for (auto x : b){
		if (count == m-1) break;
		count++;
		if (x <= n) continue;
		ans += (x - n);
	}

	cout << ans << endl;
}



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

n, q = map(int, input().split())
g = [list() for i in range(n)]
node = [0] * n

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p, x = map(int, input().split())
    node[p-1] += x

def dfs(v, p=-1):
    for u in g[v]:
        if u == p: continue
        node[u] += node[v]
        dfs(u, v)

dfs(0)
print(*node)


Measured memory_bytes: 268464
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int h = S/3600;
        int m = (S-(h*3600))/60;
        int s = S%60;
        System.out.println( h + ":" + m + ":" + s);
    }
}


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

void bubbleSort(int a[],int n) {
	int l = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				int temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
				l++;
			}
		}
	}
	
	for (int k = 0; k < n - 1; k++)
		cout << a[k] << " ";
	cout << a[n - 1] << endl;
	cout << l<<endl;
}
int main()
{
	int n;
	int a[200];
	while (cin >> n)
	{
		for (int i = 0; i < n; i++)
			cin >> a[i];
		bubbleSort(a, n);
	}
	
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int imos[100010] = {};
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        ++imos[a];
        --imos[b + 1];
    }
    int ans;
    int a = 0;
    for (int i = 0; i < 100010; ++i) {
        a += imos[i];
        if (a + 1 >= i) {
            ans = i - 1;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const ll MAX = 1e9;

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

  int b = count(s.begin(), s.end(), '#');
  int w = count(s.begin(), s.end(), '.');
  int ans = min(b, w);

  int lb = 0, lw = 0;
  rep(i, n) {
    if (s[i] == '.')
      lw++;
    else
      lb++;
    ans = min(ans, lb + w - lw);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3732
//package com.company;

import java.io.*;
import java.util.*;

//public class BeautifulStrings {
    public class Main {
    public static void main(String[] args) {

        out = new PrintWriter(new BufferedOutputStream(System.out));
        MyScanner sc = new MyScanner();//start
        Map<Character, Integer>map=new HashMap<>();
        String string= sc.nextLine();
        for (int i = 0; i <string.length() ; i++) {
            if(!map.containsKey(string.charAt(i))){
                map.put(string.charAt(i),1);
            }else {
                map.put(string.charAt(i),map.get(string.charAt(i))+1);
            }
        }
        for(var i: map.entrySet()){
            if(i.getValue()%2!=0){
                out.println("No");
                out.close();
                return;
            }
        }
        out.println("Yes");
        out.close();
    }


    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    }
//--------------------------------------------------------

}


Measured memory_bytes: 32860
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
	int n,k,q,t;
	cin>>n>>k>>q;
	memset(a,0,sizeof(a));
	for(int i=0;i<q;i++){
		cin>>t;
		a[t]++;
	}
	for(int i=1;i<=n;i++){
		if(q-a[i]>=k) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def solve():
    n = getN()
    ans = 0
    for i in range(1, n+1):
        ans += (n-1) // i

    print(ans)
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 76916
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long 
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

class UnionFind
{
private:
    vector<ll> data;
    vector<ll> tree_size;

public:
    UnionFind(ll n)
    {
        data = vector<ll>(n);
        tree_size = vector<ll>(n, 1);
        for (ll i = 0; i < n; ++i)
        {
            data[i] = i;
        }
    }

    ll root(ll a)
    {
        if (data[a] == a) return a;
        else return data[a] = root(data[a]);
    }

    void unite(ll a, ll b)
    {
        ll root_a = root(a);
        ll root_b = root(b);
        if (root_a == root_b)
            return;
        else
        {
            tree_size[root_b] += tree_size[root_a];
            tree_size[root_a] = 0;
            data[root_a] = root_b;
            return;
        }
        return;
    }
    ll get_tree_size(ll a)
    {
        return tree_size[root(a)];
    }
};

int main()
{
	std::ios::sync_with_stdio(false);
	ll N, M;
    cin >> N >> M;
    vll A(M), B(M);
    UnionFind uf = UnionFind(N);
    for(size_t i=0;i<M; i++)
    {
        cin >> A[i] >> B[i];
        uf.unite(A[i]-1, B[i]-1);
    }
    ll max_size=0;
    for(size_t i=0;i<N; i++)
    {
        max_size = max(max_size, (uf.get_tree_size(i)));
    }
    cout << max_size << endl;
	return 0;
}


Measured memory_bytes: 15584
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int n;

        n = Int32.Parse(Console.ReadLine());
        string[] inputValues = Console.ReadLine().Split(' ');
        Dictionary<int, int> order = new Dictionary<int, int>();

        for (int i = 0; i < n; i++)
        {
            order.Add(Int32.Parse(inputValues[i]), i + 1);
        }

        for (int i = 0; i < n; i++)
        {
            Console.Write(order[i + 1]);
            if (i < n - 1)
                Console.Write(" ");
        }
    }
}




Measured memory_bytes: 29276
#include<iostream>
#include <cstdio>
using namespace std;
 
int main(){
    int n, b[10000], f[10000], r[10000], v[10000];
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> b[i] >> f[i] >> r[i] >> v[i];
    }
 
    for (int building = 1; building <= 4; building++){
        for (int floor = 1; floor <= 3; floor++){
            for (int room = 1; room <= 10; room++){
                int t = 0;
                for (int i = 0; i < n; i++){
                    if (b[i] == building&&f[i] == floor&&r[i] == room)t += v[i];
                }
                cout << ' ' << t;
            }
            cout << endl;
        }
        if (building == 4)break;
        cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
#define M 1000000007
using namespace std;

int modinv(int a, int m) {
    int x = m, y = a, p = 1, q = 0, r = 0, s = 1;
    while (y != 0) {
        int u = x / y;
        int x0 = y; y = x - y * u; x = x0;
        int r0 = p - r * u, s0 = q - s * u;
        p = r; r = r0; q = s; s = s0;
    }
    return q < 0 ? q + m : q;
}
// modular factorial----------------
long long fact[1001001], facti[1001001];

// initialization
void init_fact() {
    fact[0] = 1; facti[0] = 1;
    for (int i = 1; i <= 1001000; i++) {
        fact[i] = (fact[i-1] * i) % M;
        facti[i] = modinv(fact[i], M);
    }
}

long long perm(int n, int k) {
    if (n < 0 || k < 0 || k > n) return 0;
    return fact[n] * facti[n-k] % M;
}

int main() {
    int n, m; cin >> n >> m;
    int A[n], B[m];
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < m; i++) cin >> B[i];
    sort(A, A + n); sort(B, B + m);
    for (int i = 1; i < n; i++) if (A[i-1] == A[i]) { cout << 0 << endl; return 0; }
    for (int i = 1; i < m; i++) if (B[i-1] == B[i]) { cout << 0 << endl; return 0; }
    int i = 0, j = 0;
    long long ans = 1;
    init_fact();
    while (i < n && j < m) {
        // cout << i << ' ' << j << ' ' << lb << ' ' << res << ' ' << ans << endl;
        int res = min(A[i], B[j]) - i * m - j * n + i * j;
        if (A[i] < B[j]) {
            int cnt =  m - j;
            ans = ans * (perm(res, cnt) - perm(res-1, cnt)) % M;
            i++;
        } else if (A[i] > B[j]) {
            int cnt = n - i;
            ans = ans * (perm(res, cnt) - perm(res-1, cnt)) % M;
            j++;
        } else {
            int cnt = n - i + m - j - 2;
            ans = ans * perm(res-1, cnt) % M;
            i++; j++;
        }
    }
    cout << (ans % M + M) % M << endl;
}


Measured memory_bytes: 15872
//@Author: wxyww
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
#include<cmath>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
#define pi pair<double,double>
const int N = 110;
ll read() {
	ll x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9') { x = x * 10 + c - '0', c = getchar(); }
	return x * f;
}
pi a[N];
bool cmp(const pi& A, const pi& B) {
	return atan2(A.second, A.first) < atan2(B.second, B.first);
}
int main() {
	int n = read();
	for (int i = 0; i < n; ++i) a[i].first = read(), a[i].second = read();
	sort(a, a + n, cmp);
	double ans = 0;
	for (int i = 0; i < n; ++i) {
		double X = a[i].first, Y = a[i].second;
		ans = max(ans, X * X + Y * Y);
		for (int j = (i + 1) % n; j != i; j = (j + 1) % n) {
			X += a[j].first, Y += a[j].second;
			ans = max(ans, X * X + Y * Y);
		}
	}
	printf("%.10lf", sqrt(ans));
	return 0;
}

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

int n;
int main(){
    cin>>n;
    int a1=0;
    vector<int> a;
    for(int i=0;i<n;++i){
        cin>>a1;
        a.push_back(a1);
    }
  reverse(a.begin(),a.end());
     for(int j=0;j<n;++j){
            if(j<n-1){
                cout<<a[j]<<" ";
            }else{
                cout<<a[n-1];
            }
     }
    cout<<endl;
    return 0;
}
           



Measured memory_bytes: 3140
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define vair <vector<pair<int,int>>
#define vi vector<int>
#define mp make_pair
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool checkPrime(int n)
{
    if(n<2) return false;
    for(int x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return -1;
	
}
vector<int> Two_PointerSumOfTwo(vector<int> arr, int target)
{
	int l = 0, r = arr.size()-1;
	vector<int> ans;
	while(l<r){
		if(arr[l] + arr[r] == target)
		{
			ans.push_back(l);
			ans.push_back(r);
			break;
		}else if(arr[l] + arr[r] > target){
			r--;
		}else{
			l++;;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i <(int)s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
} 
int main()
{
	int n,k;
	cin >> n >> k;
	vector<ll>  a(n);
	forn(i,n)cin>>a[i];
	sort(all(a));
	while(k-- && a.size() > 0)
	{
		a.pop_back();
	}
	ll ans = 0;
	for(auto x : a)
	{
		ans+= x;
	}
	cout << ans<< endl;
	return 0;
}

Measured memory_bytes: 4832
s=input()
s=s.replace("BC","D")
n=len(s)
ans=0
cnt=0
for i in range(n-1,-1,-1):
    if s[i]=="B" or s[i]=="C":
        cnt=0
    elif s[i]=="D":
        cnt+=1
    else:
        ans+=cnt
print(ans)


Measured memory_bytes: 41968
A=int(input())
B=int(input())
C=int(input())
X=int(input())
result=0
for a in range(0,A+1):
    for b in range(0,B+1):
        for c in range(0,C+1):
            ans=a*500+b*100+c*50
            if(ans==X):
                result=1+result
print(result)

Measured memory_bytes: 3064
#棟ごとにリストを分けてみる
heya1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        ]

heya2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        ]

heya3 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        ]

heya4 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        ]

#回数nの入力
n = int(input())

#繰り返し処理
for i in range(n):
    x = input()
    list = x.split()
    [b, f, r, v] = list
    b = int(b)
    f = int(f)
    r = int(r)
    v = int(v)
    
    #部屋番号の確認
    f = f - 1
    f = f * 10
    fr = f + r
    fr = fr - 1
    
    ####棟ごとにいじるリストを分ける
    if b == 1:
        heya = heya1[fr]
        heya = int(heya)
        heya = heya + v
        heya1[fr] = heya
    
    elif b == 2:
        heya = heya2[fr]
        heya = int(heya)
        heya = heya + v
        heya2[fr] = heya
    
    elif b == 3:
        heya = heya3[fr]
        heya = int(heya)
        heya = heya + v
        heya3[fr] = heya

    elif b == 4:
        heya = heya4[fr]
        heya = int(heya)
        heya = heya + v
        heya4[fr] = heya

#それぞれのリストを文字列に変換
heya1 = [str(n) for n in heya1]
heya2 = [str(n) for n in heya2]
heya3 = [str(n) for n in heya3]
heya4 = [str(n) for n in heya4]

#表示行ごとに分ける
heya11 = heya1[0:10]
heya12 = heya1[10:20]
heya13 = heya1[20:30]

heya21 = heya2[0:10]
heya22 = heya2[10:20]
heya23 = heya2[20:30]

heya31 = heya3[0:10]
heya32 = heya3[10:20]
heya33 = heya3[20:30]

heya41 = heya4[0:10]
heya42 = heya4[10:20]
heya43 = heya4[20:30]

#表示フォーマットを定める
heya11 = " " + " ".join(heya11)
heya12 = " " + " ".join(heya12)
heya13 = " " + " ".join(heya13)
heya21 = " " + " ".join(heya21)
heya22 = " " + " ".join(heya22)
heya23 = " " + " ".join(heya23)
heya31 = " " + " ".join(heya31)
heya32 = " " + " ".join(heya32)
heya33 = " " + " ".join(heya33)
heya41 = " " + " ".join(heya41)
heya42 = " " + " ".join(heya42)
heya43 = " " + " ".join(heya43)

#1行ごとに表示させてみる。
print(heya11)
print(heya12)
print(heya13)
print("####################")
print(heya21)
print(heya22)
print(heya23)
print("####################")
print(heya31)
print(heya32)
print(heya33)
print("####################")
print(heya41)
print(heya42)
print(heya43)


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  
  int c;
  
  vector<int> b(n);
  for(int i=1; i<=n; i++){
      b.at(a.at(i-1)-1) = i;
  }
  
  for(int i=0; i<n; i++){
      cout << b.at(i) << " ";
  }
  
  cout << endl;
	return 0;
}


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

int main(){
  int k,x;cin >> k >> x;
  for( int i = x-k+1 ; i < x+k ; ++i ){
    cout << i << " ";
  }
  return 0;
}

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

Ap=[]
Am=[]
for a in A:
    if a >= 0:
        Ap.append(a)
    else:
        Am.append(a)

Ap=sorted(Ap)
Am=sorted(Am,reverse=True)


if len(Ap)==0:
    if len(Am)%2==0:
        ans=-sum(Am)
    else:
        ans=-sum(Am)+2*Am[0]
        
elif len(Am)%2==0:
    Ams=-sum(Am)
    Aps=sum(Ap)
    ans=Ams+Aps
else:
    Ams=-sum(Am)+Am[0]
    Aps=sum(Ap)-Ap[0]
    tmp=Ap[0]+Am[0]
    if tmp<0:
        tmp=-tmp
    ans=Ams+Aps+tmp
        
print(ans)


Measured memory_bytes: 14496
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
typedef long long ll;
using namespace std;
const int k_mod = ( int )1e9 + 7;
void chmax( int &a, int b ){
	if (a < b){
		a = b;
	}
}
int main( void ){
	int n;
	cin >> n;
	int* * activities = ( int* * )malloc( sizeof( int ) * 3 );
	int* act_temp = new int[ n * 3 ]();
	rep( i, 0, 3 ){
		activities[ i ] = act_temp + i * n;
	}
	rep( i, 0, n ){
		rep( j, 0, 3 )
		cin >> activities[ j ][ i ];
	}
	int* * dp_happy = ( int* * )malloc( sizeof( int ) * 3 );
	int* dp_temp = new int[ n * 3 ]();
	rep( i, 0, 3 ){
		dp_happy[ i ] = dp_temp + i * n;
	}
	rep( j, 0, 3 ){
		rep( k, 0, 3 ){
			if(j == k)
				continue;
			chmax( dp_happy[ j ][ 0 ], activities[ k ][ 0 ] );
		}
	}
	rep( i, 1, n ){
		rep( j, 0, 3 ){
			rep( k, 0, 3 ){
				if(j == k)
					continue;
				chmax( dp_happy[ j ][ i ], dp_happy[ k ][ i - 1 ] + activities[ k ][ i ] );
			}
		}
	}
	int ans = 0;
	rep(i,0,3)
		chmax(ans, dp_happy[i][n-1]);
	printf( "%d\n", ans);
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> Pii;
const int INF = 193499;

int main(){
    vector<lli> hito;
    vector<lli> f;
    lli k;
    int n;
    cin >> n >> k;
    rep(i,n){
        lli a;
        cin >> a;
        hito.push_back(a);
    }
    rep(i,n){
        lli b;
        cin >> b;
        f.push_back(b);
    }
    sort(hito.begin(),hito.end());
    sort(f.begin(),f.end());

    lli ue = hito[n-1] * f[n-1] +3;
    lli sita = -1;
    bool flag;
    lli tmp;
    lli naka;
    lli tmp2;
    while (ue - sita > 1){
        tmp2 = k;
        flag = true;
        naka = (ue + sita)/2;
        rep(i,n){
            if (hito[i]*f[n-1-i] > naka){
                tmp = naka / f[n-1-i];
                tmp2 = tmp2 + tmp -hito[i] ;
            }
            if (tmp2 <0){
                flag = false;
                break;
            }

        }
   
        if (flag) ue = naka;
        else sita = naka;
    }
    cout << ue << endl;
    return 0;
}


Measured memory_bytes: 4848
#include <stdio.h>

int main()
{
	int arr[3] = {1, 1, 1};
	int i;
	unsigned int a, b, c;

	scanf("%d %d", &a, &b);
	arr[a - 1] = 0;
	arr[b - 1] = 0;
	
	for (i = 0; i < 3; i++)
		if (arr[i] == 1)
			printf("%d\n", i + 1);

	return 0;
}

Measured memory_bytes: 256