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

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

// 各桁の和を計算する関数


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

  cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:30: error: expected ';' before 'reverse'
   13 |   sort(vec.begin(),vec.end())
      |                              ^
      |                              ;
   14 |   reverse(vec.begin(),vec.end())
      |   ~~~~~~~                     
a.cc:17:5: error: 'sum' was not declared in this scope
   17 |     sum+=vec[i];
      |     ^~~
a.cc:19:11: error: 'sum' was not declared in this scope
   19 |   cout << sum << endl;
      |           ^~~
Language: C++

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

// 各桁の和を計算する関数


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

  cout << sum << endl;
}


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

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

// 各桁の和を計算する関数


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

  cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:30: error: expected ';' before 'reverse'
   13 |   sort(vec.begin(),vec.end())
      |                              ^
      |                              ;
   14 |   reverse(vec.begin(),vec.end)
      |   ~~~~~~~                     
a.cc:17:5: error: 'sum' was not declared in this scope
   17 |     sum+=vec[i];
      |     ^~~
a.cc:19:11: error: 'sum' was not declared in this scope
   19 |   cout << sum << endl;
      |           ^~~
Language: C++

#include <iostream>
using namespace std;

// 各桁の和を計算する関数


int main() {
  int N,K;
  cin >> N>>K;
  vector<int>vec(N);
  for (int i = 0; i < N; ++i) 
    cin>>vec[i];
  sort(l.begin(),l.end())
  reverse(l.begin(),l.end)
  int sum=0;
  for(int i=0;i<K;i++)
    sum+=vec[i];

  cout << sum << endl;
}


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

#include <iostream>
using namespace std;

// 各桁の和を計算する関数


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

  cout << sum << endl;
}


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

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'sum' was not declared in this scope
   14 |     sum+=l.at(i);
      |     ^~~
a.cc:15:10: error: 'sum' was not declared in this scope
   15 |   cout <<sum <<endl;
      |          ^~~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:24: error: no matching function for call to 'end()'
   11 |   reverse(l.begin(),end());
      |                     ~~~^~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
                 from /usr/include/c++/14/bits/stl_algo.h:59,
                 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/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:74:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:85:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:106:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1249:5: note: candidate: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
 1249 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1249:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/valarray:1265:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1265:5: note:   candidate expects 1 argument, 0 provided
a.cc:14:5: error: 'sum' was not declared in this scope
   14 |     sum+=l.at(i);
      |     ^~~
a.cc:15:10: error: 'sum' was not declared in this scope
   15 |   cout <<sum <<endl;
      |          ^~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |   sort(l, l + N, greater<int>());
      |   ^~~~
      |   short
Language: Java

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

Compiler output:
Main.java:13: error: no suitable method found for sort(int[],Comparator<T#1>)
        Arrays.sort(l,Comparator.reverseOrder());
              ^
    method Arrays.<T#2>sort(T#2[],Comparator<? super T#2>) is not applicable
      (inference variable T#2 has incompatible bounds
        equality constraints: int
        upper bounds: Object)
    method Arrays.<T#3>sort(T#3[],int,int,Comparator<? super T#3>) is not applicable
      (cannot infer type-variable(s) T#3
        (actual and formal argument lists differ in length))
  where T#1,T#2,T#3 are type-variables:
    T#1 extends Comparable<? super T#1>
    T#2 extends Object declared in method <T#2>sort(T#2[],Comparator<? super T#2>)
    T#3 extends Object declared in method <T#3>sort(T#3[],int,int,Comparator<? super T#3>)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: Java

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

Compiler output:
Main.java:18: error: reached end of file while parsing
}
 ^
1 error
Language: C++

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

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

  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int sum = 0;
  for(int i=0;i<k;i++) sum += l[i];

  cout<<sum<<endl;

  return 0;
}


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

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

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

  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int sum = 0;
  for(i=0;i<k;i++) sum += l[i];

  cout<<sum<<endl;

  return 0;
}


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

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
    }
    sort(v.rbegin(),v.rend());
    int ans=0;
    REP(i, k){
        ans+=v[i];
    }
    cout<<ans<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'i' was not declared in this scope
   13 |     rep(i,n){
      |         ^
a.cc:13:5: error: 'rep' was not declared in this scope
   13 |     rep(i,n){
      |     ^~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:20: error: expected ')' before ';' token
    5 |   vector<int> l((n);
      |                ~   ^
      |                    )
Language: C++

#include<iostream>
using namespace std;

int main(){
	int N,K,a[50],ans=0;
  	cin>>N>>K;
  	for(int i=0;i<N;++i)cin>>a[i];
  	sort(a,a+N);
  	for(int i=N-1;i=N-K+1;--i)ans+=a[i];
  	cout<<ans<<endl;
  	return 0;
}

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

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

Compiler output:
main.c: In function 'main':
main.c:5:9: error: 'n' undeclared (first use in this function)
    5 |   int l[n],max = 0;
      |         ^
main.c:5:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:21: error: 'k' undeclared (first use in this function)
    9 |   for(int i = 0;i + k <= n + 1;i++){
      |                     ^
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:27: error: expected primary-expression before ')' token
   10 |   sort(l ,l+N,greater<int>) ;
      |                           ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:13: error: 'i' was not declared in this scope
    5 |   int n,k,l[i],ans=0;cin>>n>>k;
      |             ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:13: error: 'i' was not declared in this scope
    5 |   int n,k,l[i]ans=0;cin>>n>>k;
      |             ^
a.cc:5:15: error: expected initializer before 'ans'
    5 |   int n,k,l[i]ans=0;cin>>n>>k;
      |               ^~~
a.cc:9:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
    9 |     ans+=l[j];
      |     ^~~
      |     abs
a.cc:11:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   11 |   cout<<ans;
      |         ^~~
      |         abs
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:4:13: error: 'i' was not declared in this scope
    4 |   int n,k,l[i],ans=0;cin>>n>>k;
      |             ^
a.cc:5:28: error: 'l' was not declared in this scope
    5 |   for(int i=0;i<n;i++)cin>>l[i];
      |                            ^
a.cc:6:8: error: 'l' was not declared in this scope
    6 |   sort(l,l+n,greater<int>());
      |        ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,l,ans=0;cin>>n>>k;
  for(int i=0;i<n;i++)cin>>l;
  sort(l,l+n,greater<int>);
  for(int j=0;j<k;j++){
    ans+=l;
  }
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:26: error: expected primary-expression before ')' token
    6 |   sort(l,l+n,greater<int>);
      |                          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,l,ans=0;cin>>n>>k;
  for(int i=0;i<n;i++)cin>>l;
  sort(l.rbegin(),l.rend());
  for(int j=0;j<k;j++){
    ans+=l;
  }
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:10: error: request for member 'rbegin' in 'l', which is of non-class type 'int'
    6 |   sort(l.rbegin(),l.rend());
      |          ^~~~~~
a.cc:6:21: error: request for member 'rend' in 'l', which is of non-class type 'int'
    6 |   sort(l.rbegin(),l.rend());
      |                     ^~~~
Language: C++

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



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

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

}


Compiler output:
Main.java:9: error: cannot find symbol
  Arrays.sort(po[i]);
                 ^
  symbol:   variable i
  location: class Main
Main.java:9: error: no suitable method found for sort(int)
  Arrays.sort(po[i]);
        ^
    method Arrays.sort(int[]) is not applicable
      (argument mismatch; int cannot be converted to int[])
    method Arrays.sort(long[]) is not applicable
      (argument mismatch; int cannot be converted to long[])
    method Arrays.sort(short[]) is not applicable
      (argument mismatch; int cannot be converted to short[])
    method Arrays.sort(char[]) is not applicable
      (argument mismatch; int cannot be converted to char[])
    method Arrays.sort(byte[]) is not applicable
      (argument mismatch; int cannot be converted to byte[])
    method Arrays.sort(float[]) is not applicable
      (argument mismatch; int cannot be converted to float[])
    method Arrays.sort(double[]) is not applicable
      (argument mismatch; int cannot be converted to double[])
    method Arrays.sort(Object[]) is not applicable
      (argument mismatch; int cannot be converted to Object[])
    method Arrays.<T#1>sort(T#1[],Comparator<? super T#1>) is not applicable
      (cannot infer type-variable(s) T#1
        (actual and formal argument lists differ in length))
    method Arrays.<T#2>sort(T#2[],int,int,Comparator<? super T#2>) is not applicable
      (cannot infer type-variable(s) T#2
        (actual and formal argument lists differ in length))
  where T#1,T#2 are type-variables:
    T#1 extends Object declared in method <T#1>sort(T#1[],Comparator<? super T#1>)
    T#2 extends Object declared in method <T#2>sort(T#2[],int,int,Comparator<? super T#2>)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
Language: C++

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int>l(n);
  for(int i=0; i<n; i++)cin >> l[i];
  sort(l.rbegin(), l.rend());
  cout << accumulate(l.begin(), l.begin()+k);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: no matching function for call to 'accumulate(std::vector<int>::iterator, __gnu_cxx::__normal_iterator<int*, std::vector<int> >)'
   13 |   cout << accumulate(l.begin(), l.begin()+k);
      |           ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int>l(n);
  for(int i=0; i<n; i++)cin >> l[i];
  sort(l.rbegin(), l.rend());
  cout << accumulate(l.begin(), l.begin()+k);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: 'accumulate' was not declared in this scope
   12 |   cout << accumulate(l.begin(), l.begin()+k);
      |           ^~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algortihm>

using namespace std;

int N, K, buff, ans=0;
vector<int> vec;

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

    for(int i = 0; i < N; i++){
        cin >> buff;
        vec.push_back(buff);
    }
    
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

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

    cout << ans << endl;
}


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

#include <iostream>
#include <vector>

using namespace std;

int N, K, buff, ans=0;
vector<int> vec;

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

    for(int i = 0; i < N; i++){
        cin >> buff;
        vec.push_back(buff);
    }
    
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    for(int i = 0; i < K; i++) ans += vec[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(vec.begin(), vec.end());
      |     ^~~~
      |     short
a.cc:18:5: error: 'reverse' was not declared in this scope
   18 |     reverse(vec.begin(), vec.end());
      |     ^~~~~~~
Language: C++

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

int main(){
  int n, k;
  vector<int> v;

  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end(), greater<int>());

  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:16:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |   sort(v.begin(), v.end(), greater<int>());
      |   ^~~~
      |   short
Language: C++

#include<iostream>
using namespace std;

int main()
{
	int n,k,l[50];
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>l[i];
	
	sort(l,l+n);
	int sum=0;
	for(int i=n-1;i>=n-k;i--) sum+=l[i];
	
	cout<<sum<<endl;
	
	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(l,l+n);
      |         ^~~~
      |         short
Language: C

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

#define SENTINEL 1000000000
int count = 0;
void merge(int A[], int left, int mid, int right);
void mergeSort(int A[], int left, int right) {
	int i, mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}



void merge(int A[], int left, int mid, int right) {
	int n1, n2, i, j, k;
	int *L, *R;
	n1 = mid - left;
	n2 = right - mid;
	L = (int *)malloc(sizeof(int)*(n1 + 1));
	R = (int *)malloc(sizeof(int)*(n2 + 1));
	for (i = 0; i <= n1 - 1; i++) {
		L[i] = A[left + i];
	}
	for (j = 0; j <= n2 - 1; j++) {
		R[j] = A[mid + j];
	}
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	i = 0;
	j = 0;
	for (k = left; k <= right - 1; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
			count++;
		}
		else {
			A[k] = R[j];
			j++;
			count++;
		}
	}
	free(L);
	free(R);
}

int main() {
	long long int a, b, c, d, n, m, num[2000]= {}, result = 0;
	char str[200005];
	scanf("%lld%lld", &n,&m);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &num[i]);
	}
	mergeSort(num, 0, n);
	for (int i = n-1; i >=n-m; i--) {
		result += num[i];
	}
	printf("%lld", result);
}


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

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int N,K;
    cin >> N >> K;
    int l[50];
    for(int i=0: i<N; i++) cin >> l[i];
    sort(l, l+N);
    int ans = 0;
    for(int i=0; i<K; i++) ans += l[N-i-1];
    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:14: error: initializer in range-based 'for' loop
   38 |     for(int i=0: i<N; i++) cin >> l[i];
      |              ^
a.cc:38:21: error: expected ')' before ';' token
   38 |     for(int i=0: i<N; i++) cin >> l[i];
      |        ~            ^
      |                     )
a.cc:38:23: error: 'i' was not declared in this scope
   38 |     for(int i=0: i<N; i++) cin >> l[i];
      |                       ^
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: 'cont' was not declared in this scope; did you mean 'const'?
   19 |   cont << ret << endl;
      |   ^~~~
      |   const
Language: C++

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

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

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

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

int main (){
  int n,k;
  cin >> n >> k;
  
  vector<int> l(N);
     for (int i = 0; i < N; i++) {
       cin >> l.at(i);
         }
  reverse(l.begin(),l.end());
  int bou;
  
  for (int i =0; i <= k; i++){
    bou += l.at(i);
    
  }
  
  cout << bou << endl;
  
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: 'N' was not declared in this scope
    8 |   vector<int> l(N);
      |                 ^
Language: Java

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

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] barLength = new int[n];
        for (int i = 0; i < n; i++) {
            barLength[i] = sc.nextInt();
        }

        Arrays.sort(barLength, Comparator.reverseOrder());
        int max= 0;
        for (int i = 0; i < k; i++) {
            max += barLength[i];
        }
        System.out.println(max);
    }
}

Compiler output:
Main.java:20: error: no suitable method found for sort(int[],Comparator<T#1>)
        Arrays.sort(barLength, Comparator.reverseOrder());
              ^
    method Arrays.<T#2>sort(T#2[],Comparator<? super T#2>) is not applicable
      (inference variable T#2 has incompatible bounds
        equality constraints: int
        upper bounds: Object)
    method Arrays.<T#3>sort(T#3[],int,int,Comparator<? super T#3>) is not applicable
      (cannot infer type-variable(s) T#3
        (actual and formal argument lists differ in length))
  where T#1,T#2,T#3 are type-variables:
    T#1 extends Comparable<? super T#1>
    T#2 extends Object declared in method <T#2>sort(T#2[],Comparator<? super T#2>)
    T#3 extends Object declared in method <T#3>sort(T#3[],int,int,Comparator<? super T#3>)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] num = new int[N];
    
    for(int i=0; i<N;i++){
      num[i] = sc.nextIn();
    }
    
    Arrays.sort(num);
    int output = 0;
    
    for(int i=0; i <= K; i++){
      output += num[N-1-i];
    }
    
    System.out.println(output);
  }
}



Compiler output:
Main.java:13: error: cannot find symbol
      num[i] = sc.nextIn();
                 ^
  symbol:   method nextIn()
  location: variable sc of type Scanner
1 error
Language: Java

import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextIn();
    int K = sc.nextIn();
    int[] num = new int[N];
    
    for(int i=0; i<N;i++){
      num[i] = sc.nextIn();
    }
    
    Arrays.sort(num);
    int output = 0;
    
    for(int i=0; i <= k; i++){
      output += num[N-1-i];
    }
    
    System.out.println(output);
  }
}
 
      
    
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] num = new int[N];
    
    for(int i=0; i<N;i++){
      num[i] = sc.nextIn();
    }
    
    Arrays.sort(num);
    int output = 0;
    
    for(int i=0; i <= K; i++){
      output += num[N-1-i];
    }
    
    System.out.println(output);
  }
}

      
    
提出情報

Compiler output:
Main.java:29: error: class, interface, enum, or record expected
import java.util.*;
^
Main.java:57: error: reached end of file while parsing
????
^
2 errors
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextIn();
    int K = sc.nextIn();
    int[] num = new int[N];
    
    for(int i=0; i<N;i++){
      num[i] = sc.nextIn();
    }
    
    Arrays.sort(num);
    int output = 0;
    
    for(int i=0; i <= k; i++){
      output += num[N-1-i];
    }
    
    System.out.println(output);
  }
}

      
    

Compiler output:
Main.java:8: error: cannot find symbol
    int N = sc.nextIn();
              ^
  symbol:   method nextIn()
  location: variable sc of type Scanner
Main.java:9: error: cannot find symbol
    int K = sc.nextIn();
              ^
  symbol:   method nextIn()
  location: variable sc of type Scanner
Main.java:13: error: cannot find symbol
      num[i] = sc.nextIn();
                 ^
  symbol:   method nextIn()
  location: variable sc of type Scanner
Main.java:19: error: cannot find symbol
    for(int i=0; i <= k; i++){
                      ^
  symbol:   variable k
  location: class Main
4 errors
Language: C++

#include <iostream>
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	int ans=0;
	vector<int>vec(a);
	for(int i=0;i<a;i++){
		int a;
		cin>>a;
		vec.at(i)=a;
	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	for(int i=0;i<b;i++){
		ans+=vec.at(i);
	}
	cout<<ans<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'vector' was not declared in this scope
    8 |         vector<int>vec(a);
      |         ^~~~~~
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:16: error: expected primary-expression before 'int'
    8 |         vector<int>vec(a);
      |                ^~~
a.cc:12:17: error: 'vec' was not declared in this scope
   12 |                 vec.at(i)=a;
      |                 ^~~
a.cc:14:14: error: 'vec' was not declared in this scope
   14 |         sort(vec.begin(),vec.end());
      |              ^~~
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |         sort(vec.begin(),vec.end());
      |         ^~~~
      |         short
a.cc:15:9: error: 'reverse' was not declared in this scope
   15 |         reverse(vec.begin(),vec.end());
      |         ^~~~~~~
Language: C++

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

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

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |     sort(l.begin(), l.end(), [](int a, int b) { return a > b; });
      |     ^~~~
      |     short
Language: C++

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


using namespace std;

int main(){
  int N,K;
  
  cin>>N>>K;
  vector<int> stick(N);
  
  for(int x &x:stick){
    cin>>x;
  }
  
  sort(stick.rbegin(),stick.rend());
  int ans=0;
  for(int i=0;i<K;++i){
    ans+=stick[i];
  }
  
  
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:12: error: expected ';' before '&' token
   14 |   for(int x &x:stick){
      |            ^~
      |            ;
a.cc:14:15: error: found ':' in nested-name-specifier, expected '::'
   14 |   for(int x &x:stick){
      |               ^
      |               ::
a.cc:14:14: error: 'x' is not a class, namespace, or enumeration
   14 |   for(int x &x:stick){
      |              ^
a.cc:14:21: error: expected ';' before ')' token
   14 |   for(int x &x:stick){
      |                     ^
      |                     ;
Language: C++

#include<iiostream>
#include<vector>
#include<algolithm>


using namespace std;

int main(){
  int N,K;
  
  cin>>N>>K;
  vector<int> stick(N);
  
  for(int x &x:stick){
    cin>>x;
  }
  
  sort(stick.rbegin(),stick.rend());
  int ans=0;
  for(int i=0;i<K;++i){
    ans+=stick[i];
  }
  
  
  cout<<ans<<endl;
}

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

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

int main(){
	int N, K, S=0;
	cin >> N >> K;
	int l[N], S=0;
	for(int i=0; i<N; i++) cin >> l[i];
	sort(l, l+N, greater<int>());
	for(int i=0; i<K; i++) S += l[i];
	cout << S << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:19: error: redeclaration of 'int S'
    8 |         int l[N], S=0;
      |                   ^
a.cc:6:19: note: 'int S' previously declared here
    6 |         int N, K, S=0;
      |                   ^
Language: C++

#include <iostream>
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  priority_queue<int> q;
  int a;
  for(int i = 0; i < n; i++){
    cin >> a;
    q.push(a);
  }
  a = 0;
  for(int i = 0; i < k; i++){
    a += q.top();
    q.pop();
  }
  cout << a << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'priority_queue' was not declared in this scope
    7 |   priority_queue<int> q;
      |   ^~~~~~~~~~~~~~
a.cc:2:1: note: 'std::priority_queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    1 | #include <iostream>
  +++ |+#include <queue>
    2 | using namespace std;
a.cc:7:18: error: expected primary-expression before 'int'
    7 |   priority_queue<int> q;
      |                  ^~~
a.cc:11:5: error: 'q' was not declared in this scope
   11 |     q.push(a);
      |     ^
a.cc:15:10: error: 'q' was not declared in this scope
   15 |     a += q.top();
      |          ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N, K, A[60];
	for (int i = 0; i < 60; i++) {
		A[i] = 0;
	}
	cin >> N >> K;
	for (int i = 0; i < N; i + ) {
		cin >> A[i];

	}
	sort(A, A + N, greater<int>());
	int ans = 0;
	for (int i = 0; i < K; i++) {
		ans += A[i];
	}
	cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:36: error: expected primary-expression before ')' token
   10 |         for (int i = 0; i < N; i + ) {
      |                                    ^
Language: C++

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

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

#include<iostream>
using namespace std;
int main()
{
  int N, K; cin >> N >> K;
  int l[51];
  for(int i = 0;i < N; ++i){
    cin >> l[i];
  }
  sort(i, i + N, greater<int>());
  int score;
  for(int i = 0; i < K; ++i){
    score += a[i];
  }
  cout << score << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:8: error: 'i' was not declared in this scope
   10 |   sort(i, i + N, greater<int>());
      |        ^
a.cc:10:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |   sort(i, i + N, greater<int>());
      |   ^~~~
      |   short
a.cc:13:14: error: 'a' was not declared in this scope
   13 |     score += a[i];
      |              ^
Language: C++

#include<iostream>
using namespace std;
int main()
{
  int N, K; cin >> N >> K;
  int l[51];
  for(int i = 0;i < N; ++i){
    cin >> l[i];
  }
  sort(a, a + N, greater<int>());
  int score;
  for(int i = 0; i < K; ++i){
    score += a[i];
  }
  cout << score << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
int sum(vector<int> v,int l){
  int s=0;
  for(int i=0;i<l;i++){
    s += v[i];
  }
  return s;
}
  
int main() {
  int N,K;
  cin >>N>>K;
  vector<int> l(N);
  for(int i =0;i<N;i++){
    cin >> l[i];
  }
  sort(l);
  cout <<sum(l,K)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:7: error: no matching function for call to 'sort(std::vector<int>&)'
   18 |   sort(l);
      |   ~~~~^~~
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: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 1 provided
/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, 1 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, 1 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, 1 provided
Language: C

#include<stdio.h>
#include<string.h>

int nagasa[51];

int main() {

	int i, j;
	int n, k, tmp;
	int maxsum;

	scanf_s("%d%d", &n, &k);
	for (i = 0; i < n; i++) {
		scanf_s("%d", &nagasa[i]);
	}

	//長い順にソートする//
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			if (nagasa[i] < nagasa[j]) {
				tmp = nagasa[i];
				nagasa[i] = nagasa[j];
				nagasa[j] = tmp;
			}
		}

	}

	maxsum = 0;
	for (i = 0; i < k; i++) {
		maxsum = maxsum + nagasa[i];
	}

	printf("%d", maxsum);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:12:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   12 |         scanf_s("%d%d", &n, &k);
      |         ^~~~~~~
      |         scanf
Language: C++

#include<stdio.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
int asc(const void *a,const void *b){
return *(int *)b - *(int *)a;
}
int main(int argc,char *argv[]){
 int n,k;
 scanf("%d%d",&n,&k);
 int a[n],ans=0;
 rep(i,n)scanf("%d",&a[i]);
 qsort((void *)a,n,sizeof(a[0]),asc);
 rep(i,k)ans+=a[i];
 printf("%d\n",ans);
 return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:12:2: error: 'qsort' was not declared in this scope
   12 |  qsort((void *)a,n,sizeof(a[0]),asc);
      |  ^~~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

int a[100000];

inline int read(){
    int ret,flag = 0;
    char c;
    while((c = getchar()) < '0' || c > '9') if(c == '-') flag = 1;
    ret = c - '0';
    while((c = getchar()) >= '0' && c <= '9') ret = (ret << 3) + (ret << 1) + c - '0';
    return flag ? -ret : ret;
}

int main(){
    int n,m;
    n = read();
    m = read();
    for(int i=1;i<=n;i++)
        a[i] = read();
    sort(a + 1,a + n + 1);
    int sum = 0;
    for(int i = n;i >= n-m+1;i--)
    sum += a[i];
    PRINTF("%d",sum);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: 'PRINTF' was not declared in this scope
   26 |     PRINTF("%d",sum);
      |     ^~~~~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i = 0; i < N; i++) cin >> l[i];
  sort(l.begin(), l.end()), reverse(l.begin(), l.end());
  int sum = 0;
  for(int i = 0; i < K; i++) sum += l[i];
  cout << sum << 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> l(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:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> l(N);
      |          ^~~
a.cc:9:37: error: 'l' was not declared in this scope
    9 |   for(int i = 0; i < N; i++) cin >> l[i];
      |                                     ^
a.cc:10:8: error: 'l' was not declared in this scope
   10 |   sort(l.begin(), l.end()), reverse(l.begin(), l.end());
      |        ^
Language: C++

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

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

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