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

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n, k;
    vector<int> L(n);
    rep(i, n) cin >> L[i];
    sort(L.rbegin(), L.end());
    int ans = 0;
    rep(i, k) ans += L[i];
    cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: no matching function for call to 'sort(std::vector<int>::reverse_iterator, std::vector<int>::iterator)'
   10 |     sort(L.rbegin(), L.end());
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   template argument deduction/substitution failed:
a.cc:10:9: note:   deduced conflicting types for parameter '_RAIter' ('std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
   10 |     sort(L.rbegin(), L.end());
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided
Language: C++

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

int main(){
  int N, K;
  cin>>N>>K;
  int a[100];
  
  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; K++){
    sum += a[i]
  }
  
  cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: expected ';' before '}' token
   16 |     sum += a[i]
      |                ^
      |                ;
   17 |   }
      |   ~
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 sum=0;
    for(int i=0; i<K; i++) sum+=l[i];

    cout<<sum<<endl;
}

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

#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int a,b; cin>>a>>b;
	VI l(a); rep(i,a) cin>>l[i]; sort(RALL(l));
	int ans = 0;
	rep(i.b) ans+=l[i];
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc:39:16: error: macro "rep" requires 2 arguments, but only 1 given
   39 |         rep(i.b) ans+=l[i];
      |                ^
a.cc:5:9: note: macro "rep" defined here
    5 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:39:9: error: 'rep' was not declared in this scope
   39 |         rep(i.b) ans+=l[i];
      |         ^~~
Language: C++

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

int main() {
  int n, k;
  cin >> n >> k;
  int l[k];
  rep(i, n) cin >> l[i];

  sort(l, l+n, greater<int>());
  int sum = 0;
  rep(i, k) sum += l[i];

  cout << sum << endl;

}


Compiler output:
a.cc:4:12: error: 'Long' does not name a type; did you mean 'long'?
    4 | using ll = Long Long;
      |            ^~~~
      |            long
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:29: error: 'i' was not declared in this scope
   12 |     if (N >= K) length += a[i];
      |                             ^
Language: C++

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

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


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

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

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


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

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

int main(){
  int n;
  int a[60];
  cin >> n;
  for (int i = 0; i < N; ++i) cin >> a[i];
  
  sort(a, a + N, greater<int>());
  int length = 0;
  while (n >= k){
    length += a[i];
  }
  cout << length << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:23: error: 'N' was not declared in this scope
    8 |   for (int i = 0; i < N; ++i) cin >> a[i];
      |                       ^
a.cc:10:15: error: 'N' was not declared in this scope
   10 |   sort(a, a + N, greater<int>());
      |               ^
a.cc:12:15: error: 'k' was not declared in this scope
   12 |   while (n >= k){
      |               ^
a.cc:13:17: error: 'i' was not declared in this scope
   13 |     length += a[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;
  cin >> N >> K;
  int stick[N];
  rep(i,N){
    cin >> stick[i];
  }
  sort(stick.begin(),stick.end());
  reverse(stick.begin(),stick.end());
  
  int ans=0;
  rep(i,K){
    ans += stick[i];
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: request for member 'begin' in 'stick', which is of non-class type 'int [N]'
   12 |   sort(stick.begin(),stick.end());
      |              ^~~~~
a.cc:12:28: error: request for member 'end' in 'stick', which is of non-class type 'int [N]'
   12 |   sort(stick.begin(),stick.end());
      |                            ^~~
a.cc:13:17: error: request for member 'begin' in 'stick', which is of non-class type 'int [N]'
   13 |   reverse(stick.begin(),stick.end());
      |                 ^~~~~
a.cc:13:31: error: request for member 'end' in 'stick', which is of non-class type 'int [N]'
   13 |   reverse(stick.begin(),stick.end());
      |                               ^~~
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;
  cin >> N >> K;
  int stick[N];
  rep(i,N){
    cin >> stick[i];
  }
  sort(stick.rbegin(),stick.rend());
  
  int ans=0;
  rep(i,K){
    ans += stick[i];
  }
  cout << ans << endl;
}

Compiler output:
a.cc:3:3: error: expected unqualified-id before 'for'
    3 |   for(int i=0;i<(int)(n);++i)
      |   ^~~
a.cc:3:15: error: 'i' does not name a type
    3 |   for(int i=0;i<(int)(n);++i)
      |               ^
a.cc:3:26: error: expected unqualified-id before '++' token
    3 |   for(int i=0;i<(int)(n);++i)
      |                          ^~
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |   cin >> N >> K;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:18: error: 'i' was not declared in this scope
   11 |     cin >> stick[i];
      |                  ^
a.cc:13:14: error: request for member 'rbegin' in 'stick', which is of non-class type 'int [N]'
   13 |   sort(stick.rbegin(),stick.rend());
      |              ^~~~~~
a.cc:13:29: error: request for member 'rend' in 'stick', which is of non-class type 'int [N]'
   13 |   sort(stick.rbegin(),stick.rend());
      |                             ^~~~
a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   13 |   sort(stick.rbegin(),stick.rend());
      |   ^~~~
      |   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:17:18: error: 'i' was not declared in this scope
   17 |     ans += stick[i];
      |                  ^
a.cc:19:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   19 |   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:19:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   19 |   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 <bits/stdc++.h>
using namespace std;

int ketasum(int n){
  int sum = 0;
  while (n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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 ans = 0;
  for (int i = 0; i < k; i++){
    ans += i;
  }
  cout << ans << endl;
}


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

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

int ketasum(int n){
  int sum = 0;
  while (n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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 ans = 0;
  for (int i = 0; i < k; i++){
    ans += i;
  }
  cout << ans << endl;
}


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

#include <iostream>
using namespace std;

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

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n,k;
    cin >>n >> k;
    vector<int> l(n);
    rep(i,n){
        cin >> l[i];
    }
    sort(l.rbegin(), l.rend());
    rep(i,k-1){
        l[0] += l[i + 1];
    }
    cout　<< l[0] << endl;
}

Compiler output:
a.cc:18:5: error: extended character 　 is not valid in an identifier
   18 |     cout　<< l[0] << endl;
      |     ^
a.cc: In function 'int main()':
a.cc:18:5: error: 'cout\U00003000' was not declared in this scope
   18 |     cout　<< l[0] << endl;
      |     ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K;
  int L[51];
  cin >> N >> K;
  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;
  return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, a;
  in2(n, k);
  vector<ll> c(n);
  rep(i, n)
    in(c[i]);
  sort(all(c));
  reverse(all(c));
  a = 0:
  rep(i, k)
    a = a + c[i];
  out(a);
  memi;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:8: error: expected ';' before ':' token
   25 |   a = 0:
      |        ^
      |        ;
a.cc:26:7: error: 'i' was not declared in this scope
   26 |   rep(i, k)
      |       ^
a.cc:4:33: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                 ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: 'asn' was not declared in this scope; did you mean 'ans'?
   16 |     asn += rope.at(i);
      |     ^~~
      |     ans
Language: C++

#include <iostream>
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> rope(60);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> rope(60);
      |          ^~~
a.cc:10:11: error: 'rope' was not declared in this scope
   10 |    cin >> rope.at(i);
      |           ^~~~
a.cc:12:7: error: 'rope' was not declared in this scope
   12 |  sort(rope.begin(),rope.end());
      |       ^~~~
a.cc:12:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |  sort(rope.begin(),rope.end());
      |  ^~~~
      |  short
a.cc:13:3: error: 'reverse' was not declared in this scope
   13 |   reverse(rope.begin(),rope.end());
      |   ^~~~~~~
a.cc:15:5: error: 'asn' was not declared in this scope; did you mean 'ans'?
   15 |     asn += rope.at(i);
      |     ^~~
      |     ans
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=i+1){
    cin >> l.at(i);
  }
  sort(l.begin(),l.end());
  reverse(l.begin,l.end());
  int sum = 0;
  for(int i=0;i<K;i=i+1){
    sum = sum + l.at(i);
  }
  cout << sum << endl;
}


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

#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N,K;
  int l[55];
  int 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 += l[i];
    
  }
  cout << ans <<endl;
}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:10:27: error: expected ')' before ';' token
   10 |   for(int i = 0;i < N;i ++;)cin >>l[i];
      |      ~                    ^
      |                           )
a.cc:10:28: error: expected primary-expression before ')' token
   10 |   for(int i = 0;i < N;i ++;)cin >>l[i];
      |                            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N,K;
  int l[55];
  int 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 = l[i];
    
  }
  cout << ans <<endl;
}
 

Compiler output:
a.cc: In function 'int main()':
a.cc:10:27: error: expected ')' before ';' token
   10 |   for(int i = 0;i < N;i ++;)cin >>l[i];
      |      ~                    ^
      |                           )
a.cc:10:28: error: expected primary-expression before ')' token
   10 |   for(int i = 0;i < N;i ++;)cin >>l[i];
      |                            ^
Language: Java

import java.util.*;

public class Main {
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int m = scanner.nextInt();
    int n = scanner.nextInt();
//    int[] arr = new int[m];
//    for (int i = 0; i < m; i++) {
//        arr[i] = scanner.nextInt();
//    }
//    Arrays.sort(arr);
//    reverse(arr);
//    int sum = 0;
//    for (int i = 0; i < n; i++) {
//        sum += arr[i];
//    }
    ArrayList arrayList=new ArrayList();
    for (int i = 0; i <m; i++) {
        arrayList.add(scanner.nextInt());
    }
    Collections.sort(arrayList);
    Collections.reverse(arrayList);
    int sum=0;
    for (int i = 0; i <n; i++) {
        int arr= (int) arrayList.get(i);
        sum+=arr;
    }
//    System.out.println(sum);

    System.out.println(sum);
}

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'rsort' was not declared in this scope; did you mean 'qsort'?
   10 |     rsort(x+1,x+n+1);
      |     ^~~~~
      |     qsort
Language: C++

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)

int main() {
	int n;
	int 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 a = 0;
	rep(i, k) a += l[i];

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

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long = ll;
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)

int main() {
	int n;
	int 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 a = 0;
	rep(i, k) a += l[i];

	cout << a << endl;
	return 0;
}


	


Compiler output:
a.cc:5:19: error: expected unqualified-id before '=' token
    5 | typedef long long = ll;
      |                   ^
a.cc: In function 'int main()':
a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |         sort(l.begin(), l.end());
      |         ^~~~
      |         short
a.cc:17:9: error: 'reverse' was not declared in this scope
   17 |         reverse(l.begin(), l.end());
      |         ^~~~~~~
Language: C++

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)

int main() {
	int n;
	int 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 a = 0;
	rep(i, k) a += l[i];

	cout << a << endl;
	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 'short'?
   16 |         sort(l.begin(), l.end());
      |         ^~~~
      |         short
a.cc:17:9: error: 'reverse' was not declared in this scope
   17 |         reverse(l.begin(), l.end());
      |         ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,S=0;cin>>N>>K;vector<int>l(N);
  cin(int i=0;i<N;i++)cin>>l.at(N);
  sort(l.begin(),l.end());
  for(i=N-1;i<=N-K;i++)S+=l.at(i);
  cout<<S<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:7: error: expected primary-expression before 'int'
    5 |   cin(int i=0;i<N;i++)cin>>l.at(N);
      |       ^~~
a.cc:5:15: error: 'i' was not declared in this scope
    5 |   cin(int i=0;i<N;i++)cin>>l.at(N);
      |               ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n ,k 
	cin >> n >>k 
	vector<int> l(n);
	rep(i,n) cin >> l[i];
	SORT(l);
	rSORT(l);
	ll ans = 0 ;
	rep(i,k) ans += l[i];
	cout << ans << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: expected initializer before 'cin'
   21 |         cin >> n >>k
      |         ^~~
a.cc:23:25: error: 'l' was not declared in this scope
   23 |         rep(i,n) cin >> l[i];
      |                         ^
a.cc:24:14: error: 'l' was not declared in this scope
   24 |         SORT(l);
      |              ^
a.cc:5:23: note: in definition of macro 'SORT'
    5 | #define SORT(a) sort((a).begin(),(a).end())
      |                       ^
a.cc:27:15: error: 'k' was not declared in this scope
   27 |         rep(i,k) ans += l[i];
      |               ^
a.cc:7:48: note: in definition of macro 'For'
    7 | #define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
      |                                                ^
a.cc:27:9: note: in expansion of macro 'rep'
   27 |         rep(i,k) ans += l[i];
      |         ^~~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:29: error: expected ';' before ')' token
   14 |   for (int i = 0; i < K, i++){
      |                             ^
      |                             ;
Language: C++

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

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

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

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


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

#include<iostream>
#include<algorithm>
#define rep(i,a,n) for(int i = a; i < n; i++)
int main(){
  int n, k;
  std::cin >> n >> k;
  int l[n];
  rep(i,0,n)
    std::cin >> l[i];
  std::sort(l, l + n);
  int sum = 0;
  for(int i = n - 1 ; i >= n-k-1; i--)
    sum += a[i];
  std::cout << sum << std::endl;
}

    
  

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

#include <iostream>
using namespace std;


int main() {
  int N, K;
  cin >> N >> K;
  int a[N];
for (int i=0; i < N; i++) cin >> a[i];

int lot_length=0;
sort(a, a+N, greater<int>());

for(int i=0; i<K; i++){
  lot_length += a[i];
}
  cout << lot_length << endl;
}



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

import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); //棒の全体数
    int K = sc.nextInt(); //取る棒の本数
    int[] rodList = new int[55];
    int rodSum = 0;
    for(i=0; i < N; i++){
      rodList[i] = sc.nextInt();  
    }
    //降順ソート
    for(int j = 0; j < 55; j++){
    for(int i = 54; i > j; i--){
      if(rodList[i - 1] < rodList[i]){
        int swap = rodList[i-1];
        rodList[i-1] = rodList[i];
        rodList[i] = swap;
      }
    }
    }
    for(int i = 0; i < K; i++){
      rodSum += rodList[i];
    }
   System.out.println(rodSum); 
  }
}

Compiler output:
Main.java:9: error: cannot find symbol
    for(i=0; i < N; i++){
        ^
  symbol:   variable i
  location: class Main
Main.java:9: error: cannot find symbol
    for(i=0; i < N; i++){
             ^
  symbol:   variable i
  location: class Main
Main.java:9: error: cannot find symbol
    for(i=0; i < N; i++){
                    ^
  symbol:   variable i
  location: class Main
Main.java:10: error: cannot find symbol
      rodList[i] = sc.nextInt();  
              ^
  symbol:   variable i
  location: class Main
4 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
     int N,K,a;
     int l[55];
  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 ++){
     
      a = l[i];
  }
  cout <<a<<endl;
}
  
    


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

#include<bits/stdc++.h>
using namespace std;
int main(){
     int N,K,a;
     int l[55]
  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 ++){
     
      a = l[i];
  }
  cout <<a<<endl;
}
  
    

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: expected initializer before 'cin'
    6 |   cin << N <<K;
      |   ^~~
a.cc:7:31: error: 'l' was not declared in this scope
    7 |   for(int i=0;i<N;i ++)cin >> l[i];
      |                               ^
a.cc:9:8: error: 'l' was not declared in this scope
    9 |   sort(l,l+N,greater<int>());
      |        ^
a.cc:11:17: error: 'k' was not declared in this scope
   11 |   for(int i=0;i<k;i ++){
      |                 ^
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,greter<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:10:14: error: 'greter' was not declared in this scope
   10 |   sort(a,a+n,greter<int>());
      |              ^~~~~~
a.cc:10:21: error: expected primary-expression before 'int'
   10 |   sort(a,a+n,greter<int>());
      |                     ^~~
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,grater<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:10:14: error: 'grater' was not declared in this scope
   10 |   sort(a,a+n,grater<int>());
      |              ^~~~~~
a.cc:10:21: error: expected primary-expression before 'int'
   10 |   sort(a,a+n,grater<int>());
      |                     ^~~
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: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 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: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:12: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   12 |     ans=ans+a{i};
      |         ~~~^~
      |            |
      |            int*
a.cc:12:14: error: expected ';' before '{' token
   12 |     ans=ans+a{i};
      |              ^
      |              ;
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: In function 'int main()':
a.cc:6:3: error: expected ',' or ';' before 'cin'
    6 |   cin >> n >> k;
      |   ^~~
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:12: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   12 |     ans=ans+a{i};
      |         ~~~^~
      |            |
      |            int*
a.cc:12:14: error: expected ';' before '{' token
   12 |     ans=ans+a{i};
      |              ^
      |              ;
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;
  fr(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;
  return 0;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: expected ')' before ';' token
    7 |   fr(i=0;i<n;i++){
      |     ~   ^
      |         )
a.cc:7:17: error: expected ';' before ')' token
    7 |   fr(i=0;i<n;i++){
      |                 ^
      |                 ;
a.cc:10:14: error: 'grater' was not declared in this scope
   10 |   sort(a,a+n,grater<int>());
      |              ^~~~~~
a.cc:10:21: error: expected primary-expression before 'int'
   10 |   sort(a,a+n,grater<int>());
      |                     ^~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a[55],n,k,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 'cout'
   12 |   ans=ans+a[i]
      |               ^
      |               ;
   13 |   cout << ans << endl;
      |   ~~~~         
a.cc:15:2: error: expected '}' at end of input
   15 | }
      |  ^
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: 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 a[55],n,k,i,ans=0;
  cin >> n >>k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,geater<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:10:14: error: 'geater' was not declared in this scope
   10 |   sort(a,a+n,geater<int>());
      |              ^~~~~~
a.cc:10:21: error: expected primary-expression before 'int'
   10 |   sort(a,a+n,geater<int>());
      |                     ^~~
a.cc:12:15: error: expected ';' before 'cout'
   12 |   ans=ans+a[i]
      |               ^
      |               ;
   13 |   cout << ans << endl;
      |   ~~~~         
a.cc:15:2: error: expected '}' at end of input
   15 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: error: no match for 'operator=' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int')
    8 |     cin = a[i];
      |              ^
In file included from /usr/include/c++/14/iostream:42,
                 from a.cc:1:
/usr/include/c++/14/istream:718:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator=(std::basic_istream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]'
  718 |       operator=(basic_istream&& __rhs)
      |       ^~~~~~~~
/usr/include/c++/14/istream:718:33: note:   no known conversion for argument 1 from 'int' to 'std::basic_istream<char>&&'
  718 |       operator=(basic_istream&& __rhs)
      |                 ~~~~~~~~~~~~~~~~^~~~~
a.cc:10:14: error: 'geater' was not declared in this scope
   10 |   sort(a,a+n,geater<int>());
      |              ^~~~~~
a.cc:10:21: error: expected primary-expression before 'int'
   10 |   sort(a,a+n,geater<int>());
      |                     ^~~
a.cc:12:15: error: expected ';' before 'cin'
   12 |   ans=ans+a[i]
      |               ^
      |               ;
   13 |   cin << ans << endl;
      |   ~~~          
a.cc:15:2: error: expected '}' at end of input
   15 | }
      |  ^
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,l[60];
  cin >> N >> K;
  for(int i=0 ; i<N ; i++) cin >> l[i];
 
  sort(l,l+N,greater<int>()); 
 
  int total=0;
  for(int i=0 ; i < K ; i++) total += l[i];
 
  cout << total;
}
#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>()); 
 
  int ans=0;
  for(int i=0 ; i < K ; i++) ans += l[i];
 
  cout << ans;
}


Compiler output:
a.cc:21:5: error: redefinition of 'int main()'
   21 | int main(){
      |     ^~~~
a.cc:5:5: note: 'int main()' previously defined here
    5 | 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,greather<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:10:14: error: 'greather' was not declared in this scope
   10 |   sort(a,a+n,greather<int>);
      |              ^~~~~~~~
a.cc:10:23: error: expected primary-expression before 'int'
   10 |   sort(a,a+n,greather<int>);
      |                       ^~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: error: no match for 'operator=' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int')
    8 |     cin = a[i]
      |              ^
In file included from /usr/include/c++/14/iostream:42,
                 from a.cc:1:
/usr/include/c++/14/istream:718:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator=(std::basic_istream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]'
  718 |       operator=(basic_istream&& __rhs)
      |       ^~~~~~~~
/usr/include/c++/14/istream:718:33: note:   no known conversion for argument 1 from 'int' to 'std::basic_istream<char>&&'
  718 |       operator=(basic_istream&& __rhs)
      |                 ~~~~~~~~~~~~~~~~^~~~~
a.cc:10:14: error: 'geater' was not declared in this scope
   10 |   sort(a,a+n,geater<int>());
      |              ^~~~~~
a.cc:10:21: error: expected primary-expression before 'int'
   10 |   sort(a,a+n,geater<int>());
      |                     ^~~
a.cc:12:15: error: expected ';' before 'cin'
   12 |   ans=ans+a[i]
      |               ^
      |               ;
   13 |   cin << ans << endl;
      |   ~~~          
a.cc:15:2: error: expected '}' at end of input
   15 | }
      |  ^
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: 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
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,greather<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:10:14: error: 'greather' was not declared in this scope
   10 |   sort(a,a+n,greather<int>());
      |              ^~~~~~~~
a.cc:10:23: error: expected primary-expression before 'int'
   10 |   sort(a,a+n,greather<int>());
      |                       ^~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k,a,i[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: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++){
      |               ^
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,greather<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:10:14: error: 'greather' was not declared in this scope
   10 |   sort(a,a+n,greather<int>());
      |              ^~~~~~~~
a.cc:10:23: error: expected primary-expression before 'int'
   10 |   sort(a,a+n,greather<int>());
      |                       ^~~
a.cc:15:12: error: expected '}' at end of input
   15 |   return 0;
      |            ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^