Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
int main(){
    int n, a;
    vector<int> v;
    int avg = 0;
    int sum = 0;
    
    
    int i;
    cin >> n;
    
    for(i = 0; i < n; i++){
        cin >> a;
        avg += a;
        v.push_back(a);
    }
    
if(avg%n == 0){
        avg /= n;
        for(i = 0; i < n; i++){
            sum += (avg - v[i]) * (avg - v[i]);
        }
        cout << sum << endl;
    }else{
        int sum2 = 0;
        avg /= n;
        for(i = 0; i < n; i++){
            sum += (avg - v[i]) * (avg - v[i]);
        }
        for(i = 0; i < n; i++){
            sum2 += (avg + 1 - v[i]) * (avg + 1 - v[i]);
        }
        
        cout << min(sum, sum2) << endl;
    }
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'vector' was not declared in this scope
   13 |     vector<int> v;
      |     ^~~~~~
a.cc:13:5: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/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:13:12: error: expected primary-expression before 'int'
   13 |     vector<int> v;
      |            ^~~
a.cc:19:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   19 |     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:24:9: error: 'v' was not declared in this scope
   24 |         v.push_back(a);
      |         ^
a.cc:30:27: error: 'v' was not declared in this scope
   30 |             sum += (avg - v[i]) * (avg - v[i]);
      |                           ^
a.cc:32:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   32 |         cout << sum << 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:32:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   32 |         cout << sum << endl;
      |                        ^~~~
      |                        std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:37:27: error: 'v' was not declared in this scope
   37 |             sum += (avg - v[i]) * (avg - v[i]);
      |                           ^
a.cc:40:32: error: 'v' was not declared in this scope
   40 |             sum2 += (avg + 1 - v[i]) * (avg + 1 - v[i]);
      |                                ^
a.cc:43:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   43 |         cout << min(sum, sum2) << 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:43:17: error: 'min' was not declared in this scope; did you mean 'std::min'?
   43 |         cout << min(sum, sum2) << endl;
      |                 ^~~
      |                 std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:43:35: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   43 |         cout << min(sum, sum2) << endl;
      |                                   ^~~~
      |                                   std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~