Language: C++

#include <iostream>
#include <vector>
#include <map>

int main(){
  int N;
  cin >> N;
  map<int, int> m;
  
  int maxind = 0;
  for(int i = 0; i < N; i++){
    int idx;
    cin >> idx;
    maxind = max(maxind, ind);
    m[idx]++;
  }
  
  vector<int> v;
  int c = 0;
  for(int i = 0; i <= maxind; i++){
    if(m.count(i) == 0) continue;
    v[c] = i;
    c++
  }
  
  sort(v.begin(), v.end());
  int ans = 0;
  for(int i = 0; i < v.size() - 2 ; i++){
    ans += v[i];
  }
  cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin >> N;
      |   ^~~
      |   std::cin
In file included 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:8:3: error: 'map' was not declared in this scope
    8 |   map<int, int> m;
      |   ^~~
a.cc:8:3: note: suggested alternatives:
In file included from /usr/include/c++/14/map:63,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_map.h:102:11: note:   'std::map'
  102 |     class map
      |           ^~~
/usr/include/c++/14/map:89:13: note:   'std::pmr::map'
   89 |       using map
      |             ^~~
a.cc:8:7: error: expected primary-expression before 'int'
    8 |   map<int, int> m;
      |       ^~~
a.cc:14:26: error: 'ind' was not declared in this scope; did you mean 'int'?
   14 |     maxind = max(maxind, ind);
      |                          ^~~
      |                          int
a.cc:14:14: error: 'max' was not declared in this scope; did you mean 'std::max'?
   14 |     maxind = max(maxind, ind);
      |              ^~~
      |              std::max
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:15:5: error: 'm' was not declared in this scope
   15 |     m[idx]++;
      |     ^
a.cc:18:3: error: 'vector' was not declared in this scope
   18 |   vector<int> v;
      |   ^~~~~~
a.cc:18:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:18:10: error: expected primary-expression before 'int'
   18 |   vector<int> v;
      |          ^~~
a.cc:21:8: error: 'm' was not declared in this scope
   21 |     if(m.count(i) == 0) continue;
      |        ^
a.cc:22:5: error: 'v' was not declared in this scope
   22 |     v[c] = i;
      |     ^
a.cc:23:8: error: expected ';' before '}' token
   23 |     c++
      |        ^
      |        ;
   24 |   }
      |   ~     
a.cc:26:8: error: 'v' was not declared in this scope
   26 |   sort(v.begin(), v.end());
      |        ^
a.cc:26:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   26 |   sort(v.begin(), v.end());
      |   ^~~~
      |   short
a.cc:31:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   31 |   cout << ans;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~