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

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

}



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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:7: error: invalid types '<unresolved overloaded function type>[int*]' for array subscript
   11 |   sort[x,x+n];
      |       ^
Language: C++

#include<bits/stdc++.h>
#define endl '\n'
#define fo(i,n)        for(int i=0; i<n; i++)
#define foa(i,k,n)     for(int i=k; i<=n; i++)
#define fod(i,k,n)     for(int i=n; i>=k; i--)
#define clr(arr)       memset(arr, 0, sizeof arr)
#define hi(x)          cout<<" -> "<<#x<<" : "<<x<<endl;
using namespace std;
const int mod = 1e9 + 7;

int a[1001];
void solve()
{
// #define T
	int n, k;
	cin>>n>>k;
	for(int i=0; i<n; i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0; i<k; i++)
		ans+=a[i];
	cout<<ans<<endl;
}

int32_t main()
{
///////////////////////////////////////////////////////
#ifdef FIN
	freopen("in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
///////////////////////////////////////////////////////

	int t = 1;
#ifdef T
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:21:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |                 ans+=a[i];
      |                 ^~~
      |                 abs
a.cc:22:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |         cout<<ans<<endl;
      |               ^~~
      |               abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n,k;
  cin>>n>>k;
  veci v(n);
  rep(i,n)cin>>v[i];
  sort(v.vegin(),v.end());
  int sum=0;
  rep(j,k)sum+=v[j];
  cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: 'veci' {aka 'class std::vector<int>'} has no member named 'vegin'; did you mean 'begin'?
   19 |   sort(v.vegin(),v.end());
      |          ^~~~~
      |          begin
Language: C++

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

int main(){
    int a,b,x=0;
    cin>>a>>b;
    vector <int> n;
    for(int i=0;i<a;i++){
        cin>>n.push_back();
    }
    sort(n.begin(),n.end());
    for(int i=0;i<b;i++){
        x =x+n[i];
    }
    cout<<x<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:25: error: no matching function for call to 'std::vector<int>::push_back()'
    9 |         cin>>n.push_back();
      |              ~~~~~~~~~~~^~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   candidate expects 1 argument, 0 provided
Language: C++

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<>();
        for (String i : in) {
            list.add(Integer.parseInt(i));
        }

        br.close();

        Collections.sort(list);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += list.get(i);
        }

        bw.write(String.valueOf(ans));

        bw.flush();

    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.BufferedReader;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.BufferedWriter;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.io.InputStreamReader;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.io.OutputStreamWriter;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.util.ArrayList;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import java.util.Collections;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: expected unqualified-id before 'public'
    8 | public class Main {
      | ^~~~~~
Language: C++

#include<bits/stdc++.h>
int main(){
  int n,k;
  cin>>n>>k;
  int ar[n];
  for(int i=0;i<n;i++){
    cin>>ar[i];
  }
  sort(ar,ar+n);
  int s=0;
  for(int j=0;j<k;j++)
    s=s+ar[j];
  cout<<s<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    4 |   cin>>n>>k;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:9:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
    9 |   sort(ar,ar+n);
      |   ^~~~
      |   std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:13:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   13 |   cout<<s<<endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:13:12: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   13 |   cout<<s<<endl;
      |            ^~~~
      |            std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a,b,c=0,i,p[1010];
int main()
{
	cin>>a>>b;
	for(i=0;i<a;++i)cin>>p[i];
	sort(p,p+a);
	for(i=0;i<b;++i)ans+=p[i];
	cout<<c;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
    9 |         for(i=0;i<b;++i)ans+=p[i];
      |                         ^~~
      |                         abs
Language: C++

n,k=map(int,input().split())
l=list(map(int, input().split()))
l.sort()
s=0
for i in range(k):
    s += l[i]
print(s)


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,k=map(int,input().split())
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
int n,k;
cin>>n>>k;
ll a[n];
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
int sum=0;
for(int i=0;i<k;i++)
sum+=a[i];
cout<<sum;
}
  

  

Compiler output:
a.cc: In function 'int main()':
a.cc:8:1: error: 'll' was not declared in this scope
    8 | ll a[n];
      | ^~
a.cc:10:6: error: 'a' was not declared in this scope
   10 | cin>>a[i];
      |      ^
a.cc:11:6: error: 'a' was not declared in this scope
   11 | sort(a,a+n);
      |      ^
Language: Java

import java.util.Scanner;
import java.util.Arrays;
 
class Fruits{
 
public static void main(String...as){
Scanner sc=new Scanner(System.in);
  
  int totalFruits=sc.nextInt();
  int minimum=sc.nextInt();
  int prices[]=new int [totalFruits];
  for(int i=0;i<totalFruits;i++){
   prices[i]=sc.nextInt();
  }
	Arrays.sort(prices);
	int count=0;
  for(int i=0;i<minimum;i++){
  	count=count+price[i];
  }
  
  System.out.println(count);
 
}
}

Compiler output:
Main.java:18: error: cannot find symbol
  	count=count+price[i];
  	            ^
  symbol:   variable price
  location: class Fruits
1 error
Language: Java

import java.util.Scanner;
import java.util.Arrays;
 
class Fruits{
 
public static void main(String...as){
Scanner sc=new Scanner();
  
  int totalFruits=sc.nextInt();
  int minimum=sc.nextInt();
  int prices[]=new int [totalFruits];
  for(int i=0;i<totalFruits;i++){
   prices[i]=sc.nextInt();
  }
	Arrays.sort(prices);
	int count=0;
  for(int i=0;i<minimum;i++){
  	count=count+price[i];
  }
  
  System.out.println(count);
 
}
}

Compiler output:
Main.java:7: error: no suitable constructor found for Scanner(no arguments)
Scanner sc=new Scanner();
           ^
    constructor Scanner.Scanner(Readable,Pattern) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Readable) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,CharsetDecoder) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel,Charset) is not applicable
      (actual and formal argument lists differ in length)
Main.java:18: error: cannot find symbol
  	count=count+price[i];
  	            ^
  symbol:   variable price
  location: class Fruits
2 errors
Language: C++

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

using namespace std;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> a(n);
    for (int i=0; i<n; i++)
        scanf("%d", &a[i]);

    sort(begin(a), end(a));
    long long ret = 0;
    for (int i=0; i<m; i++)
        ret += a[i];

    printf("%lld\n", ret);

    return 0;
}

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(begin(a), end(a));
      |     ^~~~
      |     short
Language: Java

import java.util.Scanner;
import java.util.Arrays;
 
class Fruits{
 
public static void main(String...as){
Scanner sc=new Scanner();
  
  int totalFruits=sc.nextInt();
  int minimum=sc.nextInt();
  int prices[]=new int [totalFruits];
  for(int i=0;i<totalFruits;i++){
  	int prices[i]=sc.nextInt();
  }
	Arrays.sort(prices);
	int count=0;
  for(int i=0;i<minimum;i++){
  	count=count+price[i];
  }
  
  System.out.println(count);
 
}
 
}

Compiler output:
Main.java:13: error: ']' expected
  	int prices[i]=sc.nextInt();
  	           ^
Main.java:13: error: ';' expected
  	int prices[i]=sc.nextInt();
  	            ^
2 errors
Language: Java

import java.util.Scanner;
import java.util.Arrays;
 
class Fruits{
 
public static void main(String...as){
Scanner sc=new Scanner();
  
  int totalFruits=sc.nextInt();
  int minimum=sc.nextInt();
  int prices[]=new int [totalFruits];
  for(int i=0;i<totalFruits;i++){
  	 prices[i]=sc.nextInt();
  }
	Arrays.sort(prices);
	int count=0;
  for(int i=0;i<minimum;i++){
  	count=count+price[i];
  }
  
  System.out.println(count);
 
}
 

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

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

class Fruits{

public static void main(String...as){
Scanner sc=new Scanner();
  
  int totalFruits=sc.nextInt();
  int minimum=sc.nextInt();
  int prices[]=new int [totalFruits];
  for(int i=0;i<totalFruits;i++){
  	int prices[i]=sc.nextInt();
  }
	Arrays.sort(prices);
	int count=0;
  for(int i=0;i<minimum;i++){
  	count=count+price[i];
  }
  
  System.out.println(count);

}

}

Compiler output:
Main.java:13: error: ']' expected
  	int prices[i]=sc.nextInt();
  	           ^
Main.java:13: error: ';' expected
  	int prices[i]=sc.nextInt();
  	            ^
2 errors
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 prices = new int[n];
      	for(int i=0;i<n;i++){
        	prices[i] = sc.nextInt();
        }

		// 出力
		System.out.println(prices);
	}
}

Compiler output:
Main.java:10: error: incompatible types: int[] cannot be converted to int
      	int prices = new int[n];
      	             ^
Main.java:12: error: array required, but int found
        	prices[i] = sc.nextInt();
        	      ^
2 errors
Language: Java

import java.util.*;
 
public class Main {
 
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    int kinds = sc.nextInt();
    int select = sc.nextInt();
    List<Integer> priceList = new ArrayList<Integer>();
    while (sc.hasNext()) {
      priceList.add(sc.nextInt());
    }
       
    Collections.sort(priceList);
    System.out.println(priceList.subList(0,select)
                       .stream()
                       .sum());
  }
}

Compiler output:
Main.java:19: error: cannot find symbol
                       .sum());
                       ^
  symbol:   method sum()
  location: interface Stream<Integer>
1 error
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: expected ')' before ';' token
    9 |   sort(p, p+n;
      |       ~      ^
      |              )
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: request for member 'begin' in 'p', which is of non-class type 'int [n]'
    9 |   sort(p.begin(), p.end());
      |          ^~~~~
a.cc:9:21: error: request for member 'end' in 'p', which is of non-class type 'int [n]'
    9 |   sort(p.begin(), p.end());
      |                     ^~~
Language: C++


int main(){
    int N,K,p[1010];
    cin>>N>>K;
    for(int i=0;i<N;i++)cin>>p[i];
    sort(p,p+N);
    
    int ans = 0;
 for(int i = 0; i < K; ++i) ans += p[i];
 cout << ans << endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin>>N>>K;
      |     ^~~
a.cc:6:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    6 |     sort(p,p+N);
      |     ^~~~
      |     short
a.cc:10:2: error: 'cout' was not declared in this scope
   10 |  cout << ans << endl;}
      |  ^~~~
a.cc:10:17: error: 'endl' was not declared in this scope
   10 |  cout << ans << endl;}
      |                 ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, k;
  cin >> n >> k;
  priority_queue<int> pq;
  for(int i=0; i<n; i++){
  	int pp; cin >> pp;
    pq.push(pp);
  }
  int ans = 0;
  while(k){
    ans += pq.top();
    pq.pop;
    k--;
  }
  cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:8: error: invalid use of non-static member function 'void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::less<int>]'
   17 |     pq.pop;
      |     ~~~^~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:771:7: note: declared here
  771 |       pop()
      |       ^~~
Language: C

#include<stdio.h>
int main(){
  int n,k,p[1000];
  int box=0,snap;
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(int i=0;i<n;i++){
    for(int w=1;p[w]!=EOF;w++){
      if(p[i]>p[w]){
        snap=p[i];
        p[i]=p[w];
        p[w]=p[i];
      }
    }
  }
  for(i=0;i<k;i++){
    box+=p[k];
  }
  printf("%d",box);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:7: error: 'i' undeclared (first use in this function)
   18 |   for(i=0;i<k;i++){
      |       ^
main.c:18:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
int main(){
  int n,k,p[1000];
  int box=0,snap;
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(i=0;i<n;i++){
    for(int w=1;p[w]!=EOF;w++){
      if(p[i]>p[w]){
        snap=p[i];
        p[i]=p[w];
        p[w]=p[i];
      }
    }
  }
  for(i=0;i<k;i++){
    box+=p[k];
  }
  printf("%d",box);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:7: error: 'i' undeclared (first use in this function)
    9 |   for(i=0;i<n;i++){
      |       ^
main.c:9:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
int main(){
  int n,k,p[1000];
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%d",p[i]);
  }
  int box=0,snap;
  for(i=0;i<n;i++){
    for(int w=1;w<n-i;w++){
      if(p[i]>p[w]){
        snap=p[i];
        p[i]=p[w];
        p[w]=p[i];
      }
    }
  }
  for(i=0;i<k;i++){
    box+=p[k];
  }
  printf("%d",box);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:9:7: error: 'i' undeclared (first use in this function)
    9 |   for(i=0;i<n;i++){
      |       ^
main.c:9:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
int main(){
  int n,k,p[1000];
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%d",p[i]);
  }
  int box=0,snap;
  for(i=0;i<n;i++){
    for(int w=1;w<n-i;w++){
      if(p[i]>p[w]){
        snap=p[i];
        p[i]=p[w];
        p[w]=p[i];
      }
    }
  }
  for(i=0;i<k;i++){
    box+=k;
  }
  printf("%d",box);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:7: error: 'i' undeclared (first use in this function)
    9 |   for(i=0;i<n;i++){
      |       ^
main.c:9:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

// file creato da gio il 2020-06-24 19:30:16.614643

#include <bits/stdc++.h>
#define FAST 

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define MOD 1000000007
#define S second
#define F first
#define PB push_back
using namespace std;

int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif

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


}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: 'arr' was not declared in this scope; did you mean 'ar'?
   30 |         cin >> arr[i];
      |                ^~~
      |                ar
Language: Java

    public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] data = line.split(" ");


    }


Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
    public static void main(String[] args) {
                  ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:19: error: 'a' was not declared in this scope
   12 |   rep(i,n) cin >> a[i];
      |                   ^
a.cc:13:8: error: 'a' was not declared in this scope
   13 |   sort(a,a + n);
      |        ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: expected ';' before '}' token
   14 |   return 0
      |           ^
      |           ;
   15 | }
      | ~
Language: C++

#include <iostream>
#include <vector>
 
int main()
{
  int N;
  int K;
  int p;
  vector<int> p_list;
  int sum = 0;
  
  std::cin >> N;
  std::cin >> K;
  
  for (int i = 0; i < N; i++){
    std::cin >> p;
    p_list.push_back(p);
  }
  
  sort(p_list.begin(),p_list.end());
  
  for (int i = 0; i < K; i++)
    sum += p_list[i];
  
  std::cout << sum;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> p_list;
      |   ^~~~~~
a.cc:9:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> p_list;
      |          ^~~
a.cc:17:5: error: 'p_list' was not declared in this scope; did you mean 'va_list'?
   17 |     p_list.push_back(p);
      |     ^~~~~~
      |     va_list
a.cc:20:8: error: 'p_list' was not declared in this scope; did you mean 'va_list'?
   20 |   sort(p_list.begin(),p_list.end());
      |        ^~~~~~
      |        va_list
a.cc:20:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |   sort(p_list.begin(),p_list.end());
      |   ^~~~
      |   short
Language: C++

#include <iostream>

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> p_list;
      |   ^~~~~~
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> p_list;
      |          ^~~
a.cc:16:5: error: 'p_list' was not declared in this scope; did you mean 'va_list'?
   16 |     p_list.push_back(p);
      |     ^~~~~~
      |     va_list
a.cc:19:8: error: 'p_list' was not declared in this scope; did you mean 'va_list'?
   19 |   sort(p_list.begin(),p_list.end());
      |        ^~~~~~
      |        va_list
a.cc:19:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |   sort(p_list.begin(),p_list.end());
      |   ^~~~
      |   short
Language: C++

#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
	// your code goes here
	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 ans = 0;
	for(int i= 0;; i < k; i++) ans += p[i];
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:29: error: expected ')' before ';' token
   15 |         for(int i= 0;; i < k; i++) ans += p[i];
      |            ~                ^
      |                             )
a.cc:15:31: error: 'i' was not declared in this scope
   15 |         for(int i= 0;; i < k; i++) ans += p[i];
      |                               ^
Language: C++

#include<iostream>
#include<algorithm>
using namepspace 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);
  int res=0;
  for(int i=0; i<k; i++)
  {res+=arr[i];}
  cout << res << endl;
  return 0;}


Compiler output:
a.cc:3:7: error: expected nested-name-specifier before 'namepspace'
    3 | using namepspace std;
      |       ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin >> n >> k;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   11 |   sort(arr,arr+n);
      |   ^~~~
      |   std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:15:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   15 |   cout << res << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:15:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   15 |   cout << res << endl;
      |                  ^~~~
      |                  std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<iostream>
#include<alogrithm>
using namespace std;
int main()
{
  int n,k;cin>>n>>k;
  int a[20000];
  for(int i=1;i<=n;++i) cin>>a[i];
  sort(a+1,a+1+n);
  int ans=0;
  for(int i=1;i<=k;++i) ans+=a[i];
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc:2:9: fatal error: alogrithm: No such file or directory
    2 | #include<alogrithm>
      |         ^~~~~~~~~~~
compilation terminated.
Language: C

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

int main(void)
{
    int n,k, ans = 0;
    cin >> n>>k;

    vector<int> p(n);

    rep(i, n)
    {
        cin >> p.at(i);
    }

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

    rep(i, k)
    {
        ans+=p.at(i);
    }

    cout << ans << endl;
    return 0;
}


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

#include <vector>
using namespace std;
 
int main() {
  int end;
  int p = 0;
  int n;
  int k;
  cin>>n>>k;
  vector<int> vect;
  int temp;
  for (int i = 1; i <= n; i++)
  {
    cin>>temp;
    vect.push_back(temp);
  }
  for(int i = 1; i <= 3; i++)
  {
    int tmp = vect[0];
    for (int f = 0; f < vect.size(); f++)
    {
      if (tmp > vect[f])
      {
        tmp = vect[f];
        p = f;
      }
    }
    vect.erase(vect.begin()+p);
    end += tmp;
    p = 0;
  }
  cout<<end;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'cin' was not declared in this scope
    9 |   cin>>n>>k;
      |   ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <vector>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:32:3: error: 'cout' was not declared in this scope
   32 |   cout<<end;
      |   ^~~~
a.cc:32:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>
using namespace std;

int main(void) {
  	int n,k;
  	cin >> n >> k;
  	vector<in> p;
  	int sum = 0;
  	for (int i = 0; i < n; i++) {
      	int i;
      	cin >> i;
      	p.push_back(i);
    }
  	
  	sort(p.begin(), p.end());
  	for (int i=0; i < k; i++)
      sum += p[i];
  	return sum;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'vector' was not declared in this scope
    7 |         vector<in> p;
      |         ^~~~~~
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:16: error: 'in' was not declared in this scope; did you mean 'n'?
    7 |         vector<in> p;
      |                ^~
      |                n
a.cc:7:20: error: 'p' was not declared in this scope
    7 |         vector<in> p;
      |                    ^
a.cc:10:13: error: redeclaration of 'int i'
   10 |         int i;
      |             ^
a.cc:9:18: note: 'int i' previously declared here
    9 |         for (int i = 0; i < n; i++) {
      |                  ^
a.cc:15:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   15 |         sort(p.begin(), p.end());
      |         ^~~~
      |         short
Language: Java

import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int[] num = new int[1000];
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        for(int i = 0;i < 1000;i++)
            num[i] = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++)
            num[i] = scanner.nextInt();
        Arrays.sort(num);
        int sum = 0;
        for(int i = 0;i < k ;i++)
            sum += num[i];
        System.out.println(sum);


    }
}

Compiler output:
Main.java:16: error: cannot find symbol
        Arrays.sort(num);
        ^
  symbol:   variable Arrays
  location: class Main
1 error
Language: C++

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

int main() {
  int a,b,c,sum=0;
  cin >> a >> b;
  vector<int> nedan(a);
  for (int i=0;i<a;i++){
    cin >> nedan.at(i);
  }
  for (int i=0;i<a;i++){
    for (int j=i+1;j<a;j++){
      if(nedan(i)>nedan(j)){
        nedan(i)=c;
        nedan(i)=nedan(j);
        nedan(j)=c;
      }
    }
  }
  for (int i=0;i<b;i++){
    sum=sum+nedan(i);
  }
  cout << sum;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:15: error: no match for call to '(std::vector<int>) (int&)'
   13 |       if(nedan(i)>nedan(j)){
      |          ~~~~~^~~
a.cc:13:24: error: no match for call to '(std::vector<int>) (int&)'
   13 |       if(nedan(i)>nedan(j)){
      |                   ~~~~~^~~
a.cc:14:14: error: no match for call to '(std::vector<int>) (int&)'
   14 |         nedan(i)=c;
      |         ~~~~~^~~
a.cc:15:14: error: no match for call to '(std::vector<int>) (int&)'
   15 |         nedan(i)=nedan(j);
      |         ~~~~~^~~
a.cc:15:23: error: no match for call to '(std::vector<int>) (int&)'
   15 |         nedan(i)=nedan(j);
      |                  ~~~~~^~~
a.cc:16:14: error: no match for call to '(std::vector<int>) (int&)'
   16 |         nedan(j)=c;
      |         ~~~~~^~~
a.cc:21:18: error: no match for call to '(std::vector<int>) (int&)'
   21 |     sum=sum+nedan(i);
      |             ~~~~~^~~
Language: C++

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

int main() {
  int a,b,c,sum=0;
  cin >> a >> b;
  vector<int> nedan(a);
  for (int i=0;i<a;i++){
    cin >> nedan.at(i);
  }
  for (int i=0;i<a;i++){
    for (int j=i+1;j<a;j++){
      if(nedan(i)>nedan(j)){
        nedan(i)=c;
        nedan(i)=nedan(j);
        nedan(j)=c;
      }
    }
  }
  for (int i=0;i<b;i++){
    sum=sum+nedan(i);
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:15: error: no match for call to '(std::vector<int>) (int&)'
   13 |       if(nedan(i)>nedan(j)){
      |          ~~~~~^~~
a.cc:13:24: error: no match for call to '(std::vector<int>) (int&)'
   13 |       if(nedan(i)>nedan(j)){
      |                   ~~~~~^~~
a.cc:14:14: error: no match for call to '(std::vector<int>) (int&)'
   14 |         nedan(i)=c;
      |         ~~~~~^~~
a.cc:15:14: error: no match for call to '(std::vector<int>) (int&)'
   15 |         nedan(i)=nedan(j);
      |         ~~~~~^~~
a.cc:15:23: error: no match for call to '(std::vector<int>) (int&)'
   15 |         nedan(i)=nedan(j);
      |                  ~~~~~^~~
a.cc:16:14: error: no match for call to '(std::vector<int>) (int&)'
   16 |         nedan(j)=c;
      |         ~~~~~^~~
a.cc:21:18: error: no match for call to '(std::vector<int>) (int&)'
   21 |     sum=sum+nedan(i);
      |             ~~~~~^~~
Language: C++

#include <bits/stdc++.h> 
using namespace std; 
int a,b;
int main(){
  cin >>a >>b; 
  vector<int>data(a);
  for(int& i : data) 
    cin >> i;
  sort(data.begin(),data.end());
  int sum = 0;
  for(int i = 0;i<k;i++) sum += data[i];
  cout << sum;


Compiler output:
a.cc: In function 'int main()':
a.cc:11:19: error: 'k' was not declared in this scope
   11 |   for(int i = 0;i<k;i++) sum += data[i];
      |                   ^
a.cc:12:15: error: expected '}' at end of input
   12 |   cout << sum;
      |               ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h> using namespace std; int a,b; int main(){ cin >>a >>b; vector<int>data(a); for(int& i : data) cin >> i; sort(data.begin(),data.end()): int sum = 0; for(int i = 0;i<k;i++) sum += data[i]; cout << sum;


Compiler output:
a.cc:1:26: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h> using namespace std; int a,b; int main(){ cin >>a >>b; vector<int>data(a); for(int& i : data) cin >> i; sort(data.begin(),data.end()): int sum = 0; for(int i = 0;i<k;i++) sum += data[i]; cout << sum;
      |                          ^~~~~
/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++

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

int a,b;

int main(){
  cin >>a >>b;
  vector<int>data(a);
  for(int& i : data)
    cin >> i;
  sort(data.begin(),data.end()):
  int sum = 0;
  for(int i = 0;i<k;i++)
    sum += data[i];
  cout << sum;

Compiler output:
a.cc: In function 'int main()':
a.cc:11:32: error: expected ';' before ':' token
   11 |   sort(data.begin(),data.end()):
      |                                ^
      |                                ;
a.cc:13:19: error: 'k' was not declared in this scope
   13 |   for(int i = 0;i<k;i++)
      |                   ^
a.cc:14:5: error: 'sum' was not declared in this scope
   14 |     sum += data[i];
      |     ^~~
a.cc:15:11: error: 'sum' was not declared in this scope
   15 |   cout << sum;
      |           ^~~
a.cc:15:15: error: expected '}' at end of input
   15 |   cout << sum;
      |               ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

ll x[500005];

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   10 |   cin >> n >> k;
      |          ^
      |          yn
a.cc:10:15: error: 'k' was not declared in this scope
   10 |   cin >> n >> k;
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
const int inf = 1000000000; // 10^9 Ten to the power of nine.
/**** Type Define ****/
 
    int main(){
       int n,K;
       cin>>n>>K;
       int a[1000];  int ans=0;

       for (int i = 0; i < n; i++)
       {
          cin>>a[i];
       }
       
       sort(a,a+n);//1000までsortしない

     
       for (int i = 0; i < k; i++)
       {
          ans +=a[i];
       }
       
         cout<<ans<<endl;
         return 0;}

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

#include <bits/stdc++.h>

using namespace std;
#define ll longlong
int main()
{   ll n,k;cin>>n>>k;
     ll a[n];
 for(ll i=0;i<n;i++){
   cin>>a[i];
 }
 sort(a,a+n);
 ll ans=0;
 ll i=0;
 while(k>0){
   ans+=a[i];
   i++;
   k--;
 }
 cout<<ans<<endl;
 
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:12: error: 'longlong' was not declared in this scope
    4 | #define ll longlong
      |            ^~~~~~~~
a.cc:6:5: note: in expansion of macro 'll'
    6 | {   ll n,k;cin>>n>>k;
      |     ^~
a.cc:6:17: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 | {   ll n,k;cin>>n>>k;
      |                 ^
      |                 yn
a.cc:6:20: error: 'k' was not declared in this scope
    6 | {   ll n,k;cin>>n>>k;
      |                    ^
a.cc:7:9: error: expected ';' before 'a'
    7 |      ll a[n];
      |         ^
a.cc:8:9: error: expected ';' before 'i'
    8 |  for(ll i=0;i<n;i++){
      |         ^
a.cc:8:13: error: 'i' was not declared in this scope
    8 |  for(ll i=0;i<n;i++){
      |             ^
a.cc:9:9: error: 'a' was not declared in this scope
    9 |    cin>>a[i];
      |         ^
a.cc:11:7: error: 'a' was not declared in this scope
   11 |  sort(a,a+n);
      |       ^
a.cc:12:5: error: expected ';' before 'ans'
   12 |  ll ans=0;
      |     ^~~
a.cc:13:5: error: expected ';' before 'i'
   13 |  ll i=0;
      |     ^
a.cc:15:4: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |    ans+=a[i];
      |    ^~~
      |    abs
a.cc:15:11: error: 'i' was not declared in this scope
   15 |    ans+=a[i];
      |           ^
a.cc:19:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |  cout<<ans<<endl;
      |        ^~~
      |        abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  priority_queue<int,vector<int>,greater<int>> pq;
  for(i=0;i<n;i++)
  {
    cin>>arr[i];
    pq.push(arr[i]);
  }
  int sum=0;
  while(k--)
  {
      sum+=pq.top();
      pq.pop();
  }
  
  cout<<sum<<"\n";
  
  return 0;
  
  
}

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

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  priority_queue<int,vector<int>,greater<int>> pq;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    pq.push(arr[i]);
  }
  int sum=0;
  while(k--)
    sum+=pq.pop();
  
  cout<<sum<<"\n";
  
  return 0;
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: void value not ignored as it ought to be
   16 |     sum+=pq.pop();
      |          ~~~~~~^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  priority_queue<int,vector<int>,greater<int>> pq;
  for(i=0;i<n;i++)
  {
    cin>>arr[i];
    pq.push(arr[i]);
  }
  int sum=0;
  while(k--)
    sum+=pq.pop();
  
  cout<<sum<<"\n";
  
  return 0;
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   for(i=0;i<n;i++)
      |       ^
a.cc:16:16: error: void value not ignored as it ought to be
   16 |     sum+=pq.pop();
      |          ~~~~~~^~
Language: C++

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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 s = 0;
  for(int i=0; i<k; i++) s += p[i];
  
  cout << s << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: no matching function for call to 'sort(std::vector<int>::iterator, <unresolved overloaded function type>)'
   10 |   sort(p.begin(),p.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:63: note:   no known conversion for argument 2 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 <iostream>
#include <algorithm>
int main(){
  int n,k,sum=0;	cin >> n >> k;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  
  sort(a,a+n);
  for(int i=0;i<k;i++) sum+=a[i];
  
  cout << sum << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:25: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    4 |   int n,k,sum=0;        cin >> n >> k;
      |                         ^~~
      |                         std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
    8 |   sort(a,a+n);
      |   ^~~~
      |   std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:11:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   11 |   cout << sum << "\n";
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C

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

int compare(const void * n, const void * m)
{
	return *(long *)n - *(long *)m;
}

int main(void){
  int N,K,p[1000]={0},sum=0;
  scanf("%d %d",&N,&K);
  for(i=0; i<N; i++){
    scanf("%d",&p[i]);
  }
  qsort(p,N,sizeof(int),compare);
  
  for(i=0; i<K; i++){
    sum += p[i];
  }
  printf("%d\n",sum);
}

Compiler output:
main.c: In function 'main':
main.c:12:7: error: 'i' undeclared (first use in this function)
   12 |   for(i=0; i<N; i++){
      |       ^
main.c:12:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
#include <stdio.h>
#include <ctype.h>
#define FOR1toN(a) for(int i=1;i<=a;i++)
#define FOR0ton(a) for(int i=0;i<a;i--) 
using namespace std;

int main()
{
	//freopen("in.txt","r",stdin);
	int n,k,arr[1100];
	scanf("%d%d",&n,&k);
	FOR1toN(n) scanf("%d",&arr[i]);

	sort(arr+1,arr+1+n);

    int ans=0;
	FOR1toN(k) ans+=arr[i];
	cout<<ans<<endl;



   return 0;
}

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