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

#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)

int main() {
	int N = 0, K = 0;
	scanf("%d %d", &N, &K);
	int price[1000] = { 0 };
	for (int i = 0; i < N; i++) {
		scanf("%d", &price[i]);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (price[j] > price[j + 1]) {
				int temp = price[j];
				price[j] = price[j + 1];
				price[j + 1] = temp;
			}
		}
	}
	int m = 0
	for (int i = 0; i < K; i++) {
		m += price[i];
	}
	printf("%d", m);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: expected ',' or ';' before 'for'
   22 |         for (int i = 0; i < K; i++) {
      |         ^~~
a.cc:22:25: error: 'i' was not declared in this scope
   22 |         for (int i = 0; i < K; i++) {
      |                         ^
Language: C

#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)

int main() {
	int N = 0, K = 0;
	scanf("%d %d", &N, &K);
	int price[1000] = { 0 };
	for (int i = 0; i < N; i++) {
		scanf("%d", &price[i]);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (price[j] > price[j + 1]) {
				int temp = price[j];
				price[j] = price[j + 1];
				price[j + 1] = temp;
			}
		}
	}
	int m = 0
	for (int i = 0; i < K; i++) {
		m += price[i];
	}
	printf("%d", m);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:22:9: error: expected ',' or ';' before 'for'
   22 |         for (int i = 0; i < K; i++) {
      |         ^~~
main.c:22:25: error: 'i' undeclared (first use in this function)
   22 |         for (int i = 0; i < K; i++) {
      |                         ^
main.c:22:25: note: each undeclared identifier is reported only once for each function it appears in
main.c:22:35: error: expected ';' before ')' token
   22 |         for (int i = 0; i < K; i++) {
      |                                   ^
      |                                   ;
main.c:22:35: error: expected statement before ')' token
Language: C

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

using namespace std;
int main(void) {
	int K, N;
	scanf("%d%d", &N, &K);

	vector<int>vec(N);
	int num;
	for (int i = 0; i < N; i++) {
		scanf("%d", &num);
		vec[i] = num;
	}

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

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

	printf("%d", sum);

	return 0;
}

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

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}
int n,k;
cin>>n>>k;
vector<int>p(n);
rep(i,n){
  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:20:1: error: 'cin' does not name a type
   20 | cin>>n>>k;
      | ^~~
a.cc:4:18: error: expected unqualified-id before 'for'
    4 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                  ^~~
a.cc:22:1: note: in expansion of macro 'rep'
   22 | rep(i,n){
      | ^~~
a.cc:22:5: error: 'i' does not name a type
   22 | rep(i,n){
      |     ^
a.cc:4:29: note: in definition of macro 'rep'
    4 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                             ^
a.cc:22:5: error: 'i' does not name a type
   22 | rep(i,n){
      |     ^
a.cc:4:33: note: in definition of macro 'rep'
    4 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                                 ^
a.cc:25:5: error: expected constructor, destructor, or type conversion before '(' token
   25 | sort(p.begin(),p.end());
      |     ^
a.cc:27:1: error: expected unqualified-id before 'for'
   27 | for(int i=0;i<k;i++){
      | ^~~
a.cc:27:13: error: 'i' does not name a type
   27 | for(int i=0;i<k;i++){
      |             ^
a.cc:27:17: error: 'i' does not name a type
   27 | for(int i=0;i<k;i++){
      |                 ^
a.cc:30:1: error: 'cout' does not name a type
   30 | cout<<ans<<endl;
      | ^~~~
a.cc:32:3: error: expected unqualified-id before 'return'
   32 |   return 0;
      |   ^~~~~~
a.cc:35:1: error: expected declaration before '}' token
   35 | }
      | ^
Language: C++

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}
int n,k;
cin>>n>>k;
vector<int>p(n);
rep(i,n){
  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:20:1: error: 'cin' does not name a type
   20 | cin>>n>>k;
      | ^~~
a.cc:4:17: error: expected unqualified-id before 'for'
    4 | #define rep(i,n)for(ll i=0;i<n;i++)
      |                 ^~~
a.cc:22:1: note: in expansion of macro 'rep'
   22 | rep(i,n){
      | ^~~
a.cc:22:5: error: 'i' does not name a type
   22 | rep(i,n){
      |     ^
a.cc:4:28: note: in definition of macro 'rep'
    4 | #define rep(i,n)for(ll i=0;i<n;i++)
      |                            ^
a.cc:22:5: error: 'i' does not name a type
   22 | rep(i,n){
      |     ^
a.cc:4:32: note: in definition of macro 'rep'
    4 | #define rep(i,n)for(ll i=0;i<n;i++)
      |                                ^
a.cc:25:5: error: expected constructor, destructor, or type conversion before '(' token
   25 | sort(p.begin(),p.end());
      |     ^
a.cc:27:1: error: expected unqualified-id before 'for'
   27 | for(int i=0;i<k;i++){
      | ^~~
a.cc:27:13: error: 'i' does not name a type
   27 | for(int i=0;i<k;i++){
      |             ^
a.cc:27:17: error: 'i' does not name a type
   27 | for(int i=0;i<k;i++){
      |                 ^
a.cc:30:1: error: 'cout' does not name a type
   30 | cout<<ans<<endl;
      | ^~~~
a.cc:32:3: error: expected unqualified-id before 'return'
   32 |   return 0;
      |   ^~~~~~
a.cc:35:1: error: expected declaration before '}' token
   35 | }
      | ^
Language: C++

#include<algorithm>
#include<iostream>
#define STR 1000
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |     ans = 0;
      |     ^~~
      |     abs
Language: C++

#include<algorithm>
#include<iostream>
#define STR 1000
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: expected initializer before 'cin'
    8 |     cin >> n >> k;
      |     ^~~
a.cc:10:16: error: 'p' was not declared in this scope
   10 |         cin >> p[i];
      |                ^
a.cc:12:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |     ans = 0;
      |     ^~~
      |     abs
a.cc:13:10: error: 'p' was not declared in this scope
   13 |     sort(p,p+n)
      |          ^
a.cc:14:17: error: 'i' was not declared in this scope
   14 |     for(int i=0;i<k;i++){
      |                 ^
Language: C++

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

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



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

#include<iostream>
using namespace std;
 
int main()
{
    // get a integer
    int N, k;
    cin >> N >> k;
  	vector<int> arr(N);
  	int a;
    // get two integers separated with half-width break
  	for (int i=0; i<N; i++) {
      	cin >> a;
      	arr.push_back(a);
    }
  	priority_queue<int> pq;
  	for (int i=0; i<N; i++) {
      pq.push(arr[i]);
      if (i>=k)
        pq.pop();
    }
  	int res = 0;
  	while (!pq.empty()) {
      	res += pq.top();
      	pq.pop();
    }
  	cout << res;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'vector' was not declared in this scope
    9 |         vector<int> arr(N);
      |         ^~~~~~
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:9:16: error: expected primary-expression before 'int'
    9 |         vector<int> arr(N);
      |                ^~~
a.cc:14:9: error: 'arr' was not declared in this scope
   14 |         arr.push_back(a);
      |         ^~~
a.cc:16:9: error: 'priority_queue' was not declared in this scope
   16 |         priority_queue<int> pq;
      |         ^~~~~~~~~~~~~~
a.cc:2:1: note: 'std::priority_queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    1 | #include<iostream>
  +++ |+#include <queue>
    2 | using namespace std;
a.cc:16:24: error: expected primary-expression before 'int'
   16 |         priority_queue<int> pq;
      |                        ^~~
a.cc:18:7: error: 'pq' was not declared in this scope
   18 |       pq.push(arr[i]);
      |       ^~
a.cc:18:15: error: 'arr' was not declared in this scope
   18 |       pq.push(arr[i]);
      |               ^~~
a.cc:23:17: error: 'pq' was not declared in this scope
   23 |         while (!pq.empty()) {
      |                 ^~
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] nk = new int[2];
    for (int i = 0; i < nk.length; i++){
      nk[i] = sc.nextInt();
    }
    sc.nextLine();
    int[] pn = new int[nk[0]];
	for (int i = 0; i < nk[0]; i++){
      pn[i] = sc.nextInt();
    }
    Arrays.sort(pn);
    int answer = 0;
    for (int i = 0; i < nk[1]; i++){
      answer += pn[i];
    }
    println(answer);
  }
}

Compiler output:
Main.java:20: error: cannot find symbol
    println(answer);
    ^
  symbol:   method println(int)
  location: class Main
1 error
Language: C++

#include <iostream>
#include <algorithm>
 
int main(void) {
  	int N, K, i;
  	std::cin >> N;
  	std::cin >> K;
  	std::vector<int> input(N);
  	for (i = 0; i < N: i++) {
     	int tmp;
      	std::cin >> tmp;
      	input.emplace_back(tmp);
    }
  	std::sort(input.begin(), input.end());
  	int sum = 0;
  	for (i = 0; i < K; i++) {
     	sum += input[i]; 
    }
  	std::cout << sum << std::endl;
 	return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: error: 'vector' is not a member of 'std'
    8 |         std::vector<int> input(N);
      |              ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | 
a.cc:8:21: error: expected primary-expression before 'int'
    8 |         std::vector<int> input(N);
      |                     ^~~
a.cc:9:21: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
    9 |         for (i = 0; i < N: i++) {
      |                     ^
a.cc:9:26: error: found ':' in nested-name-specifier, expected '::'
    9 |         for (i = 0; i < N: i++) {
      |                          ^
      |                          ::
a.cc:9:25: error: 'N' is not a class, namespace, or enumeration
    9 |         for (i = 0; i < N: i++) {
      |                         ^
a.cc:14:19: error: 'input' was not declared in this scope; did you mean 'int'?
   14 |         std::sort(input.begin(), input.end());
      |                   ^~~~~
      |                   int
a.cc:15:9: error: expected primary-expression before 'int'
   15 |         int sum = 0;
      |         ^~~
a.cc:14:47: error: expected ')' before 'int'
   14 |         std::sort(input.begin(), input.end());
      |                                               ^
      |                                               )
   15 |         int sum = 0;
      |         ~~~                                    
a.cc:9:13: note: to match this '('
    9 |         for (i = 0; i < N: i++) {
      |             ^
a.cc:17:9: error: 'sum' was not declared in this scope
   17 |         sum += input[i];
      |         ^~~
a.cc:17:16: error: 'input' was not declared in this scope; did you mean 'int'?
   17 |         sum += input[i];
      |                ^~~~~
      |                int
a.cc:19:22: error: 'sum' was not declared in this scope
   19 |         std::cout << sum << std::endl;
      |                      ^~~
Language: C++

#include <iostream>
#include <algorithm>

int main(void) {
  	int N, K;
  	std::cin >> N;
  	std::cin >> K;
  	std::vector<int> input(N);
  	for (int i = 0; i < N: i++) {
     	int tmp;
      	std::cin >> tmp;
      	input.emplace_back(tmp);
    }
  	std::sort(input.begin(), input.end());
  	int sum = 0;
  	for (int i = 0; i < K; i++) {
     	sum += input[i]; 
    }
  	std::cout << sum << std::endl;
 	return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: error: 'vector' is not a member of 'std'
    8 |         std::vector<int> input(N);
      |              ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | 
a.cc:8:21: error: expected primary-expression before 'int'
    8 |         std::vector<int> input(N);
      |                     ^~~
a.cc:9:25: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
    9 |         for (int i = 0; i < N: i++) {
      |                         ^
a.cc:9:30: error: found ':' in nested-name-specifier, expected '::'
    9 |         for (int i = 0; i < N: i++) {
      |                              ^
      |                              ::
a.cc:9:29: error: 'N' is not a class, namespace, or enumeration
    9 |         for (int i = 0; i < N: i++) {
      |                             ^
a.cc:14:19: error: 'input' was not declared in this scope; did you mean 'int'?
   14 |         std::sort(input.begin(), input.end());
      |                   ^~~~~
      |                   int
a.cc:15:9: error: expected primary-expression before 'int'
   15 |         int sum = 0;
      |         ^~~
a.cc:14:47: error: expected ')' before 'int'
   14 |         std::sort(input.begin(), input.end());
      |                                               ^
      |                                               )
   15 |         int sum = 0;
      |         ~~~                                    
a.cc:9:13: note: to match this '('
    9 |         for (int i = 0; i < N: i++) {
      |             ^
a.cc:17:9: error: 'sum' was not declared in this scope
   17 |         sum += input[i];
      |         ^~~
a.cc:17:16: error: 'input' was not declared in this scope; did you mean 'int'?
   17 |         sum += input[i];
      |                ^~~~~
      |                int
a.cc:19:22: error: 'sum' was not declared in this scope
   19 |         std::cout << sum << std::endl;
      |                      ^~~
Language: Java

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();  	//入力数
		int k=scan.nextInt();
		int [] price=new int [n];
		for(int i=0;i<n;i++) {
			price[i]=scan.nextInt();
		}

		MixJuice a=new MixJuice(n,k,price);
		System.out.println(a.ans);
	}

}
class MixJuice {
	int n;
	int k;
	int ans;

	MixJuice(int n,int k,int [] p){
		this.n=n;
		this.k=k;
		int min[]=new int [k];

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

			for(int j=0;j<k;j++) {
				if(p[i]==-1) {

				}else if(min[j]==0) {
					min[j]=p[i];
					p[i]=-1;
				}else if(min[j]>p[i]) {

					for(int l=k-1;l>j;l--) {
						int g=min[l-1];
						min[l]=g;  //min[k-0]～min[j+1]=min[k-1]～min[j]
					}
					min[j]=p[i];
					p[i]=-1;
				}

			}

		}


		this.ans=0;
			for(int i=0;i<k;i++) {
				this.ans+=min[i];
			}
	}





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


public class MixJuice {
	int n;
	int k;
	int ans;

	MixJuice(int n,int k,int [] p){
		this.n=n;
		this.k=k;
		int min[]=new int [k];

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

			for(int j=0;j<k;j++) {
				if(p[i]==-1) {

				}else if(min[j]==0) {
					min[j]=p[i];
					p[i]=-1;
				}else if(min[j]>p[i]) {

					for(int l=k-1;l>j;l--) {
						int g=min[l-1];
						min[l]=g;  //min[k-0]～min[j+1]=min[k-1]～min[j]
					}
					min[j]=p[i];
					p[i]=-1;
				}

			}

		}


		this.ans=0;
			for(int i=0;i<k;i++) {
				this.ans+=min[i];
			}
	}



}


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

/// FROM A.R.A

#include <bits/stdc++.h>
 using namepace  std;
int main(){
  long long  n,k,sum=0;
  cin>>n>>k;
  long long  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;
  return 0;
}


Compiler output:
a.cc:4:8: error: expected nested-name-specifier before 'namepace'
    4 |  using namepace  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 /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:3:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   12 |   sort(a,a+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:16:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |   cout<<sum;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

/// FROM A.R.A

#include <bits/stdc++.h>
 using names  std;
int main(){
  long long  n,k,sum=0;
  cin>>n>>k;
  long long  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;
  return 0;
}

Compiler output:
a.cc:4:8: error: expected nested-name-specifier before 'names'
    4 |  using names  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 /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:3:
/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: expected initializer before 'for'
    9 |   for (int i=0;i <n;i++){
      |   ^~~
a.cc:9:16: error: 'i' was not declared in this scope
    9 |   for (int i=0;i <n;i++){
      |                ^
a.cc:12:8: error: 'a' was not declared in this scope
   12 |   sort(a,a+n);
      |        ^
a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   12 |   sort(a,a+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:16:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |   cout<<sum;
      |   ^~~~
      |   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<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0; i<n; i++)	cin>>arr[i];
  sort(arr, arr+n);
 ll sum=0;
 for(int i=0; i<k; i++){
 	sum+=arr[i];
 }
 cout<<sum;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:2: error: 'll' was not declared in this scope
    9 |  ll sum=0;
      |  ^~
a.cc:11:9: error: 'sum' was not declared in this scope
   11 |         sum+=arr[i];
      |         ^~~
a.cc:13:8: error: 'sum' was not declared in this scope
   13 |  cout<<sum;
      |        ^~~
Language: C++

 #include <iostream>
using namespace std;

int N, K, p[1010];

int main(){
 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:9:2: error: 'sort' was not declared in this scope; did you mean 'short'?
    9 |  sort(p, p + N);
      |  ^~~~
      |  short
Language: C++

#include<bits/stdc++.h>
using namespace std;
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 sum=0;
  for(int i=0;i<k;i++)
    sum+=ar[i];
  cout<<sum<<"\n";
  return 0
}

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

//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
ld pie=3.141592653589793238462643383279;
int mod=1e9+7;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};


int dig(int a){
  int r=0;
  while(a!=0){
    int xp=a%10;
    a/=10; if(xp==1) ++r;
  }
  return r;
}

int fact[2000005];
int infact[2000005];

int inv(int a){
  int y=mod-2;
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r;
}

int po(int a,int y){
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r; 
}

void facto(){
  fact[0]=1;
  f(i,1,2000005) {fact[i]=i*fact[i-1]; fact[i]%=mod;}
  f(i,0,2000005) infact[i]=inv(fact[i]); 
}

int nck (int n,int k){
  if(k<0 || k>n) return 0;
  int ret=fact[n]; ret*=infact[k]; ret%=mod;
  ret*=infact[n-k]; ret%=mod;
  return ret;
}
void q1(){
  string s; cin>>s;
  if(s>="a" && s<="z") cout<<"a";
  else cout<<"A";
}
void q2(){
  int n,k; cin>>n>>k;
  int a[n]; f(i,0,n) cin>>a[i];
  sort(a,a+n);
  int s=0;
  f(i,0,k)s+=a[i];
  cout<<s;
}
void q3(){
  string ret="";
  int a; cin>>a;
  while(a!=0){
    a--;
    ret+=(a%26 +'a');
    a/=26;
  }
  reverse(ret.begin(),ret.end());
  cout<<ret;
}
void q4(){
  int n; cin>>n;
   int a[100005]={0};
   int s=0;
  f(i,0,n){
    int x; cin>>x;
    s+=x;
    a[x]++;
  }
  int q; cin>>q;
  while(q--){
    int b,c; cin>>b>>c;
    s-=a[b]*b;
    s+=a[b]*c;
    a[c]+=a[b];
    a[b]=0;
    cout<<s<<"\n";
  }
 
}
void q5(){
  int n; cin>>n;
  int x=0;
  int a[n]; f(i,0,n){
    cin>>a[i];
    x^=a[i];
  } 
   f(i,0,n) cout<<x^a[i]<<" ";
}
int32_t main(){
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  q2();
  return 0;
  facto();
  int k; cin>>k;
  string s; cin>>s;
  int l=k+s.size();
  int xp=s.size();
  // total = 26^l - those which do not contain subsequence
  // --- i= 0 to  xp-1 prefix present as subseqeunce and remaining have 25^(l-i)
  int ret=1;
  f(i,0,l){
    ret*=26; ret%=mod;
  }
  int sub=0;

  f(i,0,xp){
    // l choose i
    sub+= (nck(l,i)*po(25,l-i));
    sub%=mod; 
  }

  cout<<((ret-sub)%mod + mod) %mod <<"\n";
  return 0;
}


Compiler output:
a.cc: In function 'void q5()':
a.cc:115:25: error: invalid operands of types 'long long int' and 'const char [2]' to binary 'operator<<'
  115 |    f(i,0,n) cout<<x^a[i]<<" ";
      |                     ~~~~^~~~~
      |                        |  |
      |                        |  const char [2]
      |                        long long int
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define FastIO ios_base :: sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read(in) freopen("Input.txt","r",stdin)
#define write(out) freopen("Ouput.txt","w",stdout)
#define pf printf
#define sf scanf
#define fr(i,n) for(i=1 ; i<=n ; i++)
#define fr1(i,x,n) for(i=x ; i<=n ; i++)
#define sf1(val) scanf("%lld",&val)
#define sf2(val1,val2) scanf("%lld %lld",&val1,&val2)
#define INF 999999999999999999
#define Pi 2*acos(0.0)
#define len 200000

typedef long long int lli;

lli a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,sum=0,total=0,res=0,ans=0;

int main()
{
    //FastIO;

    //read(in);
  
  	sf2(n,k);
  
  	vector<lli>ar;
  	
  	fr(i,n)	sf(x) , ar.push_back(x);
  
  	sort(ar.begin(),ar.end());
  
  	fr(i,k)	sum+=(ar[i-1]);
  
  	pf("%lld\n",sum);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:20: error: invalid conversion from 'lli' {aka 'long long int'} to 'const char*' [-fpermissive]
   32 |         fr(i,n) sf(x) , ar.push_back(x);
      |                    ^
      |                    |
      |                    lli {aka long long int}
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/stdio.h:428:42: note:   initializing argument 1 of 'int scanf(const char*, ...)'
  428 | extern int scanf (const char *__restrict __format, ...) __wur;
      |                   ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:17: error: expected ')' before ';' token
    7 |   sort(v.begin();v.end());  sum=0;
      |       ~         ^
      |                 )
a.cc:7:25: error: expected ';' before ')' token
    7 |   sort(v.begin();v.end());  sum=0;
      |                         ^
      |                         ;
a.cc:7:23: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::end() [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator]', declared with attribute 'nodiscard' [-Wunused-result]
    7 |   sort(v.begin();v.end());  sum=0;
      |                  ~~~~~^~
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:893:7: note: declared here
  893 |       end() _GLIBCXX_NOEXCEPT
      |       ^~~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:19: error: expected '}' at end of input
   19 |   cout<<sum<<endl;
      |                   ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{ int n,k;ll sum=0;
  cin>>n>>k;
  int arr[n];
  f(i,n)cin>>arr[i];
  sort(arr,arr+n);
  f(i,k)sum+=arr[i];cout<<sum;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'i' was not declared in this scope
   10 |   f(i,n)cin>>arr[i];
      |     ^
a.cc:10:3: error: 'f' was not declared in this scope
   10 |   f(i,n)cin>>arr[i];
      |   ^
Language: C++

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> p[i];
	}

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

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

	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'll' was not declared in this scope
   14 |         ll ans = 0;
      |         ^~
a.cc:16:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |                 ans += p[i];
      |                 ^~~
      |                 abs
a.cc:19:17: 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;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int sum=0;
	rep(i,k)sum+=a[i];
	puts(sum);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:15: error: 'k' was not declared in this scope
   22 |         rep(i,k)sum+=a[i];
      |               ^
a.cc:3:32: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                ^
Language: C++

#include<stdio.h>
signed main{
    int n,x[10000];
    int i,j,temp;
    for(i=0;i<n;i++){
        for(j=0;j<n-i-1;j++){
            if(x[i]>x[j+1]){
                temp=x[i];
                x[j]=x[j+1];
                x[j+1]=temp;
            }
        }
    }
    return(0);
}

Compiler output:
a.cc:2:8: error: cannot declare '::main' to be a global variable
    2 | signed main{
      |        ^~~~
a.cc:3:5: error: expected primary-expression before 'int'
    3 |     int n,x[10000];
      |     ^~~
a.cc:3:5: error: expected '}' before 'int'
a.cc:2:12: note: to match this '{'
    2 | signed main{
      |            ^
a.cc:5:5: error: expected unqualified-id before 'for'
    5 |     for(i=0;i<n;i++){
      |     ^~~
a.cc:5:13: error: 'i' does not name a type
    5 |     for(i=0;i<n;i++){
      |             ^
a.cc:5:17: error: 'i' does not name a type
    5 |     for(i=0;i<n;i++){
      |                 ^
a.cc:14:5: error: expected unqualified-id before 'return'
   14 |     return(0);
      |     ^~~~~~
a.cc:15:1: error: expected declaration before '}' token
   15 | }
      | ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){
  int n, k, res=0;
  vector<int> v(n);
  cin>>n>>k;
  for(i=0; i<n; i++)
    cin>>v[i];
  sort(v.begin(), v.end());
  
  for(int i=0; i<k; i++)
    res += v[i];
  
  cout<<res;
}

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<stdio.h>
 
int main (void){
  int N,K;
  scanf("%d%d",&N,&K);
  int p[N];
  for(int i=0;i<K;i++){
    scanf("%d",&p[i]);
  }
  int s;
  int sum=0;
  for(int k=0;k<N;k++){
    for(int j=k;j<N;j++){
      if(p[j]<p[i]){
        s=p[i];
        p[i]=p[j];
        p[j]=s;
      }
    }
  }
  for(int l=0;l<K;l++){
    sum=sum+p[i];
  }
  printf("%d\n",sum);
  return 0;  
}

Compiler output:
main.c: In function 'main':
main.c:14:17: error: 'i' undeclared (first use in this function)
   14 |       if(p[j]<p[i]){
      |                 ^
main.c:14:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>

int main (void){
  int N,K;
  scanf("%d%d",&N,&K);
  int p[N];
  for(int i=0;i<K;i++){
    scanf("%d",&p[i]);
  }
  int s;
  int sum=0;
  for(int k=0;k<N;k++){
    for(int j=i;j<N;j++){
      if(p[j]<p[i]){
        s=p[i];
        p[i]=p[j];
        p[j]=s;
      }
    }
  }
  for(int l=0;l<K;l++){
    sum=sum+p[i];
  }
  printf("%d\n",sum);
  return 0;  
}

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

#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#define bye return 0
#define speedOne ios::sync_with_stdio(false)
#define speedtwo cin.tie(0)
typedef long long int lli;
typedef long long ll;
using namespace std;
int main()
{
    vector<int> v;
    int a, b, c;
    cin >> a >> b;
    for(int i=0; i<a; ++i){
        cin >> c;
        v.push_back(c);
    }
    
    sort(v.begin(), v.end());
    
    int sum = 0;
    for(int i=0; i<b; ++i){
        sum = sum+v[i];
    }
    
    cout << sum << endl;
	bye;
}

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

#include<stdio.h>

int main (void){
  int N,K;
  scanf("%d%d",&N,&K);
  int p[N];
  for(int i=0;i<K,i++){
    scanf("%d",&p[i]);
  }
  int s;
  int sum=0;
  for(i=0;i<N;i++){
    for(int j=i;j<N;j++){
      if(p[j]<p[i]){
        s=p[i];
        p[i]=p[j];
        p[j]=s;
      }
    }
  }
  for(i=0;i<K;i++){
    sum=sum+p[i];
  }
  printf("%d/n",sum);
  return 0;  
}

Compiler output:
main.c: In function 'main':
main.c:7:22: error: expected ';' before ')' token
    7 |   for(int i=0;i<K,i++){
      |                      ^
      |                      ;
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<stdio.h>

int main (void){
  int N,K;
  scanf("%D%D",&N,&K);
  int p[N];
  for(int i=0;i<K,i++){
    scanf("%d"&p[i]);
  }
  int s;
  int sum=0;
  for(i=0;i<N;i++){
    for(int j=i;j<N;j++){
      if(p[j]<p[i]){
        s=p[i];
        p[i]=p[j];
        p[j]=s;
      }
    }
  }
  for(i=0;i<K;i++){
    sum=sum+p[i];
  }
  prinf("%d/n",sum);
  return 0;  
}

Compiler output:
main.c: In function 'main':
main.c:7:22: error: expected ';' before ')' token
    7 |   for(int i=0;i<K,i++){
      |                      ^
      |                      ;
main.c:8:15: error: invalid operands to binary & (have 'char *' and 'int')
    8 |     scanf("%d"&p[i]);
      |           ~~~~^~~~~
      |           |     |
      |           |     int
      |           char *
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
main.c:24:3: error: implicit declaration of function 'prinf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   24 |   prinf("%d/n",sum);
      |   ^~~~~
      |   printf
Language: C++

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

using namespace std;

int main() {

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

}

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

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

using namespace std;

int main() {

  int N, K;
  cin >> N >> K;
  vector<int> price(N);
  for(int i=0;i<N;i++) {
    cin >> price[i];
  }
  sort(price);
  sum = 0;
  for(auto i: price) {sum+=i;}
  cout << sum << endl;
    

}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   15 |   sort(price);
      |   ^~~~
      |   short
a.cc:16:3: error: 'sum' was not declared in this scope
   16 |   sum = 0;
      |   ^~~
Language: C++

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"

void solve()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(auto &x:v)cin>>x;
    sort(v.begin(),v.end());
    ll sum=0;
    for(int i=0;i<k;i++){
        sum+=c[i];
    }
    cout<<sum;
}

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:16:14: error: 'c' was not declared in this scope
   16 |         sum+=c[i];
      |              ^
Language: C++

#include<bits/stdc++.h>


using namespace std;

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


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

#include<stdio.h>
#include<stdlib.h>
int main()
{   int n,i,j,k,min,temp,*p,s=0;
    scanf("%d %d",&n,&k);
	p=(int*)malloc(n*sizeof(int));
    for(i=0;i<n;i++) 
	{
		scanf("%d ",(p+i));
	}
	for(i=0;i<n-1;i++)
	{
		min=i;
		for(j=i+1;j<n;j++)
		{
			if(*(p+min)>*(p+j))
			min=j;
		}
		temp=*(p+i);
		*(p+i)=*(p+min);
		*(p+min)=temp;
	}
	for(i=0;i<k;i++)
      s=s+*(p+i)
    printf("%d",s);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:24:17: error: expected ';' before 'printf'
   24 |       s=s+*(p+i)
      |                 ^
      |                 ;
   25 |     printf("%d",s);
      |     ~~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:8: error: 'i' was not declared in this scope
   10 |   for (i = 0 ; i < n ; i++){
      |        ^
a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   13 |   sort((a).begin(),(a).end());
      |   ^~~~
      |   short
a.cc:15:8: error: 'i' was not declared in this scope
   15 |   for (i = 0 ; i < m ; i++ {
      |        ^
a.cc:15:27: error: expected ')' before '{' token
   15 |   for (i = 0 ; i < m ; i++ {
      |       ~                   ^~
      |                           )
Language: C++

#include <bits/stdc++.h>

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

using namespace std;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> p(n);
	rep(i,n) scanf("%d",&p[i]);

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

	printf("%d\n",accumulate(p.begin(),p.begin()+k));

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:33: error: no matching function for call to 'accumulate(std::vector<int>::iterator, __gnu_cxx::__normal_iterator<int*, std::vector<int> >)'
   14 |         printf("%d\n",accumulate(p.begin(),p.begin()+k));
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:23:7: error: expected primary-expression before ')' token
   23 |   for()
      |       ^
a.cc:24:1: error: expected primary-expression before '}' token
   24 | }
      | ^
a.cc:23:8: error: expected ';' before '}' token
   23 |   for()
      |        ^
      |        ;
   24 | }
      | ~       
a.cc:24:1: error: expected primary-expression before '}' token
   24 | }
      | ^
a.cc:23:8: error: expected ')' before '}' token
   23 |   for()
      |      ~ ^
      |        )
   24 | }
      | ~       
a.cc:24:1: error: expected primary-expression before '}' token
   24 | }
      | ^
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 N = scan.nextInt();
		int K = scan.nextInt();
		int[] p = new int[N];
		int ans = 0;

		for(int i = 0;i < N;i++) {
			p[i] = scan.nextInt();
		}

		Arrays.sort(p);

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

		System.out.println(ans);

	}
}

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: Java

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

public class ques {
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		
		int a[] = new int[n];
		for(int i=0;i<n;i++)
			a[i] = s.nextInt();
		
		Arrays.parallelSort(a);
		int sum = 0;
		for(int i=0;i<k;i++)
			sum+=a[i];
		System.out.println(sum);
	}

}


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

#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>
 
using namespace std;

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

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:10: error: 'n' was not declared in this scope
    7 |     cin>>n>>k;
      |          ^
a.cc:7:13: error: 'k' was not declared in this scope
    7 |     cin>>n>>k;
      |             ^
a.cc:12:9: error: no matching function for call to 'sort(<unresolved overloaded function type>, std::vector<int>::iterator)'
   12 |     sort(p.begin,p.end());
      |     ~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/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<iostream>
using namespace std;
int main()
{
int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
   cin>>a[i];
  }
  sort(a,a+n);
  int ans=0;
  for(int i=0;i<k;i++)
  {
   ans+=a[i];
  }
  cout<<ans<<endl;
}

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(a,a+n);
      |   ^~~~
      |   short
Language: C++

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

     int sum=0;

     for(i=0; i<k; i++)
    {
        sum+=ar[i];
    }
    cout<<sum<<endl;

    return 0;
}


Compiler output:
a.cc:1:9: 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 a,i,k;
    cin>>a;
    int ar[a];
    cin>>k;
    for(i=0; i<a; i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+a);

     int sum=0;

     for(i=0; i<k; i++)
    {
        sum+=ar[i];
    }
    cout<<sum<<endl;

    return 0;
}


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(ar,ar+a);
      |     ^~~~
      |     short