criyle/codenet-compile-errors huggingface dataset:
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> p(n);
  for(i, n){
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  int ans = 0;
  for(i, k){
    ans += p.at(i);
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: 'i' was not declared in this scope
    8 |   for(i, n){
      |       ^
a.cc:11:7: error: could not convert 'std::sort<__gnu_cxx::__normal_iterator<int*, vector<int> > >(p.std::vector<int>::begin(), p.std::vector<int>::end())' from 'void' to 'bool'
   11 |   sort(p.begin(), p.end());
      |   ~~~~^~~~~~~~~~~~~~~~~~~~
      |       |
      |       void
a.cc:12:30: error: expected ')' before ';' token
   12 |   reverse(p.begin(), p.end());
      |                              ^
      |                              )
a.cc:8:6: note: to match this '('
    8 |   for(i, n){
      |      ^
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   for(i, k){
      |       ^
a.cc:18:3: error: expected primary-expression before 'return'
   18 |   return 0;
      |   ^~~~~~
a.cc:17:23: error: expected ')' before 'return'
   17 |   cout << ans << endl;
      |                       ^
      |                       )
   18 |   return 0;
      |   ~~~~~~               
a.cc:14:6: note: to match this '('
   14 |   for(i, k){
      |      ^
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Prob2 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int chosen = scanner.nextInt();
		int[] numbers = new int[length];
		for(int i = 0; i < length; i++) 
			numbers[i] = scanner.nextInt();
		
		Arrays.sort(numbers);
		
		long result = 0l;
		for(int i = 0; i < chosen; i++) 
			result += numbers[i];
		System.out.print(result);
	}
}


Compiler output:
Main.java:4: error: class Prob2 is public, should be declared in a file named Prob2.java
public class Prob2 {
       ^
1 error
Language: C++

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

int main() {
  ll N, K;
  cin >> N >> K;
  ll pi;
  vector<ll> p;
  for (ll i=0;i<N;i++) {
  	cin >> pi;
    p.push_bask(pi);
  }
  sort(p.begin(), p.end());
  
  ll sum=0;
  for (ll i=0;i<K;i++) {
  	sum+=p[i];
  }
  cout << sum;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: 'class std::vector<long long int>' has no member named 'push_bask'; did you mean 'push_back'?
   12 |     p.push_bask(pi);
      |       ^~~~~~~~~
      |       push_back
Language: C++

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;

int main(){
	IOS;
	ll n;
	cin >> n;
	ll a[n + 1];
	loop(i, 1, n + 1)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	ll ans = 0;
	loop(i, 1, k + 1)
		ans += a[i];
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:20: error: 'k' was not declared in this scope
   57 |         loop(i, 1, k + 1)
      |                    ^
a.cc:7:42: note: in definition of macro 'loop'
    7 | #define loop(i,start,n) for(ll i=start;i<n;i++)
      |                                          ^
Language: C++

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

int main() {
  ll N, K;
  cin >> N >> K;
  ll pi;
  vector<ll> p;
  for (ll i=0;i<N;i++) {
  	cin >> pi;
    p.push_bask(pi);
  }
  sort(p.begin(), p.end());
  
  ll sum=0;
  for (ll i=0;i<K;i++) {
  	sum+=p[i];
  }
  cout << sum;
}


Compiler output:
a.cc:5:1: error: expected initializer before 'int'
    5 | int main() {
      | ^~~
Language: C++

#include <iostream>
#include<vector>
using namespace std;
int main() {
  int n, k, p, sum = 0;
  vector<int> v;
  scanf("%d %d", &n , &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p);
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < k; i++) {
    sum += v[i];
  }
  printf("%d\n", sum);
}

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

int main(void)
{
  int size,reps;
  scanf("%d%d",&size,&reps);
  int i=0,arr[size]=0;
  
  while(i<size)
  {
    scanf("%d",&arr[i]);
    i++;
  }
  
 int sum=0,min[reps],j=0,l;
 print("\n");
  
  
   for(i=0;i<size;i++)
   {
    for(l=0;l<size;l++)
    {
      if(arr[i]>arr[j])
      {
        int tmp=arr[i];
        arr[i]=arr[j];
        arr[j]=tmp;
      }
    }
     
 while(j!=reps)
 {
  sum=arr[j]+sum;      	
 }
     printf("%d",sum);
   
  

Compiler output:
main.c: In function 'main':
main.c:4:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    4 |   scanf("%d%d",&size,&reps);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(void)
main.c:4:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    4 |   scanf("%d%d",&size,&reps);
      |   ^~~~~
main.c:4:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:5:21: error: variable-sized object may not be initialized except with an empty initializer
    5 |   int i=0,arr[size]=0;
      |                     ^
main.c:14:2: error: implicit declaration of function 'print' [-Wimplicit-function-declaration]
   14 |  print("\n");
      |  ^~~~~
main.c:33:6: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   33 |      printf("%d",sum);
      |      ^~~~~~
main.c:33:6: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:33:6: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:33:6: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:33:6: error: expected declaration or statement at end of input
main.c:33:6: error: expected declaration or statement at end of input
Language: C++

#include <iostream>
using namespace std;
#define ll long long int
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll i;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll sum=0;
    for(i=0;i<k;i++){
        sum = sum+a[i];
    }
    cout<<sum;
}


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

#include<stdio.h>
#include<stdlib.h>
int compare_int(const void *a,const void *b)
{
 return *(int*)a - *(int*)b; 
}
int main()
{
  int N,K,ans=0;
  int i;
  int p[1000];
	scanf("%d %d\n",&N,&K);
  	for(i=0;i<N,i++){
     scanf("%d ",&p[i]); 
    }
  	 
  	qsort(p,N,sizeof(int),compare_int);
  	for(i=0;i<K;i++){
     ans+=p[i]; 
    }
  	printf("%d\n",ans);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:13:24: error: expected ';' before ')' token
   13 |         for(i=0;i<N,i++){
      |                        ^
      |                        ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  vector<int> fruit(n);
  
  cin >> n;
  for(int i=0;i<n;n++){
    cin >> fruit.at(i);
    }
  
  sort(fruit.begin(), fruit.end());
  
  int goukei=0;
  for(int j=0;j<n;j++){
    goukei += fruit.at(j);
    if(j==n-1)｛
      cout << goukei << endl;
    }
    }
  }
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:18:15: error: '\U0000ff5b' was not declared in this scope
   18 |     if(j==n-1)｛
      |               ^~
a.cc: At global scope:
a.cc:22:3: error: expected declaration before '}' token
   22 |   }
      |   ^
Language: C++

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> p;
  for (ll i=0;i<N;i++) cin >> p[i];
  sort(p.begin(), p.end());
  
  ll sum=0;
  for (ll i=0;i<K;i++) {
  	sum+=p[i];
  }
  cout << sum;
}


Compiler output:
a.cc:5:1: error: expected initializer before 'int'
    5 | int main() {
      | ^~~
Language: C

#include<stdio.h>

int amin(void){
    int N,K;
    scanf("%d %d", &N, &K);

    int p[N];
    int temp,sum=0;
    for(int i=0;i<N;i++){
        scanf("%d", &p[i]);
    }

    for(int j=0;j<N;j++){
        for(int k=j+1;k<N;k++){
            if(p[j]>p[k]){
                temp = p[j];
                p[j] = p[k];
                p[k] = temp;
            }
        }
    }

    for(int n=0;n<K;n++){
        sum += p[n];
    }

    printf("%d", sum);

    return 0;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

using namespace std;
#include<iostream>
int main()
{
int n,k,a[100];
int sum=0,j;
cin>>n>>k;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
int temp;
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<k;i++)
{
sum=sum+a[i];
}
cout<<sum;
}



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

import java.util.Arrays;
import java.util.Scanner;

public class B {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		int[] arr = new int[t];
		int type = scan.nextInt();
		for (int count = 0; count < t; count++)
			arr[count] = scan.nextInt();
		Arrays.sort(arr); int sum = 0;
		for (int count = 0; count < type; count++)
			sum += arr[count];
		System.out.println(sum);
		scan.close();
	}
}


Compiler output:
Main.java:4: error: class B is public, should be declared in a file named B.java
public class B {
       ^
1 error
Language: C++

#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n, k; cin >> n >> k;
    vector<int> p(n); for(int i=0; i<n; ++i){cin >> p[i];}
    sort(p.begin(), p.end());
    int res = 0;
    for(int i=0; i<k; ++i){
        res += p[i];
    }
    cout << res << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:15: error: 'cin' was not declared in this scope
    6 |     int n, k; cin >> n >> k;
      |               ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <vector>
  +++ |+#include <iostream>
    4 | using namespace std;
a.cc:13:5: error: 'cout' was not declared in this scope
   13 |     cout << res << endl;
      |     ^~~~
a.cc:13:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:13:20: error: 'endl' was not declared in this scope
   13 |     cout << res << endl;
      |                    ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    3 | #include <vector>
  +++ |+#include <ostream>
    4 | using namespace std;
Language: Java

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.CountDownLatch;

public class Main {

	public static void main(String args[]) {

		Scanner scanner = new Scanner(System.in);

		
		String[] nk =  scanner.nextLine().split(" ");
		int[] ar = new int[Integer.parseInt(nk[0])];
		
		for(int i = 0; i < Integer.parseInt(nk[0]) ; i++) {
			ar[i] = scanner.nextInt();
		}
		
//		System.out.println(Arrays.toString(ar));
		
		Arrays.sort(ar);
		
		
//		System.out.println(Arrays.toString(ar));
		
		int sum=0;
		for(int i = 0; i < Integer.parseInt(nk[1]); i++) {
			sum+= ar[i];
		}
		
		
		System.out.println(sum);
		
//		5 3 50 100 80 120 80
	}

Compiler output:
Main.java:42: error: reached end of file while parsing
	}
	 ^
1 error
Language: Java

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[] alpha = new int[N];
     for(int i=0;i<N;i++){
       alpha[i]= sc.nextInt();
     }
     for (int j = 1; j < alpha.length; j++) {
            int key = alpha[j];
            i = j - 1;
            while (i >= 0 && alpha[i] > key) {
                alpha[i + 1] = alpha[i];
                i--;
            }
            alpha[i + 1] = key;
        }
     System.out.println(alpha[0]+alpha[1]+alpha[2]+alpha[3]);

   }
   
}


Compiler output:
Main.java:7: error: cannot find symbol
     int[] alpha = new int[N];
                           ^
  symbol:   variable N
  location: class Main
Main.java:8: error: cannot find symbol
     for(int i=0;i<N;i++){
                   ^
  symbol:   variable N
  location: class Main
Main.java:13: error: cannot find symbol
            i = j - 1;
            ^
  symbol:   variable i
  location: class Main
Main.java:14: error: cannot find symbol
            while (i >= 0 && alpha[i] > key) {
                   ^
  symbol:   variable i
  location: class Main
Main.java:14: error: cannot find symbol
            while (i >= 0 && alpha[i] > key) {
                                   ^
  symbol:   variable i
  location: class Main
Main.java:15: error: cannot find symbol
                alpha[i + 1] = alpha[i];
                      ^
  symbol:   variable i
  location: class Main
Main.java:15: error: cannot find symbol
                alpha[i + 1] = alpha[i];
                                     ^
  symbol:   variable i
  location: class Main
Main.java:16: error: cannot find symbol
                i--;
                ^
  symbol:   variable i
  location: class Main
Main.java:18: error: cannot find symbol
            alpha[i + 1] = key;
                  ^
  symbol:   variable i
  location: class Main
9 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  int x=0;
  cin>>n>>k;
  vector<int>vec (n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);}
  
  sort(vec.begin,vec.end());
  for (int i=0;i<k;i++){
    x+=vec.at(i);}
  cout<<x<<endl;}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:11:7: error: no matching function for call to 'sort(<unresolved overloaded function type>, std::vector<int>::iterator)'
   11 |   sort(vec.begin,vec.end());
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:32: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |          ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided
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;
  scanf("%d%d", &n, &k);
  int p[1001] = { 0 };
  for(int i = 1;i <= n;i++) {
    scanf("%d", p + i);
  }
  qsort(p, compare_int);
  int sum = 0;
  for(int i = 0;i < k;i++) {
    sum += p[n-i];
  }
  printf("%d\n", sum);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:16:12: error: passing argument 2 of 'qsort' makes integer from pointer without a cast [-Wint-conversion]
   16 |   qsort(p, compare_int);
      |            ^~~~~~~~~~~
      |            |
      |            int (*)(const void *, const void *)
In file included from main.c:2:
/usr/include/stdlib.h:970:41: note: expected 'size_t' {aka 'long unsigned int'} but argument is of type 'int (*)(const void *, const void *)'
  970 | extern void qsort (void *__base, size_t __nmemb, size_t __size,
      |                                  ~~~~~~~^~~~~~~
main.c:16:3: error: too few arguments to function 'qsort'
   16 |   qsort(p, compare_int);
      |   ^~~~~
/usr/include/stdlib.h:970:13: note: declared here
  970 | extern void qsort (void *__base, size_t __nmemb, size_t __size,
      |             ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin>>N>>K;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int ans=0;
  for(int=0;i<K;i++){
    ans=ans+vec.at(i);
  }
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:10: error: expected unqualified-id before '=' token
   13 |   for(int=0;i<K;i++){
      |          ^
a.cc:13:10: error: expected ';' before '=' token
   13 |   for(int=0;i<K;i++){
      |          ^
      |          ;
a.cc:13:10: error: expected primary-expression before '=' token
a.cc:13:13: error: 'i' was not declared in this scope
   13 |   for(int=0;i<K;i++){
      |             ^
a.cc:13:16: error: expected ')' before ';' token
   13 |   for(int=0;i<K;i++){
      |      ~         ^
      |                )
a.cc:13:17: error: 'i' was not declared in this scope
   13 |   for(int=0;i<K;i++){
      |                 ^
Language: C++

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

int main() {
	int n ,k; 
  cin >> n >> k;
  
  int arr[1000];
  for (int i = 0; i < n; i++) 
    cin >> arr[i]

    sort(arr, arr+n);
    int sum = 0;
  for (int i = 0; i < k; i++) {
	sum += arr[i];
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:18: error: expected ';' before 'sort'
   10 |     cin >> arr[i]
      |                  ^
      |                  ;
   11 | 
   12 |     sort(arr, arr+n);
      |     ~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  int x=0;
  cin>>n>>k;
  vector<int>vec (n);
  sort(vec.begin,vec.end());
  for (int i=0;i<k;i++){
    x+=vec.at(i);}
  cout<<x<<endl;}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: no matching function for call to 'sort(<unresolved overloaded function type>, std::vector<int>::iterator)'
    8 |   sort(vec.begin,vec.end());
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:32: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |          ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided
Language: C++

N,K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
sort = sorted(p)
print(sum(sort[:K]))

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N,K = [int(x) for x in input().split()]
      | ^
Language: Java

import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner obj=new Scanner(System.in);
    int n=obj.nextInt();
    int m=obj.nextInt();
    int a[]=new int[n]
    for(int i=0;i<n;i++){
		a[i]=obj.nextInt();}
    Arrays.sort(a);
    int sum=0;
    for(int i=0;i<m;i++)
    sum=sum+a[i];  
    System.out.println(sum);
  }
}

Compiler output:
Main.java:7: error: ';' expected
    int a[]=new int[n]
                      ^
1 error
Language: C++

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

int main() {
  int N,K;cin>>N>>K;
  vector<int> vec(N);
  for (int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int S=0;
  for (int j=0;j<K;j++){
    S = S + vec.at(j);
  }
  cout<<S<<endl;
    
}


Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | z#include <bits/stdc++.h>
      |  ^
a.cc:1:1: error: 'z' does not name a type
    1 | z#include <bits/stdc++.h>
      | ^
a.cc: In function 'int main()':
a.cc:5:11: error: 'cin' was not declared in this scope
    5 |   int N,K;cin>>N>>K;
      |           ^~~
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int> vec(N);
      |   ^~~~~~
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int> vec(N);
      |          ^~~
a.cc:8:10: error: 'vec' was not declared in this scope
    8 |     cin>>vec.at(i);
      |          ^~~
a.cc:10:8: error: 'vec' was not declared in this scope
   10 |   sort(vec.begin(), vec.end());
      |        ^~~
a.cc:10:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |   sort(vec.begin(), vec.end());
      |   ^~~~
      |   short
a.cc:15:3: error: 'cout' was not declared in this scope
   15 |   cout<<S<<endl;
      |   ^~~~
a.cc:15:12: error: 'endl' was not declared in this scope
   15 |   cout<<S<<endl;
      |            ^~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:11: error: expected ';' before ':' token
    7 |   cin >> k:
      |           ^
      |           ;
a.cc:10:12: error: 't' was not declared in this scope
   10 |     cin >> t[i];
      |            ^
a.cc:11:8: error: 't' was not declared in this scope
   11 |   sort(t, t + n);
      |        ^
Language: C++

#include<iostream>

#include<vector>

using namespace std;

int main(){

  int n,k;

  cin>>n>>k;

  vector<int>ok(n);

  

  for(int i=0;i<n;i++){

  	cin>>ok[i];  }

  sort(ok.begin(),ok.end());

  int ans=0;

  for(int i=0;i<k;i++){

  	ans+=ok[i];

  }

  cout<<ans<<'\n';

  	

  

    

}

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

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

int main(){
    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    for (int i=0; i<n; i++){
        cin >> v.at(i);
    }

    sort(v.begin(), v.end());

    int total = 0;
    for (int j=0; j<k; j++){
        total += v.at(j);
    }
    cout << total << endl;
}

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

#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;

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


    cout << sum << endl;

    return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

int main() {

  int n,k;
  
  cin >> n >> k;
  
  int arr[1000];
  
  for (int i - 0; i < n; i++) {
	cin >> arr[i];
  }
  
  sort(arr, arr+n);
  
  int sum = 0;
  for (int i = 0; i< k; i++) {
	sum += arr[i];

  }
  
  cout << sum << "\n";

}









Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: expected ';' before '-' token
   13 |   for (int i - 0; i < n; i++) {
      |             ^~
      |             ;
a.cc:13:24: error: expected ')' before ';' token
   13 |   for (int i - 0; i < n; i++) {
      |       ~                ^
      |                        )
a.cc:13:26: error: 'i' was not declared in this scope
   13 |   for (int i - 0; i < n; i++) {
      |                          ^
Language: C++


#include <iostream>
#include <vector>

using namespace std;
int main()
{
    vector<int> v;
    int N,K;
    cin >> N >> K;
    while(N--)
    {
        int num;
        cin >> num;
        v.push_back(num);
    }
    sort(v.begin(),v.end());
    int sum =0;
    for(int i=0;i<K;i++)
    {
        sum+=v[i];
    }
    cout << sum <<"\n";
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |     sort(v.begin(),v.end());
      |     ^~~~
      |     short
Language: Java

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[] alpha = new int[N];
     for(int i=0;i<N;i++){
       alpha[i]= sc.nextInt();
     }
     sort(alpha);
     System.out.println(alpha[0]+alpha[1]+alpha[2]+alpha[3]);

   }
   private static void sort(int[] array) {//[10]
       int elementEndIndex = array.length - 1;//[11]
       for (int comparisonEndIndex = 0; comparisonEndIndex < elementEndIndex; comparisonEndIndex++) {//[12]
           swapIfGreaterThan(array, comparisonEndIndex, elementEndIndex);//[13]
       }
   }
   private static void swapIfGreaterThan(int[] array, int comparisonEndIndex, int elementEndIndex) {//[20]
       for (int comparisonIndex = elementEndIndex; comparisonIndex > comparisonEndIndex; comparisonIndex--) {//[21]
           if(array[comparisonIndex] < array[comparisonIndex - 1]) {//[22]
               swapElementOfArray(array, comparisonIndex);//[23]
           }
       }
   }
   private static void swapElementOfArray(int[] array, int index) {//[30]
       int temp = array[index];//[31]
       array[index] = array[index - 1];//[32]
       array[index - 1] = temp;//[33]
   }
}


Compiler output:
Main.java:7: error: cannot find symbol
     int[] alpha = new int[N];
                           ^
  symbol:   variable N
  location: class Main
Main.java:8: error: cannot find symbol
     for(int i=0;i<N;i++){
                   ^
  symbol:   variable N
  location: class Main
2 errors
Language: C++

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    int p;
    cin>>p;
    P.at(i)=p;
  }
  sort(P.begin(),P.end());
  int ans=0;
  for(int j=0;j<K;j++){
    ans+=P.at(j);
  }
  cout<<ans<<enndl;
}


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

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[] p=new int[N];
		for( int i=0;i<N;i++){
          p[i]=sc.nextInt();
        }
        Arrays.sort(p,Collections.reverseOrder());
        int syutu=0;
        for(int i=0;i<K;i++){
          syutu=syutu+p[i];
        }
        System.out.println(syutu);
}
}

Compiler output:
Main.java:12: error: no suitable method found for sort(int[],Comparator<Object>)
        Arrays.sort(p,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 endl '\n'
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,k;
    int arr[1000]={0};
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int inp;
        cin>>arr[i];
    }
    int tmp;
    for(int i=n-1;i>0;i--){
        for(int j=0;j<=i-1;j++){
            if(arr[j]>arr[j+1]){
                tmp = arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=tmp;    
            }
        }
    }
    int ans=0;
    for(int i=0;i<k;i++){
        ans = ans + arr[i];
    }
    cout<<ans;


}  

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:5:5: error: 'ios' has not been declared
    5 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:6:5: error: 'cin' was not declared in this scope
    6 |     cin.tie(NULL);
      |     ^~~
a.cc:6:13: error: 'NULL' was not declared in this scope
    6 |     cin.tie(NULL);
      |             ^~~~
a.cc:1:1: note: 'NULL' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | include <bits/stdc++.h>
a.cc:29:5: error: 'cout' was not declared in this scope
   29 |     cout<<ans;
      |     ^~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
  int K,N;
  int p[1000];
  int tmp;
  int sum=0;

  cin >> K >> N;

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

  for(int i=0; i<N; ++i)
  {
    for(int j=0; j<N-1; ++j)
    {
      if(p[i] > p[i+1])
      {
        tmp = p[i];
        p[i] = p[i+1];
        p[i+1] = tmp;
      }
    }
  }

  for(int i=0; i<K; ++i)
  {
    sum += p[i];
  }

  cout << p[i] << endl;

  //cout << fixed << setprecision(8) << s << " " << l << " " << endl;

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:38:13: error: 'i' was not declared in this scope
   38 |   cout << p[i] << endl;
      |             ^
Language: Java

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[] p=new int[N];
		for(for int i=0;i<N;i++){
          p[i]=sc.nextInt();
        }
        Arrays.sort(p,Collections.reverseOrder());
        int syutu=0;
        for(for int i=0;i<K;i++){
          syutu=syutu+p[i];
        }
        System.out.println(syutu);
}
}

Compiler output:
Main.java:9: error: illegal start of expression
		for(for int i=0;i<N;i++){
		    ^
Main.java:9: error: '(' expected
		for(for int i=0;i<N;i++){
		       ^
Main.java:14: error: illegal start of expression
        for(for int i=0;i<K;i++){
            ^
Main.java:14: error: '(' expected
        for(for int i=0;i<K;i++){
               ^
4 errors
Language: C++

#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;

int main(){
    int n=0;
    int k=0;
    cin >> n >> k;
    int p[n+1];
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> p[i] ;
    }
    sort(p,p+n);
    for(int i=0;i<k;i++){
        sum += p[i];
    }


    cout << sum << endl;

    return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p.at(i);
	}
	sort(p.begin(), p.end());
	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += p.at(i);
	}
	cout << sum << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:9: error: 'cin' was not declared in this scope
    3 |         cin >> N >> K;
      |         ^~~
a.cc:4:9: error: 'vector' was not declared in this scope
    4 |         vector<int> p(N);
      |         ^~~~~~
a.cc:4:16: error: expected primary-expression before 'int'
    4 |         vector<int> p(N);
      |                ^~~
a.cc:6:24: error: 'p' was not declared in this scope
    6 |                 cin >> p.at(i);
      |                        ^
a.cc:8:14: error: 'p' was not declared in this scope
    8 |         sort(p.begin(), p.end());
      |              ^
a.cc:8:9: error: 'sort' was not declared in this scope; did you mean 'short'?
    8 |         sort(p.begin(), p.end());
      |         ^~~~
      |         short
a.cc:13:9: error: 'cout' was not declared in this scope
   13 |         cout << sum << endl;
      |         ^~~~
a.cc:13:24: error: 'endl' was not declared in this scope
   13 |         cout << sum << endl;
      |                        ^~~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
int main()
{
  int n,k,sum=0;
  scanf("%d %d,&n,&k);
        int arr[n];
        for(int i=0;i<n;i++)
        {
          scanf("%d",&arr[i]);
        }
        sort(arr,arr+n);
        for(int i=0;i<k;i++)
        {
          sum+=arr[i];
        }
        printf("%d",sum);
        
  return 0;
}

Compiler output:
a.cc:7:9: warning: missing terminating " character
    7 |   scanf("%d %d,&n,&k);
      |         ^
a.cc:7:9: error: missing terminating " character
    7 |   scanf("%d %d,&n,&k);
      |         ^~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:8:9: error: expected primary-expression before 'int'
    8 |         int arr[n];
      |         ^~~
a.cc:11:23: error: 'arr' was not declared in this scope
   11 |           scanf("%d",&arr[i]);
      |                       ^~~
a.cc:13:14: error: 'arr' was not declared in this scope
   13 |         sort(arr,arr+n);
      |              ^~~
a.cc:13:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   13 |         sort(arr,arr+n);
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
Language: Java


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class C {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int n = fr.nextInt();
        int k = fr.nextInt();
        ArrayList<Integer> arrayList = new ArrayList<>();
        for(int i=0;i<n;i++){
            int val = fr.nextInt();
            arrayList.add(val);
        }
        Collections.sort(arrayList);
        int ans = 0;
        for(int i=0;i<k;i++){
            ans+=(arrayList.get(i));
        }
        System.out.println(ans);
    }
}

Compiler output:
Main.java:7: error: class C is public, should be declared in a file named C.java
public class C {
       ^
1 error
Language: Java

import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
      	int k = Integer.parseInt(sc.next());
      	ArrayList<Integer> list = new ArrayList<>();
      	for(int cnt = 0;cnt < n;cnt++){
        	list.add(Integer.parseInt(sc.next()));
        }
      	list.sort();
      	int total = 0;
      	for(int cnt = 0;cnt < k;cnt++){
        	total += list.get(cnt);
        }
      	System.out.println(total);
	}
}

Compiler output:
Main.java:12: error: method sort in class ArrayList<E> cannot be applied to given types;
      	list.sort();
      	    ^
  required: Comparator<? super Integer>
  found:    no arguments
  reason: actual and formal argument lists differ in length
  where E is a type-variable:
    E extends Object declared in class ArrayList
1 error
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'sum' was not declared in this scope
   11 |   sum=0;
      |   ^~~
Language: C++

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    vector<int> p;
    int N, K;
    cin >> N >> K;

    for(int i = 0; i < N; ++i){
        int price;
        cin >> price;
        p.push_back(price);
    }
    std::sort(p.begin(), p.end());
    int sum = 0;
    for(int i=0; i < K; ++i){
        sum += p[i];
    }
    cout << sum << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   17 |     std::sort(p.begin(), p.end());
      |          ^~~~
      |          qsort
Language: C++

#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <list>
#include <vector>
#include <queue>
#include <bitset>
#include <cctype>

typedef long long ll;
#define nn cout << '\n'
#define rep(n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i <n; i++)

using namespace std;


void testcase() {
	int n, k; cin >> n >> k;
	vector<pair<int,int>> v(n);
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		v[i - 1] = make_pair(x,i);
	}
	sort(v.begin(), v.end());
	ll sum = 0;
	for (int i = 0; i < k; i++) {
		sum += v[i].first;
	}

	cout << sum;


}


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

	int x = 1;
	rep(x) {
		testcase();
		nn;

	}
	return 0;
}

/*

*/

Compiler output:
a.cc: In function 'void testcase()':
a.cc:28:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   28 |         sort(v.begin(), v.end());
      |         ^~~~
      |         short
Language: C++

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

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

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

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

int main(){
  int n , k ;
  cin >> n >> k ;
  int ans = 0;
  vector<int> mon(1100,3000);
  sort(mon.begin(),mon.end());
  
  for(int i=0;i<K;i++){
    ans += mon[i] ;
  }
  
  cout << ans << endl;
}
  

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

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	int N,K;
	int sum;
	cin >>N >>K;

	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}

	sort(vec.bigin(), vec.end());

	for (int i = 0; i < K; i++) {
		sum +=  vec.at(N-1-i);
	}

	cout << sum;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:18: error: 'class std::vector<int>' has no member named 'bigin'; did you mean 'begin'?
   15 |         sort(vec.bigin(), vec.end());
      |                  ^~~~~
      |                  begin
Language: Java

import java.math.*;

class Main
{

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		int sum = 0;
		for(int i=0;i<n;i++){
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		for(int i=0;i<k;i++){
			sum += arr[i];
		}
		System.out.println(sum);
	}
}

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

#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, K, ans=0;
    cin >> N >> K;
   vector<int> p(N);
    for(int i=0; i<N; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    for(int i=0; i<K; i++){
        ans += p[i];
    }
    cout << ans << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
using namespace std;

int main () {
  int N,K;
  cin >> N >> K;
  vector<int> name(3);
  for (int i=0; i<N; i++){
    cin >> name[i];
  }
  sort(name.begin(),name.end());
  int cnt = 0;
  for (int i=0; i<K; i++){
    cnt += name[i];
  }
  cout << cnt << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> name(3);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> name(3);
      |          ^~~
a.cc:9:12: error: 'name' was not declared in this scope; did you mean 'tzname'?
    9 |     cin >> name[i];
      |            ^~~~
      |            tzname
a.cc:11:8: error: 'name' was not declared in this scope; did you mean 'tzname'?
   11 |   sort(name.begin(),name.end());
      |        ^~~~
      |        tzname
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |   sort(name.begin(),name.end());
      |   ^~~~
      |   short