Language: C++

#include<iostream>
#include<stdio.h>
#include<vector>
#include <string>
#include <cstdlib>
#include <tuple>

using lint = long long;
using namespace std;

main() {
    auto input = irLine(2);
	auto K = input[0][1];
	auto H = input[1];

	qiSort(H);
	lint sum;

	for (lint i = 0; i < H.size()-K; i++) {
		sum += H[i];
	}
	
    printf("%d", sum);
    return 0;
}

lint Sum(lint a, lint b){
    return (a + b) * (b - a + 1) / 2;
}

lint permutation(lint n, lint k)  {
	lint v = 1;
	if (0 < k && k <= n) {
		for (lint i = 0; i < k; i++) {
			v *= (n - i);
		}
	} else if (k > n) {
		v = 0;
	}
	return v;
}

lint factorial(lint n) {
	return permutation(n, n-1);
}

lint combination(lint n , lint k) {
	return permutation(n, k) / factorial(k);
}

lint homogeneous(lint n ,lint k )  {
	return combination(n+k-1, k);
}

//round returns rounded linteger number
lint round(double x) {
	if (x < double(lint(x))+0.5) {
		return lint(x);
	}
	return lint(x) + 1;
}


//minf returns min{a, b}(a, b: float64)
double minf(double a,double b)  {
	if (a > b) {
		return b;
	}
	return a;
}


//mini returns min{a, b} (a, b: int)
lint mini(lint a,lint  b) {
	if (a > b) {
		return b;
	}
	return a;
}

//minf returns max{a, b}(a, b: float64)
lint maxf(double a,double b) {
	if (a > b) {
		return a;
	}
	return b;
}

//maxi returns max{a, b} (a, b: int)
lint maxi(lint a, lint b ) {
	if (a > b) {
		return a;
	}
	return b;
}

//pawf paw returns f^num(f:float64)
lint pawf(double f, lint num)  {
	double result  = 1;
	for (lint i = 0; num > i; i++) {
		result *= f;
	}
	return result;
}

//pawi paw returns f^num(f:int)
lint pawi(lint f, lint num ) {
	lint result = 1;
	for (lint i = 0; num > i; i++) {
		result *= f;
	}
	return result;
}


//rLine Read all standard input data
std::vector<std::vector<string>> rLine(lint line)  {
    std::vector<std::vector<string>> stringInput ;
    std::string s;

    for (int i = 0; i < line; i++){
        std::getline(std::cin, s);
        stringInput.push_back(split(s, char(" ")));
    }

    return stringInput;
}

//irLine Read Standard input data and convert into integer
vector<vector<lint>> irLine(int i) {
	return alatois(rLine(i));
}


//mrLine Read multi-line standard input data
// put the location of data of the number of lines in a first line
//ex:
// 3 5
// 1 2
// 2 3
// 3 5
// you have to put 1, where the number 3 put in the first line
tuple<vector<lint>, vector<vector<string>>> mrLine(lint line) {
    std::vector<std::vector<string>> stringInput ;
    std::vector<lint> input;
    std::string s;

    std::getline(std::cin, s);
    input = atois(split(s, char(" ")));

    stringInput = rLine(input[line-1]);

    return forward_as_tuple(input, stringInput);
}


//mirLine  Read multi-line standard input data and convert into integer data
// put the location of data of the number of lines in a first line
//ex:
// 3 5
// 1 2
// 2 3
// 3 5
// you have to put 1, where the number 3 put in the first line
tuple<vector<lint>, vector<vector<lint>>> mirLine(lint line) {
    vector<lint> first;
    vector<vector<string>> input;
    return forward_as_tuple(first, alatois(input));
}

std::vector<string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);

    std::vector<std::string> result;

    while (first < str.size()) {
        std::string subStr(str, first, last - first);
 
        result.push_back(subStr);
 
        first = last + 1;
        last = str.find_first_of(del, first);
 
        if (last == std::string::npos) {
            last = str.size();
        }
    }
 
    return result;
}

vector<lint> atois(vector<string> str){
    vector<lint> result(str.size) ;
    for (lint i = 0; i < str.size();i++){
        result[i] = atoi(str[i].c_str());
    }
    return result;
}

vector<vector<lint>> alatois(vector<vector<string>> str){
    vector<vector<lint>> result(str.size) ;
    for (lint i = 0; i < str.size();i++){
        result[i] = atois(str[i]);
    }
    return result;
}


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

lint gcd3(lint a,lint b,lint c) {
	return gcd(gcd(a, b), c);
}


//meds3 return median of 3 stringer values
string meds3(string x,string y,string z) {
	if (x < y){
		if (x > z){
			return x;
        }else if (z > y){
			return y;
        }else {
			return z;
		}
    }
    if (z < y){
        return y;
    } else if (x < z){
        return x;
    } else {
        return z;
    }
}

//medi3 return median of 3 stringer values
lint medi3(lint x,lint y,lint z) {
	if (x < y){
		if (x > z){
			return x;
        }else if (z > y){
			return y;
        }else {
			return z;
		}
    }
    if (z < y){
        return y;
    } else if (x < z){
        return x;
    } else {
        return z;
    }
}


//iQuicksort sort integer slice by quick sort
void iQuicksort(vector<lint> a, lint left, lint right) {
	if (left < right) {
		lint i, j = left, right;
        lint tmp = 0;
		lint pivot = medi3(a[i], a[i+(j-i)/2], a[j]);

		for(;;){
			for (; a[i] < pivot; i++) {
			}
			for (; pivot < a[j]; j--) {
			}
			if (i >= j) {
				break;
			}
			tmp = a[i];
			a[i] = a[j];
			a[j] = tmp; /* a[i], a[j] を交換 */
			i++;
			j--;
		}
		iQuicksort(a, left, i-1);  /* 分割した左を再帰的にソート */
		iQuicksort(a, j+1, right); /* 分割した右を再帰的にソート */
	}
}


//iQuicksort sort integer slice by quick sort
void sQuicksort(vector<string> a, lint left, lint right) {
	if (left < right) {
		lint i, j = left, right;
        string tmp = 0;
		string pivot = meds3(a[i], a[i+(j-i)/2], a[j]);

		for(;;){
			for (; a[i] < pivot; i++) {
			}
			for (; pivot < a[j]; j--) {
			}
			if (i >= j) {
				break;
			}
			tmp = a[i];
			a[i] = a[j];
			a[j] = tmp; /* a[i], a[j] を交換 */
			i++;
			j--;
		}
		sQuicksort(a, left, i-1);  /* 分割した左を再帰的にソート */
		sQuicksort(a, j+1, right); /* 分割した右を再帰的にソート */
	}
}

//qiSort sort integer slie by quick sort
void qiSort(vector<lint> a) {
	iQuicksort(a, 0, a.size()-1);
}

//qsSort sort stringer slie by quick sort
void qsSort(vector<string> a) {
	sQuicksort(a, 0, a.size()-1);
}

//abs returns absolute integer number
lint abs(lint a) {
	if (a > 0) {
		return a;
	}
	return -a;
}


Compiler output:
a.cc:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:12:18: error: 'irLine' was not declared in this scope; did you mean 'inline'?
   12 |     auto input = irLine(2);
      |                  ^~~~~~
      |                  inline
a.cc:16:9: error: 'qiSort' was not declared in this scope; did you mean 'qsort'?
   16 |         qiSort(H);
      |         ^~~~~~
      |         qsort
a.cc: In function 'std::vector<std::vector<std::__cxx11::basic_string<char> > > rLine(lint)':
a.cc:123:40: error: cast from 'const char*' to 'char' loses precision [-fpermissive]
  123 |         stringInput.push_back(split(s, char(" ")));
      |                                        ^~~~~~~~~
a.cc:123:31: error: 'split' was not declared in this scope
  123 |         stringInput.push_back(split(s, char(" ")));
      |                               ^~~~~
a.cc: In function 'std::vector<std::vector<long long int> > irLine(int)':
a.cc:131:16: error: 'alatois' was not declared in this scope; did you mean 'atoi'?
  131 |         return alatois(rLine(i));
      |                ^~~~~~~
      |                atoi
a.cc: In function 'std::tuple<std::vector<long long int, std::allocator<long long int> >, std::vector<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > > mrLine(lint)':
a.cc:149:28: error: cast from 'const char*' to 'char' loses precision [-fpermissive]
  149 |     input = atois(split(s, char(" ")));
      |                            ^~~~~~~~~
a.cc:149:19: error: 'split' was not declared in this scope
  149 |     input = atois(split(s, char(" ")));
      |                   ^~~~~
a.cc:149:13: error: 'atois' was not declared in this scope; did you mean 'atoi'?
  149 |     input = atois(split(s, char(" ")));
      |             ^~~~~
      |             atoi
a.cc: In function 'std::tuple<std::vector<long long int, std::allocator<long long int> >, std::vector<std::vector<long long int, std::allocator<long long int> >, std::allocator<std::vector<long long int, std::allocator<long long int> > > > > mirLine(lint)':
a.cc:168:36: error: 'alatois' was not declared in this scope; did you mean 'atoi'?
  168 |     return forward_as_tuple(first, alatois(input));
      |                                    ^~~~~~~
      |                                    atoi
a.cc: In function 'std::vector<long long int> atois(std::vector<std::__cxx11::basic_string<char> >)':
a.cc:194:29: error: invalid use of non-static member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; size_type = long unsigned int]'
  194 |     vector<lint> result(str.size) ;
      |                         ~~~~^~~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:992:7: note: declared here
  992 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
a.cc: In function 'std::vector<std::vector<long long int> > alatois(std::vector<std::vector<std::__cxx11::basic_string<char> > >)':
a.cc:202:37: error: invalid use of non-static member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::vector<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::vector<std::__cxx11::basic_string<char> > >; size_type = long unsigned int]'
  202 |     vector<vector<lint>> result(str.size) ;
      |                                 ~~~~^~~~
/usr/include/c++/14/bits/stl_vector.h:992:7: note: declared here
  992 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~