akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
	val N = readLine()!!.toInt()
	var a = readLine()!!.split(" ").map(String::toInt)
	a = a.sorted()

	var Alice = 0
	var Bob = 0
	var j = 0

	for (i in (N - 1) downTo 0) {
		if (j % 2 == 0) {
			Alice += a[i]
		} else{
			Bob += a[i]
		}
		j += 1
	}
	println(Alice - Bob)
}

Measured memory_bytes: 37876
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

	int cmax = A[0];
	ll ret = 0;
	rep(i, N) {
		if (A[i] <= cmax) {
			ret += (cmax - A[i]);
		}
		else {
			cmax = A[i];
		}
	}

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


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#include<string>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = LONG_MAX;
const int N = 1e3 + 5;
const ll mod = 1000000007 ;
using namespace std;

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;

	while (tc--) {

		ll n, m, k, i, j;
		ll x, y;
		string s;

		cin >> s;

		cout << s[0] << s[1] << s[2] << endl;





	}

}

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

int main(){
  for(int n, p; cin >> n >> p && (n|p); ) {
    int q = p;
    vector<int> a(n, 0);
    for(int k = 0; ; k = (k + 1) % n) {
      if(p) {
        a[k] += 1;
        p -= 1;
        if(a[k] == q) {
          cout << k << endl;
          break;
        }
      } else {
        p += a[k];
        a[k] = 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1196
# include <iostream>
using namespace std;
int n, w, ans[1000010], tot,q, s,tt[100001]; 
bool vis[100000010];
int main() {
    cin >> q ;
	n=100000;
    vis[1]=1;
    for(int i = 2; i <= n; i++) {  
        if(vis[i] == false) ans[++tot] = i;
        for(int j = 1; (j <= tot) && (i*ans[j] <= n); j++) {
            vis[i * ans[j]] = true;
            if(i % ans[j] == 0) break;
        }
    }
    for (int i=1;i<=100000;i++){
    	if (!vis[i]&&!vis[(i+1)/2]) tt[i]++;
    	tt[i]+=tt[i-1];
	}
	int ll,rr;
	for (int i=1;i<=q;i++){
		cin>>ll>>rr;
		int summ=0;
		summ=tt[rr]-tt[--ll];
		cout<<summ<<endl;
	}
    return 0;
}

Measured memory_bytes: 2816
MOD = 10**9+7
X, Y = map(int, input().split())
if (X > Y):
    X, Y = Y, X

if (X+Y)%3 != 0:
    print (0)
    exit()

if (2*X < Y):
    print (0)
    exit()

W = X - ((X+Y)//3)
H = Y - ((X+Y)//3)

mx = 10**6
fact = [1] * (mx+1) # 階乗を格納するリスト
def inv(n): # MODを法とした逆元
    return pow(n, MOD-2, MOD)
for i in range(mx):
    fact[i+1] = fact[i] * (i+1) % MOD # 階乗を計算
ans = (fact[W+H] * inv(fact[W]) * inv(fact[H])) % MOD # comb(W+H,W) = (W+H)!/(W!H!)
print (ans)

Measured memory_bytes: 42612
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1 << 18, maxm = 1 << 9, maxw = 1e5 + 2, L = 1e5;
int n, m, q, v[maxn], w[maxn], f[maxm][maxw];

int dfs(int x, int l) {
    if (l <= 0) return 0;
    if (x < (1 << m)) return f[x][l];
    int ret = dfs(x >> 1, l);
    if (l >= v[x]) ret = max(ret, dfs(x >> 1, l - v[x]) + w[x]);
    return ret;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n; m = log2(n + 1) / 2;
    for (int i = 1; i <= n; ++i) cin >> w[i] >> v[i];
    for (int i = 1; i < (1 << m); ++i)
        for (int j = 0; j <= L; ++j) {
            f[i][j] = f[i >> 1][j];
            if (j >= v[i])
                f[i][j] = max(f[i][j], f[i >> 1][j - v[i]] + w[i]);
        }
    // cout << f[1][1] << endl;
    for (cin >> q; q; --q) {
        int x, l; cin >> x >> l;
        cout << dfs(x, l) << endl;
    }
    return 0;
}

Measured memory_bytes: 406996
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N, M = MAP()
a = [INT() for _ in range(M)]
a.append(0)

dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1

k = 0

if a[0] == 1:
	dp[1] = 0
	k += 1

for i in range(2, N+1):
	if i == a[k]: 
		k += 1
	else:
		dp[i] = (dp[i-1] + dp[i-2])%mod

print(dp[N])


Measured memory_bytes: 9920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll K; cin >> K;
    vector<ll> a(K);
    for(int i=0; i<K; ++i) cin >> a[i];

    ll maxv = 2, minv = 2;

    for(int i=K-1; i>=0; --i){
        ll check = a[i]*(minv/a[i]);
        if(check < minv && maxv < check+a[i]){
            cout << -1 << endl;
            return 0;
        }

        maxv = a[i]*(maxv/a[i]+1)-1;
        minv = a[i]*((minv-1)/a[i]+1);
    }

    cout << minv << " " << maxv << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

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

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
vi V[10];

int find_min_index(int a, int from) {
  const vi& v = V[a];
  auto it = lower_bound(begin(v), end(v), from);
  if (it == end(v)) {
    return -1;
  }

  return *it;
}

int main(int argc, char** argv) {
  int N;
  cin >> N;
  string S;
  cin >> S;

  REP(i, S.size()) {
    int a = S[i]-'0';
    V[a].emplace_back(i);
  }

  int ret = 0;
  REP(x, 1000) {
    int a = x/100;
    int ai = find_min_index(a, 0);
    if (ai < 0) continue;

    int b = (x/10)%10;
    int bi = find_min_index(b, ai+1);
    if (bi<0) continue;

    int c = x%10;
    int ci = find_min_index(c, bi+1);
    if (ci < 0) continue;

    ret++;
  }

  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;





bool primenum(int p){
  int cnt=2;
  double root;

  if (p ==2){ return true;
  }
    
  if(p<2 or p%2==0){
    
      return false;
  }
  
  root = sqrt((double)p);
    
    while(cnt<=(int)root){

      if(p%cnt ==0){
	return false;
      }
      

      
      cnt++;
    }
    
    return true;
    
}




int main(){
  int prime[10001],i=0,ptot=0;
  
  while(cin>>prime[i]){
    i++;
  }

  

  for(int s=0;s<i;s++){
    if (primenum(prime[s])==true){
      ptot++;


    }
  }
      

  cout <<ptot<<endl;
  
  
  
    return 0;
}

Measured memory_bytes: 3124
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll n,k,r,s,p;
  ll dp[110000][2]={};
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  for(int i=0;i<n;i++){
    ll tmp = max(dp[i][0],dp[i][1]);
    dp[i+1][0] = dp[i+1][1] = tmp;
    if(i<k){
      if(t[i]=='r') dp[i+1][0] += p;
      if(t[i]=='s') dp[i+1][0] += r;
      if(t[i]=='p') dp[i+1][0] += s;
    }else{
      if(t[i]!=t[i-k]||dp[i+1-k][0]==dp[i+1-k][1]){
        if(t[i]=='r') dp[i+1][0] += p;
        if(t[i]=='s') dp[i+1][0] += r;
        if(t[i]=='p') dp[i+1][0] += s;
      }
    }
  }
  cout << max(dp[n][0],dp[n][1])<<endl;
}


Measured memory_bytes: 2176
def stones(a,k): # k個の石を取り合う a[i](sorted)個とることが可能な時必勝はどちらか
    n=len(a)
    dp=[False for _ in range(k+1)] #石がi個の時、dp[i]=Trueで勝利Falseで敗北
    for i in range(k+1):
        for j in range(n):
            if i-a[j]>=0:
                if not dp[i-a[j]]:
                    dp[i]=True
    if dp[k]:
        print("First")
    else:
        print("Second")


def main():
    n,k = map(int,input().split()) 
    a = list(map(int,input().split()))
    a.sort()
    stones(a,k)
if __name__ == "__main__":
    main()


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

int main(void)
{
  char str[300],head[300],tail[300];
  int len,i;

  fgets(str,300,stdin);
  len = strlen(str);

  //  printf("%d\n",len);

  if(len % 2)
    len = len - 3;
  else
    len = len - 2;

  //printf("%d\n",len);
  while(len >= 0)
    {
      //      printf("len = %d\n",len);
      for(i = 0;i < len/2;i++)
        {
          head[i] = str[i];
          //  printf("head[%d] = %c\n",i,str[i]);
        }
      head[i] = '\0';

      for(i = 0;i <len/2;i++)
        {
          tail[i] = str[len/2 + i];
          //printf("tail[%d] = %c\n",i,str[len/2 + i]);
        }
    tail[i] = '\0';
      /*
      printf("head:");
      printf(head);
      printf("\n");
      printf("tail:");
      printf(tail);
      printf("\n");
      */
      //printf("strcmp = %d\n",strcmp(head,tail));

      if(strcmp(head,tail) == 0)
        {
          printf("%d\n",len);
          return 0;
        }
      len = len-2;
    }

  return 0;
}


Measured memory_bytes: 128
def prime_judge(n):
    if n==1:
        return False
    elif n==2:
        return True
    elif n%2==0:
        return False
    else:
        sqrt_num=int(n**0.5)+1
        for i in range(3,sqrt_num, 2):
            if n%i==0:
                return False
        return True

prime=[0]
for i in range(1,1000000):
    if prime_judge(i):
        prime.append(prime[-1]+1)
    else:
        prime.append(prime[-1])

while 1:
    try:
        print(prime[int(input())])     
    except:
        break


Measured memory_bytes: 16084
fn main() {
    let n: i32 = read();
    // println!("{}", n/1000);
    let bills = n/1000;
    match n%1000 {
        0 => println!("{}", 0),
        _ => println!("{}", 1000 * (bills + 1) - n),
    }
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 2128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){

	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);

	if(A >= C){
		printf("0\n");
	}else if(A+B >= C){
		printf("%d\n",C-A);
	}else{
		printf("NA\n");
	}

	return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Data{
public:
    int y, x, d;
    Data(int y0, int x0, int d0){
        y = y0;
        x = x0;
        d = d0;
    }
};

int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

int main()
{
    for(;;){
        int h, w, cost;
        cin >> h >> w >> cost;
        if(h == 0)
            return 0;

        vector<vector<int> > grid(2*h+1, vector<int>(2*w+1, 0));
        for(int i=0; i<2*h+1; ++i)
            grid[i][0] = grid[i][2*w] = -1;
        for(int i=0; i<2*w+1; ++i)
            grid[0][i] = grid[2*h][i] = -1;

        int ns;
        cin >> ns;
        for(int i=0; i<ns; ++i){
            char y, c;
            int x, k;
            cin >> y >> c >> x >> k;
            grid[2*(y-'a')+1][2*(x-1)+1] = k;
        }

        int nc;
        cin >> nc;
        for(int i=0; i<nc; ++i){
            char y1, y2, c;
            int x1, x2;
            cin >> y1 >> c >> x1 >> y2 >> c >> x2;
            grid[y1-'a'+y2-'a'+1][x1+x2-1] = -1;
        }

        int nj;
        cin >> nj;
        for(int i=0; i<nj; ++i){
            char y1, y2, c;
            int x1, x2, d;
            cin >> y1 >> c >> x1 >> y2 >> c >> x2 >> d;
            grid[y1-'a'+y2-'a'+1][x1+x2-1] = d;
        }

        int sy, sx, gy, gx;
        char c, c1, c2;
        cin >> c1 >> c >> sx >> c2 >> c >> gx;
        sy = 2 * (c1 - 'a') + 1;
        gy = 2 * (c2 - 'a') + 1;
        sx = 2 * (sx - 1) + 1;
        gx = 2 * (gx - 1) + 1;

        vector<vector<vector<vector<bool> > > > check(2*h+1, vector<vector<vector<bool> > >(2*w+1, vector<vector<bool> >(4, vector<bool>(101, false))));
        multimap<int, Data> mm;
        for(int i=0; i<4; ++i){
            check[sy][sx][i][0] = true;
            mm.insert(make_pair(0, Data(sy, sx, i)));
        }

        for(;;){
            int t = mm.begin()->first;
            Data d = mm.begin()->second;
            mm.erase(mm.begin());
            if(grid[d.y][d.x] > 0 && !((t / grid[d.y][d.x] % 2 == 0) ^ (d.d % 2 == 0)))
                continue;
            if(d.y == gy && d.x == gx){
                cout << t << endl;
                break;
            }

            for(int i=0; i<4; ++i){
                if((i+2)%4 == d.d)
                    continue;
                int y = d.y + dy[i];
                int x = d.x + dx[i];
                if(grid[y][x] == -1)
                    continue;
                int t1 = t + cost + grid[y][x];
                y += dy[i];
                x += dx[i];
                if(t1 <= 100 && !check[y][x][i][t1]){
                    check[y][x][i][t1] = true;
                    mm.insert(make_pair(t1, Data(y, x, i)));
                }
            }
        }
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="AC") a++;
        else if(s=="TLE") b++;
        else if(s=="WA") c++;
        else d++;

    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<c<<endl;
    cout<<"TLE x "<<b<<endl;
    cout<<"RE x "<<d<<endl;

}


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

// Loops
#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 < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!
string rotate(string S){
  string R; R += S[S.size()-1];
  rep(i,S.size()-1){
    R += S[i];
  }
  return R;
}
//

void solve(std::string S, std::string T) {
  bool ok = false;
  rep(i,S.size()+1){
    if(S==T){
      ok = true; break;
    }
    S = rotate(S);
  }
  yesno(ok);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


Measured memory_bytes: 3648
/**
*    author:  souzai32
*    created: 12.08.2020 21:51:55
**/

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

int main() {

    int n,m,k;
    cin >> n >> m >> k;
    string ans="No";
    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++) if(k==i*(m-j)+j*(n-i)) ans="Yes";
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;




signed main(){
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vec(p,a);
    vec(q,b);
    vec(r,c);
    input(p,a);
    input(q,b);
    input(r,c);
    Sort(p);
    Sort(q);
    Sort(r);
    Reverse(p);
    Reverse(q);
    Reverse(r);
    vector<int> tmp;
    REP(i,x){
        tmp.push_back(p[i]);
    }
    REP(i,y){
        tmp.push_back(q[i]);
    }
    Sort(tmp);
    int itr = 0;
    while(true){
        if(tmp[itr] < r[itr]){
            tmp[itr] = r[itr];
            itr++;
        }
        else break;
    }
    int ans = 0;
    REP(i,x+y){
        ans += tmp[i];
    }
    print(ans);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
const int mod=1e6+3;
int x,d,n,fac[mod];
int qpow(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}
int main()
{
	fac[0]=1;for(int i=1;i<mod;i++)fac[i]=1ll*fac[i-1]*i%mod;
	int Q;scanf("%d",&Q);
	while(Q--)
	{
		scanf("%d%d%d",&x,&d,&n);
		if(!d)printf("%d\n",qpow(x,n));
		else{
			x=1ll*x*qpow(d,mod-2)%mod;
			if(!x||x+n-1>=mod)puts("0");
			else printf("%d\n",1ll*fac[x+n-1]*qpow(fac[x-1],mod-2)%mod*qpow(d,n)%mod);
		}
	}
}

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

int main() {
    
    int ballsNum;
    int typeARobotInitialPostionX = 0;
    int typeBRobotInitialPostionX;
    
    cin >> ballsNum >> typeBRobotInitialPostionX;
    
    int totalDistanceToMove = 0;
    
    for (int i = 0; i < ballsNum; i++) {
    	int ballPostionX;
    	cin >> ballPostionX;
    	
    	int distanceFromRobotAToTheBall = abs(ballPostionX - typeARobotInitialPostionX);
    	int distanceFromRobotBToTheBall = abs(ballPostionX - typeBRobotInitialPostionX);
    	
    	// 近い方のロボットが取りに行く 取りに行った後、元の場所に戻るので往復の距離を足す
    	totalDistanceToMove += min(distanceFromRobotAToTheBall, distanceFromRobotBToTheBall) * 2;
    }
    
    cout << totalDistanceToMove << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] tb = new int[10][10];
        for(int i = 1; i <= n; i++){
            String tmp = String.valueOf(i);
            int t = Character.getNumericValue(tmp.charAt(0));
            int b = Character.getNumericValue(tmp.charAt(tmp.length()-1));
            tb[t][b]++;
        }
        int ans = 0;
        for(int i = 1; i <= n; i++){
            String tmp = String.valueOf(i);
            int t = Character.getNumericValue(tmp.charAt(0));
            int b = Character.getNumericValue(tmp.charAt(tmp.length()-1));
            ans += tb[b][t];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 38576
N, K = map(int, input().split())
X = list(map(int, input().split()))
ans = 10**20
for i in range(N-K+1):
  l = X[i]
  r = X[i+K-1]
  if l*r >= 0:
    ans = min(ans, max(abs(l), abs(r)))
  else:
    ans = min(ans, r-l + min(abs(l), abs(r)))
print(ans)

Measured memory_bytes: 19952
#include<iostream>
#include<vector>
using namespace std;
typedef pair<int,int> mypair;
int main(void){
while(1){
int n=0;
cin>>n;
if(n==0)break;
vector<mypair> a(n);
a[0]=mypair(0,0);
int r=0,l=0,u=0,d=0;
for(int i=1;i<n;i++){
int n1,d1;
cin>>n1>>d1;
if(d1==0){
a[i]=mypair(a[n1].first-1,a[n1].second);
l=min(l,a[i].first);
}
if(d1==1){
a[i]=mypair(a[n1].first,a[n1].second-1);
d=min(d,a[i].second);
}
if(d1==2){
a[i]=mypair(a[n1].first+1,a[n1].second);
r=max(r,a[i].first);
}
if(d1==3){
a[i]=mypair(a[n1].first,a[n1].second+1);
u=max(u,a[i].second);
}

}
//cout<<r<<l<<u<<d<<endl;
cout<<r-l+1<<' '<<u-d+1<<endl;
}

return 0;
}



Measured memory_bytes: 3088
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    int i = 0, j = 0;
    for(i = 0; i < SZ(s); i++){
        if(j < SZ(t) && s[i] == t[j]){
            j++;
        }
    }
    int ans = SZ(s) + SZ(t.substr(j));
    cout << ans + (ans >= n ? 0 : n - ans);    
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

int main(){
  int n,f[101][12],p[101][12];
  cin>>n;
  for(int i=0;i<n;++i){
    for(int j=0;j<10;++j){
        cin>>f[i][j];
    }
  }
  for(int i=0;i<n;++i){
    for(int j=0;j<=10;++j){
        cin>>p[i][j];
    }
  }
  int m=-1e9;
  for(int bit=1;bit<1<<10;++bit){

    int ans=0;
    for(int i=0;i<n;++i){
        int cnt=0;
        for(int j=0;j<10;++j){
            if(bit&(1<<j)&&f[i][j])cnt++;
        }
        ans+=p[i][cnt];
    }
    m=max(m,ans);
  }

  cout << m << endl;

  return 0;
}


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

const char *name[] = {
	"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white",
};

int main(){
	int r, g, b;
	while(scanf(" #%2x%2x%2x", &r, &g, &b) == 3){
		puts(name[(r > 127) * 4 + (g > 127) * 2 + (b > 127)]);
	}
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define fint register int
#define h 5001
#define p 3457943
#define inf 3000000008LL
#define int long long
using namespace std;
struct node
{
	int a;
	int b;
	int c;
	int d;
}
e[p];
signed main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int max_a=-inf,max_b=-inf,min_a=-inf,min_b=-inf;
	int x,y;
	for(fint i=1;i<=n;i++)
	{
		cin>>x>>y;
		max_a=max(x-y,max_a);
		min_a=max(y-x,min_a);
		max_b=max(x+y,max_b);
		min_b=max(-x-y,min_b);
	}
	cout<<max(max_a+min_a,max_b+min_b);
	return 0;
}

Measured memory_bytes: 3628
n,k = map(int,input().split())
num  = 0
for select_num in range(k,n+2):
    st = (select_num*(2*0+(select_num - 1)*( 1)))/2
    ed = (select_num*(2*n+(select_num - 1)*(-1)))/2
    sum = ed - st + 1
    num += sum
print(int(num)%1000000007)



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

int main(){
	int a,b,c;
	int ans;
	int cnt=-1;
	
	while(cin>>a>>b){
		cnt++;
		//-----test-----
		if(a<1000) break;
		
		//--------------
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}
int st[500000][20];
int stm[500000][20];
int a[400000];
int mark[500000];
int sta[500000],l,r;
int n;
int que(int l,int r,int mode){
    int k=__lg(r-l+1);
    if(mode==1)
    return max(st[l][k],st[r-(1<<k)+1][k]);
    else
        return min(stm[l][k], stm[r - (1 << k) + 1][k]);
}
signed main()
{
    io;
    cin>>n; int k;cin>>k;
    rep(i,1,n)cin>>a[i],st[i][0]=a[i],stm[i][0]=a[i];
    l=1,r=0;
    rep(i,1,n){
        while(l<=r&&a[sta[r]]>a[i])r--;
        sta[++r]=i;
        while(l<=r&&sta[l]<=i-k)l++;
        if(r-l+1>=k)mark[i]=1;
    }
    rep(k,1,19){
        for(int j=1;j+(1<<k)-1<=n;j++){
            st[j][k]=max(st[j][k-1],st[j+(1<<(k-1))][k-1]);
            stm[j][k] = min(stm[j][k - 1], stm[j + (1 << (k - 1))][k - 1]);
        }
    }
    int ans=0; int fl=0;
    for(int i=k;i<=n;i++){

        if (i != k && a[i-k] == que(i-k, i - 1, 0) && a[i] == que(i -k+1, i , 1))

         {

         }
         else if(fl && mark[i]){

         }
         else       ans++;
        
        if(mark[i])fl=1;
    }
    cout<<ans<<endl;

   


    getchar(); //
    getchar();
}


Measured memory_bytes: 75520
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;

int main(){
    ll x;
    scanf("%lld",&x);
    ll a=100,ans=0;
    while(a<x)
    {
        a*=1.01;
        ans++;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 3824
#include <stdio.h>
int main(void){
    int s, h, m;
    int S; 
    int a;
    
    scanf("%d", &S);
    
     0 <= S < 86400;
    
    a = S / 60  ;
    s = S % 60 ;
    h = a / 60 ;
    m = a % 60  ;
    
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int a, b; cin >> a >> b;
  int sum = (max(0,4-a)+max(0,4-b));
  cout << (sum==6?10:sum)*(100000) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n, d, x;
    cin >> n >> d >> x;
    rep(i, n)
    {
        int a;
        cin >> a;
        x += (d + a - 1) / a;
    }
    cout << x << endl;
}

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

signed main() {
  int N,M;
  cin>>N>>M;
  int x,y,z;
  std::vector<int> a(N),b(N),c(N),d(N),e(N),f(N),g(N),h(N);
  for(int i=0;i<N;i++){
    cin>>x>>y>>z;
    a[i]=x+y+z;
    b[i]=-x+y+z;
    c[i]=x-y+z;
    d[i]=-x-y+z;
    e[i]=x+y-z;
    f[i]=-x+y-z;
    g[i]=x-y-z;
    h[i]=-x-y-z;
  }
  int ans=0;
  int kk=0;
  sort(a.rbegin(),a.rend());
  sort(b.rbegin(),b.rend());
  sort(c.rbegin(),c.rend());
  sort(d.rbegin(),d.rend());
  sort(e.rbegin(),e.rend());
  sort(f.rbegin(),f.rend());
  sort(g.rbegin(),g.rend());
  sort(h.rbegin(),h.rend());
  for(int i=0;i<M;i++)ans+=a[i];
  for(int i=0;i<M;i++)kk+=b[i];
  ans=max(ans,kk);
  kk=0;
  for(int i=0;i<M;i++)kk+=c[i];
  ans=max(ans,kk);
  kk=0;
  for(int i=0;i<M;i++)kk+=d[i];
  ans=max(ans,kk);
  kk=0;
  for(int i=0;i<M;i++)kk+=e[i];
  ans=max(ans,kk);
  kk=0;
  for(int i=0;i<M;i++)kk+=f[i];
  ans=max(ans,kk);
  kk=0;
  for(int i=0;i<M;i++)kk+=g[i];
  ans=max(ans,kk);
  kk=0;
  for(int i=0;i<M;i++)kk+=h[i];
  ans=max(ans,kk);
  kk=0;
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n;
  cin>>n;
  vector<P> p(n);
  set<P> st;
  for(int i=0;i<n;i++){
    cin>>p[i].fi>>p[i].se;
    st.insert(p[i]);
  }
  int ans=n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
	 if(i==j)continue;
	 int s=p[i].fi-p[j].fi;
	 int t=p[i].se-p[j].se;
	 int sum=0;
	 for(int x=0;x<n;x++){
	   if(st.count(P(p[x].fi-s,p[x].se-t)))continue;
	   sum++;
	 }
	 ans=min(ans,sum);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

vector<vector<int>> G(2e5+5);
vector<int> ans;

void dfs(int v, int p=-1) {
    for(int i: G[v]){
	if(i == p)
	    continue;
	ans[i] += ans[v];
        dfs(i, v);
    }
}

int main(){
    int N, M, Q, p, x, a, b;
    cin >> N >> Q;
    for(int i=0; i<N-1; i++){
	cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
	G[b].push_back(a);
    }
    ans.resize(N);
    for(int i=0; i<Q; i++){
	cin >> p >> x;
	p--;
	ans[p] += x;
    }
    dfs(0);
    for(int i=0; i<N; i++){
	cout << ans[i] << " ";	    
    }
    cout << endl;
}



Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back

using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

template<class T,class U>
void chmin(T& t,U u){
	if(ll(t)>ll(u))
		t=u;
}

template<class T,class U>
void chmax(T& t,U u){
	if(ll(t)<ll(u))
		t=u;
}

int main(){
	ll a,b,n;
	cin>>a>>b>>n;
	ll ans=LLONG_MAX;
	for(ll q=1;q<=n;q++){
		if(b%q!=0)
			continue;
		ll k=b/q;
		ll x=a/k*k;
		ll y=x+k;
		ll z=k*n;
		if(0<x&&x<=z)
			chmin(ans,abs(a-x));
		if(0<y&&y<=z)
			chmin(ans,abs(a-y));
		if(0<z)
			chmin(ans,abs(a-z));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yn(int o){
    if (o == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

struct point {
    vector<int> to;
};

int main() {
    int n, m; cin >> n >> m;
    vector<point> ar(n);
    rep(i,m){
        int a, b; cin >> a >> b;
        a--; b--;
        ar[a].to.emplace_back(b);
        ar[b].to.emplace_back(a);
    }
    bool t = false;
    rep(i,ar[0].to.size()){
        int p = ar[0].to[i];
        rep(j,ar[p].to.size()){
            if (ar[p].to[j] == n - 1) t = true;
        }
    }
    if (t) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

string S;

long long f( int ptn )
{
	if( ptn >= 1 << (S.size() - 1) ) {
		return 0;
	}
	long long res = 0;
	int last = 0;
	for( int i = 1, p = ptn; i < S.size(); i++, p >>= 1 ) {
		if( ( p & 1 ) == 0 ) {
			continue;
		}
		int l = i - last;
		string s = S.substr( last, l );
		long long n = atoll( s.c_str() );
		res += n;
		last = i;
	}
	int l = S.size() - last;
	string s = S.substr( last, l );
	long long n = atoll( s.c_str() );
	res += n;

	res += f( ptn + 1 );
	return res;
}

int main() {
	cin >> S;

	long long ans = f( 0 );

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
using namespace std;
int x,a,b; 
int main()  
{  
	cin>>x>>a>>b;
	if(abs(x-a)>abs(b-x)){
		cout<<"B";
	}else{
		cout<<"A";
	} 
	return 0;  
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n,k;
  cin>>n>>k;
  vector<int>h(n);
  rep(i,n) cin>>h[i];
  sort(h.rbegin(),h.rend());
  ll ans=0;
  if(n>k){
    for(int i=k;i<n;i++){
      ans+=h[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>


int main(void){
    char *s = (char*)malloc(101 * sizeof(char));
    char *t = (char*)malloc(101 * sizeof(char));
    scanf("%s", s);
    scanf("%s", t);


    int S = strlen(s);
    int T = strlen(t);
    int i, j;
    for(i=0; i<S-1; i++) {
        for(j=S-1; j>= i+1; j--) {
            if(s[j] < s[j-1]) {
                char temp;
                temp = s[j];
                s[j] = s[j - 1];
                s[j - 1] = temp;
            }
        }
    }
    for(i=0; i<T-1; i++) {
        for(j=T-1; j>= i+1; j--) {
            if(t[j] > t[j-1]) {
                char temp;
                temp = t[j];
                t[j] = t[j - 1];
                t[j - 1] = temp;
            }
        }
    }

    if(strcmp(s, t) < 0) {
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
  return 0;
}

Measured memory_bytes: 128
/*
 * FILE: ABC 127B.cpp
 *
 * @author: Piyush Kanti Das <piyush123kantidas[at]gmail[dot]com>
 *
 * LINK:
 *
 * DATE CREATED: 04.06.2019 01:45:38 +06
 *
 * DESCRIPTION:
 *
 * DEVELOPMENT HISTORY:
 * Date         Version     Description
 * --------------------------------------------------------------
 * 04-06-2019	1.0         File Created
 *
 */


/*
// _______________________________________________________________/\\\_________
//  ______________________________________________________________\/\\\_________
//   ___/\\\\\\\\\___/\\\____/\\\__/\\\____________________________\/\\\_________
//    __/\\\/////\\\_\///____\//\\\/\\\___/\\\____/\\\__/\\\\\\\\\\_\/\\\_________
//     _\/\\\\\\\\\\___/\\\____\//\\\\\___\/\\\___\/\\\_\/\\\//////__\/\\\\\\\\\\__
//      _\/\\\//////___\/\\\_____\//\\\____\/\\\___\/\\\_\/\\\\\\\\\\_\/\\\/////\\\_
//       _\/\\\_________\/\\\__/\\_/\\\_____\/\\\___\/\\\_\////////\\\_\/\\\___\/\\\_
//        _\/\\\_________\/\\\_\//\\\\/______\//\\\\\\\\\___/\\\\\\\\\\_\/\\\___\/\\\_
//         _\///__________\///___\////_________\/////////___\//////////__\///____\///__
//
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long           ll;
typedef double              lf;
typedef unsigned long long  ull;
typedef pair<int, int>      pii;
typedef vector<pii>         vpii;
typedef vector<int>         vi;
typedef vector<long long>   vll;

#define __FastIO        ios_base::sync_with_stdio(false); cin.tie(0)

#define forr(i, a, b)   for (__typeof (a) i=a; i<=b; i++)
#define rof(i, b, a)    for (__typeof (a) i=b; i>=a; i--)
#define rep(i, n)       for (__typeof (n) i=0; i<n; i++)
#define forit(i, s)     for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define all(ar)         ar.begin(), ar.end()

#define fill(ar)   		memset(ar, -1, sizeof(ar))
#define clr(a)          memset(a, 0, sizeof(a))

#define nl              cout << '\n';
#define sp              cout << ' ';
#define ckk             cout << "##########\n"

#define pb              push_back
#define MP 				make_pair

#define debug1(x)       cerr << #x << ": " << x << endl
#define debug2(x, y)    cerr << #x << ": " << x << '\t' << #y << ": " << y << endl
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << endl

#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define MAX             100005

int Set(int N,int pos){return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}


ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;
    
    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}

//Auto-format --> ctrl+shift+a
/********************* Code starts here ************************/

int main() {
    __FastIO;   //Be aware to use it!
   int r, d, x;
	
	cin >> r >> d >> x;
	int Xnext;
	
	forr(i, 1, 10){
		Xnext = x*r - d;
		cout << Xnext << endl;
		x = Xnext;
	}
	
    return 0;
}


Measured memory_bytes: 256
def p_s(H, W):
    for i in range(H):
        str = ''
        for j in range(W):
            if j == 0:
                str += "#"
            elif j == (W - 1):
                str += "#"
            elif i == 0:
                str += "#"
            elif i == (H - 1):
                str += "#"
            else:
                str += "."
        print(str)
    print()


while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    p_s(H, W)



Measured memory_bytes: 5616
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

typedef long long ll;


using namespace std;


int main(){
    int a,h,m,s;
    cin>>a;
    h=a/3600;
    a=a%3600;
    m=a/60;
    s=a%60;
    cout<<h<<":"<<m<<":"<<s<<endl;


    return 0;
};

Measured memory_bytes: 3072
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return [int(i)-1 for i in input().split()]
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    ans = 0
    for i in range(1, n + 1):
        ans += i & 1
    print(ans/n)
    return

#B
def B():
    n, k = LI()
    h = LI()
    ans = 0
    for i in h:
        ans += i >= k
    print(ans)
    return

#C
def C():
    n = II()
    a = LI()
    d = defaultdict(int)
    for i in range(n):
        d[a[i] + 1] = i + 1
    for _, v in sorted(d.items()):
        print(v, end=" ")
    print()
    return

def primes(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    """ 6以上の数であれば p (素数) <= n のlistを返す """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
        if sieve[i]:
            k=3*i+1|1
            sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

#D
def D():
    a, b = LI()
    da = defaultdict(int)
    db = defaultdict(int)
    for i in range(2, int(math.sqrt(a)) + 1):
        while a % i == 0:
            a = a // i
            da[i] = 1
        while b % i == 0:
            b = b // i
            db[i] = 1
    da[a] = 1
    db[b] = 1
    da[1] = 1
    db[1] = 1
    print(len(set(da.keys()) & set(db.keys())))
    return

#E
def E():
    n, m = LI()
    dp = [inf] * (1 << n)
    dp[0] = 0
    for _ in range(m):
        a, b = LI()
        c = LI_()
        fulls = sum((1<<c[i] for i in range(b)))
        for i in range(1 << n):
            dp[i | fulls] = min(dp[i | fulls], dp[i] + a)
    if dp[-1] == inf:
        print(-1)
    else:
        print(dp[-1])
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    E()


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

int main() {
  int a, b; cin>>a>>b;
  vector<string> v(a);
  for (int i=0; i<a; i++) cin>>v[i];
  cout << string(b+2,'#') << endl;
  for (int i=0; i<a; i++) cout << '#' << v[i] << '#' << endl;
  cout << string(b+2,'#') << endl;
}

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

using namespace std;

string conv(string s)
{
    string res = "";
    int i = 1;
    res += s[0];
    for (; i < (int)s.length() - 3; i++)
    {
        string sub = s.substr(i, 3);
        if (sub == "mew")
            i += 2;
        else
            res += s[i];
    }
    for (; i < (int)s.length(); i++)
        res += s[i];
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    if (s == "mew")
    {
        cout << "Cat" << endl;
        return 0;
    }
    int pre = s.length();
    while (true)
    {
        s = conv(s);
        if ((int)s.length() == pre)
        {
            cout << "Rabbit" << endl;
            return 0;
        }
        if (s == "mew")
        {
            cout << "Cat" << endl;
            return 0;
        }
        pre = s.length();
    }
    return 0;
}


Measured memory_bytes: 3232