criyle/codenet-compile-errors huggingface dataset:
Language: C++

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

int main(){
  int N, K ;
  cin >> N >> K;
  
  vector<int>a(N);
  rep(i,N) cin >> a[i];
  sort(a.begin(),a.end());
  
  int sum = 0;
  rep(i,N-K) sum += a[i];
  
  cont << sum << endl;
    
}

  


Compiler output:
a.cc: In function 'int main()':
a.cc:17:3: error: 'cont' was not declared in this scope; did you mean 'const'?
   17 |   cont << sum << endl;
      |   ^~~~
      |   const
Language: C++

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

int main(){
  int N, K ;
  cin >> N >> K;
  
  vector(int)a(N);
  rep(i,N) cin >> a[i];
  sort(a.begin(),a.end());
  
  int sum = 0;
  rep(i,N-K) sum += a[i];
  
  cont << sum << endl;
    
}

  


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: missing template arguments before '(' token
   10 |   vector(int)a(N);
      |         ^
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector(int)a(N);
      |          ^~~
a.cc:11:19: error: 'a' was not declared in this scope
   11 |   rep(i,N) cin >> a[i];
      |                   ^
a.cc:12:8: error: 'a' was not declared in this scope
   12 |   sort(a.begin(),a.end());
      |        ^
a.cc:17:3: error: 'cont' was not declared in this scope; did you mean 'const'?
   17 |   cont << sum << endl;
      |   ^~~~
      |   const
Language: Java

import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    long sum  =0;
    long[] HP = new long[N];
    for(int i=0; i<N; i++)
      HP[i] = sc.nextLong();
    
    if(K >= N)
      System.out.println(0);
    else{
		Arrays.sort(HP, Collections.reverseOrder());
       for(int i = K; i<N; i++){
         sum += HP[i];
       }
    }
    System.out.println(sum);
    
    
  }
}


Compiler output:
Main.java:17: error: no suitable method found for sort(long[],Comparator<Object>)
		Arrays.sort(HP, Collections.reverseOrder());
		      ^
    method Arrays.<T#1>sort(T#1[],Comparator<? super T#1>) is not applicable
      (inference variable T#1 has incompatible bounds
        equality constraints: long
        upper bounds: Object)
    method Arrays.<T#2>sort(T#2[],int,int,Comparator<? super T#2>) is not applicable
      (cannot infer type-variable(s) T#2
        (actual and formal argument lists differ in length))
  where T#1,T#2 are type-variables:
    T#1 extends Object declared in method <T#1>sort(T#1[],Comparator<? super T#1>)
    T#2 extends Object declared in method <T#2>sort(T#2[],int,int,Comparator<? super T#2>)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: Java

import java.util.Scanner;
import java.util.Arrays.
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    long sum  =0;
    long[] HP = new long[N];
    for(int i=0; i<N; i++)
      HP[i] = sc.nextLong();
    
    if(K >= N)
      System.out.println(0);
    else{
        Array.sort(HP); //HPを少ない順にソート、多い順にK回消す
       for(int i = 0; i<N, i++){
         if(i < K)
       		HP[N-i-1] = 0;
         else
            sum += HP[N-i-1];
       }
    }
    System.out.println(sum);
    
    
  }
}

Compiler output:
Main.java:2: error: <identifier> expected
import java.util.Arrays.
                        ^
Main.java:17: error: ';' expected
       for(int i = 0; i<N, i++){
                         ^
2 errors
Language: C++

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

vi sub(vector<bool> fin,ll n) {
  vi ret;
  REP(i,n) {
    if(fin.at(i))continue;
    vector<bool> cp = fin;
    cp.at(i) = true;
    vi result = sub(cp,n);
    ret.insert(ret.end(),result.begin(),result.end());
  }
  return ret;
}

int main() {
  ll n,k;
  cin >> n >> k;
  vi a(n);
  REP(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  ll ans=0;
  REP(i,n-k)ans+=a.at(i);
  cout << ans << endkl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:18: error: 'endkl' was not declared in this scope
   53 |   cout << ans << endkl;
      |                  ^~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main(int argc, char** argv)
{
  int n, k; cin >> n >> k;
  vector<int> h(n);
  for(int& i : h) cin >> i;
  sort(h.begin(), h.end());
  ll ans = 0;
  for (int i = 0; i < n-k; i++) ans += h[i];
  cout << ans << endl;
  return 0;
}
  

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |   sort(h.begin(), h.end());
      |   ^~~~
      |   short
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(void){
//string S;
int N;
cin >> N;
int K;
cin >> K;
long long mincost = 0;
vector<int> H(N);

for(int i = 0; i < N; i++){
  cin >> H[i];
}

sort(H.begin(), H.end(), greater<int>());

for(i = K; i < H.size(); i++){
  maxcost += H[i];
}
cout << maxcost << endl;

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:5: error: 'i' was not declared in this scope
   20 | for(i = K; i < H.size(); i++){
      |     ^
a.cc:21:3: error: 'maxcost' was not declared in this scope; did you mean 'mincost'?
   21 |   maxcost += H[i];
      |   ^~~~~~~
      |   mincost
a.cc:23:9: error: 'maxcost' was not declared in this scope; did you mean 'mincost'?
   23 | cout << maxcost << endl;
      |         ^~~~~~~
      |         mincost
Language: C++

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int h[n];
    
    for (int i=0; i<n; i++) {
        cin >> h[i];
    }
    
    for (int i=0; i<k; i++) {
        auto in = distance(h, max_element(h, h+n));
        h[in] = 0;
    }
    
    long long d = accumulate(h, h+n, 0LL);
    cout << d << "\n";
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:31: error: 'max_element' was not declared in this scope
   17 |         auto in = distance(h, max_element(h, h+n));
      |                               ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int h[n];
    
    for (int i=0; i<n; i++) {
        cin >> h[i];
    }
    
    for (int i=0; i<k; i++) {
        auto in = distance(h, max_element(h, h+n));
        h[in] = 0;
    }
    
    long long d = accumulate(h, h+n, 0);
    cout << d << "\n";
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:31: error: 'max_element' was not declared in this scope
   17 |         auto in = distance(h, max_element(h, h+n));
      |                               ^~~~~~~~~~~
Language: C++

#include <algorithm>

using namespace std;

int dat[200010];
int a, b;

int main(void) {
	scanf("%d %d", &a, &b);
  	for (int i = 1;i <= a;i ++) {
      scanf("%d", &dat[i]);
    }
  	sort(&dat[1], &dat[1]+a);
  	int sum = 0;
  	for (int i = 1;i <= a-b;i ++) {
    	sum += dat[i];
    }
  	printf("%d", sum);
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'scanf' was not declared in this scope
    9 |         scanf("%d %d", &a, &b);
      |         ^~~~~
a.cc:18:9: error: 'printf' was not declared in this scope
   18 |         printf("%d", sum);
      |         ^~~~~~
a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    1 | #include <algorithm>
  +++ |+#include <cstdio>
    2 |
Language: C

#include <stdio.h>
#include <stdlib.h>

int main()
{
    long N;
    long K;
    long *H;
    long long sum = 0;
    long long sumk =0;
    long i, j, tmp;
    
    scanf("%ld %ld", &N, &K);
    
    H = (long*) malloc(N * sizeof(long));
    
    for(i = 0; i<N; i++)
    {
        scanf("%ld ", &H[i]);
        sum += H[i];
    }
    
    if(N > K)
    {
    
    for(i = 0; i<N; i++)
    {
        for(j = i+1; j<N; j++)
        {
            if(H[i] < H[j])
            {
                tmp = H[i];
                H[i] = H[j];
                H[j] = tmp;
            }
        }
        
        if (i < K)
        {
            sumk += H[i];
        }
        if(i == K-1)
        break;
    }

Compiler output:
main.c: In function 'main':
main.c:44:5: error: expected declaration or statement at end of input
   44 |     }
      |     ^
main.c:44:5: error: expected declaration or statement at end of input
Language: C

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

                            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 <stdio.h>

int main()
{
    long N;
    long K;
    long *H;
    long long sum = 0;
    long long sumk =0;
    long i, j, tmp;
    
    scanf("%ld %ld", &N, &K);
    
    H = (long*) malloc(N * sizeof(long));
    
    for(i = 0; i<N; i++)
    {
        scanf("%ld ", &H[i]);
        sum += H[i];
    }
    
    if(N > K)
    {
    
    for(i = 0; i<N; i++)
    {
        for(j = i+1; j<N; j++)
        {
            if(H[i] < H[j])
            {
                tmp = H[i];
                H[i] = H[j];
                H[j] = tmp;
            }
        }
        
        if (i < K)
        {
            sumk += H[i];
        }
        if(i == k-1)
        break;
    }
    
    }
    
    printf("%lld", sum-sumk);
    
    
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:22:17: error: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
   22 |     H = (long*) malloc(N * sizeof(long));
      |                 ^~~~~~
main.c:10:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
    9 | #include <stdio.h>
  +++ |+#include <stdlib.h>
   10 | 
main.c:22:17: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   22 |     H = (long*) malloc(N * sizeof(long));
      |                 ^~~~~~
main.c:22:17: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:49:17: error: 'k' undeclared (first use in this function)
   49 |         if(i == k-1)
      |                 ^
main.c:49:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n,k;
    cin >> n >> k;
    long h[n];
    rep(i,0,n) cin >> h[i];
    sort(h.begin(), h.end());
    long long ans;
    for(int i=n-k-1; i>=0; --i) ans += h[i];
    cout << ans << "\n";




}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:12: error: request for member 'begin' in 'h', which is of non-class type 'long int [n]'
   14 |     sort(h.begin(), h.end());
      |            ^~~~~
a.cc:14:23: error: request for member 'end' in 'h', which is of non-class type 'long int [n]'
   14 |     sort(h.begin(), h.end());
      |                       ^~~
Language: Java

import java.math.BigInteger;
import java.util.*;
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int k = sc.nextInt();
			int h[] = new int[n];
			long sum = 0;
			
			
			for(int i=0;i<n;i++) {
				h[i]=sc.nextInt();
			}
			
			Arrays.sort(h,Collections.reverseOrder());
			
			if(n<=k) {
				System.out.println(0);
				return;
			}else {
				for(int i=k;i<n;i++) {
					sum += h[i];
				}
				
				System.out.println(sum);
			}
			
			
			
			
			
		}
				
	}

Compiler output:
Main.java:19: error: no suitable method found for sort(int[],Comparator<Object>)
			Arrays.sort(h,Collections.reverseOrder());
			      ^
    method Arrays.<T#1>sort(T#1[],Comparator<? super T#1>) is not applicable
      (inference variable T#1 has incompatible bounds
        equality constraints: int
        upper bounds: Object)
    method Arrays.<T#2>sort(T#2[],int,int,Comparator<? super T#2>) is not applicable
      (cannot infer type-variable(s) T#2
        (actual and formal argument lists differ in length))
  where T#1,T#2 are type-variables:
    T#1 extends Object declared in method <T#1>sort(T#1[],Comparator<? super T#1>)
    T#2 extends Object declared in method <T#2>sort(T#2[],int,int,Comparator<? super T#2>)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(longlong i=0;i<n;i++)
using namespace std;
 
int main() {
  long n,k,sum=0;
  cin>>n>>k;
  vector<long> h(n);
  rep(i,n){
    cin>>h[i];
    
  }
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  if(k<n){
    for(long i=k;i<n;i++){
    sum+=h[i];
    }
  cout<<sum<<endl;
  }
  else{
    cout<<0<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:22: error: 'longlong' was not declared in this scope
    2 | #define rep(i,n) for(longlong i=0;i<n;i++)
      |                      ^~~~~~~~
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i,n){
      |   ^~~
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   rep(i,n){
      |       ^
a.cc:2:35: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(longlong i=0;i<n;i++)
      |                                   ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main() {
  int n,k,sum=0;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n){
    cin>>h[i];
    
  }
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  if(k<n){
    for(int i=k;i<n;i++){
    sum+=h[i];
    }
    
  cout<<sum<<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:2: error: expected '}' at end of input
   22 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

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

int main()
{
    int N, K;
    //vector<int> H;
    priority_queue<int> H;
    int res = 0;
    int t;

    cin >> N >> K;
    rep(i, N)
    {
        cin >> t;
        H.push(t);
    }

    //res = accumulate(A.begin(), A.end(), 0);
    //sort(A.begin(), A.end());

    rep(i, K)
    {
        H.pop();
        //res++;
    }
    while (!H.empty())
    {
        res += H.top()
        H.pop();
    }

    //res += accumulate(H.begin(), H.end(), 0);
    cout << res;
    /*
    if (res >= H)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }*/
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:23: error: expected ';' before 'H'
   30 |         res += H.top()
      |                       ^
      |                       ;
   31 |         H.pop();
      |         ~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main() {
  int n,k,sum=0;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n){
    cin>>h[i];
    
  }
  sort(h.begin(),h.end());
  reverse(h.begin(),h.begin());
  for(int i=k;i<n;i++){
    sum+=h[i];
  }
  cou<<k+sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: 'cou' was not declared in this scope; did you mean 'cos'?
   18 |   cou<<k+sum<<endl;
      |   ^~~
      |   cos
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main() {
  int n,k,sum=0;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n){
    cin>>h[i];
    
  }
  sort(h.begin(),h.end());
  reverse(h.begin(),h.begin());
  for(int=k;i<n;i++){
    sum+=h[i];
  }
  cou<<k+sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:10: error: expected unqualified-id before '=' token
   15 |   for(int=k;i<n;i++){
      |          ^
a.cc:15:10: error: expected ';' before '=' token
   15 |   for(int=k;i<n;i++){
      |          ^
      |          ;
a.cc:15:10: error: expected primary-expression before '=' token
a.cc:15:13: error: 'i' was not declared in this scope
   15 |   for(int=k;i<n;i++){
      |             ^
a.cc:15:16: error: expected ')' before ';' token
   15 |   for(int=k;i<n;i++){
      |      ~         ^
      |                )
a.cc:15:17: error: 'i' was not declared in this scope
   15 |   for(int=k;i<n;i++){
      |                 ^
a.cc:18:3: error: 'cou' was not declared in this scope; did you mean 'cos'?
   18 |   cou<<k+sum<<endl;
      |   ^~~
      |   cos
Language: Java

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
//------------------------------------------------------------
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] monsters =new int[n];
		for (int i=0;i<n;i++){
			monsters[i]=sc.nextInt();
		}
		Arrays.sort(monsters);

		int hp =0;
		if (k>=n) {
			System.out.println(0);
		} else{
			for (int j=0;j<k-1;j++) {
				hp += monsters[j];
			}
			System.out.println(hp);

		}



		//------------------------------------------------------------
	}
}

Compiler output:
Main.java:3: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
Main.java:11: error: cannot find symbol
		Arrays.sort(monsters);
		^
  symbol:   variable Arrays
  location: class Main
3 errors
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}



void oneCase () {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for (auto& el : h) {
        cin >> el;
    }
    sort(h.begin(), h.end());
    cout << accumulate(h.begin(), h.begin() + n - min(n, k), 0LL) << "\n";

}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Compiler output:
a.cc: In function 'void oneCase()':
a.cc:37:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   37 |     sort(h.begin(), h.end());
      |     ^~~~
      |     sqrt
Language: C++

#include <iostream>
using namespace std;

int main() {
  long long int n,k,s=0;
  cin >> n >> k;
  long long int a[n];
  for (int i=0;i<n;i++) {
    cin >> a[i];
  }
  sort(a, a+n);
  for (int i=0;i<n-k;i++) {
    s+=a[i];
  }
  cout << s;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |   sort(a, a+n);
      |   ^~~~
      |   short
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
	int n,k;
  	long count=0;
  	cin >> n >> k;
  	int x[n],i;
  	for(i=0;i<a;i++){
    	cin >> x[i];
    }
  	sort(x,x+n,[](int aa, int bb) {
        return aa > bb;   
    });
  	for(i=k;i<n;i++){
      	count += x[i];
    }
  	cout << count << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:11:19: error: 'a' was not declared in this scope
   11 |         for(i=0;i<a;i++){
      |                   ^
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
	int n,k;
  	long count=0;
  	cin >> n >> k;
  	int x[n],i;
  	for(i=0;i<n;i++){
    	cin >> x[i];
    }
  	sort(x,x+n,[](int aa, int bb) {
        return aa > bb;   
    });
  	for(i=k;i<a;i++){
      	count += x[i];
    }
  	cout << count << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:19: error: 'a' was not declared in this scope
   17 |         for(i=k;i<a;i++){
      |                   ^
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
	int n,k;
  	long count=0;
  	cin >> n >> k;
  	int x[n],i;
  	for(i=0;i<a;i++){
    	cin >> x[i];
    }
  	sort(x,x+n,[](int aa, int bb) {
        return aa > bb;   
    });
  	for(i=k;i<a;i++){
      	count += x[i];
    }
  	cout << count << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:11:19: error: 'a' was not declared in this scope
   11 |         for(i=0;i<a;i++){
      |                   ^
a.cc:17:19: error: 'a' was not declared in this scope
   17 |         for(i=k;i<a;i++){
      |                   ^
Language: C++

#include <iostream>
using namespace std;

int main(){
  int n,k;cin>>n>>k;
  int arr[n];
  for(int i=0; i<n; i++)cin>>arr[i];
  sort(arr,arr+n);
  long long sum=0;
  for(int i=0; i<n-k; i++){
  	ans+=arr[i];
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'sort' was not declared in this scope; did you mean 'short'?
    8 |   sort(arr,arr+n);
      |   ^~~~
      |   short
a.cc:11:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   11 |         ans+=arr[i];
      |         ^~~
      |         abs
a.cc:13:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |   cout<<ans<<endl;
      |         ^~~
      |         abs
Language: C++

#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()

int main() {
	int N,K,X;
	X = 0;
	cin >> N >> K;
	vector<int> H(N);
	rep(i, N)
		cin >> H[i];
	sort(all(H));
	rep(i, N - K)
		X += H[i];
	cout << X;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<stdio.h>
int main(){
  int n,k;
  scanf("%d%d",&n,&k)
  int a;
  int x[n];
  for (a=0;a<k;a++){
    scanf("%d", &x[a])
   }
  if(n<=k) printf("0");
  else{
    int i,j;
    for (i=0;i<n;i++){
      for (j=i+1;j<n;i++)
        if (x[i]>x[j]){
          int tmp = x[i];
          x[i] = x[j];
          x[j] = tmp;
        }
    }
    int b,c;
    for (b=0;b<n;b++){
      c = n-b-1;
      x[c] = 0;
    }
    int s;
    for (c=0;c<n;c++)
      s += x[c];
    printf("%d", s);
  }
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:4:22: error: expected ';' before 'int'
    4 |   scanf("%d%d",&n,&k)
      |                      ^
      |                      ;
    5 |   int a;
      |   ~~~                 
a.cc:7:8: error: 'a' was not declared in this scope
    7 |   for (a=0;a<k;a++){
      |        ^
Language: C++

#include<stdio.h>
int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int a;
  int x[n];
  for (a=0;a<k;a++){
    scanf("%d", &x[a]);
   }
  if(n<=k) printf("0");
  else{
    int i,j;
    for (i=0;i<n;i++){
      for (j=i+1;j<n;i++)
        if (x[i]>x[j]){
          int tmp = x[i];
          x[i] = x[j];
          x[j] = tmp;
        }
    }
    int b;
    for (b=0;b<n;b++){
      int c;
      c = n-b-1;
      x[c] = 0;
    }
    int s;
    for (c=0;c<n;c++)
      s += x[c];
    printf("%d", s);
  }
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:28:10: error: 'c' was not declared in this scope
   28 |     for (c=0;c<n;c++)
      |          ^
Language: C++

#include<stdio.h>
int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int a;
  int x[n];
  for (a=0,a<k,a++){
    scanf("%d", &x[a]);
   }
  if(n<=k) printf("0");
  else{
    int i,j;
    for (i=0,i<n,i++){
      for (j=i+1,j<n,i++)
        if (x[i]>x[j]){
          int tmp = x[i];
          x[i] = x[j];
          x[j] = tmp;
        }
    }
    int b;
    for (b=0,b<n,b++){
      int c;
      c = n-b-1;
      x[c] = 0;
    }
    int s;
    for (c=0,c<n,c++)
      s += x[c];
    printf("%d", s);
  }
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:7:19: error: expected ';' before ')' token
    7 |   for (a=0,a<k,a++){
      |                   ^
      |                   ;
a.cc:10:3: error: expected primary-expression before 'if'
   10 |   if(n<=k) printf("0");
      |   ^~
a.cc:9:5: error: expected ';' before 'if'
    9 |    }
      |     ^
      |     ;
   10 |   if(n<=k) printf("0");
      |   ~~ 
a.cc:10:3: error: expected primary-expression before 'if'
   10 |   if(n<=k) printf("0");
      |   ^~
a.cc:9:5: error: expected ')' before 'if'
    9 |    }
      |     ^
      |     )
   10 |   if(n<=k) printf("0");
      |   ~~ 
a.cc:7:7: note: to match this '('
    7 |   for (a=0,a<k,a++){
      |       ^
a.cc:13:21: error: expected ';' before ')' token
   13 |     for (i=0,i<n,i++){
      |                     ^
      |                     ;
a.cc:21:10: error: expected initializer before ';' token
   21 |     int b;
      |          ^
a.cc:22:5: error: expected primary-expression before 'for'
   22 |     for (b=0,b<n,b++){
      |     ^~~
a.cc:21:11: error: expected ')' before 'for'
   21 |     int b;
      |           ^
      |           )
   22 |     for (b=0,b<n,b++){
      |     ~~~    
a.cc:13:9: note: to match this '('
   13 |     for (i=0,i<n,i++){
      |         ^
a.cc:22:21: error: expected ';' before ')' token
   22 |     for (b=0,b<n,b++){
      |                     ^
      |                     ;
a.cc:27:10: error: expected initializer before ';' token
   27 |     int s;
      |          ^
a.cc:28:5: error: expected primary-expression before 'for'
   28 |     for (c=0,c<n,c++)
      |     ^~~
a.cc:27:11: error: expected ')' before 'for'
   27 |     int s;
      |           ^
      |           )
   28 |     for (c=0,c<n,c++)
      |     ~~~    
a.cc:22:9: note: to match this '('
   22 |     for (b=0,b<n,b++){
      |         ^
a.cc:28:10: error: 'c' was not declared in this scope
   28 |     for (c=0,c<n,c++)
      |          ^
a.cc:31:3: error: expected primary-expression before '}' token
   31 |   }
      |   ^
a.cc:30:21: error: expected ')' before '}' token
   30 |     printf("%d", s);
      |                     ^
      |                     )
   31 |   }
      |   ~                  
a.cc:28:9: note: to match this '('
   28 |     for (c=0,c<n,c++)
      |         ^
a.cc:31:3: error: expected primary-expression before '}' token
   31 |   }
      |   ^
Language: C++

int main{
  int n,k;
  scanf("%d%d", &n,&k);
  int a;
  int x[n];
  for (a=0,a<k,a++){
    scanf("%d", &x[a]);
   }
  if(n<=k) printf("0");
  else{
    int i,j;
    for (i=0,i<n,i++){
      for (j=i+1,j<n,i++)
        if (x[i]>x[j]){
          int tmp = x[i];
          x[i] = x[j];
          x[j] = tmp;
        }
    }
    int b;
    for (b=0,b<n,b++){
      int c;
      c = n-b-1;
      x[c] = 0;
    }
    int s;
    for (c=0,c<n,c++)
      s += x[c];
    printf("%d", s);
  }
}
      

Compiler output:
a.cc:1:5: error: cannot declare '::main' to be a global variable
    1 | int main{
      |     ^~~~
a.cc:2:3: error: expected primary-expression before 'int'
    2 |   int n,k;
      |   ^~~
a.cc:2:3: error: expected '}' before 'int'
a.cc:1:9: note: to match this '{'
    1 | int main{
      |         ^
a.cc:3:8: error: expected constructor, destructor, or type conversion before '(' token
    3 |   scanf("%d%d", &n,&k);
      |        ^
a.cc:5:9: error: 'n' was not declared in this scope
    5 |   int x[n];
      |         ^
a.cc:6:3: error: expected unqualified-id before 'for'
    6 |   for (a=0,a<k,a++){
      |   ^~~
a.cc:9:3: error: expected unqualified-id before 'if'
    9 |   if(n<=k) printf("0");
      |   ^~
a.cc:10:3: error: expected unqualified-id before 'else'
   10 |   else{
      |   ^~~~
a.cc:31:1: error: expected declaration before '}' token
   31 | }
      | ^
Language: C++

int main{
  int n,k;
  scanf(%d%d, &n,&k);
  int a;
  int x[n];
  for (a=0,a<k,a++){
    scanf(%d, &x[a]);
   }
  if(n<=k) printf("0");
  else{
    int i,j;
    for (i=0,i<n,i++){
      for (j=i+1,j<n,i++)
        if (x[i]>x[j]){
          int tmp = x[i];
          x[i] = x[j];
          x[j] = tmp;
        }
    }
    int b;
    for (b=0,b<n,b++){
      int c;
      c = n-b-1;
      x[c] = 0;
    }
    int s;
    for (c=0,c<n,c++)
      s += x[c];
    printf(%d, s);
  }
}
      

Compiler output:
a.cc:1:5: error: cannot declare '::main' to be a global variable
    1 | int main{
      |     ^~~~
a.cc:2:3: error: expected primary-expression before 'int'
    2 |   int n,k;
      |   ^~~
a.cc:2:3: error: expected '}' before 'int'
a.cc:1:9: note: to match this '{'
    1 | int main{
      |         ^
a.cc:3:8: error: expected constructor, destructor, or type conversion before '(' token
    3 |   scanf(%d%d, &n,&k);
      |        ^
a.cc:5:9: error: 'n' was not declared in this scope
    5 |   int x[n];
      |         ^
a.cc:6:3: error: expected unqualified-id before 'for'
    6 |   for (a=0,a<k,a++){
      |   ^~~
a.cc:9:3: error: expected unqualified-id before 'if'
    9 |   if(n<=k) printf("0");
      |   ^~
a.cc:10:3: error: expected unqualified-id before 'else'
   10 |   else{
      |   ^~~~
a.cc:31:1: error: expected declaration before '}' token
   31 | }
      | ^
Language: C++

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

int main(){
  int n, k;
  cin>>n >>k;
  vector<int> h(n);
  for(int i=0;i<n;i++)cin>>h[i];
  
  sort(h.rbegin(), h.rend());
  
  long long ans=0;
  for(int i=k;i<n;i++)ans+=h[i];
  cout<<max(ans, 0)<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:12: error: no matching function for call to 'max(long long int&, int)'
   14 |   cout<<max(ans, 0)<<endl;
      |         ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:14:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   14 |   cout<<max(ans, 0)<<endl;
      |         ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:14:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   14 |   cout<<max(ans, 0)<<endl;
      |         ~~~^~~~~~~~
Language: C++

int main{
  int n,k;
  scanf(%d%d, &n,&k);
  int a;
  int x[n];
  for (a=0,a<k,a++){
    scanf(%d, &x[a]);
   }
  if(n<=k) printf("0");
  else{
    int i,j;
    for (i=0,i<n,i++){
      for (j=i+1,j<n,i++)
        

Compiler output:
a.cc:1:5: error: cannot declare '::main' to be a global variable
    1 | int main{
      |     ^~~~
a.cc:2:3: error: expected primary-expression before 'int'
    2 |   int n,k;
      |   ^~~
a.cc:2:3: error: expected '}' before 'int'
a.cc:1:9: note: to match this '{'
    1 | int main{
      |         ^
a.cc:3:8: error: expected constructor, destructor, or type conversion before '(' token
    3 |   scanf(%d%d, &n,&k);
      |        ^
a.cc:5:9: error: 'n' was not declared in this scope
    5 |   int x[n];
      |         ^
a.cc:6:3: error: expected unqualified-id before 'for'
    6 |   for (a=0,a<k,a++){
      |   ^~~
a.cc:9:3: error: expected unqualified-id before 'if'
    9 |   if(n<=k) printf("0");
      |   ^~
a.cc:10:3: error: expected unqualified-id before 'else'
   10 |   else{
      |   ^~~~
Language: C++

    #include<bits/stdc++.h>
     
    using namespace std;
     
    int main(){
    	int n , k;
      	cin >> n >> k;
      	vector<long> v(n);
      	for(int i =0; i < n; i++) cin >> v[i];
      	
      	sort(v.rbegin(), v.rend());
      	
      	long long moves = 0
      	
        for(int i = k - 1; i < n; i++) move +=v[i]; 
      	cout <<moves << endl;
    	
      return 0;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: expected ',' or ';' before 'for'
   15 |         for(int i = k - 1; i < n; i++) move +=v[i];
      |         ^~~
a.cc:15:28: error: 'i' was not declared in this scope
   15 |         for(int i = k - 1; i < n; i++) move +=v[i];
      |                            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,n,res=0; cin>>h>>n;
  int a[n]; 
  for(int i=0; i<n; ++i) cin>>a[i];
  sort(a, a+n);
  for(int i=0; i < n-k; ++i){
  	res += a[i];
  }
  cout<<res;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:22: error: 'k' was not declared in this scope
    8 |   for(int i=0; i < n-k; ++i){
      |                      ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int N,K;
  vector int hoge;
  int bash;
  int sum = 0;
  cin >> N >> K;
  if (N <= K){
    cout << "0" << endl;
  }
  for (int i = 0; i < N; i++){
    cin >> bash;
    hoge.push_back(bash);
  }
  sort(hoge.begin(),hoge.end());
  for (int i = K; i < N; i++){
    sum += hoge[i];
  }
  cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: two or more data types in declaration of 'hoge'
    8 |   vector int hoge;
      |   ^~~~~~
a.cc:17:5: error: 'hoge' was not declared in this scope
   17 |     hoge.push_back(bash);
      |     ^~~~
a.cc:19:8: error: 'hoge' was not declared in this scope
   19 |   sort(hoge.begin(),hoge.end());
      |        ^~~~
Language: C++

#include <iostream>
using namespace std;

int main(){
  int N,K;
  unsigned int hoge[200000];
  int bash;
  int sum = 0;
  cin >> N >> K;
  if (N <= K){
    cout << "0" << endl;
  }
  for (int i = 0; i < N; i++){
    cin >> bash;
    hoge[i] = bash;
  }
  sort(hoge,hoge[0],hoge[N - 1]);
  for (int i = K; i < N; i++){
    sum += hoge[i];
  }
  cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |   sort(hoge,hoge[0],hoge[N - 1]);
      |   ^~~~
      |   short
Language: C++

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

int main()
{

        int N;
        int K;
        cin >> N >> K;
        unsigned int H[N];
        for (int i = 0; i < N; ++i) {
                cin >> H[i];
        }
        sort(H, H+N, std::greater<int>());
        for (int i = 0; i < K; ++i) {
                if (i == N) {
                        break;
                }
                H[i] = 0;
        }
        longlong num = 0;
        for (int  i = 0; i < N; ++i) {
                num += H[i];
        }
        cout << num << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'longlong' was not declared in this scope
   21 |         longlong num = 0;
      |         ^~~~~~~~
a.cc:23:17: error: 'num' was not declared in this scope; did you mean 'enum'?
   23 |                 num += H[i];
      |                 ^~~
      |                 enum
a.cc:25:17: error: 'num' was not declared in this scope; did you mean 'enum'?
   25 |         cout << num << endl;
      |                 ^~~
      |                 enum
Language: Java

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        List<Integer> list = new ArrayList<>();
        scanner.nextLine();
        for (int i = 0; i < n; i++) {
            list.add(scanner.nextInt());
        }
        if (k >= n) {
            System.out.println(0);
        } else {
            System.out.println(list.stream().sorted(Comparator.comparingInt()).collect(Collectors.toList()).subList(0, n - k).stream().mapToInt(m -> m).sum());
        }
    }
}


Compiler output:
Main.java:20: error: method comparingInt in interface Comparator<T#2> cannot be applied to given types;
            System.out.println(list.stream().sorted(Comparator.comparingInt()).collect(Collectors.toList()).subList(0, n - k).stream().mapToInt(m -> m).sum());
                                                              ^
  required: ToIntFunction<? super T#1>
  found:    no arguments
  reason: cannot infer type-variable(s) T#1
    (actual and formal argument lists differ in length)
  where T#1,T#2 are type-variables:
    T#1 extends Object declared in method <T#1>comparingInt(ToIntFunction<? super T#1>)
    T#2 extends Object declared in interface Comparator
1 error
Language: C++

#include<bits/stdc++.h>
#include <vector>
using namespace std;
typedef long long ll;

const int maxn=2e5+10;
int n,k;
ll answer;
int data[maxn];

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
      	cin >> data[i];
	}
    sort(a+1,a+1+n);
    for (int i = 0;i < (n - k) ; i++){
      answer =+ data[i];
    }
	cout << answer << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:16: error: reference to 'data' is ambiguous
   14 |         cin >> data[i];
      |                ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:5: note:                 'int data [200010]'
    9 | int data[maxn];
      |     ^~~~
a.cc:16:10: error: 'a' was not declared in this scope
   16 |     sort(a+1,a+1+n);
      |          ^
a.cc:18:17: error: reference to 'data' is ambiguous
   18 |       answer =+ data[i];
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:5: note:                 'int data [200010]'
    9 | int data[maxn];
      |     ^~~~
Language: C++

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

int n,k;
ll answer,h[1000000];

int main() {

	cin >> n >> k;
  	vector<int> data(n);
	for (int i = 0; i < n; i++) {
     	cin >> h[i];
        data.push_back(h[i]);
	}
    sort(data.begin(),data.end());
    for (int i = 0;i < n -k ; i++){
      answer =+ data[i];
    }
	cout << answer << endl;
	return 0;
}


Compiler output:
a.cc:6:1: error: 'll' does not name a type
    6 | ll answer,h[1000000];
      | ^~
a.cc: In function 'int main()':
a.cc:13:16: error: 'h' was not declared in this scope
   13 |         cin >> h[i];
      |                ^
a.cc:18:7: error: 'answer' was not declared in this scope
   18 |       answer =+ data[i];
      |       ^~~~~~
a.cc:20:17: error: 'answer' was not declared in this scope
   20 |         cout << answer << endl;
      |                 ^~~~~~
Language: C++

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

long long k, n,sum,x;

int main() {
	std::vector<long long> data;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
     	cin >> h;
        data.push_back(h);
	}
    sort(data.begin(),data.end(),greater<long long>());//降順ソート
    data.erase(data.begin(), data.begin() + k);
    for (long long i : data){
      sum =+ i;
    }
	cout << sum << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:16: error: 'h' was not declared in this scope
   11 |         cin >> h;
      |                ^
Language: C++

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

long k, n,sum,x;

long main() {
	std::vector<long> data;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
     	cin >> h;
        data.push_back(h);
	}
    sort(data.begin(),data.end(),greater<long>());//降順ソート
    data.erase(data.begin(), data.begin() + k);
    for (long i : data){
      sum =+ i;
    }
	cout << sum << endl;
	return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:11:16: error: 'h' was not declared in this scope
   11 |         cin >> h;
      |                ^
Language: C++

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

long k, n,sum,x;

int main() {
	std::vector<long> data;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
     	cin >> h;
        data.push_back(h);
	}
    sort(data.begin(),data.end(),greater<long>());//降順ソート
    data.erase(data.begin(), data.begin() + k);
    for (long i : data){
      sum =+ i;
    }
	cout << sum << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:16: error: 'h' was not declared in this scope
   11 |         cin >> h;
      |                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int sum=0;
  long int n,i;
  cin>>n>>k;
  long int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  for(i=0;i<n-k;i++)
  {
    sum+=a[i];
  }
  cout<<sum;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:11: error: 'k' was not declared in this scope
    7 |   cin>>n>>k;
      |           ^
Language: C++

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

const int N = 1e5 + 100;

int k, n, a[N], sum,x;

int main() {
	std::vector<int> data;
	cin >> n >> k;
     	cin >> x;
        data.push_back(x);
	}
    sort(data.begin(),data.end(),greater<int>());//降順ソート
    data.erase(data.begin(), data.begin() + k);
    for (int i : data){
      sum =+ i;
    }
	cout << sum << endl;
	return 0;
}


Compiler output:
a.cc:15:9: error: expected constructor, destructor, or type conversion before '(' token
   15 |     sort(data.begin(),data.end(),greater<int>());//降順ソート
      |         ^
a.cc:16:5: error: 'data' does not name a type
   16 |     data.erase(data.begin(), data.begin() + k);
      |     ^~~~
a.cc:17:5: error: expected unqualified-id before 'for'
   17 |     for (int i : data){
      |     ^~~
a.cc:20:9: error: 'cout' does not name a type
   20 |         cout << sum << endl;
      |         ^~~~
a.cc:21:9: error: expected unqualified-id before 'return'
   21 |         return 0;
      |         ^~~~~~
a.cc:22:1: error: expected declaration before '}' token
   22 | }
      | ^
Language: C++

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

const int N = 1e5 + 100;

int k, n, a[N], sum,x;

int main() {
	std::vector<int> data;
  
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		//cin >> a[i];
		//sum += a[i];
     	cin >> x;
        data.push_back(x);
	}
  	sort(data.end(),data.begin());
    //iterator erase(const_iterator first, const_iterator last);
    v.erase(v.begin(), v.begin() + k);
    for (int i : data){
      sum =+ i;
    }
	cout << sum << endl;
	//cout << (sum >= h? "Yes" : "No") << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:5: error: 'v' was not declared in this scope
   21 |     v.erase(v.begin(), v.begin() + k);
      |     ^
Language: C++

#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int H, N;
  scanf("%d %d", &N,&H);

  
  if(H>= N ){
    printf("0\n",);
    return 0;
  }

  vector<int> A;
  for (int i=0; i<N; i++){
    int kari;
    scanf("%d", &kari);
    A.push_back(kari);
  }
  sort(A.begin(), A.end());

  int sum=0;
  for (int i=0; i<N-H ; i++){
    sum += A[i];
  }  
  printf("%d\n", sum);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:18: error: expected primary-expression before ')' token
   14 |     printf("0\n",);
      |                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
  ll n.k,tmp;
  vector<ll> vec(0);
  cim >> n >> k;
  rep(i,n){
    cin >> tmp;
    vec.push_back(tmp);
  }
  sort(vec.begin(),vec.end());
  tmp=0;
  rep(i,n-k)tmp+=vec.at(i);
  cout << tmp << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:7: error: expected initializer before '.' token
    6 |   ll n.k,tmp;
      |       ^
a.cc:8:3: error: 'cim' was not declared in this scope
    8 |   cim >> n >> k;
      |   ^~~
a.cc:8:10: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |   cim >> n >> k;
      |          ^
      |          yn
a.cc:8:15: error: 'k' was not declared in this scope
    8 |   cim >> n >> k;
      |               ^
a.cc:10:12: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   10 |     cin >> tmp;
      |            ^~~
      |            tm
a.cc:14:3: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   14 |   tmp=0;
      |   ^~~
      |   tm
Language: C

#include<stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(void){
	int n,k,i,j;
	unsigned long h[200000],sum=0,temp;

	scanf("%d %d",&n,&k);

	for(i=0;i<n;i++){
		scanf("%lu",&h[i]);
	}

	qsort(h,n,sizeof(unsigned long),compare_int)

	if(n>k){
		for(i=k;i<n;i++){
			sum+=h[i];
		}
	}

	printf("%lu\n",sum);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:17:53: error: expected ';' before 'if'
   17 |         qsort(h,n,sizeof(unsigned long),compare_int)
      |                                                     ^
      |                                                     ;
   18 | 
   19 |         if(n>k){
      |         ~~