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> xi(n);
	int mx;
	for (int i = 0; i < n; i++) {
		cin >> xi[i];
		mx = (mx, xi[i]);
	}
	long long m = 10000000000000;
	int u;
	int i = 1;
	int t;
	while (i <= mx) {
		u = 0;
		for (int j = 0; j < n; j++) {
			t = (xi[j] - i)*(xi[j] - i);
			u += t;
		}
		m = min(m, u);
		i++;
	}
	cout << m << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:24: error: no matching function for call to 'min(long long int&, int&)'
   28 |                 m = min(m, u);
      |                     ~~~^~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: '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:28:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |                 m = min(m, u);
      |                     ~~~^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/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:28:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |                 m = min(m, u);
      |                     ~~~^~~~~~
Language: C++

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> xi(n);
	int mx;
	for (int i = 0; i < n; i++) {
		cin >> xi[i];
		mx = (mx, xi[i]);
	}
	long long m = 10e10;
	int u;
	int i = 1;
	int t;
	while (i <= mx) {
		u = 0;
		for (int j = 0; j < n; j++) {
			t = (xi[j] - i)*(xi[j] - i);
			u += t;
		}
		m = min(m, u);
		i++;
	}
	cout << m << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:24: error: no matching function for call to 'min(long long int&, int&)'
   28 |                 m = min(m, u);
      |                     ~~~^~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: '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:28:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |                 m = min(m, u);
      |                     ~~~^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/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:28:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |                 m = min(m, u);
      |                     ~~~^~~~~~
Language: C++

#include <iostream>
using namespace std;

int main(){
    int n, p;
    int min = 100;
    int max = 0;
    int hp = 1000000000000000000;
    int* php = &hp;
    int tmp = 0;
    int* ptmp;
    int* px;
    cin >> n;
    px = new int[n];
    for (int i=0; i<n; i++){
        cin >> px[n];
    }
    for (int i=0; i<n; i++){
        if (min < px[i]){
            min = px[i];
        }
    }
    for (int i=0; i<n; i++){
        if (max > px[i]){
            max = px[i];
        }
    for (int i=0; i<(max-min+1); i++){
        for (int j=0; j<n; j++){
            *ptmp= (px[j]-i)*(px[j]-i);
            
        }
        if (*php < tmp){
                *php = tmp;
        }
    }
    cout << hp;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: warning: overflow in conversion from 'long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
    8 |     int hp = 1000000000000000000;
      |              ^~~~~~~~~~~~~~~~~~~
a.cc:38:2: error: expected '}' at end of input
   38 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

int main(){
        int n;cin>>n;
        int x[n];
        int p=0;
        int s=0;
        for(int i=0;i<n;i++){
                cin >> x[i];
                s+=x[i];
        }
        sort(x,x+n);
        int sum;
        int temp=0;
        while(true){
                sum=0;
                for(int i=0;i<n;i++){
                        sum+=2*(p-x[i])+1;
                }
                if(sum<0)p++;
                else break;
        }
        sum=0
        for(int j=0;j<n;j++){
                sum+=(p-x[j])*(p-x[j]);
        }
        cout << sum;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:14: error: expected ';' before 'for'
   25 |         sum=0
      |              ^
      |              ;
   26 |         for(int j=0;j<n;j++){
      |         ~~~   
a.cc:26:21: error: 'j' was not declared in this scope
   26 |         for(int j=0;j<n;j++){
      |                     ^
Language: C++

#include <iostream>
using namespace std;

int main(){
    int n, p;
    int min = 100;
    int max = 0;
    int hp = 1000000000000000000;
    int* php = &hp;
    int tmp = 0;
    int* ptmp;
    int* px;
    cin >> n;
    px = new int[n];
    for (int i=0; i<n; i++){
        cin >> px[n];
    }
    for (int i=0; i<n; i++){
        if (min < px[i]){
            min = px[i];
        }
    }
    for (int i=0; i<n; i++){
        if (max > px[i]){
            max = px[i];
        }
    for (int i=0; i<(max-min+1); i++){
        for (int j=0; j<n; j++){
            *ptmp=(px[j]-i)(px[j]-i);
            
        }
        if (*php < tmp){
                *php = tmp;
        }
    }
    cout << hp;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: warning: overflow in conversion from 'long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
    8 |     int hp = 1000000000000000000;
      |              ^~~~~~~~~~~~~~~~~~~
a.cc:29:28: error: expression cannot be used as a function
   29 |             *ptmp=(px[j]-i)(px[j]-i);
      |                   ~~~~~~~~~^~~~~~~~~
a.cc:38:2: error: expected '}' at end of input
   38 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: Java

{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X[] = new int[N];
        int sum = 0;
        int ans = 0;
        for (int i = 0 ; i< N ; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        double M =(double)Math.round(sum/N);
        int ans1 = 0;
        for (int i= 0 ; i< X.length;i++ ){
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        }
        System.out.println(ans);
    }
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
{
^
Main.java:2: error: unnamed classes are a preview feature and are disabled by default.
    public static void main(String[] args) {
                  ^
  (use --enable-preview to enable unnamed classes)
Main.java:20: error: class, interface, enum, or record expected
}
^
3 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num;
  cin >> num;
  vector<int> v;
  for (int i = 0; i < num; i++){
    int input;
    cin >> input;
    v.push_back(input);
  }
  int ans = 0;
  for(int j = 0; j < v.size(); j++){
    ans += pow((v.at(j) - num), 2);
    cout << ans << endl;
  }
  cout << ans 

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

#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,i,avg,avg2;
  double avg1;
  int sum1=0,sum2=0;
  cin>>N;
  vector<int>X(N);
  for(i=0;i<N;i++){
    cin>>X[i];
    sum1+=X[i];
  }
  avg1=sum1/N;
  avg2=(int)avg1;
   avg=avg2+1;
   for(i=0;i<N;i++){
       X[i]-=avg;
       sum2+=X[i]*X[i];
       }
       
   }
   cout<<sum2<<endl;
}

Compiler output:
a.cc:23:4: error: 'cout' does not name a type
   23 |    cout<<sum2<<endl;
      |    ^~~~
a.cc:24:1: error: expected declaration before '}' token
   24 | }
      | ^
Language: C++

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> xi(n);
	int mx;
	for (int i = 0; i < n; i++) {
		cin >> xi[i];
		mx = (mx, xi[i]);
	}
	int m = 1000000;
	int u;
	int i = 1;
	int t;
	while (i <= mx) {
		u = 0;
		for (int j = 0; j < n; j++) {
			t = (xi[j] - i)*(xi[j] - i);
			u += t;
		}
		m = min(m, u);
		i++;
	}
	cout << m << endl;
	r

Compiler output:
a.cc: In function 'int main()':
a.cc:32:9: error: 'r' was not declared in this scope
   32 |         r
      |         ^
a.cc:32:10: error: expected '}' at end of input
   32 |         r
      |          ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^
Language: C++

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

int main(){
    int N;
    cin >> N;
    int X[N] = {};
    int sum1 = 0;
    int sum2 = 0;
    for (int i = 0;i < N;i++){
        cin >> X[i];
        sum1 += X[i];
        sum2 += pow(X[i], 2);
    }

    int p1 = sum1 / N;
    int p2 = p1 + 1;
    int p3 = p1 - 1;
    int ans1 = 0,ans2 = 0,ans3 = 0;

    for (int i = 0;i < N; i++){
        ans1 += pow(p1 - X[i],2);
        ans2 += pow(p2 - X[i],2);
        ans3 += pow(p3- X[i],2);
    }

    cout << min(ans1,ans2,ans3) << endl;

}

Compiler output:
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:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:27:16:   required from here
   27 |     cout << min(ans1,ans2,ans3) << endl;
      |             ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~
Language: Java

class Main
{
  public static void main(String args[])
  {
    int i=0,j=0,k,l,m=0,n=0;
     Scanner myObj = new Scanner(System.in);
     i = myObj.nextInt();
     int a[]=new int[i];
     for(j=0;j<i;j++)
     {
     	a[j]=myObj.nextInt();
     	if(a[j]>m)
     		m=a[j];
     }
     if(m%2!=0)
     	m=(m-1)/2;
     else
     	m=m/2;
    for(j=0;j<i;j++)
    {
    	n=n+(a[j]-m)*(a[j]-m);
    }
    System.out.println(n);
  }
}
    





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

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

int main(){
    int N;
    int X[110];
    int Y[110];
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> X[i];
    }
    for(int i = 0;i < N;i++){
        Y[i] = 0;
    }
    for(int i = 0;i < N;i++){
        for(int j = 0; j < N;j++){
                Y[j] += (X[i] - (j + 1))*(X[i] -(j + 1));
        }
    fd
    }
    sort(Y,Y + N, greater<int>());
    for(int i = 0;i < N;i++){
        cout << Y[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'fd' was not declared in this scope
   22 |     fd
      |     ^~
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);
  
  vector<int> X2(N);
  int sum = 0;
  for(int i = 0: i < N; i++)
  {
    X2.at(i) = X.at(i) * X.at(i);
    sum += X2.at(i);
  }
  double mean2 = sum / N;
  int res = 1;
  double mean = mean2 - 1;
  for(int i = 2; i < 101; i++)
  {
    if(mean2 - pow(res,2) < mean)
    {
      res = i;
      mean = mean2 - pow(res, 2);
    }
  }
  sum = 0;
  for(int i = 0; i < N; i++)
    sum += (X.at(i) - res) * (X.at(i) - res);
    
  cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:13: error: initializer in range-based 'for' loop
   15 |   for(int i = 0: i < N; i++)
      |             ^
a.cc:15:23: error: expected ')' before ';' token
   15 |   for(int i = 0: i < N; i++)
      |      ~                ^
      |                       )
a.cc:15:25: error: 'i' was not declared in this scope
   15 |   for(int i = 0: i < N; i++)
      |                         ^
Language: C++

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

int main()
{
  int N;
  cin >> N;
  vector<int> X(N);

  for(i = 0; i < N; i++)
    cin >> X.at(i);
  
  vector<int> X2(N);
  int sum = 0;
  for(i = 0: i < N; i++)
  {
    X2.at(i) = X.at(i) * X.at(i);
    sum += X2.at(i);
  }
  double mean2 = sum / N;
  int res = 1;
  mean = mean2 - 1;
  for(i = 2; i < 101; i++)
  {
    if(mean2 - pow(res,2) < mean)
    {
      res = i;
      mean = mean2 - pow(res, 2);
    }
  }
  sum = 0;
  for(i = 0; i < N; i++)
    sum += (X.at(i) - res) * (X.at(i) - res);
    
  cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   for(i = 0; i < N; i++)
      |       ^
a.cc:15:7: error: 'i' was not declared in this scope
   15 |   for(i = 0: i < N; i++)
      |       ^
a.cc:15:24: error: expected ';' before ')' token
   15 |   for(i = 0: i < N; i++)
      |                        ^
      |                        ;
a.cc:22:3: error: 'mean' was not declared in this scope; did you mean 'mean2'?
   22 |   mean = mean2 - 1;
      |   ^~~~
      |   mean2
a.cc:23:7: error: 'i' was not declared in this scope
   23 |   for(i = 2; i < 101; i++)
      |       ^
a.cc:32:7: error: 'i' was not declared in this scope
   32 |   for(i = 0; i < N; i++)
      |       ^
Language: C++

#include <iostream>

using namespace std;

int main()
{
	int N;
	int X[100];
	int i;
	int P = 0;
	double total = 0;

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

	for (i = 0; i < N; i++) {
		P += X[i] / N;
	}

	for (i = 0; i < N; i++) {
		total += pow((X[i] - P),2);
	}
	
	cout << total;

	return 0;
}

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

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


int main() {
    int N,sum=0,ans=100000;

    cin >> N;
    vector<int>A(N);

    for (int i=0;i<N;i++){
        cin >> A[i];
    }
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            sum+= (A[i]-A[k])*(A[i]-A[k]);
            
        }
        if(sum<ans)ans=sum;
        sum=0;
    }
    

}




Compiler output:
a.cc: In function 'int main()':
a.cc:17:27: error: 'k' was not declared in this scope
   17 |             sum+= (A[i]-A[k])*(A[i]-A[k]);
      |                           ^
Language: C++

using namespace std;

int main() {
  int N,sum,min,y;
  cin >> N;

  vector<int> math(N); 
  int mathmin=100,mathmax=0;

  // 座標データを受け取る
  for (int i = 0; i < N; i++) {
    cin >> math.at(i);
    if(math.at(i) < mathmin) mathmin = math.at(i);
    if(math.at(i) > mathmax) mathmax = math.at(i);
  }
  
  min = 100*100;
  //cout << mathmin << endl;
  //cout << mathmax << endl;

  // 集会を開く座標
  for (int i = mathmin; i <= mathmax; i++) {
    sum = 0;
    for(int j = 0; j < N; j++){ //体力計算
      sum = sum + (math.at(j) - i)*(math.at(j) - i);
    }
    if(sum < min)min = sum;
  }
  
  cout << min << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
    5 |   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:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> math(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:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> math(N);
      |          ^~~
a.cc:12:12: error: 'math' was not declared in this scope
   12 |     cin >> math.at(i);
      |            ^~~~
a.cc:25:20: error: 'math' was not declared in this scope
   25 |       sum = sum + (math.at(j) - i)*(math.at(j) - i);
      |                    ^~~~
a.cc:30:3: error: 'cout' was not declared in this scope
   30 |   cout << min << endl;
      |   ^~~~
a.cc:30:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:18: error: 'endl' was not declared in this scope
   30 |   cout << min << 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 <stdio.h>
#include <stdlib.h>
 
int		main()
{
	int		N, sum, mid;
	int		*rally;
	int		i, r1 = 0, r2 = 0, result = 0;
 
	sum = 0;
	i = 0;
	r1 = scanf("%d\n", &N);
	if (N < 1 || N > 100 || r1 == EOF)
		return (-1);
	rally = (int *)malloc(sizeof(int) * N + 1);
	if (!rally)
	    return (-1);
	while (i < N)
	{
		r2 = scanf("%d", &rally[i]);
		if(rally[i] < 1 || rally[i] > 100 || r2 == EOF)
		    return (-1);
		if()
		sum += rally[i];
		i++;
	}
	if (sum % N != 0)
		mid = (sum / N) + 1;
	else
		mid = sum / N;
	i = 0;
	while (i < N)
	{
		result += ((rally[i] - mid) * (rally[i] - mid));
		i++;
	}
	printf ("%d\n", result);
	return (0);
}

Compiler output:
main.c: In function 'main':
main.c:23:20: error: expected expression before ')' token
   23 |                 if()
      |                    ^
Language: C++

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int a[110];
long long ans;
int main(){
	int x;
	scanf("%d",&x);
	for(int i=1;i<=x;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+x+1);
	for(int i=a[i];i<=a[x];i++){
		for(int j=1;j<=x;j++){
			int b=abs(a[j]-i);
			ans=min(b*b,ans);
		}
	}
	printf("%d",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:32: error: no matching function for call to 'min(int, long long int&)'
   17 |                         ans=min(b*b,ans);
      |                             ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 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:17:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   17 |                         ans=min(b*b,ans);
      |                             ~~~^~~~~~~~~
/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:17:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |                         ans=min(b*b,ans);
      |                             ~~~^~~~~~~~~
Language: C++

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

int main() {
  int n;
  int x[100] ={};
  cin >> n;
  rep(i,n) cin >> x[i];

  int sum_x = 0 ,p;
  rep(i,n) sum_x += x[i];
  p = sum_x / n;

  int power[2]={};
  rep(i,2){
    rep(j,n) power[i] += (x[j] - (p+i))*(x[j] - (p+i));
  }
  if(power[0]>power[1]) power[0]=power[1];

  cout << power[0] << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:22:28: error: expected '}' at end of input
   22 |   cout << power[0] << endl;
      |                            ^
a.cc:6:12: note: to match this '{'
    6 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <string>
#include <vector>

int main(){
    int num, temp, ans=INT_MAX;
    std::vector<int> a;

    // 入力
    std::cin >> num;

    for(int i=0; i<num; i++){
        std::cin >> temp;
        a.push_back(temp);
    }

    for(int i=1; i<100; i++){
        int sum = 0;
        for(int j=0; j<num; j++){
            sum += (a[j]-i)*(a[j]-i);
            // std::cout << sum << std::endl;
            // std::cout << j << ", " << a[j] << ", " << i << std::endl;
        }
        //std::cout << sum << std::endl;
        if(sum < ans) ans = sum;
    }
    
    std::cout << ans << std::endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:24: error: 'INT_MAX' was not declared in this scope
    6 |     int num, temp, ans=INT_MAX;
      |                        ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 |
Language: C++

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

int main(){
  int N;
  vector<int> X(N);
  cin >> N;
  for(int i = 0; i < N; i++){
    cin << X.at(i);
  }
  
  int sum = 0;
  for(int i = 0; i < N; i++){
    sum += X.at(i);
  }
  int answer = sum / N;
  int hit_point = 0;
  for(int i = 0; i < N; i++){
    hit_point = (X.at(i) - answer)^2;
  }
  cout << hit_point << endl;
}

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

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;

ll n,x[110],minm = 9999999999;

pot (ll q,ll w){
	ll qw = q;
	q = 1;
	for (int i = 0; i<w; i++)
		q *= qw;
	return q;
}

int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin >> n;

for (int i = 1; i<=n; i++)
	cin >> x[i];
	
for (int i = 1; i<=n; i++){
	ll zbr = 0;
	for (int k = 1; k<=n; k++){
		zbr += (x[k]*x[k]) - (2*x[k]*i) + (i*i);
		cout << zbr << " ";
	}
	if (zbr < minm)
		minm = zbr;
	cout << endl;
}

cout << minm;

return 0;
}



Compiler output:
a.cc:13:1: error: ISO C++ forbids declaration of 'pot' with no type [-fpermissive]
   13 | pot (ll q,ll w){
      | ^~~
Language: C

#include<stdio.h>
int main(){
  int N;
  int X[100] = {};
  int P;
  int S = 0;
  int E1,E2,E3;
  int i,j,k;

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

  for(j=0;j<N;j++){
    S += X[j];
  }

  P = S/N;
  E1 = 0;
  E2 = 0;
  E3 = 0;

  for(k=0;k<N;k++){
    E1 += (X[k]-P)*(X[k]-P);
    //E2 += (X[k]-(P+1))*(X[k]-(P+1));
    E3 += (X[k]-(P+1))*(X[k]-(P+1));
  }

  if(E1<E3){
    printf("%d",E1);
  }
  if(E3<E1){
    printf("%d",E3);
  }
  if(E1==E3){
    print("%d",E1);
  }
  /*if(E2<E3 && E2<E1){
    printf("%d",E2);
  }
  if(E3<E1 && E3<E2){
    printf("%d",E3);
  }*/
  //printf("%d",E1);

  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:37:5: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
   37 |     print("%d",E1);
      |     ^~~~~
      |     printf
Language: C++

#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#define INF INT_MAX / 2
#define rep(i, s, n) for(int i = s; i < (int)n; ++i)

using namespace std;

int N;
int x[110];

int main() {
        cin >> N;
        for (int i = 0; i < N; ++i) cin >> x[i];

        int sum = 0;
        rep(i, 0, N) sum += x[i];

        int ave = sum / N;

        int a = 0;
        int b = 0;

        rep(i, 0, N) {
                a += (ave - x[i]) * (ave - x[i]) ;
                b += (ave + 1 - x[i]) * (ave + 1 - x[i]);
        }

        cout << min(a, b);
}
~                         

Compiler output:
a.cc:32:2: error: expected class-name at end of input
   32 | ~
      |  ^
Language: C++

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

int main() {
  int N,sum,equ,ans=0;
  cin>>N;
  int X[110];
  
  for(int i=0;i<N;i++){
    cin>>X[i];
  }
  
  for(int i=0;i<N;i++){
    sum+=X[i];
  }
  
  equ=sum/N;
  
  for(int i=0;i<N;i++){
    
    if(equ>X[i]){
      ans+=(equ-X[i])*(equ-X[i]);
    }
    
    else if(equ=X[i]){
      ans+=0:
    }
    
    else{
      ans+=(X[i]-equ)*(X[i]-equ);
    }
    
  }
  
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:13: error: expected ';' before ':' token
   26 |       ans+=0:
      |             ^
      |             ;
Language: C++

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

int main() {
  int N,sum,equ,ans=0;
  cin>>N;
  int X[110];
  
  for(int i=0;i<N;i++){
    cin>>X[i];
  }
  
  for(int i=0;i<N;i++){
    sum+=X[i];
  }
  
  equ=sum/N;
  
  for(int i=0;i<N;i++){
    
    if(equ>X[i]){
      ans+=(equ-X[i])*(equ-X[i]);
    }
    
    else if(eequ=X[i]){
      ans+=0:
    }
    
    else{
      ans+=(X[i]-equ)*(X[i]-equ);
    }
    
  }
  
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: 'eequ' was not declared in this scope; did you mean 'equ'?
   25 |     else if(eequ=X[i]){
      |             ^~~~
      |             equ
a.cc:26:13: error: expected ';' before ':' token
   26 |       ans+=0:
      |             ^
      |             ;
Language: Java

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class atcoder0221_C{
	public class Main{
		//	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> X = new ArrayList<Integer>();
		for(int i=0;i<N;i++) {
			X.add(scan.nextInt());
		}

		int i = 0;
		int sum = 0;
		for(int tmp:X) {
			sum = sum+tmp;
			i++;
		}

		int av = sum/i;
		int av2 = av;

		if(sum%i>0) {
			av2 = av++;
		}
		int result = 0;
		int result2 = 0;

		if(i>1) {
			for(int tmp2:X) {
				result=result+(tmp2-av)*(tmp2-av);
			}

			for(int tmp3:X) {
				result2=result2+(tmp3-av2)*(tmp3-av2);
			}
			if(result>result2) {
				result = result2;
			}
			if(result==0) {
				result = av;
			}
		}else {
			result=av;
		}
		System.out.println(result);
	}
}



Compiler output:
Main.java:11: error: illegal start of type
		for(int i=0;i<N;i++) {
		^
Main.java:11: error: > or ',' expected
		for(int i=0;i<N;i++) {
		               ^
Main.java:11: error: <identifier> expected
		for(int i=0;i<N;i++) {
		                 ^
Main.java:17: error: illegal start of type
		for(int tmp:X) {
		^
Main.java:17: error: ';' expected
		for(int tmp:X) {
		           ^
Main.java:17: error: <identifier> expected
		for(int tmp:X) {
		             ^
Main.java:25: error: illegal start of type
		if(sum%i>0) {
		^
Main.java:25: error: <identifier> expected
		if(sum%i>0) {
		      ^
Main.java:25: error: <identifier> expected
		if(sum%i>0) {
		        ^
Main.java:31: error: illegal start of type
		if(i>1) {
		^
Main.java:31: error: <identifier> expected
		if(i>1) {
		    ^
Main.java:45: error: illegal start of type
		}else {
		 ^
Main.java:48: error: <identifier> expected
		System.out.println(result);
		                  ^
Main.java:48: error: <identifier> expected
		System.out.println(result);
		                         ^
14 errors
Language: C++

#include <iostream>
#include <vector>

int main()
{

  int N;
  std::cin >> N;
  std::vector<int> A;
  std::vector<int> val;
  A.resize(N);
  val.resize(100);
  for(int i=0;i<N;++i)
  {
    std::cin >> A[i];
  }

  for(int q=0;q<100;++q)
  {
    int p = q + 1;
    for(int i=0;i<N;++i)
    {   
      val[q] += (A[i] - p) * (A[i] - p); 
    }   
  }

  std::vector<int>::iterator iter = std::min_element(val.begin(), val.end());
  size_t index = std::distance(val.begin(), iter);

  std::cout << val[index];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:42: error: 'min_element' is not a member of 'std'; did you mean 'tuple_element'?
   27 |   std::vector<int>::iterator iter = std::min_element(val.begin(), val.end());
      |                                          ^~~~~~~~~~~
      |                                          tuple_element
Language: C++

#include <bits/stdc++.h>
#define INF 0x7fffffff
#define MAXN 100010
#define MOD 1000000007
#define int long long
using namespace std;
inline int read(){
	int ret=0,pos=1;char c=getchar();
	while(!isdigit(c) && c!='-' ) c=getchar();
	if(c=='-')	pos=-1,c=getchar();
	while(isdigit(c))ret=(ret<<3)+(ret<<1)+c-48,c=getchar();
	return pos*ret;
}
inline int fst_pow(int a,int b){
	int ret=1;
    for(;b;b>>=1,a=(a*a)%MOD)	if(b&1)	ret=a*ret%MOD;
    return ret;
}
int a[MAXN];
int n,k,ans=0x7fffffff;
signed main(){
	n=read();for(int i=1;i<=N;++i) a[i]=read();
    for (int i=1;i<=100;i++) {
		int sum = 0;
		for(int j=1;j<=n;j++)	sum+=pow(a[j]-i,2);
		ans=min(ans, sum);
	}
	cout<<ans<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:22:33: error: 'N' was not declared in this scope
   22 |         n=read();for(int i=1;i<=N;++i) a[i]=read();
      |                                 ^
Language: C++

import numpy as np
n = input()
x = input().split()
n = int(n)
x = list(map(int,x))
x = np.array(x)
maxed = np.max(x)
cand = []

for p in range(1,maxed):
    xp = (x - p) ** 2
    cand.append(np.sum(xp))
y = np.min(cand)
print(y)

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main (){
    int N;
    cin >> N;
    vector<int> X;
    int X_i;
    for (int i=0; i<N; i++){
        cin >> X_i;
        X.push_back(X_i);
    };

    int min = *std::min_element(X.begin(), X.end());
    int max = *std::max_element(X.begin(), X.end());
    int sum = 0;
    int max_sum = 10000, k = 0;
    for (int j = min; j <= max; j++){
        sum = 0;
        k = 0;
        while( sum <= max_sum && k < N){
            sum += pow(X[k]-j,2);
            k++;
        }
        
        if( k == N ) max_sum = std::min(sum, max_sum);
    }

    cout << max_sum << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: 'min_element' is not a member of 'std'; did you mean 'tuple_element'?
   17 |     int min = *std::min_element(X.begin(), X.end());
      |                     ^~~~~~~~~~~
      |                     tuple_element
a.cc:18:21: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
   18 |     int max = *std::max_element(X.begin(), X.end());
      |                     ^~~~~~~~~~~
      |                     tuple_element
Language: C++

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

int main() {
  int n;
  cin >> n;
  int x[110];
  for (int i=0; i<n; i++) cin >> x[i];
  sort(x, x+n);
  long int res = 10000000000000;
  for (int i=x[0]; i<=x[n-1]; i++) {
    int sum = 0;
    for (int j=0; j<n; j++) {
       sum += pow(abs(i - x[j]), 2);
    }
    if (res > sum) res = sum;
  }
  cout <<  res << endl;
}


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


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


int main(){
	/*input*/
	int n;
	int x[100];
	int Max=0;
	int all = 0;
	int ave = 0;
	cin >> n ;
	for(int i = 0; i < n; i++){
		cin >> x[i];
		Max = max(Max,x[i]);
		all += x[i];
	}
//	ave = all / n + 1;
//	cout << ave << endl;

	/*calc*/
	int ans = 0;

//	for(int i = 0; i < n; i++){
//		ans += pow(x[i] - ave,2.0);
//	}

	int Min = INT_MAX;
	for(int i = 1; i <= Max; i++){
		ans = 0;
		for(int j = 0; j < n; j++){
			ans += pow(x[j] - i,2.0);
		}
		Min = min(Min,ans);
//		cout << i << " : " << Min <<endl;
	}

	/*output*/
	cout<< Min <<endl;
//	cout<< ans <<endl;
    return 0;
}


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

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

int main() {
  int n;
  cin >> n;
  int x[110];
  for (int i=0; i<n; i++) cin >> x[i];
  sort(x, x+n);
  long int res = 10000000000000;
  for (int i=x[0]; i<=x[n-1]; i++) {
    int sum = 0;
    for (int j=0; j<n; j++) {
       sum += pow(abs(i - x[j]), 2);
    }
    if (res > sum) res = sum;
  }
  cout <<  res << endl;
}


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


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

int main(int argc, const char * argv[]) {
    int N = 0;
    int value = 0;
    int averagePoint = 0;
    int resultValue = 0;
    int resultValue2 = 0;
    int resultValue3 = 0;
    list<int> list = {};
    
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> value;
        averagePoint = averagePoint + value;
        list.push_front(value);
    }
    list.sort();
    
    if (averagePoint % N == 0) {
        averagePoint = averagePoint / N;
        for (int i = 0; i < N ; i++) {
            value = list.front();
            list.pop_front();
            resultValue = resultValue + ((value - averagePoint) * (value - averagePoint));
        }
        cout << resultValue;
    }else{
        averagePoint = averagePoint / N;
        int averagePoint2 = averagePoint + 1;
        int averagePoint3 = averagePoint - 1;
        for (int i = 0; i < N ; i++) {
            value = list.front();
            list.pop_front();
            resultValue = resultValue + ((value - averagePoint) * (value - averagePoint));
            resultValue2 = resultValue2 + ((value - averagePoint2) * (value - averagePoint2));
            resultValue3 = resultValue3 + ((value - averagePoint3) * (value - averagePoint3));
        }
        if (resultValue > resultValue2) {
            if (resultValue2 > resultValue3) {
                cout << resultValue3;
            }else{
                cout << resultValue2;
            }
        }else{
            if (resultValue > resultValue3) {
                cout << resultValue3
            }else{
                cout << resultValue;
            }
        }
    }

    return 0;
}



Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:50:37: error: expected ';' before '}' token
   50 |                 cout << resultValue3
      |                                     ^
      |                                     ;
   51 |             }else{
      |             ~
Language: C++

#include<iostream>

using namespace std;

long long int ara[200];

long long int comp(long long int a, long long int n)

{
    long long int i,b = 0;
    for(i = 0; i < n; i++){
        b += ((ara[i]-a)*(ara[i]-a));
    }
    return b;
}

int main(void)

{
    long long int n,a = 0,i,dis = INT_MAX, b = 440,c;
    cin>>n;
    for(i = 0; i < n; i++){
        cin>>ara[i];
        if(ara[i] > a)
            a = ara[i]; //boro
        if(ara[i] < b)
            b = ara[i]; //choto
    }
    for(i = b; i <= a; i++){
        c = comp(i, n);
        if(c < dis){
            dis = c;
        }
    }
    cout<<dis<<"\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:35: error: 'INT_MAX' was not declared in this scope
   20 |     long long int n,a = 0,i,dis = INT_MAX, b = 440,c;
      |                                   ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include<iostream>
  +++ |+#include <climits>
    2 | 
a.cc:26:21: error: 'b' was not declared in this scope
   26 |         if(ara[i] < b)
      |                     ^
a.cc:29:13: error: 'b' was not declared in this scope
   29 |     for(i = b; i <= a; i++){
      |             ^
a.cc:30:9: error: 'c' was not declared in this scope
   30 |         c = comp(i, n);
      |         ^
Language: C++

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> vec(n);
  for (int i=0; i<n; i++)
    cin >> vec.at(i);
  
  vector<int> cost(100);
  int camp;
  
  for(int i=1; i<101; i++) {
    for(int j=0; j<n; i++) {
	camp = i;
	cost.at(i-1) += (i - vec.at(j))*(i - vec.at(j));
    }
  }
  int answer = cost.at(0);
                                  
  for(int i=0; i<100; i++) {        
    if(cost.at(i) < cost.at(i+1))
       answer = cost(i+1);
  }
      
    cout << answer << endl;
       
}   

Compiler output:
a.cc: In function 'int main()':
a.cc:26:21: error: no match for call to '(std::vector<int>) (int)'
   26 |        answer = cost(i+1);
      |                 ~~~~^~~~~
Language: C++

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

const int inf=1e6;

bool cmp(int x,int y)
{
	return x<y;
}

int main()
{
	int n;
	int a[101];
	cin>>n;
	for(int i=0;i<n;++i)
	 cin>>a[i];
	sort(a,a+n,cmp);
	int minn=inf;
	for(int i=a[0];i<=a[n-1];++i)
	{
		int sum=0;
		for(int j=0;j<n;++j)
		{
			sum+=pow(a[j]-i,2);
		}
		minn=min(minn,sum);
	}
	cout<<minn<<endl;
	return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

int solve(int n, vector<double> x) {
    sort(x.begin(), x.end());
    double point = ceil(accumulate(x.begin(), x.end(), 0.0) / n);
    for (auto& i : x) {
        int tmp = i - point;
        ans += std::pow(tmp, 2);
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<double> x(n);
    for (int i=0; i<n; ++i)
        cin >> x.at(i);
    cout << solve(n, x);
}


Compiler output:
a.cc: In function 'int solve(int, std::vector<double>)':
a.cc:10:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   10 |         ans += std::pow(tmp, 2);
      |         ^~~
      |         abs
a.cc:12:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |     return ans;
      |            ^~~
      |            abs
Language: C++

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

int main() 
{
	int n;
	vector<int> x;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		x.push_back(t);
	}
	double ave = 0;
	for (int i = 0; i < n; i++) {
		ave += x[i];
	}
	ave /= n;
	int p = round(ave);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += pow(x[i] - p, 2);
	}
	cout << sum << endl;
	return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

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

    int sum = 0, sum2 = 0;
    for (int i = 0; i < n; i++) {
        sum += x[i];
        sum2 += x[i]*x[i];
    }
    double fans = sum2-sum*sum/(double)n;
    int ians = sum2-sum*sum/n;
    if (fans-ians > 0.5) inas++;

    cout << ians << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:26: error: 'inas' was not declared in this scope; did you mean 'ians'?
   28 |     if (fans-ians > 0.5) inas++;
      |                          ^~~~
      |                          ians
Language: C++

// https://atcoder.jp/contests/abc147/submissions/8853537
// https://outline.hatenadiary.jp/entry/2019/12/17/021530
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

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

    int sum = 0, sum2 = 0;
    for (int i = 0; i < n; i++) {
        sum += x[i];
        sum2 += x[i]*x[i];
    }
    double fans = sum2-sum*sum/(double)n;
    int ians = sum2-sum*sum/n
    if (fans-ians > 0.5) inas++;

    cout << ians << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:5: error: expected ',' or ';' before 'if'
   30 |     if (fans-ians > 0.5) inas++;
      |     ^~
Language: C++

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> vec(n);
  for (int i=0; i<n; i++)
    cin >> vec.at(i);
  
  vector<int> cost(100);
  int camp;
  
  for(int i=1; i<101; i++) {
    for(int j=0; j<n; i++) {
	camp = i;
	cost.at(i-1) += (i - vec.at(j))(i - vec.at(j));
    }                              
  }
  int answer = cost.at(0);
                                  
  for(i=0; i<100; i++) {        
    if(cost.at(i) < cost.at(i+1)
       answer = cost(i+1);
  {
      
    cout << answer << endl;
       
}   

Compiler output:
a.cc: In function 'int main()':
a.cc:19:40: error: expression cannot be used as a function
   19 |         cost.at(i-1) += (i - vec.at(j))(i - vec.at(j));
      |                         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
a.cc:24:7: error: 'i' was not declared in this scope
   24 |   for(i=0; i<100; i++) {
      |       ^
a.cc:27:3: error: expected primary-expression before '{' token
   27 |   {
      |   ^
a.cc:26:27: error: expected ')' before '{' token
   26 |        answer = cost(i+1);
      |                           ^
      |                           )
   27 |   {
      |   ~                        
a.cc:25:7: note: to match this '('
   25 |     if(cost.at(i) < cost.at(i+1)
      |       ^
a.cc:31:2: error: expected statement at end of input
   31 | }
      |  ^
a.cc:31:2: error: expected '}' at end of input
a.cc:24:24: note: to match this '{'
   24 |   for(i=0; i<100; i++) {
      |                        ^
a.cc:31:2: error: expected '}' at end of input
   31 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  int arr[n];
  long long int minTotal = INT_MAX,total=0;
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<=100;i++){
  		for(int j=0;j<n;j++){
        	total+= ((arr[j]-i)*(arr[j]-i));
        }
  		minTotal = total<minTotal?total:minTotal;
  }
  cout<<minTotal<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:28: error: 'v' was not declared in this scope
    8 |   for(int i=0;i<n;i++)cin>>v[i];
      |                            ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main() {
	int a, b;
	cin >> a ;
	vector<int> c(a);
	double num=0;
	for (int i = 0;i < a;i++) {
		cin >> c[i];
		num += c[i];
	}
	num /= a;
	num=round(num);
	cout << num << "\n";
	int p = 0;
	for (int i = 0;i < a;i++) {
		p+=pow(c[i] - num, 2);
	}
	cout << p;
}

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

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

int main() {
  int N,sum,equ,ans;
  cin>>N;
  int X[110];
  
  for(int i=0;i<N;i++){
    cin>>X[i];
  }
  
  for(int i=0;i<N;i++){
    sum+=x[i];
  }
  
  equ=sum/N;
  
  for(int i=0;i<N;i++){
    ans=(equ-x[i])*(equ-x[i]);
  }
  
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'x' was not declared in this scope
   14 |     sum+=x[i];
      |          ^
a.cc:20:14: error: 'x' was not declared in this scope
   20 |     ans=(equ-x[i])*(equ-x[i]);
      |              ^