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

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int *ary = new int[N];
    for (int i = 0; i < N; i++)
    {
        cin >> ary[i];
    }

    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += ary[i];
    }

    int x = (int)round(sum / (0. + N));
    //cout << x << endl;
    int cost = 0;
    for (int i = 0; i < N; i++)
    {
        int a = ary[i] - x;
        cost += a * a;
    }
    cout << cost << endl;
    delete[] ary;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:18: error: 'round' was not declared in this scope
   22 |     int x = (int)round(sum / (0. + N));
      |                  ^~~~~
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  vector<int> cost;
  for(int i=0;i<N;i++){cin>>a[i];}
  for(int i=-100;i<=100;i++){
    int temp=0;
    for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
    cost.push_back(temp);
  }
  int ans=*min_element(cost.begin(),cost.end());
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:12: error: 'min_element' was not declared in this scope
   15 |   int ans=*min_element(cost.begin(),cost.end());
      |            ^~~~~~~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  vector<int> cost;
  for(int i=0;i<N;i++)cin>>a[N];
  for(int i=-100;i<=100;i++){
    int temp=0;
    for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
    cost.push_back(temp);
  }
  int ans=cost[min_element(cost.begin(),cost.end())];
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:15: error: no match for 'operator[]' (operand types are 'std::vector<int>' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
   16 |   int ans=cost[min_element(cost.begin(),cost.end())];
      |               ^
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  vector<int> cost;
  for(int i=0;i<N;i++)cin>>a[N];
  for(int i=-100;i<=100;i++){
    int temp=0;
    for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
    cost.push_back(temp);
  }
  int ans=min_element(cost.begin(),cost.end());
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:22: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization
   16 |   int ans=min_element(cost.begin(),cost.end());
      |           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
      |                      |
      |                      __gnu_cxx::__normal_iterator<int*, std::vector<int> >
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  vector<int> cost;
  for(int i=0;i<N;i++)cin>>a[N];
  for(int i=-100;i<=100;i++){
    int temp=0;
    for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
    cost.push_back(temp);
  }
  int ans=min_element(cost.begin(),cost.end())
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:22: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization
   16 |   int ans=min_element(cost.begin(),cost.end())
      |           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
      |                      |
      |                      __gnu_cxx::__normal_iterator<int*, std::vector<int> >
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  vector<int> cost;
  for(int i=0;i<N;i++)cin>>a[N];
  for(int i=-100;i<=100;i++){
    int temp=0;
    for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
    cost.push_back(temp);
  }
  cout<<min_element(cost.begin(),cost.end())<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> cost;
      |   ^~~~~~
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:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> cost;
      |          ^~~
a.cc:13:5: error: 'cost' was not declared in this scope; did you mean 'const'?
   13 |     cost.push_back(temp);
      |     ^~~~
      |     const
a.cc:15:21: error: 'cost' was not declared in this scope; did you mean 'const'?
   15 |   cout<<min_element(cost.begin(),cost.end())<<endl;
      |                     ^~~~
      |                     const
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  int cost[200]={0};
  for(int i=0;i<N;i++)cin>>a[N];
  for(int i=-100;i<=100;i++){
    for(int j=0;j<N;j++)cost[i+100]+=(a[j]-i)*(a[j]-i);
  }
  cout<<min_element(cost[0],cost[199])<<endl;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 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,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = int; _Iterator2 = int]':
/usr/include/c++/14/bits/stl_algo.h:5562:12:   required from 'constexpr _ForwardIterator std::__min_element(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 5562 |         if (__comp(__first, __result))
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5586:43:   required from 'constexpr _FIter std::min_element(_FIter, _FIter) [with _FIter = int]'
 5586 |       return _GLIBCXX_STD_A::__min_element(__first, __last,
      |                                           ^
a.cc:13:20:   required from here
   13 |   cout<<min_element(cost[0],cost[199])<<endl;
      |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:16: error: invalid type argument of unary '*' (have 'int')
   45 |       { return *__it1 < *__it2; }
      |                ^~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:25: error: invalid type argument of unary '*' (have 'int')
   45 |       { return *__it1 < *__it2; }
      |                         ^~~~~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  int cost[200]={0};
  for(int i=0;i<N;i++)cin>>a[N];
  for(int i=-100;i<=100;i++){
    for(int j=0;j<N;j++)cost[i+100]+=(a[j]-i)*(a[j]-i);
  }
  cout<<min_element(cost.begin(),cost.end())<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:26: error: request for member 'begin' in 'cost', which is of non-class type 'int [200]'
   13 |   cout<<min_element(cost.begin(),cost.end())<<endl;
      |                          ^~~~~
a.cc:13:39: error: request for member 'end' in 'cost', which is of non-class type 'int [200]'
   13 |   cout<<min_element(cost.begin(),cost.end())<<endl;
      |                                       ^~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  int cost[200]={0};
  for(int i=0;i<N;i++)cin>>a[N];
  for(int i=-100;i<=100;i++){
    for(int j=0;j<N;j++)cost[i+100]+=(a[j]-i)*(a[j]-i);
  }
  cout<<cost.min()<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:14: error: request for member 'min' in 'cost', which is of non-class type 'int [200]'
   13 |   cout<<cost.min()<<endl;
      |              ^~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  int cost[200]={0};
  for(int i=0;i<N;i++)cin>>a[N];
  for(int i=-100;i<=100;i++){
    for(int j=0;j<N;j++)cost+=(a[j]-i)*(a[j]-i);
  }
  cout<<cost.min()<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:29: error: incompatible types in assignment of 'int' to 'int [200]'
   11 |     for(int j=0;j<N;j++)cost+=(a[j]-i)*(a[j]-i);
      |                         ~~~~^~~~~~~~~~~~~~~~~~~
a.cc:13:14: error: request for member 'min' in 'cost', which is of non-class type 'int [200]'
   13 |   cout<<cost.min()<<endl;
      |              ^~~
Language: Java

public class Main {
	public static void main(String[] args) {
		Scanner stdin =new Scanner(System.in);
		int n=stdin.nextInt();
		int a[]=new int [n];
		int i;
		for(i=0;i<n;i++){
			a[i]=stdin.nextInt();
		}
		int max=-300,min=300;
		for(i=0;i<n;i++){
			if(max<a[i])
				max=a[i];
			if(min>a[i])
				min=a[i];
		}
		int min2=Integer.MAX_VALUE;
		int p=0;
		for(i=min;i<=max;i++){
			p=0;
			for(int j=0;j<n;j++)
				p+=(a[j]-i)*(a[j]-i);

			if(p<min2)
				min2=p;
		}

		System.out.println(min2);
	}
}

Compiler output:
Main.java:3: error: cannot find symbol
		Scanner stdin =new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
		Scanner stdin =new Scanner(System.in);
		                   ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

ll sq(ll x){
	return x*x;
}

int main(void){
	int n,i;
	ll a[123],tmp,ans=INFLL,mx=-INFLL,mn=INFLL,j;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
		mn = min(mn,a[i]);
		mx = max(mx,a[i]);
	}
	for(j=min; j<max; ++j){
		tmp = 0ll;
		for(i=0; i<n; ++i){
			tmp += sq(a[i]-j);
		}
		ans = min(tmp,ans);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:15: error: cannot resolve overloaded function 'min' based on conversion to type 'll' {aka 'long long int'}
   22 |         for(j=min; j<max; ++j){
      |               ^~~
a.cc:22:21: error: invalid operands of types 'll' {aka 'long long int'} and '<unresolved overloaded function type>' to binary 'operator<'
   22 |         for(j=min; j<max; ++j){
      |                    ~^~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

#define size_t int

using namespace std;
typedef unsigned long ul;
typedef unsigned long long ull;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  std::cin >> n;

  vector<int> a(n,0);

  for (size_t i = 0; i < n; i++) {
    std::cin >> a[i];
  }

  int c = accumulate(a.begin(),a.end(), 0);

  int c2 = 0;
  for (size_t i = 0; i < n; i++) {
    /* code */
    c2 += a[i]*a[i];
  }
  int alpha = c / n;
  int beta = alpha + 1;
  int ans = min(c2 - 2 * alpha * c + n * alpha * alpha,c2 - 2 * beta * c + n * beta * beta);

  std::cout << ans << '\n';

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:11: error: 'accumulate' was not declared in this scope
   26 |   int c = accumulate(a.begin(),a.end(), 0);
      |           ^~~~~~~~~~
Language: C

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

#define size_t int

using namespace std;
typedef unsigned long ul;
typedef unsigned long long ull;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  std::cin >> n;

  vector<int> a(n,0);

  for (size_t i = 0; i < n; i++) {
    std::cin >> a[i];
  }

  int c = accumulate(a.begin(),a.end(), 0);

  int c2 = 0;
  for (size_t i = 0; i < n; i++) {
    /* code */
    c2 += a[i]*a[i];
  }
  int alpha = c / n;
  int beta = alpha + 1;
  int ans = min(c2 - 2 * alpha * c + n * alpha * alpha,c2 - 2 * beta * c + n * beta * beta);

  std::cout << ans << '\n';

  return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<math.h>
using namespace std;

int main() {
	// your code goes here
	int n,i,b,sum;
	double k;
	cin>>n;
	int a[n];
	sum=0;
	for(i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	k=(double)sum/n;
	b=round(k);
	sum=0;
	for(i=0;i<n;i++)
	{
	    sum+=(b-a[i])*(b-a[i]);
	}
	cout<<sum<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin>>n;
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<math.h>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:23:9: error: 'cout' was not declared in this scope
   23 |         cout<<sum<<endl;
      |         ^~~~
a.cc:23:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:23:20: error: 'endl' was not declared in this scope
   23 |         cout<<sum<<endl;
      |                    ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include<math.h>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: Java

import java.util.Scanner;

public class ProblemC {

    public static int max_a (int[] array) {
        int val = array[0];
        for (int i = 1; i < array.length; i++) {
            val = Math.max(val, array[i]);
        }

        return val;
    }

    public static int min_a (int[] array) {
        int val = array[0];
        for (int i = 1; i < array.length; i++) {
            val = Math.min(val, array[i]);
        }

        return val;
    }

    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }

        int maxa = max_a(a);
        int mina = min_a(a);

        int min_cost = Integer.MAX_VALUE;
        for (int i = mina; i <= maxa; i++) {
            int cost = 0;
            for (int j = 0; j < n; j++) {
                 cost += (i - a[j]) * (i - a[j]);
            }
            min_cost = Math.min(min_cost, cost);
        }

        System.out.println(min_cost);
    }
}

Compiler output:
Main.java:3: error: class ProblemC is public, should be declared in a file named ProblemC.java
public class ProblemC {
       ^
1 error
Language: C++

#include <cmath>
#include <iostream>

using namespace std;

int main(void) {
  int N, a[100], cost, mincost = INT_MAX, max = 0, min = INT_MAX;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (max < a[i])
      max = a[i];
    if (min > a[i])
      min = a[i];
  }
  for (int i = min; i <= max; i++) {
    cost = 0;
    for (int j = 0; j < N; j++) {
      cost += pow(a[j] - i, 2.0);
    }
    if (cost < mincost)
      mincost = cost;
  }
  cout << mincost << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:34: error: 'INT_MAX' was not declared in this scope
    7 |   int N, a[100], cost, mincost = INT_MAX, max = 0, min = INT_MAX;
      |                                  ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <iostream>
  +++ |+#include <climits>
    3 | 
a.cc:11:9: error: parse error in template argument list
   11 |     if (max < a[i])
      |         ^~~~~~~~~~
a.cc:11:19: error: cannot resolve overloaded function 'max' based on conversion to type 'bool'
   11 |     if (max < a[i])
      |                   ^
a.cc:12:16: error: overloaded function with no contextual type information
   12 |       max = a[i];
      |                ^
a.cc:13:13: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator>'
   13 |     if (min > a[i])
      |         ~~~~^~~~~~
a.cc:14:16: error: overloaded function with no contextual type information
   14 |       min = a[i];
      |                ^
a.cc:16:16: error: cannot resolve overloaded function 'min' based on conversion to type 'int'
   16 |   for (int i = min; i <= max; i++) {
      |                ^~~
a.cc:16:23: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<='
   16 |   for (int i = min; i <= max; i++) {
      |                     ~~^~~~~~
Language: C++

#include <iostream>

using namespace std;

int a[105];
int n, ll, rr;
long res = 105 * 105;

long check(long value)
{
	long ret = 0;

	for (int i = 0; i < n; ++i)
		ret += (a[i] - value) * (a[i] - value);

	return ret;
}

int main()
{
	ll = 105; rr = -105;

	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (a[i] < ll)
			ll = a[i];
		if (a[i] > rr)
			rr = a[i];
	}

	for (int i = -1000; i <= 1000 ++i)
	{
		long ret = check(i);
		if (ret < res)
			res = ret;
	}

	cout << res << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:34: error: lvalue required as increment operand
   33 |         for (int i = -1000; i <= 1000 ++i)
      |                                  ^~~~
a.cc:33:41: error: expected ';' before 'i'
   33 |         for (int i = -1000; i <= 1000 ++i)
      |                                         ^
      |                                         ;
Language: C++

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

int n, a[110];
set<int> st;
int ab, ad;

inline p(int x, int y) {
    return (x-y)*(x-y);
}

int main()
{
    cin >> n;
    int sum = 0;
    st.clear();
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
        if (st.find(a[i]) == st.end()) sum += a[i];
        st.insert(a[i]);
    }
    int num = st.size();
    if (sum % num) {
        ab = sum/num, ad = ab+1;
    } else {
        ab = sum/num, ad = ab;
    }
    int sum1=0, sum2=0;
    for (int i = 0; i < n; ++ i) {
        sum1 += p(a[i], ab);
        sum2 += p(a[i], ad);
    }
    cout << min(sum1, sum2) << endl;
    return 0;
}


Compiler output:
a.cc:9:8: error: ISO C++ forbids declaration of 'p' with no type [-fpermissive]
    9 | inline p(int x, int y) {
      |        ^
Language: C

#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int t;
    int a[110];
    int sum;
    while(~scanf("%d",&t))
    {
        sum=0;
        for(int i=0;i<t;i++)
        {
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        int ans=0;
        if(sum%t==0)
        {
            sum/=t;
            for(int i=0;i<t;i++)
            {
               ans+=(sum-a[i])*(sum-a[i]);
            }
        }
        else
        {
            sort(a,a+t);
            sum/=t;
            for(int i=0;i<t;i++)
            {
               ans+=(sum-a[i])*(sum-a[i]);
            }
            sum++;int res=0;
            for(int i=0;i<t;i++)
            {
               res+=(sum-a[i])*(sum-a[i]);
            }
            ans=min(res,ans);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Compiler output:
main.c:1:9: fatal error: cstdio: No such file or directory
    1 | #include<cstdio>
      |         ^~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int min(int x,int y)
{
	return x>y?y:x;
}
int main()
{
	int n;
	int a[205];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
	sort(a,a+n);
	int ans=80000;
	int sum;
	for(int i=a[0];i<a[n-1];i++)
	{
		sum=0;
		for(int j=0;j<n;j++)
		{
			sum+=(i-a[j])*(i-a[j]);
		}
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
}

Compiler output:
main.c:3:9: fatal error: iostream: No such file or directory
    3 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include <stdio.h>
int n;
int m;
int ans;
int a[101];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		m+=a[i];
	}
	if(m>0){
		m=(m*10/n+5)/10;
	}else if(m<0){
		m=(m*10/n-5)/10;
	}else if(m==0){
		m=(m*10/n)/10;
	}
	for(int i=0;i<n;i++){
		if(a[i]<m){
			ans+=(m-a[i])*(m-a[i]);
		}else if(a[i]>m){
			ans+=(a[i]-m)*(a[i]-m);
		}
	}
	printf("%d",ans);
	return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:28:18: error: expected '}' at end of input
   28 |         return 0;
      |                  ^
a.cc:7:11: note: to match this '{'
    7 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define itr(i, x) for(auto i = (x).begin(); i != (x).end(); i++)
#define ritr(i, x) for(auto i = (x).rbegin(); i != (x).rend(); i++)
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> an(n);
    for (auto& e: an) cin >> e;

    double sum = (double)accumulate(all(an), 0);
    int ave = (int)round(sum / n);

    int ans = 0;
    for (const auto e: an) {
        int diff = e - ave;
        ans += diff * diff;
    }

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:26: error: 'accumulate' was not declared in this scope
   27 |     double sum = (double)accumulate(all(an), 0);
      |                          ^~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define itr(i, x) for(auto i = (x).begin(); i != (x).end(); i++)
#define ritr(i, x) for(auto i = (x).rbegin(); i != (x).rend(); i++)
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> an(n);
    for (auto& e: an) cin >> e;

    double sum = accumulate(all(an), 0);
    int ave = (int)round(sum / n);

    int ans = 0;
    for (const auto e: an) {
        int diff = e - ave;
        ans += diff * diff;
    }

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:18: error: 'accumulate' was not declared in this scope
   27 |     double sum = accumulate(all(an), 0);
      |                  ^~~~~~~~~~
Language: C++

import java.util.*;

// ABC 43-C
// http://abc043.contest.atcoder.jp/tasks/arc059_a

public class Main {
	
	public static void main (String[] args) throws java.lang.Exception {
	    Scanner in = new Scanner(System.in);
	    
	    int n = in.nextInt();
	    int[] nums = new int[n];
	    int sum = 0;
	    
	    for (int i = 0; i < n; i++) {
	    	nums[i] = in.nextInt();
	    	sum += nums[i];
	    }
	    
	    int avg = sum / n; // Probably need to investigate avg + 1 too
	    
	    System.out.println(Math.min(cost(nums, avg), cost(nums, avg + 1)));
	}
	
	public static int cost(int[] nums, int avg) {
		int cost = 0;
		for (int i = 0; i < nums.length; i++) {
			cost += (nums[i] - avg) * (nums[i] - avg);
		}
		return cost;
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
    6 | public class Main {
      | ^~~~~~
Language: C++

#include <iostream>
#include<algorithm>

using namespace std;

int main()
{	
	int n,i,a[100],sum=0,num=0,res=0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum % n == 0)
		num = sum / n;
	else
		num = sum / n + 1;
	
	for (i = 0; i < n; i++) 
		res += (int)pow((num - a[i]), 2);
	
	
	cout << res << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:29: error: 'pow' was not declared in this scope
   20 |                 res += (int)pow((num - a[i]), 2);
      |                             ^~~
Language: C++

#include <iostream>
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define REP(i, end) FOR(i, 0, end)

using namespace std;

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

	int* p = new int[size];

	REP(i, size)
		cin >> p[i];

	int min, max;
	min = max = p[0];

	int minAmount, maxAmount;    //最小値、最大値がいくつあるか
	minAmount = maxAmount = 1;

	FOR(i, 1, size){
		if(min > p[i]){
			min = p[i];
			minAmount = 0;
		}
		if(min == p[i])  minAmount++;

		if(max < p[i]){
			max = p[i];
			maxAmount = 0;
		}
		if(max == p[i])  maxAmount++;
	}

	int difference = max - min;               //最小値と最大値の差
	int target;                               //揃える数
	if(difference%2 == 0)
		target = difference/2;
	else{
		if(minAmount > maxAmount)  target = difference/2;
		else                       target = difference/2+1;
	}

	target += min;

	int cost = 0;
	REP(i, size)
		cost += (int)pow(p[i] - target, 2);

	cout << cost << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:30: error: 'pow' was not declared in this scope
   49 |                 cost += (int)pow(p[i] - target, 2);
      |                              ^~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N;
	int ave = 0, ans = 0;
	cin >> N;

	vector<int> a(N);

	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		ave += a[i];
	}
	ave = round(double(ave) / double(N));

	for (int i = 0; i < N; i++)
	{
		ans += pow(a[i] - ave, 2);
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: 'round' was not declared in this scope
   19 |         ave = round(double(ave) / double(N));
      |               ^~~~~
a.cc:23:24: error: 'pow' was not declared in this scope
   23 |                 ans += pow(a[i] - ave, 2);
      |                        ^~~
Language: C++

#include <iostream>
#include <algorithm>
#define  MAX 100
using namespace std;
int a[MAX];
int main() {
	int n, minv, maxv;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (i == 0)
		{
			minv = a[i];
			maxv = a[i];
		}
		else
		{
			if (minv > a[i]) minv = a[i];
			if (maxv < a[i]) maxv = a[i];
		}
	}
	long long cost = 0, res = 9223372036854775807;
	for (int j = minv; j <= maxv; ++j)
	{
		if (cost != 0) {
			if (cost < res) res = cost;
			cost = 0;
		}
		for (int i = 0; i < n; ++i)
		{
			cost += (a[i] - j) *  (a[i] - j);
		}
	}
	cout << (res == LONG_MAX ? 0 :res) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:25: error: 'LONG_MAX' was not declared in this scope
   35 |         cout << (res == LONG_MAX ? 0 :res) << endl;
      |                         ^~~~~~~~
a.cc:3:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <algorithm>
  +++ |+#include <climits>
    3 | #define  MAX 100
Language: C++

#include <iostream>
#include <algorithm>
#define  MAX 100
using namespace std;
int a[MAX];
int main() {
	int n, minv, maxv;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (i == 0)
		{
			minv = a[i];
			maxv = a[i];
		}
		else
		{
			if (minv > a[i]) minv = a[i];
			if (maxv < a[i]) maxv = a[i];
		}
	}
	long long cost = 0, res = LONG_MAX;
	for (int j = minv; j <= maxv; ++j)
	{
		if (cost != 0) {
			if (cost < res) res = cost;
			cost = 0;
		}
		for (int i = 0; i < n; ++i)
		{
			cost += (a[i] - j) *  (a[i] - j);
		}
	}
	cout << (res == LONG_MAX ? 0 :res) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:35: error: 'LONG_MAX' was not declared in this scope
   23 |         long long cost = 0, res = LONG_MAX;
      |                                   ^~~~~~~~
a.cc:3:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <algorithm>
  +++ |+#include <climits>
    3 | #define  MAX 100
Language: C

#include<stdio.h>
#include<math.h>
 
int main(void){
    int N, a, i;
	unsigned long sum=0, ss=0, x;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d", &a);
		sum += a;
		ss += a*a;
	}
	x = (int)floor(((double)sum)/N+0.5)
	printf("%lu\n", x*(N*x-2*sum)+ss);
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:13:44: error: expected ';' before 'printf'
   13 |         x = (int)floor(((double)sum)/N+0.5)
      |                                            ^
      |                                            ;
   14 |         printf("%lu\n", x*(N*x-2*sum)+ss);
      |         ~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(void){
    int N, *a, i, j, dif;
    unsigned long sum, min=ULONG_MAX;
    scanf("%d", &N);
    a = (int *)malloc(N*sizeof(int));
    for(i = 0; i < N; i++){
        scanf("%d" a+i);
    }
    for(i = (-100); i <=100 ; i++){
        sum = 0;
        for(j = 0; j < N; j++){
            dif = a[j]-100;
            sum += (unsigned long)(dif*dif);
        }
        if(min > sum) min = sum;
    }
    printf("%lul/n", min);
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:11:19: error: expected ')' before 'a'
   11 |         scanf("%d" a+i);
      |              ~    ^~
      |                   )
Language: C++

n = input()

arr = map(int, raw_input().split())
if n == 1:
	print 0
else:
	mid = (arr[0] + arr[-1])/2
	ans = 0
	for e in arr:
		ans += (e-mid)**2
	print ans


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

#include <iostream>
using namespace std;

int main(void){
	int n, a[100], ans = 0;
	double sum = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	sum /= n;
	sum = round(sum);

	for (int i = 0; i < n; i++){
		ans += pow(((int)sum - a[i]), 2);
	}
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: 'round' was not declared in this scope
   14 |         sum = round(sum);
      |               ^~~~~
a.cc:17:24: error: 'pow' was not declared in this scope
   17 |                 ans += pow(((int)sum - a[i]), 2);
      |                        ^~~
Language: C++

//Be together
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int calcCost(int * array, int size, int y){
   int sum = 0;
   for(int x = 0; x < size; x++){
      sum += ((array[x] - y)*(array[x] - y));
   }
   return sum;
}

int main(){
   int n;
   scanf("%d",&n);
   int * arr = malloc(n*sizeof(int));
   scanf("%d",&arr[0]);
   int min = arr[0];
   int max = arr[0];
   for(int i = 1; i < n; i++){
      scanf("%d",&arr[i]);
      if(arr[i] < min){
         min = arr[i];
      }else if(arr[i] > max){
         max = arr[i];
      }
   }
   
   int lowestCost = 100000;
   int cost = 0;
   while(min <= max){
      cost = calcCost(arr,n,min);
      if(cost < lowestCost){
         lowestCost = cost;
      }
      min++;
   }
   printf("%d\n",lowestCost);
   return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:22: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   17 |    int * arr = malloc(n*sizeof(int));
      |                ~~~~~~^~~~~~~~~~~~~~~
      |                      |
      |                      void*
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
vector<int> v;
long long sum = INT_MAX;
int n;
long long cal(int k) {
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += pow(k - v[i], 2);
  }
  return sum;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a = 0;
    cin >> a;
    v.push_back(a);
  }
  int max_v = *max_element(v.begin(), v.end());
  int min_v = *min_element(v.begin(), v.end());
  for (int i = min_v; i <= max_v; ++i) {
    sum = min(sum, cal(i));
  }
  cout << sum << endl;
  return 0;
}


Compiler output:
a.cc:9:17: error: 'INT_MAX' was not declared in this scope
    9 | long long sum = INT_MAX;
      |                 ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <numeric>
  +++ |+#include <climits>
    7 | using namespace std;
Language: C++

#include<iostream>


using namespace std;

int main() {
	int n,min,max;
	min = 100;
	max = -100;
	cin >> n;
	int *a=new int [n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > max) {
			max = a[i];
		}
		if (a[i] < min) {
			min = a[i];
		}
	}
	
	if (min == max) { cout << 0 << endl; }
	else {
		double mid = (min + max) / 2.0;
		double b, c;
		b = modf(mid, &c);
		if (b != 0) {
			int count, countt;
			count = 0; countt = 0;
			int d = c + 1;
			for (int i = 0; i < n; i++) {
				if (a[i] == c) { count++; }
				if (a[i] == d) { countt++; }
			}
			if (count >= countt) { mid = c; }
			else { mid = d; }
		}

		int ans=0;
		for (int i = 0; i < n; i++) {
			double e = pow((a[i] - mid), 2);
			ans += e;
		}
		cout << ans << endl;
	}


	delete a;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:21: error: 'modf' was not declared in this scope
   26 |                 b = modf(mid, &c);
      |                     ^~~~
a.cc:41:36: error: 'pow' was not declared in this scope
   41 |                         double e = pow((a[i] - mid), 2);
      |                                    ^~~
Language: C++

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define PCC pair<char,char>
#define PIC pair<int,char>
#define Pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PI 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE() freopen("out0.txt","w",stdout)
#define IN scanf
#define OUT(x) cout<<x<<endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second

#include<iostream>

using namespace std;
int main()
{
  // 入力
  int N;
  cin >> N;
  int a[N];
  REP(i,N){
      cin >> a[i];
  } 

  int last_sum = INF;
  FOR(i,-100,101) {
    int sum = 0;
    REP(j, N){
      sum += (i - a[j]) * (i - a[j]);
    }
    if(last_sum < sum) break;
    last_sum = sum;
  }
  OUT(last_sum);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: 'INT_MAX' was not declared in this scope
    6 | #define INF INT_MAX/3
      |             ^~~~~~~
a.cc:46:18: note: in expansion of macro 'INF'
   46 |   int last_sum = INF;
      |                  ^~~
a.cc:34:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   33 | #include<iostream>
  +++ |+#include <climits>
   34 |
Language: C++

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

int main(int argc, char const *argv[]) {
  std::vector<int> v(100),costs(201);
  int n,i,k;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>v[i];
  }

  for (i=-100; i <= 100; i++) {
    for (k = 0; k < n; i++) {
      costs[i+100]+=((i-v[k])*(i-v[k]));
    }
  }

  cout<<*min_element(costs.begin(),costs.end());
  return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:20:10: error: 'min_element' was not declared in this scope
   20 |   cout<<*min_element(costs.begin(),costs.end());
      |          ^~~~~~~~~~~
Language: C++

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

int main(int argc, char const *argv[]) {
  std::vector<int> v(100),costs(201);
  int n,i,k;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>v[i];
  }

  for (i=-100; i <= 100; i++) {
    for (k = 0; k < n; i++) {
      costs[i+100]+=(i-v[k])**2;
    }
  }

  cout<<*costs.min_element();
  return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:16:30: error: invalid type argument of unary '*' (have 'int')
   16 |       costs[i+100]+=(i-v[k])**2;
      |                              ^~
a.cc:20:16: error: 'class std::vector<int>' has no member named 'min_element'
   20 |   cout<<*costs.min_element();
      |                ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

const int INF = 1e9 + 10;

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

  vector<int> an(N);
    
  int l = INF, r = -INF, c;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    an[i] = a;
    l = min(l, an[i]);
    r = max(r, an[i]);
  }

  int s = INF;
  for (int i = l; i <= r; i++) {
    int t = 0;
    for (int j = 0; j < N; j++) {
      t += (an[j] - i) * (an[j] - i); 
    }
    s = min(s, t)
  }

  cout << s << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:18: error: expected ';' before '}' token
   29 |     s = min(s, t)
      |                  ^
      |                  ;
   30 |   }
      |   ~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main() {
	int loop;
	int N;
	int *a;
	int x, y;
	int sum;
	int best;

	scanf("%d", &N);
	a = malloc(sizeof(int)*N);
	best = INT_MAX;
	for (loop = 0; loop < N; loop++) {
		scanf("%d", &a[loop]);
	}
	for (x = -100; x <= 100; x++) {
		sum = 0;
		for (y = 0; y < N; y++) {
			sum += pow(x - a[y], 2);
		}
		if (sum < best)
			best = sum;
	}
	printf("%d", best);

	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:15:16: error: 'INT_MAX' undeclared (first use in this function)
   15 |         best = INT_MAX;
      |                ^~~~~~~
main.c:4:1: note: 'INT_MAX' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
    3 | #include<math.h>
  +++ |+#include <limits.h>
    4 | 
main.c:15:16: note: each undeclared identifier is reported only once for each function it appears in
   15 |         best = INT_MAX;
      |                ^~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main() {
	int loop;
	int N;
	int *a;
	int x, y;
	int sum = 0;
	int best = 0;

	scanf("%d", &N);
	a = malloc(sizeof(int)*N);

	for (loop = 0; loop < N; loop++) {
		scanf("%d", &a[loop]);
	}
	for (x = 1, x <= 100; x++) {
		for (y = 0; y < N; y++) {
			sum += pow(x - a[y], 2);
		}
		if (sum < best)
			best = sum;
	}
	

	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:19:34: error: expected ';' before ')' token
   19 |         for (x = 1, x <= 100; x++) {
      |                                  ^
      |                                  ;
Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000

int rec(int A[],int N,int k){
    int sum = 0;
    REP1(i,N) sum += (A[i]-k)*(A[i]-k);
    return sum;
}

int rec2(int A[],int N){
    int mini = INF;
    for (int i = -100; i <= 100; i++) {
        mini = min(rec(A,N,i),min);
    }
}

int main(){
    INT(N);
    A[100];
    REP1(i,N) INPUT(A[i]);
    cout << rec2(A,N) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int rec2(int*, int)':
a.cc:24:19: error: no matching function for call to 'min(int, <unresolved overloaded function type>)'
   24 |         mini = min(rec(A,N,i),min);
      |                ~~~^~~~~~~~~~~~~~~~
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,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:36: note:   no known conversion for argument 2 from '<unresolved overloaded function type>' to 'const int&'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |                         ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:24:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |         mini = min(rec(A,N,i),min);
      |                ~~~^~~~~~~~~~~~~~~~
a.cc:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | }
      | ^
a.cc: In function 'int main()':
a.cc:30:5: error: 'A' was not declared in this scope
   30 |     A[100];
      |     ^
Language: C++

#include <iostream>
#include <vector>
#include <cstdio>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(void){
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	ll sum = 1e9;
	for (int i = -100; i <= 100 ; ++i){
		ll tmp = 0;
		rep(j, n){
			tmp += pow((i - v[j]), 2);
		}
		sum = min(tmp, sum);
	}
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:32: error: 'pow' was not declared in this scope
   16 |                         tmp += pow((i - v[j]), 2);
      |                                ^~~
Language: C++

#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(void){
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	ll sum = 1e9;
	for (int i = -100; i <= 100 ; ++i){
		ll tmp = 0;
		rep(j, n){
			tmp += pow((i - v[j]), 2);
		}
		sum = min(tmp, sum);
	}
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'll' was not declared in this scope
   11 |         ll sum = 1e9;
      |         ^~
a.cc:13:19: error: expected ';' before 'tmp'
   13 |                 ll tmp = 0;
      |                   ^~~~
      |                   ;
a.cc:15:25: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   15 |                         tmp += pow((i - v[j]), 2);
      |                         ^~~
      |                         tm
a.cc:15:32: error: 'pow' was not declared in this scope
   15 |                         tmp += pow((i - v[j]), 2);
      |                                ^~~
a.cc:17:17: error: 'sum' was not declared in this scope
   17 |                 sum = min(tmp, sum);
      |                 ^~~
a.cc:17:27: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   17 |                 sum = min(tmp, sum);
      |                           ^~~
      |                           tm
a.cc:19:17: error: 'sum' was not declared in this scope
   19 |         cout << sum << endl;
      |                 ^~~
Language: C++

#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	long long int s = 0;
	int t;
	vector<int> x;
	for (int i = 0; i < n; i++) {
		cin >> t;
		x.push_back(t);
	}
	int m = INT_MAX;
	for (int i = -100; i < 101; i++) {
		m = min(m, accumulate(x.begin(), x.end(), 0, [&i](long int ss, int x) {return ss += (int)(pow(i - x, 2)); }));
	}
	cout << m << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: 'INT_MAX' was not declared in this scope
   18 |         int m = INT_MAX;
      |                 ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 | 
a.cc: In lambda function:
a.cc:20:107: error: 'pow' was not declared in this scope
   20 |                 m = min(m, accumulate(x.begin(), x.end(), 0, [&i](long int ss, int x) {return ss += (int)(pow(i - x, 2)); }));
      |                                                                                                           ^~~
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  int min = INT_MAX;
  for(int p = 0; p <= 1; p++){
    int ave = sum / n + p;
    int ans = 0;
    for(int i = 0; i < n; i++){
      ans += (a[i] - ave) * (a[i] - ave);
    }
    if(min > ans) min = ans;
  }
  cout << min << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'INT_MAX' was not declared in this scope
   14 |   int min = INT_MAX;
      |             ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<vector>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

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

int main() {
	int a,e,f;
	cin >> a;
	int b[a];
	int c = 0;
	double d=0,g=a;
	while (a > c) {
		cin >> b[c];
		c = c + 1;
	}
	c = 0;
	while (a > c) {
		d = d + b[c];
		c = c + 1;
	}
	d = d / g;
	if (d>=0)f = d + 0.5;
	else d = d*(-1), f = d + 0.5, f = f*(-1);
	c = 0;
	while (a > c) {
		e = e + (b[c] - f)*(b[c] - f);
		c = c + 1;
	}
	cout << e << endl;
　　return 0;
}

Compiler output:
a.cc:29:1: error: extended character 　 is not valid in an identifier
   29 | 　　return 0;
      | ^
a.cc:29:1: error: extended character 　 is not valid in an identifier
a.cc: In function 'int main()':
a.cc:29:1: error: '\U00003000\U00003000return' was not declared in this scope
   29 | 　　return 0;
      | ^~~~~~~~~~