akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
  int f[N2];
  int space;
  string path;

  bool operator < (const Puzzle &p) const {
    for(int i = 0 ; i < N2 ; i++){
      if(f[i] == p.f[i]) continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const int dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p){
  for(int i = 0 ; i < N2 ; i++)
    if(p.f[i] != (i + 1)) return false;
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u, v;
  s.path = "";
  Q.push(s);
  V[s] = true;


  while(!Q.empty()){
    u = Q.front();
    Q.pop();
    if(isTarget(u)) return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    for(int r = 0 ; r < 4 ; r++){
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
      v = u;
      swap(v.f[u.space], v.f[tx * N + ty]);
      v.space = tx * N + ty;
      if(!V[v]){
        V[v] = true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }

  return "unsolvable";
}

int main(){
  Puzzle in;

  for(int i = 0 ; i < N2 ; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}

Measured memory_bytes: 30544
import math

n = int(input())
x = list(map(int,input().split()))

mod = 10**9 + 7

f = math.factorial(n-1)
f %= mod

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

l = []
for i in range(n-1):
    d = x[i+1] - x[i]
    l.append(d)

# print(l)

count = 0
k = f
plus = 0
for i in range(1,n):
    # print(k)
    k = f + plus
    count += l[i-1] * k
    plus += f * modinv(i+1,mod)

print(int(count)%mod)

Measured memory_bytes: 15064
from Queue import Queue

n, q = [ int( val ) for val in raw_input( ).split( " " ) ]
names = Queue( )
times = Queue( )
for i in range( n ):
	name, time = raw_input( ).split( " " )
	names.put( name )
	times.put( int( time ) )
 
qsum = 0
output = []
while not times.empty( ):
	name = names.get( )
	time = times.get( )
	if time <= q:
		qsum += time
		output.append( "{:s} {:d}".format( name, qsum ) )
	else:
		times.put( time - q )
		names.put( name )
		qsum += q

print( "\n".join( output ) )

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

int n,k;

int cant[20];


bool ok(int num)
{
    while(num)
    {
        int t = num % 10;
        if(cant[t]) return false;
        num /= 10;
    }
    return true;
}

int solve()
{

    for(int i = n;;++i)
    {
        if(ok(i))
            return i;
    }
}

int main()
{
  //  freopen("./test.txt","r",stdin);
    scanf("%d %d",&n,&k);
    memset(cant,0,sizeof(cant));
    for(int i = 0;i < k;++i)
    {
        int t;
        scanf("%d",&t);
        cant[t] = 1;
    }

    int res = solve();
    printf("%d\n",res);

    return 0;
}


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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    vector<string> a = {"Sunny", "Cloudy", "Rainy"};

    string b;

    cin >> b;

    for(long long i = 0 ; i < a.size() ; i++) {

        if(a[i]==b) {

            cout << a[(i+1)%3] << '\n';

            return 0;

        }

    }

    return 0;

}



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


long long cur[1<<17] = {0}, pre[1<<17] = {0};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, W; cin >> n >> W;
  cur[0] = 0;
  fill(cur + 1, cur + W + 1, -(1ll<<60));
  for (int i = 1; i <= n; ++i) {
    swap(pre, cur);
    int w, v; cin >> w >> v;
    copy(pre, pre + w, cur);
    for (int j = w; j <= W; ++j) {
      cur[j] = max(pre[j], pre[j - w] + v);
    }
  }
  cout << *max_element(cur, cur + W + 1) << '\n';
}



Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	string s;
	cin>>s;
	rep(i,size(s)){
		if(s[i]=='?'){
			s[i]='D';
		}
	}
	cout<<s<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3748
import sys
from io import StringIO
import unittest
#import math
from decimal import *

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    a,b,c=list(map(int, readline().strip().split()))

    getcontext().prec = 50
    #m = Decimal(n).sqrt()
    #r_ab=math.sqrt(a)+math.sqrt(b)
    #r_c=math.sqrt(c)
    r_ab=Decimal(a).sqrt()+Decimal(b).sqrt()
    r_c=Decimal(c).sqrt()

    if r_ab < r_c:
        print("Yes")
    else:
        print("No")

    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Measured memory_bytes: 6344
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
	
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		String str = scan.next();
		if(str.length()<=k)
		{
			System.out.println(str);
		}
		else
		{
			System.out.println(str.substring(0,k)+"...");
		}
	}
}

Measured memory_bytes: 27052
def main():
    n, m = list(map(int, input().split()))
    a_list = list(map(int, input().split()))
    
    homework_day = 0
    for task in a_list:
        homework_day += task
    
    play_day = n - homework_day
    if play_day >= 0:
        print(play_day)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int x = a[n-1];
    int y = a[0];
    for(int i = 1; i < n-1; i++){
        if (abs(a[i]-x/2) <= abs(y-x/2)) y = a[i];
    }
    printf("%d %d\n", x, y);
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
  cin.sync_with_stdio(false);
  int n, m, tmp;
  while(cin >> n >> m, n | m) {
    vector<int> w, h;
    rep(i, n) cin >> tmp, h.pb(tmp);
    rep(i, n - 1) {
      tmp = h[i];
      repl(j, i + 1, n) tmp += h[j], h.pb(tmp);
    }

    rep(i, m) cin >> tmp, w.pb(tmp);
    rep(i, m - 1) {
      tmp = w[i];
      repl(j, i + 1, m) tmp += w[j], w.pb(tmp);
    }

    sort(all(h)); sort(all(w));
    int i = 0, j = 0;
    ll ans = 0;
    while(i < h.size() && j < w.size()) {
      if (h[i] < w[j]) i++;
      else if (h[i] > w[j]) j++;
      else {
        tmp = h[i];
        int a = 0, b = 0;
        while(i < h.size() && h[i] == tmp) i++, a++;
        while(j < w.size() && w[j] == tmp) j++, b++;
        ans += a * b;
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 19660
d,g=map(int,input().split())
spc=[]
c=[]
for i in range(d):
    pi,ci=map(int,input().split())
    si=pi*100*(i+1)+ci
    av=si//pi
    spc.append([av,si,pi,ci,100*(i+1)])

#print(spc)

spc.sort(reverse=True)
#print(spc)

#r=g
#icnt=0
#for i in range(d):
#   r=r-spc[i][1]
#   icnt=icnt+spc[i][2]
#   if r<=0:
#       break
#print(r,icnt)


dmin=10000
for i in range(d):
    for j in range(2**d):
#        print("d=",d,"i=",i,"j=",j,j//2,j%2)
        icnt=0
        sisum=0
        j2=j
        for i2 in range(d):
            if i2!=i:
                if j2%2==1:
                    sisum=sisum+spc[i2][1]
                    icnt=icnt+spc[i2][2]
#            if sisum>g:
#               break
#                print("j=",j,icnt,sisum)
            j2=j2//2
        
        for k in range(spc[i][2]):
            sisum=sisum+spc[i][4]
            icnt=icnt+1
#            print("k",k,icnt,sisum)
            if sisum>=g:
                break
        if k==spc[i][2]-1 :
            sisum=sisum+spc[i][3]
#        if sisum>=g :
#            print("kend",icnt,sisum)
        if sisum>=g and icnt<dmin :
            dmin=icnt
#            print("dmin=",dmin,sisum)
    
print(dmin)     
         

Measured memory_bytes: 3188
A,B,C,D = map(int,input().split())

taka = A//D
amt = A%D
aok = C//B
ama = C%B

if amt>0:
    taka+=1

if ama>0:
    aok +=1


if taka>=aok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9156
let () = Scanf.scanf "%d\n%s" @@ fun n s ->
  let dp =
    [| Array.make 10 0;
       Array.make 100 0;
       Array.make 1000 0 |] in
  for i = 0 to n - 1 do
    let d0 = Char.code s.[i] - Char.code '0' in
    for d21 = 0 to 99 do
      dp.(2).(10 * d21 + d0) <- dp.(1).(d21) lor dp.(2).(10 * d21 + d0)
    done;
    for d1 = 0 to 9 do
      dp.(1).(10 * d1 + d0) <- dp.(0).(d1) lor dp.(1).(10 * d1 + d0)
    done;
    dp.(0).(d0) <- 1
  done;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 dp.(2)



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, m;

int main() {
    cin >> n >> m;
    cout << n * n - m << endl;
    return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int dp[101][100001];
int p[101][100001];

int32_t main(){
	fast;
	int n,k;
	cin >> n >> k;
	
	int a[n+1];
	
	for(int i=1 ; i<=n ; i++)
		cin >> a[i];

	for(int i=0 ; i<=n ; i++)
		dp[i][0] = p[i][0] = 1;

	for(int i=0 ; i<=k ; i++)
		p[0][i] = 1;

	for(int i=1 ; i<=n ; i++)
	{
		for(int j=1 ; j<=k ; j++)
		{
			dp[i][j] = p[i-1][j] %MOD;
			if(j - a[i] - 1 >= 0)
				dp[i][j] = (dp[i][j] - p[i-1][j - a[i] - 1] + MOD)%MOD;
			p[i][j] = dp[i][j];
			if(j > 0)
				p[i][j] = (p[i][j] + p[i][j-1])%MOD;
		}
	}
	cout << dp[n][k];
}



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

int w[100005];
int main() {
	int n, k; scanf("%d%d", &n, &k);
	rep(i, n)scanf("%d", &w[i + 1]);
	for (int i = 1; i <= n; i++)w[i] += w[i - 1];
	int a = 0, b = INT_MAX;
	while (a != b) {
		int t = (a + b) / 2;
		int cnt = 0, i = 0;
		while (i < n&&++cnt <= k) {
			i = upper_bound(w, w + n + 1, w[i] + t) - w - 1;
		}
		if (cnt > k)a = t + 1;
		else b = t;
	}
	printf("%d\n", a);
}

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

vector<vector<int>> edge;
vector<int> tp;

void dfs(int now, int par) {
    tp.push_back(now);
    for (int nxt : edge[now]) {
        if (nxt != par) dfs(nxt, now);
    }
    return;
}

int main(){
    int N;
    cin >> N;
    edge.resize(N);
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dfs(0, -1);
    int ans = 0; 
    vector<bool> visit(N, false), cexist(N, false), pneed(N, false);
    for (int i = N-1; i >= 0; i--) {
        int now = tp[i];
        visit[now] = true;
        int cs = 0, ca = 0, onechild = -1, pn = 0;
        for (int child : edge[now]) {
            if (!visit[child]) continue;
            cs++;
            onechild = child;
            if (cexist[child]) {
                cexist[now] = true;
                ca++;
            }
            if (pneed[child]) pn++;
        }
        bool nw = false;
        if (cs - ca >= 2) {
            ans += cs-ca-1;
            ca = cs-1;
            nw = true;
            cexist[now] = true;
            pneed[now] = true;
        }else if (cs - ca == 1) {
            pneed[now] = true;
        }else if (cs == 1 && pneed[onechild]){
            pneed[now] = true;
        }else if (cs == 0) {
            pneed[now] = true;
        }
        if (i == 0 && pn >= 2 && ca <= 1 && !nw) ans++;
        //cout << now << " " << ans << endl;
    }
    if ((int)edge[0].size() == 1 && pneed[0]) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10872
#include <iostream>
#include <vector>
#include <algorithm>
//#include <ios>
//#include <iomanip>
using namespace std;

int N, K;

int main() {
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    
    int answer = 1000000000;
    for (int i = 0; i < N - K + 1; i++) {
        int difference = *(h.begin() + K + i - 1) - *(h.begin() + i);
        if (difference < answer) {
            answer = difference;
        }
    }
    cout << answer << endl;
}

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

int main(){
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    long double s = (double)w * (double)h  / (double)2.0;
    int ism = ((x+x == w) && (y+y == h)) ? 1 : 0;
    cout << fixed << setprecision(10) << s;
    cout <<  " " << ism << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
	Scanner stdIn = new Scanner(System.in);
		int a=stdIn.nextInt();
		int b=stdIn.nextInt();
		
	if(b>=a){
		System.out.println(a);
	}
	else
		System.out.println(a-1);
	}

}


Measured memory_bytes: 21716
#include <stdio.h>
#include <math.h>

int main()
{
    int i, n;
    int s[1000], sum, t;
    double a, m;
    while(1) {
        scanf("%d", &n);
        if(n==0) break;
        sum=0;
        for(i=0; i<n; i++) {
            scanf("%d", &t);
            sum+=t;
            s[i]=t;
        }
        m=(double)sum/n;
        a=0;
        for(i=0; i<n; i++) {
            a+=(s[i]-m)*(s[i]-m);
        }
        printf("%f\n", sqrt(a/n));
    }
    return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool prime_judge(ll n){
    for (ll i = 2; i*i <= n; i++){
        if (n%i == 0){
            return false;
        }
    }
    return true;
}

vector<ll> divisors_list(ll n){
    vector<ll> res;
    for (ll i = 1; i*i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (n/i != i){
                res.push_back(n/i);
            }
        }
    }
    sort(all(res));
    return res;
}

int main(){
    ll n;
    scanf("%lld", &n);
    int ans = 0;
    for (int i=1; i<=n; i += 2){
      vector<ll> div = divisors_list(i);
      if (div.size() == 8) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, q;
    cin >> n >> q;
    VL a(n);
    REP(i,n) a[i] = in();
    VL s(n+1), s2(n+2);
    REP(i,n) s[i+1] = s[i] + a[i];
    s2[1] = a[0];
    FOR(i,2,n) s2[i] = s2[i - 2] + a[i - 1];

    vector<PL> xx(q);
    REP(i,q) xx[i] = PL(in(), i);
    sort(ALL(xx));
    reverse(ALL(xx));

    VL ans(q);
    ll c = 1;

    REP(t,q){
        ll x = xx[t].first;

        while (true){
            ll r = n - c - 1;
            ll l = n - 2 * c;
            if (l <= 0){
                break;
            }
            if (a[r] - x >= x - a[l - 1]){
                c++;
            }else{
                break;
            }
        }

        ll tmp = s[n] - s[n - c];
        ll l = n - 2 * c;
        if (l > 0) tmp += s2[l];
        ans[xx[t].second] = tmp;
    }

    REP(i,q){
        printf("%lld\n", ans[i]);
    }

    return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
int dp[1<<18][2];
int main(){
	int n, a;
	scanf("%d", &n);
	for(int i=0;i<(1<<n);i++){
		scanf("%d", &a);
		dp[i][0] = a;
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<(1<<n);j++){
			if((j>>i)&1){
				dp[j][1] = max(dp[j][1], dp[j][0]+dp[j^(1<<i)][0]);
				dp[j][0] = max(dp[j][0], dp[j^(1<<i)][0]);
			}
		}
	}
	int ans = 0;
	for(int i=1;i<(1<<n);i++) ans = max(ans, dp[i][1]), printf("%d\n", ans);
}

Measured memory_bytes: 5120
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

const int MAXN = 5005 * 5005;
int dp[MAXN];

class DSquirrelMerchant {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    int g[2][3];

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        REP(i, 2) {
            REP(j, 3) {
                cin >> g[i][j];
            }
        }

        REP(i, N + 1) {
            dp[i] = i;
            REP(j, 3) {
                if (i < g[0][j]) continue;
                dp[i] = max(dp[i], dp[i - g[0][j]] + g[1][j]);
            }
        }
        N = dp[N];

        CLR(dp, 0);
        REP(i, N + 1) {
            dp[i] = i;
            REP(j, 3) {
                if (i < g[1][j]) continue;
                dp[i] = max(dp[i], dp[i - g[1][j]] + g[0][j]);
            }
        }
        cout << dp[N] << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DSquirrelMerchant solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 195968
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>
using namespace std;
int main()
{
	int n,a[100005];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	long long nowa=0,sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
		if(i%2==0)
		{
			if(sum<=0)
			{
				nowa+=1-sum;
				sum=1;
			}
		}
		else
		{
			if(sum>=0)
			{
				nowa+=sum+1;
				sum=-1;
			}
		}
	}
	long long ans=nowa;
	nowa=0;
	sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
		if(i%2==1)
		{
			if(sum<=0)
			{
				nowa+=1-sum;
				sum=1;
			}
		}
		else
		{
			if(sum>=0)
			{
				nowa+=sum+1;
				sum=-1;
			}
		}
	}
	cout<<min(ans,nowa);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define INF 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main(){
    FAST_IO;
    ll _=1;
    //cin>>_;
    for(ll ii=1;ii<=_;ii++)
    {
        ll a,b,c,k,sum=0;
        cin>>a>>b>>c>>k;
        int A=1,B=0,C=-1;
        while(k--){
            if(a>0){sum+=A;a--;}
            else if(b>0){sum+=B;b--;}
            else if(c>0){sum+=C;c--;}
        }
        cout<<sum<<endl;
	}
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
	// your code goes here
	string a, b; cin >> a >> b;
	int length = b.length();
	int max = 0;
	for (int i = 0; i < a.length() - length + 1; i++) {
	    int cur_max = 0;
	    string str = "";
	    for (int x = 0; x < length; x++) {
	        if (b[x] == a[i + x]) {
	            cur_max++;
	        }
	    }
	    
	    if (cur_max > max) {
	        max = cur_max;
	    }
	    
	}
	cout << length - max;
	
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int cal(char t[])
{
    int ans=0,n=strlen(t+1);
    for(int i=1;i<=n/2;++i)
    {
        if(t[i]!=t[n-i+1])
            ans++;
    }
    return ans;
}
char t[10005];
int main()
{
    scanf("%s",t+1);
    cout<<cal(t)<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	s, err := nextInts(n, sc)
	if err != nil {
		panic(err)
	}
	q, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	t, err := nextInts(q, sc)
	if err != nil {
		panic(err)
	}
	fmt.Println(linearSearch(s, t))
}

func linearSearch(s, t []int) int {
	count := 0
	for _, v := range t {
		for _, w := range s {
			if w == v {
				count++
				break
			}
		}
	}
	return count
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func nextInts(n int, sc *bufio.Scanner) ([]int, error) {
	ns := make([]int, n)
	for i, _ := range ns {
		x, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		ns[i] = x
	}
	return ns, nil
}



Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define chmax(x, y) x = max(x, y) 
int a[3005][3005] ;
ll dp[3005][3005][4] ;
int main() {
    int R, C, n ;
    cin >> R >> C >> n ;
    rep(i, n){
        int r, c, v ;
        cin >> r >> c >> v ;
        a[r-1][c-1] = v ;
    }
    rep(i, R){
        rep(j, C){
            for(int k = 2; k >= 0; k--){
                chmax(dp[i][j][k+1], dp[i][j][k]+ a[i][j]) ;
            }
            rep(k, 4){
                chmax(dp[i+1][j][0], dp[i][j][k]) ;
                chmax(dp[i][j+1][k], dp[i][j][k]) ;
            }
        }
    }
    ll ans = 0 ;
    rep(k, 4){
        chmax(ans, dp[R-1][C-1][k]) ;
    }
    cout << ans << endl ;
} 

Measured memory_bytes: 320588
N = int(input())
D, X = map(int, input().split())
A = [0] * N
for i in range(N):
    A[i] = int(input())
ans_list = []

for i in range(N):
    tmp = 1
    tmp += (D - 1) // A[i]
    ans_list.append(tmp)

ans = X + sum(ans_list)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <unordered_set>
#include <utility>
using namespace std;

const int M = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% M + M) % M) {};
	void operator += (const mll& a) {
		if ((x += a.x) >= M) x -= M;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= M;
	}
	mll inv() {
		long long a = x, 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;
		a = u;
		return mll(a);
	}
};

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	int tento_in = 0;
	int tento_out = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (A[i] > A[j]) {
				tento_out++;
				if (i < j)tento_in++;
			}
		}
	}
	mll ans = tento_in;
	ans *= K;
	mll ans2 = tento_out;
	ans2 *= K;
	ans2 *= (long long)(K - 1);
	ans2 *= mll(2).inv();
	ans += ans2;
	cout << ans.x << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
bitset<701> exi;
vector<int> G[700],cG[700];
int main() {
	int n, m; cin >> n >> m;
	int a, b;
	rep(i, m) {
		cin >> a >> b; a--; b--;
		G[a].push_back(b); G[b].push_back(a);
	}
	rep(i, n) {
		int used[700] = {};
		int len = G[i].size();
		rep(j, len) {
			used[G[i][j]] = 1;
		}
		rep(j, n) {
			if (i == j)continue;
			if (!used[j]) {
				cG[i].push_back(j);
			}
		}
	}
	int used[700] = {};
	bool g = true;
	queue<P> que;
	rep(i, n) {
		if (used[i])continue;
		used[i] = 1;
		bool chk = true;
		queue<int> q; q.push(i);
		int cnt1 = 0; int cnt2 = 0;
		while (!q.empty()) {
			int len = q.size();
			if (chk)cnt1 += len;
			else cnt2 += len;
			rep(j, len) {
				int nex = q.front(); q.pop();
				int len2 = cG[nex].size();
				rep(k, len2) {
					int v = cG[nex][k];
					if (used[v]) {
						if ((chk&&used[v] == 1) || ((!chk) && used[v] == -1))g = false;
						continue;
					}
					if (chk)used[v] = -1;
					else used[v] = 1;
					q.push(v);
				}
			}
			chk = !chk;
		}
		que.push({ cnt1,cnt2 });
	}
	if (!g) {
		cout << -1 << endl;
	}
	else {
		exi[0] = 1;
		int len = que.size();
		rep(i, len) {
			P nex = que.front(); que.pop();
			int x = nex.first; int y = nex.second;
			exi = (exi << x) | (exi << y);
		}
		int mi = (int)MOD;
		rep(i, n + 1) {
			if (exi[i]) {
				int csum1 = i * (i - 1) / 2;
				int csum2 = (n - i)*(n - i - 1) / 2;
				mi = min(mi, csum1 + csum2);
			}
		}
		cout << mi << endl;
	}
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int k, x;
	cin >> k >> x;
	for(int i=x-k+1; i<=x+k-1; i++) cout << i << ' '; 
	return 0;
}


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

int main() {
  int d,N,K;
  cin >> N >> K;
  vector<int> S(N);
  
  
  for(int i=0;i < K;i++) {
    cin >> d;
    for(int j=0;j < d;j++) {
      int A;
      cin >> A;
      S.at(A-1)++;
    }
  }
  
  int count=0;
  
  for(int i=0;i < N;i++) {
    if(S.at(i)==0)
      count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  map<int, int> fs;
  int x;
  while (scanf("%d", &x) == 1)
    fs[x]++;
  int c = 0;
  vector<int> rs;
  for (map<int, int>::iterator it = fs.begin(); it != fs.end(); ++it) {
    if (it->second == c)
      rs.push_back(it->first);
    if (it->second > c) {
      rs.clear();
      rs.push_back(it->first);
      c = it->second;
    }
  }
  for (int i = 0; i < rs.size(); i++)
    printf("%d\n", rs[i]);
  return 0;
}

Measured memory_bytes: 0
// 作者：杨成瑞先生
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        String s = sc.nextLine();

        if(s.length() < 4) {
            pw.println("No");
        }
        else {
            pw.println(s.substring(0, 4).equals("YAKI") ? "Yes" : "No");
        }
        
        pw.close();
	}

}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

using mint = modint998244353;

mint table[10][MAX];
mint table_ten[MAX];

struct S {
    mint n;
    int size;
};

struct F {
    int d;
    bool id;
};

S op(S a, S b) {
    return S{a.n * table_ten[b.size] + b.n, a.size + b.size};
}

S e() { return S{0, 0}; }

S mapping(F l, S r) {
    return (l.id)? r : S{table[l.d][r.size], r.size};
}

F composition(F l, F r) { return (l.id)? r : l; }

F id() { return F{'0', true}; }

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

    for (int i = 1; i < 10; ++i) {
        rep(j, N) {
            table[i][j+1] = table[i][j] * 10 + i;
        }
    }

    table_ten[0] = 1;
    rep(i, N) table_ten[i+1] = table_ten[i] * 10;

    vector<S> v(N);
    rep(i, N) v[i] = {1, 1};
    lazy_segtree<S, op, e, F, mapping, composition, id> st(v);

    rep(i, Q) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;

        st.apply(l, r, F{d, false});
        cout << st.all_prod().n.val() << endl;
    }
}

Measured memory_bytes: 19604
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repN(i,n) for(int i = (n); i > 0; --i)
#define rep2(i,s,n) for(int i = s; i < (n); ++i)
#define rep2N(i,e,n) for(int i = e; i < ((e) - (n)); --i)

typedef long long i64;
typedef unsigned long long u64;
typedef boost::multiprecision::int128_t i128;
typedef boost::multiprecision::uint256_t u256;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF BIG_PRIME

int A[3][3];
int open[3][3];
int b[12];
int N;

void Solve()
{
  for (int k = 0; k < N; ++k){
    for (int i = 0; i < 3; ++i){
      for (int j = 0; j < 3; ++j){
        if (A[i][j] == b[k]){
          open[i][j] = 1;
        }
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < 3; ++i)
    if (open[i][0] + open[i][1] + open[i][2] == 3) ++ans;
  for (int j = 0; j < 3; ++j)
    if (open[0][j] + open[1][j] + open[2][j] == 3) ++ans;
  if (open[0][0] + open[1][1] + open[2][2] == 3) ++ans;
  if (open[0][2] + open[1][1] + open[2][0] == 3) ++ans;

  if (ans) puts("Yes");
  else puts("No");
}

void Init()
{
    for (int i = 0; i < 3; ++i){
      for (int j = 0; j < 3; ++j){
        cin >> A[i][j];
        open[i][j] = 0;
      }
    }
    cin >> N;
    for (int i = 0; i < N; ++i)
      cin >> b[i];
}

void Clean(){}

int main(){ Init(); Solve(); Clean(); return 0; }


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

num_minus = [a < 0 for a in A].count(True)

B = [abs(a) for a in A]

if num_minus%2 == 0:
    print(sum(B))
else:
    b = sorted(B)[0]
    print(sum(B) - 2*b)


Measured memory_bytes: 98280
package main

import (
	"fmt"
	"io"
	"os"
	"runtime"
)

type query struct {
	T int
	F int
	C byte
}

func calc(qq []query) ([]byte, []byte, bool) {
	head := true
	left := make([]byte, 0)
	right := make([]byte, 0)
	for _, que := range qq {
		if que.T == 1 {
			head = !head
		} else {
			if (head && que.F == 1) || (!head && que.F == 2) {
				left = append(left, que.C)
			} else {
				right = append(right, que.C)
			}
		}
	}
	return left, right, head
}

func run(input io.Reader, output io.Writer) int {
	var s string
	fmt.Scanf("%s\n", &s)
	var q int
	fmt.Scanf("%d\n", &q)
	var qq []query
	for i := 0; i < q; i++ {
		var t int
		var f int
		var c byte
		fmt.Scanf("%d", &t)
		if t == 1 {
			if runtime.GOOS == "windows" {
				fmt.Scanf("\n")
			}
		} else {
			fmt.Scanf("%d %c\n", &f, &c)
		}
		qq = append(qq, query{T: t, F: f, C: c})
	}

	left, right, head := calc(qq)

	if head {
		for i := len(left) - 1; i >= 0; i-- {
			fmt.Printf("%c", left[i])
		}
		fmt.Print(s)
		for i := 0; i < len(right); i++ {
			fmt.Printf("%c", right[i])
		}
		fmt.Println()
	} else {
		for i := len(right) - 1; i >= 0; i-- {
			fmt.Printf("%c", right[i])
		}
		for i := len(s) - 1; i >= 0; i-- {
			fmt.Printf("%c", s[i])
		}
		for i := 0; i < len(left); i++ {
			fmt.Printf("%c", left[i])
		}
		fmt.Println()
	}
	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 22016
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    if(x1 == 0)
    cout << "1";
    else if(x2 == 0)
    cout << "2";
else if(x3 == 0)
    cout << "3";
    else if(x4 == 0)
    cout << "4";
    else
    cout << "5";
    return 0;
}



Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
 
#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
 
#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)
 
typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)
 
#define S_RTN(S)  s_cout(S);return 0
 
 
#define _itoa(A,N) sprintf(A, "%d", N);
 
int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);
 
int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);
 
 
int s_asorts(const void* a, const void* b);
 
//昇順
int s_asorts(const void* a, const void* b) {
    return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
    return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
    return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
    int i;
    rept(i, 0, n) {
        l_cin2(*(a + i), *(b + i));
    }
    return 0;
}
int i_cins(int n, int* a) {
    int i;
    for (i = 0; i < n; i++) {
        i_cin(*(a + i));
    }
 
    return 0;
}
int _gcd(int a, int b) {
    int r, tmp;
    if (a < b) { tmp = a; a = b; b = tmp; }
    r = a % b;
    while (r) {
        if (!r) break;
        a = b; b = r;
        r = a % b;
    }
    return(b);
}
 
long _max(long a, long b) {
    return a > b ? a : b;
}
long _min(long a, long b) {
    return a < b ? a : b;
}
int _swp(int* a, int* b)
{
    int tmp;
    tmp = *b; *b = *a; *a = tmp;
    return 0;
}

int compare_int(const void *a, const void *b)
{
    return *(long long*)b - *(long long*)a;
}





int main(){
    int N,K;
    ll sum=0;
    i_cin2(N,K);
    ll H[N];
    rept(i,0,N)
    scanf("%lld",&H[i]);
    qsort(H,N,sizeof(long long),compare_int);
    rept(i,K,N)
    sum+=H[i];
    printf("%lld",sum);
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for(int i = m; i < (n); ++i)
#define pb push_back

int main()
{
    string str;
    
    while(getline(cin, str) && str != ".")
    {
        int t;
        stack<int> st;
        
        rep(i, str.size()) {
            switch (str[i]) {
                case '(':
                    st.push(1);
                    break;
                case '[':
                    st.push(2);
                    break;
                case ')':
                    if(st.empty()) goto no;
                    t = st.top(); st.pop();
                    if(t != 1) goto no;
                    break; 
                case ']':
                    if(st.empty()) goto no;
                    t = st.top(); st.pop();
                    if(t != 2) goto no;
                    break; 
            }
        }
        if(!st.empty()) goto no;
        cout << "yes" << endl;
        continue;
    no:;
        cout << "no" << endl;
    }
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n, m;
    cin >> n >> m;
    vvi s(m);
    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int x;
            cin >> x;
            --x;
            s[i].push_back(x);
        }
    }
    vi p(m);
    rep(i, m) cin >> p[i];
    
    int ans = 0;
    rep(bit, (1 << n)) {
        bool ok = true;
        rep(i, m) {
            int cnt = 0;
            for(auto v : s[i]) {
                if(bit & (1 << v)) cnt++;
            }
            if(cnt % 2 != p[i]) ok = false;
        }
        if(ok) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

namespace Math_Functions
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ');
            var a = double.Parse(x[0]);
            var b = double.Parse(x[1]);
            var c = double.Parse(x[2]);

            var t = (c * Math.PI) / 180;

            Console.Write("{0:F4}\n{1:F4}\n{2:F4}\n",
                          0.5 * a * b * Math.Sin(t),
                          a + b + Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(t)),
                          b * Math.Sin(t));
        }
    }
}

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

int main()
{
	long long a;
	long double b;
	
	cin>>a>>b;
	
	long long c=a*b;
	cout<<c<<endl;
/*	int x=b[0]-48;
	int y=b[2]-48;
	int z=b[3]-48;
	
	long long c=0ll;
	c+=a*x;
	c+=a/10ll*y;
	c+=a/100ll*z;
	cout<<c<<endl;*/
	return 0;
}

Measured memory_bytes: 3736
"""
NTC here
"""
import sys
inp= sys.stdin.readline
input = lambda : inp().strip()
flush= sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**25)

def iin(): return int(input())
def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input


def main():
    from bisect import bisect as br
    n, d, A= lin()
    a = [lin() for i in range(n)]
    a.sort()
    a+= [[10**9+1+2*d,0]]
    a1=[i for i, j in a ]
    a2 = [0]*(n+1)
    ch = 0
    ans = 0
    for i in range(n):
        ch -= a2[i]
        x = a[i][1]-A*ch
        if x>0:    
            pos = a[i][0]
            r = br(a1, pos+2*d)
            amt = (x+A-1)//A
            a2[r]+=amt
            ch += amt
            ans += amt
    print(ans)





            
        

        
main()
# threading.Thread(target=main).start()


Measured memory_bytes: 88028
n = int(input())
a = []
for i in range(n):
  a.append(input())
print('AC x ' + str(a.count('AC')))
print('WA x ' + str(a.count('WA')))
print('TLE x ' + str(a.count('TLE')))
print('RE x ' + str(a.count('RE')))

Measured memory_bytes: 16212
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //System.setIn(Main.class.getResourceAsStream("input"));
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        int h = sc.nextInt();
        int a = sc.nextInt();
        System.out.println(h/a + (h%a==0 ? 0 : 1));
    }

    private static int nextInt(Scanner sc) {
        return Integer.valueOf(sc.nextLine());
    }

    private static int[] toArray(String text) {
        return Arrays.stream(text.split("\\s")).mapToInt(Integer::valueOf).toArray();
    }

}

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

int main(){
	
	int ans[10010] = {};
	ans[0] = 1;
	for( int i=1 ; i<=10000 ; i++ ){
		ans[i] = ans[i-1] + i ;
	}
	
	int N;
	while( cin >> N ){
		if( cin.eof() ) break ;
		cout << ans[N] << endl ;
	}
	
	return 0 ;
}

Measured memory_bytes: 1204
import sys
input = sys.stdin.readline
N = int(input())
a = [tuple(map(int, input().split())) for _ in range(N)]
a.sort(key = lambda x: -(x[0] + x[1]))

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

for i in range(N):
  w, s, c = a[i]
  for j in range(a[0][1] + a[0][0] + 1):
    if j >= w:
      x = min(j - w, s)
      dp[x] = max(dp[x], dp[j] + c)
print(max(dp))

Measured memory_bytes: 42604
#include<bits/stdc++.h>
#define ll long long
#define fs first
#define sec second
#define md 1000000007
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
using namespace std;
ll power(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p  
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll T=1;
    // cin>>T;
    while(T--){
    	ll n;
        cin>>n;
        vector<ll> v(n);
        ll s=0;
        for(ll i=0;i<n;i++){
            cin>>v[i];
            s=(s+v[i])%md;
        }
        ll ans=0;
        for(ll i=0;i<n;i++){
            s=(s-v[i]+md)%md;
            ans=(ans+(s*v[i])%md)%md;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 4668