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: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 'begin' in 'stick', which is of non-class type 'int [N]'
   13 |   sort(stick.begin(),stick.end());
      |              ^~~~~
a.cc:13:28: error: request for member 'end' in 'stick', which is of non-class type 'int [N]'
   13 |   sort(stick.begin(),stick.end());
      |                            ^~~
a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   13 |   sort(stick.begin(),stick.end());
      |   ^~~~
      |   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:14:17: error: request for member 'begin' in 'stick', which is of non-class type 'int [N]'
   14 |   reverse(stick.begin(),stick.end());
      |                 ^~~~~
a.cc:14:31: error: request for member 'end' in 'stick', which is of non-class type 'int [N]'
   14 |   reverse(stick.begin(),stick.end());
      |                               ^~~
a.cc:14:3: error: 'reverse' was not declared in this scope; did you mean 'std::reverse'?
   14 |   reverse(stick.begin(),stick.end());
      |   ^~~~~~~
      |   std::reverse
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note: 'std::reverse' declared here
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
a.cc:18:18: error: 'i' was not declared in this scope
   18 |     ans += stick[i];
      |                  ^
a.cc:20:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |   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:20:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   20 |   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)
      |     ^~~~