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

#include<bit/stdc++.h>
using namespace std;
main(){
  int n,k;
  cin>>n>>k;
  long ans=0;
  vector<long>a(n);
  for(int i=0;i<n;++i)cin>>a[i];
  sort(begin(a),end(a),greater<>());
  for(int i=0;i<k;++i){
    ans+=a[i];
  }
  cout<<ans<<endl;
}

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

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

int main() {

  int N,K,sum;
  
  vector<int> vec[N];
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }

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

  for (int i=0; i<K; i++){
    sum += vec.at(i);
  }
  cout << sum << endl;  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: request for member 'at' in 'vec', which is of non-class type 'std::vector<int> [N]'
   10 |     cin >> vec.at(i);
      |                ^~
a.cc:13:13: error: request for member 'begin' in 'vec', which is of non-class type 'std::vector<int> [N]'
   13 |   sort (vec.begin(),vec.end());
      |             ^~~~~
a.cc:13:25: error: request for member 'end' in 'vec', which is of non-class type 'std::vector<int> [N]'
   13 |   sort (vec.begin(),vec.end());
      |                         ^~~
a.cc:14:16: error: request for member 'begin' in 'vec', which is of non-class type 'std::vector<int> [N]'
   14 |   reverse (vec.begin(),vec.end());
      |                ^~~~~
a.cc:14:28: error: request for member 'end' in 'vec', which is of non-class type 'std::vector<int> [N]'
   14 |   reverse (vec.begin(),vec.end());
      |                            ^~~
a.cc:17:16: error: request for member 'at' in 'vec', which is of non-class type 'std::vector<int> [N]'
   17 |     sum += vec.at(i);
      |                ^~
Language: C++

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,k,a[10001],sym=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++) 
    {
	cin>>a[i];
    }
    for(int i=1;i<=n-1;i++)
        for(int j=i+1;j<=n;j++)
        {
            if(a[i]<a[j]) 
            {
			swap(a[i],a[j]);
		    }
        }
    for(int i=1;i<=k;i++) 
    {
	sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: 'sum' was not declared in this scope; did you mean 'sym'?
   22 |         sum+=a[i];
      |         ^~~
      |         sym
a.cc:24:11: error: 'sum' was not declared in this scope; did you mean 'sym'?
   24 |     cout<<sum<<endl;
      |           ^~~
      |           sym
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,k,ans;
int a[50+10];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=n;i>=n-k+1;i--)a
		ans+=a[i];
	cout<<ans<<"\n";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:35: error: expected ';' before 'ans'
   14 |         for(int i=n;i>=n-k+1;i--)a
      |                                   ^
      |                                   ;
   15 |                 ans+=a[i];
      |                 ~~~
Language: C

#include <stdio.h>
int n;
void merge_sort (int array[], int left, int right) {
  int i, j, k, mid;
  int work[n];  
  if (left < right) {
    mid = (left + right)/2; 
    merge_sort(array, left, mid);  
    merge_sort(array, mid+1, right);  
    for (i = mid; i >= left; i--) { work[i] = array[i]; } 
    for (j = mid+1; j <= right; j++) {
      work[right-(j-(mid+1))] = array[j]; 
    }
    i = left; j = right;
    for (k = left; k <= right; k++) {
      if (work[i] < work[j]) { array[k] = work[i++]; }
      else                   { array[k] = work[j--]; }
    }
  }
}
int main(void){
int k;
scanf("%d%d",&n,&k);
int arr[n];
for(int i=0;i<n;i++)scanf("%d",&arr[i]);
merge_sort(arr,0,n-1);
int ans=0;
for(int i=n-1;i>=n-k;i-=1){
ans+=arr[i];
}
printf(“%d\n”,ans);
}


Compiler output:
main.c: In function 'main':
main.c:31:8: error: stray '\342' in program
   31 | printf(<U+201C>%d\n<U+201D>,ans);
      |        ^~~~~~~~
main.c:31:9: error: expected expression before '%' token
   31 | printf(“%d\n”,ans);
      |         ^
main.c:31:11: error: stray '\' in program
   31 | printf(“%d\n”,ans);
      |           ^
main.c:31:13: error: stray '\342' in program
   31 | printf(<U+201C>%d\n<U+201D>,ans);
      |                    ^~~~~~~~
Language: C

#include <stdio.h>
int n;
void merge_sort (int array[], int left, int right) {
  int i, j, k, mid;
  int work[n];  
  if (left < right) {
    mid = (left + right)/2; 
    merge_sort(array, left, mid);  
    merge_sort(array, mid+1, right);  
    for (i = mid; i >= left; i--) { work[i] = array[i]; } 
    for (j = mid+1; j <= right; j++) {
      work[right-(j-(mid+1))] = array[j]; 
    }
    i = left; j = right;
    for (k = left; k <= right; k++) {
      if (work[i] < work[j]) { array[k] = work[i++]; }
      else                   { array[k] = work[j--]; }
    }
  }
}
int main(void){
int k;
scanf(“%d%d”,&n,&k);
int arr[n];
for(int i=0;i<n;i++)scanf(“%d”,&arr[i]);
merge_sort(arr,0,n-1);
int ans=0
for(int i=n-1;i>=n-k;i-=1){
ans+=arr[i];
}
printf(“%d\n”,ans);
}

Compiler output:
main.c: In function 'main':
main.c:23:7: error: stray '\342' in program
   23 | scanf(<U+201C>%d%d<U+201D>,&n,&k);
      |       ^~~~~~~~
main.c:23:8: error: expected expression before '%' token
   23 | scanf(“%d%d”,&n,&k);
      |        ^
main.c:23:12: error: stray '\342' in program
   23 | scanf(<U+201C>%d%d<U+201D>,&n,&k);
      |                   ^~~~~~~~
main.c:25:27: error: stray '\342' in program
   25 | for(int i=0;i<n;i++)scanf(<U+201C>%d<U+201D>,&arr[i]);
      |                           ^~~~~~~~
main.c:25:28: error: expected expression before '%' token
   25 | for(int i=0;i<n;i++)scanf(“%d”,&arr[i]);
      |                            ^
main.c:25:30: error: stray '\342' in program
   25 | for(int i=0;i<n;i++)scanf(<U+201C>%d<U+201D>,&arr[i]);
      |                                     ^~~~~~~~
main.c:28:1: error: expected ',' or ';' before 'for'
   28 | for(int i=n-1;i>=n-k;i-=1){
      | ^~~
main.c:28:15: error: 'i' undeclared (first use in this function)
   28 | for(int i=n-1;i>=n-k;i-=1){
      |               ^
main.c:28:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:28:26: error: expected ';' before ')' token
   28 | for(int i=n-1;i>=n-k;i-=1){
      |                          ^
      |                          ;
main.c:28:26: error: expected statement before ')' token
main.c:31:8: error: stray '\342' in program
   31 | printf(<U+201C>%d\n<U+201D>,ans);
      |        ^~~~~~~~
main.c:31:9: error: expected expression before '%' token
   31 | printf(“%d\n”,ans);
      |         ^
main.c:31:11: error: stray '\' in program
   31 | printf(“%d\n”,ans);
      |           ^
main.c:31:13: error: stray '\342' in program
   31 | printf(<U+201C>%d\n<U+201D>,ans);
      |                    ^~~~~~~~
Language: C++

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

int main() {
  int a,b;
  cin >> a>>b;
  int  c[100];
  for (int i =0;i<a; i++)
    
  cin >> c[i];
  
 sort(c,c+a);
  
   for(int i=a-1; i >a-1-b ; i--){
        int d =0;
      d += c[i];
   }
     cout << d << endl;       
            return 0; 
   }
      
       
     
   


Compiler output:
a.cc: In function 'int main()':
a.cc:18:14: error: 'd' was not declared in this scope
   18 |      cout << d << endl;
      |              ^
Language: C++

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

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

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

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

#include <iostream>
#include <vector>

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 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:14:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |   sort(l.begin(),l.end());
      |   ^~~~
      |   short
a.cc:15:3: error: 'reverse' was not declared in this scope
   15 |   reverse(l.begin(),l.end());
      |   ^~~~~~~
Language: C++

#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using namespace std;
#define inf 2000000000
template<class t> inline bool chmin(t& a, t b) { if (a > b) { a = b; return true; } return false; }
template<class t> inline bool chmax(t& a, t b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int n,k;
int main(){
	cin >>  n >> k ;
	int a[n];
	rep(i,n){
	cin>>a[i];
	}
	sort(a,a+n);
	int ans = 0;
	int count = 0;
	for(int i = n-1; i>=0; i--){
			count++;	
			ans+=a[i];
			if(count==k){
				break;
			}
	}
	cout<<ans<<endl;
}




Compiler output:
a.cc:23:19: error: macro "sort" passed 2 arguments, but takes just 1
   23 |         sort(a,a+n);
      |                   ^
a.cc:8:9: note: macro "sort" defined here
    8 | #define sort(a) sort((a).begin(),(a).end())
      |         ^~~~
a.cc: In function 'int main()':
a.cc:23:20: error: statement cannot resolve address of overloaded function
   23 |         sort(a,a+n);
      |                    ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:14:29: error: expected ';' before 'reverse'
   14 |     sort(l.begin(), l.end())
      |                             ^
      |                             ;
   15 |     reverse(l.begin(), l.end())
      |     ~~~~~~~                  
a.cc:18:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   18 |         cnt += l[i]
      |         ^~~
      |         int
a.cc:20:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   20 |     cout << cnt << endl;
      |             ^~~
      |             int
Language: C++

#include <bits/stdc++.h>

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

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

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,i,j,k,sum=0;
	cin>>n>>k;
	int a[n+1];
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1;a+n+1);
	for(i=n;i>=(n-k);i--){
		sum+=a[i];
	}
	cout<<a[i];
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: expected ')' before ';' token
   11 |         sort(a+1;a+n+1);
      |             ~   ^
      |                 )
a.cc:11:23: error: expected ';' before ')' token
   11 |         sort(a+1;a+n+1);
      |                       ^
      |                       ;
Language: C++

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

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

#include <bis/stdc++.h>
using namespace std;
int main() {
  priority_queue<int> l;
  int n,k;
  cin >> n >> k;
  int ll;
  for(int i = 0;i < n;i++) {
    cin >> ll;
    l.push(ll);
  }
  int sum = 0;
  for(int i = 0;i < k;i++) {
    sum += l.top();
    l.pop();
  }
  cout << sum << endl;
}

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

#include<iostream>
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, l+n, greater<int>());
  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:6:3: error: 'sort' was not declared in this scope; did you mean 'short'?
    6 |   sort(l, l+n, greater<int>());
      |   ^~~~
      |   short
Language: C++

#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数

int main() {
  ll a,b;
  ci(a>>b);
  vec c(a);
  for(i,0,a)
    ci(c[i]);
  sort(c,c);
  ll d=0;
  for(int i=a-1;i>a-1-b;i--)
    d+=c[i];
  co(d);
  }

Compiler output:
a.cc:44:28: error: macro "for" requires 3 arguments, but only 1 given
   44 |   for(int i=a-1;i>a-1-b;i--)
      |                            ^
a.cc:16:9: note: macro "for" defined here
   16 | #define for(i,a,b) for(int i=a;i<b;i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:45:5: error: expected '(' before 'd'
   45 |     d+=c[i];
      |     ^
      |     (
a.cc:45:10: error: 'i' was not declared in this scope
   45 |     d+=c[i];
      |          ^
a.cc:47:3: error: expected primary-expression before '}' token
   47 |   }
      |   ^
a.cc:46:9: error: expected ')' before '}' token
   46 |   co(d);
      |         ^
      |         )
   47 |   }
      |   ~      
a.cc:45:5: note: to match this '('
   45 |     d+=c[i];
      |     ^
a.cc:47:3: error: expected primary-expression before '}' token
   47 |   }
      |   ^
Language: C++

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int n, k, res = 0;
    cin >> n >> k;
    vector<int> l(n);
    rep(i, n) cin >> l.at(i);
    reverse(sort(all(l)));
    rep(i, k) res += l.at(i);
    cout << res << endl;
    // end

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: invalid use of void expression
   17 |     reverse(sort(all(l)));
      |             ~~~~^~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
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.begin(),L.end());
  reverse(L.begin(),L.end());
  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:11:10: error: request for member 'begin' in 'L', which is of non-class type 'int [55]'
   11 |   sort(L.begin(),L.end());
      |          ^~~~~
a.cc:11:20: error: request for member 'end' in 'L', which is of non-class type 'int [55]'
   11 |   sort(L.begin(),L.end());
      |                    ^~~
a.cc:12:13: error: request for member 'begin' in 'L', which is of non-class type 'int [55]'
   12 |   reverse(L.begin(),L.end());
      |             ^~~~~
a.cc:12:23: error: request for member 'end' in 'L', which is of non-class type 'int [55]'
   12 |   reverse(L.begin(),L.end());
      |                       ^~~
Language: C++

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

int main(){
  int N,K;cin>>N>>K;
  int L(50);
  for (int i=0;i<N;++i){
    cin>>L[i];
  }
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  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:9:11: error: invalid types 'int[int]' for array subscript
    9 |     cin>>L[i];
      |           ^
a.cc:11:10: error: request for member 'begin' in 'L', which is of non-class type 'int'
   11 |   sort(L.begin(),L.end());
      |          ^~~~~
a.cc:11:20: error: request for member 'end' in 'L', which is of non-class type 'int'
   11 |   sort(L.begin(),L.end());
      |                    ^~~
a.cc:12:13: error: request for member 'begin' in 'L', which is of non-class type 'int'
   12 |   reverse(L.begin(),L.end());
      |             ^~~~~
a.cc:12:23: error: request for member 'end' in 'L', which is of non-class type 'int'
   12 |   reverse(L.begin(),L.end());
      |                       ^~~
a.cc:15:11: error: invalid types 'int[int]' for array subscript
   15 |     ans+=L[i];
      |           ^
Language: Java

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

Compiler output:
Main.java:12: error: cannot find symbol
      	Arrays.sort(sticks[i]);
      	                   ^
  symbol:   variable i
  location: class Main
Main.java:12: error: no suitable method found for sort(int)
      	Arrays.sort(sticks[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<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;

int main(){
  int N,K;
  cin >>N>>K;
  
  vector<int> l(N);
  rep(i,0,N) cin >>l.at(i);
  
  l.sort(l.begin(),l.end(),greater<int>());
  
  int ans = 0;
  rep(i,0,K) ans += l.at(i);
  
  cout <<ans<< endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'class std::vector<int>' has no member named 'sort'
   12 |   l.sort(l.begin(),l.end(),greater<int>());
      |     ^~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<algorithm>

using namespace std;

#define ll long long

int main(void){
	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,0) << endl;
	return 0;
}

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

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>

using namespace std;

#define ll long long

int main(void){
	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,0) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   15 |         sort(l.rbegin(),l.rend());
      |         ^~~~
      |         sqrt
a.cc:16:17: error: 'accumulate' was not declared in this scope
   16 |         cout << accumulate(l.begin(),l.begin()+k,0) << endl;
      |                 ^~~~~~~~~~
Language: C++

#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n, k;
	cin >> n >> k;
	vi l(n);
	rep(i, n) cin >> l[i];
	vsort(l);
	rv(l);
	int sum = 0;
	rep(i, k) sum += a[i];
	cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:26: error: 'a' was not declared in this scope
   25 |         rep(i, k) sum += a[i];
      |                          ^
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);
      for(int i = n-1;i>=n-k;i--) sum += l[i];
      System.out.println(sum);
    }
}

Compiler output:
Main.java:10: error: cannot find symbol
      arrays.sort(l);
      ^
  symbol:   variable arrays
  location: class Main
1 error
Language: C++

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

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



Compiler output:
a.cc: In function 'int main()':
a.cc:16:11: error: 'class std::vector<int>' has no member named 'sort'
   16 |         v.sort(v.begin(), v.end());
      |           ^~~~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: 'i' was not declared in this scope
   12 |         rei(i, K) sum += l[i];
      |             ^
a.cc:12:9: error: 'rei' was not declared in this scope; did you mean 'rep'?
   12 |         rei(i, K) sum += l[i];
      |         ^~~
      |         rep
Language: C++

#include <iostream>
using namespace std;

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

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

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


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


Compiler output:
a.cc: In function 'int main()':
a.cc:17:8: error: 'v' was not declared in this scope
   17 |   sort(v.begin(), V.end());
      |        ^
Language: C++

#include <isotream>
#include <vector>
#include <algorithm>


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

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

#include<iostream>
#include<algorithm>
#include<map>
map<int,int> a;
using namespace std;
int main()
{
    int n,k;
    int sum=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=k;i++) sum+=a[i];
    cout<<sum<<'\n';
    return 0;
}

Compiler output:
a.cc:4:1: error: 'map' does not name a type
    4 | map<int,int> a;
      | ^~~
a.cc: In function 'int main()':
a.cc:11:32: error: 'a' was not declared in this scope
   11 |     for(int i=1;i<=n;i++) cin>>a[i];
      |                                ^
a.cc:12:10: error: 'a' was not declared in this scope
   12 |     sort(a+1,a+1+n);
      |          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: no match for call to '(std::vector<int>) (int&)'
   17 |   rep(i,n)cin>>l(i);
      |                ~^~~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:21: error: 'l' was not declared in this scope
    8 |     rep(i,n) cin >> l[i];
      |                     ^
a.cc:9:12: error: request for member 'begin' in 's', which is of non-class type 'int [n]'
    9 |     sort(s.begin(),s.end());
      |            ^~~~~
a.cc:9:22: error: request for member 'end' in 's', which is of non-class type 'int [n]'
    9 |     sort(s.begin(),s.end());
      |                      ^~~
a.cc:10:15: error: request for member 'begin' in 's', which is of non-class type 'int [n]'
   10 |     reverse(s.begin(),s.end());
      |               ^~~~~
a.cc:10:25: error: request for member 'end' in 's', which is of non-class type 'int [n]'
   10 |     reverse(s.begin(),s.end());
      |                         ^~~
a.cc:11:20: error: 'l' was not declared in this scope
   11 |     rep (i,k) ans+=l[i];
      |                    ^
Language: C++

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

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

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: no match for call to '(std::vector<int>) (int&)'
   13 |     sum += a(i);
      |            ~^~~
Language: C++

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

int main() {
  int n,k,ans = 0
  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());
  for(int i = 0; i < k; i++){
    ans += l.at(i);
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: expected ',' or ';' before 'cin'
    6 |   cin >> n >> k;
      |   ^~~
Language: C++

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

int main(){
    int n,k,s=0;
    cin>>n>>k;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(l.begin(),l.end(),greater<int>());
    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:8:31: error: 'v' was not declared in this scope
    8 |     for(int i=0;i<n;i++) cin>>v[i];
      |                               ^
a.cc:10:29: error: 'v' was not declared in this scope
   10 |     for(int i=0;i<k;i++) s+=v[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];
  reverse(sort(a.begin(),a.end()));
  int sum=0;
  for(int i=0;i<k;i++){
    sum += a[i];
  }
  cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: invalid use of void expression
    8 |   reverse(sort(a.begin(),a.end()));
      |           ~~~~^~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>


int main() {
  unsigned int N, K;
  std::cin >> N >> K;
  std::vector<unsigned int> l(N);
  for (unsigned int i = 0; i < N; ++i) std::cin >> l[i];

  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  unsigned int res = 0;
  for (unsigned int i = 0; i < K; ++i) res += l[i];

  std::cout << res << "\n";
  return 0;
}


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.begin(), l.end());
      |   ^~~~
      |   short
a.cc:13:3: error: 'reverse' was not declared in this scope
   13 |   reverse(l.begin(), l.end());
      |   ^~~~~~~
Language: C++

#include <iostream>
#include <vector>
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(), greater<int>());

    int len = 0;
    for (int i = 0; i < k; i++) {
        len += l[i];
    }
    cout << len << 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(l.begin(), l.end(), greater<int>());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <cmath>
using namespace std;
int l[110];

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   for(i=0; i<N; ++i) cin >> l[i];
      |       ^
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   11 |   sort(l, l + N, greater<int>());
      |   ^~~~
      |   sqrt
a.cc:13:7: error: 'i' was not declared in this scope
   13 |   for(i=0; i<K; ++i){
      |       ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  int k;
  cin >> n >> k;
  int a[n];
  for(int i=0;i<n;i++)
  {
    int x;
    cin >>x;
    a[i]=x;
  }
  sort(a,a+n,greater<int>()); //大きい順にソート
  							　//何もなしだと小さい順
  int total=0;
  for(int i=0;i<k;i++)
  {
    total+=a[i];
  }
  cout << total << endl;
  return 0;
}
  

Compiler output:
a.cc:17:57: error: extended character 　 is not valid in an identifier
   17 |                                                         　//何もなしだと小さい順
      |                                                         ^
a.cc: In function 'int main()':
a.cc:17:57: error: '\U00003000' was not declared in this scope
   17 |                                                         　//何もなしだと小さい順
      |                                                         ^~
a.cc:21:5: error: 'total' was not declared in this scope
   21 |     total+=a[i];
      |     ^~~~~
a.cc:23:11: error: 'total' was not declared in this scope
   23 |   cout << total << 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());
  
  int sum=0;
  
  for(int i=i.size()-1;i>l.size()-K;i++){
    sum+=l.at(i);
  }
  
  cout<<sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:15: error: request for member 'size' in 'i', which is of non-class type 'int'
   15 |   for(int i=i.size()-1;i>l.size()-K;i++){
      |               ^~~~
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());
  
  int sum=0:
  
  for(int i=i.size()-1;i>l.size()-k;i++){
    sum+=l.at(i);
  }
  
  cout<<sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: expected ',' or ';' before ':' token
   13 |   int sum=0:
      |            ^
a.cc:15:24: error: 'i' was not declared in this scope
   15 |   for(int i=i.size()-1;i>l.size()-k;i++){
      |                        ^
a.cc:15:35: error: 'k' was not declared in this scope
   15 |   for(int i=i.size()-1;i>l.size()-k;i++){
      |                                   ^
Language: C++

#incluide<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());
  
  int sum=0:
  
  for(int i=i.size()-1;i>l.size()-k;i++){
    sum+=l.at(i);
  }
  
  cout<<sum<<endl;
}


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #incluide; did you mean #include?
    1 | #incluide<bits/stdc++.h>
      |  ^~~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
    5 |   cin>>N>>K;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #incluide<bits/stdc++.h>
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int>l(N);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #incluide<bits/stdc++.h>
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int>l(N);
      |          ^~~
a.cc:8:10: error: 'l' was not declared in this scope
    8 |     cin>>l.at(i);
      |          ^
a.cc:11:8: error: 'l' was not declared in this scope
   11 |   sort(l.begin(),l.end());
      |        ^
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |   sort(l.begin(),l.end());
      |   ^~~~
      |   short
a.cc:13:12: error: expected ',' or ';' before ':' token
   13 |   int sum=0:
      |            ^
a.cc:15:24: error: 'i' was not declared in this scope
   15 |   for(int i=i.size()-1;i>l.size()-k;i++){
      |                        ^
a.cc:15:35: error: 'k' was not declared in this scope
   15 |   for(int i=i.size()-1;i>l.size()-k;i++){
      |                                   ^
a.cc:19:3: error: 'cout' was not declared in this scope
   19 |   cout<<sum<<endl;
      |   ^~~~
a.cc:19:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:14: error: 'endl' was not declared in this scope
   19 |   cout<<sum<<endl;
      |              ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #incluide<bits/stdc++.h>
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:14:33: error: expected ';' before '}' token
   14 |   for (int i;i<K;++i){ans +=v[i] }
      |                                 ^~
      |                                 ;
Language: C++

#include <iostream>
  2 #include <vector>
  3 #include <algorithm>
  4 
  5 using namespace std;
  6 
  7 int main() {
  8     int N, K;
  9     cin >> N >> K;
 10     vector<int> l(N);
 11     for(int i = 0; i < N; i++)
 12         cin >> l[i];
 13 
 14     sort(l.begin(), l.end(), greater<int>());
 15 
 16     int sum = 0;
 17 
 18     for(int i = 0; i < K; i++)
 19         sum += l[i];
 20 
 21     cout << sum << endl;
 22 }

Compiler output:
a.cc:2:5: error: stray '#' in program
    2 |   2 #include <vector>
      |     ^
a.cc:3:5: error: stray '#' in program
    3 |   3 #include <algorithm>
      |     ^
a.cc:2:3: error: expected unqualified-id before numeric constant
    2 |   2 #include <vector>
      |   ^
a.cc:6:3: error: expected unqualified-id before numeric constant
    6 |   6
      |   ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: expected ',' or ';' before 'int'
    8 |   int ans=0;
      |   ^~~
a.cc:15:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |     ans += a.at(i);
      |     ^~~
      |     abs
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:26: error: expected primary-expression before ')' token
   11 |   sort(A,A+N,greater<int>);
      |                          ^
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,greater<int>());
  int sum = 0;
  for(int j=0;j>K;j++){
    sum += A[i];
  }
  cout << sum << endl;
}  
  
  
    

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

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

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

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 >> A[i];
      |       ^
a.cc:11:7: error: 'j' was not declared in this scope
   11 |   for(j=0;j>K;j++){
      |       ^
a.cc:12:14: error: 'i' was not declared in this scope
   12 |     sum += A[i];
      |              ^
Language: C++

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

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

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 >> A[i];
      |       ^
a.cc:11:7: error: 'i' was not declared in this scope
   11 |   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> l(N)
  for(int i=0;i<N;i++){
    cin >> l[i];
  }
  sort(l.end(),l.begin());
  int a=0;
  for(int i=0;i<K;i++){
    a+=l[i];
  }
  cout << a << endl;
}

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

#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,K;
	cin>>N>>K;
	vector<int> l(N);
	FDS(i,N){
		cin>>l[i];
	}
	VSORT(l);
	VREV(l);
	ans=0;
	FDS(i,K){
		ans+=l[i];
	}
	
	cout<<ans<<endl;
}

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

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

Compiler output:
Main.java:11: error: no suitable method found for sort(no arguments)
        Arrays.sort();
              ^
    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
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

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(), greater<int>);
  
  int ans = 0;
  for (int i = 0; i < K; i++) ans += l.at(i);
  
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:40: error: expected primary-expression before ')' token
   21 |   sort(l.begin(), l.end(), greater<int>);
      |                                        ^