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

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




int main() {
	char s[11];
	char r[11];
	char buf[64];
	int i,n,j,dummy,k;
	scanf_s("%s", s, 11);
	for (n = 0; s[n] != '\0'; n++);

	for (i = 0, j=0; s[i] != '\0'; i++) {
		fgets(buf, 64, stdin);
		if (s[i] == 'B') {
			//j--;
			continue;
		}
		r[j] = s[i];
		j++;
		for (k = 0, r[j] = '\0'; k < j; k++) printf("%c", r[k]);
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:12:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   12 |         scanf_s("%s", s, 11);
      |         ^~~~~~~
      |         scanf
Language: C

#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{

        char S[11];
        char S2[11];
        int i;
        int j;
        int len;

        scanf("%s",S);

        len = strlen( S );
        j = 0;
        for (i=0; i < len; i++) {
           if (S[i]  ==  '0') {
             j = j + 1;
             S2[j - 1] = '0';
           }
           if  ( S[i]  ==  '1') {
             j = j + 1;
             S2[j - 1] = '1';
           }

           if  ( S[i]  ==  'B') {
             if  ( j != 0 ) {
                 j = j - 1;
                 S2[j] = null;
             }
   
           }
        }

           printf("%s\n",S2);
        
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:30:26: error: 'null' undeclared (first use in this function)
   30 |                  S2[j] = null;
      |                          ^~~~
main.c:30:26: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

using namespace std;
int main() {
  string a,b;
  cin>>a;
  int n=a.size();
  for (int i=0;i<n;i++){
    if (a[i]!='B'){
      b+=a[i];
      }else{
        b.pop_back();}
  cout<<b<<endl;
  return 0;
}

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

#include <iostream>
#include <string>


using namespace std;

int main() {
	string str;
	cin >> str;
	int len = str.length();
	char* s = new char[len + 1];
	memcpy(s, str.c_str(), len + 1);
	
	for (int i = 0; i < len; i++) {
		if (s[i] == 'B') {
			if (i >= 1) {
				for (int j = i - 1; j < len - -2; j++) {
					s[j] = s[j + 2];
				}
				len -= 2;
				i = -1;
			}
			if (i == 0) {
				for (int j = i; j < len - 1; j++) {
					s[j] = s[j + 1];
				}
				len -= 1;
				i = -1;
			}
		}
	}
	for (int i = 0; i < len; i++) {
		cout << *(s + i);
	}
	cout << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'memcpy' was not declared in this scope
   12 |         memcpy(s, str.c_str(), len + 1);
      |         ^~~~~~
a.cc:2:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
Language: C++

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

using namespace std;

#include<stdio.h>

int main() {
	char s[10000],m[10000];
	char c;
	int i, j, k=0, l;
	fgets(s, 10000, stdin);
	for (i = 0;i < strlen(s);i++) {
		switch (s[i])
		{
		case '0':
			m[k] = '0';
			k++;
			break;
		case '1':
			m[k] = '1';
			k++;
			break;
		case 'B':
			if (k == 0)break;
			m[k - 1] = '\0';
			k--;
			break;
		default:
			break;
		}
	}
	m[k] = '\0';
	l = strlen(m);
	for (i = l-1;i >=0;i--) {
		printf("%c", m[i]);
	}
	printf("\n");

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:24: error: 'strlen' was not declared in this scope
   17 |         for (i = 0;i < strlen(s);i++) {
      |                        ^~~~~~
a.cc:7:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include<algorithm>
  +++ |+#include <cstring>
    7 | 
a.cc:38:13: error: 'strlen' was not declared in this scope
   38 |         l = strlen(m);
      |             ^~~~~~
a.cc:38:13: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

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

int main(){
  int n;
  string s,ans;
  for(int i = 0; i < s.size(); i++)
  {
    if(s[i]=='B'){
      if(ans.size != 0){
        ans = ans.substr(0,s.size()-1);
      }
    }
    else{
      ans += s[i];
    }
  }
  cout << ans << endl; 

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:14: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   11 |       if(ans.size != 0){
      |          ~~~~^~~~
      |                  ()
Language: C++

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <list>
#include <vector>
#include <map>

using namespace std;


int main(void) {
	string str,a;
	cin >> str;
	

	for (int i = 0; i < str.length(); i++) {
		switch(str[i]) {
		case '0':
			a.push_back('0');
			break;
		case '1':
			a.push_back('1');
			break;
		case 'B':
			if(!a.empty)
				a.pop_back();
			break;
		}
	}
	cout << a << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:31: error: cannot convert 'std::__cxx11::basic_string<char>::empty' from type 'bool (std::__cxx11::basic_string<char>::)() const noexcept' to type 'bool'
   27 |                         if(!a.empty)
      |                               ^~~~~
a.cc:27:31: error: in argument to unary !
   27 |                         if(!a.empty)
      |                             ~~^~~~~
Language: C++

string = input()
result = []
j=0
for i in range(len(string)):
    if string[i] == '0':
        result.append('0')
    elif string[i] == '1':
        result.append('1')
    elif string[i]=='B' and result[-1] in ['0','1']:
        result.append(" ")
str_result=" ".join(result)

print(str_result.replace(" ",""))



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

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

int main(){
  int n;
  string s,ans;
  for(int i = 0; i < strlen(s); i++)
  {
    if(s[i]=="B"){
      if(ans != 0){
        ans = ans.substr(0,strlen(ans)-1);
      }
    }
    else{
      ans += s[i];
    }
  }
  cout << ans << endl; 

  return 0;
}


Compiler output:
a.cc:2:1: error: stray '##' in program
    2 | ##include <string>
      | ^~
a.cc:2:3: error: 'include' does not name a type
    2 | ##include <string>
      |   ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:3: error: 'string' was not declared in this scope
    7 |   string s,ans;
      |   ^~~~~~
a.cc:7:3: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included 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:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:8:29: error: 's' was not declared in this scope
    8 |   for(int i = 0; i < strlen(s); i++)
      |                             ^
a.cc:8:22: error: 'strlen' was not declared in this scope
    8 |   for(int i = 0; i < strlen(s); i++)
      |                      ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | ##include <string>
a.cc:11:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   11 |       if(ans != 0){
      |          ^~~
      |          abs
a.cc:16:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |       ans += s[i];
      |       ^~~
      |       abs
a.cc:19:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   19 |   cout << ans << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:19:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |   cout << ans << endl;
      |           ^~~
      |           abs
a.cc:19:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   19 |   cout << ans << endl;
      |                  ^~~~
      |                  std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C

#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{

        char S[11];
        char S2[11];
        int i;
        int j;
        int len;

        scanf("%s",S);

        len = strlen( S );
        j = 0;
        for (i=0; i < len; i++) {
           if (S[i]  ==  0) {
             j = j + 1;
             S2[j - 1] = 0;
           }
           if  ( S[i]  ==  1) {
             j = j + 1;
             S2[j - 1] = 1;
           }

           if  ( S[i]  ==  'B') {
             j = j - 1;
           }

        printf("%s\n",S2);
        
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:34:1: error: expected declaration or statement at end of input
   34 | }
      | ^
Language: C

#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{

        char S[11];
        char S2[11];
        int i;
        int j;

        scanf("%s",S);

        j = 0;
        for (i=0; i < 10; i++) {
           if (S[i]  ==  0) {
             j = j + 1;
             S2[j - 1] = 0;
           }
           if  ( S[i]  ==  1) {
             j = j + 1;
             S2[j - 1] = 1;
           }

           if  ( S[i]  ==  'B') {
             j = j - 1;
           }
           if  (S[i]  ==  " ") {        
             break; 
           }       

        printf("%s\n",S2);
        
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:28:23: warning: comparison between pointer and integer
   28 |            if  (S[i]  ==  " ") {
      |                       ^~
main.c:35:1: error: expected declaration or statement at end of input
   35 | }
      | ^
Language: C

#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{

        char S[11];
        char S2[11];
        int i;
        int j;

        scanf("%s",S);

        j = 0;
        for (i=0; i < 10; i++) {
           if (S[i]  ==  0) {
             j = j + 1;
             S2[j - 1] = 0;
           }
           if  ( S[i]  ==  1) {
             j = j + 1;
             S2[j - 1] = 1;
           }

           if  ( S[i]  ==  "B") {
             j = j - 1;
           }
           if  (S[i]  ==  " ") {        
             break; 
           }       

        printf("%s\n",S2);
        
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:25:24: warning: comparison between pointer and integer
   25 |            if  ( S[i]  ==  "B") {
      |                        ^~
main.c:28:23: warning: comparison between pointer and integer
   28 |            if  (S[i]  ==  " ") {
      |                       ^~
main.c:35:1: error: expected declaration or statement at end of input
   35 | }
      | ^
Language: C

#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{

        char S[11];
        char S2[11];
        int i;
        int j;

        scanf("%s",S);

        j = 0;
        for (i=0; i < 10; i++) {
           if (S[i]  ==  0) {
             j = j + 1;
             S2[j - 1] = 0;
           }
           if  ( S[i]  ==  1) {
             j = j + 1;
             S2[j - 1] = 1;
           }

           if  ( S[i]  ==  B) {
             j = j - 1;
           }
           if  (S[i]  ==  "") {        
             break; 
           }       

        printf("%s\n",S2);
        
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:25:28: error: 'B' undeclared (first use in this function)
   25 |            if  ( S[i]  ==  B) {
      |                            ^
main.c:25:28: note: each undeclared identifier is reported only once for each function it appears in
main.c:28:23: warning: comparison between pointer and integer
   28 |            if  (S[i]  ==  "") {
      |                       ^~
main.c:35:1: error: expected declaration or statement at end of input
   35 | }
      | ^
Language: C

#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{

        char S[11];
        char S2[11];
        int i;
        int j;

        scanf("%s",S);

        j = 0;
        for (i=0; i < 10; i++) {
           if (S[i]  ==  0) {
             j = j + 1;
             S2[j - 1] = 0;
           }
           if  ( (S[i]  ==  1) {
             j = j + 1;
             S2[j - 1] = 1;
           }

           if  ( S[i]  ==  B) {
             j = j - 1;
           }
           if  (S[i]  ==  "") {        
             break; 
           }       

        printf("%s\n",S2);
        
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:20:31: error: expected ')' before '{' token
   20 |            if  ( (S[i]  ==  1) {
      |                ~              ^~
      |                               )
main.c:35:1: error: expected expression before '}' token
   35 | }
      | ^
main.c:35:1: error: expected declaration or statement at end of input
Language: C++


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

using namespace std;

#include<stdio.h>

int main() {
	int a;
	char c;
	int x=0,i=0,j,n=0;
	char s[1000];

	while(scanf("%c",&c)!=EOF){
		switch (c)
		{
		case '0':
			x *= 2;
			i++;
			if (x == 0)n++;
			break;
		case '1':
			x *= 2;
			x++;
			i++;
			break;
		case 'B':
			if (x == 0) {
				if(n!=0)n--;
				if(i!=0)i--;
				break;
			}
			x /= 2;
			i--;
		default:
			break;
		}
	if (c == EOF)break;
	}

	itoa(x,s,2);
	if (i == 0) {
		printf("\n");
		return 0;
	}

	for (j = 0;j < n-1;j++) {
		printf("0");
	}
	printf("%s\n", s);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:9: error: 'itoa' was not declared in this scope
   45 |         itoa(x,s,2);
      |         ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main(){
vector<char> s;
char c;
 
while(cin>>c){
if(c=="1"){
s.push_buck("1");
}else if(c=="0"){
s.push_buck("0");
}else if(c=="B"){
s.pop_buck();
}
}
for(auto it=s.begin();it!=s.end();it++) {
cout<<*it<<endl;
}
 
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    9 | if(c=="1"){
      |    ~^~~~~
a.cc:10:3: error: 'class std::vector<char>' has no member named 'push_buck'; did you mean 'push_back'?
   10 | s.push_buck("1");
      |   ^~~~~~~~~
      |   push_back
a.cc:11:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   11 | }else if(c=="0"){
      |          ~^~~~~
a.cc:12:3: error: 'class std::vector<char>' has no member named 'push_buck'; did you mean 'push_back'?
   12 | s.push_buck("0");
      |   ^~~~~~~~~
      |   push_back
a.cc:13:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 | }else if(c=="B"){
      |          ~^~~~~
a.cc:14:3: error: 'class std::vector<char>' has no member named 'pop_buck'; did you mean 'pop_back'?
   14 | s.pop_buck();
      |   ^~~~~~~~
      |   pop_back
Language: C++

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

using namespace std;

#include<stdio.h>

int main() {
	int a;
	int c;
	int x=0,i=0,j,n=0;
	char s[1000];

	while(scanf("%c",&c)!=EOF){
		switch (c)
		{
		case '0':
			x *= 2;
			i++;
			if (x == 0)n++;
			break;
		case '1':
			x *= 2;
			x++;
			i++;
			break;
		case 'B':
			if (x == 0) {
				if(n!=0)n--;
				if(i!=0)i--;
				break;
			}
			x /= 2;
			i--;
		default:
			break;
		}
	if (c == EOF)break;
	}

	itoa(x,s,2);
	if (i == 0) {
		printf("\n");
		return 0;
	}

	for (j = 0;j < n-1;j++) {
		printf("0");
	}
	printf("%s\n", s);

	return 0;
}
//改行注意

Compiler output:
a.cc: In function 'int main()':
a.cc:43:9: error: 'itoa' was not declared in this scope
   43 |         itoa(x,s,2);
      |         ^~~~
Language: C++

#include <algorithm>
using namespace std;

int main(){
    string s; cin >> s;
    string a = "";
    int cnt = 0;
    for(int i = s.size() - 1; i >= 0; i--){
        if(s[i] == 'B'){
            cnt++;
            continue;
        }
        a += s[i-cnt];
        if(i-cnt == 0) break;
        if(cnt < 0) cnt++;
    }
    reverse(a.begin(),a.end());
    cout << a << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'string' was not declared in this scope
    5 |     string s; cin >> s;
      |     ^~~~~~
a.cc:2:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
    1 | #include <algorithm>
  +++ |+#include <string>
    2 | using namespace std;
a.cc:5:15: error: 'cin' was not declared in this scope
    5 |     string s; cin >> s;
      |               ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <algorithm>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:5:22: error: 's' was not declared in this scope
    5 |     string s; cin >> s;
      |                      ^
a.cc:6:11: error: expected ';' before 'a'
    6 |     string a = "";
      |           ^~
      |           ;
a.cc:13:9: error: 'a' was not declared in this scope
   13 |         a += s[i-cnt];
      |         ^
a.cc:17:13: error: 'a' was not declared in this scope
   17 |     reverse(a.begin(),a.end());
      |             ^
a.cc:18:5: error: 'cout' was not declared in this scope
   18 |     cout << a << endl;
      |     ^~~~
a.cc:18:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:18:18: error: 'endl' was not declared in this scope
   18 |     cout << a << endl;
      |                  ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <algorithm>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C

#include<stdio.h>
int main(void){
char s[12],a[12];
int i,c=0;
scanf("%s",s);
for(i=0,s[i]!='\0',i++){
if(s[i]=='B'){
c--;
}else{
a[c]=s[i];
c++;
}
}
for(i=0;i<c;i++)printf("%c",a[i]);
puts("");return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:23: error: expected ';' before ')' token
    6 | for(i=0,s[i]!='\0',i++){
      |                       ^
      |                       ;
main.c:6:23: error: expected expression before ')' token
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner x= new Scanner(System.in);

String y = x.next();
char[] z = new char[y.length()];
int c=0;
for(int i=0;i<y.length();i++){
if(y.charAt(i)=='B'){
    if(c!=0){
	c--;
    z[c] =0;

    }
}else{
    z[c] = y.charAt(i);
    c++;
    }
}

String o="";
for(int i=0;i<z.length;i++){
	o = o+z.charAt(i);

}
System.out.println(o);
}
}

Compiler output:
Main.java:24: error: cannot find symbol
	o = o+z.charAt(i);
	       ^
  symbol:   method charAt(int)
  location: variable z of type char[]
1 error
Language: C++

#include <iostream>
using namespace std;

int main() {
  string a;
  cin >> a;
  for(int i = 0; i <= a.size(); i++) {
    if(a[i] == "b"){
      a.erase(i - 1, 2)
      i-= 2
    };
  }
  cout << a << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    8 |     if(a[i] == "b"){
a.cc:9:24: error: expected ';' before 'i'
    9 |       a.erase(i - 1, 2)
      |                        ^
      |                        ;
   10 |       i-= 2
      |       ~
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner x= new Scanner(System.in);

String y = x.next();
char[] z = new char[y.length()];
int c=0;
for(int i=0;i<y.length();i++){
if(y.charAt(i)=='B'){
    if(c!=0){
	c--;
    z[c] =0;

    }
}else{
    z[c] = y.charAt(i);
    c++;
    }
}

String o="";
for(int i=0;i<z.length;i++){
	o = o+z.charAt(i);

}
System.out.println(o);
}

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

s = raw_input()
words = []
for c in list(s):
    if c == 'B':
        words.pop()
    else:
        words.append(c)
print ''.join(words)

Compiler output:
a.cc:8:7: error: empty character constant
    8 | print ''.join(words)
      |       ^~
a.cc:1:1: error: 's' does not name a type
    1 | s = raw_input()
      | ^
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner x= new Scanner(System.in);

String y = x.next();
char[] z = new char[y.length()];
int c=0;
for(int i=0;i<y.length();i++){
if(y.charAt(i)=='B'){
    if(c!=0){
	c--;
    z[c] =0;

    }
}else{
    z[c] = y.charAt(i);
    c++;
    }
}

String o="";
for(int i=0;i<,z.length;i++){
	o = o+z.charAt(i);

}
System.out.println(o);
}

Compiler output:
Main.java:23: error: illegal start of expression
for(int i=0;i<,z.length;i++){
              ^
Main.java:23: error: not a statement
for(int i=0;i<,z.length;i++){
                ^
Main.java:23: error: ')' expected
for(int i=0;i<,z.length;i++){
                       ^
Main.java:23: error: ';' expected
for(int i=0;i<,z.length;i++){
                           ^
Main.java:28: error: reached end of file while parsing
}
 ^
5 errors
Language: C++

#include <iostream>
using namespace std;

int main() {
  string a;
  cin >> a;
  for(int i = 0; i <= a.size(); i++) {
    if(a[i] == "b"){a.erase(i - 1, 2); i-= 2};
  }
  cout << a << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    8 |     if(a[i] == "b"){a.erase(i - 1, 2); i-= 2};
a.cc:8:45: error: expected ';' before '}' token
    8 |     if(a[i] == "b"){a.erase(i - 1, 2); i-= 2};
      |                                             ^
      |                                             ;
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner x= new Scanner(System.in);

String y = x.next();
char[] z = new char[y.length()];
int c=0;
for(int i=0;i<y.length();i++){
if(y.charAt(i)=='B'){
    if(c!=0){
	c--;
    z[c] =0;

    }
}else{
    z[c] = y.charAt(i);
    c++;
    }
}

String o="";
for(int i=0;i<,z.length;i++)
	o = o+z.charAt(i);

}
System.out.println(o);
}

Compiler output:
Main.java:23: error: illegal start of expression
for(int i=0;i<,z.length;i++)
              ^
Main.java:23: error: not a statement
for(int i=0;i<,z.length;i++)
                ^
Main.java:23: error: ')' expected
for(int i=0;i<,z.length;i++)
                       ^
Main.java:23: error: ';' expected
for(int i=0;i<,z.length;i++)
                           ^
Main.java:27: error: <identifier> expected
System.out.println(o);
                  ^
Main.java:27: error: <identifier> expected
System.out.println(o);
                    ^
6 errors
Language: C++

#include <iostream>
using namespace std;

int main() {
  string a;
  cin >> a;
  for(int i = 0; i <= a.size(); i++) {
    if(a.[i] == "b"){.erase(i - 1, 2); i-= 2};
  }
  cout << a << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: expected unqualified-id before '[' token
    8 |     if(a.[i] == "b"){.erase(i - 1, 2); i-= 2};
      |          ^
a.cc:8:22: error: expected primary-expression before '.' token
    8 |     if(a.[i] == "b"){.erase(i - 1, 2); i-= 2};
      |                      ^
a.cc:8:45: error: expected ';' before '}' token
    8 |     if(a.[i] == "b"){.erase(i - 1, 2); i-= 2};
      |                                             ^
      |                                             ;
Language: C++

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

int _tmain(int argc, _TCHAR* argv[])
{
	string s,ans;
	cin >> s;
	for (int i = 0; i < s.length(); ++i){
		if (s[i] == '1'){ ans += '1'; }
		if (s[i] == '0'){ ans+= '0'; }
		if (s[i] == 'B'){ if(ans.length()>0) ans.pop_back(); }
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:5:22: error: '_TCHAR' has not been declared
    5 | int _tmain(int argc, _TCHAR* argv[])
      |                      ^~~~~~
Language: C++

#include <string>
using namespace std;

int main(){
    string s; cin >> s;
    string a = "";
    int cnt = 0;
    for(int i = s.size() - 1; i-cnt >= 0; i--){
        if(s[i] == 'B'){
            cnt++;
            continue;
        }
        a += s[i-cnt];
    }
    cout << a << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:15: error: 'cin' was not declared in this scope
    5 |     string s; cin >> s;
      |               ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <string>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:15:5: error: 'cout' was not declared in this scope
   15 |     cout << a << endl;
      |     ^~~~
a.cc:15:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:18: error: 'endl' was not declared in this scope
   15 |     cout << a << endl;
      |                  ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <string>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

from re import sub


s = input()

print(sub(r'.B', '', s).replace('B', ''))


Compiler output:
a.cc:6:12: warning: multi-character character constant [-Wmultichar]
    6 | print(sub(r'.B', '', s).replace('B', ''))
      |            ^~~~
a.cc:6:18: error: empty character constant
    6 | print(sub(r'.B', '', s).replace('B', ''))
      |                  ^~
a.cc:6:38: error: empty character constant
    6 | print(sub(r'.B', '', s).replace('B', ''))
      |                                      ^~
a.cc:1:1: error: 'from' does not name a type
    1 | from re import sub
      | ^~~~
Language: C++

#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>

using namespace std;

int main()
{
    int numm[105];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {   
        int temp;
        cin >> temp;
        numm[i] = temp;

    }
    
    int mincost = INT_MAX;


    for (int i = -100; i < 101; i++)
    {
        int cost = 0;
        for (int j = 0; j < n; j++)
        {
            cost += ((numm[j] - i) * (numm[j] - i));

        }
        if (cost < mincost) mincost = cost;

    }
    cout << mincost;
}

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

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define INF 0x7fffffff

using namespace std;

int N;

int main() {
    cin >> N;
    vector<int> nums(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> nums[i];
        sum += nums[i];
    }
    int x = floor(sum / n);
    int y = ceil(sum / n);
    int ans1 = 0, ans2 = 0;
    for(auto index : nums) {
        ans1 += (index - x) * (index - x);
        ans2 += (index - y) * (index - y);
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

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

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


int main(){

  int n; cin>>n;
  int arr[n];
  for(int i=0;i<n;i++) cin>>arr[i];
  
  int ans = 1e9;
  for(int k=-100;k<=100;k++){
		int cost = 0;
    	for(int i=0;i<n;i++) cost += (k-arr[i])*(k-arr[i]);
    	ans = min(ans,cost);
  }
  cout<<cost;
  
 return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   17 |   cout<<cost;
      |         ^~~~
      |         cosl
Language: C++

#include<bits/stdc++.h> 
#define ll long long 
#define pb push_back
#define vec vector<int>
#define fo(i,n) for (int i = 0; i < n; i++)
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second
using namespace std;  




int main()
{
  int n;
  cin>>n;
 
    vector<int> a(n) ;
    int sum = 0 ;
    fo(i,n){
        cin >> a[i] ;
        sum+=a[i] ;
    }
    sort(a.begin(),a.end()) ;
    int mean = sum/n ;
    int a = 0 ;
    int a2 = 0 ;
    fo(i,n){
        a+=(a[i]-mean)*(a[i]-mean) ;
    }
 
    fo(i,n){
        a2+=(a[i]-(mean+1))*(a[i]-(mean+1)) ;
    }
 
    cout << min(a,as2)<< endl ;
 
    return 0 ;


 
    
}



   

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: conflicting declaration 'int a'
   27 |     int a = 0 ;
      |         ^
a.cc:19:17: note: previous declaration as 'std::vector<int> a'
   19 |     vector<int> a(n) ;
      |                 ^
a.cc:30:10: error: no match for 'operator+=' (operand types are 'std::vector<int>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   30 |         a+=(a[i]-mean)*(a[i]-mean) ;
      |         ~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:37:19: error: 'as2' was not declared in this scope; did you mean 'a2'?
   37 |     cout << min(a,as2)<< endl ;
      |                   ^~~
      |                   a2
Language: Java

import java.util.*;

/**
 * C Main
 *
 * @date 2020.08.22
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    int n = this.sc.nextInt();
    int[] a = new int[n];
    int sum = 0;

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

    double avg = sum * 1.0 / n;
    int high = (int) (Math.ceil(avg));
    int low = (int) (Math.floor(avg));

    int totalCostAtHigh = 0;
    for (int i = 0; i < n; i++) {
      totalCostAtHigh += this.cost(a[i], high);
    }
    if (high == low) {
      System.out.println(totalCostAtHigh);
      return 0;
    }

    int totalCostAtLow = 0;
    for (int i = 0; i < n; i++) {
      totalCostAtLow += this.cost(a[i], low);
    }

    System.out.println(totalCostAtHigh < totalCostAtLow ? totalCostAtHigh : totalCostAtLow);
  }

  public int cost(int from, int to) {
    if (from == to) {
      return 0;
    }

    return (from - to) * (from - to);
  }
}


Compiler output:
Main.java:38: error: incompatible types: unexpected return value
      return 0;
             ^
1 error
Language: C

#include<stdio.h>
void swap(int* a,int* b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}
void sorted_array(int* array,int n){
  int i,j;
  int min_i;
  for(i=0;i<n-1;i++){
    min_i = i;
    for(j=i+1;j<n;j++){
      if(arr[j]<min_i){
        min_i=j;
      }
    }
    swap(&arr[i],&arr[min_i]);
  }
}
int min(int a,int b){
  if(a>b) return b;
  else return a;
}   
int main(){
  int n;
  scanf("%d\n",&n);
  int arr[n];
  int i;
  for(i=0;i<n;i++){
    scanf("%d ",&arr[i]);
  }
  sorted_array(&arr,n);
  int min,max;
  min= arr[0],max= arr[n-1];
  int min_sum = 1000000;
  int k;
  for(i=min;i<=max;i++){
    int sum = 0;
    for(j=0;j<n;j++){
      sum = sum + (arr[j]-i)*(arr[j]-i);
    }
    k = sum;
    int d = min(min_sum,k);
    if(d==k){
      min_sum = k;
    }
  }
  printf("%d\n",min_sum);
  return 0;
}
  
  

Compiler output:
main.c: In function 'sorted_array':
main.c:14:10: error: 'arr' undeclared (first use in this function); did you mean 'array'?
   14 |       if(arr[j]<min_i){
      |          ^~~
      |          array
main.c:14:10: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:33:16: error: passing argument 1 of 'sorted_array' from incompatible pointer type [-Wincompatible-pointer-types]
   33 |   sorted_array(&arr,n);
      |                ^~~~
      |                |
      |                int (*)[n]
main.c:8:24: note: expected 'int *' but argument is of type 'int (*)[n]'
    8 | void sorted_array(int* array,int n){
      |                   ~~~~~^~~~~
main.c:40:9: error: 'j' undeclared (first use in this function)
   40 |     for(j=0;j<n;j++){
      |         ^
main.c:44:13: error: called object 'min' is not a function or function pointer
   44 |     int d = min(min_sum,k);
      |             ^~~
main.c:34:7: note: declared here
   34 |   int min,max;
      |       ^~~
Language: C

#include<stdio.h>

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

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

    int sum=0;
    for(int i=-100;i<=100;i++){
      for(int j=0;j<N;j++){
        sum+=(a[j]-i)*(a[j]-i);
      }
      if(i==-100){
        min=sum;
      }else{
        temp=sum;
      }
      if(temp<min){
        temp=min;
      }
      sum=0;
    }
    printf("%d\n",min);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:9: error: 'min' undeclared (first use in this function); did you mean 'main'?
   18 |         min=sum;
      |         ^~~
      |         main
main.c:18:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:20:9: error: 'temp' undeclared (first use in this function)
   20 |         temp=sum;
      |         ^~~~
Language: C

#include<stdio.h>

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

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

    int sum=0;
    int min=0;
    int temp=0;
    for(int i=-100;i<=100;i++){
      for(int j=0;j<N;j++){
        sum+=(a[j]-i)*(a[j]-i);
      }
      if(j==-100){
        min=sum;
      }else{
        temp=sum;
      }
      if(temp<sum){
        temp=sum;
      }
      sum=0;
    }
    printf("%d\n",min);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:19:10: error: 'j' undeclared (first use in this function)
   19 |       if(j==-100){
      |          ^
main.c:19:10: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>

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

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

    int min=0;
    int temp=0;
    for(int i=-100;i<=100;i++){
      for(int j=0;j<N;j++){
        if(i==-100){
            min+=(a[j]-i)*(a[j]-i);];
        }else{
            temp+=(a[j]-i)*(a[j]-i);
        }
        if(temp<min){
            min=temp;
        }
      }
    }
    printf("%d\n",min);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:17:36: error: expected statement before ']' token
   17 |             min+=(a[j]-i)*(a[j]-i);];
      |                                    ^
Language: C

#include <stdio.h>

int main (void){

	long long N,A[101],B[101]i,j,k;
  	long long sum = 0;
  	long long min=10000*10000;
  	scanf("%lld",&N);
  	for(i=0;i<N;i++){
    	scanf("&lld",A[i]);
    }
  	
  	for(i=0;i<101;i++){
    	for(j=0;j<N;j++){
        	B[j] = (A[j]-i)*(A[j]-i);
          	sum +=B[j];
        }
      	if(min>sum){
        	min=sum;
        }
      	sum=0;
    }
  	printf("%d",sum);
  
}

Compiler output:
main.c: In function 'main':
main.c:5:34: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'i'
    5 |         long long N,A[101],B[101]i,j,k;
      |                                  ^
main.c:9:13: error: 'i' undeclared (first use in this function)
    9 |         for(i=0;i<N;i++){
      |             ^
main.c:9:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:14:13: error: 'j' undeclared (first use in this function)
   14 |         for(j=0;j<N;j++){
      |             ^
main.c:15:17: error: 'B' undeclared (first use in this function)
   15 |                 B[j] = (A[j]-i)*(A[j]-i);
      |                 ^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.File;
import java.util.*;

public class C {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int arr[] = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        Solver solver = new Solver();
        solver.solve(arr);
        System.out.println(output);
    }

}

class Solver {
    public void solve(int arr[]) {
        int ans = Integer.MAX_VALUE;
        for (int i = -100; i <= 100; i++) {
            // Try each number to find min
            int curr = 0;
            for (int j = 0; j < arr.length; j++) {
                curr += (arr[j] - i) * (arr[j] - i);
            }
            ans = Math.min(curr, ans);
            // arr[idx] - i
        }
        C.output.append(ans);
    }
}

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

#include <bits/stdc++.h>

#define ll long long

using namespace std;

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

    int ans = 0;
    ll curr_min = INT_MAX;

    for (int i = -100; i <= 100; i++) {
        int curr = 0;
        for (int j = 0; j < n; j++) {
            curr += (arr[j] - i * arr[j] - i);
        }

        curr_min = min(curr_min, curr);
        ans = min(ans, curr);
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:23: error: no matching function for call to 'min(long long int&, int&)'
   22 |         curr_min = min(curr_min, curr);
      |                    ~~~^~~~~~~~~~~~~~~~
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: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:22:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   22 |         curr_min = min(curr_min, curr);
      |                    ~~~^~~~~~~~~~~~~~~~
/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:22:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   22 |         curr_min = min(curr_min, curr);
      |                    ~~~^~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
 
using namespace std;

int main() 
{
     int n,ans=100000000;
     cin>>n;

     int a[n+5];
     
        for(int i=0; i<n; i++) cin>>a[i];
 
        for(int i=-100;i<=100;i++)
        {
            int cost=0;
            for(int j=0;j<n;j++)
            {
               cost+=(i-a[j])*(i-a[j]);
            }
            ans=min(ans,cost);
        }
         cout<<ans<<endl;
    }
}

Compiler output:
a.cc:40:1: error: expected declaration before '}' token
   40 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int c(int d,vector<int> v){
    int e = 0;
    int n = v.size();
    for (int y=0;y<n;y++){
        e =(v[y]-d)*(v[y]-d) + e;
    }
    return e;
}
int main() {
    int a=0;
    int n; cin>>n;
    vector<int> v(n);
    for (int i=0;i<n;i++){
        cin>>v[i];
    }
    for (int u=0;u<n;u++){
        a = v[u]+a;
    }
    int b = a/n;
    cout << min(c(b,v),c(b+1,v));

Compiler output:
a.cc: In function 'int main()':
a.cc:22:34: error: expected '}' at end of input
   22 |     cout << min(c(b,v),c(b+1,v));
      |                                  ^
a.cc:11:12: note: to match this '{'
   11 | int main() {
      |            ^
Language: C++

#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int min_cost=100000000;
  for(int i=-100;i<=100;i++){
    int cost=0;
    for(int j=0;j<n;j++){
      int b=a[j]-i;
      cost+=pow(b,2);
    }
    min_cost=min(min_cost,cost);
  }
  cout<<min_cost<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int> a(n);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int> a(n);
      |          ^~~
a.cc:8:10: error: 'a' was not declared in this scope
    8 |     cin>>a[i];
      |          ^
a.cc:14:13: error: 'a' was not declared in this scope
   14 |       int b=a[j]-i;
      |             ^
a.cc:15:13: error: 'pow' was not declared in this scope
   15 |       cost+=pow(b,2);
      |             ^~~
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int min_cost=100000000;
  for(int i=-100;i<101;i++){
    int cost=0;
    for(int j=0;j<N;j++){
      int B=A.at(j)-i;
      cost+=pow(B,2);
    }
    min_cost=min(min_cost,cost);
  }
  cout << min_cost << endl;

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

#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    ll tmp = 0;
    ll ans = 1e9;
    rep(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    for(int i = -100;i<=100;i++){
        tmp = 0;
        rep(j,n){
            temp += (a[j]-i)*(a[j]-i);
        }
        ans = min(tmp,ans);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:13: error: 'temp' was not declared in this scope; did you mean 'tmp'?
   21 |             temp += (a[j]-i)*(a[j]-i);
      |             ^~~~
      |             tmp
Language: C++

#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    ll tmp = 0;
    ll ans = 1e9;
    rep(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    for(int i = -100;i<=100;i++){
        tmp = 0;
        rep(i,n){
            temp += (a[i]-i)*(a[i]-i);
        }
        ans = min(tmp,ans);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:13: error: 'temp' was not declared in this scope; did you mean 'tmp'?
   21 |             temp += (a[i]-i)*(a[i]-i);
      |             ^~~~
      |             tmp
Language: C++

//C - Be Together
int N;
int a[101];

int main()
{
	int min = -101,max = 101,mincost;
	scanf("%d",&N);

	for (int i=1;i<=N;i++)
	{
		scanf("%d",&a[i]);

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

	mincost = computeCost(min);

	for (int j=min;j<=max;j++)
	{
		int cost = computeCost(j);
		if (cost<mincost)
			mincost = cost;
	}

	printf("%d",mincost);

}

int computeCost(int target)
{
	int cost = 0;
	for(int i=1;i<=N;i++)
	{
		cost += (a[i]-target)*(a[i]-target);
	}
	return cost;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'scanf' was not declared in this scope
    8 |         scanf("%d",&N);
      |         ^~~~~
a.cc:20:19: error: 'computeCost' was not declared in this scope
   20 |         mincost = computeCost(min);
      |                   ^~~~~~~~~~~
a.cc:29:9: error: 'printf' was not declared in this scope
   29 |         printf("%d",mincost);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | //C - Be Together
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,m=1000000000,c=0;
	cin>>n;
	vector<int> arr(n);
	for(i=0;i<n;i++)cin>>arr[i];
	for(i=-100;i<=100;i++)
	{
		for(int w:arr)
			cost+=(w-i)*(w-i);
		m=min(m, cost);
 
	}
	cout<<m;
	return 0;
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:25: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   12 |                         cost+=(w-i)*(w-i);
      |                         ^~~~
      |                         cosl
a.cc:13:26: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   13 |                 m=min(m, cost);
      |                          ^~~~
      |                          cosl
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,m=1000000000,c=0;
	cin>>n;
	vector<int> arr(n);
	for (i=0;i<n; ++)cin>>arr[i];
	for(i=-100;i<=100;i++)
	{
		for(int w:arr)
			cost+=(w-i)*(w-i);
		m=min(m, cost);
 
	}
	cout<<m;
	return 0;
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:25: error: expected primary-expression before ')' token
    8 |         for (i=0;i<n; ++)cin>>arr[i];
      |                         ^
a.cc:12:25: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   12 |                         cost+=(w-i)*(w-i);
      |                         ^~~~
      |                         cosl
a.cc:13:26: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   13 |                 m=min(m, cost);
      |                          ^~~~
      |                          cosl