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

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    int ans = INT_MAX;
    for (int same = -100; same <= 100; same++)
    {
        int sum = 0;
        rep(i,n) {
            sum += (a[i]-same)*(a[i]-same);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:15: error: 'INT_MAX' was not declared in this scope
   21 |     int ans = INT_MAX;
      |               ^~~~~~~
a.cc:10:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    9 | #include <map>
  +++ |+#include <climits>
   10 | using namespace std;
Language: C++

#include <iostream>

using namespace std;

const int N = 1e6 + 5;
const int inf = 1e9 + 7;

int a[N];

int main() {
	int n, cost = inf, mn = inf, mx = -inf;
	cin >> n;
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}
	for (int i = mn; i <= mx; i ++) {
		int sum = 0;
		for (int j = 0; j < n; j ++) {
			sum += (a[j] - i) * (a[j] - i);
		}
		if (sum < cost) {
			cost = sum;
			ans = i;
		}
	}
	cout << cost << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |                         ans = i;
      |                         ^~~
      |                         abs
Language: C++

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

// int main(){
//     int N, temp;
//     cin >> N;
//     vector<int> A;
//     for(int i = 0; i < N; i++){
//         cin >> temp;
//         A.push_back(temp);
//     }
//     // 配列だとaccumulateを使用できないため、vectorを使用した。
//     double average = accumulate(A.begin(), A.end(), 0) / double(A.size());
//     average = round(average); //平均を四捨五入する。
    
//     int ans = 0;
//     for(int i = 0; i < N; i++){
//         ans += (average - A[i])*(average - A[i]);
//     }
//     cout << ans << endl;
// }


int main(){
    int N, temp;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[N];
    }
    int minCost = 1000000;
    for(int i = -100; i < 101; i++){
        for(int n = 0; n < N; n++){
            temp += (i - A[n]) * (i - A[n]);
        }
        if(temp < minConst) minCost = temp;
        temp = 0;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:19: error: 'minConst' was not declared in this scope; did you mean 'minCost'?
   39 |         if(temp < minConst) minCost = temp;
      |                   ^~~~~~~~
      |                   minCost
Language: C++

#include <bits/stdc++.h>
using namespace std;
int a[105],n;
int is_ok(int x)
{
	int s=0;
	for(int i=1; i<=n; i++)
		s+=(a[i]-x)*(a[i]-x);
	return s;
}
int main()
{
	int i,r=0,l=105,iv=1e9,ans=0;
	cin>>n;
	for(i=1; i<=n; i++)
	{
		cin>>a[i];
		r=max(r,a[i]);
		l=min(l,a[i]);
	}
	sort(a+1,a+n+1); 
	for(i=l; i<=r; i++)
		if(is_ok(i)<iv)
		{
			v=is_ok(i);
			ans=i;
		}
		
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:25: error: 'v' was not declared in this scope; did you mean 'iv'?
   25 |                         v=is_ok(i);
      |                         ^
      |                         iv
Language: C

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	int a[n+1];
	int maxv;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<=n;i++)
		if(a[i]<0)
			a[i]=0;
	maxv=a[1];
	for(i=1;i<=n;i++)
	{
		if(a[i]>maxv)
		{
			maxv=a[i];
		}
	}
	cout<<maxv;
}

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;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

 
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int ans=MOD;
    for(int i=-100;i<=100;i++){
        int sum=0;
        rep(j,n){
            sum+=pow(a[j]-i,2);
        }
        ans=min(ans,sum)
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:25: error: expected ';' before '}' token
   19 |         ans=min(ans,sum)
      |                         ^
      |                         ;
   20 |     }
      |     ~
Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
  int n,i,j,min=1000000000,cost;
  cin>>n;
  int list[n];
   for(i=0;i<n;i++)
     cin>>list[i];
  sort(list,list+n);
  for(i=list[0];i<=list[n-1];i++)
  {   
      cost=0
     for(j=0;j<n;j++)
     {
       cost+=pow(i-list[j],2);
     }
    if(cost<min)
       min=cost;
  }
  cout<<min;
  return 0;
}
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:15:13: error: expected ';' before 'for'
   15 |       cost=0
      |             ^
      |             ;
   16 |      for(j=0;j<n;j++)
      |      ~~~     
a.cc:16:21: error: expected ';' before ')' token
   16 |      for(j=0;j<n;j++)
      |                     ^
      |                     ;
Language: C++

n = int(input())
a = list(map(int, input().split()))

ans = 10000000
for i in range(-100, 101):
  sm = 0
  for x in a:
    sm += (x-i) ** 2
  ans = min(ans, sm)
  
print(ans)

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

#include <iostream>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#pragma warning(disable: 4996)

int main()
{
	int N;
	int ret;

	ret = scanf("%d", &N);

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		ret = scanf("%d", &v[i]);
	}

	int sum = accumulate(v.begin(),v.end(),0);
    double average = (double)sum/(double)N;
    int average_int = round(average);

	int result = 0;
	for (int i = 0; i < N; i++) {
		result += pow((v[i] - average_int), 2);
	}
	////	sort(v.begin(), v.end(), std::greater<int>());
	//sort(v.begin(), v.end());

	//int result = INT_MAX, temp;
	//for (int i = v[0]; i <= v[N - 1]; i++) {
	//	temp = 0;
	//	for (int j = 0; j < N; j++) {
	//		temp += (v[j] - i)*(v[j] - i);
	//	}
	//	if (result > temp) {
	//		result = temp;
	//	}
	//}
	printf("%d\n", result);
	return 0;
//	std::cout << "Hello World!\n"; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:23: error: 'round' was not declared in this scope
   25 |     int average_int = round(average);
      |                       ^~~~~
a.cc:29:27: error: 'pow' was not declared in this scope
   29 |                 result += pow((v[i] - average_int), 2);
      |                           ^~~
Language: C++

#include <iostream>

#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>

using namespace std;

//#define _DBG

int main()
{
	uint32_t N;
	int ret;

#ifdef _DBG
	ret = scanf_s("%d", &N);
#else
	ret = scanf("%d", &N);
#endif

	vector<int> v(N);
	for (size_t i = 0; i < N; i++) {
#ifdef _DBG
		ret = scanf_s("%d", &v[i]);
#else
		ret = scanf("%d", &v[i]);
#endif
	}
	//	sort(v.begin(), v.end(), std::greater<int>());
	sort(v.begin(), v.end());
	int32_t result = INT_MAX,temp;
	for (int32_t i = v[0]; i <= v[N-1]; i++) {
		temp = 0;
		for (uint32_t j = 0; j < N; j++) {
			temp += (v[j] - i)*(v[j] - i);
		}
		if (result > temp) {
			result = temp;
		}
	}
	printf("%d\n", result);
	return 0;
//	std::cout << "Hello World!\n"; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'uint32_t' was not declared in this scope
   14 |         uint32_t N;
      |         ^~~~~~~~
a.cc:7:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    6 | #include <algorithm>
  +++ |+#include <cstdint>
    7 | 
a.cc:20:28: error: 'N' was not declared in this scope
   20 |         ret = scanf("%d", &N);
      |                            ^
a.cc:33:26: error: 'INT_MAX' was not declared in this scope
   33 |         int32_t result = INT_MAX,temp;
      |                          ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <algorithm>
  +++ |+#include <climits>
    7 | 
a.cc:35:17: error: 'temp' was not declared in this scope; did you mean 'tm'?
   35 |                 temp = 0;
      |                 ^~~~
      |                 tm
a.cc:36:30: error: expected ';' before 'j'
   36 |                 for (uint32_t j = 0; j < N; j++) {
      |                              ^~
      |                              ;
a.cc:36:38: error: 'j' was not declared in this scope
   36 |                 for (uint32_t j = 0; j < N; j++) {
      |                                      ^
Language: C++

#include <iostream>

#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	uint32_t N;
	int ret;

	ret = scanf_s("%d", &N);

	vector<int> v(N);
	uint32_t sum = 0;
	for (size_t i = 0; i < N; i++) {
		ret = scanf_s("%d", &v[i]);
	}
//	sort(v.begin(), v.end(), std::greater<int>());
	sort(v.begin(), v.end());

	int32_t result = 100,temp;
	int32_t pos = 0;

	for (int32_t i = v[0]; i < v[N-1]; i++) {
		temp = 0;
		for (uint32_t j = 0; j < N; j++) {
			temp += (v[j] - i)*(v[j] - i);
		}
		if (result > temp) {
			result = temp;
		}
	}

	printf("%d\n", result);
	return 0;
//	std::cout << "Hello World!\n"; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'uint32_t' was not declared in this scope
   12 |         uint32_t N;
      |         ^~~~~~~~
a.cc:7:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    6 | #include <algorithm>
  +++ |+#include <cstdint>
    7 | 
a.cc:15:30: error: 'N' was not declared in this scope
   15 |         ret = scanf_s("%d", &N);
      |                              ^
a.cc:15:15: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   15 |         ret = scanf_s("%d", &N);
      |               ^~~~~~~
      |               scanf
a.cc:18:17: error: expected ';' before 'sum'
   18 |         uint32_t sum = 0;
      |                 ^~~~
      |                 ;
a.cc:30:30: error: expected ';' before 'j'
   30 |                 for (uint32_t j = 0; j < N; j++) {
      |                              ^~
      |                              ;
a.cc:30:38: error: 'j' was not declared in this scope
   30 |                 for (uint32_t j = 0; j < N; j++) {
      |                                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a[100100];
int main(){
  int n;cin>>n;
  f(i,1,n) cin>>a[i];
  sort(a+1,a+1+n);
  cout<<a[(n+1)>>1];}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'i' was not declared in this scope
    6 |   f(i,1,n) cin>>a[i];
      |     ^
a.cc:6:3: error: 'f' was not declared in this scope
    6 |   f(i,1,n) cin>>a[i];
      |   ^
Language: C++

#include <bits/stdc++.h>

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;

int main(){
    int N;
    int ave = 0,ans = 0;
    cin >> N;
    int a[200];
    rep(i,N) cin >> a[i];
    ave = accumulate(a,a+N);
    ave = round((double)ave/N);
    rep(i,N) ans += (a[i]-ave)*(a[i]-ave);

    
    
    cout << ans;
    //printf("%.15lf",ans);
    cout << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:21: error: no matching function for call to 'accumulate(int [200], int*)'
   21 |     ave = accumulate(a,a+N);
      |           ~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

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

#define ll long long
int main()
{
	int n,a,mn,ans,as;
	cin>>n;
	vector<int>v;
	while(n--)
	{
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	for(int i=-1000;i<=1000;i++)
	{
		ans=0;
		for(int j=0;j<v.size();j++)
		{
			ans=ans+((i-v[j])*(i-v[j]));
		}
		if(i==0)
		{
			mn=ans;
		}2

		else
		{
			mn=min(ans,mn);
		}
	}
	cout<<mn<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:19: error: expected ';' before 'else'
   26 |                 }2
      |                   ^
      |                   ;
   27 | 
   28 |                 else
      |                 ~~~~
Language: C

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

int main ()
{
    long long int sum= 0,count= 0;
    int n,i;
    cin >> n;
    long long int ans = 1e18;
    vector<int> arr(n);
    for (i = 0 ; i<n ;i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    sum = sum /n;
    for ( i = 0 ; i < n ;i++)
    {
        count += pow(arr[i]-sum,2);
    }
    ans = min (count,ans);
    count = 0;
     for ( i = 0 ; i < n ;i++)
    {
        count += pow(arr[i]-sum-1,2);
    }
    ans = min (count,ans);
    count = 0;
     for ( i = 0 ; i < n ;i++)
    {
        count += pow(arr[i]-sum+1,2);
    }
    ans = min (count,ans);
    cout << ans <<endl;
    }


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>
#define long long ll
using namespace std;
int main() {
    init();
   ll n,c=0,mi=INT_MAX;
   cin>>n;
   ll arr[n];
   for(int i=0;i<n;i++)
    cin>>arr[i];
   for(int i=-100;i<=100;i++){
       for(int o=0;o<n;o++){
        c=pow(abs(i-arr[o]),2)+c;
    }
    mi=min(c,mi);
    c=0;
   }
   cout<<mi;
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'init' was not declared in this scope; did you mean 'int'?
    5 |     init();
      |     ^~~~
      |     int
a.cc:6:4: error: 'll' was not declared in this scope
    6 |    ll n,c=0,mi=INT_MAX;
      |    ^~
a.cc:7:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |    cin>>n;
      |         ^
      |         yn
a.cc:8:6: error: expected ';' before 'arr'
    8 |    ll arr[n];
      |      ^~~~
      |      ;
a.cc:10:10: error: 'arr' was not declared in this scope
   10 |     cin>>arr[i];
      |          ^~~
a.cc:13:9: error: 'c' was not declared in this scope
   13 |         c=pow(abs(i-arr[o]),2)+c;
      |         ^
a.cc:13:21: error: 'arr' was not declared in this scope
   13 |         c=pow(abs(i-arr[o]),2)+c;
      |                     ^~~
a.cc:15:5: error: 'mi' was not declared in this scope; did you mean 'i'?
   15 |     mi=min(c,mi);
      |     ^~
      |     i
a.cc:15:12: error: 'c' was not declared in this scope
   15 |     mi=min(c,mi);
      |            ^
a.cc:18:10: error: 'mi' was not declared in this scope
   18 |    cout<<mi;
      |          ^~
Language: C++

#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    int a[n];
    long long ans = 1000000000;
    REP(i, n)
    {
        cin >> a[i];
    }
    for (int i = -100; i <= 100; i++)
    {
        long long tmp = 0;
        REP(j, n)
        {
            tmp += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:44:25: error: expected '}' at end of input
   44 |     cout << ans << endl;
      |                         ^
a.cc:26:1: note: to match this '{'
   26 | {
      | ^
Language: C++

//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int n, ans, p;
double sum;
int arr[105];

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    sum = 0;
    forn(i,n){
        cin >> arr[i];
        sum += arr[i];
    }
    sum = sum/n;
    sum += 0.5;
    p = (int)sum;

    ans = 0;

    forn(i,n){
        ans += ( (arr[i]-p) * (arr[i]-p) );
    }

    int temp = 0;

    forn(i,n){
        temp += ( (arr[i]-p-1) * (arr[i]-p-1) );
    }

    ans = min(ans,temp);

    int temp = 0;

    forn(i,n){
        temp += ( (arr[i]-p+1) * (arr[i]-p+1) );
    }

    ans = min(ans,temp);

    cout << ans << "\n";

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:9: error: redeclaration of 'int temp'
   52 |     int temp = 0;
      |         ^~~~
a.cc:44:9: note: 'int temp' previously declared here
   44 |     int temp = 0;
      |         ^~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n];
    //int av=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }   
    int ans=1000000;
    int sum=0;
    for(int i=-100;i<=100;i++){//a
        for(int j=0;j<n;j++){//an
        sum+=(a[j]-i)*(a[j]-i);
        }
        if(sum<ans){
            ans=sum;
            sum=0;
        }
    }
    cout<<ans;


Compiler output:
a.cc: In function 'int main()':
a.cc:39:15: error: expected '}' at end of input
   39 |     cout<<ans;
      |               ^
a.cc:18:1: note: to match this '{'
   18 | {
      | ^
Language: C++

#include <iosream>

int main()
{
  int N;
  
  std::cin >> N;
  
  int a[N];
  int i;
  int sum_a = 0;
  int sum_aa = 0;
  
  for (i = 0; i < N; i++) {
    std::cin >> a[i];
    sum_a += a[i];
    sum_aa += a[i] * a[i];
  }
  
  int min = 40000;
  
  for (i = -100; i <= 100; i++) {
    int tmp = sum_aa - 2 * i * sum_a + N * i * i;
    if (min > tmp) min = tmp;
  }
  
  std::cout << min;
  return 0;
}
  

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

#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 int a[n];
 int i;
 int sum=0;
 for(i=0;i<n;i++)
 {
 cin>>a[i];
 sum+=a[i];
 }
 float m=1.0;
 m*=sum;
 m/=n;
 float x=m-floor(m);
 if(x>=0.5)
 {
 	int p=m+1;
 	int ans1=0;
 	for(i=0;i<n;i++)
 	ans+=pow(abs(a[i]-p),2);
 //	cout<<ans<<endl;
 	 p=m;
 	int ans2=0;
 	for(i=0;i<n;i++)
 	ans+=pow(abs(a[i]-p),2);
 	cout<<min(ans1,ans2)<<endl;
 }
 else
 {
 	 		int p=m+1;
 	int ans1=0;
 	for(i=0;i<n;i++)
 	ans+=pow(abs(a[i]-p),2);
 //	cout<<ans<<endl;
 	 p=m;
 	int ans2=0;
 	for(i=0;i<n;i++)
 	ans+=pow(abs(a[i]-p),2);
 	cout<<min(ans1,ans2)<<endl;
 }
 return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'ans' was not declared in this scope; did you mean 'ans1'?
   24 |         ans+=pow(abs(a[i]-p),2);
      |         ^~~
      |         ans1
a.cc:29:9: error: 'ans' was not declared in this scope; did you mean 'ans2'?
   29 |         ans+=pow(abs(a[i]-p),2);
      |         ^~~
      |         ans2
a.cc:37:9: error: 'ans' was not declared in this scope; did you mean 'ans1'?
   37 |         ans+=pow(abs(a[i]-p),2);
      |         ^~~
      |         ans1
a.cc:42:9: error: 'ans' was not declared in this scope; did you mean 'ans2'?
   42 |         ans+=pow(abs(a[i]-p),2);
      |         ^~~
      |         ans2
Language: C++

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	int minimum = 100;
	int maximum = -100;
	for(int i = 0; i < n; i++){
		cin >> a.at(i);
		minimum = min(minimum, a.at(i));
		maximum = max(maximum, a.at(i));
	}
	// cout << "maximum: " << maximum << endl;
	// cout << "minimum: " << minimum << endl;
	long long cost = 4000000001;
	for(int i = minimum; i <= maximum; i++){
		int sum = 0;
		for(auto j : a){
			sum += (i - j) * (i - j);
		}
		cost = min(cost, sum);
	}
	cout << cost << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:27: error: no matching function for call to 'min(long long int&, int&)'
   24 |                 cost = min(cost, sum);
      |                        ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:24:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |                 cost = min(cost, sum);
      |                        ~~~^~~~~~~~~~~
/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:
/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:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |                 cost = min(cost, sum);
      |                        ~~~^~~~~~~~~~~
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] arg){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];
    double sum = 0;
    double ans = 0;
    double totalAns = 0;
    for(int i = 0 ;i < N;i++){
      a[i] = sc.nextInt();
    }
    for(int i = 0 ;i < N;i++){
      sum += a[i];
    }
    sum = Math.round(sum/N);
    for(int j = 0;j < N; j++){
      if(a[j] != sum){
        ans = Math.pow((sum - a[j]),2);
        totalAns += ans;
      }
    }
    System.out.println((int)totalAns);
  }


Compiler output:
Main.java:25: error: reached end of file while parsing
  }
   ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int q,w=1000000000;
  for(int i=-100;i<101;i++){
    q=0;
    for(j=0;j<n;j++){
      q+=(a[j]-i)*(a[j]-i);
    }
    w=min(w,q);
  }
  cout << w;
}


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

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int q,w=1000000000;
  for(int i=-100;i<101;i++){
    q=0
    for(j=0;j<n;j++){
      q+=(a[j]-i)*(a[j]-i);
    }
    w=min(w,q);
  }
  cout << w;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:8: error: expected ';' before 'for'
   12 |     q=0
      |        ^
      |        ;
   13 |     for(j=0;j<n;j++){
      |     ~~~ 
a.cc:13:13: error: 'j' was not declared in this scope
   13 |     for(j=0;j<n;j++){
      |             ^
Language: Java

import java.util.*;

public class Main {
  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 < n; i++) {
      a[i] = sc.nextInt();
    }
    int ans = Integer.MAX_VALUE;
    for(int t = -100; t <= 100; t++) {
      int c = 0;
      for(int i = 0; i < n; i++) {
        c += ((a[i] - t) * (a[i] - t));
      }
      ans = Math.min(ans, c);
    }
    System.out.println(ans);
  }

Compiler output:
Main.java:20: error: reached end of file while parsing
  }
   ^
1 error
Language: C++

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

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    for (int i=0;i<N;i++){
        cin>>a.at(i);
    }
    int cost=0;
    for (int i=0;i<N;i++){
        cost += (100-a.at(i))*(100-a.at(i));
    }
    for(int j=-100;j<101;j++){
        for (int i=0;i<N;i++){
            cost += (100-a.at(i))*(100-a.at(i));
        }
        if(cost>= (j-a.at(i))*(j-a.at(i))){
            cost = (j-a.at(i))*(j-a.at(i));
        }
    }
    cout<<cost<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:27: error: 'i' was not declared in this scope
   19 |         if(cost>= (j-a.at(i))*(j-a.at(i))){
      |                           ^
Language: C++

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

int main(){
  int n, a[100], b[201], s, ans;
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> a[i];
  ans = 0;
  for(int i = 0; i < n; i++)
    ans = ans + a[i] * a[i];
  for(int i = -100; i < 101; i++){
    s = 0;
    for(int j = 0; j < n; j++){
      s = s + (a[j] - i) * (a[j] - i);
      if(s > ans) break;
    }
    ans = min(ans, s);
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:2: error: expected '}' at end of input
   20 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

int main(){
  int n, a[100], b[201], s, ans;
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> a[i];
  for(i = -100; i < 101; i++){
    s = 0;
    for(int j = 0; j < n; i++){
      s = s + (a[j] - i) * (a[j] - i);
    }
    b[i] = s;
  }
  ans = b[0];
  for(int i = 0; i < n; i++)
    ans = min(ans, b[i]);
  cout << ans << endl;
}

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

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	ans := 1000000000
	for i := -100; i <= 100; i++ {
		tmp := 0
		for j := 0; j < n; j++ {
			x := a[j] - i
			tmp += x * x
		}
		if tmp < ans {
			ans = tmp
		}
	}
	fmt.Println(ans)
}


Compiler output:
a.cc:1:1: error: 'package' does not name a type
    1 | package main
      | ^~~~~~~
Language: C++

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

int main(){
  int N; cin>>N;
  int sum=0;
  
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    sum+=a.at(i);
  }
  
  int x=sum/N;
  int y=sum%N;
  if(2*y>N){
    x++;
  }
  
  int cost=0;
  for(int i=0;i<N;i++){
    cost+=(a.at(i)-x)*(a.at(i)-x);
  }
  
  cout<<cost<<endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:25:20: error: expected '}' at end of input
   25 |   cout<<cost<<endl;
      |                    ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,c=0,avg,count=0;
  cin>>N;
  vector<int>B(N);for(int i=0;i<N;i++){cin>>B[i];c+=B[i];}
  sort(B.begin(),B.end());
  c%2==0?avg=c/N:avg=c/N+1;
  for(int i=0;i<N;i++){
    count+=(
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:1: error: expected primary-expression before '}' token
   11 | }
      | ^
a.cc:10:13: error: expected ')' before '}' token
   10 |     count+=(
      |            ~^
      |             )
   11 | }
      | ~            
a.cc:11:2: error: expected '}' at end of input
   11 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#define N 102
using namespace std;
int n;
int a[N];
int main() {
  cin>>n;
  for (int i=0; i < n; ++i) {
  	cin>>a[i];
  }
  int ans=INT_MAX;
  for (int i= 0; i < n; ++i) {
  	int det=0;
    for (int j = 0; j < n; ++j) {
      det += (a[i]-a[j])*(a[i]-a[j]);
    }
    ans=min(ans, det);
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:11: error: 'INT_MAX' was not declared in this scope
   15 |   int ans=INT_MAX;
      |           ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include <algorithm>
  +++ |+#include <climits>
    6 | #define N 102
Language: Java

import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] a = sc.nextInt();
   for(int i=0;i<N;i++) a[i]=sc.nextInt();
   
   int ans=100*100*100;
   int tmp=0;
   for(int i=-100;i<100;i++)
   {
     tmp=0;
     for(int k=0;k<N;k++)
     {
       tmp+= (a[k]-i)*(a[k]-i);
     }
     if(tmp<ans) ans=tmp;
   }
   System.out.println(ans);
 }
}

Compiler output:
Main.java:7: error: incompatible types: int cannot be converted to int[]
   int[] a = sc.nextInt();
                       ^
1 error
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> vec;
  int tmp;
  for(int i=0; i<n; i++){
    cin >> tmp;
    vec.push_back(tmp);
  }
  int ans = 100000000;
  for(int i=-100; i<=100; i++){
    tmp = 0;
    for(auto v : vec){
      tmp += pow((v-i),2);
    }
    ans = min(ans,tmp);
  }
  cout << ans << endl;
}

Compiler output:
a.cc:1:10: fatal error: bits/stdc+.h: No such file or directory
    1 | #include <bits/stdc+.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

#define DEBUG1  false
#define DEBUG2  false
#define DEBUG3  false
#define DEBUG4  false
#define DEBUG5  false

int cost(int x, int y)
{
#if DEBUG3
    std::cout << "DEBUG3: r: " << std::pow(x - y, 2) << " x: " << x << " y: " << y << std::endl;
#endif
    return std::pow(x - y, 2);
}

int cost(std::vector<int>& A, int y)
{
    int c = 0;
    for (auto itr = A.begin(); itr != A.end(); ++itr)
    {
        c += cost(*itr, y);
#if DEBUG4
    std::cout << "DEBUG4: c: " << c << std::endl;
#endif
    }
    return c;
}

int middle(int l, int r)
{
    return (l - r) / 2 + r;
}

int main(void)
{
    int N;
    std::cin >> N;
#if DEBUG1
    std::cout << "DEBUG1: N: " << N << std::endl;
#endif

    std::vector<int> A;
    while (N)
    {
        int a;
        std::cin >> a;
        A.push_back(a);
        N--;
    }
#if DEBUG2
    std::cout << "DEBUG2: A:";
    for (auto itr = A.begin(); itr != A.end(); ++itr)
    {
        std::cout << " " << *itr;
    }
    std::cout << std::endl;
#endif

    int L = *std::min_element(A.begin(), A.end());
    int R = *std::max_element(A.begin(), A.end());
    int M = middle(L, R);
    std::map<int, int> costs;
    costs[L] = cost(A, L);
    costs[R] = cost(A, R);
    int c = (costs[L] < costs[R] ? costs[R] : costs[L]);
    while (true)
    {
        if (!costs.count(M))
        {
            costs[M] = cost(A, M);
            if (costs[M] < c)
            {
                c = costs[M];
            }
        }
        else
        {
            break;
        }
        if (costs[L] < costs[R])
        {
            R = M;
            M = middle(L, M);
        }
        else
        {
            L = M;
            M = middle(M, R);
        }
    }
#if DEBUG5
    for (auto itr = costs.begin(); itr != costs.end(); ++itr)
    {
        std::cout << "DEBUG5: " << itr->first << " " << itr->second << std::endl;
    }
#endif
    std::cout << c << std::endl;

    return 0;
}

Compiler output:
a.cc: In function 'int cost(int, int)':
a.cc:17:17: error: 'pow' is not a member of 'std'
   17 |     return std::pow(x - y, 2);
      |                 ^~~
Language: C++

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

int main(void) {
  int n; scanf("%d", &n);
  int arr[n], ans = 123456;
  forn(i, n) scanf("%d", &arr[i]);
  for (int i = -100; i <= 100; i++) {
    i64 temp = 0;
  	for (int j = 0; j < n; j++) {
      temp += abs(i-arr[j]) * abs(i-arr[j]);
    }
    ans = min(ans, temp);
  }
  printf("%lld\n", ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: 'i' was not declared in this scope
    7 |   forn(i, n) scanf("%d", &arr[i]);
      |        ^
a.cc:7:3: error: 'forn' was not declared in this scope; did you mean 'fork'?
    7 |   forn(i, n) scanf("%d", &arr[i]);
      |   ^~~~
      |   fork
a.cc:9:5: error: 'i64' was not declared in this scope
    9 |     i64 temp = 0;
      |     ^~~
a.cc:11:7: error: 'temp' was not declared in this scope; did you mean 'tm'?
   11 |       temp += abs(i-arr[j]) * abs(i-arr[j]);
      |       ^~~~
      |       tm
a.cc:13:20: error: 'temp' was not declared in this scope; did you mean 'tm'?
   13 |     ans = min(ans, temp);
      |                    ^~~~
      |                    tm
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans;
  ans = 10000000;
  cin >> n;
  vector<int>a(n);
  vector<int>b(201)
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=-100;i<101;i++){
    for(int j=0;j<n;j++) b.at(i) += (a.at(j)-i)*(a.at(j)-i);
  }
  sort(b.begin(),b.end());
  cout << b.at(0) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: expected ',' or ';' before 'for'
    9 |   for(int i=0;i<n;i++){
      |   ^~~
a.cc:9:15: error: 'i' was not declared in this scope
    9 |   for(int i=0;i<n;i++){
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  int cnt1=vec_sum(v)/n;
  int cnt2=ans1+1;
  int ans1=0,ans2=0;
  rep(i,n){
    ans1+=(int)pow(abs(v[i]-cnt1),2);
    ans2+=(int)pow(abs(v[i]-cnt2),2);
  }
  cout<<min(ans1,ans2)<<endl;
}
///////////////////////////

Compiler output:
a.cc: In function 'int main()':
a.cc:75:12: error: 'ans1' was not declared in this scope
   75 |   int cnt2=ans1+1;
      |            ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
const int INF=1001001001;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    int n;
    cin >> n;
    float a[n];
    float cnt = 0.0;
    rep(i, n)
    {
        cin >> a[i];
        cnt+=a[i];
    }
    cnt = round(cnt / n);
    ll ans = 0;
    rep(i,n){
        ans += pow(a[i]-cnt,2.0);
    }
    cout << ans << endl;z
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:25: error: 'z' was not declared in this scope
   28 |     cout << ans << endl;z
      |                         ^
Language: Java

import java.util.*;
import java.util.Arrays;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int min = 0;
        int max = 0;
        int sum = 0;
        int ans = 10000000000000;

        for(int i = 0 ; i < N ; i++){
            a[i] = sc.nextInt();
            min = a[0];
            max = a[0];

            if(min > a[i]){
                min = a[i];
            }

            if(max < a[i]){
                max = a[i];
            }
        }

        for(int j = min ; j <= max ; j ++){
            sum = 0;
            
            for (int i = 0 ; i < N ; i++){
                sum = sum + (a[i] - j) * (a[i] - j) ;
            }

            if(ans > sum){
                ans = sum;
            }
        }

        System.out.println(ans);
    }
}

Compiler output:
Main.java:13: error: integer number too large
        int ans = 10000000000000;
                  ^
1 error
Language: C++

#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int N:
    cin >> N;
    vector<int> a;
    for (int i  = 0; i < N; i++) {
        int _a;
        cin >> _a;
        a.push_back(_a);
    }

    int min_cost = 1000000000;
    for (int y = -100; y <= 100; y++) {
        int cost = 0;
        for (int i = 0; i < N; i++) {
            cost += (a[i] - y) * (a[i] - y);
        }
        min_cost = min(cost, min_cost);
    }
    cout << min_cost << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:10: error: found ':' in nested-name-specifier, expected '::'
   20 |     int N:
      |          ^
      |          ::
a.cc:20:9: error: 'N' has not been declared
   20 |     int N:
      |         ^
a.cc:21:9: error: qualified-id in declaration before '>>' token
   21 |     cin >> N;
      |         ^~
a.cc:23:26: error: 'N' was not declared in this scope
   23 |     for (int i  = 0; i < N; i++) {
      |                          ^
a.cc:32:29: error: 'N' was not declared in this scope
   32 |         for (int i = 0; i < N; i++) {
      |                             ^
Language: C++

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

int main()
{
  long long int n, d, sumA = 0, sumB = 0, midA, midB = 1e7;
  cin >> n;
  vector<long long int> v;
  for (long long int i = 0; i < n; i++)
  {
    cin >> d;
    v.push_back(d);
  }
  v.resize(n);
  if (n == 1)
  {
    cout << 0;
    return 0;
  }
  sort(v.begin(), v.end());
  midA = (v[0] + v[n - 1]) / 2;
  if ((v[0] + v[n - 1]) % 2)
    midB = (v[0] + v[n - 1]) / 2 + 1;
  for (long long int i = 0; i < n; i++)
  {
    sumA += pow(midA - v[i], 2);
    if (midB != 1e7)
      sumB += pow(midB - v[i], 2);
  }
  cout << ((midB == 1e7) ? sumA : min(sumA, sumB)) ;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   22 |   sort(v.begin(), v.end());
      |   ^~~~
      |   sqrt
Language: C++

#include <iostream>
#include <cmath>
using namespace std;
int main () 
{
int n;
cin>>n;
int a[102];
long long sum=0;
for (int i=1;i<=n;i++){
	cin>>a[i];
	sum+=a[i];
}
long long j=round(double(sum)/n);
int o=0;
for (int i=1;i<=n;i++){
	o+=(a[i]-j)*(a[i]-j);
}
cout<<o;


Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: expected '}' at end of input
   19 | cout<<o;
      |         ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

#include <iostream>
using namespace std;
int main () 
{
int n;
cin>>n;
int a[n];
int sum=0;
for (int i=1;i<=n;i++){
	cin>>a[i];
	sum+=a[i];
}
int j=round(sum/n);
int o=0;
for (int i=1;i<=n;i++){
	o+=(a[i]-j)*(a[i]-j);
}
cout<<o;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:7: error: 'round' was not declared in this scope
   13 | int j=round(sum/n);
      |       ^~~~~
Language: Java

import java.util.*;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int max = 0;
		int min = 0;
		int ans = 100;
		ArrayList<Integer> ary = new ArrayList<Integer>();
		
		for(int i = 0; i < N; i ++) {
			ary.add(Integer.parseInt(sc.next()));
		}
		max = Collections.max(ary);
		min = Collections.min(ary);
		
		for(int i = min; i <= max; i++) {
			int x = 0;
			for(int y = 0;y < ary.size(); y++) {
				x += (ary.get(y) - i) * (ary.get(y) - i);
			}
			ans = Math.min(cost, cost_);
		}
		System.out.println(ans);
	}
}

Compiler output:
Main.java:23: error: cannot find symbol
			ans = Math.min(cost, cost_);
			               ^
  symbol:   variable cost
  location: class Main
Main.java:23: error: cannot find symbol
			ans = Math.min(cost, cost_);
			                     ^
  symbol:   variable cost_
  location: class Main
2 errors
Language: C++

#include <iostream>
using namespace std;
int n;
int a[210];
int minu=0, maxi=0;
int minute() {
	int min = 1000;
	for (int i = 0; i < n; i++) {
		if (a[i] < min) {
			min = a[i];
		}
	}
	return min;
}

int maximum() {
	int max = -1000;
	for (int i = 0; i < n; i++) {
		if (a[i] > max) {
			max = a[i];
		}
	}
	return max;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	minu = minute();
	maxi = maximum();
	//cout << minu << " " << maxi << endl;
	double ans = 0;
	double min = 10000000;

	if (minu == maxi) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = minu; i <= maxi; i++) {
		for (int j = 0; j < n; j++) {
			ans += pow((double)a[j] - i, 2.0);
		}
		if (ans < min) min = ans;
		ans = 0;
	}
	cout << min << endl;
	return 0;
}

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

using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  a.push_back(-1777);
  sort(a.begin(),a.end());
  int s=0;
  int c=0;
  for(int i=1;i<=n;i++){
    if(a[i-1]!=a[i]){
      s+=a[i];
      c++;
    }
  }
  if(s%c>=c/2){
    s=s/c+1;
  }
  else {
    s/=c;
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    ans+=(a[i]-s)*(a[i]-s);
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
    4 |   cin>>n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:5:3: error: 'vector' was not declared in this scope
    5 |   vector<int> a(n);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> a(n);
      |          ^~~
a.cc:7:10: error: 'a' was not declared in this scope
    7 |     cin>>a[i];
      |          ^
a.cc:9:3: error: 'a' was not declared in this scope
    9 |   a.push_back(-1777);
      |   ^
a.cc:10:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |   sort(a.begin(),a.end());
      |   ^~~~
      |   short
a.cc:29:3: error: 'cout' was not declared in this scope
   29 |   cout<<ans<<endl;
      |   ^~~~
a.cc:29:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:29:14: error: 'endl' was not declared in this scope
   29 |   cout<<ans<<endl;
      |              ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  a.push_back(-1777);
  sort(a.begin(),a.end());
  int s=0;
  int c=0;
  for(int i=1;i<=n;i++){
    if(a[i-1]!=a[i]){
      s+=a[i];
      c++;
    }
  }
  s/=c;
  int ans=0;
  for(int i=1;i<=n;i++){
    ans+=(a[i]-s)*(a[i]-s)
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:27: error: expected ';' before '}' token
   23 |     ans+=(a[i]-s)*(a[i]-s)
      |                           ^
      |                           ;
   24 |   }
      |   ~
Language: C++

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

int main() {
	double n;
	cin >> n;
	vector<double> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	double sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}
	int ave = round(sum / n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += abs(a[i] - ave)*abs(a[i] - ave);
	}
	cout << ans << endl;

	return 0;
}

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

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

int main(){
  int n;
  cin >> n;
  int sum;
  vector<int>q;
  for(int i=0; i<n; ++i){
    int a;
    cin >> a;
    q.push_back(a);
    sum += a;
  }
  int mean=int(sum/n+0.5);
  
  int res =0;
  int abs1=0;
  for(int i=0; i<n; ++i)
    
    abs1 = abs(q[i]-mean);
    int b = abs1 * abs1;
    res += abs1;}
  cout << res << endl;
}
  

Compiler output:
a.cc:24:3: error: 'cout' does not name a type
   24 |   cout << res << endl;
      |   ^~~~
a.cc:25:1: error: expected declaration before '}' token
   25 | }
      | ^