akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n, a, b, c;

	cin >> n >> a >> b >> c;
	vector<int>p(n);
	for (int i = 0; i < n; i++)cin >> p[i];
	int  ans = 99999999;
	for (int i = 0; i < pow(4, n); i++) {
		vector<int>t(n);
		int k = i;
		int r = 0;
		for (int j = 0; j < n; j++) {
			t[j] = k % 4;
	
			k /= 4;
			
		}
		//cout << i;
		int x=0, y=0, z=0;
		for (int j = 0; j < n; j++) {
			if (!t[j])continue;
			if (t[j] == 1) {
				if (x)r += 10;
				x += p[j];
			}
			if (t[j] == 2) {
				if (y)r += 10;
				y += p[j];
			}
			if (t[j] == 3) {
				if (z)r += 10;
				z += p[j];
			}
		}
		r += abs(x - a) + abs(y - b) + abs(z - c);
		if(x&&y&&z)ans = min(r, ans);


	}
	cout << ans << endl;


	return 0;

}

Measured memory_bytes: 384
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto ab = readints;
    int a = ab[0], b = ab[1];

    int x = cast(int)(ceil((a + b) / 2.0));
    writeln(x);
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    long x=sc.nextLong();
    long y=sc.nextLong();
    for(int i=0;true;i++){
      if(x>y){
        System.out.println(i);
        return;
      }
      y/=2;
    }
  }
}

Measured memory_bytes: 21972
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
  //文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
  
  var c = a + b
  if ( c % 2 ) {
    console.log('IMPOSSIBLE');
  } else {
    console.log(c/2)
  }

  //出力
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#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;

int main(){
    ios::sync_with_stdio(false);
    int c[]={1,5,10,50,100,500};
    int a,sum=0;
    REP(i,6){
        cin >> a;
        sum+=a*c[i];
    }
    if(sum<1000)cout << 0 << endl;
    else cout << 1 << endl;
}



Measured memory_bytes: 3108
H, W, N = map(int, input().split())
d = {}

for i in range(N):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    for j in range(-1, 2):
        for k in range(-1, 2):
            if 1 <= a+j < H-1 and 1 <= b+k < W-1:
                if d.get((a+j, b+k)) is None:
                    d[(a+j, b+k)] = 0
                d[(a+j, b+k)] += 1


ans = [0] * 10
for v in d.values():
    ans[v] += 1
ans[0] = (H-2)*(W-2)-sum(ans[1:])

for i in range(10):
    print(ans[i])

Measured memory_bytes: 166516
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int h = sc.nextInt();
		int w = sc.nextInt();

		char map[][] = new char[h][];

		for (int i = 0; i < h; i++) {
			map[i] = sc.next().toCharArray();
		}

		int mask[][] = new int[h][w];
		int max = 0;

		int y[] = new int[h];
		int t[] = new int[w];

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (map[i][j] == '.') {
					mask[i][j] = 0;
				} else {
					mask[i][j] = 1 << (map[i][j] - 'A');
					max = Math.max(map[i][j] - 'A', max);
				}
				y[i] |= mask[i][j];
				t[j] |= mask[i][j];
			}
		}
		max += 1;
		boolean dp[] = new boolean[1 << max];
		dp[0] = true;
		int n = max;
		int mk = 0;

		int nnt[] = new int[n];
		int nnt2[] = new int[n];
		int nny[] = new int[n];
		int nny2[] = new int[n];

		int memo[] = new int[n];
		Arrays.fill(memo, -1);
		int memo2[] = new int[n];
		Arrays.fill(memo, -1);

		for (int j = 0; j < n; j++) {
			int shj = 1 << j;

			int nt = -1;
			int nt2 = -1;
			int ny = -1;
			int ny2 = -1;
			for (int ii = 0; ii < h; ii++) {
				if ((y[ii] & shj) != 0) {
					if (nt == -1) {
						nt = ii;
					} else {
						nt2 = ii;
					}
				}
			}
			for (int ii = 0; ii < w; ii++) {
				if ((t[ii] & shj) != 0) {
					if (ny == -1) {
						ny = ii;
					} else {
						ny2 = ii;
					}
				}
			}
			if (nt2 == -1) {
				nt2 = nt;
			}
			if (ny2 == -1) {
				ny2 = ny;
			}

			if ((nt & ny) == -1) {
				nnt[j] = nt;
				nnt2[j] = nt2;
				nny[j] = ny;
				nny2[j] = ny2;
				continue;
			}

			if (mask[nt][ny] == shj) {
				int temp = ny2;
				ny2 = ny;
				ny = temp;
			}

			nnt[j] = nt;
			nnt2[j] = nt2;
			nny[j] = ny;
			nny2[j] = ny2;

			int tf = 0;
			int tf2 = 0;
			for (int ii = Math.min(nt, nt2); ii <= Math.max(nt, nt2); ii++) {
				tf |= mask[ii][ny];
				tf2 |= mask[ii][ny2];
			}

			int yf = 0;
			int yf2 = 0;
			for (int ii = Math.min(ny, ny2); ii <= Math.max(ny, ny2); ii++) {
				yf |= mask[nt][ii];
				yf2 |= mask[nt2][ii];

			}

			memo[j] = tf | yf;
			memo2[j] = tf2 | yf2;

		}

		int i = 0;
		for (;;) {
			int previ = i;			
			for (int j = 0; j < n; j++) {
				int shj = 1 << j;
				if (dp[i | shj]) {
					// System.out.println("here");
					continue;
				}

				int nt = nnt[j];
				int nt2 = nnt2[j];
				int ny = nny[j];
				int ny2 = nny2[j];

				if ((nt & ny) == -1) {
					continue;
				}
				if (Math.abs(nt - nt2) + Math.abs(ny2 - ny) < 2) {
					continue;
				}

				if (((~(i | shj)) & (memo[j])) == 0
						|| ((~(i | shj)) & (memo2[j])) == 0) {
					dp[i | shj] = true;
					i |= shj;
				}
			}
			if(i==previ){
				break;
				
			}
		}
		System.out.println(Integer.bitCount(i)*2);
	}

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

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
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; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

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

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

int main() {
	ll N, Q; cin >> N >> Q;
	vll dat(N);
	iota(begin(dat), end(dat), 1);

	set<int> st;
	st.insert(1); st.insert(2);
	int pos = 0;
	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b; --a, --b;
		swap(dat[a], dat[b]);
		if (a == pos) pos = b;
		else if (b == pos) pos = a;
		if (pos > 0) st.insert(dat[pos-1]);
		if (pos < N-1) st.insert(dat[pos+1]);
	}
	cout << st.size() << endl;
	return (0);
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
 
 
int main(){
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll s = min(a,min(b,min(c,min(d,e))));
    if(n % s == 0) cout << n / s + 4 << endl;
    else cout << n / s + 5 << endl;
}


Measured memory_bytes: 3624
/*input
1000 1 1000
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long
int n,x,t;
signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>n>>x>>t;
	cout<<(int)ceil((double)n/x)*t;
	return 0;	
}

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

signed main() {
  int n, k;
  cin >> n >> k;
  int count = 0;
  for (int i = 1; i <= n; i++) {
    int sho = n / i;
    int amari = n % i;
    count += sho * max(0LL, i - k);
    count += max(0LL, amari - k + 1);
  }
  if (k == 0) count -= n;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>         
#define N 400008   
#define ll long long         
#define setIO(s) freopen(s".in","r",stdin)       
using namespace std;           
int a[N],b[N],c[N],d[N];  
int main() 
{ 
	// setIO("input");   
	int i,j,n;  
	scanf("%d",&n);
	for(i=1;i<=n;++i)   
		scanf("%d",&a[i]); 
	for(i=1;i<=n;++i)   
		scanf("%d",&b[i]);                
	int ans=0,pow=1;   
	for(i=0;i<=28;++i) 
	{        
		for(j=1;j<=n;++j)  
			c[j]=a[j],d[j]=b[j];       
		for(j=1;j<=n;++j)    
		{
			c[j]%=(pow<<1);     
			d[j]%=(pow<<1);   
		}   
		sort(d+1,d+1+n);      
		int l,r,sum=0;     
		for(j=1;j<=n;++j)  
		{
			l=lower_bound(d+1,d+1+n,pow-c[j])-d;     
			r=lower_bound(d+1,d+1+n,2*pow-c[j])-d;   
			if(d[r]>=2*pow-c[j])     
				--r;      
			if(r>n)   
				--r; 
			if(l<=r)   
			    sum+=(r-l+1);             
			l=lower_bound(d+1,d+1+n,3*pow-c[j])-d;   
			r=lower_bound(d+1,d+1+n,4*pow-c[j])-d; 
			if(d[r]>=4*pow-c[j])     
				--r;      
			if(r>n)   
				--r;   
			if(l<=r)
			    sum+=(r-l+1);  
		}
		if(sum&1)     
			ans+=pow;     
		pow*=2;  
	}    
	printf("%d\n",ans);  
	return 0; 
}

Measured memory_bytes: 5632
#include <cstdio>
#include <cmath>
#include <stack>
#include <iostream>
#include <string> 
#define debug	  0
#define 	MAXN		110
using namespace std;
int ans,N;
void dfs(long long index,int flag)
{	if(index > N)return ;
	if(flag == 7)
	{	ans++;
	}
	dfs(index*10+3,flag|1);
	dfs(index*10+5,flag|2);
	dfs(index*10+7,flag|4);
 } 
int main()
{	
#if debug	
freopen("data.txt","r",stdin);
#endif
	ans =0;
	cin>>N;
	dfs(0,0);
	cout<<ans;
 } 

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

#define PI 3.14159265359
#define sqrt(x) (x)*(x)

int main() 
{
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  
  long double AX = A * cos((H * 60 + M) * PI / 360.0);
  long double AY = A * sin((H * 60 + M) * PI / 360.0);
  long double BX = B * cos(M / 30.0 * PI);
  long double BY = B * sin(M / 30.0 * PI);
  
  cout << fixed << setprecision(10);
  cout << powl(sqrt(AX - BX) + sqrt(AY - BY), 0.5) << endl;
  return 0;
}


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

const int INF = 1000000000;
int n, h[101010], dp[101010];

int main(){
  cin >> n;
  rep(i, n) cin >> h[i];
  rep(i, n) dp[i] = INF;
  dp[0] = 0;
  for(int i = 0; i < n - 1; i++){
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
  }
  rep(i, n) cerr << dp[i] <<" ";
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
import sys
l,r = map(int,input().split())
ans = int(2018)
if(r-l > 2020):
    print(0)
    sys.exit()
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            if((i*j)%2019 < ans):
                ans = (i*j)%2019
print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    n = int(input())
    jobs = [tuple(map(int, input().split())) for _ in range(n)]
    jobs.sort(key=lambda x: (x[1], x[0]))

    t = 0
    for cost, deadline in jobs:
        t += cost
        if t > deadline:
            print('No')
            return
    print('Yes')


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 65444
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int, A: "List[int]"):
    bits = [0] * int(ceil(log(max(K, max(A))) / log(2)))
    for a in A:
        i = 0
        while 0 < (a >> i):
            bits[i] += (a >> i) & 1
            i += 1

    x = 0
    for i in range(len(bits)-1, -1, -1):
        c = bits[i]
        diff = (1 << i) if 2 * c <= N else 0
        if x + diff <= K:
            x += diff

    ret = 0
    for a in A:
        ret += x ^ a
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, K, A)
    print(result)

if __name__ == '__main__':
    main()


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9+7;


ll dp[100010][13];
int main(){
	
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);


    ll a,b; cin >>a>>b;
    b = 2*b+1;

    cout << a/b + (a%b ? 1:0) << endl;
    return 0;
}

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

const int maxN=200000+10;
int dp[maxN];

int main(){
	int n,m;
	cin>>n>>m;
	while(m--){
		int x,y;
		cin>>x>>y;
		if(x==n || x==1){
			if(dp[y]==0){
				dp[y]++;
			}
			else{
				cout<<"POSSIBLE";
				exit(0);
			}
		}
		else if(y==n || y==1){
			if(dp[x]==0){
				dp[x]++;
			}
			else{
				cout<<"POSSIBLE";
				exit(0);
			}
		}
	}
	cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace _001_FindingMissingCards
{

    class Program
    {
        static void Main()
        {
            Boolean isContinued = true;

            while (isContinued)
            {
                var givenNum = Convert.ToInt32(Console.ReadLine());
                if (givenNum == 0)
                {
                    isContinued = false;
                }
                else
                {
                    var tmp = Console.ReadLine().Split(' ');
                    double []point = new double[tmp.Length];
                    for (int i = 0; i < tmp.Length; i++)
                    {
                        point[i] = Convert.ToDouble(tmp[i]);
                    }
                    double m = point.Average();
                    double h = 0;
                    for (int i = 0; i < point.Length; i++)
                    {
                        h += Math.Pow(point[i] - m, 2.0);
                    }
                    Console.WriteLine(Math.Sqrt(h / point.Length));

                    
                }

            }

            
            

        }
    }
}

Measured memory_bytes: 9748
import sys
sys.setrecursionlimit(10000000)


def main():
    N = int(input())
    for i in range(1, 10):
        for j in range(1, 10):
            if N == i * j:
                print("Yes")
                sys.exit()
    print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;
using System.Linq;
using static System.Console;
using static System.Int32;
using static System.Math;

namespace ConsoleApp2
{
    class Program
    {
        static void Main()
        {
        lbl:
            var n = Parse(ReadLine());
            var ary = new long[60];
            foreach (var a in ReadLine().Split())
            {
                int j = 0;
                for (var aa = long.Parse(a); 0 < aa; aa >>= 1)
                {
                    if (0 != (aa & 1)) ++ary[j];
                    ++j;
                }
            }
            const long WARU = 1000000007;
            long result = 0;
            for (int i = 0; i < ary.Length; ++i)
            {
                var kisu = (1L << i) % WARU;
                kisu *= ary[i];
                kisu %= WARU;
                kisu *= (n - ary[i]);
                result += kisu;
                result %= WARU;
            }
            WriteLine(result);
        }
    }
}


Measured memory_bytes: 49736
#include <iostream>
#include<vector>
#include <cstring>
#include <cstdio>
#include<cstdint>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
int n ;
int f[100][14];
int p[100][15];
int main ()
{
  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 <11; j ++)cin>>p[i][j];
int max=-(1<<30);
    for(int bit=1;bit<(1<<10);bit++){
        int sum=0;
        for(int i=0;i<n;i++){
            int count=0;
        rep(j,10)if((bit>>j & 1) && f[i][j])count++;
        sum+=p[i][count];
        }
        if(sum>max)max=sum;
        }
        cout<<max<<endl;

}

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

int N,N3;
int a[MAXN];

priority_queue<int> q1;
priority_queue<int, vector<int>, greater<int> > q0;
LL sum0, sum1;
LL f0[MAXN], f1[MAXN];

int main(){
	
	cin>>N;
	N3 = 3*N;
	for(int i=1;i<=N3;i++){
		cin>>a[i];
	}
	
	int x;
	for(int i=1;i<=N3;i++){
		x = a[i];
		
		q0.push(x); sum0 += x;
		if(q0.size() > N){
			sum0 -= q0.top();
			q0.pop();
		}
		
		if(i>=N) f0[i] = sum0;
	}
	
	for(int i=N3;i>=1;i--){
		x = a[i];
		
		q1.push(x); sum1 += x;
		if(q1.size() > N){
			sum1 -= q1.top();
			q1.pop();
		}
		
		if(i<=N3-N+1) f1[i] = sum1;
	}
	
	LL ans = -1e18;
	for(int i=N;i<=N3-N;i++){
		ans = max(ans, f0[i] - f1[i+1]);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 6520
n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]

def binary_search(a, key):
  left = 0
  right = len(a)
  while left < right:
    mid = int((left + right) / 2)
    if a[mid] == key:
      return mid
    elif key < a[mid]:
      right = mid
    else:
      left = mid + 1
  return None

count = 0

for key in t:
  if binary_search(s, key) != None:
    count += 1

print(count)



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

int main(void)
{
  string s, t;
  cin >> s >> t;
  
  for(auto i=0; i<s.length(); i++){
      char c1=s[i];
      char c2=t[i];
      if(c1==c2) continue;
      
      for(auto j=0; j<i; j++){
          if(s[j]==c1 || s[j]==c2){
              cout << "No" << endl;
              return 0;
          }
      }
      for(auto j=i; j<s.length(); j++){
          if(s[j]==c1) s[j]=c2;
          else if(s[j]==c2) s[j]=c1;
      }
      if(s==t){
          cout << "Yes" << endl;
          return 0;
      }
  }
  if(s==t)  cout << "Yes" << endl;
  else      cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 505;
ll a[maxN][maxN];
vector < int > primes;
int n;
bool used[maxN * maxN * 10];
ll gcd(ll a, ll b) {
    while (a > 0 && b > 0) {
        if (a < b) swap(a, b);
        a %= b;
    }
    return a + b;
}
ll lcm(ll a, ll b) {
    return (a * (b / gcd(a, b)));
}
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    int max_n = 500;
    for (int i = 2; ; i++) {
        if (used[i]) continue;
        primes.push_back(i);
        if (primes.size() > 2 * max_n + 10) {
            break;
        }
        for (int j = i; j < maxN * maxN * 10; j += i) used[j] = true;
    }
    set < ll > all;
    for (int i = 1; i <= max_n; i++) {
        for (int j = 1; j <= max_n; j++) {
            if (((i + j) % 2) == 0) {
                a[i][j] = 1LL * primes[(i + j) / 2] * primes[(i - j) / 2 + max_n + 2 + (max_n / 2)];
                all.insert(a[i][j]);
            }
        }
    }
    ll mx = 1;
    for (int i = 1; i <= max_n; i++) {
        for (int j = 1; j <= max_n; j++) {
            if (((i + j) % 2) == 0) continue;
            a[i][j] = 1;
            if (i > 1) a[i][j] = lcm(a[i][j], a[i - 1][j]);
            if (i < max_n) a[i][j] = lcm(a[i + 1][j], a[i][j]);
            if (j < max_n) a[i][j] = lcm(a[i][j], a[i][j + 1]);
            if (j > 1) a[i][j] = lcm(a[i][j], a[i][j - 1]);
            a[i][j]++;
            mx = max(mx, a[i][j]);
            all.insert(a[i][j]);
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cout << a[i][j] << " ";
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 19328
def readln():
    return list(map(int, input().split()))


A, B, K = readln()

cnt = 0
for n in range(min(A, B), -1, -1):
    if (A % n == 0) and (B % n == 0):
        cnt += 1
    if cnt == K:
        print(n)
        break


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

#define INF 2147483647
const int MAX_N = 1 << 17;

/*
Range Sum Query by FenwickTree(Binary Indexed Tree)

total number: n
queries:
    1. add(i, val): add val to i-th value 
    2. sum(k): sum(bit[0] + ... + bit[k])
complexity: O(log n)

Self-balancing binary search tree or Segment Tree can do the same, it takes longer to program and complexity also increases.

Thanks: http://hos.ac/slides/20140319_bit.pdf
    
used in ARC031 C, indeednow finalB E, DSL2B(AOJ)
*/

int dat[MAX_N + 1];

struct RangeSumQuery {
  int N;

  RangeSumQuery(int N_){
    N = N_;
  }

  void update(int k, int val) {
    while (k < N) {
      dat[k] += val;
      k |= k + 1;
    }
  }

  int query(int k) {
    int ret = 0;
    while (k >= 0) {
      ret += dat[k];
      k = (k & (k + 1)) - 1;
    }
    return ret;
  }
};

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

  int n, q;
  cin >> n >> q;

  RangeSumQuery bit(n);

  REP(i, q) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      bit.update(x-1, y);
    } else if (com == 1) {
      cout << bit.query(y-1) - bit.query(x-2) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1584
def main():
    n, m = map(int, input().split())
    s_dict = {}
    sum = 0
    for _ in range(m):
        s, c = map(int, input().split())
        if s in s_dict and s_dict[s] != c or n!=1 and s==1 and c==0:
            sum = -1
            break
        else:
            s_dict[s] = c
    
    if sum != -1:
        for i in range(1, n+1):
            if i in s_dict:
                sum += s_dict[i]*pow(10, n-i)
            elif i == 1 and n != 1:
                sum += pow(10, n-1)
    print(sum)

if __name__=='__main__':
    # import time
    # start = time.time()
    main()
    # print(f"{time.time()-start}[s]")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;
     
int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 2; i < n; i++) {
    if (s[i - 2] == 'A' and
        s[i - 1] == 'B' and
        s[i - 0] == 'C') ans++;
  }
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 256
#include <stdio.h>

main()
{
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if( ((x - r) >= 0 && W >= (x + r)) && ((y - r) >= 0 && H >= (y + r)) )
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	

	return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////

int main() {
	ll n; cin >> n;
	if (n <= 3) {
		cout << 0 << endl;
		return 0;
	}
	string s; cin >> s;
	ll cntr = 0;
	ll cntg = 0;
	ll cntb = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'R') {
			cntr++;
		}
		else if (s[i] == 'G') {
			cntg++;
		}
		else {
			cntb++;
		}
	}
	ll sum = 0;
	sum += cntr * cntg*cntb;
	for (int i = 1; i < n-1; ++i) {
		for (int j = 1; i - j >= 0 && i + j < n; ++j) {
			if (s[i - j] != s[i] && s[i] != s[i + j] && s[i - j] != s[i + j]) {
				sum -= 1;
			}
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3612
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        w: usize,
        h: usize,
        n: usize,
        xya: [(usize, usize, usize); n],
    };
    let mut ans = vec![vec![1u32; w]; h];
    for (x, y, a) in xya{
        match a {
            1 => {
                for i in 0..h{
                    for j in 0..x{
                        ans[i][j] = 0;
                    }
                }
            },
            2 => {
                for i in 0..h{
                    for j in x..w{
                        ans[i][j] = 0;
                    }
                }
            },
            3 => {
                for i in 0..y{
                    for j in 0..w{
                        ans[i][j] = 0;
                    }
                }
            },
            4 => {
                for i in y..h{
                    for j in 0..w{
                        ans[i][j] = 0;
                    }
                }
            },
            _ => {},
        }
    }

    println!(
        "{}",
        ans.iter().map(|v| v.iter().sum::<u32>()).sum::<u32>()
    );
}


Measured memory_bytes: 4352
#include <string.h>
int main(void){
  char s[11], t[11], u[11];
  int a, b;
  scanf("%s%s%d%d%s", s, t, &a, &b, u);
  if(strcmp(s, u) ==0) a--;
  else b--;
  printf("%d %d\n", a, b);
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
  int x,y,z,k,s,c;
  c = 0;
  scanf("%d %d",&k,&s);
  for(x=0; x<=k; x++){
    for(y=0; y<=k; y++){
      z = s-x-y;
      if(z>=0 && z<=k) c++;
    }}
    printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 128
use std::{io};


fn main() {
    let mut input = String::new();
    let _ = io::stdin().read_line(&mut input).unwrap();
    let mut n = input.as_bytes().iter().take_while(|x| 0x30 <= **x && **x <= 0x39).map(|x| (x - 0x30) as i32).collect::<Vec<i32>>();
    let mut s = 0;
    for i in (1..n.len()).rev() {
        s += 9;
        if n[i] < 9 {
            n[i-1] -= 1;
        }
    }
    s += n[0];
    println!("{}", s);
}

Measured memory_bytes: 4352
while True:
    table = input().split()
    a = int(table[0])
    op = table[1]
    b = int(table[2])
    if op == '?':
        break
    if op == '+':
        print("%d"%(a+b))
    elif op == '-':
        print("%d"%(a-b))
    elif op == '/':
        print("%d"%(a/b))
    else:
        print("%d"%(a*b))


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


int main(void){
    int n,y;
    cin>>n>>y;
    rep(i,n+1)rep(j,n+1-i){
        int k=n-i-j;
        if(10000*i+5000*j+1000*k==y){
            cout<<i<<" "<<j<<" "<<k<<endl;
            return 0;
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

int n;
ll c;
ll x[100005], v[100005];
std::pair<ll, ll> dp[100005], dp2[100005];
int main()
{
	std::cin >> n >> c;

	for (int i = 1; i <= n; i++)
		std::cin >> x[i] >> v[i];

	ll vsum = 0;
	for (int i = 1; i <= n; i++) {
		vsum += v[i];

		if (dp[i - 1].first < vsum - x[i])
			dp[i].second = x[i];
		else
			dp[i].second = dp[i - 1].second;
		dp[i].first = std::max(dp[i - 1].first, vsum - x[i]);
	}

	vsum = 0;
	for (int i = n; i >= 1; i--) {
		vsum += v[i];

		if (dp2[i + 1].first < vsum - (c - x[i]))
			dp2[i].second = c - x[i];
		else
			dp2[i].second = dp2[i + 1].second;
		dp2[i].first = std::max(dp2[i + 1].first, vsum - (c - x[i]));
	}

	ll ans = 0;
	for (int i = 0; i <= n; ++i)
		ans = std::max(ans, dp[i].first + dp2[i + 1].first - std::min(dp[i].second, dp2[i + 1].second));

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


Measured memory_bytes: 4992
def f(i,s):
    if i == len(n)-1:
        if eval(s) == 7:
            ans.append(s)
            return 1
        else:return 0
    return f(i+1,s+"-"+n[i+1])+f(i+1,s+"+"+n[i+1])
n = input()
ans = []
f(0,n[0])
print(ans[0]+"=7")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+13;
struct node{
	int val,pos;
	bool operator <(const node &b)
	const{
		return pos<b.pos;//从小到大 
	}
}a[maxn],b[maxn]; 
priority_queue<int,vector<int>,greater<int> > q;//greater默认小根堆
int main()
{
	int t,n;
	scanf("%d",&t);
	while(t--)
	{
		int k,l,r;
		ll ans=0;
		int cnt1=0,cnt2=0;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
          scanf("%d%d%d",&k,&l,&r);
        if(l>r) ans+=1ll*r,a[++cnt1]=(node){l-r,k};
		else ans+=1ll*l,b[++cnt2]=(node){r-l,n-k}; 
		}
		sort(a+1,a+1+cnt1);
		sort(b+1,b+1+cnt2);
		for(int i=1;i<=cnt1;i++)
		{
			if(q.size()<a[i].pos) q.push(a[i].val);
			else if(q.size()==a[i].pos)
			{
				if(a[i].val>q.top()) q.push(a[i].val),q.pop();
			}
		}
		while(!q.empty()) ans+=1ll*q.top(),q.pop();
		for(int i=1;i<=cnt2;i++)
		{
			if(q.size()<b[i].pos) q.push(b[i].val);
			else if(q.size()==b[i].pos)
			{
				if(b[i].val>q.top()) q.push(b[i].val),q.pop();
			}
		}
		while(!q.empty()) ans+=1ll*q.top(),q.pop();
		printf("%lld\n",ans);
	}    
}

Measured memory_bytes: 5516
n, W = map(int, input().split())

dp = [[0 for _ in range(W+1)] for _ in range(n+1)]

for i in range(n):
    w, v = map(int, input().split())
    for j in range(W+1):
        if j-w >= 0: dp[i+1][j] = max(dp[i][j], v+dp[i][j-w])
        else: dp[i+1][j] = dp[i][j]

print(dp[-1][-1])

Measured memory_bytes: 171400
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	string s,p;
	cin >> s >> p;

	s = s + s;

	if(s.find(p) == string::npos){
		println("No");
	}else{
		println("Yes");
	}

	return 0;
}



Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};



int main(){
  string s;cin>>s;
  int n=s.size();
  int ans=0;
  rep(i,n-1)
    if(s[i]!=s[i+1])ans++;
  cout<<ans<<endl;

  return 0;   

  }

Measured memory_bytes: 512
#n = input()
n = int(input())
#a,b = map(int,input().split())
mydata = list(map(int,input().split()))
res = [0] * len(mydata)
#res[0] = 0
res[0] = mydata[0]
for i in range(0,len(mydata)-1):
    res[i+1] = res[i] + mydata[i+1]


ans = 2020202020**100
for i in range(n-1):
    before_sum = res[i]
    after_sum = res[n-1]-res[i]
    tmp = abs(before_sum-after_sum)
    ans = min(ans,tmp)
print(ans)

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

using namespace std;

int main() {
    int n;

    cin >> n;

    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a<b)System.out.println("a < b");
		else if(a>b)System.out.println("a > b");
		else System.out.println("a == b");
	}
}



Measured memory_bytes: 26304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ul;
#define all(x) (x).begin(), (x).end()
#define pi 3.1415926536

struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;

    TreeNode(int x): val(x), left(NULL), right(NULL){}
};

struct ListNode {
    int val;
    ListNode* next;

    ListNode(int x): val(x), next(NULL){}
};

int nxt(){
    int x;
    cin>>x;
    return x;
}

ll nxtLong(){
    ll x;
    cin>>x;
    return x;
}

string nxtStr(){
    string x;
    cin>>x;
    return x;
}

char nxtChar(){
    char x;
    cin>>x;
    return x;
}

double nxtDouble(){
    double x;
    cin>>x;
    return x;
}

ld nxtLDouble(){
    ld x;
    cin>>x;
    return x;
}

TreeNode* makeTree(int n){
    queue<TreeNode*> tree_nodes;
    TreeNode* root;
    if(n){
        root = new TreeNode(nxt());
        tree_nodes.push(root);
    }else{
        return NULL;
    }
    while(!tree_nodes.empty()){
        TreeNode* node = tree_nodes.front();
        tree_nodes.pop();
        bool left;
        cin>>left;
        if(left){
            node->left = new TreeNode(nxt());
            tree_nodes.push(node->left);
        }
        bool right;
        cin>>right;
        if(right){
            node->right = new TreeNode(nxt());
            tree_nodes.push(node->right);
        }
    }
    return root;
}

ListNode* makeLinkedList(int n){
    ListNode* list = new ListNode(0);
    ListNode* dummy = list;

    for(int i=0;i<n;++i){
        list->next = new ListNode(nxt());
        list = list->next;
    }

    return dummy->next;
}

void solve(){
    string s1 = nxtStr(), s2 = nxtStr();

    int cnt = 0;

    int n = s1.length();

    for(int i=0;i<n;++i){
        if(s1[i] != s2[i]){
            cnt++;
        }
    }

    cout<<cnt<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<fixed<<setprecision(9);
    //ll t;
    //cin>>t;
    //while(t--){
    //    solve();
    //}
    solve();
    return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>

int main () {
    ll n , k ;
    cin >> n >> k ;
    ll H[n] ;
    for(int i = 0 ; i < n ; i++){
        cin >> H[i] ;
    }

    sort(H , H + n) ;
    ll ans = 0 ;
    for(int j = 0 ; j < n - k ; j++){
        ans += H[j] ;
    }


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

 



Measured memory_bytes: 1792
# Resale

# libraries
import numpy as np

# input
N = int(input())
V = np.array(list(map(int, input().split())))
C = np.array(list(map(int, input().split())))

# solve
res = sum([max(0, v - c) for v, c in zip(V, C)])

# output
print(res)

Measured memory_bytes: 12504
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
		int k = sc.nextInt();
		int q = sc.nextInt();
        int[] a = new int[q];//回答者ナンバー
        for(int i=0;i<q;i++)
          a[i] = sc.nextInt();
      
      	int[] point = new int[n];//参加者が持つポイント
        for(int i=0;i<n;i++)
          point[i] = k;
        
        for(int j=0;j<point.length;j++){
          point[j]-=a.length; 
         }
        for(int i=0;i<a.length;i++){
          point[a[i]-1]++;
        }
        
      
      for(int i=0;i<n;i++){
       if(point[i]>0)System.out.println("Yes");
        else System.out.println("No");
      }
	}
}


Measured memory_bytes: 65900
#include<iostream>
#define N 1000001
using namespace std;
int main(){
  int p[N]={0};
  for(int i=3;i<N;i+=2) p[i] = 1;
  p[2] = 1;
  for(int i=3;i<=1000;i+=2){
    if(p[i]==1){
      for(int j=2*i;j<N;j+=i) p[j] = 0;
    }
  }
  int n,x;
  while(cin >> n >> x){
    if(n==0&&x==0) break;
    int t[x+1];
    for(int i=0;i<=x;i++) t[i] = 0;
    for(int i=0;i<n;i++){
      int k;
      cin >> k;
      if(k<=x) t[k] = 1;
      for(int j=1;j<=x;j++){
	if(t[j]==1&&j+k<=x) t[j+k] = 1;
      }
    }
    bool ok = false;
    for(int i=x;i>=0;i--){
      if(t[i]==1&&p[i]==1){
	cout << i << endl;
	ok = true;
	break;
      }
    }
    if(!ok) cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 8976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int t = 0;
		int x = 0;
		int y = 0;
		for (int i = 0; i < n; i++) {
			int[] ia = readNums();
			int ti = ia[0];
			int xi = ia[1];
			int yi = ia[2];
			int dt = abs(ti - t);
			int dx = abs(xi - x);
			int dy = abs(yi - y);
			if (dt < dx + dy) {
				pln("No");
				return;
			}
			dt -= dx + dy;
			if (dt % 2 == 1) {
				pln("No");
				return;
			}
			t = ti;
			x = xi;
			y = yi;
		}
		pln("Yes");
	}

	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    if(s.size() <= n) cout << s << endl;
    else{
        for(int i = 0; i < n; i++)
            cout << s[i];
        cout << "..." << endl;
    }
    return  0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef long long ll;
const int MOD = 1000000007;
const int BASE = 27;
const int oo = 1e9;
const double EPS = 1e-9;
const int MX = 1e6 + 1;

int n, a , b, c ,d;

string s;

int main() {
  cin >> n >> a >> b >> c >> d;
  cin >> s;
  a--,b--,c--,d--;
  int cnt = 0;
  bool can = true;
  for(int i = b;i <= d ; ++i){
    if(s[i]=='.'){
      cnt = 0;
    }else{
      cnt++;
      if(cnt >= 2)can = false;
    }
  }
  cnt = 0;
  for(int i = a ; i <= c ; ++i){
    if(s[i]=='.'){
      cnt = 0;
    }else{
      cnt++;
      if(cnt >= 2)can = false;
    }
  }

  if(c > d){

    bool c1 = false;
    for (int i = b; i <= d; ++i){

      if(i > 0 && s[i]=='.' && s[i+1]=='.' && s[i-1] == '.'){
        c1 = true;
      }
    }
    if(!c1)can = false;
  }
  if(can){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char a,b;cin >> a >> b;
	if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) cout << "H" << endl;
	else cout << "D" << endl;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  string S;
  cin >> S;
  bool flag = true;
  for(int i = 0; i < A; ++i){
    if(S[i] > '9' || S[i] < '0'){
      flag = false;
       } 
  }
  if(S[A] != '-'){
    flag = false;
  } 
  for(int i = A+1; i < A+B+1; ++i){
    if(S[i] > '9' || S[i] < '0'){
      flag = false;
    } 
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main() {
	string s, t;
	cin >> s;
	cin >> t;

	int ss[100] = { 0 };
	int tt[100] = { 0 };

	int id = -1;
	int smin[100] = { 0 };
	for (int i = 0; i < s.size(); i++) {
		id = -1;
		smin[i] = 1000;
		for (int j = 0; j < s.size(); j++) {
			if (0 == s[j]) continue;
			if (smin[i] > (int)s[j]) {
				smin[i] = (int)s[j];
				id = j;
			}
		}
		s[id] = 0;
	}

	int tmax[100] = { 0 };
	for (int i = 0; i < t.size(); i++) {
		id = -1;
		tmax[i] = -1;
		for (int j = 0; j < t.size(); j++) {
			if (tmax[i] < t[j]) {
				tmax[i] = t[j];
				id = j;
			}
		}
		t[id] = 0;
	}

	bool b = s.size() < t.size();
	int size = (s.size()< t.size()) ? s.size() : t.size();
	bool r = false;
	for (int i = 0; i < size; i++) {
		if (smin[i] != tmax[i]) {
			cout << ((smin[i] < tmax[i]) ? "Yes" : "No") << endl;
			r = true;
			break;
		}
	}
	if (!r) {
		cout << (b ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 256