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

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

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

	vector<int> x(n);
	for (int i = 0; i < n; ++i) {
		cin >> x.at(i);
	}

	int min = *min_element(x.cbegin(), x.cend());
	int max = *max_element(x.cbegin(), x.cend());

	int load = max+1 - min;
	vector<int> v(load);

	for (int i = 0; i < load; ++i) {
		v.at(i) = min + i;
	}

	vector<int> consumption(load);
	for (int i = 0; i < load; ++i) {
		int kuso = 0;
		for (auto t : x) {
			kuso += pow(t - v.at(i), 2);
		}
		consumption.at(i) = kuso;
	}

	int result = *min_element(consumption.cbegin(), consumption.cend());

	cout << result;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:33: error: 'pow' was not declared in this scope
   29 |                         kuso += pow(t - v.at(i), 2);
      |                                 ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i= 1;i<=(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


int main(){
  int n;
  cin >>n;
  vector <int> x(n+1);
  rep(i,n)cin>>x.at(i);
  ll sum =0;
  ll  ans = 0;

  //x.at(0)には0
  rep(i,n){
    sum =0;
    rep(j,n){
      sum +=(x.at(j)-i)*(x.at(j)-i);
    }
  if(i = 1){
    ans = sum;
    continue;
  }
  ans =max(sum,ans);
  }
  cout<<ans<<endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:28:19: error: expected '}' at end of input
   28 |   cout<<ans<<endl;
      |                   ^
a.cc:8:11: note: to match this '{'
    8 | int main(){
      |           ^
Language: Java

import java.util.Scanner;


public class CopyOfMain3 {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());	//N人
        int[] xs = new int[N];
        for(int i = 0; i < N; i++) {

        	xs[i] = Integer.parseInt(sc.next());
        }
        quick_sort(xs, 0, xs.length-1);

        int sum = 0;
        int current = 0;
        boolean flg = true;
        for(int i = xs[0]; i < xs[N-1]; i++) {
        	for(int j = 0; j < N; j++) {
        		int pos = (xs[j]-i) * (xs[j]-i);
        		current += pos;
        	}
        	if (current < sum || flg) {
        		sum = current;
        		flg = false;
        	}
        	current = 0;
        }
        System.out.println(sum);
	}


	static void quick_sort(int[] d, int left, int right) {
        if (left>=right) {
            return;
        }
        int p = d[(left+right)/2];
        int l = left, r = right, tmp;
        while(l<=r) {
            while(d[l] < p) { l++; }
            while(d[r] > p) { r--; }
            if (l<=r) {
                tmp = d[l]; d[l] = d[r]; d[r] = tmp;
                l++; r--;
            }
        }
        quick_sort(d, left, r);  // ピボットより左側をクイックソート
        quick_sort(d, l, right); // ピボットより右側をクイックソート
    }
}

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

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


int asc(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}

int power(double a,double b) 
{
	return (int)pow((a - b), 2);
}

int rounding(double a) 
{
	int b = (int)a;
	return ((a - b) < 0.5) ? b : b + 1;
}

int average(int *a,double b) 
{
	double c = 0;
	for (int i = 0; i != b; i++)
	{
		c += a[i];
	}

	return rounding(c / b);
}

int main()
{
	int n, x[100]{ NULL };
	scanf("%d", &n);
	for (int i = 0; i != n; i++) 
	{
		scanf("%d", &x[i]);
	}

	qsort(x, n, sizeof(int), asc);

	int a = average(x, n);
	long long b = 0;

	for (int i = 0; i != n; i++) 
	{
		b += power(x[i], a);
	}

	printf("%lld", b);

	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:34:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   34 |         int n, x[100]{ NULL };
      |                      ^
main.c:38:30: error: 'x' undeclared (first use in this function)
   38 |                 scanf("%d", &x[i]);
      |                              ^
main.c:38:30: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,r,s;
 
cin >> n;
  vector<int> vec(n);
for (int i = 0; i < n; i++) {
  cin >> vec.at(i);
  r=r+vec.at(i);
}

r=std::round(r/n);

s=0
  
for (int i = 0; i < n; i++) {
  s=s+(r-vec.at(i))*(r-vec.at(i));
}
cout << s << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:4: error: expected ';' before 'for'
   16 | s=0
      |    ^
      |    ;
   17 | 
   18 | for (int i = 0; i < n; i++) {
      | ~~~ 
a.cc:18:17: error: 'i' was not declared in this scope
   18 | for (int i = 0; i < n; i++) {
      |                 ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int N = 105;
int x[N];
int main()
{
	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i)
		scanf("%d", &x[i]);

	int c1 = 0, c2 = 0;

	for (int i = 1; i <= n; ++i)
	{
		c1 = c1 + x[i];
		c2 = c2 + x[i] * x[i];
	}

	if (c1 % n == 0)
	{
		printf("%d\n", c2 - c1 * c1 / n);
	}
	else
	{
		int a1 = floor(1.0 * c1 / n), a2 = ceil(1.0 * c1 / n);
		a1 = a1 - c1 / n, a2 = a2 - c1 / n;

		printf("%d\n", min(n * a1 * a1 + c2 - c1 * c1 / n, n * a2 * a2 + c2 - c1 * c1 / n));
		
	}


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:26: error: 'floor' was not declared in this scope
   31 |                 int a1 = floor(1.0 * c1 / n), a2 = ceil(1.0 * c1 / n);
      |                          ^~~~~
a.cc:32:35: error: 'a2' was not declared in this scope; did you mean 'a1'?
   32 |                 a1 = a1 - c1 / n, a2 = a2 - c1 / n;
      |                                   ^~
      |                                   a1
Language: C

#include<stdio.h>
int main()
{
    int i,a,b=0,c;
    scanf("%d",&i);
    for(a=1;a<=i;a++)
    {
       scanf("%d",&c);
       b=b+(c-i)*(c-i);
    }
    printf("%d",b);a
return 0;
}


Compiler output:
main.c: In function 'main':
main.c:11:21: error: expected ';' before 'return'
   11 |     printf("%d",b);a
      |                     ^
      |                     ;
   12 | return 0;
      | ~~~~~~
Language: Java

import java.util.*;
class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
			int [] b = new int[a];
      //int c = sc.nextInt();



			int sum = 0;
      for(int i = 0;i < a; i++){
				b[i] = sc.nextInt();
				sum += b[i];
			}

			int pos = 0;
			if(sum%a >= a(float)/2)pos = (sum/a) + 1;
			else pos = sum/a;
			
			sum = 0;
			for(int i = 0;i < a; i++){

				sum += (b[i] - pos)*(b[i] - pos);

			}
			System.out.println(sum);

    }


    public static long factorial(long n){
      if(n == 0){
        return new Long(1);
       }
       System.out.println(n * factorial(n-1));

      return n * factorial(n-1);
    }
}


Compiler output:
Main.java:18: error: '.class' expected
			if(sum%a >= a(float)/2)pos = (sum/a) + 1;
			                   ^
1 error
Language: C++

// ConsoleApplication85.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include<iomanip>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int a[105];
int main()
{
	int n;
	double aa = 0;
	double as=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		aa += a[i];
	}
	sort(a, a + n);
	aa /= n;
	if (aa - floor(aa) >= 0.5)
	{
		aa = floor(aa) + 1;
	}
	else
	{
		aa = floor(aa);
	}
	for (int i = 0; i < n; i++)
	{
		as += (a[i] - aa) * (a[i] - aa);
	}
	cout << setprecision(0)<<fixed<<as << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:24:18: error: 'floor' was not declared in this scope
   24 |         if (aa - floor(aa) >= 0.5)
      |                  ^~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
int main(){
  int N, P, sum, i;
  int X[100];
  int min = INT_MAX;

  scanf("%d", &N);
  for(i=0; i<N; i++) scanf("%d", &X[i]);

  for(P=0; P<X[N-1]; P++){
    sum = 0;
    for(i=0; i<N; i++) sum += (X[i] - P)*(X[i] - P);
    if(sum < min) min = sum;
  }

  printf("%d\n", min);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:6:13: error: 'INT_MAX' undeclared (first use in this function)
    6 |   int min = INT_MAX;
      |             ^~~~~~~
main.c:3:1: note: 'INT_MAX' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
    2 | #include<stdlib.h>
  +++ |+#include <limits.h>
    3 | int main(){
main.c:6:13: note: each undeclared identifier is reported only once for each function it appears in
    6 |   int min = INT_MAX;
      |             ^~~~~~~
Language: Java

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main2 {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		ArrayList<Integer> inputs = new ArrayList<Integer>();
		for(int n =0; n<a; n++) {
			int ele = scanner.nextInt();
			inputs.add(ele);
		}
		
		List<Integer> answers = new ArrayList<Integer>();
		for(int xi =1; xi<=100 ; xi++) {
			answers.add(min(xi,inputs));
		}
		
		List<Integer> sorted = answers.stream().sorted((o1,o2)->o1.intValue()-o2.intValue()).collect(Collectors.toList());
		System.out.println(sorted.get(0));
	}
	
	public static int min(int in,ArrayList<Integer> inputs) {
		int ans = 0;
		for(Integer ins: inputs) {
			ans += (ins-in)*(ins-in);
		}
		return ans;
	}
	
}

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

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

int main() {
  // 入力
  int N;
  cin >> N ;
  
  vector<unsigned long int> X;
  unsigned long int X_tmp;
  for (int i=0; i<N; i++) {
    cin >> X_tmp;
    X.push_back(X_tmp);
  }

  sort(X.begin(), X.end());


  int P;
  unsigned long int sum = ULONG_MAX;
  unsigned long int sum_tmp = 0;
  for (unsigned long int i=X[0]; i<X[N-1]; i++) {
    P = i;
    sum_tmp = 0;
    for (int j=0; j<N; j++) {
      sum_tmp += (X[j] - P)*(X[j] - P);
    }
    if (sum_tmp < sum) {
      sum = sum_tmp;
    }
  }

  cout << sum << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:27: error: 'ULONG_MAX' was not declared in this scope
   22 |   unsigned long int sum = ULONG_MAX;
      |                           ^~~~~~~~~
a.cc:4:1: note: 'ULONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 | using namespace std;
Language: C++

#include <cmath>
#include <cstdlib>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  vector<int> X(n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    X[i] = x;
  }

  sort(X.begin(), X.end());

  int head = X[0];
  int tail = X[n-1];
  int min_p = 0;
  int min_cost = numeric_limits<int>::max();
  for (int p = head; p <= tail; p++) {
    int cost = 0;
    for (int i = 0; i < n; i++) {
      cost += (X[i] - p) * (X[i] - p);
    }
    if (cost < min_cost) {
      min_cost = cost;
      min_p = p;
    }
  }

  cout << min_cost << endl;

  return 0;
}


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

// Contest.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int* r = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> r[i];
    }
    int sum = 0;
    int min = INT_MAX;
    for (int i = 1; i <= 100; i++) {
        for (int j = 0; j < n; j++) {
            sum += pow(r[j] - i, 2);
        }
        min = std::min(min, sum);
        sum = 0;
    }
    cout << min;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:15: error: 'INT_MAX' was not declared in this scope
   17 |     int min = INT_MAX;
      |               ^~~~~~~
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 | using namespace std;
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i=0;i<n;i++) {
    cin >> x.at(i);
  }
	
   if(n%2=0) {
     int j=0;
     for(int i=0;i<n;i++) {
       j+=n/2-x.at(i);
     }
     cout << j << endl;
   }
  else {
    for(int i=0;i<n;i++) {
       j+=n+1/2-x.at(i);
     }
    j+=1;
    cout << j << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:8: error: lvalue required as left operand of assignment
   12 |    if(n%2=0) {
      |       ~^~
a.cc:21:8: error: 'j' was not declared in this scope
   21 |        j+=n+1/2-x.at(i);
      |        ^
a.cc:23:5: error: 'j' was not declared in this scope
   23 |     j+=1;
      |     ^
Language: C++

#include<iostream>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	int x[101];
	for (int i(0); i < n; i++) {
		cin >> x[i];
	}
	//最小の座標と最大の座標を求める
	int min(x[0]);
	int max(x[0]);
	for (int i(1); i < n; i++) {
		if (min > x[i])min = x[i];
		if (max < x[i])max = x[i];
	}
	//中間の座標を求める
	int mid = (min + max) / 2;
	//重心の位置を求める
	int total(0);
	for (int i(0); i < n; i++) {
		total += x[i];
	}
	int center = total / n;
	//重心の位置から中間の座標までの体力の総和を求める
	int power_total(100000);
	int tmp_num;
	if (mid<center) {
		for (int i(mid-1); i <=center+1; i++) {
			int tmp_power_total(0);
			for (int j(0); j <n; j++) {
				tmp_power_total += pow(x[j]-i,2);
			}
			if (power_total > tmp_power_total)power_total = tmp_power_total;
		}
	}
	else {
		for (int i(center - 1); i <= mid + 1; i++) {
			int tmp_power_total(0);
			for (int j(0); j < n; j++) {
				tmp_power_total += pow(x[j] - i, 2);
			}
			if (power_total > tmp_power_total)power_total = tmp_power_total;
		}
	}
	cout << power_total << endl;
	return 0;
}

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

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  int ans = 1001001001;
  rep(i,100) {
    ni = i+1;
    int tot=0;
    rep(j,n) {
      tot+= (x[j]-ni)*(x[j]-ni);
    }
    ans = min(ans,tot);
  }
  cout << ans;
}


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

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

int main(){
    int n;
    cin >> n;
    vector<int> x;
    for(int i = 0; i < n; ++i) {
        int buffer;
        cin >> buffer;
        x.emplace_back(buffer);
    }

    sort(x.begin(), x.end());

    int mn = x[0];
    int mx = x[n-1];

    int ans = INT_MAX;

    for(int i = mn; i < mx; ++i) {
        int sum = 0;
        for(auto p : x) {
            sum += pow((p - i), 2);
        }

        ans = min(ans, sum);
    }

    cout << ans;
}

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

import java.util.Scanner;


public class CopyOfMain3 {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());	//N人
        int[] xs = new int[N];
        for(int i = 0; i < N; i++) {

        	xs[i] = Integer.parseInt(sc.next());
        }
        quick_sort(xs, 0, xs.length-1);

        int sum = 1000000000;
        int current = 0;
        for(int i = xs[0]; i < xs[N-1]; i++) {
        	for(int j = 0; j < N; j++) {
        		int pos = (xs[j]-i) *  (xs[j]-i);
        		current += pos;
        	}
        	if (current < sum) sum = current;
        	current = 0;
        }
        System.out.println(sum);
	}


	static void quick_sort(int[] d, int left, int right) {
        if (left>=right) {
            return;
        }
        int p = d[(left+right)/2];
        int l = left, r = right, tmp;
        while(l<=r) {
            while(d[l] < p) { l++; }
            while(d[r] > p) { r--; }
            if (l<=r) {
                tmp = d[l]; d[l] = d[r]; d[r] = tmp;
                l++; r--;
            }
        }
        quick_sort(d, left, r);  // ピボットより左側をクイックソート
        quick_sort(d, l, right); // ピボットより右側をクイックソート
    }
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  
  
  rep(i, N){
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }

  
  sort(Y.begin(), Y.end());
  int start_point = Y.at(0);
  int end_point = Y.at(N-1);
  
  int Sum_of_X = 0;
  int position = start_point;
  
  rep(i, N){
    Sum_of_X += (X.at(i));
  }

  
  while(-2*Sum_of_X + N*(2*position + 1) < 0){
    position++;
  }
  
  ll answer = 0;
  rep(i, N){
    answer += (X.at(i) - position)*(X.at(i) - position);
  }
  
  cout << answer;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'cin' was not declared in this scope
   13 |   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:14:3: error: 'vector' was not declared in this scope
   14 |   vector<int> X(N), Y(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:14:10: error: expected primary-expression before 'int'
   14 |   vector<int> X(N), Y(N);
      |          ^~~
a.cc:18:12: error: 'X' was not declared in this scope
   18 |     cin >> X.at(i);
      |            ^
a.cc:19:5: error: 'Y' was not declared in this scope
   19 |     Y.at(i) = X.at(i);
      |     ^
a.cc:23:8: error: 'Y' was not declared in this scope
   23 |   sort(Y.begin(), Y.end());
      |        ^
a.cc:23:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   23 |   sort(Y.begin(), Y.end());
      |   ^~~~
      |   short
a.cc:31:18: error: 'X' was not declared in this scope
   31 |     Sum_of_X += (X.at(i));
      |                  ^
a.cc:41:16: error: 'X' was not declared in this scope
   41 |     answer += (X.at(i) - position)*(X.at(i) - position);
      |                ^
a.cc:44:3: error: 'cout' was not declared in this scope
   44 |   cout << answer;
      |   ^~~~
a.cc:44:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

using namespace std;

int main() {
  int n;
  vector<int> x;

  cin >> n;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    x.push_back(tmp);
  }

  int min = *min_element(x.begin(), x.end());
  int max = *max_element(x.begin(), x.end());
  int res = 0;

  for (int i = 0; i < n; i++) {
    res += pow(x[i] - min, 2);
  }

  for (int crt = min + 1; crt <= max; crt++) {
    int sum = 0;

    for (int i = 0; i < n; i++) {
      sum += pow(x[i] - crt, 2);
    }

    if (sum < res) {
      res = sum;
    }
  }

  cout << res << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:12: error: 'pow' was not declared in this scope
   25 |     res += pow(x[i] - min, 2);
      |            ^~~
a.cc:32:14: error: 'pow' was not declared in this scope
   32 |       sum += pow(x[i] - crt, 2);
      |              ^~~
Language: C++

#include<bits/stdc++.h>

using namespace std;
int n;
vector<int> x(101);
int main(){
  cin >> n;
  int sum=0;
  for(int i=0; i<n ;i++){
    cin >> x[i];
    sum += x[i];
  }
  sum = sum/n;
  int a = sum;
  int b = sum+1;
  sum=0;
  int sum1=0;
  for(int i=0; i<n;i++){
    sum += (a-x[i])(a-x[i]);
    sum1 += (b-x[i])(b-x[i]);
  }
  cout << min(sum, sum1);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:20: error: expression cannot be used as a function
   19 |     sum += (a-x[i])(a-x[i]);
      |            ~~~~~~~~^~~~~~~~
a.cc:20:21: error: expression cannot be used as a function
   20 |     sum1 += (b-x[i])(b-x[i]);
      |             ~~~~~~~~^~~~~~~~
Language: C++

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

int n, a[110], res;

int main(){
  cin >> n;
  for (int i=1; i<=n; ++i) cin >> a[i];
  res = 100*100*100;
  for (int i=1; i<=100; ++i){
  	tmp = 0;
    for (auto aa : a) tmp+= (aa-i)*(aa-i);
    res = min(res, tmp);
  }
  cout << res;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   11 |         tmp = 0;
      |         ^~~
      |         tm
Language: C++

#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  ll ans=INF;
  for(int i=1;i<=100;i++){
    ll cu=0;
    for(int j=0;j<n;j++){
      cu+=abs(a[j]-i)*abs(a[j]-i);
    }
    ans=min(ans,cu);
  }
  COUT8ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:3: error: 'COUT8ans' was not declared in this scope
   54 |   COUT8ans);
      |   ^~~~~~~~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,ans=0,sum=0;
  cin >> n;
  vint v(n);
	rep(i,n){
		cin >> v[i];
    sum += v[i];
	}

  //昇順
  sort(v.begin(),v.end());

  int h,ans1=inf;
  // if(n%2==0){
  //   h = n/2;
  // }
  // else{
  //   h = n/2 +1;
  // }
  //
  // h=sum/n;
  // h=13;
  for(int j=1;j<=v[n-1];j++){
    rep(i,n){
      ans += pow(abs(v[i]-j),2);
    }
    if(ans<ans1){
      ans1=ans;
    }
    ans = 0;
  }


  pri(ans1);

}

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

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
double a[10005];
int n,t;
double x,maxx = 0,L,Lmid,rmid,r;
double cal(double x)
{

    double ans=0;
    for(int i=1;i<=n;i++){
       ans+=(a[i]-x)*(a[i]-x);
    }
    return ans;
}
int main()
{

        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            scanf("%lf",&a[i]);
        L = 1,r = 100;
        for(int i=1;i<=100;i++){//三分算法寻找最小值
            Lmid = L + (r-L)/3;
            rmid = r - (r-L)/3;
            if(cal(Lmid) <= cal(rmid))
                r = rmid;
            else
                L = Lmid;
        }
        int xx=ceil(L);
        printf("%.0f\n",cal(xx));

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:16: error: 'ceil' was not declared in this scope
   32 |         int xx=ceil(L);
      |                ^~~~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,ans=0,sum=0;
  cin >> n;
  vint v(n);
	rep(i,n){
		cin >> v[i];
    sum += v[i];
	}

  //昇順
  std::sort(v.begin(),v.end());

  int h,ans1=inf;
  // if(n%2==0){
  //   h = n/2;
  // }
  // else{
  //   h = n/2 +1;
  // }
  //
  // h=sum/n;
  // h=13;
  for(int j=1;j<=v[n-1];j++){
    rep(i,n){
      ans += pow(abs(v[i]-j),2);
    }
    if(ans<ans1){
      ans1=ans;
    }
    ans = 0;
  }


  pri(ans1);

}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:8: error: 'sort' is not a member of 'std'; did you mean 'sqrt'?
   31 |   std::sort(v.begin(),v.end());
      |        ^~~~
      |        sqrt
Language: C++

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

ll cost(vector<int> &X, ll p){
    ll res =0;
    int N = X.size();
    for(int i=0; i<N; i++){
        res += pow(X.at(i) - p, 2);
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<ll> X(N);
    int x;
    int x_min = 101;
    int x_max = 0;
    for(int i=0; i<N; i++){
        cin >> x;
        X.at(i) = x;
        x_min = min(x_min, x);
        x_max = max(x_max, x);
    }

    ll ans = pow(N * 100, 2);
    for(int i=x_min; i<x_max; i++){
        ans = min(ans, cost(X, i));
    }

    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:29: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<long long int>'
   30 |         ans = min(ans, cost(X, i));
      |                             ^
a.cc:5:22: note: in passing argument 1 of 'll cost(std::vector<int>&, ll)'
    5 | ll cost(vector<int> &X, ll p){
      |         ~~~~~~~~~~~~~^
Language: C++

#include <iosteam>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
  int N, X[1001], P, ans = 0;
  cin >> N;
  for (int i = 0; i <= N; i++)
    cin >> X[i];
  sort (X + 1, X + N + 1);
  P = (X[1] + X[N]) / 2;
  for (int j = 0; j <= N; j++)
    ans += (X[j] - P) * (X[j] - P);
  cout << ans;
  return 0;
}
  
  

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

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

int main() {
  int n;
  cin >> n;
  vector<int> x;
  rep(i,n) cin >> x[i];
  int ans = 1001001001;
  rep(i,100) {
    i++;
    int tot=0;
    rep(j,n) {
      tot+= (x[j]-i)*(x[j]-i);
    }
    ans = min(ans,tot);
  }
  cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:43: error: expected ')' before ';' token
    3 | #define rep(i,n) for(int i = 0; i < n; i++;)
      |                     ~                     ^
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i,n) cin >> x[i];
      |   ^~~
a.cc:3:44: error: expected primary-expression before ')' token
    3 | #define rep(i,n) for(int i = 0; i < n; i++;)
      |                                            ^
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i,n) cin >> x[i];
      |   ^~~
a.cc:3:43: error: expected ')' before ';' token
    3 | #define rep(i,n) for(int i = 0; i < n; i++;)
      |                     ~                     ^
a.cc:11:3: note: in expansion of macro 'rep'
   11 |   rep(i,100) {
      |   ^~~
a.cc:3:44: error: expected primary-expression before ')' token
    3 | #define rep(i,n) for(int i = 0; i < n; i++;)
      |                                            ^
a.cc:11:3: note: in expansion of macro 'rep'
   11 |   rep(i,100) {
      |   ^~~
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >> v(i);
  }
  vector<int> ans(n);
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ans(i)+=(v.at(j)-v.at(i))*(v.at(j)-v.at(i));
    }
  }
  sort(ans.begin(),ans.end());
  cout << ans(0) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:13: error: no match for call to '(std::vector<int>) (int&)'
    9 |     cin >> v(i);
      |            ~^~~
a.cc:14:10: error: no match for call to '(std::vector<int>) (int&)'
   14 |       ans(i)+=(v.at(j)-v.at(i))*(v.at(j)-v.at(i));
      |       ~~~^~~
a.cc:18:14: error: no match for call to '(std::vector<int>) (int)'
   18 |   cout << ans(0) << endl;
      |           ~~~^~~
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> x;
  rep(i,n) cin >> x[i];
  int ans = 1001001001;
  rep(i,100) {
    i++;
    int tot=0;
    rep(j,n) {
      tot+= (x[j]-p)*(x[j]-p);
    }
    ans = min(ans,tot);
  }
  cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:19: error: 'p' was not declared in this scope
   15 |       tot+= (x[j]-p)*(x[j]-p);
      |                   ^
Language: Java

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

		int n = scan.nextInt();

		int[] x = new int[n];

		for(int i = 0; i < n; i++) {
			x[i] = scan.nextInt();
		}

		int ans = Integer.MAX_VALUE;
		for(int i = 1; i <= 100; i++) {
			int temp =0;
			for ( int j = 0; j < n; j++) {
				temp += (int)Math.pow((x[j] - i), 2);
			}
			if(temp < ans)
				ans = temp;
		}
		System.out.println(ans);
	}
}

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

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

int main() {
  int n;
  cin >> n;
  vector<int> x;
  rep(i,n) cin >> x[i];
  int ans = 1001001001;
  rep(i,100) {
    i++;
    int tot=0;
    rep(j,n) {
      tot+= (x[j]-p)*(x[j]-p);
    }
    ans = min(ans,tot);
  }
  cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:43: error: expected ')' before ';' token
    3 | #define rep(i,n) for(int i = 0; i < n; i++;)
      |                     ~                     ^
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i,n) cin >> x[i];
      |   ^~~
a.cc:3:44: error: expected primary-expression before ')' token
    3 | #define rep(i,n) for(int i = 0; i < n; i++;)
      |                                            ^
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i,n) cin >> x[i];
      |   ^~~
a.cc:3:43: error: expected ')' before ';' token
    3 | #define rep(i,n) for(int i = 0; i < n; i++;)
      |                     ~                     ^
a.cc:11:3: note: in expansion of macro 'rep'
   11 |   rep(i,100) {
      |   ^~~
a.cc:3:44: error: expected primary-expression before ')' token
    3 | #define rep(i,n) for(int i = 0; i < n; i++;)
      |                                            ^
a.cc:11:3: note: in expansion of macro 'rep'
   11 |   rep(i,100) {
      |   ^~~
Language: C++

#include<iostream>
#include<cstdlib>
#define int long long
using namespace std;
int ans=INT_MAX,x[105],n;
signed main(){
	int n;cin>>n;
	for(int i=1;i<=n;++i)cin>>x[i];
	for(int i=1;i<=100;++i){
		int tmp=0;
		for(int j=1;j<=n;++j){
			tmp+=(i-x[j])*(i-x[j]);
		}
		ans=min(ans,tmp);
	}cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc:5:9: error: 'INT_MAX' was not declared in this scope
    5 | int ans=INT_MAX,x[105],n;
      |         ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<cstdlib>
  +++ |+#include <climits>
    3 | #define int long long
a.cc: In function 'int main()':
a.cc:8:35: error: 'x' was not declared in this scope
    8 |         for(int i=1;i<=n;++i)cin>>x[i];
      |                                   ^
a.cc:12:33: error: 'x' was not declared in this scope
   12 |                         tmp+=(i-x[j])*(i-x[j]);
      |                                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0;i<N;i++) cin >> vec.at(i);
  
  vector<int> dis(101);
  
  int Xmin = *min_element(X.begin(),X.end());
  int Xmax = *max_element(X.begin(),X.end());
  int m = 0;
  
  for (int p = Xmin; p <= Xmax; p++){
    int sum = 0;
    for (int i = 0; i < X.size(); i++){
      sum += (X.at(i) - p)*(X.at(i) - p);
    }
    dis.at(m) = sum;
    m++;
  }
  
  sort(dis.begin(),dis.end(),greater<int>());
  
  cout << dis.at(0) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:34: error: 'vec' was not declared in this scope
    8 |   for (int i = 0;i<N;i++) cin >> vec.at(i);
      |                                  ^~~
Language: C++

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

int main(){
    int N;
    cin >> N;
    vector<int> V(N);
    for(int i = 0; i < N; i++){
        cin >> V.at(i);
    }
    //入力終了
    vector<int> W(N); //総和用配列
    int K;
    for(int i = 0; i < N; i++){
        K = for(int j = 0; j < N; j++){
            W.at(i) + V.at(j);
        }
        W.at(i) = K;
        K = 0;
    }
    sort(W.begin(), W.end());
    cout << W.at(0) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:13: error: expected primary-expression before 'for'
   15 |         K = for(int j = 0; j < N; j++){
      |             ^~~
a.cc:15:28: error: 'j' was not declared in this scope
   15 |         K = for(int j = 0; j < N; j++){
      |                            ^
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0;i<N;i++) cin >> vec.at(i);
  
  vector<int> dis(101);
  
  int Xmin = *min_element(X.begin(),X.end());
  int Xmax = *max_element(X.begin(),X.end());
  int m = 0;
  
  for (int p = Xmin; p <= Xmax; p++){
    for (int i = 0; i < X.size(); i++){
      int sum = 0;
      sum += (X.at(i) - p)*(X.at(i) - p);
    }
    dis.at(m) = sum;
    m++;
  }
  
  sort(dis.begin(),dis.end(),greater<int>());
  
  cout << dis.at(0) << endl;
}
  
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:8:34: error: 'vec' was not declared in this scope
    8 |   for (int i = 0;i<N;i++) cin >> vec.at(i);
      |                                  ^~~
a.cc:21:17: error: 'sum' was not declared in this scope
   21 |     dis.at(m) = sum;
      |                 ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main (){
    int N,X[100],maxim;
    cin >> N;

    for(int i = 0;i<N;i++){
        int a;
        cin >> a;
        X[i] = a;
        maxim = max(maxim,a);
    }
    int minP = INT_MAX;
    for (size_t i = 0; i < maxim; i++)
    {
        int sum = 0;
        for (size_t j = 0; j < N; j++)
        {
            sum+=(X[j]-i)*(X[j]-i);
        }
        minP = min(minP,sum);
    }
    cout << minP << endl;
    


    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:16: error: 'INT_MAX' was not declared in this scope
   15 |     int minP = INT_MAX;
      |                ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <algorithm>
  +++ |+#include <climits>
    3 | #include <string>
Language: C++

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

int main(){
    int N;
    cin >> N;
    vector<int> V(N);
    for(int i = 0; i < N; i++){
        cin >> V.at(i);
    }
    //入力終了
    vector<int> W(N); //総和用配列
    for(int i = 0; i < N; i++){
        W.at(i) = for(int j = 0; j < N; j++){W.at(i) + V.at(j);};
    }
    sort(W.begin(), W.end());
    cout << W.at(0) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: expected primary-expression before 'for'
   14 |         W.at(i) = for(int j = 0; j < N; j++){W.at(i) + V.at(j);};
      |                   ^~~
a.cc:14:34: error: 'j' was not declared in this scope
   14 |         W.at(i) = for(int j = 0; j < N; j++){W.at(i) + V.at(j);};
      |                                  ^
Language: Java

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main2 {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		ArrayList<Integer> inputs = new ArrayList<Integer>();
		for(int n =0; n<a; n++) {
			int ele = scanner.nextInt();
			inputs.add(ele);
		}
		System.out.println(min(a,inputs));
 
	}
	
	public static int min(int in,ArrayList<Integer> inputs) {
		int ans = 0;
		for(Integer ins: inputs) {
			ans += (ins-in)*(ins-in);
		}
		return ans;
	}
	
}

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

#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <set>
#include <set>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <cmath>
#include <sstream>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (auto& i : a) cin >> i;
	sort(a.begin(), a.end());
	int ans = INT_MAX;
	for (int p = 1; p <= 100; p++) {
		int tmp = 0;
		for (auto& i : a) {
			tmp += (p - i) * (p - i);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}


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

n=gets.to_i
x=gets.split.map(&:to_i)
m = 100000
mi,mx = x.minmax
for i in 1..100
    s = 0
    for j in 0...n
        s += (x[j]-i)*(x[j]-i)
    end
    m = (m<s)?m:s
end
p m



Compiler output:
a.cc:5:10: error: too many decimal points in number
    5 | for i in 1..100
      |          ^~~~~~
a.cc:7:14: error: too many decimal points in number
    7 |     for j in 0...n
      |              ^~~~~
a.cc:1:1: error: 'n' does not name a type
    1 | n=gets.to_i
      | ^
Language: C++

#include <bits/stdc++.h>
#define ll long long

#define endl '\n'

using namespace std;

int n, x[100], p, a;

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i];
        p+=x[i];
    }
    p /= n;
    for(int i = 0; i < n; i++)a += (x[i] - p)*(a[i] - p);
    cout << a;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:49: error: invalid types 'int[int]' for array subscript
   17 |     for(int i = 0; i < n; i++)a += (x[i] - p)*(a[i] - p);
      |                                                 ^
Language: C

#include <iostream>


using namespace std;
#define N 105
int main()
{
    int a[N];
    int i,j,k,n;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    int mx=99999999,sum,t;
    for(k=1;k<100;k++){
            sum=0;
        for(i=0;i<n;i++){
            sum+=(a[i]-k)*(a[i]-k);
        }
        if(sum<mx)
        {
            t=i;
            mx=sum;
        }
    }
    cout<<mx;
    return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

ll sc(int x, int p) { return pow((x - p), 2); }

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> X(N);
  REP(i, N) cin >> X[i];

  ll ans = INT_MAX;
  for (int i = -1; i <= 101; i++) {
    int p = i;
    ll sum = 0;
    REP(i, N) { sum += sc(X[i], p); }
    ans = min(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:12: error: 'INT_MAX' was not declared in this scope
   46 |   ll ans = INT_MAX;
      |            ^~~~~~~
a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <set>
  +++ |+#include <climits>
   12 | #include <string>
Language: C++

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for(size_t i = 0; i < N; i++) {
        cin >> X[i];
    }

    int ans = 2147483647 ;
    for(int i=1; i<=100; i++){
        int sum = 0;
        for(size_t j=0; j<N; j++) {
            sum += pow((X[j]-i),2);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


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

#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
typedef long long int llint;

int main(void){

  int n;
  std::cin >> n;

  std::vector<int> X(n);
  for(int i=0; i<n; i++){
    std::cin >> X[i];
  }

  std::vector<llint> cost(100, 0);

  for(const auto& elem: X){
    for(int i=0; i<cost.size(); i++){
      cost[i] += (elem-i-1)*(elem-i-1);
    }
  }

  /**
  for(const auto& elem: cost){
    std::cout << elem << " ";
  }
  std::cout << std::endl;
  **/
  
  llint result = std::accumulate(cost.begin(), cost.end(), 99999999L, [](llint acc, llint i){ return std::min(acc, i);});
  std::cout << result << std::endl;

  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:23: error: 'accumulate' is not a member of 'std'
   42 |   llint result = std::accumulate(cost.begin(), cost.end(), 99999999L, [](llint acc, llint i){ return std::min(acc, i);});
      |                       ^~~~~~~~~~
Language: C++

// hhttps://atcoder.jp/contests/apg4b/tasks/APG4b_ca
// g++ -std=c++11 ex22.cpp && ./a.out
#include <vector>
#include <tuple>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    for (int &xi : X)
    {
        cin >> xi;
    }

    cout << minsum << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:13: error: 'minsum' was not declared in this scope; did you mean 'fminimum'?
   27 |     cout << minsum << endl;
      |             ^~~~~~
      |             fminimum
Language: C++

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for(size_t i = 0; i < N; i++) {
        cin >> X[i];
    }

    int ans = INT_MAX ;
    for(int i=1; i<=100; i++){
        int sum = 0;
        for(size_t j=0; j<N; j++) {
            sum += pow((X[j]-i),2);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:15: error: 'INT_MAX' was not declared in this scope
   33 |     int ans = INT_MAX ;
      |               ^~~~~~~
a.cc:18:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   17 | #include <utility>       // pair, make_pair
  +++ |+#include <climits>
   18 | #include <vector>        // vector
a.cc:37:20: error: 'pow' was not declared in this scope
   37 |             sum += pow((X[j]-i),2);
      |                    ^~~