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

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

typedef long long ll;
#define nn cout << '\n'
#define rep(n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i <n; i++)
#define rd(n) ll n; cin >> n;
#define rd(n,k) ll n,k; cin >> n >> k;
#define rd(a,b,c,d) ll a,b,c,d; cin >> a>> b >> c >> d;

using namespace std;


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

	cout << sum;


}


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

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

	}
	return 0;
}

/*

*/

Compiler output:
a.cc:18:9: warning: "rd" redefined
   18 | #define rd(n,k) ll n,k; cin >> n >> k;
      |         ^~
a.cc:17:9: note: this is the location of the previous definition
   17 | #define rd(n) ll n; cin >> n;
      |         ^~
a.cc:19:9: warning: "rd" redefined
   19 | #define rd(a,b,c,d) ll a,b,c,d; cin >> a>> b >> c >> d;
      |         ^~
a.cc:18:9: note: this is the location of the previous definition
   18 | #define rd(n,k) ll n,k; cin >> n >> k;
      |         ^~
a.cc: In function 'void testcase()':
a.cc:31:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   31 |         sort(v.begin(), v.end());
      |         ^~~~
      |         short
Language: C++

#include<cstdio>
#include<set>
#include<iostream>
using namespace std;

int main(){
    int N,K;
    scanf("%d %d", &N, &K);
    set<int> s;
    for(int i=0;i<N;i++){
        int x;
        scanf("%d", &x);
        s.insert(x);
    }
    int ans = 0;
    auto itr = s.begin();
    for(int i=0;i<K;i++){
        ans += itr*;
        itr++;
    }
    printf("%d", ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:20: error: expected primary-expression before ';' token
   18 |         ans += itr*;
      |                    ^
Language: Java

import java.util.*;
import java.io.*;
import java.lang.*;

public class ABC171B {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt(); int n = sc.nextInt();
		int[] price = new int[t];
		while (t-- > 0) {
			price[t] = sc.nextInt(); //receives input in reverse
		}

		Arrays.sort(price);
		int sum = 0;
		for (int i = 0; i<n; i++) {
			sum+=price[i];
		}

		System.out.println(sum);
	}
}


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

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

int main()

{
	int n, k;
	cin >> n >> k>>;
	
	int arr[n+1];
	
	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 = sum + arr[i];
	}
	
	cout<< sum <<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:24: error: expected primary-expression before ';' token
    8 |         cin >> n >> k>>;
      |                        ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: 'arr' was not declared in this scope
    9 |     cin>>arr[i];
      |          ^~~
a.cc:12:10: error: 'arr' was not declared in this scope
   12 |     sum+=arr[i];
      |          ^~~
Language: Java

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

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


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

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


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

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

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

const int N=2e5+5;


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int p[n];
        for(int i=0;i<n;i++)
        {
            cin>>p[i];
        }
        sort(c,c+n);
        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:23:14: error: 'c' was not declared in this scope
   23 |         sort(c,c+n);
      |              ^
Language: C++

#include<iostream>
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: expected primary-expression before 'int'
    9 |         cin>>int[i];
      |              ^~~
a.cc:11:10: error: request for member 'begin' in 'p', which is of non-class type 'int [n]'
   11 |   sort(p.begin(),p.end());
      |          ^~~~~
a.cc:11:20: error: request for member 'end' in 'p', which is of non-class type 'int [n]'
   11 |   sort(p.begin(),p.end());
      |                    ^~~
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |   sort(p.begin(),p.end());
      |   ^~~~
      |   short
Language: C++

#include<bits/stdc++.h>
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 sum = 0;
  for(int i=0;i<k;i++)
  {
    sum+=a[i]
  }
  cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:14: error: expected ';' before '}' token
   17 |     sum+=a[i]
      |              ^
      |              ;
   18 |   }
      |   ~
Language: C++

#include <iostream>
using namespace std;

int n, k, c[1005], ans;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> c[i];
    }
    sort(c, c+n);
    for (int i = 0; i < k; i++){
        ans += c[i];
    }
    cout << ans << "\n";
}


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

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> p;
  int tmp;
  for(int i = 0;i<n;i++){
    cin >> tmp;
    p.push_back(tmp);
  }
  sort(p.begin(), p.end());//昇順
  int c= 0;
  
  for(int i = 0;i<k;i++){
    c+= p[i];
  }
  
  cout a<< c;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:7: error: expected ';' before 'a'
   22 |   cout a<< c;
      |       ^~
      |       ;
Language: C++

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

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

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

	int tal = 0;

	for (int i = 0; i < k; i++) {
		tal = tal + p[i];
	}

	cout << tal << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:44: error: expected primary-expression before ')' token
   13 |                 for (int j = 1; j < i; j + ) {
      |                                            ^
Language: C++

#include <iostream>
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> name(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:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> name(N);
      |          ^~~
a.cc:9:12: error: 'name' was not declared in this scope; did you mean 'tzname'?
    9 |     cin >> name[i];
      |            ^~~~
      |            tzname
a.cc:11:8: error: 'name' was not declared in this scope; did you mean 'tzname'?
   11 |   sort(name.begin(),name.end());
      |        ^~~~
      |        tzname
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |   sort(name.begin(),name.end());
      |   ^~~~
      |   short
Language: C++

#include<bits/stdc+++.h>
using namespace std;
int main(void){
  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());
  cout<<p[0]+p[1]+p[2]<<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>
#include <vector>
#include <queue>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;

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

    long long 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:17:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |     sort(p.begin(), p.end());
      |     ^~~~
      |     short
Language: C++

#include <stdio.h>
#include<queue>
using namespace std;

int main() {
  int n,k,p;
  priority_queue<int> pq;
  scanf("%d%d",&n,&d);
  for(int i=0; i<k; i++) {
    scanf("%d",&p);
    pq.push(-p);
  }
  for(int i=k;i<n;i++){
    scanf("%d",&p);
    int v=pq.top();
    if(-v>p){
      pq.pop();
      pq.push(-p);
    }
  }
  int s=0;
  while(!pq.empty()){
    s+=pq.top();
    pq.pop();
  }
  printf("%d",s);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:20: error: 'd' was not declared in this scope
    8 |   scanf("%d%d",&n,&d);
      |                    ^
Language: C

#include<stdio.h>

 int main(){
   int n,k;
   scanf("%d %d",&n,&k);
   int p[n+1];
   for(int i=1;i<=n;i++)scanf("%d",&p[i]);
   
   for(int i=1;i<=n-1;i++){
     for(int j=i+1;j++){
       if(p[i]>=p[j]){
         int s=p[i];
         p[i]=p[j];
         p[j]=s;
       }
     }
   }
   int ans=0;
   for(int i=1;i<=k;i++){
     ans+=p[i];
   }
   printf("%d",ans);
   return 0;
 }

Compiler output:
main.c: In function 'main':
main.c:10:23: error: expected ';' before ')' token
   10 |      for(int j=i+1;j++){
      |                       ^
      |                       ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int N,K;  cin>>N>>K;
  vector<int> p(N);
  rep(i,0,N) cin>>p[i];
  sort(all(p));
  ll sum=0;
  rep(i,0,K){
    sum += v[i];
  }
  cout<<sum<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:90:12: error: 'v' was not declared in this scope
   90 |     sum += v[i];
      |            ^
Language: C++

#include <iostream>
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> name(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:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> name(N);
      |          ^~~
a.cc:9:12: error: 'name' was not declared in this scope; did you mean 'tzname'?
    9 |     cin >> name[i];
      |            ^~~~
      |            tzname
a.cc:11:8: error: 'name' was not declared in this scope; did you mean 'tzname'?
   11 |   sort(name.begin(),name.end());
      |        ^~~~
      |        tzname
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |   sort(name.begin(),name.end());
      |   ^~~~
      |   short
a.cc:13:17: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   13 |   for (int i=0; i<K: i++){
      |                 ^
a.cc:13:20: error: found ':' in nested-name-specifier, expected '::'
   13 |   for (int i=0; i<K: i++){
      |                    ^
      |                    ::
a.cc:13:19: error: 'K' is not a class, namespace, or enumeration
   13 |   for (int i=0; i<K: i++){
      |                   ^
a.cc:17:1: error: expected primary-expression before '}' token
   17 | }
      | ^
a.cc:16:23: error: expected ')' before '}' token
   16 |   cout << cnt << endl;
      |                       ^
      |                       )
   17 | }
      | ~                      
a.cc:13:7: note: to match this '('
   13 |   for (int i=0; i<K: i++){
      |       ^
a.cc:17:1: error: expected primary-expression before '}' token
   17 | }
      | ^
Language: C

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

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


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

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,p[1000];
    scanf("%d %d",&n,&k);
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%d",&p[i]);
    }
    sort(p,p+n);
    int sum=0;
    for(i=0;i<k;i++)
    {
        sum+=p[i];
    }
    printf("%d",sum);
}


Compiler output:
main.c: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 N,K;
  cin >> N >> K;
  vector<int> name(N);
  for (int i=0; i<N; i++){
    cin >> name[i];
  }
  sort(name.begin(),name.end());
  int cnt = 0;
  for (int i=0; i<K: i++){
    cnt += name[i]
  }
  cout << cnt << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> name(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:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> name(N);
      |          ^~~
a.cc:9:12: error: 'name' was not declared in this scope; did you mean 'tzname'?
    9 |     cin >> name[i];
      |            ^~~~
      |            tzname
a.cc:11:8: error: 'name' was not declared in this scope; did you mean 'tzname'?
   11 |   sort(name.begin(),name.end());
      |        ^~~~
      |        tzname
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |   sort(name.begin(),name.end());
      |   ^~~~
      |   short
a.cc:13:17: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   13 |   for (int i=0; i<K: i++){
      |                 ^
a.cc:13:20: error: found ':' in nested-name-specifier, expected '::'
   13 |   for (int i=0; i<K: i++){
      |                    ^
      |                    ::
a.cc:13:19: error: 'K' is not a class, namespace, or enumeration
   13 |   for (int i=0; i<K: i++){
      |                   ^
a.cc:17:1: error: expected primary-expression before '}' token
   17 | }
      | ^
a.cc:16:23: error: expected ')' before '}' token
   16 |   cout << cnt << endl;
      |                       ^
      |                       )
   17 | }
      | ~                      
a.cc:13:7: note: to match this '('
   13 |   for (int i=0; i<K: i++){
      |       ^
a.cc:17:1: error: expected primary-expression before '}' token
   17 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define vvll vector<vll>
#define wh(t) while(t--)
#define fi(n) for(ll i = 0; i < n; i++)
#define fj(n) for(ll j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fr first
#define se second
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
const ll M = 1e9+7;
//const ll M = 998244353;

ll pmp(ll x,ll n){ll a = 1;while(n > 0){if(n & 1) a = (a * x)%M;x = (x * x)%M;n = n>>1;}return a;}

void solve(){
	ll n,k;
	cin >> n >> k;
	vll a(n);
	fi(n) cin >> a[i];
	ll ans=0;
	sort(a.begin(), a.end());
	fi(k) sum+=a[i];
	cout << sum << endl;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// #endif
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		solve();
	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:34:15: error: 'sum' was not declared in this scope
   34 |         fi(k) sum+=a[i];
      |               ^~~
a.cc:35:17: error: 'sum' was not declared in this scope
   35 |         cout << sum << endl;
      |                 ^~~
Language: C++

#include<iostream>
using namespace std;
int main(){
  long long int n,k;
  cin>>n>>k;
  long long int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long long int ans=0,k,ans=0;
    for(int j=0;j<k;j++){
      for(int i=0;i<n;i++){
        int min=10000;
        if(min>a[i]){
        min=a[i];
        k=i;
        }
      }
      ans+=min;
      a[k]=10000;
    }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:23: error: redeclaration of 'long long int k'
   10 |   long long int ans=0,k,ans=0;
      |                       ^
a.cc:4:19: note: 'long long int k' previously declared here
    4 |   long long int n,k;
      |                   ^
a.cc:10:25: error: redeclaration of 'long long int ans'
   10 |   long long int ans=0,k,ans=0;
      |                         ^~~
a.cc:10:17: note: 'long long int ans' previously declared here
   10 |   long long int ans=0,k,ans=0;
      |                 ^~~
a.cc:19:12: error: overloaded function with no contextual type information
   19 |       ans+=min;
      |            ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
vector<int> v;
int n,m,x,ans;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    cin>>n>>m;
    for(int i=1; i<=n; i++){
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(int i=0; i<v.size(); i++){
        ans+=v[i];
        if(!--m) break;
    
    cout<<ans<<'\n';
}

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: 's' was not declared in this scope
    9 |   sort(f.begin(),s.end());
      |                  ^
Language: C++

 #include <bits/stdc++.h>
      //#define ll long long
      using namespace std;
      #define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
      #define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
      #define ll long long
      #define pb push_back
      #define pll pair<ll,ll>
      #define ff first
      #define ss second
     
      #define N 2000001
      #define M 998244353
      #define INF 1000000000000000
      std::vector<ll> v;

int main()
{
  SPEED;
 ll t;
 cin>>t;

 while(t-->0)
 {
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll i;
    for(i=0;i<n;i++)
    {
      cin>>a[i];
    }
    sort(a,a+n);ll sum=0;
    for(i=0;i<k;i++)
    {
      sum+=a[i]
    }
    cout<<sum;
 }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:16: error: expected ';' before '}' token
   36 |       sum+=a[i]
      |                ^
      |                ;
   37 |     }
      |     ~
Language: C++

#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int x,y,sum;
	cin >> x >> y;
    vector<int> vec(114514);
    for(int i=0; i<x; i++){
      cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    for(int i=0; i<y; i++){
      sum += vec.at(i)
    }
    cout << sum;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:23: error: expected ';' before '}' token
   22 |       sum += vec.at(i)
      |                       ^
      |                       ;
   23 |     }
      |     ~
Language: C++

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

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;
#define    nl     "\n"
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long int

int main()
{
    int n,m;
    ll s=0;
    cin>>n>>m;
    int a[n];
    for0(i,n)cin>>a[i];
    sort(a,a+n);
    for0(i,m){
        s+=a[i];
    }
    cout<<s;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'i' was not declared in this scope
   14 |     for0(i,n)cin>>a[i];
      |          ^
a.cc:14:5: error: 'for0' was not declared in this scope; did you mean 'fork'?
   14 |     for0(i,n)cin>>a[i];
      |     ^~~~
      |     fork
Language: C++

#!/bin/bash

CONTEST_NAME=abc171
QUESTION_ID=b

g++ ${QUESTION_ID}.cpp -o  ${QUESTION_ID}.out

oj d https://atcoder.jp/contests/${CONTEST_NAME}/tasks/${CONTEST_NAME}_${QUESTION_ID} -d ${QUESTION_ID}
oj t -d ${QUESTION_ID} -c ./${QUESTION_ID}.out



Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/bin/bash
      |  ^
a.cc:3:1: error: 'CONTEST_NAME' does not name a type
    3 | CONTEST_NAME=abc171
      | ^~~~~~~~~~~~
a.cc:6:19: error: expected unqualified-id before '.' token
    6 | g++ ${QUESTION_ID}.cpp -o  ${QUESTION_ID}.out
      |                   ^
a.cc:6:42: error: expected unqualified-id before '.' token
    6 | g++ ${QUESTION_ID}.cpp -o  ${QUESTION_ID}.out
      |                                          ^
a.cc:9:24: error: expected unqualified-id before '-' token
    9 | oj t -d ${QUESTION_ID} -c ./${QUESTION_ID}.out
      |                        ^
a.cc:9:43: error: expected unqualified-id before '.' token
    9 | oj t -d ${QUESTION_ID} -c ./${QUESTION_ID}.out
      |                                           ^
Language: Java

import javax.swing.plaf.synth.SynthLookAndFeel;
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class CP {
    static Scanner sc = new Scanner(System.in);
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;

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

        String next()




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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static int lowerBound
    (Integer[] array, int length, int value) {
        int l = 0;
        int r = length;
        while (l < r) {
            int mid = (l + r) / 2;
            if (value < array[mid]) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        return l;
    }
    public static long gcd(long a, long b){
        if (b == 0)
            return a;
        else return gcd(b, a % b);
    }
    public static void main(String [] args) {
      //  int T = sc.nextInt();while (T--!=0)
        {
            solve();
        }
    }
    public static void solve(){
///////////////////////////////////////////////////////////////////////////////////////////
          int n = sc.nextInt();
          int k = sc.nextInt();
          int [] arr = new int [n];
        for (int i = 0; i <n ; i++) {
            arr[i] =sc.nextInt();
        }
        Arrays.sort(arr);
        long sum=0;
        for (int i = 0; i <k ; i++) {
            sum+=arr[i];
        }
        System.out.println(sum);
////////////////////////////////////////////////////////////////////////////////////////////
    }

}

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

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

int main(){
  long long A, B,s=0;
  cin >> A >> B;
  long long int ar[A];
  for(int i = 0; i < A; i++){
    cin>>ar[i];
  }
  sort(ar,ar+A);
  for(i=0; i<B; i++)
  {
    s+=ar[i];
  }
  cout<<s;
  return 0;
}


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

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int 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:12:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |     sort(p.begin(), p.end());
      |     ^~~~
      |     short
Language: C++

#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int x,y,sum;
	cin >> x >> y;
    vector<int> vec(114514);
    for(int i=0; i<x; i++){
      cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end())
    for(int i=0;i<y;i++){
      sum += vec.at(i)
    }
    cout << sum;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:33: error: expected ';' before 'for'
   20 |     sort(vec.begin(), vec.end())
      |                                 ^
      |                                 ;
   21 |     for(int i=0;i<y;i++){
      |     ~~~                          
a.cc:21:17: error: 'i' was not declared in this scope
   21 |     for(int i=0;i<y;i++){
      |                 ^
Language: C++

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

int const N=1e6+3;
const double PI = acos(-1);

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

///ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
///bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0n%(i+2)==0)return false;}return true;}

///************************************************ C o d e ************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,s=0,k;
  	cin>>n>>k;
  k--;
  ll a[n];
  	forn(i,n) cin>>a[i];
  	sort(a,a+n);
  for(i=0;i<=k;i++) s+=a[i];
  cout<<s el;

}

main()
{
///    test
///    while(1)
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Compiler output:
a.cc: In function 'void _case()':
a.cc:60:14: error: 'i' was not declared in this scope
   60 |         forn(i,n) cin>>a[i];
      |              ^
a.cc:27:23: note: in definition of macro 'forn'
   27 | #define forn(i,n) for(i=0;i<n;i++)
      |                       ^
a.cc:62:7: error: 'i' was not declared in this scope
   62 |   for(i=0;i<=k;i++) s+=a[i];
      |       ^
a.cc: At global scope:
a.cc:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main()
      | ^~~~
Language: C++

#incldue <iostream>
#include <algorithm>

int main() {
int n, m;
std :: cin >> n >> m;

int arr[n];
for(int i = 0 ; i < n ; i++) std :: cin >> arr[i];

std :: sort(arr , arr + n);

long long sum = 0;

for(int i = 0 ; i < m ; i++) sum += arr[i];
std :: cout << sum << '\n';
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #incldue; did you mean #include?
    1 | #incldue <iostream>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:6:8: error: 'cin' is not a member of 'std'
    6 | std :: cin >> n >> m;
      |        ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <algorithm>
  +++ |+#include <iostream>
    3 | 
a.cc:9:37: error: 'cin' is not a member of 'std'
    9 | for(int i = 0 ; i < n ; i++) std :: cin >> arr[i];
      |                                     ^~~
a.cc:9:37: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:16:8: error: 'cout' is not a member of 'std'
   16 | std :: cout << sum << '\n';
      |        ^~~~
a.cc:16:8: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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 ans=0;
  for(int i=0;i<K;i++){
    ans=ans+p[i];
  }
  cout <<ans<<endl;
  
 return 0;
}


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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:27: error: expected ';' before 'int'
    5 |   int n,sum=0,k; cin>>n>>k
      |                           ^
      |                           ;
    6 |     int ar[n];
      |     ~~~                    
a.cc:9:10: error: 'ar' was not declared in this scope
    9 |     cin>>ar[i];
      |          ^~
a.cc:10:8: error: 'ar' was not declared in this scope
   10 |   sort(ar,ar+n);
      |        ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main()
{
 
   
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n, k; cin >> n >> k;
    int a[n]; 
    for (int i=0; i<n; i++)
        cin >>a[i];
    sort(a.begin(), a.end());
    int s = 0;
    for (int i=0; i<k; i++)
        s += a[i];
    cout << s;

    return 0;
}

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

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

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

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll t,i,j,n,b,c,d,k;
	cin>>n>>k;
	vector<ll>arr(n);
	for(i=0;i<n;i++) cin>>arr[i];
	sort(arr.begin,arr.end());
	ll ans=0;
	for(i=0;i<min(n,k);i++) ans += arr[i];
	cout<<ans<<'\n';
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: no matching function for call to 'sort(<unresolved overloaded function type>, std::vector<long long int>::iterator)'
   12 |         sort(arr.begin,arr.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<long long int*, vector<long long 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<long long int*, std::vector<long long 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<bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    ll n, k;
    cin >> n >> k;
    ll 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:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <allgorithm>
using namespace std;
typedef long long ll;

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

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

#include <iostream>
using namespace std;

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


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

/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

void virus(){
       ll l;
       cin>>l;
       vector<ll> a(l);
       for(auto &i:a) cin>>i;
       sort(a.begin(),a.end());
       ll s=0;
       for(auto i=0;i<k;i++) s+=a[i];
       cout<<s;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Compiler output:
a.cc: In function 'void virus()':
a.cc:36:23: error: 'k' was not declared in this scope
   36 |        for(auto i=0;i<k;i++) s+=a[i];
      |                       ^
Language: C++

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n,k;cin>>n>>k;
    vi p(n):
    rep(i,n)cin>>p[i];
    sort(all(p));
    int sum=0;
    rep(i,k)sum+=p[i];
    cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:12: error: expected ',' or ';' before ':' token
   41 |     vi p(n):
      |            ^
a.cc:42:9: error: 'i' was not declared in this scope
   42 |     rep(i,n)cin>>p[i];
      |         ^
a.cc:18:34: note: in definition of macro 'rep'
   18 | #define rep(i, n) for(int i = 0; i < (int)(n); i++)
      |                                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int> > pipii;
typedef priority_queue<pii,vector<pii>,greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;





int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    vi arr(n);
    fo(i,n) cin>>arr[i];
    sort(all(arr));
    int sum=0;
    fo(i,k){
        sum+=arr[i];
    }
    cout<<sum<<endl;
 



	
	
	
}

Compiler output:
a.cc:3:23: error: '::main' must return 'int'
    3 | #define int long long int
      |                       ^~~
a.cc:26:1: note: in expansion of macro 'int'
   26 | int main() {
      | ^~~
Language: C++

#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<algorithm>
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define ll long long 
#define mod 998244353
using namespace std;



int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    _cin;

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

}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:13: error: expected primary-expression before ';' token
   22 |     cin>>n>>;
      |             ^