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

#include <bits/stdc++.h>
#define rep(n) for(int i=0;i<n;i++)
#define reps(i,s,n) for(int i=s;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ll long long
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
using namespace std;
typedef vector<vector<int> > Graph;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
//abs(x) = (x の絶対値)
//string S  S[i],S += T,S += c,S.size(),S.substr(l),S.substr(l, r)
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1;
//find(all(x), key)boolソート済みのベクトル
//lower_bound(all(x),k)以上,uppper_bound(all(x),k)より大きい
int main(){

    int N;
    cin >> N;
    vi vec;
    rep(i,N) cin >> vec.push_back(i);
    sort(all(vec));
    int ans = 0;
    int fu = 1;
    rep(i,N){
        ans += vec.back()*fu;
        vec.pop_back();
        fu *= -1;
    }
    
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc:33:12: error: macro "rep" passed 2 arguments, but takes just 1
   33 |     rep(i,N) cin >> vec.push_back(i);
      |            ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(n) for(int i=0;i<n;i++)
      |         ^~~
a.cc:37:12: error: macro "rep" passed 2 arguments, but takes just 1
   37 |     rep(i,N){
      |            ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(n) for(int i=0;i<n;i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:33:5: error: 'rep' was not declared in this scope
   33 |     rep(i,N) cin >> vec.push_back(i);
      |     ^~~
a.cc:37:8: error: expected ';' before '{' token
   37 |     rep(i,N){
      |        ^    ~
      |        ;
Language: C++

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

int main(){
  
  //入力
  int N;
  cin >> N;
  int a[110];
  for( int i = 0; i < N; i++ )cin >> a[i];
  
  //処理
    sort(a, a + N, greater<int>()); 
  int score_Alice = 0;
  int score_Bob = 0;
  for( int i = 0; i < N; i++ ){
    
    if( i % 2 == 0 ){
      score_Alice += a[i];
    }
    else{
      ( i % 2 != 0 )score_Bob += a[i];
    }
  }
  
  //出力
  cout << score_Alice - score_Bob << endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:21: error: expected ';' before 'score_Bob'
   23 |       ( i % 2 != 0 )score_Bob += a[i];
      |                     ^~~~~~~~~
      |                     ;
Language: C++

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

int main(){
  
  //入力
  int N;
  cin >> N;
  int a[110];
  for( int i = 0; i < N; i++ )cin >> a[i];
  
  //処理
  sort(a[0], a[N-1],greater<int>());
  for( int i = 0; i < N-1; i++ ){
    
    int score_ Alice = 0;
    int score_Bob = 0;
    
    if( i % 2 == 0 )score_Alice += a[i];
    if( i % 2 != 0 )score_Bob += a[i];
    
  }
  
  //出力
  cout << score_Alice - score_Bob << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |   sort(a[0], a[N-1],greater<int>());
      |   ^~~~
      |   short
a.cc:17:16: error: expected initializer before 'Alice'
   17 |     int score_ Alice = 0;
      |                ^~~~~
a.cc:20:21: error: 'score_Alice' was not declared in this scope
   20 |     if( i % 2 == 0 )score_Alice += a[i];
      |                     ^~~~~~~~~~~
a.cc:26:11: error: 'score_Alice' was not declared in this scope
   26 |   cout << score_Alice - score_Bob << endl;
      |           ^~~~~~~~~~~
a.cc:26:25: error: 'score_Bob' was not declared in this scope
   26 |   cout << score_Alice - score_Bob << endl;
      |                         ^~~~~~~~~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'B' was not declared in this scope
   12 |     B+=vec.at(i+1);
      |     ^
a.cc:14:13: error: 'B' was not declared in this scope
   14 |   cout << A-B << endl;
      |             ^
Language: C++

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


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<N;i+2){
      |       ^
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   for(i=1;i<N;i+2){
      |       ^
Language: C++

#include <iostream>
using namespace std;

int main() {
    int N;
    cin >>N;
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a,a+N,greater<int>());
    int Alice =0;
    int Bob =0 ;
    for (int i = 0; i < N; i++)
    {
        if (i%2==0)
        {
            Alice+=a[i];
        }
        else
        {
            Bob+=a[i];
        }
        
    }
    int dif = Alice-Bob;
    cout << dif<<endl;
    
    
    
    
    
}

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

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

int main() {
  int N;
  vector<int> point;
  for (int i = 0;i < N; i++) {
    cin >> point.at(i);
  }
  sort(point.begin(), point.end());
  reverse(point.begin(), point.end());
  int s = 0;
  string p;
  for (int i = 0;i < N ; i++) {
    if (i % 2 == 0) s += point.at(i);
    else s -= point.at(i)
  }
  cout << s << endl; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:26: error: expected ';' before '}' token
   16 |     else s -= point.at(i)
      |                          ^
      |                          ;
   17 |   }
      |   ~
Language: C++

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

int main() {
  int N;
  vector<int> point;
  for (int i = 0;i < N; i++) {
    cin >> point.at(i);
  }
  sort(point.begin(), point.end());
  reverse(point.begin(), point.end());
  int s = 0;
  string p;
  for (int i = 0;i < N ; i++) {
    if (i % 2 == 0) p = "+";
    else p = "-";
  s = s p point.at(i);
  }
  cout << s << endl; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:8: error: expected ';' before 'p'
   17 |   s = s p point.at(i);
      |        ^~
      |        ;
Language: C++

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

int main() {
  int N;
  vector<int> point;
  for (int i = 0;i < N; i++) {
    cin >> point.at(i);
  }
  sort(point.begin(), point.end());
  reverse(point.begin(), point.end());
  int s = 0;
  string p;
  for (int i = 0;i < N ; i++) {
    if (i % 2 == 0) p = "+";
    else p = "-";
  s = p point.at(i);
  }
  cout << s << endl; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int' in assignment
   17 |   s = p point.at(i);
      |       ^
      |       |
      |       std::string {aka std::__cxx11::basic_string<char>}
Language: C++

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

int main() {
  int N;
  vector<int> point;
  for (int i = 0;i < N; i++) {
    cin >> point.at(i);
  }
  sort(point.begin(), point.end());
  reverse(point.begin(), point.end());
  int s = 0;
  string p;
  for (int i = 0;i < N ; i++) {
    if (i % 2 == 0) p = +;
    else p = -;
  s = p point.at(i);
  }
  cout << s << endl; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:26: error: expected primary-expression before ';' token
   15 |     if (i % 2 == 0) p = +;
      |                          ^
a.cc:16:15: error: expected primary-expression before ';' token
   16 |     else p = -;
      |               ^
a.cc:17:7: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int' in assignment
   17 |   s = p point.at(i);
      |       ^
      |       |
      |       std::string {aka std::__cxx11::basic_string<char>}
Language: C++

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

int main() {
  int num, alice = 0, bob = 0;
  cin >> num;
  vector<int> vec(num);
  
  for(int i = 0; i < num; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec,end());
  reverse(vec.begin(), vec.end());
  for(int i = 0; i < num; i++){
    if(i%2 == 0) alice += vec.at(i);
    if(i%2 == 1) bob += vec.at(i);
  }
  cout << alice - bob << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:28: error: no matching function for call to 'end()'
   12 |   sort(vec.begin(), vec,end());
      |                         ~~~^~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
                 from /usr/include/c++/14/bits/stl_algo.h:59,
                 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/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:74:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:85:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:106:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1249:5: note: candidate: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
 1249 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1249:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/valarray:1265:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1265:5: note:   candidate expects 1 argument, 0 provided
Language: C++

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

int main() {
  int num, min = 0, min = 101;
  cin >> num;
  vector<int>vec(num);
  
  for(int i = 0; i < num; i++){
    cin >> vec(i);
    if(min > vec(i)) min = vec(i);
    if(max < vec(i)) max = vec(i);
  }
  cout << max - min << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:21: error: redeclaration of 'int min'
    5 |   int num, min = 0, min = 101;
      |                     ^~~
a.cc:5:12: note: 'int min' previously declared here
    5 |   int num, min = 0, min = 101;
      |            ^~~
a.cc:10:15: error: no match for call to '(std::vector<int>) (int&)'
   10 |     cin >> vec(i);
      |            ~~~^~~
a.cc:11:17: error: no match for call to '(std::vector<int>) (int&)'
   11 |     if(min > vec(i)) min = vec(i);
      |              ~~~^~~
a.cc:11:31: error: no match for call to '(std::vector<int>) (int&)'
   11 |     if(min > vec(i)) min = vec(i);
      |                            ~~~^~~
a.cc:12:17: error: no match for call to '(std::vector<int>) (int&)'
   12 |     if(max < vec(i)) max = vec(i);
      |              ~~~^~~
a.cc:12:8: error: parse error in template argument list
   12 |     if(max < vec(i)) max = vec(i);
      |        ^~~~~~~~~~~~
a.cc:12:20: error: cannot resolve overloaded function 'max' based on conversion to type 'bool'
   12 |     if(max < vec(i)) max = vec(i);
      |                    ^
a.cc:12:31: error: no match for call to '(std::vector<int>) (int&)'
   12 |     if(max < vec(i)) max = vec(i);
      |                            ~~~^~~
a.cc:14:15: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator-'
   14 |   cout << max - min << endl;
      |           ~~~~^~~~~
Language: C++

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

int main() {
  int N,A,B;
  cin >> N;
  vector<int> ar(N);
  for(int i=0;i<N;i++)
    cin >> ar.at(i);
    
   sort(ar.bigin(), ar.end());
   reverse(ar.bigin(), ar.end());
   for(int i = 0; i<N;i++){
     if(i%2 == 0)
       A += ar.at(i);
     else
       B += ar.at(i);
   }
   cout << A - B << endl;
}


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

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

int main() {
  int N,A,B;
  cin >> N;
  vector<int> ar(N);
  for(int i=0;i<N;i++)
    cin >> ar.at(i)
    
   sort(ar.bigin(), ar.end())
   reverse(ar.bigin(), ar.end())
   for(int i = 0; i<N;i++){
     if(i%2 == 0)
       A += ar.at(i);
     else
       B += ar.at(i);
   }
   cout << A - B << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:20: error: expected ';' before 'sort'
    9 |     cin >> ar.at(i)
      |                    ^
      |                    ;
   10 | 
   11 |    sort(ar.bigin(), ar.end())
      |    ~~~~             
a.cc:13:19: error: 'i' was not declared in this scope
   13 |    for(int i = 0; i<N;i++){
      |                   ^
Language: C++

N = int(input())
List = [int(x) for x in input().split()]
Sum = sum(List)
List.sort(reverse=True)
del List[::2]
Sum_B = sum(List)
Sum_A = Sum-Sum_B
print(Sum_A-Sum_B)

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

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

int main(){
    int N;
    cin >> N;
    int alice = 0;
    int kirito = 0;
    vector<int>vec(N);
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    for(int i = 0; i < N; i++){
    cin >>vec[i];
    if(i%2 == 0){
      alice+=vec[i]
    }
    else{
      kirito+=vec[i]
    }
    }
    cout << alice - kirito <<endl;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: expected ';' before '}' token
   15 |       alice+=vec[i]
      |                    ^
      |                    ;
   16 |     }
      |     ~               
a.cc:18:21: error: expected ';' before '}' token
   18 |       kirito+=vec[i]
      |                     ^
      |                     ;
   19 |     }
      |     ~
Language: C++

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

int main() {

    int N ;

    cin >> N ;

    vector<int> vec(N);

    for ( int i = 0 ; i < N ; i++){

        cin >> vec.at(i) ;

    }

    int countA = 0 , countB = 0;

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


    for ( int i = 0 ; i < N/2 ; i++){

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

        countA = countA + vec[0] ;

        vec.erase(vec.begin()) ;

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

        countB = countB + vec[0] ;

        vec.erase(vec.begin()) ;

    }

    cout << countA - countB << endl;

}


        

Compiler output:
a.cc: In function 'int main()':
a.cc:20:34: error: expected ';' before 'for'
   20 |     sort(vec.begin() , vec.end())
      |                                  ^
      |                                  ;
......
   23 |     for ( int i = 0 ; i < N/2 ; i++){
      |     ~~~                           
a.cc:23:23: error: 'i' was not declared in this scope
   23 |     for ( int i = 0 ; i < N/2 ; i++){
      |                       ^
Language: C++

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

int main(){
    int N;
    cin >> N;

    int numbs[110];
    int bucket[N];
    int count = 0;

    for(int i = 0;i < N;i++){
        cin >> numbs[i];

    }
    for(int i = 0;i < N;i++){
        
        bucket[numbs[i]]++;
        
    }
   
    if(bucket[numbs[i]] > 0){
        count++;
    }

    cout << count << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:21: error: 'i' was not declared in this scope
   22 |     if(bucket[numbs[i]] > 0){
      |                     ^
Language: C++

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

int main(){
    int N;
    cin >> N;

    int numbs[110];
    int bucket[N];
    int count = 0;

    for(int = 0;i < N;i++){
        cin >> numbs[i];

    }
    for(int = 0;i < N;i++){
        
        bucket[numbs[i]]++;
        
    }
   
    if(bucket[numbs[i]] > 0){
        count++;
    }

    cout << count << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: expected unqualified-id before '=' token
   12 |     for(int = 0;i < N;i++){
      |             ^
a.cc:12:12: error: expected ';' before '=' token
   12 |     for(int = 0;i < N;i++){
      |            ^~
      |            ;
a.cc:12:13: error: expected primary-expression before '=' token
   12 |     for(int = 0;i < N;i++){
      |             ^
a.cc:12:17: error: 'i' was not declared in this scope
   12 |     for(int = 0;i < N;i++){
      |                 ^
a.cc:12:22: error: expected ')' before ';' token
   12 |     for(int = 0;i < N;i++){
      |        ~             ^
      |                      )
a.cc:12:23: error: 'i' was not declared in this scope
   12 |     for(int = 0;i < N;i++){
      |                       ^
a.cc:16:13: error: expected unqualified-id before '=' token
   16 |     for(int = 0;i < N;i++){
      |             ^
a.cc:16:12: error: expected ';' before '=' token
   16 |     for(int = 0;i < N;i++){
      |            ^~
      |            ;
a.cc:16:13: error: expected primary-expression before '=' token
   16 |     for(int = 0;i < N;i++){
      |             ^
a.cc:16:22: error: expected ')' before ';' token
   16 |     for(int = 0;i < N;i++){
      |        ~             ^
      |                      )
Language: C++

#include <iostream>
using namespace std;

int main(){
    int n, a[101];
    cin >> n;

    for (int i = 0; i < n; i++) cin >> a[i];
    
    int Alice = 0, Bob = 0;

    sort(a, a + n, greater<int>());

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) Alice += a[i];
        else Bob += a[i];
    }

    cout << Alice - Bob << endl;

}

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

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

int main() {
  int N; cin >> N;
  vector<int> cards(N);
  for(int i=0;i<N;i++){
    cin >> cards.at(i);
  }
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  for(int i=0;i<N;i++){
    if(i%2==0)
      a+=cards.at(i);
    else
      b+=cards.at(i);
  }
  cout << a-b << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:7: error: 'a' was not declared in this scope
   15 |       a+=cards.at(i);
      |       ^
a.cc:17:7: error: 'b' was not declared in this scope
   17 |       b+=cards.at(i);
      |       ^
a.cc:19:11: error: 'a' was not declared in this scope
   19 |   cout << a-b << endl;
      |           ^
a.cc:19:13: error: 'b' was not declared in this scope
   19 |   cout << a-b << endl;
      |             ^
Language: C++

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

int main() {
  int N; cin >> N;
  vector<int> cards(N);
  for(int i=0;i<N;i++){
    cin >> cards.at(i);
  }
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  for(int i=0;i<N;i++){
    if(i%2==0)
      a+=cards.at(i);
    else
      b+=cards.at(i);
  }
  cout << a-b << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |   sort(cards.begin(), cards.end());
      |   ^~~~
      |   short
a.cc:12:3: error: 'reverse' was not declared in this scope
   12 |   reverse(cards.begin(), cards.end());
      |   ^~~~~~~
a.cc:16:7: error: 'a' was not declared in this scope
   16 |       a+=cards.at(i);
      |       ^
a.cc:18:7: error: 'b' was not declared in this scope
   18 |       b+=cards.at(i);
      |       ^
a.cc:20:11: error: 'a' was not declared in this scope
   20 |   cout << a-b << endl;
      |           ^
a.cc:20:13: error: 'b' was not declared in this scope
   20 |   cout << a-b << endl;
      |             ^
Language: C++

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

int main() {
  int N; cin >> N;
  vector<int> cards(N);
  for(int i=0;i<N;i++)
    cin >> cards.at(i);
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  for(int i=0;i<N;i++){
    if(i%2==0)
      a+=cards.at(i);
    else
      b+=cards.at(i);
  }
  cout << a-b << endl;
}


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(cards.begin(), cards.end());
      |   ^~~~
      |   short
a.cc:11:3: error: 'reverse' was not declared in this scope
   11 |   reverse(cards.begin(), cards.end());
      |   ^~~~~~~
a.cc:15:7: error: 'a' was not declared in this scope
   15 |       a+=cards.at(i);
      |       ^
a.cc:17:7: error: 'b' was not declared in this scope
   17 |       b+=cards.at(i);
      |       ^
a.cc:19:11: error: 'a' was not declared in this scope
   19 |   cout << a-b << endl;
      |           ^
a.cc:19:13: error: 'b' was not declared in this scope
   19 |   cout << a-b << endl;
      |             ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
#define pb push_back
using namespace std;
using P = pair<int,int>;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef tuple<int,int,int> T;
typedef vector<P> vp;
typedef vector<T> vt;

// head
int a[110];
int main(void){
  int n;
  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a,a+n);
  reverse(a,a+n);
  int a=0,b=0;
  for(int i=0; i<n; i++){
    if(i%2==0){
      a+=a[i];
    } else {
      b+=a[i];
    }
  }
  cout << a-b << endl;
  return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:28:11: error: invalid types 'int[int]' for array subscript
   28 |       a+=a[i];
      |           ^
a.cc:30:11: error: invalid types 'int[int]' for array subscript
   30 |       b+=a[i];
      |           ^
a.cc:34:12: error: expected '}' at end of input
   34 |   return 0;
      |            ^
a.cc:19:15: note: to match this '{'
   19 | int main(void){
      |               ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main(void)
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end()、greater<int>());
  int ans = 0;
  
  for (int i=0;i<N;i++){
    ans += a.at(i) * (i & 1 ? -1 : 1);
  }
  
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc:14:26: error: extended character 、 is not valid in an identifier
   14 |   sort(a.begin(), a.end()、greater<int>());
      |                          ^
a.cc: In function 'int main()':
a.cc:14:26: error: expected ')' before '\U00003001greater'
   14 |   sort(a.begin(), a.end()、greater<int>());
      |       ~                  ^~~~~~~~~
      |                          )
Language: C++

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

int main(void)
{
  int N;
  cin >> N;
  vector<int> a;
  for (int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  
  for (int i=0;i<N;i++){
    ans += a.at(i) * (i & 1 ? -1 : 1);
  }
  
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> a;
      |   ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> a;
      |          ^~~
a.cc:11:12: error: 'a' was not declared in this scope
   11 |     cin >> a.at(i);
      |            ^
a.cc:13:8: error: 'a' was not declared in this scope
   13 |   sort(a.begin(), a.end());
      |        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int a[110];
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int sum=0;
    int total=0;
    for(int i=0;i<N;i++){
      if(i==0||i%2==0){
        sum+=a[i];
      }
      else{
        total+=a[i];
      }
    }
  cout<<sum-total<<endl;
  }
}


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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int a[110];
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a[i];
    sort(a.begin(0),a.end(N));
    reverse(a.begin(0),a.end(N));
    int sum=0;
    int total=0;
    for(int i=0;i<N;i++){
      if(i==0||i%2==0){
        sum+=a[i];
      }
      else{
        total+=a[i];
      }
    }
  cout<<sum-total<<endl;
  }
}


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

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

int main() {
  int N, A, B;
  cin >> N;
  vector<int> vec = (N);
  for(int i=0;i<N;i++){
  cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for(int i=0;i<N;i+=2){
  A = A + vec.at(i);
  }
  for(int i=1;i<N;i+=2){
  B = B + vec.at(i);
  }
  cout << A-B << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:7:22: error: conversion from 'int' to non-scalar type 'std::vector<int>' requested
    7 |   vector<int> vec = (N);
      |                     ~^~
Language: C

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a, a + n, greater<int>());//降順にする
  int Alice=0,Bob=0;
  for(i=0;i<n;i++){
    if(i%2==0){
      Alice+=a[i];
    }else{
      Bob+=a[i];
    }
  }
  cout << Alice-Bob << endl;    
  return 0;
}

Compiler output:
main.c: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 A=0,B=0;
  
  int n,m;
  cin>>n;
  
  int a[n];
  for(int i=0;i<n;i++)
      cin>>a[i];
  
     sort(a, a+n);
     reverse(a,a+n);
  
      for(int i=0;i<n;i++)
      {
         if(i%2==0)
         {
           A+=a[i];
         }
         else{
           B+=a[i]
         }
      }
  
  
   cout<<A-B<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:19: error: expected ';' before '}' token
   29 |            B+=a[i]
      |                   ^
      |                   ;
   30 |          }
      |          ~
Language: C++

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


int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}


int main() {
 
 int A=0,B=0;
  
  int n,m;
  cin>>n;
  
  int a[n];
  for(int i=0;i<n;i++)
      cin>>a[i];
  
     qsort(a, sizeof(a) / sizeof(a[0]), sizeof(int), cmpnum);
  
  
      for(int i=0;i<n;i++)
      {
         if(i%2==0)
           A+=a[i];
        
         if(i%2==1)
           B+=a[i]
      }
  
  
   cout<<A-B<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:19: error: expected ';' before '}' token
   42 |            B+=a[i]
      |                   ^
      |                   ;
   43 |       }
      |       ~
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> int vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  int A = 0;
  int B = 0;
  
  for ( int i = 0;i < N; i += 2 ) {
    A += vec.at(i);
  }
  
  for ( int i = 1;i < N; i += 2 ) {
    B += vec.at(i);
  }
  
  cout << A - B << endl;
}
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     cin >> int vec.at(i);
      |            ^~~
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> int vec.at(i);
  }
  sort(vec.begin().vec.end());
  
  int A = 0;
  int B = 0;
  
  for ( int i = 0;i < N; i += 2 ) {
    A += vec.at(i);
  }
  
  for ( int i = 1;i < N; i += 2 ) {
    B += vec.at(i);
  }
  
  cout << A - B << endl;
}
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     cin >> int vec.at(i);
      |            ^~~
a.cc:11:20: error: 'std::vector<int>::iterator' has no member named 'vec'
   11 |   sort(vec.begin().vec.end());
      |                    ^~~
Language: C++

using System;
using System.Linq;
class abc
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] aa = Console.ReadLine().Split(' ');
        int[] a = Array.ConvertAll(aa, int.Parse);
        Array.Sort(a);
        Array.Reverse(a);
        int A = 0;
        int B = 0;
        for (int i = 0; i < N - 1; i++)
        {
            A += a[i];
            B += a[i + 1];
        }
        Console.WriteLine(A - B);
    }
}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Linq;
      |       ^~~~~~
a.cc:21:2: error: expected ';' after class definition
   21 | }
      |  ^
      |  ;
a.cc: In static member function 'static void abc::Main()':
a.cc:7:17: error: expected primary-expression before 'int'
    7 |         int N = int.Parse(Console.ReadLine());
      |                 ^~~
a.cc:8:9: error: 'string' was not declared in this scope
    8 |         string[] aa = Console.ReadLine().Split(' ');
      |         ^~~~~~
a.cc:8:16: error: expected primary-expression before ']' token
    8 |         string[] aa = Console.ReadLine().Split(' ');
      |                ^
a.cc:9:12: error: structured binding declaration cannot have type 'int'
    9 |         int[] a = Array.ConvertAll(aa, int.Parse);
      |            ^~
a.cc:9:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:9:12: error: empty structured binding declaration
a.cc:9:15: error: expected initializer before 'a'
    9 |         int[] a = Array.ConvertAll(aa, int.Parse);
      |               ^
a.cc:10:9: error: 'Array' was not declared in this scope
   10 |         Array.Sort(a);
      |         ^~~~~
a.cc:10:20: error: 'a' was not declared in this scope
   10 |         Array.Sort(a);
      |                    ^
a.cc:19:9: error: 'Console' was not declared in this scope
   19 |         Console.WriteLine(A - B);
      |         ^~~~~~~
Language: C++

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

int main() {
  int n;
  int value=0;
  cin >>n;
  vector<int> v(n);
  for(int i=0; i<n;i++){
    v.at(i);
  }
  sort(v.begin(),v.end());
  reverese(v.begin(),v.end());

  for(int i=0;i<n;i++){
    if(i%2==0)
      value+=v.at(i);
    else
      value-=v.at(i);
  }
  cout << value <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   10 |     v.at(i);
      |     ~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1180:7: note: declared here
 1180 |       at(size_type __n)
      |       ^~
a.cc:13:3: error: 'reverese' was not declared in this scope
   13 |   reverese(v.begin(),v.end());
      |   ^~~~~~~~
Language: C++

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

int main() {
  int n;
  int value=0;
  cin >>n;
  vector<int> v;
  for(int i=0; i<n;i++){
    v.at(i);
  }
  sort(v.begin(),v.end());
  reverese(v.begin(),v.end());

  for(int i=0;i<n;i++){
    if(i%2==0)
      value+=v.at(i);
    else
      value-=v.at(i);
  }
  cout << value <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   10 |     v.at(i);
      |     ~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1180:7: note: declared here
 1180 |       at(size_type __n)
      |       ^~
a.cc:13:3: error: 'reverese' was not declared in this scope
   13 |   reverese(v.begin(),v.end());
      |   ^~~~~~~~
Language: C++

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

int main() {
  int n;
  int value=0;
  cin >>n;
  vector<int> v;
  for(int i=0; i<n;i++){
    v.at(i);
  }
  sort(v.begin(),vrend());
  reverese(v.begin(),v.end());

  for(int i=0;i<n;i++){
    if(i%2==0)
      value+=v.at(i);
    else
      value-=v.at(i);
  }
  cout << value <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   10 |     v.at(i);
      |     ~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1180:7: note: declared here
 1180 |       at(size_type __n)
      |       ^~
a.cc:12:18: error: 'vrend' was not declared in this scope
   12 |   sort(v.begin(),vrend());
      |                  ^~~~~
a.cc:13:3: error: 'reverese' was not declared in this scope
   13 |   reverese(v.begin(),v.end());
      |   ^~~~~~~~
Language: C++

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

int main() {
  int n;
  int value=0;
  cin >>n;
  vector<int> v;
  for(int i=0; i<n;i++){
    v.at(i)
  }
  sort(v.rbegin(),v.rend());

  for(int i=0;i<n;i++){
    if(i%2==0)
      value+=v.at(i);
    else
      value-=v.at(i);
  }
  cout << value <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: expected ';' before '}' token
   10 |     v.at(i)
      |            ^
      |            ;
   11 |   }
      |   ~         
a.cc:10:9: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   10 |     v.at(i)
      |     ~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1180:7: note: declared here
 1180 |       at(size_type __n)
      |       ^~
Language: C++

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

int main() {
  int n;
  int value=0;
  cin >>n;
  vector<int> v;
  for(int i=0; i<n;i++){
    v.at(i)
  }
  sort(begin.v(),end.v());
  reverse(begin.v(),end.v());
  for(int i=0;i<n;i++){
    if(i%2==0)
      value+=v.at(i);
    else
      value-=v.at(i);
  }
  cout << value <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: expected ';' before '}' token
   10 |     v.at(i)
      |            ^
      |            ;
   11 |   }
      |   ~         
a.cc:10:9: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   10 |     v.at(i)
      |     ~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1180:7: note: declared here
 1180 |       at(size_type __n)
      |       ^~
a.cc:12:14: error: overloaded function with no contextual type information
   12 |   sort(begin.v(),end.v());
      |              ^
a.cc:12:22: error: overloaded function with no contextual type information
   12 |   sort(begin.v(),end.v());
      |                      ^
a.cc:13:17: error: overloaded function with no contextual type information
   13 |   reverse(begin.v(),end.v());
      |                 ^
a.cc:13:25: error: overloaded function with no contextual type information
   13 |   reverse(begin.v(),end.v());
      |                         ^
Language: C++

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

int main() {
  int n;
  int value=0;
  cin >>n;
  vector<int> v;
  for(int i=0; i<n;i++){
    v.at(i)
  }
  sort(rbegin.v(),rend.v());
  for(int i=0;i<n;i++){
    if(i%2==0)
      value+=v.at(i);
    else
      value-=v.at(i);
  }
  cout << value <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: expected ';' before '}' token
   10 |     v.at(i)
      |            ^
      |            ;
   11 |   }
      |   ~         
a.cc:10:9: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   10 |     v.at(i)
      |     ~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1180:7: note: declared here
 1180 |       at(size_type __n)
      |       ^~
a.cc:12:15: error: overloaded function with no contextual type information
   12 |   sort(rbegin.v(),rend.v());
      |               ^
a.cc:12:24: error: overloaded function with no contextual type information
   12 |   sort(rbegin.v(),rend.v());
      |                        ^
Language: C++

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

int main() {
  int n;
  size_t hito;
  cin >> n;
  vevtor<int> v(n);
  for(int i=0; i<n; i++){
    v.at(i);
  }
  
  vector<int> ten(2);
  for(int cnt=0; cnt<n;cnt++){
    if(cnt%2==0)
      hito=0;
    else  hito=1;
    
  int tmp=0;
  for(int i=0;i<n;i++){
    if(v.at(tmp)<v.at(i))
      tmp=i; 
    if(i+1==n){
      ten.at(hito)+=v.at(tmp);
      v.at(tmp)=0;
    }
  }
  }
  cout << ten.at(0)-ten.at(1) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vevtor' was not declared in this scope
    8 |   vevtor<int> v(n);
      |   ^~~~~~
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vevtor<int> v(n);
      |          ^~~
a.cc:10:5: error: 'v' was not declared in this scope
   10 |     v.at(i);
      |     ^
a.cc:21:8: error: 'v' was not declared in this scope
   21 |     if(v.at(tmp)<v.at(i))
      |        ^
a.cc:24:21: error: 'v' was not declared in this scope
   24 |       ten.at(hito)+=v.at(tmp);
      |                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main{
  int N,a,M;
  M=0;
  vector<int> vec(N);
  for (int i=0;i<N;i++)
    cin >> vec.at(i);
  for (int i=0;i<N-1;i++){
    for (int j=i+1; j<N; j++){
      if (vec.at(i)<vec.at(j)){
        a=vec.at(i);
        vec.at(i)=vec.at(j);
        vec.at(j)=a;
      }
    }
  }
 for(int i=0;i<N;i++){
   if (i%2==0)
     M+=vec.at(i);
   else
     M -= vec.at(i);
 }
  cout << M << endl;
}
        
      

Compiler output:
a.cc:3:5: error: cannot declare '::main' to be a global variable
    3 | int main{
      |     ^~~~
a.cc:4:3: error: expected primary-expression before 'int'
    4 |   int N,a,M;
      |   ^~~
a.cc:4:3: error: expected '}' before 'int'
a.cc:3:9: note: to match this '{'
    3 | int main{
      |         ^
a.cc:5:3: error: 'M' does not name a type
    5 |   M=0;
      |   ^
a.cc:6:19: error: 'N' was not declared in this scope
    6 |   vector<int> vec(N);
      |                   ^
a.cc:7:3: error: expected unqualified-id before 'for'
    7 |   for (int i=0;i<N;i++)
      |   ^~~
a.cc:7:16: error: 'i' does not name a type
    7 |   for (int i=0;i<N;i++)
      |                ^
a.cc:7:20: error: 'i' does not name a type
    7 |   for (int i=0;i<N;i++)
      |                    ^
a.cc:9:3: error: expected unqualified-id before 'for'
    9 |   for (int i=0;i<N-1;i++){
      |   ^~~
a.cc:9:16: error: 'i' does not name a type
    9 |   for (int i=0;i<N-1;i++){
      |                ^
a.cc:9:22: error: 'i' does not name a type
    9 |   for (int i=0;i<N-1;i++){
      |                      ^
a.cc:18:2: error: expected unqualified-id before 'for'
   18 |  for(int i=0;i<N;i++){
      |  ^~~
a.cc:18:14: error: 'i' does not name a type
   18 |  for(int i=0;i<N;i++){
      |              ^
a.cc:18:18: error: 'i' does not name a type
   18 |  for(int i=0;i<N;i++){
      |                  ^
a.cc:24:3: error: 'cout' does not name a type
   24 |   cout << M << endl;
      |   ^~~~
a.cc:25:1: error: expected declaration before '}' token
   25 | }
      | ^
Language: C++

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

int main()
{
  int n;
  cin>>n;
  int alice =0;
  int bob = 0;
  vector<int> vec;
  for (int i =0; i< n; i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i<n; i++){
    if(n % 2 == 0){
      if (i % 2 == 1){
        alice += vec.at(i);
      } if (i % 2 == 0){
        bob += vec.at(i);
      }
    } if (n % 2 = 1){
      if (i % 2 == 1){
        bob += vec.at(i);
      } if (i % 2 = 0){
        alice += vec.at(i);
      }
    }
  }
  cout << alice - bob <<endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:22:13: error: lvalue required as left operand of assignment
   22 |     } if (n % 2 = 1){
      |           ~~^~~
a.cc:25:15: error: lvalue required as left operand of assignment
   25 |       } if (i % 2 = 0){
      |             ~~^~~
Language: C++

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

int main()
{
  int n;
  cin>>n;
  int alice =0;
  int bob = 0;
  vector<int> vec;
  for (int i =0; i< n; i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i<n; i++){
    if(n % 2 == 0){
      if (i % 2 == 1){
        alice += vec.at(i);
      } if (i % 2 == 0){
        bob += vec.at(i);
      }
    } if (n % 2 = 1;){
      if (i % 2 == 1){
        bob += vec.at(i);
      } if (i % 2 = 0){
        alice += vec.at(i);
      }
    }
  }
  cout << alice - bob <<endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:22:13: error: lvalue required as left operand of assignment
   22 |     } if (n % 2 = 1;){
      |           ~~^~~
a.cc:22:21: error: expected primary-expression before ')' token
   22 |     } if (n % 2 = 1;){
      |                     ^
a.cc:25:15: error: lvalue required as left operand of assignment
   25 |       } if (i % 2 = 0){
      |             ~~^~~
Language: C++

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

int main() {
  int N;
  cin >> N;
  
  vector <int> a(N);
  for (i=0; i<N; i++) {
    cin >> a.at(i);
  }
  
  sort (a.begin(),a.end());
  reverse (a.begin(),a.end());
  
  int A=0;
  int B=0;
  
  for (i=0; i<N; i++) {
    if (i%2 == 0) {
      A += a.at(i);
    }
    else {
      B += a.at(i);
    }
  }
  
  cout << A-B << endl;
}


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

#include<iostream>
using std::cout;
using std::cin;
using std::endl;

#include<argorithm>
using std::sort;

#include<vector>
using std::vector;

int main()
{
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i ++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  int alice = 0;
  int bob = 0;
  
  for (int i = 0; i < n; i ++)
  {
    if (i % 2 == 0) alice += a.at(i);
    else bob += a.at(i);
  }
  
  cout << alice - bob << endl;
  
  return 0;
}

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

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

int main(){
  int a,N,total;
  total = 0;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> a;
    v(i) = a;
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0;i<N;i++)
   if(i%2==0){
     total += v(i);
   }else{
    total -= v(i); 
   }
  cout << total << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:6: error: no match for call to '(std::vector<int>) (int&)'
   11 |     v(i) = a;
      |     ~^~~
a.cc:17:16: error: no match for call to '(std::vector<int>) (int&)'
   17 |      total += v(i);
      |               ~^~~
a.cc:19:15: error: no match for call to '(std::vector<int>) (int&)'
   19 |     total -= v(i);
      |              ~^~~