akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using P=pair<int,int>;
using PP=pair<P,P>;
using ll=long long;
int main(){
    int n;
    cin>>n;
    ll ret=0,now=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a==0){
            ret+=now/2;
            now=0;
        }else{
            now+=a;
        }
    }
    ret+=now/2;
    cout<<ret<<endl;
}

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

using namespace std;

int main() {
    string S;
    cin >> S;
    int f = stoi(S.substr(0, 2)), b = stoi(S.substr(2, 4));
    if (1 <= f && f <= 12) { // f is MM
        if (1 <= b && b <= 12) cout << "AMBIGUOUS" << endl;
        else if (b == 0 || (12 < b && b <= 99)) cout << "MMYY" << endl;
        else cout << "NA" << endl;
    } else if (f == 0 || (12 < f && f <= 99)) { // f is YY
        if (1 <= b && b <= 12) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    } else cout << "NA" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

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

long long power(long long x, long long y, long long p)
{
long long res = 1;


x = x % p;


while (y > 0)
{
if (y & 1)
res = (res*x) % p;


y = y>>1;
x = (x*x) % p;
}
return res;
}


const int N=2e5+5;
 const int M=998244353;
ll fac[N];


void compute()
{
    fac[0]=1;
    fac[1]=1;
    ll i;
    for(i=2;i<N;i++)
    {
        fac[i]=fac[i-1]*i;
        fac[i]%=M;
    }
   
}

long long modInverse(long long n, long long p)
{
return power(n, p-2, p);
}


long long ncrp(long long n, long long r, long long p)
{


if (r==0)
return 1;




 return (fac[n]* modInverse(fac[r], p) % p *modInverse(fac[n-r], p) % p) % p;
}

void solve()
{
   ll n,m,k;
   cin>>n>>m>>k;
   compute();
   ll p;
   ll res=0;
   for(p=n-k;p<=n;p++)
   {
       ll tans=ncrp(n-1,p-1,M);
       tans%=M;
       ll tans2=(m*(power(m-1,p-1,M)));
       tans2%=M;
       tans*=tans2;
       tans%=M;
       res+=tans;
    //    cout<<tans<<"\n";
       res%=M;
   }
   cout<<res<<"\n";
  


}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 5192
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))

n = int(input())
for _ in range(n):
    b = int(input())

    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0

if a[0][0] == a[0][1] == a[0][2] == 0 or a[1][0] == a[1][1] == a[1][2] == 0 or a[2][0] == a[2][1] == a[2][2] == 0 \
   or a[0][0] == a[1][0] == a[2][0] == 0 or a[0][1] == a[1][1] == a[2][1] == 0 or a[0][2] == a[1][2] == a[2][2] == 0 \
   or a[0][0] == a[1][1] == a[2][2] == 0 \
   or a[0][2] == a[1][1] == a[2][0] == 0:
    print("Yes")
else:
    print("No")


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

int dp[100000];

int main() {

  int n;
  int h[100000];

  cin >> n;

  for ( int i = 1; i <= n; ++i ) {
    cin >> h[i];
  }

  dp[0] = 10001;

  // 必ず"足場1"から始まるためi=2に設定(場合によって"足場2"から始まってしまう場合があるから)
  for ( int i = 2; i <= n; ++i ) {
    // absは絶対値
    dp[i] = min ( dp[i-2] + abs(h[i-2] - h[i]), 
                  dp[i-1] + abs(h[i-1] - h[i]) );
  }

  cout << dp[n] << endl;

  return 0;

}


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

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

typedef long long Int;

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> A(n);
    Int sum = 0;
    Int r;
    rep(i,n) {
        cin >> A[i];
        sum += A[i];
        if (i == 0) r = A[i];
        else r = max(r, A[i]);
    }
    Int l = sum / (n + k);
    if (l == 0) l++;

    Int nowl = 0;
    rep(i,n) {
        nowl += (A[i] - 1) / l;
    }
    if (nowl <= k) {
        cout << l << endl;
        return 0;
    }

    while(true) {
        Int c = (l + r) / 2;
        Int nowc = 0;
        rep(i,n) {
            nowc += (A[i] - 1) / c;
        }
        if (nowc <= k) {
            r = c;
        }
        else {
            l = c;
        }
        if (r == l + 1) break;
    }
    cout << r << endl;
    return 0;

}


Measured memory_bytes: 4684
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    X, K, D = MI()


    if D*K > abs(X):
        n = K-X//D
        if n % 2 == 0:
            ans = X%D
        else:
            ans = D-X%D
    
    else:
        ans = abs(X) - D*K



    
    print(ans)

if __name__ == "__main__":
	main()

Measured memory_bytes: 9196
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
const int mx = 1000 * 100 + 5;
vector < int > ad[mx];
int col[12][mx], v[mx], d[mx], c[mx];
void dfs(int v, int d, int c){
	if(col[d][v])
		return;
	col[d][v] = c;
	if(!d)
		return;
	dfs(v , d - 1, c);
	for(auto u : ad[v])
		dfs(u , d - 1, c);
	return;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	int n, m, q, a, b;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		a--, b--;
		ad[a].pb(b);
		ad[b].pb(a);
	}
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}
	for(int i = q - 1; i >= 0; i--)
		dfs(v[i] , d[i] , c[i]);
	for(int i = 0; i < n; i++)
		cout << col[0][i] << endl;
	return 0;
}



Measured memory_bytes: 18676
#include<deque>
#include<string>
#include<iostream>

using namespace std;

int main()
{
	int n;	cin>>n;
	while(n--){
		string tr;	cin>>tr;
		deque<char> dq(1,tr[0]);
		deque<char>::iterator it=dq.begin();

		for(int i=1;i<tr.length();i+=3){
			if(tr[i]=='-'){	// forward
				it++;
				if(it==dq.end())	dq.push_back(tr[i+2]);
			}
			else{			// backward
				if(it==dq.begin())	dq.push_front(tr[i+2]);
				it--;
			}
		}

		for(it=dq.begin();it!=dq.end();it++)	cout<<*it;
		cout<<endl;
	}

	return 0;
}

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

int main(){
  int n,res=0;
  cin >> n;
  for(int i=1;i<=9;i++){
    for(int k=1;k<=9;k++){      
      if(n==i*k)res=1;
    }
  }
  if(res){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N, as[MAX_N];
  scanf("%ld", &N);
  for (int i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }

  // solve
  long ans = 0;
  for (int i = 0; i < N - 1; i++) {
    const long num_self = as[i] / 2;
    as[i] -= 2 * num_self;
    ans += num_self;
    const long num_next = min(as[i], as[i + 1]);
    as[i] -= num_next;
    as[i + 1] -= num_next;
    ans += num_next;
  }
  ans += as[N - 1] / 2;
  printf("%ld\n", ans);
  
  return 0;
}


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

#define int long long
#define debug(x) cout<<#x<<" "<<x<<endl;

const int N=1e6+5;
const double eps=1e-9;
const int INF=1e18;

int f(int x){
    if(x==1) return 1;
    return 2ll*f(x/2)+1;
}

signed main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int x;cin>>x;
    cout<<f(x)<<endl;
    return 0;
}

//Created Time  :2020/1/26 20:09:32


Measured memory_bytes: 256
#include<bits/stdc++.h>
# define mp make_pair
# define ll long long int
# define INF 10e9+7
using namespace std;

main()
{
  int n,w;
  cin>>n>>w;
  int x,y;
  pair<int,int> p[n+1];
  p[0]=mp(0,0);
  ll sum=0;
  for(int i=1;i<=n;++i) cin>>x>>y,sum+=y,p[i]=mp(x,y);
  ll dp[n+1][sum+1]={};
  for(int i=0;i<=n;++i) for(int j=1;j<=sum;++j) dp[i][j]=INF;
  
  for(int i=1;i<=n;++i)
  {
  	for(int j=1;j<=sum;++j)
  	{
      dp[i][j]=dp[i-1][j];
      if(p[i].second<=j) dp[i][j]=min(dp[i][j],p[i].first+dp[i-1][j-p[i].second]);
  	}
  }
  int ans=0;
  for(int i=0;i<=sum;++i) 
  	if(dp[n][i]<=w) ans=i;
  cout<<ans;
}

Measured memory_bytes: 79104
W=input()
W=W.lower()
list1=[]

for i in range(1001):
    S=input()
    if S=="END_OF_TEXT":
        break
    else:
        S=S.lower()
        S=S.rstrip().split(" ")
        for j in range(len(S)):
            list1.append(S[j])
print(list1.count(W))


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

const ll INF = 1LL << 60;
const int MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

struct UnionFind {
    vi par, rank;

    UnionFind(int n) {
        par.resize(n); rank.resize(n, 0);
        REP(i, n) par[i] = i;
    }

    int find(int x) {
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int N, M;
vi X, Y, Z;
int main() {
    cin >> N >> M;
    X.resize(M); Y.resize(M); Z.resize(M);
    REP(i, M) cin >> X[i] >> Y[i] >> Z[i];

    UnionFind uf(N);

    REP(i, M) {
        uf.unite(X[i] - 1, Y[i] - 1);
    }
    set<int> s;
    REP(i, N) s.insert(uf.find(i));

    int ans = s.size();
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6912
# -*- coding: utf-8 -*-
h, w = map(int, input().split())
grid = []

for i in range(h):
    grid.append(list(input()))

for i in range(h):
    for j in range(w):
        if grid[i][j] == '#':
            # 左右のマスをチェック
            if 0 < j and grid[i][j-1] == '#':
                continue
            if j < (w - 1) and grid[i][j+1] == '#':
                continue
            # 上下のマスをチェック
            if 0 < i and grid[i-1][j] == '#':
                continue
            if i < (h - 1) and grid[i+1][j] == '#':
                continue
            # 接するマスに#がなかった場合は終了
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3064
b=list(input())
t=[]
for i in range(len(b)):
    if b[i]=='A':
        t+=['T']
    elif b[i]=='T':
        t+=['A']
    elif b[i]=='G':
        t+=['C']
    elif b[i]=='C':
        t+=['G']
t=''.join(t)
print(t)

Measured memory_bytes: 2940
A, B, C = [int(x) for x in input().split()]
K = int(input())
i = 0
while 1:
    if (A >= B):
        B *= 2
        i += 1
    elif (B >= C):
        C *= 2
        i += 1
    else:
        break
print('Yes' if i <= K else 'No')


Measured memory_bytes: 61684
from collections import *
from heapq import *
from itertools import *
from fractions import gcd

from decimal import *
import copy
from bisect import *
import time
import sys
import math
input=lambda :sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
N=int(input())
S=input()
lst=[[],[],[]]
for i in range(N):
    if S[i]=="R":
        lst[0].append(i)
    if S[i]=="G":
        lst[1].append(i)
    if S[i]=="B":
        lst[2].append(i)

Z=len(lst[0])*len(lst[1])*len(lst[2])
setlst=[set(i) for i in lst]
for x,y,z in list(permutations(range(3))):
    for a in lst[x]:
        for b in lst[y]:
            if a>b:
                continue
            if b-a + b in setlst[z]:
                Z-=1
print(Z)


Measured memory_bytes: 73752
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  ll n,T,t[200010],x=0;
  std::cin >> n >> T;
  for(int i=0; i<n; i++) std::cin >> t[i];

  for(int i=0; i<n-1; i++){
    if(t[i+1]-t[i]<T) x+=t[i+1]-t[i];
    else x+=T;
  }
  x+=T;
  std::cout << x << '\n';
  return 0;
}


Measured memory_bytes: 1792
K,A,B = (int(x) for x in input().split())
ans = 1

if B-A>2:
    if K>= A-1:
        ans += A - 1
        K -= A - 1
        if K >= 2:
            ans = ans + (B - A) * (K // 2)
            K = K % 2

ans += K

print(ans)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n, m;
	cin >> n >> m;
	int sum = 0;
	forn(i, m) {
		int x;
		cin >> x;
		sum += x;
	}
	if(sum > n) cout << -1 << endl;
	else cout << n-sum << endl;
	return 0;
}



Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int ch = 0;
        int A[] = new int[N];
        int ans[] = new int[N];
        for (int i = 0; N > i; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);
        for (int j = 1; N > j; j++) {
            if (A[j - 1] == A[j]) {
                ans[ch]++;
            } else {
                ch++;
            }
        }
        int re[] = new int[ch + 1];
        for (int z = 0; ch + 1 > z; z++) {
            re[z] = ans[z] + 1;
        }
        if (ch < K) {
            System.out.println("0");
        } else {
            int result = 0;
            Arrays.sort(re);
            for (int k = 0; ch - K >= k; k++) {
                result += re[k];
            }
            System.out.println(result);
        }
    }
}



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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	string s;
	cin >> s;
	for (int i = s.size() / 2 - 1; i >= 0; i--) {
		if (s.substr(0, i) == s.substr(i, i)) {
			cout << i * 2 << endl;
			return 0;
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main(void) {
    ll n;
    cin >> n;
    vector<P> ps(n);
    REP(i, n) {
        ll x, y;
        cin >> x >> y;
        ps[i] = {x, y};
    }

    auto c = smallest_enclosing_disc(ps);
    cout << fixed << setprecision(15) << c.first << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;


int main() {
  ll n, p;
  cin >> n >> p;
  if(n == 1) {
    cout << p << endl;
    return 0;
  }
  ll ans = 1;
  for (ll i = 2; i * i <= p; ++i) {
    if (p % i) continue;
    ll cnt = 0;
    while (p % i == 0) {
      cnt++;
      p /= i;
    }
    ans *= pow(i, cnt / n);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int x,a;
    cin >> x >>a;
    if(x<a) cout << 0 <<endl;
    else cout << 10 <<endl;
    return 0;

}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, min_r, r;
  int ans = numeric_limits<int>::min();
  cin >> n >> min_r;
  for (int i = 1; i < n; i++) {
    cin >> r;
    ans = max(ans, r - min_r);
    min_r = min(r, min_r);
  }
  cout << ans << "\n";
}


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

using namespace std;

int main(){ string S; cin >> S;
 if( S == "KIHBR" || S =="AKIHBR" || S == "KIHABR" || S == "KIHBAR" || S == "KIHBRA" || S == "AKIHABR" || S == "AKIHBAR" || S == "AKIHBRA" || S == "KIHABAR" || S == "KIHABRA" || S == "KIHBARA" || S == "AKIHABAR" || S == "AKIHABRA" || S == "AKIHBARA" || S == "KIHABARA" || S == "AKIHABARA"){ cout << "YES" << endl;}
           else{cout << "NO" << endl;}
           return 0;}

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

string S;

int main() {
    cin >> S;

    int ans = 0;
    rep(i, S.size()) {
        if (S[i] == '+') ans++;        
        if (S[i] == '-') ans--;        
    }

    cout << ans << endl;
}

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

using namespace std;

int main()
{
	string s;
	int m, h;
	
	while(true)
	{
		cin >> s;
		
		if(s == "-")
			break;
		
		scanf("%d", &m);
		
		deque<char> d;
		string out = "";
		
		for(int i = 0; i < s.size(); d.push_back(s[i]), i++);
		
		for(int i = 0; i < m; i++)
		{
			scanf("%d", &h);
		
			for(int j = 0; j < h; j++)
			{
				d.push_back(d.front());
				d.pop_front();
			}
		}
		
		deque<char>::iterator it;
		
		for(it = d.begin(); it != d.end(); it++)
			out += *it;
		
		cout << out << "\n";
	}
	
	return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(n);
    rep(i,0,n)scanf("%d",&a[i]);
    ll ans=0;
    rep(p,1,n){
        ll sub=0; int lb=0,rb=n-1;
        if((n-1)%p==0){
            while(lb<rb){
                sub+=a[lb]+a[rb];
                chmax(ans,sub);
                lb+=p; rb-=p;
            }
        }
        else{
            while(lb<n-1-p){
                sub+=a[lb]+a[rb];
                chmax(ans,sub);
                lb+=p; rb-=p;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 100005
int a[MAX],b[MAX],c[MAX],dp[MAX][3];
signed main()
{
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	for(i=1;i<=n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

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

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

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


int main(){
  ll a,b;
  cin >>a>>b;
  ll ans = lcm(a,b);
  cout <<lcm(a,b)<<endl;

}


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

const int INF = 999999999;
const int rot[] = {4, 1, 4, 1, 2, 1, 2, 1};

int main ()
{
    int n[8];
    while (cin >> n[0]) {
        for (int i = 1; i < 8; i++) cin >> n[i];
        int min_c = INF, min_n = INF;
        int res = 0;
        for (int i = 0; i < 8; i++) {
            int c = 0, num = 0;
            int LL = 10000000;
            for (int j = 0; j < 8; j++) {
                int k = (j + i) % 8;
                int t = n[j] - rot[k];
                if (t > 0) c += t;
                num += rot[k] * LL;
                LL /= 10;
            }
            if (min_c > c) {
                min_c = c;
                min_n = num;
                res = i;
            } else if (min_c == c && min_n > num) {
                min_n = num;
                res = i;
            }
        }
        for (int i = res; i < res + 7; i++) {
            cout << rot[i % 8] << " ";
        }
        cout << rot[(res + 7) % 8] << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
    multimap <string,int> m;
    int q;
    cin>>q;
    while(q--)
    {
        int a;
        cin>>a;
        if(a==0)
        {
            string key;
            long long x;
            cin>>key>>x;
            m.emplace(key,x);
        }
        else if(a==1)
        {
            string key;
            cin>>key;
            auto p=m.equal_range(key);
            for(auto it=p.first;it!=p.second;it++)
            {
                cout<<it->second<<endl;
            }
        }
        else if(a==2)
        {
            string key;
            cin>>key;
            m.erase(key);
        }
        else
        {
            string l,r;
            cin>>l>>r;
            auto p=m.lower_bound(l);
            while(p!=m.end()&&p->first<=r)
            {
                cout<<p->first<<" "<<p->second<<endl;
                p++;
            }
        }
    }
    return 0;
}



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


using namespace std;


int main() {
 // if '<', add one , eg. << 0+1, when it turn > wait, or at the end continue add one
  // if >. add one as well, >> 0+1+2, when it turn < or at the end continue add one
  // for <<<<>> the big number depends on count of < and >
  // <<>>> as unit, when >< a new unit start
  // use two count for < and > for each unit
  string s;
  cin>>s;
  char pre='>';
  long long int lcnt=0;
  long long int gcnt=0;
  long long int sum=0;
  for (char ch:s) {
    if (ch=='<') {
      if (pre=='>') {
        //previous unit end
        sum+=max(lcnt,gcnt);
        sum+=(lcnt-1)*lcnt/2;
        sum+=(gcnt-1)*gcnt/2;
        lcnt=0;
        gcnt=0;        
      }
      lcnt++;
      pre='<';
    } else {
      gcnt++;
      pre='>';
    }
  }
if (pre=='>') {
  sum+=max(lcnt,gcnt);
        sum+=(lcnt-1)*lcnt/2;
        sum+=(gcnt-1)*gcnt/2;
} else {
  sum+=(lcnt+1)*lcnt/2;
}
  
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std; 
typedef long long ll; typedef string str;

int main ()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
	
	int n,k;
	cin >> n >> k;
	
	vector<int> arr(n);
	for(int i = 0 ; i < n;  i++)
		cin >> arr[i];
		
	sort(arr.begin(), arr.end());
	
	int sum = 0;
	for(int i = 0 ; i < k ; i++)
	{
		sum += arr[i];
	}
	
	cout << sum;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

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

    ll N, K;
    cin >> N >> K;
    map<ll, ll> num;
    rep(i, N) {
        ll A, B;
        cin >> A >> B;
        num[A] += B;
    }

    ll sum = 0;
    for (auto n : num) {
        sum += n.second;
        if (K <= sum) {
            cout << n.first << endl;
            return 0;
        }
    }
    assert(false);
}



Measured memory_bytes: 4224
n,k=map(int,input().split(" "))

c=abs(n-k)
d=abs(c-k)
if(c+d==k):
    if(c>d):
        print(d)
    else:
        print(c)
    exit()
if(n>=k):
    if(n%k==0):
        print(0)
        exit()
    else:
        a=n-k*(n//k)
        b=k*(n//k+1)-n
        if(a>b):
            print(b)
        else:
            print(a)
        exit()
else:
    
    while(1):
        a=abs(n-k)
        if(n>a):
            n=a
        else:
            print(n)
            exit()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
    string N;

    cin >> N;

    bool flg = false;
    for (char c : N) {
        if (c == '7') {
            flg = true;
            break;
        }
    }

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

    return 0;
}


Measured memory_bytes: 3132
#include <stdio.h>

int main(void)
{
  int n,m[100],q,p[100][100],l[100],i,j,k,ans,ansi,end;

  for(;;){
    scanf("%d", &n);
    if(!n) break;

    for(i=0;i<n;i++){
      scanf("%d", &m[i]);
      for(j=0;j<m[i];j++){
	scanf("%d", &p[i][j]);
      }
    }
    scanf("%d", &q);
    int can[100]={0};
    for(i=0;i<q;i++){
      scanf("%d", &l[i]);
      for(j=0,end=0;j<n;j++){
	for(k=0;k<m[j];k++){
	  if(l[i]==p[j][k]){
	    can[j]++; end=1; break;
	  }
	}
      }
    }
    for(i=0,ans=0,ansi=0;i<n;i++){
      if(can[i]==q){
	ans++; ansi+=i+1;
      }
    }
    if(ans==1) printf("%d\n", ansi); 
    else printf("-1\n");
  }

  return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 h, w;
    cin >> h >> w;

    i64 cnt = 0;
    for (i64 i = 0; i < h * w; i++) {
        char c;
        cin >> c;
        if (c == '#') cnt++;
    }

    cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N,Q;
  int64_t K;
  cin >> N >> K >> Q;
  int p[N]={0};
  rep(i,Q){
    int a; cin >> a;
    p[a-1]++;
  }

  rep(i,N){
    if(K-Q+p[i]>0) puts("Yes");
    else puts("No");
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int>
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0);
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;
int inf=1e18;

void solve(){
    int n;cin>>n;
    int a[n];rep(i,0,n) cin>>a[i];
    int g=a[0];
    rep(i,1,n){
        g=__gcd(g,a[i]);
    }
    if(g>1){
        cout<<"not coprime";return;
    }
    set<int> s;

    rep(i,0,n){
        int x=2;
        while(x*x<=a[i]){
            if(!(a[i]%x)){
                if(s.count(x)){
                    cout<<"setwise coprime";return;
                }
                s.insert(x);
            }
            while(!(a[i]%x)){
                a[i]/=x;
            }
            x++;
        }
        if(a[i]>1){
            x=a[i];
            if(s.count(x)){
                cout<<"setwise coprime";return;
            }
            s.insert(x);
        }
    }

    cout<<"pairwise coprime";
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 11428
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);
    ll x,i,j;
    cin>>x;
    bool check=false;
    for (i=-1000;i<=1000;i++){
    	for(j=-1000;j<=1000;j++){
    		if (pow(i,5)-pow(j,5)==x){
    			cout<<i<<" "<<j<<endl;
    			check=true;
    			break;
    			}
    	}
    	if (check==true) break;
    }
	return 0;
}

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

int main() {
  	ll N;
  	cin >> N;
  	
	map<ll,int> A;
  	for (ll i=0; i<N; ++i) {
		ll llbuff;
		cin >> llbuff;
      	A[llbuff]++;
        if (A[llbuff]%2) A[llbuff]=1;
        else A.erase(llbuff);
    }
  
  	cout << A.size() << endl;

  	return 0;
}

Measured memory_bytes: 9804
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	ll N,M; cin  >> N >> M;
	V<ll> A,B; 
	REP(i,N){
		int tmp; cin >> tmp;
		(N>=M?A:B).push_back(tmp);
	}
	REP(i,M){
		int tmp; cin >> tmp;
		(N<M?A:B).push_back(tmp);
	}
	if(N<M) swap(N,M);
	sort(ALL(A),greater<ll>());
	sort(ALL(B),greater<ll>());

	corner(A[0]!=N*M || B[0] != N*M,0);

	ll a = 1,b = 1, ans = 1, cnt = 1;
	for(ll i = N*M-1; 1 <= i; --i){
		if(a<N && b < M && A[a]== i && B[b] == i){
			cnt++;
			a++;
			b++;
		}
		else if(a < N && A[a] == i){
			cnt++;
			(ans *= b) %= MOD;
			a++;
		}
		else if(b < M && B[b] == i){
			cnt++;
			(ans *= a) %= MOD;
			b++;
		}
		else{
			ll k = a*b-cnt;
			if(k <= 0){
				ans = 0;
				break;
			}
			(ans *= k) %= MOD;
			cnt++;
		}
	}
	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
count = 0

def fun(x):
  y = 0
  while(x > 0):
    y = y + (x%10)
    x = x//10
  return y

for i in range(n):
  sum = fun(i+1)
  if a <= sum <= b:
    count = count + (i+1)

print(count)

Measured memory_bytes: 3060
#include <string.h>
#include <iostream>
using namespace std;

int main() {
  int64_t a;
  int64_t b;
  int64_t c;
  int64_t d;
  int64_t e;
  cin>>a;
  b=a/15;
  c=a%15;
  d=60*b*b;
  e=15*b;
  if(c==1){
    d+=e+1;
  }
  if(c==2||c==3){
    d+=e*2+3;
  }
  if(c==4||c==5||c==6){
    d+=e*3+7;
  }
  if(c==7){
    d+=e*4+14;
  }
  if(c==8||c==9||c==10){
    d+=e*5+22;
  }
  if(c==11||c==12){
    d+=e*6+33;
  }
  if(c==13){
    d+=e*7+46;
  }
  if(c==14){
    d+=e*8+60;
  }
  cout<<d<<endl;
}



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

using namespace std;
typedef long long ll;

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

  for (int i = 0; i < 1 << 4; ++i) {
    int sum = s[0] - '0';
    for (int j = 1; j < 4; ++j) {
      int num = s[j] - '0';
      if (i >> j & 1) {
	sum += num;
      } else {
	sum -= num;
      }
    }
    if (sum == 7) {
      string ans = "";
      ans += s[0];
      for (int j = 1; j < 4; ++j) {
	if (i >> j & 1) ans += '+';
	else ans += '-';
	ans += s[j];	
      }
      cout << ans << "=7" << endl;
      return 0;
    }
  }
  return 0;
}




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

#define X first
#define Y second
#define ll long long
#define MP make_pair
#define PB push_back

using namespace std;

const int MAXN=1e5;
ll INF=1e12;

ll n,niz[MAXN+5],dp[MAXN+5],k;

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

	cin>>n>>k;
	for(int i=0; i<n; i++){
		cin>>niz[i];
	}
	dp[0]=0;
	for(int i=1; i<n; i++){
		ll pom=i-k,pom1=0;
		dp[i]=INF;
		for(int j=i-1; j>=max(pom1,pom); j--){
			dp[i]=min(dp[i],dp[j]+abs(niz[i]-niz[j]));
	//		cout<<i<<" "<<j<<"\n";
		}
	//	cout<<dp[i]<<"\n";
	}
	cout<<dp[n-1];
	
	return 0;
}

Measured memory_bytes: 5096
import itertools


a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

combs = itertools.combinations([a, b, c, d, e], 2)

can_connects = [abs(x[0] - x[1]) <= k for x in combs]

if all(can_connects):
    print('Yay!')
else:
    print(':(')




Measured memory_bytes: 3060
#include <stdio.h>

#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node t[100005];
int n,D[100005];

int rec(int u,int p){
  D[u] = p;
  if(t[u].r != NIL)rec(t[u].r,p+1);
  if(t[u].l != NIL)rec(t[u].l,p+1);
}
int hei(int u){
  int h1=0,h2=0;

  if(t[u].r != NIL)
    h1=hei(t[u].r)+1;
  if(t[u].l != NIL)
    h2=hei(t[u].l)+1;

  if(h1>h2)return h1;
  else return h2;
}

int main(){

  int i,n,v,r,sib,deg;
  scanf("%d",&n);

  for(i=0;i<n;i++)t[i].p=t[i].l=t[i].r = NIL;
    
  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&t[v].l);
    scanf("%d",&t[v].r);
    t[t[v].l].p = t[t[v].r].p = v;
    // printf("%d %d %d\n",t[v].l,t[v].r,t[v].p);
  }
  
  for(i=0;i<n;i++)if(t[i].p==NIL)r=i;

  rec(r,0);
  
  for(i=0;i<n;i++){
    deg=0;

    if(t[i].p==NIL)sib=-1;
    else sib = t[t[i].p].l+t[t[i].p].r-i;
    
    if(t[i].l!=NIL)deg++;
    if(t[i].r!=NIL)deg++;
    
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,t[i].p,sib,deg,D[i],hei(i));
  
    if(t[i].p==NIL)printf("root");
    else if(t[i].l==NIL && t[i].r==NIL)printf("leaf");
    else printf("internal node");
 
    printf("\n");

  }

 
  return 0;
}



Measured memory_bytes: 2132
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

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

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

func main() {
	n := nextInt()
	k := nextInt()
	if n <= k {
		fmt.Println(0)
		return
	}
	hn := make([]int, n)
	var totalh int
	for i := 0; i < n; i++ {
		hn[i] = nextInt()
		totalh += hn[i]
	}
	sort.Ints(hn)

	if k != 0 {
		for j := 0; j < k; j++ {
			totalh -= hn[n-j-1]
		}
	}
	fmt.Println(totalh)
}

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


Measured memory_bytes: 40576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<pair<int,int> > data(M);
  for (int i = 0; i < M; i++)
  {
    cin>>data[i].second>>data[i].first;
  }
  sort(data.begin(),data.end());
  int ANS = 0;
  int POS = -1;
  for (int i = 0; i < M; i++)
  {
    if(POS < data[i].second)
    {
      ANS++;
      POS = data[i].first-1;
      // DEBUG(POS);
    }
  }
  cout<<ANS<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 1920
x, y = map(int, input().split())
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 =[4, 6, 9, 11]
if x in g1 and y in g1:
    print("Yes")
elif x in g2 and y in g2:
    print("Yes")
elif x == 2 and y ==2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int i,s[10000],max;
	
	i = 0;
	
	while(1){
		i++;
		scanf("%d\n",&s[i]);
		if(s[i] == 0){ max = i; break;}
	}
	
	for(i=1;i<max;i++)
	printf("Case %d: %d\n",i,s[i]);
	return 0;
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}


const double EPS=1e-6;
const double INF=1e10;

typedef complex<double> Point;
typedef complex<double> Vector;

struct Line
{
	Point a, b;
	Line() {}
	Line(const Point &_a, const Point &_b)
	{
		a = _a; b = _b;
	}
};

//Line????????????
struct Segment
{
	Point a, b;
	Segment() {}
	Segment(const Point &_a, const Point &_b)
	{
		a = _a; b = _b;
	}
};

istream& operator >> (istream& is, Point &p)
{
	double x, y;
	is >> x >> y;
	p.real(x); p.imag(y);
	return is;
}

Segment ToSegment(const Line l)
{
	return Segment(l.a, l.b);
}

Line ToLine(const Segment s)
{
	return Line(s.a, s.b);
}

double dot(const Vector &a, const Vector &b)
{
	return a.real()*b.real() + a.imag()*b.imag();
}

double cross(const Vector &a, const Vector &b)
{
	return a.real()*b.imag() - a.imag()*b.real();
}

double GetDistance(const Line &l, const Point &p)
{
	return abs(cross(l.a - l.b, p - l.a) / abs(l.b - l.a));
}

double GetDistance(const Segment &s, const Point &p)
{
	if (dot(s.b - s.a, p - s.a) < 0.0) return abs(p - s.a);
	if (dot(s.a - s.b, p - s.b) < 0.0) return abs(p - s.b);
	return GetDistance(ToLine(s), p);
}



int N,M;
Point p[11111];
bool used[11111];
double dist[11111];
signed main(){
    cin>>N>>M;
    rep(i,N+1)cin>>p[i];

    used[0]=true;
    double ans=0;
    rep(i,N+1)dist[i]=abs(p[i]-p[0]);
    rep(t,M){
        int mi=-1;
        for(int i=N;i>=0;i--){
            if(used[i])continue;
            if(mi==-1)mi=i;
            else if(dist[mi]+EPS>dist[i])mi=i;
        }
        double mincost=INF;
        int vv=-1;
        for(int i=N;i>=0;i--){
            if(!used[i])continue;
            double tmp=abs(p[mi]-p[i]);
            if(mincost+EPS>tmp){
                mincost=tmp;
                vv=i;
            }
        }

        ans+=mincost;
        used[mi]=true;
        Segment s(p[mi],p[vv]);
        rep(i,N+1){
            if(used[i])continue;
            chmin(dist[i],GetDistance(s,p[i]));
        }
    }

    printf("%.20f\n",ans);
}

Measured memory_bytes: 3432
#include <bits/stdc++.h>
#define inf 1e9+10
#define ll long long
#define inf 1e18
using namespace std;
inline int read(){
	int x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
ll a,b,c,k;
int main(){
	int t;
	cin>>a>>b>>c>>k;
	if(k%2) t=-1;
	else t=1;
	ll sum=a-b;
	sum*=t;
	if(abs(sum)<=inf) cout<<sum<<endl;
	else cout<<"Unfair"<<endl;
	return 0;
} 

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

int main(){
  ll K, A, B; cin>>K>>A>>B;
  if(A-B+2>=0 || K<A+1) cout<<K+1<<endl;
  else{
    ll N=K-(A+1);
    if(N%2==0) cout<<B+(B-A)*(N/2)<<endl;
    if(N%2==1) cout<<B+(B-A)*((N-1)/2)+1<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e5+10;
char s[110];
int n,k;
ll dp[110][5];
ll dfs(int pos,int sta,bool limit){
	if(pos==-1) return sta==k;
	if(!limit&&~dp[pos][sta]) return dp[pos][sta];
	int up=limit?s[pos]-'0':9;
	ll ans=0;
	for(int i=0;i<=up;i++){
        if(i&&sta==k) continue;
		ans+=dfs(pos-1,sta+(i!=0),limit&&i==s[pos]-'0');
	}
	if(!limit) dp[pos][sta]=ans;
	return ans;
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	memset(dp,-1,sizeof(dp));
	cin>>s>>k;
	n=strlen(s);
	reverse(s,s+n);
	cout<<dfs(n-1,0,true)<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int H, W;
  scanf("%d %d", &H, &W);
  vector<string> board(H);
  for (int i = 0; i < H; ++i) {
    cin >> board[i];
  }
  for (int r = 0; r < H; ++r) {
    for (int c = 0; c < W; ++c) {
      if (board[r][c] == '.') { continue; }
      bool ok = false;
      for (int dr = -1; dr <= 1; ++dr) {
        for (int dc = -1; dc <= 1; ++dc) {
          if (abs(dr) + abs(dc) != 1) { continue; }
          int nr = r + dr, nc = c + dc;
          if (0 <= nr and nr < H and 0 <= nc and nc < W and board[nr][nc] == '#') {
            ok = true;
            break;
          }
        }
      }
      if (not ok) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 256