Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i=0; i<n; i++) {
    cin >> x.at(i);
  }
  
  int res = 1e9;
  for (int i=0; i<=100; i++) {
    int tmp = 0;
    for (int j : x) {
      tmp += (x - i) * (x - i);
    }
    if (tmp < res) {
      res = tmp;
    }
  }
  
  cout << res << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: no match for 'operator-' (operand types are 'std::vector<int>' and 'int')
   18 |       tmp += (x - i) * (x - i);
      |               ~ ^ ~
      |               |   |
      |               |   int
      |               std::vector<int>
In file included from /usr/include/c++/14/string:48,
                 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,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:18:19: note:   'std::vector<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
   18 |       tmp += (x - i) * (x - i);
      |                   ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:18:19: note:   'std::vector<int>' is not derived from 'const std::move_iterator<_IteratorL>'
   18 |       tmp += (x - i) * (x - i);
      |                   ^
a.cc:18:27: error: no match for 'operator-' (operand types are 'std::vector<int>' and 'int')
   18 |       tmp += (x - i) * (x - i);
      |                         ~ ^ ~
      |                         |   |
      |                         |   int
      |                         std::vector<int>
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:18:29: note:   'std::vector<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
   18 |       tmp += (x - i) * (x - i);
      |                             ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:18:29: note:   'std::vector<int>' is not derived from 'const std::move_iterator<_IteratorL>'
   18 |       tmp += (x - i) * (x - i);
      |                             ^