Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> l=input(n);
  sort#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int n,k,ans=0;
  cin >> n >> k;
  vector<int> l=input(n);
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  for(int i=0;i<k;i++){
    ans+=l[i];
  }
  cout << ans << endl;
}


Compiler output:
a.cc:88:7: error: stray '#' in program
   88 |   sort#include <bits/stdc++.h>
      |       ^
a.cc: In function 'int main()':
a.cc:88:7: error: expected ';' before 'include'
   88 |   sort#include <bits/stdc++.h>
      |       ^~~~~~~~
      |       ;
a.cc:89:20: error: statement cannot resolve address of overloaded function
   89 | using namespace std;
      |                    ^
a.cc:91:24: error: a function-definition is not allowed here before '{' token
   91 | int ctoi(const char c) {
      |                        ^
a.cc:95:26: error: a function-definition is not allowed here before '{' token
   95 | vector<int> input(int n) {
      |                          ^
a.cc:102:30: error: a function-definition is not allowed here before '{' token
  102 | void output(vector<int> vec) {
      |                              ^
a.cc:108:41: error: a function-definition is not allowed here before '{' token
  108 | vector<vector<int>> input(int n, int m) {
      |                                         ^
a.cc:117:40: error: a function-definition is not allowed here before '{' token
  117 | void output(vector<vector<int>> table) {
      |                                        ^
a.cc:125:30: error: a function-definition is not allowed here before '{' token
  125 | long long perm(int n, int r) {
      |                              ^
a.cc:136:30: error: a function-definition is not allowed here before '{' token
  136 | long long comb(int n, int r) {
      |                              ^
a.cc:147:30: error: a function-definition is not allowed here before '{' token
  147 | long long homo(int n, int r) {
      |                              ^
a.cc:150:23: error: a function-definition is not allowed here before '{' token
  150 | long long fact(int n) {
      |                       ^
a.cc:158:1: error: a function-definition is not allowed here before '{' token
  158 | {
      | ^
a.cc:168:23: error: a function-definition is not allowed here before '{' token
  168 | int lcm(int a, int b) {
      |                       ^
a.cc:171:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  171 | int main() {
      |         ^~
a.cc:171:9: note: remove parentheses to default-initialize a variable
  171 | int main() {
      |         ^~
      |         --
a.cc:171:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:171:12: error: a function-definition is not allowed here before '{' token
  171 | int main() {
      |            ^
a.cc:181:2: error: expected '}' at end of input
  181 | }
      |  ^
a.cc:84:12: note: to match this '{'
   84 | int main() {
      |            ^