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

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int i,n,k,a,[55],ans=0
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a;a+n,greater<int>());
  for(i=0;i<k;i++){
    ans=ans+a{i};
  }
  cout << ans << endl;
  return 0;
  {

Compiler output:
a.cc: In function 'int main()':
a.cc:5:15: error: expected unqualified-id before '[' token
    5 |   int i,n,k,a,[55],ans=0
      |               ^
a.cc:8:13: error: invalid types 'int[int]' for array subscript
    8 |     cin >> a[i];
      |             ^
a.cc:10:9: error: expected ')' before ';' token
   10 |   sort(a;a+n,greater<int>());
      |       ~ ^
      |         )
a.cc:10:28: error: expected ';' before ')' token
   10 |   sort(a;a+n,greater<int>());
      |                            ^
      |                            ;
a.cc:12:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |     ans=ans+a{i};
      |     ^~~
      |     abs
a.cc:14:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |   cout << ans << endl;
      |           ^~~
      |           abs
a.cc:16:4: error: expected '}' at end of input
   16 |   {
      |   ~^
a.cc:16:4: error: expected '}' at end of input
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<algorithm
using namespace std;
int main(){
int i,n,k,a[55],ans=0;
  cin >> n >> k;
  for(i=0,i=n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  for(i=0,i<k;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
return 0;
}

Compiler output:
a.cc:2:19: error: missing terminating > character
    2 | #include<algorithm
      |                   ^
a.cc: In function 'int main()':
a.cc:7:18: error: expected ';' before ')' token
    7 |   for(i=0,i=n;i++){
      |                  ^
      |                  ;
a.cc:11:18: error: expected ';' before ')' token
   11 |   for(i=0,i<k;i++){
      |                  ^
      |                  ;
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: invalid types 'int[int]' for array subscript
   10 |   ans=ans+a[i];
      |            ^
a.cc:13:13: error: expected '}' at end of input
   13 |    return 0;
      |             ^
a.cc:4:12: note: to match this '{'
    4 |  int main(){
      |            ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n,k,a[55],ans=0;
  cin >> n >> k;
  for(i=0,i=n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  for(i=0,i<k;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:7: error: 'i' was not declared in this scope
    7 |   for(i=0,i=n;i++){
      |       ^
a.cc:7:18: error: expected ';' before ')' token
    7 |   for(i=0,i=n;i++){
      |                  ^
      |                  ;
a.cc:11:7: error: 'i' was not declared in this scope
   11 |   for(i=0,i<k;i++){
      |       ^
a.cc:11:18: error: expected ';' before ')' token
   11 |   for(i=0,i<k;i++){
      |                  ^
      |                  ;
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int i,n,k,a,[55];
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a;a+n,greater<int>());
  for(i=0;i<k;i++){
    ans=ans+a{i};
  }
  cout << ans << endl;
  return 0;
  {

Compiler output:
a.cc: In function 'int main()':
a.cc:5:15: error: expected unqualified-id before '[' token
    5 |   int i,n,k,a,[55];
      |               ^
a.cc:8:13: error: invalid types 'int[int]' for array subscript
    8 |     cin >> a[i];
      |             ^
a.cc:10:9: error: expected ')' before ';' token
   10 |   sort(a;a+n,greater<int>());
      |       ~ ^
      |         )
a.cc:10:28: error: expected ';' before ')' token
   10 |   sort(a;a+n,greater<int>());
      |                            ^
      |                            ;
a.cc:12:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |     ans=ans+a{i};
      |     ^~~
      |     abs
a.cc:14:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |   cout << ans << endl;
      |           ^~~
      |           abs
a.cc:16:4: error: expected '}' at end of input
   16 |   {
      |   ~^
a.cc:16:4: error: expected '}' at end of input
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k,a,i[55];
  cin >> n >> k:
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>);
  for(i=0;i<k;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:16: error: expected ';' before ':' token
    6 |   cin >> n >> k:
      |                ^
      |                ;
a.cc:7:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    7 |   for(i=0;i<n;i++){
      |           ~^~
a.cc:7:15: error: lvalue required as increment operand
    7 |   for(i=0;i<n;i++){
      |               ^
a.cc:10:26: error: expected primary-expression before ')' token
   10 |   sort(a,a+n,greater<int>);
      |                          ^
a.cc:11:8: error: incompatible types in assignment of 'int' to 'int [55]'
   11 |   for(i=0;i<k;i++){
      |       ~^~
a.cc:11:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   11 |   for(i=0;i<k;i++){
      |           ~^~
a.cc:11:15: error: lvalue required as increment operand
   11 |   for(i=0;i<k;i++){
      |               ^
a.cc:12:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |     ans=ans+a[i];
      |     ^~~
      |     abs
a.cc:14:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include<iostream>
#include<algorithm>
using namespace std,
int main(){
  int i,n,k,a,[55];
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a;a+n,greater<int>());
  for(i=0;i<k;i++){
    ans=ans+a{i};
  }
  cout << ans << endl;
  return 0;
  {

Compiler output:
a.cc:3:20: error: expected ';' before ',' token
    3 | using namespace std,
      |                    ^
      |                    ;
a.cc:3:20: error: expected unqualified-id before ',' token
a.cc:4:1: error: expected unqualified-id before 'int'
    4 | int main(){
      | ^~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   10 |   ans=ans+a[i];
      |   ^~~
      |   abs
a.cc:10:11: error: 'a' was not declared in this scope
   10 |   ans=ans+a[i];
      |           ^
a.cc:12:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |    cout<<ans<<endl;
      |          ^~~
      |          abs
a.cc:13:13: error: expected '}' at end of input
   13 |    return 0;
      |             ^
a.cc:4:12: note: to match this '{'
    4 |  int main(){
      |            ^
Language: C++

#include<iostream>
using namespace std;
int main(){
  int n,k,a,i[55];
  cin >> n >> k:
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>);
  for(i=0;i<k;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:16: error: expected ';' before ':' token
    5 |   cin >> n >> k:
      |                ^
      |                ;
a.cc:6:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    6 |   for(i=0;i<n;i++){
      |           ~^~
a.cc:6:15: error: lvalue required as increment operand
    6 |   for(i=0;i<n;i++){
      |               ^
a.cc:9:26: error: expected primary-expression before ')' token
    9 |   sort(a,a+n,greater<int>);
      |                          ^
a.cc:9:3: error: 'sort' was not declared in this scope; did you mean 'short'?
    9 |   sort(a,a+n,greater<int>);
      |   ^~~~
      |   short
a.cc:10:8: error: incompatible types in assignment of 'int' to 'int [55]'
   10 |   for(i=0;i<k;i++){
      |       ~^~
a.cc:10:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   10 |   for(i=0;i<k;i++){
      |           ~^~
a.cc:10:15: error: lvalue required as increment operand
   10 |   for(i=0;i<k;i++){
      |               ^
a.cc:11:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   11 |     ans=ans+a[i];
      |     ^~~
      |     abs
a.cc:13:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include<iostream>
#include<algorithm>
using namespace std,
int main(){
  int i,n,a,[55];
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a;a+n,greater<int>());
  for(i=0;i<k;i++){
    ans=ans+a{i};
  }
  cout << ans << endl;
  return 0;
  {

Compiler output:
a.cc:3:20: error: expected ';' before ',' token
    3 | using namespace std,
      |                    ^
      |                    ;
a.cc:3:20: error: expected unqualified-id before ',' token
a.cc:4:1: error: expected unqualified-id before 'int'
    4 | int main(){
      | ^~~
Language: C++

#include<iostream>
#include<algorithm
using namespace std;
int main(){
int n,k,a[55],ans=0;
  cin >> n >> k;
  for(i=0,i=n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  for(i=0,i<k;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
return 0;
}

Compiler output:
a.cc:2:19: error: missing terminating > character
    2 | #include<algorithm
      |                   ^
a.cc: In function 'int main()':
a.cc:7:7: error: 'i' was not declared in this scope
    7 |   for(i=0,i=n;i++){
      |       ^
a.cc:7:18: error: expected ';' before ')' token
    7 |   for(i=0,i=n;i++){
      |                  ^
      |                  ;
a.cc:11:7: error: 'i' was not declared in this scope
   11 |   for(i=0,i<k;i++){
      |       ^
a.cc:11:18: error: expected ';' before ')' token
   11 |   for(i=0,i<k;i++){
      |                  ^
      |                  ;
Language: C++

#include <iostream>
#include<algorithm>
using namespace std;
int main(){
	  int n,k,a[55];
	  cin >>n >>k;
      for(i=0,i<n,i++){
      		cin >>a[i];
      		}
  	  sort(a,a+n,grater<int>());
  	for(i=0,i<k,i++){
    ans=ans+a[i];
    }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:11: error: 'i' was not declared in this scope
    7 |       for(i=0,i<n,i++){
      |           ^
a.cc:10:22: error: 'grater' was not declared in this scope
   10 |           sort(a,a+n,grater<int>());
      |                      ^~~~~~
a.cc:10:29: error: expected primary-expression before 'int'
   10 |           sort(a,a+n,grater<int>());
      |                             ^~~
a.cc:11:9: error: expected primary-expression before 'for'
   11 |         for(i=0,i<k,i++){
      |         ^~~
a.cc:10:37: error: expected ')' before 'for'
   10 |           sort(a,a+n,grater<int>());
      |                                     ^
      |                                     )
   11 |         for(i=0,i<k,i++){
      |         ~~~                          
a.cc:7:10: note: to match this '('
    7 |       for(i=0,i<n,i++){
      |          ^
a.cc:14:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |   cout << ans << endl;
      |           ^~~
      |           abs
a.cc:15:1: error: expected primary-expression before '}' token
   15 | }
      | ^
a.cc:14:23: error: expected ')' before '}' token
   14 |   cout << ans << endl;
      |                       ^
      |                       )
   15 | }
      | ~                      
a.cc:11:12: note: to match this '('
   11 |         for(i=0,i<k,i++){
      |            ^
a.cc:15:1: error: expected primary-expression before '}' token
   15 | }
      | ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n,k,a[55],i,ans=0;
  cin >> n >> k;
  for(i=0;i<n;i++){
  cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  for(i=0;i<k;i++){
  ans=ans+a[i]
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: expected ';' before '}' token
   12 |   ans=ans+a[i]
      |               ^
      |               ;
   13 |   }
      |   ~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k,a[55],ans;
  cin >> n >>k;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  for(i=0;i<k;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
  return 0;
}

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

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k,a,i[55],ans;
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,freater<int>());
  for(i=0;i<k;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: incompatible types in assignment of 'int' to 'int [55]'
    7 |   for(i=0;i<n;i++){
      |       ~^~
a.cc:7:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    7 |   for(i=0;i<n;i++){
      |           ~^~
a.cc:7:15: error: lvalue required as increment operand
    7 |   for(i=0;i<n;i++){
      |               ^
a.cc:10:14: error: 'freater' was not declared in this scope
   10 |   sort(a,a+n,freater<int>());
      |              ^~~~~~~
a.cc:10:22: error: expected primary-expression before 'int'
   10 |   sort(a,a+n,freater<int>());
      |                      ^~~
a.cc:11:8: error: incompatible types in assignment of 'int' to 'int [55]'
   11 |   for(i=0;i<k;i++){
      |       ~^~
a.cc:11:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   11 |   for(i=0;i<k;i++){
      |           ~^~
a.cc:11:15: error: lvalue required as increment operand
   11 |   for(i=0;i<k;i++){
      |               ^
Language: C++

#include<iostream>
using namespace std;
int main(){
  int n,k,a,i[55],ans;
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,freater<int>());
  for(i=0;i<k;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:8: error: incompatible types in assignment of 'int' to 'int [55]'
    6 |   for(i=0;i<n;i++){
      |       ~^~
a.cc:6:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    6 |   for(i=0;i<n;i++){
      |           ~^~
a.cc:6:15: error: lvalue required as increment operand
    6 |   for(i=0;i<n;i++){
      |               ^
a.cc:9:14: error: 'freater' was not declared in this scope
    9 |   sort(a,a+n,freater<int>());
      |              ^~~~~~~
a.cc:9:22: error: expected primary-expression before 'int'
    9 |   sort(a,a+n,freater<int>());
      |                      ^~~
a.cc:9:3: error: 'sort' was not declared in this scope; did you mean 'short'?
    9 |   sort(a,a+n,freater<int>());
      |   ^~~~
      |   short
a.cc:10:8: error: incompatible types in assignment of 'int' to 'int [55]'
   10 |   for(i=0;i<k;i++){
      |       ~^~
a.cc:10:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   10 |   for(i=0;i<k;i++){
      |           ~^~
a.cc:10:15: error: lvalue required as increment operand
   10 |   for(i=0;i<k;i++){
      |               ^
Language: C++

#include <iostream>
using namespace std,
int main(){
  int << N,K,1[60]

Compiler output:
a.cc:2:20: error: expected ';' before ',' token
    2 | using namespace std,
      |                    ^
      |                    ;
a.cc:2:20: error: expected unqualified-id before ',' token
a.cc:3:1: error: expected unqualified-id before 'int'
    3 | int main(){
      | ^~~
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, l+n, greater<int>());
  	int sum = 0;
  	for(int i = 0; i < k; i++)
      	s += l[i];
  	cout<<sum;
	return 0;
}

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

#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int l[60];
  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;
  return 0;
}

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

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

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

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

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

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

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

#include<bits/stdc++.h>
#define f(i,s,n)for(register int i=s;i<=n;++i)
#define f2(i,s,n)for(register int i=n;i>=s;--i)
#define N 60
using namespace std;
int a[N];
int main(){
	ios::sync_with_stdio(false);
	long long n,sum=0;
	cin>>n;
	f(i,1,n){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	f(i,1,k){
		sum+=a[i];
	}
	cout<<sum<<"\n";
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 |         f(i,1,n){
      |           ^
a.cc:2:34: note: in definition of macro 'f'
    2 | #define f(i,s,n)for(register int i=s;i<=n;++i)
      |                                  ^
a.cc:15:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |         f(i,1,k){
      |           ^
a.cc:2:34: note: in definition of macro 'f'
    2 | #define f(i,s,n)for(register int i=s;i<=n;++i)
      |                                  ^
a.cc:15:15: error: 'k' was not declared in this scope
   15 |         f(i,1,k){
      |               ^
a.cc:2:41: note: in definition of macro 'f'
    2 | #define f(i,s,n)for(register int i=s;i<=n;++i)
      |                                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007


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:10:11: error: 'k' was not declared in this scope
   10 |     int n;k;
      |           ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
bool cmp(int a,int b){
	return a<b;
}
int main()
{
	int a[10001];
	int n,m;
	int ans=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=m;i++)ans=a[i]+ans;
	cout<<ans;
	return 0; 
} 

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

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

  }
}



Compiler output:
Main.java:14: error: no suitable method found for sort(int[],Comparator<Object>)
      Arrays.sort(l, Collections.reverseOrder());
            ^
    method Arrays.<T#1>sort(T#1[],Comparator<? super T#1>) is not applicable
      (inference variable T#1 has incompatible bounds
        equality constraints: int
        upper bounds: Object)
    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 <iostream>
#include <algorithm>
#include <string> 
#include <math.h>
#include <vector>
#define rep(i,n) for(int i=0; i< int(n); i++)
using namespace std;


int main(){
	int n,k;
	int a[60];
	cin >> n >> k ;
	rep(i,n) cin >> a[i];
	sort(a, a+n, greater<int>());
	int ans = 0;
	rep(i,k) res += a[i];
	cout << ans << endl;

} 



Compiler output:
a.cc: In function 'int main()':
a.cc:17:18: error: 'res' was not declared in this scope; did you mean 'rep'?
   17 |         rep(i,k) res += a[i];
      |                  ^~~
      |                  rep
Language: C++

#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair

int main(){
      int n,k;cin >> n >> k;
      vector<int> arr[n + 5];
      int ans = 0;
      for(int i = 0;i < n;i++){
            int t;cin >> t;
            arr.push_back(t);
      }
      sort(arr.rbegin(), arr.rend());
      for(int i = 0;i < k;i++){
            ans += arr[i];
      }
      cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: request for member 'push_back' in 'arr', which is of non-class type 'std::vector<int> [(n + 5)]'
   12 |             arr.push_back(t);
      |                 ^~~~~~~~~
a.cc:14:16: error: request for member 'rbegin' in 'arr', which is of non-class type 'std::vector<int> [(n + 5)]'
   14 |       sort(arr.rbegin(), arr.rend());
      |                ^~~~~~
a.cc:14:30: error: request for member 'rend' in 'arr', which is of non-class type 'std::vector<int> [(n + 5)]'
   14 |       sort(arr.rbegin(), arr.rend());
      |                              ^~~~
a.cc:16:17: error: no match for 'operator+=' (operand types are 'int' and 'std::vector<int>')
   16 |             ans += arr[i];
      |             ~~~~^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k,a[10001];
int main(){
    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:11:27: error: 'sum' was not declared in this scope
   11 |     for(int i=1;i<=k;i++) sum+=a[i];
      |                           ^~~
a.cc:12:11: error: 'sum' was not declared in this scope
   12 |     cout<<sum<<endl;
      |           ^~~
Language: C++


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
int main(void){
int n,k;
  cin >> n >>k;
  int snake[60];
  for(int i=0i<n;++i){
     cin >> snake[i];
  }
  int ans=0;
  std::sort(snake,snake+n);
  for(int i=0;i<k;i++){
     ans += snake[i];
  }
  cout << ans;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:15: error: invalid operands of types '__complex__ int' and 'int' to binary 'operator<'
   13 |   for(int i=0i<n;++i){
a.cc:13:21: error: expected ';' before ')' token
   13 |   for(int i=0i<n;++i){
      |                     ^
      |                     ;
Language: C++

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


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin2(n,k);
    intv l(n);
    input(n,l);

    sort(l.begin(),l.end(),[](const int &a,const int &b){return a>b;});
    int ans = 0;
    rap(k,i){
        ans += l[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

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


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin2(n,k);
    intv l(n);
    input(n,l);

    sort(all(l));
    reverse(all(l));
    int ans = 0;
    rap(k,i){
        ans += l[i];
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:87:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   87 |     sort(all(l));
      |     ^~~~
      |     sqrt
a.cc:88:5: error: 'reverse' was not declared in this scope
   88 |     reverse(all(l));
      |     ^~~~~~~
Language: C++

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


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin2(n,k);
    intv l(n);
    input(n,l);

    sort(all(l),[](const int &a,const int &b){return a>b;});
    int ans = 0;
    rap(k,i){
        ans += l[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

#include <iostream>

using namespace std;

int main(void)
{
    int N, K, i, l[51], ans=0;

    cin >> N >> K;

    for(i=1; i<=N; i++){
        cin >> l[i];
    }

    sort(l+1, l+N+1);

    for(i=N-K+1; i<=N; i++){
        ans += l[i];
    }

    cout << ans << endl;

    return 0;
}

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

#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  REP(i, N) cin >> l.at(i);
  sort(all(l));
  reverse(all(l));
  int sum = 0;
  REP(i, K) sum += l.at(i);
  cout << sum << endl;
  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(all(l));
      |   ^~~~
      |   short
a.cc:13:3: error: 'reverse' was not declared in this scope
   13 |   reverse(all(l));
      |   ^~~~~~~
Language: C++

#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int my_abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

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


Compiler output:
a.cc: In function 'int main()':
a.cc:19:21: error: 'n' was not declared in this scope
   19 |     for(int i = 0;i<n;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.begin(),l.end(),greater);
    int sum=0;
    for (int i = 0; i < K; i++)
    {
        sum+=l.at(i);
    }
    cout<<sum;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:35: error: missing template arguments before ')' token
   11 |     sort(l.begin(),l.end(),greater);
      |                                   ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a,b;
    
    cin>>a>>b;
    int c[10000000];
    for(int i=0;i<a;i++){
        cin>>c[i];
    }
    sort(a+1,a+n+1);
    for(int i=a-1;i>=b;i--){
        int ans=0;
        ans+=c[i];
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: 'n' was not declared in this scope
   12 |     sort(a+1,a+n+1);
      |                ^
Language: C++

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

int ordem(const void*a, const void*b){
    return strcmp(a,b);
}


int main(){
    int n,k, total = 0,x;
    scanf("%d %d", &n, &k);
    int t[n];
    for(int i=0; i<n; i++){
        scanf("%d", &t[i]);
    }
    qsort(t, n, sizeof(t[0]), ordem);
    x = n - k;
    k += 1;
    for (int i = x ; i <= k ; i++){
        total += t[i];
    }
    printf("%d\n", total);

    return 0;
}

Compiler output:
a.cc: In function 'int ordem(const void*, const void*)':
a.cc:6:19: error: invalid conversion from 'const void*' to 'const char*' [-fpermissive]
    6 |     return strcmp(a,b);
      |                   ^
      |                   |
      |                   const void*
In file included from a.cc:2:
/usr/include/string.h:156:32: note:   initializing argument 1 of 'int strcmp(const char*, const char*)'
  156 | extern int strcmp (const char *__s1, const char *__s2)
      |                    ~~~~~~~~~~~~^~~~
a.cc:6:21: error: invalid conversion from 'const void*' to 'const char*' [-fpermissive]
    6 |     return strcmp(a,b);
      |                     ^
      |                     |
      |                     const void*
/usr/include/string.h:156:50: note:   initializing argument 2 of 'int strcmp(const char*, const char*)'
  156 | extern int strcmp (const char *__s1, const char *__s2)
      |                                      ~~~~~~~~~~~~^~~~
Language: C++

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

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:15: error: 'n5' was not declared in this scope; did you mean 'n'?
    9 |     for(int i=n5;i>=n-k+1;i--)
      |               ^~
      |               n
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[] data = new int[n];
      int sum = 0;

      for(int i = 0;i<n;i++){
        data[i] = sc.nextInt();
      }
      Arrays.sort(data);

      for(int i = n-1;i>n-1-k;i--){
        sum = sum + data[i];
      }

      System.out.println(sum);

  }
}


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

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];
        for(int i=0;i<n;i++){
            l[i]=sc.nextInt();
        }
        Arrays.sort(l);
        int total=0;
        for(int i=n-1;i>n-1-k;i--){
            total+=l[i];
        }
        System.out.println(total);
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main{
      | ^~~~~~
Language: C++

#include <iostream>
using namespace std;
long long a,b[55],c;
int main()
{
    cin>>a;
    for(int i=0;i<a;i++)
        cin>>b[i];
    sort(b,b+a);
    for(int i=a-c;i<a;i++)
        c+=b[i];
    cout<<c<<endl;
    return 0;
}

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: expected initializer before 'for'
    8 |   for(i=0;i<n;i++){
      |   ^~~
a.cc:8:18: error: expected ';' before ')' token
    8 |   for(i=0;i<n;i++){
      |                  ^
      |                  ;
a.cc:11:8: error: 'L' was not declared in this scope
   11 |   sort(L,L+n,greater<int>());
      |        ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: 'a' was not declared in this scope
    9 |         cin>>a[i];
      |              ^
a.cc:10:14: error: 'a' was not declared in this scope
   10 |         sort(a+1,a+1+m);
      |              ^
Language: C++

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

int n,k,ans;

int a[10001];

int main(){
    cin>>n>>k;
    for(re int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1);
    for(re int i=n;i>=n-k;i--)
    ans+=a[i];
    printf("%d\n",ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 're' was not declared in this scope
   10 |     for(re int i=1;i<=n;i++)
      |         ^~
a.cc:10:20: error: 'i' was not declared in this scope
   10 |     for(re int i=1;i<=n;i++)
      |                    ^
a.cc:13:9: error: 're' was not declared in this scope
   13 |     for(re int i=n;i>=n-k;i--)
      |         ^~
a.cc:13:20: error: 'i' was not declared in this scope
   13 |     for(re int i=n;i>=n-k;i--)
      |                    ^
Language: C++

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

int n,k,ans;

int a[10001];

int main(){
    cin>>n>>k;
    for(re int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1);
    for(re int i=n;i>=n-k;i--)
    ans+=a[i];
    printf("%d",ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 're' was not declared in this scope
   10 |     for(re int i=1;i<=n;i++)
      |         ^~
a.cc:10:20: error: 'i' was not declared in this scope
   10 |     for(re int i=1;i<=n;i++)
      |                    ^
a.cc:13:9: error: 're' was not declared in this scope
   13 |     for(re int i=n;i>=n-k;i--)
      |         ^~
a.cc:13:20: error: 'i' was not declared in this scope
   13 |     for(re int i=n;i>=n-k;i--)
      |                    ^
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> vecn(n);
  //vector<int> veck(k);
  rep(i,n)cin >> vecn.at(i);
  sort(vecn.begin(),vecn.end());
  reverse(vecn.begin(),vecn.end());
  ans = 0;
  rep(i,k)ans += vecn.at(i);
  cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |   ans = 0;
      |   ^~~
      |   abs
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> vecn(n);
  //vector<int> veck(k);
  rep(i,n)cin >> vecn.at(i);
  sort(vecn.begin(),vecn.end());
  reverse(vecn.begin(),vecn.end());
  ans = 0;
  rep(i,k)ans += vecn(i);
  cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |   ans = 0;
      |   ^~~
      |   abs
a.cc:14:22: error: no match for call to '(std::vector<int>) (int&)'
   14 |   rep(i,k)ans += vecn(i);
      |                  ~~~~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int i,j;
    int N,K;
    int sum=0;
    cin>>N>>K;
    vector<int> num(N);
    for(i=0;i<N;i++){
        cin>>num.at(i)
    }  
    sort(num.rbegin(),num.rend());
    for(j=0;j<K;j++){
        sum+=num.at(j);
    }
    cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:23: error: expected ';' before '}' token
   11 |         cin>>num.at(i)
      |                       ^
      |                       ;
   12 |     }
      |     ~
Language: C++

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int N, K;
vi arr;

int main() {
  io();
  cin >> N >> K;
  fori(i, N) {
    int a;
    cin >> a;
    arr.pb(a);
  }
  
  qsortd(a);
  int ret = 0;
  fori(i, K) {
    ret += arr[i];
  }
  
  cout << ret;
  
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:87:10: error: 'a' was not declared in this scope
   87 |   qsortd(a);
      |          ^
a.cc:50:16: note: in definition of macro 'all'
   50 | #define all(a) a.begin(), a.end()
      |                ^
a.cc:87:3: note: in expansion of macro 'qsortd'
   87 |   qsortd(a);
      |   ^~~~~~
Language: C++

#include<bits/stdc++.h>
#include<bitset>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

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


Compiler output:
a.cc: In function 'int main()':
a.cc:159:15: error: 'sum' was not declared in this scope
  159 |  rep(i, 0, k) sum += arr[i];
      |               ^~~
a.cc: In function 'll fxor(ll)':
a.cc:64:1: warning: control reaches end of non-void function [-Wreturn-type]
   64 | }
      | ^