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

//tt89 ;)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void testcase(int t) { cout<<"Case #"<<t<<": "; }
void online() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
}
const int mod= 1e9+7;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:21:20: error: no matching function for call to 'accumulate(std::vector<int>::iterator, __gnu_cxx::__normal_iterator<int*, std::vector<int> >)'
   21 |   cout<<*accumulate(arr.begin(),arr.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:2:
/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++

//tt89 ;)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void testcase(int t) { cout<<"Case #"<<t<<": "; }
void online() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
}
const int mod= 1e9+7;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: invalid type argument of unary '*' (have 'int')
   21 |   cout<<*accumulate(arr.begin(),arr.begin()+k,0);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:4:10: error: expected initializer before ':' token
    4 |   int n,k:
      |          ^
a.cc:10:17: error: 'k' was not declared in this scope
   10 |   for(int i=0;i<k;i++){
      |                 ^
a.cc:11:5: error: 'x' was not declared in this scope
   11 |     x+=vec.at(i);}
      |     ^
a.cc:12:9: error: 'x' was not declared in this scope
   12 |   cout<<x<<endl;}
      |         ^
Language: C

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

int cmp(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int n, k;
	scanf("%d %d", &n, &k);
	int *p = malloc(sizeof(int) * n);
	for(int i = 0; i < n; i++)
		scanf("%d", p + i);
	qsort(p, n, sizeof(int), cmp);
	int sum = 0;
	for(int i = 0; i < k; i+)
		sum += p[i];
	printf("%d\n", sum);
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:16:33: error: expected expression before ')' token
   16 |         for(int i = 0; i < k; i+)
      |                                 ^
Language: C++

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

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

#include <iostream>
using namespace std;
int main()
{
	int n, k,sum=0;
	cin >> n >> k;
	int a[n + 10];
	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: In function 'int main()':
a.cc:10:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |         sort(a, a + n);
      |         ^~~~
      |         short
Language: C++

#include <iostream>
#include <vector>
using i64 = long long;
using namespace std;
 
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i =0; i < n; i++){
      cin >> a.at(i);
    }
    sort(a.begin(), a.end());
  
  	int sum = 0;
    for(int i = 0; i < k; i++){
      sum += a.at(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(a.begin(), a.end());
      |     ^~~~
      |     short
Language: C++

#include<iostream>
using namespace std;
 
int main(){
  int N, K;
  cin >> N >> K;
  
  int flutes[N];
  for(int i = 0; i < N; i++){
    cin >> flutes[i];
  }
  
  sort(flutes, flutes + N);
  int ans = 0;
  for(int i = 0; i < K; i++){
    ans += flutes[i];
  }
  
  cout << ans << endl;
  return 0;
}

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

#include<iostream>
using namespace std;
 
int main(){
  int N, K;
  cin >> N >> K;
  
  int flutes[N];
  for(int i = 0; i < N; i++){
    cin >> flutes[i];
  }
  
  sort(flutes.begin(), flutes.end());
  int ans = 0;
  for(int i = 0; i < K; i++){
    ans += flutes[i];
  }
  
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:15: error: request for member 'begin' in 'flutes', which is of non-class type 'int [N]'
   13 |   sort(flutes.begin(), flutes.end());
      |               ^~~~~
a.cc:13:31: error: request for member 'end' in 'flutes', which is of non-class type 'int [N]'
   13 |   sort(flutes.begin(), flutes.end());
      |                               ^~~
a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   13 |   sort(flutes.begin(), flutes.end());
      |   ^~~~
      |   short
Language: C++

#include<iostream>
using namespace std;

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

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

#include<stdio.h>
int main()
{
  int i,n,k;
  scanf("%d %d",&n,&k);
  int arr[n];
  for(i=0;i<n;i++)
  {
     scanf("%d",&arr[i]);
  }
  for(i=1;i<=k;i++)
  {
    less

Compiler output:
main.c: In function 'main':
main.c:13:5: error: 'less' undeclared (first use in this function)
   13 |     less
      |     ^~~~
main.c:13:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:13:9: error: expected ';' at end of input
   13 |     less
      |         ^
      |         ;
main.c:13:5: error: expected declaration or statement at end of input
   13 |     less
      |     ^~~~
main.c:13:5: error: expected declaration or statement at end of input
Language: C

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

  int arr[N];
  for(int i = 0; i < N; i++)
    scanf("%d", &arr[i]);

  qsort(arr, N, sizeof(int), compare);

  int ans = 0;
  for(int i = 0; i < K; i++)
    ans += arr[i];

  printf("%d\n", ans);

  return 0;
}

int compare( const void* a, const void* b) {
  int int_a = * ( (int*) a );
  int int_b = * ( (int*) b );

  if ( int_a == int_b ) return 0;
  else if ( int_a < int_b ) return -1;
  else return 1;
}

Compiler output:
main.c: In function 'main':
main.c:3:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    3 |   scanf("%d %d", &N, &K);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(void) {
main.c:3:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    3 |   scanf("%d %d", &N, &K);
      |   ^~~~~
main.c:3:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:9:3: error: implicit declaration of function 'qsort' [-Wimplicit-function-declaration]
    9 |   qsort(arr, N, sizeof(int), compare);
      |   ^~~~~
main.c:9:30: error: 'compare' undeclared (first use in this function)
    9 |   qsort(arr, N, sizeof(int), compare);
      |                              ^~~~~~~
main.c:9:30: note: each undeclared identifier is reported only once for each function it appears in
main.c:15:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   15 |   printf("%d\n", ans);
      |   ^~~~~~
main.c:15:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:15:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:15:3: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C++

#include <iostream>
using namespace std;
int main(void){
    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:5:10: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
    5 |  int main(){
      |          ^~
a.cc:5:10: note: remove parentheses to default-initialize a variable
    5 |  int main(){
      |          ^~
      |          --
a.cc:5:10: note: or replace parentheses with braces to value-initialize a variable
a.cc:5:12: error: a function-definition is not allowed here before '{' token
    5 |  int main(){
      |            ^
a.cc:14:2: error: expected '}' at end of input
   14 | }
      |  ^
a.cc:3:15: note: to match this '{'
    3 | int main(void){
      |               ^
Language: C++

#include <iostream>
#include <vector>

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main()
{
    int N, K; cin >> N >> K;
    vector<int> p(N);
    rep (i, 0, N) cin >> p[i];
    sort(p.begin(), p.end());

    int ans = 0;
    rep (i, 0, K) ans += p[i];

    cout << ans << endl;
}


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(p.begin(), p.end());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <vector>

int main() {
    int n, k, sum = 0;
    std::cin >> n >> k;
    std::vector<int> p;
    for (int i = 0; i < n; i++) {
        int temp;
        std::cin >> temp;
        p.push_back(temp);
    }
    std::sort(p.begin(), p.end());

    for (int i = 0; i < k; i++) {
        sum += p.at(i);
    }
    std::cout << sum << std::endl;
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define push_back pb
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) ((find(all(container),element) != container.end())
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
     int n,x;
     cin>>n;
     vi v(n);
     for(int i=0;i<n;i++)
     {
             cin>>v[i];
     }
     sort(v,v+n);
     int s=0;
     for(int i=0;i<x;i++)
     {
             s+=v[i];
     }
     cout<<s;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:6: error: 'vi' was not declared in this scope
   17 |      vi v(n);
      |      ^~
a.cc:20:19: error: 'v' was not declared in this scope
   20 |              cin>>v[i];
      |                   ^
a.cc:22:11: error: 'v' was not declared in this scope
   22 |      sort(v,v+n);
      |           ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   14 |   std::sort(p.begin(),p.end());
      |        ^~~~
      |        qsort
a.cc:14:15: error: request for member 'begin' in 'p', which is of non-class type 'int [N]'
   14 |   std::sort(p.begin(),p.end());
      |               ^~~~~
a.cc:14:25: error: request for member 'end' in 'p', which is of non-class type 'int [N]'
   14 |   std::sort(p.begin(),p.end());
      |                         ^~~
Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i=a;i<b;i++)
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	l(i,0,n){
		cin>>a[i];
	}
	sort(a,a+n);
	int sum=0;
	l(i,0,k){
		sum+=a[i];
	}
  cout<<sum<<"\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |         cin>>n>>k;
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   11 |         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<<"\n";
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:21:18: error: void value not ignored as it ought to be
   21 |     s+=v.pop_back();
      |        ~~~~~~~~~~^~
Language: C++

#include<iostream>
#include<vector>
using namespace std;
 
int main()
{
  int n,k;
  cin>>n>>k;
  
  vector <int> v;
  int s=0;
  for(int i=0;i<n;i++)
  { int x;
   cin>>x;
    v.push_back(x);
   
  }
  
  sort(v.begin(), v.end());
  
  for(int i=0;i<k;i++)
  {
    s+=v[i];
  }
  
  cout<<s<<endl;
    
 
    
return 0;}


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

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

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

#include <bits/stdc++.h>

using namespace std;

int main() {
//#define LOCAL
#ifdef LOCAL
    freopen("/Users/ttjy/Desktop/in.txt", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    int p[1010];
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    sort(p, p + n);
    int sum = 0;
    while (k--) {
        sum += p[i];
    }
    cout << sum << endl;
    return 0;
}

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

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

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

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

int main() {
  int N, K;
  
  cin >> N >> K;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> c.at(i);
  }
  std::sort(vec.begin(),vec.end());//昇順ソート
  int out = 0;
  for (int i = 0; i < K; i++) {
    out+=vec[i];
  }
  
  std::cout << out << std::endl;
  
}

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

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k,all=0;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  sort(p,p+n);
  for(int i=0;i<k;i++){
    all += p.at(i)
  }
  cout << all << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> p(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 | using namespace std;
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> p(n);
      |          ^~~
a.cc:9:12: error: 'p' was not declared in this scope
    9 |     cin >> p.at(i);
      |            ^
a.cc:11:8: error: 'p' was not declared in this scope
   11 |   sort(p,p+n);
      |        ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: no match for call to '(std::vector<int>) (int&)'
   11 |     all += min_element(p(n));
      |                        ~^~~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:11:16: error: overloaded function with no contextual type information
   11 |     all += min.p(n)
      |                ^
Language: C++

#include<cstdio>
#define maxn 1005
using namespace std;
bool cmp(int x,int y)
{
	return x<y;
}
int main(void)
{
	int n,k;
	int a[maxn];
	while(~scanf("%d%d",&n,&k))
	{
		for(int i=0;i<n;++i)
			scanf("%d",&a[i]);
			sort(a,a+n,cmp);
		int sum=0;
		for(int i=0;i<k;++i)
		sum+=a[i];
		printf("%d\n",sum);
	}
	return 0;
}

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

#include<cstdio>
#define maxn 1005
using namespace std;
bool cmp(int x,int y)
{
	return x<y;
}
int main(void)
{
	int n,k;
	while(~scanf("%d%d",&n,&k))
	{
		for(int i=0;i<n;++i)
			scanf("%d",&a[i]);
			sort(a,a+n,cmp);
		int sum=0;
		for(int i=0;i<k;++i)
		sum+=a[i];
		printf("%d\n",sum);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:37: error: 'a' was not declared in this scope
   14 |                         scanf("%d",&a[i]);
      |                                     ^
a.cc:15:30: error: 'a' was not declared in this scope
   15 |                         sort(a,a+n,cmp);
      |                              ^
a.cc:15:25: error: 'sort' was not declared in this scope; did you mean 'short'?
   15 |                         sort(a,a+n,cmp);
      |                         ^~~~
      |                         short
Language: C

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

Compiler output:
main.c: In function 'main':
main.c:17:5: error: expected declaration or statement at end of input
   17 |     return 0;
      |     ^~~~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    int sum = 0;
    vactor<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    sort(p);
    for(int i=0; i<k; i++){
        sum += p[i]
    }
    cout << sum;
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:5: error: 'vactor' was not declared in this scope
   62 |     vactor<int> p(n);
      |     ^~~~~~
a.cc:62:12: error: expected primary-expression before 'int'
   62 |     vactor<int> p(n);
      |            ^~~
a.cc:64:16: error: 'p' was not declared in this scope
   64 |         cin >> p[i];
      |                ^
a.cc:66:10: error: 'p' was not declared in this scope
   66 |     sort(p);
      |          ^
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);
  long long sum = 0 ;
  accumulate(a , a + k , sum);
  cout << sum ;
}

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

#include <stdio.h>

#define LENGTH 256
#define SIZE 999

int main() {
  int n, k p[SIZE], tmp, ans;
  char input[LENGTH];
  fgets(input, LENGTH, stdin);
  sscanf(input, "%d %d", &n, &k);
  for(int i = 0; i < n; i++) {
    sscanf(input, "%d", &p[i]);
    for(int j = i + 1; j < n; n++) {
      if(p[i] > p[j]) {
        tmp = p[i];
        p[i] = p[j]
        p[j] = tmp;
      }
    }
  }
  for(int i = 0; i < k; i++) {
    ans += ans + p[i];
  }
  printf("%d", ans);
}


Compiler output:
main.c: In function 'main':
main.c:7:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'p'
    7 |   int n, k p[SIZE], tmp, ans;
      |            ^
main.c:10:31: error: 'k' undeclared (first use in this function)
   10 |   sscanf(input, "%d %d", &n, &k);
      |                               ^
main.c:10:31: note: each undeclared identifier is reported only once for each function it appears in
main.c:12:26: error: 'p' undeclared (first use in this function)
   12 |     sscanf(input, "%d", &p[i]);
      |                          ^
main.c:15:9: error: 'tmp' undeclared (first use in this function)
   15 |         tmp = p[i];
      |         ^~~
main.c:16:20: error: expected ';' before 'p'
   16 |         p[i] = p[j]
      |                    ^
      |                    ;
   17 |         p[j] = tmp;
      |         ~           
main.c:22:5: error: 'ans' undeclared (first use in this function)
   22 |     ans += ans + p[i];
      |     ^~~
Language: C++

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

int main()
{
  int n, k;
  cin >> n >> k;
  int a[n+1];
  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;
  
  return 0;
}

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


import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;
public class mixJuice {

	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		Vector <Integer> precios=new Vector<Integer>();
		short n=input.nextShort();
		int k=input.nextInt();
		for(int i=0;i<n;i++) {
			precios.add(input.nextInt());
		}
		Collections.sort(precios);
		int suma=0;
		for (int j=0;j<k;j++) {
			suma+=precios.get(j);
		}
		System.out.println(suma);
	}

}


Compiler output:
Main.java:5: error: class mixJuice is public, should be declared in a file named mixJuice.java
public class mixJuice {
       ^
1 error
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];
    }
    sort(p.begin(),p.end());
    int sum = 0;
    for(i=0;i<k;i++){
      sum = sum+p[i];
    }
    cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: request for member 'begin' in 'p', which is of non-class type 'int [n]'
   11 |     sort(p.begin(),p.end());
      |            ^~~~~
a.cc:11:22: error: request for member 'end' in 'p', which is of non-class type 'int [n]'
   11 |     sort(p.begin(),p.end());
      |                      ^~~
a.cc:13:9: error: 'i' was not declared in this scope
   13 |     for(i=0;i<k;i++){
      |         ^
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:15: error: 'i' was not declared in this scope
   16 |   cout << ans[i] << endl;
      |               ^
Language: C++

#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    ll ans = g;
    sort(p.begin(), p.end());
    rep(i,k) ans += p[i];
    cout << ans << '\n';
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:65:14: error: 'g' was not declared in this scope
   65 |     ll ans = g;
      |              ^
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:6: error: no match for call to '(std::vector<int>) (int&)'
   12 |     A(N) = P ;
      |     ~^~~
a.cc:17:9: error: 'i' was not declared in this scope
   17 |   for ( i = 0 ; i < K ; i++){
      |         ^
Language: Java

import java.util.*;
public class B{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		Long[] arr=new Long[n];
		for(int i=0;i<n;i++){
			arr[i]=in.nextLong();
		}
		Arrays.sort(arr);
		long ans=0;
		for(int i=0;i<k;i++){
			ans+=arr[i];
		}
		System.out.print(ans);
	}
}

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

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


Compiler output:
Main.java:15: error: cannot find symbol
    Arrays.sort(p);
    ^
  symbol:   variable Arrays
  location: class Main
1 error
Language: Java

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


Compiler output:
Main.java:15: error: cannot find symbol
    Arrays.sort(p);
    ^
  symbol:   variable Arrays
  location: class Main
1 error
Language: Java

import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] p = new int[n];
    
    for(int i = 0; i < n; i++)
    {
      p[i] = sc.nextInt();
    }
    Arrays.sort(p);
    int resut = 0;
    for(int i = 0; i < k; i++)
    {
      result += p[i];
    }
    System.out.println(result);
  }
}


Compiler output:
Main.java:15: error: cannot find symbol
    Arrays.sort(p);
    ^
  symbol:   variable Arrays
  location: class Main
Main.java:19: error: cannot find symbol
      result += p[i];
      ^
  symbol:   variable result
  location: class Main
Main.java:21: error: cannot find symbol
    System.out.println(result);
                       ^
  symbol:   variable result
  location: class Main
3 errors
Language: Java

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

Compiler output:
Main.java:18: error: ';' expected
      int result += p[i];
                ^
Main.java:18: error: not a statement
      int result += p[i];
                     ^
2 errors
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: 'll' was not declared in this scope
   12 |   for(ll i = 0 ; i<k ; ++i){
      |       ^~
a.cc:12:18: error: 'i' was not declared in this scope
   12 |   for(ll i = 0 ; i<k ; ++i){
      |                  ^
a.cc:17:2: error: expected '}' at end of input
   17 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include< bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin>>n>>k;
  vector< int > v(n, 0);
  for(int i = 0 ; i<n ; ++i){
    cin>>v[i];
  }
  int sum = 0;
  sort(v.begin(), v.end());
  for(ll i = 0 ; i<k ; ++i){
    sum += v[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: Java

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


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

import java.util.Scanner;

class Main{
  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-1];
    for(int i = 0; i < N; i++){
      p[i] = scan.nextInt();
    }
    
    for(int j = 0; j < N-1; j++){
      for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          int k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    }
    
    int sum;
    for(int m = 0; m < K; m++){
      sum += p[m];
    }
    
    System.out.println(sum);
  }
}        


Compiler output:
Main.java:26: error: variable sum might not have been initialized
      sum += p[m];
      ^
Main.java:29: error: variable sum might not have been initialized
    System.out.println(sum);
                       ^
2 errors
Language: Java

import java.util.Scanner;

class Main{
  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-1];
    for(int i = 0; i < N; i++){
      p[i] = scan.nextInt();
    }
    
    for(int j = 0; j < N-1; j++){
      for(int l = j+1; l < N; l++){
        if(a[j] > p[l]){
          int k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    }
    
    
    for(int m = 0; m < K; m++){
      sum += p[m];
    }
    
    System.out.println(sum);
  }
}        


Compiler output:
Main.java:16: error: cannot find symbol
        if(a[j] > p[l]){
           ^
  symbol:   variable a
  location: class Main
Main.java:26: error: cannot find symbol
      sum += p[m];
      ^
  symbol:   variable sum
  location: class Main
Main.java:29: error: cannot find symbol
    System.out.println(sum);
                       ^
  symbol:   variable sum
  location: class Main
3 errors
Language: Java

import java.util.Scanner;

class Main{
  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-1];
    for(int i = 0; i < N; i++){
      p[i] = scan.nextInt();
    }
    
    for(int j = 0; j < N-1; j++){
      for(int l = j+1; l < N; l++){
        if(a[j] > a[l]){
          int k = a[j];
          a[j] = a[l];
          a[l] = k;
        }
      }
    }
    
    
    for(int m = 0; m < K; m++){
      sum += p[m];
    }
    
    System.out.println(sum);
  }
}        

Compiler output:
Main.java:16: error: cannot find symbol
        if(a[j] > a[l]){
           ^
  symbol:   variable a
  location: class Main
Main.java:16: error: cannot find symbol
        if(a[j] > a[l]){
                  ^
  symbol:   variable a
  location: class Main
Main.java:17: error: cannot find symbol
          int k = a[j];
                  ^
  symbol:   variable a
  location: class Main
Main.java:18: error: cannot find symbol
          a[j] = a[l];
          ^
  symbol:   variable a
  location: class Main
Main.java:18: error: cannot find symbol
          a[j] = a[l];
                 ^
  symbol:   variable a
  location: class Main
Main.java:19: error: cannot find symbol
          a[l] = k;
          ^
  symbol:   variable a
  location: class Main
Main.java:26: error: cannot find symbol
      sum += p[m];
      ^
  symbol:   variable sum
  location: class Main
Main.java:29: error: cannot find symbol
    System.out.println(sum);
                       ^
  symbol:   variable sum
  location: class Main
8 errors
Language: Java

import java.util.Scanner;
import java.util.Arrays;
public class main
{
	public static void main(String args[])
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int fruits[] = new int[n];
		for(int i=0;i<n;i++) fruits[i] = s.nextInt();
		solver(arr,k);
	}
	private static void solver(int arr[],int k)
	{
		int min = 0;
		Arrays.sort(arr);
		for(int i=0;i<k;i++) min = min+arr[i];
		System.out.println(min); 
	}
}

Compiler output:
Main.java:3: error: class main is public, should be declared in a file named main.java
public class main
       ^
Main.java:12: error: cannot find symbol
		solver(arr,k);
		       ^
  symbol:   variable arr
  location: class main
2 errors
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 += p[i];
    }
        cout << ans << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> n >> k;
      |     ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int> p(n);
      |     ^~~~~~
a.cc:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> p(n);
      |            ^~~
a.cc:8:16: error: 'p' was not declared in this scope
    8 |         cin >> p[i];
      |                ^
a.cc:11:10: error: 'p' was not declared in this scope
   11 |     sort(p.begin(), p.end());
      |          ^
a.cc:11:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |     sort(p.begin(), p.end());
      |     ^~~~
      |     short
a.cc:16:9: error: 'cout' was not declared in this scope
   16 |         cout << ans << endl;
      |         ^~~~
a.cc:16:24: error: 'endl' was not declared in this scope
   16 |         cout << ans << endl;
      |                        ^~~~
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 += p[i];

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


    return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e3;
int k, n, a[N]
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n) cin >> a[i];
  sort(a, a+n);
  int s = 0;
  FOR(i, 0, k) s += a[i];
  cout << s << endl;
}


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

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

int main()
{
	int k,n;
    cin>>k>>n;
  	int a[k];
    int len = a.size();
    if(len<=1)
    {
		cout<<n<<endl;
    }
   else
   {
    int sum = 0;
  	for(int i=0;i<len;i++)
    {
		sum+=min(a[i],a[i+1]);
    }
  cout<<sum<<endl;
   }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:17: error: request for member 'size' in 'a', which is of non-class type 'int [k]'
    9 |     int len = a.size();
      |                 ^~~~
Language: C++

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

int main()
{
	int k,n;
    cin>>k>>n;
  	int arr[k];
    int len = arr.size();
    if(len<=1)
    {
		cout<<n<<endl;
    }
   else
   {
    int sum = 0;
  	for(int i=0;i<len;i++)
    {
		sum+=min(a[i],a[i+1]);
    }
  cout<<sum<<endl;
   }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:19: error: request for member 'size' in 'arr', which is of non-class type 'int [k]'
    9 |     int len = arr.size();
      |                   ^~~~
a.cc:19:26: error: 'a' was not declared in this scope
   19 |                 sum+=min(a[i],a[i+1]);
      |                          ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:26: error: 'a' was not declared in this scope
   12 |                 sum+=min(a[i],a[i+1]);
      |                          ^