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

#include <iostream>
using namespace std;
char str[120];

int calc2(char *eq){
	int c=0,num[100]={0}, sign[100]={0};
	char *p = eq;
	while(*p){
		if('0'<=*p && *p<='9') num[c]=num[c]*10+*p-'0';
		else{
			if(*p=='+') sign[c]=1;
			else if(*p=='-') sign[c]=2;
			else if(*p=='*') sign[c]=3;
			else if(*p=='/') sign[c]=4;
			else if(*p=='=') break;
			else printf("err %c\n", *p);
			c++;
		}
		p++;
	}
	c++;
	for(int i=0;i<c;i++){
		if(sign[i]==3 || sign[i]==4){
			if(sign[i]==3)	num[i+1] = num[i] * num[i+1];
			if(sign[i]==4)	num[i+1] = num[i] / num[i+1];
			for(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	for(int i=0;i<c;i++){
		if(sign[i]==1 || sign[i]==2){
			if(sign[i]==1)	num[i+1] = num[i] + num[i+1];
			if(sign[i]==2)	num[i+1] = num[i] - num[i+1];
			for(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	return num[0];
}

int calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	int k,ret;
	strcpy(cp, eq);
	if((p=strchr(cp, '('))!=NULL){
		for(k=0,p2=p+1;;p2++)
			if(*p2=='(')k++;
			else if(*p2==')'){
				if(k)k--;
				else break;
			}
		memcpy(buf, p+1, p2-p-1);
		buf[p2-p-1]='=';
		ret = calc(buf);
		*p=0;
		sprintf(buf, "%s%d%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return calc2(cp);
}

int main(){
	int i,j,n;
	char buf[120], p;
	for(cin >> n;n;n--){
		cin >> buf;
		cout << calc(buf) <<endl;
	}
}

Compiler output:
a.cc: In function 'int calc(char*)':
a.cc:52:9: error: 'strcpy' was not declared in this scope
   52 |         strcpy(cp, eq);
      |         ^~~~~~
a.cc:2:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
a.cc:53:15: error: 'strchr' was not declared in this scope
   53 |         if((p=strchr(cp, '('))!=NULL){
      |               ^~~~~~
a.cc:53:15: note: 'strchr' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:60:17: error: 'memcpy' was not declared in this scope
   60 |                 memcpy(buf, p+1, p2-p-1);
      |                 ^~~~~~
a.cc:60:17: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <iostream>
using namespace std;

int calc2(char *eq){
	int c=0,num[100]={0}, sign[100]={0};
	char *p = eq;
	while(*p){
		if('0'<=*p && *p<='9') num[c]=num[c]*10+*p-'0';
		else{
			if(*p=='+') sign[c]=1;
			else if(*p=='-') sign[c]=2;
			else if(*p=='*') sign[c]=3;
			else if(*p=='/') sign[c]=4;
			else if(*p=='=') break;
			else printf("err %c\n", *p);
			c++;
		}
		p++;
	}
	c++;
	for(int i=0;i<c;i++){
		if(sign[i]==3 || sign[i]==4){
			if(sign[i]==3)	num[i+1] = num[i] * num[i+1];
			if(sign[i]==4)	num[i+1] = num[i] / num[i+1];
			for(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	for(int i=0;i<c;i++){
		if(sign[i]==1 || sign[i]==2){
			if(sign[i]==1)	num[i+1] = num[i] + num[i+1];
			if(sign[i]==2)	num[i+1] = num[i] - num[i+1];
			for(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	return num[0];
}

int calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	int k,ret;
	strcpy(cp, eq);
	if((p=strchr(cp, '('))!=NULL){
		for(k=0,p2=p+1;;p2++)
			if(*p2=='(')k++;
			else if(*p2==')'){
				if(k)k--;
				else break;
			}
		memcpy(buf, p+1, p2-p-1);
		buf[p2-p-1]='=';
		ret = calc(buf);
		*p=0;
		sprintf(buf, "%s%d%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return calc2(cp);
}

int main(){
	int i,j,n;
	char buf[120], p;
	for(cin >> n;n;n--){
		cin >> buf;
		cout << calc(buf) <<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int calc(char*)':
a.cc:51:9: error: 'strcpy' was not declared in this scope
   51 |         strcpy(cp, eq);
      |         ^~~~~~
a.cc:2:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
a.cc:52:15: error: 'strchr' was not declared in this scope
   52 |         if((p=strchr(cp, '('))!=NULL){
      |               ^~~~~~
a.cc:52:15: note: 'strchr' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:59:17: error: 'memcpy' was not declared in this scope
   59 |                 memcpy(buf, p+1, p2-p-1);
      |                 ^~~~~~
a.cc:59:17: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

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

long calc2(char *eq){
	long c=0,num[100]={0}, sign[100]={0};
	char *p = eq;
	while(*p){
		if('0'<=*p && *p<='9') num[c]=num[c]*10+*p-'0';
		else{
			if(*p=='+') sign[c]=1;
			else if(*p=='-') sign[c]=2;
			else if(*p=='*') sign[c]=3;
			else if(*p=='/') sign[c]=4;
			else if(*p=='=') break;
			else printf("err %c\n", *p);
			c++;
		}
		p++;
	}
	c++;
	for(long i=0;i<c;i++){
		if(sign[i]==3 || sign[i]==4){
			if(sign[i]==3)	num[i+1] = num[i] * num[i+1];
			if(sign[i]==4)	num[i+1] = num[i] / num[i+1];
			for(long j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	for(long i=0;i<c;i++){
		if(sign[i]==1 || sign[i]==2){
			if(sign[i]==1)	num[i+1] = num[i] + num[i+1];
			if(sign[i]==2)	num[i+1] = num[i] - num[i+1];
			for(long j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	return num[0];
}

long calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	long k,ret;
	strcpy(cp, eq);
	if((p=strchr(cp, '('))!=NULL){
		for(k=0,p2=p+1;;p2++)
			if(*p2=='(')k++;
			else if(*p2==')'){
				if(k)k--;
				else break;
			}
		memcpy(buf, p+1, p2-p-1);
		buf[p2-p-1]='=';
		ret = calc(buf);
		*p=0;
		sprintf(buf, "%s%ld%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return calc2(cp);
}

long main(){
	long i,j,n;
	char buf[120], p;
	for(cin >> n;n;n--){
		cin >> buf;
		cout << calc(buf) <<endl;
	}
	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

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

double calc2(char *eq){
	long c=0, sign[100]={0};
	double num[100]={0};
	char *p = eq;
	while(*p){
		if('0'<=*p && *p<='9') num[c]=num[c]*10+*p-'0';
		else{
			if(*p=='+') sign[c]=1;
			else if(*p=='-') sign[c]=2;
			else if(*p=='*') sign[c]=3;
			else if(*p=='/') sign[c]=4;
			else if(*p=='=') break;
			else printf("err %c\n", *p);
			c++;
		}
		p++;
	}
	c++;
	for(int i=0;i<c-1;i++){
		if(sign[i]==3 || sign[i]==4){
			if(sign[i]==3)	num[i+1] = num[i] * num[i+1];
			if(sign[i]==4)	num[i+1] = num[i] / num[i+1];
			for(long j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	for(int i=0;i<c-1;i++){
		if(sign[i]==1 || sign[i]==2){
			if(sign[i]==1)	num[i+1] = num[i] + num[i+1];
			if(sign[i]==2)	num[i+1] = num[i] - num[i+1];
			for(long j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	return num[0];
}

__int64 calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	long k,ret;
	strcpy(cp, eq);
	if((p=strchr(cp, '('))!=NULL){
		for(k=0,p2=p+1;;p2++)
			if(*p2=='(')k++;
			else if(*p2==')'){
				if(k)k--;
				else break;
			}
		memcpy(buf, p+1, p2-p-1);
		buf[p2-p-1]='=';
		ret = calc(buf);
		*p=0;
		sprintf(buf, "%s%ld%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return (__int64)calc2(cp);
}

int main(){
	long i,j,n;
	char buf[120], p;
	for(cin >> n;n;n--){
		cin >> buf;
		cout << calc(buf) <<endl;
	}
	return 0;
}

Compiler output:
a.cc:50:1: error: '__int64' does not name a type; did you mean '__int64_t'?
   50 | __int64 calc(char *eq){
      | ^~~~~~~
      | __int64_t
a.cc: In function 'int main()':
a.cc:76:25: error: 'calc' was not declared in this scope; did you mean 'calc2'?
   76 |                 cout << calc(buf) <<endl;
      |                         ^~~~
      |                         calc2
Language: C++

#include<isotream>
#include<string>
#include<sstream>
using namespace std;

ll stol(string s){
  stringstream ss(s);
  ll n;
  ss >> n;
  return n;
}

ll parse(int l, int r){
  int n = 0,i;

  for(i=r-1;i>=l;i--){
    if(s[i] == ‘)‘)n++;  if(s[i] == ‘(’)n--;
    if(!n){
      if(s[i] == ‘+’)return parse(l,i)+parse(i+1,r);
      if(s[i] == ‘-’)return parse(l,i)-parse(i+1,r);
    }
  }

  for(i=r-1;i>=l;i--){
    if(s[i] == ‘)‘)n++;  if(s[i] == ‘(’)n--;
    if(!n){
      if(s[i] == ‘*’)return parse(l,i)*parse(i+1,r);
      if(s[i] == ‘/’)return parse(l,i)/parse(i+1,r);
    }
  }

  if(s[l] == ‘(‘ && s[r-1] == ‘)’)return parse(l+1,r-1);
  return stol(s.substr(l,r-l));
}

int main(){
  int n;
  string s;
  cin >> n;
  while(n--){
    cin >> s;
    cout << parse(0,(int)s.size()-1) << endl;
  }
}

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

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

typedef long long ll;

string s;

ll stol(string str){
  stringstream ss(str);
  ll n;
  ss >> n;
  return n;
}

ll parse(int l, int r){
  int num = 0, i;
  for(int i=r-1;i>=l;i--){
    if(s[i] == ')')n++;
    if(s[i] == '(')n--;
    if(!n){
      if(s[i] == '+')return parse(l,i) + parse(i+1,r);
      if(s[i] == '-')return parse(l,i) - parse(i+1,r);
    }
  }
  for(int i=r-1;i>=l;i--){
    if(s[i] == ')')n++;
    if(s[i] == '(')n--;
    if(!n){
      if(s[i] == '*')return parse(l,i) * parse(i+1,r);
      if(s[i] == '/')return parse(l,i) / parse(i+1,r);
    }
  }

  if(s[l] == '(' && s[r-1] == ')')return parse(l+1,r-1);
  return stol( s.substr(l,r-l) );
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << parse(0,(int)s.size()-1) << endl;
  }
}

Compiler output:
a.cc: In function 'll parse(int, int)':
a.cc:20:20: error: 'n' was not declared in this scope
   20 |     if(s[i] == ')')n++;
      |                    ^
a.cc:21:20: error: 'n' was not declared in this scope
   21 |     if(s[i] == '(')n--;
      |                    ^
a.cc:22:9: error: 'n' was not declared in this scope
   22 |     if(!n){
      |         ^
a.cc:28:20: error: 'n' was not declared in this scope
   28 |     if(s[i] == ')')n++;
      |                    ^
a.cc:29:20: error: 'n' was not declared in this scope
   29 |     if(s[i] == '(')n--;
      |                    ^
a.cc:30:9: error: 'n' was not declared in this scope
   30 |     if(!n){
      |         ^
a.cc:37:14: error: call of overloaded 'stol(std::__cxx11::basic_string<char>)' is ambiguous
   37 |   return stol( s.substr(l,r-l) );
      |          ~~~~^~~~~~~~~~~~~~~~~~~
a.cc:10:4: note: candidate: 'll stol(std::string)'
   10 | ll stol(string str){
      |    ^~~~
In file included from /usr/include/c++/14/string:54,
                 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/basic_string.h:4169:3: note: candidate: 'long int std::__cxx11::stol(const std::string&, std::size_t*, int)'
 4169 |   stol(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
Language: C++

n=gets.to_i;n.times{puts eval gets[0..-3]}

Compiler output:
a.cc:1:36: error: too many decimal points in number
    1 | n=gets.to_i;n.times{puts eval gets[0..-3]}
      |                                    ^~~
a.cc:1:1: error: 'n' does not name a type
    1 | n=gets.to_i;n.times{puts eval gets[0..-3]}
      | ^
a.cc:1:13: error: 'n' does not name a type
    1 | n=gets.to_i;n.times{puts eval gets[0..-3]}
      |             ^
Language: C++

n=gets.to_i;n.times{puts eval gets.strip[0..-2]}

Compiler output:
a.cc:1:42: error: too many decimal points in number
    1 | n=gets.to_i;n.times{puts eval gets.strip[0..-2]}
      |                                          ^~~
a.cc:1:1: error: 'n' does not name a type
    1 | n=gets.to_i;n.times{puts eval gets.strip[0..-2]}
      | ^
a.cc:1:13: error: 'n' does not name a type
    1 | n=gets.to_i;n.times{puts eval gets.strip[0..-2]}
      |             ^
Language: C++

#include <iostream>
#include <stack>

using namespace std;

int pri(char ch) 
{
    if (ch == '*' || ch == '/')
        return 2;
    if (ch == '+' || ch == '-')
        return 1;
    else
        return 0;
}

int main()
{
    int n;

    cin >> n;

    while (n--) {
        string exp, cha;
        stack<char> pol;
        stack<int> cal;

        cin >> exp;
        for (int i = 0; i < exp.size() - 1; i++) {
            if ('0' <= exp[i] && exp[i] <= '9') {
                while (true) {
                    cha.push_back(exp[i]);
                    if ('0' > exp[i + 1] || exp[i + 1] > '9') {
                        cha.push_back('.');
                        break;
                    }
                    else
                        i++;
                }
            }
            else if (exp[i] == '(')
                pol.push(exp[i]);
            else if (exp[i] == ')') {
                while (true) {
                    if (pol.top() == '(') {
                        pol.pop();
                        break;
                    }
                    cha.push_back(pol.top());
                    pol.pop();

                }
            }
            else {
                while (!pol.empty()) {
                    if (pri(exp[i]) < pri(pol.top())) {
                        cha.push_back(pol.top());
                        pol.pop();
                    }
                    else 
                        break;
                }
                pol.push(exp[i]);
            }
        }

        while (!pol.empty()) {
            cha.push_back(pol.top());
            pol.pop();
        }

        for (int i = 0; i < cha.size(); i++) {
            if ('0' <= cha[i] && cha[i] <= '9') {
                int tmp = cha[i] - '0';

                while (true) {
                    i++;
                    if (cha[i] == '.') 
                        break;
                    tmp *= 10;
                    tmp += cha[i] - '0';
                }
                cal.push(tmp);
            }
            else {
                int a, b;

                b = cal.top();
                cal.pop();
                a = cal.top();
                cal.pop();

                if (cha[i] == '*') 
                    cal.push(a * b);
                else if (cha[i] == '/') 
                    cal.push(a / b);
                else if (cha[i] == '+') 
                    cal.push(a + b);
                else if (cha[i] == '-') 
                    cal.push(a - b);
            }
        }
        cout << cal.top() << endl;
    }

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

#include <string>
#include <cstring>
#include <cctype>
#include <iostream>
using namespace std;
class ParseError {};

int exp(char* & p);

int num(char* & p) {
    int ret = 0;
    while (isdigit(*p)) {
        ret *= 10;
        ret += *p - '0';
        p++;
    }
    return ret;
}

int fac(char* & p) {
    int ret = 0;
    if (*p == '(') {
        p++;
        ret += exp(p);
        p++;
    } else {
        ret += num(p);
    }
    return ret;
}

int term(char* & p) {
    int ret = fac(p);
    while(1) {
        if (*p == '*') {
            p++;
            ret *= fac(p);
        } else if (*p == '/') {
            p++;
            ret /= fac(p);
        } else {
            break;
        }
    }
    return ret;
}

int exp(char* & p) {
    int ret = term(p);
    while(1) {
        if (*p == '+') {
            p++;
            ret += term(p);
        } else if (*p == '-') {
            p++;
            ret -= term(p);
        } else break;
    }
    return ret;
}

int eval(const string & s){
    char* p = (char*)s.c_str();
    return exp(p);
}

int eval(const char* str){
    char* p = (char*)str;
    return exp(p);
}

using namespace std;

int main(){
    char str[128];
    while(gets(str))
        cout << eval(str) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:11: error: 'gets' was not declared in this scope; did you mean 'getw'?
   76 |     while(gets(str))
      |           ^~~~
      |           getw
Language: C++

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

int exp(char* & p);

int num(char* & p) {
    int ret = 0;
    while (isdigit(*p)) {
        ret *= 10;
        ret += *p - '0';
        p++;
    }
    return ret;
}

int fac(char* & p) {
    int ret = 0;
    if (*p == '(') {
        p++;
        ret += exp(p);
        p++;
    } else {
        ret += num(p);
    }
    return ret;
}

int term(char* & p) {
    int ret = fac(p);
    while(1) {
        if (*p == '*') {
            p++;
            ret *= fac(p);
        } else if (*p == '/') {
            p++;
            ret /= fac(p);
        } else {
            break;
        }
    }
    return ret;
}

int exp(char* & p) {
    int ret = term(p);
    while(1) {
        if (*p == '+') {
            p++;
            ret += term(p);
        } else if (*p == '-') {
            p++;
            ret -= term(p);
        } else break;
    }
    return ret;
}

int eval(const string & s){
    char* p = (char*)s.c_str();
    return exp(p);
}

int eval(const char* str){
    char* p = (char*)str;
    return exp(p);
}

using namespace std;

int main(){
    char str[128];
    while(gets(str))
        cout << eval(str) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:11: error: 'gets' was not declared in this scope; did you mean 'getw'?
   75 |     while(gets(str))
      |           ^~~~
      |           getw
Language: C++

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

using namespace std;
typedef string::const_iterator iter;

int expr(iter &p);
int term(iter& p);
int factor(iter& p);
int number(iter& p);

int expr(iter& p) {
    int r = term(p);
    while(true) {
        if(*p == '+') {
            ++p;
            int rs = term(p);
            r += rs;
        }
        else if(*p == '-') {
            ++p;
            int rs = term(p);
            r -= rs;
        }
        else {
            break;
        }
    }
    return r;
}

int term(iter& p) {
    int r = factor(p);
    while(true) {
        if(*p == '*') {
            ++p;
            int rs = term(p);
            r *= rs;
        }
        else if(*p == '/') {
            ++p;
            int rs = term(p);
            r /= rs;
        }
        else {
            break;
        }
    }
    return r;
}

int factor(iter& p) {
    if(*p == '(') {
        ++p; // skip (
        int r = expr(p);
        ++p; // skip )
        return r;
    }
    
    return number(p);
}

int number(iter& p) {
    int r = 0;
    while(isdigit(*p)) {
        r *= 10;
        r += *p -'0';
        p++;
    }
    return r;
}

int main() {
    int n; cin >> n;
    while(n--) {
        string s; cin >> s;
        iter it = s.begin();
        int res = expr(it);
        cout << res << endl;
    }
}
s

Compiler output:
a.cc:85:1: error: 's' does not name a type
   85 | s
      | ^
Language: Java

import java.util.*;
import java.math.*;

public class M0110 {
    public static void main(String[] args) {
        new M0110().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            String line = sc.nextLine();
            int plusPos = line.indexOf('+');
            int equalPos = line.indexOf('=');
            String leftOp = line.substring(0, plusPos);
            String rightOp = line.substring(plusPos + 1, equalPos);
            String answerOp = line.substring(equalPos + 1);
            int res = -1;
            int start = 0;
            if(leftOp.charAt(0) == 'X' || rightOp.charAt(0) == 'X' || answerOp.charAt(0) == 'X')
                start = 1;
            for(int i = start; i <= 9; i++) {
                BigInteger l = new BigInteger(leftOp.replace("X", Integer.toString(i)));
                BigInteger r = new BigInteger(rightOp.replace("X", Integer.toString(i)));
                BigInteger a = new BigInteger(answerOp.replace("X", Integer.toString(i)));
                if(a.equals(l.add(r))) res = i;
            }
            if(res == -1) System.out.println("NA");
            else System.out.println(res);
        }
    }
}

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

while True:
    try:
        string = raw_input()
    except EOFError:
        break
    for i in range(10):
        translated = string.replace("X", str(i))
        left,right = translated.split("=")
        right = int(right)
        first,second = map(int,left.split("+"))
        if first + second == right:
            print i
            break
    else:
        print "NA"

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
while True:
^
1 error
Language: Java

import java.math.BigInteger;
import java.util.Scanner;

public class Main{

	//????????????X?????????????????°??????????????????
	static String assignX(String str, int attempt){
		char[] chars = new char[str.length()];

        //????????????ASC?????§????????????X?????????????????°???????????´??????
		for(int iChar = 0; iChar < chars.length; iChar++){
			if(str.charAt(iChar) >= '0' && str.charAt(iChar) <= '9'){
				chars[iChar] = str.charAt(iChar);

			} else {
				chars[iChar] = (char)('0' + attempt);
			}
		}
		return String.valueOf(chars);
	}

	public int searchRightX(String str, int answerX){

		//???????????????????????????
		String s1 = str.substring(0, str.indexOf('+'));
		String s2 = str.substring(str.indexOf('+') + 1, str.indexOf('='));
		String s3 = str.substring(str.indexOf('=') + 1);

		//0???9?????¨??¶?????????????????????????????????????????°???????????????
		for(int iTry = 0; iTry < 10; iTry++){

			//iTry??§X?????£??\??????
			String a1 = assignX(s1,iTry);
			String a2 = assignX(s2,iTry);
			String a3 = assignX(s3,iTry);

			//?????¶????????????????????¶????????????????????????
			if(a1.length() != 1 && a1.charAt(0) == '0'){
				continue;
			}
			if(a2.length() != 1 && a2.charAt(0) == '0'){
				continue;
			}
			if(a3.length() != 1 && a3.charAt(0) == '0'){
				continue;
				}

			//?????£?????????????????????????????§???????????????????????????
			//???????????´?????????????????????X????????´??????
			//???????????´??????????????????-1????????´??????
			BigInteger a = new BigInteger(a1);
			BigInteger b = new BigInteger(a2);
			BigInteger c = new BigInteger(a3);
			if(a.add(b).equals(c)){
				return iTry;
			}
		}
		return -1;
	}

	public static void main(String[] args) {

		Main alphametic = new Main();

		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			String str = input.next();

			//X????????????????????????
			int answerX = alphametic.searchRightX(str, answerX);

			//X????????¨????????°????????????????????§??????????????°NA?????????
			if(answerX == -1){
				System.out.println("NA");
			} else {
				System.out.println(answerX);
			}
		}
		input.close();
	}
}

Compiler output:
Main.java:70: error: variable answerX might not have been initialized
			int answerX = alphametic.searchRightX(str, answerX);
			                                           ^
1 error
Language: Java

import java.util.*;class Main{public static void main(String[]a){for(Scanner s=new Scanner(System.in);s.hasNext();){int n=10;l:for(String b=s.next();n-->0;){for(String p:(a=b.replaceAll("X",""+n).split("[\\+=]")))if(p.startsWith("0"))continue l;if(new Long(a[0])+new Long(a[1])==new Long(a[2]))break;}System.out.println(n>=0?n:"NA");}}}}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
import java.util.*;class Main{public static void main(String[]a){for(Scanner s=new Scanner(System.in);s.hasNext();){int n=10;l:for(String b=s.next();n-->0;){for(String p:(a=b.replaceAll("X",""+n).split("[\\+=]")))if(p.startsWith("0"))continue l;if(new Long(a[0])+new Long(a[1])==new Long(a[2]))break;}System.out.println(n>=0?n:"NA");}}}}
                                                                                                                                                                                                                                                                                                                                                ^
1 error
Language: Java

import java.util.Scanner;

//Alphametic
public class AOJ0110 {

	static char[] s;
	static int id;
	
	static boolean exp(){
		int a = fact();
		if(a==-1)return false;
		while(true){
			char c = s[id++];
			if(c=='=')break;
			int x = fact();
			if(x==-1)return false;
			a+=x;
		}
		int b = fact();
		if(b==-1)return false;
		return a==b;
	}
	
	static int fact(){
		int x = s[id++]-'0';
		if(x==0&&Character.isDigit(s[id]))return -1;
		while(Character.isDigit(s[id])){
			x *= 10;
			x += s[id++]-'0';
		}
		return x;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String r = sc.next();
			String ans = "NA";
			for(int i=0;i<10;i++){
				s = (r.replace("X", (char)(i+'0')+"")+"$").toCharArray();
				id = 0;
				if(exp()){
					ans = i+"";
					break;
				}
			}
			System.out.println(ans);
		}
	}
}

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


import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class P0110 {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;sc.hasNext();) {
			String formula = sc.next();
			String[] str = formula.split("[ + = ]");
			boolean f = true;
			for(String s: str) f &= s.charAt(0) != 'X';
			int i=0;
			for(i=f? 0: 1;i<10;i++) {
				if(isequal(formula, i)) break;
			}
			System.out.println((i==10? "NA": i));
		}
	}
	
	boolean isequal(String formula, int i) {
		String[] s = formula.replace('X', (char) (i+'0')).split("[ + = ]");
		return Integer.valueOf(s[0]) + Integer.valueOf(s[1]) == Integer.valueOf(s[2]);
	}

	public static void main(String[] args) {
		new P0110().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Compiler output:
Main.java:6: error: class P0110 is public, should be declared in a file named P0110.java
public class P0110 {
       ^
1 error
Language: Java

import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out = "";
    char[] cs = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    while (scanner.hasNext()) {
      String line = scanner.nextLine();
out += "NA\n";
continue;
      String[] works1 = line.split("=");
      String c = works1[1];
      String[] works2 = works1[0].split("\\+");
      String a = works2[0];
      String b = works2[1];
      boolean flag = false;
      for (int ii = 0; ii <= 9; ii++) {
        int aa = Integer.parseInt(a.replace('X', cs[ii]));
        int bb = Integer.parseInt(b.replace('X', cs[ii]));
        int cc = Integer.parseInt(c.replace('X', cs[ii]));
        if (aa + bb == cc) {
          flag = true;
          out += ii + "\n";
          break;
        }
      }
      if (!flag) {
        out += "NA\n";
      }
    }
    System.out.print(out);
  }
}

Compiler output:
Main.java:12: error: unreachable statement
      String[] works1 = line.split("=");
               ^
1 error
Language: C

#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
void Xtoi
(char*, int);
int cnt;
int main() {
	char f[127], s[127], sum[127];
	char tf[127],ts[127],tsum[127];
	int i, a, b, c,flg;
	while (~fscanf(stdin, "%[0123456789X]+%[0123456789X]=%[0123456789X]", f,s,sum) != NULL) {
		getchar();
		strcpy(tf, f);
		strcpy(ts, s);
		strcpy(tsum, sum);
		flg = 0;
		for (i = 0; i < 10; i++) {
			cnt = 0;
			if (i == 0 && ((f[0] == 'X'&&strlen(f)>1)|| (s[0] == 'X'&&strlen(s) >1) || (sum[0] == 'X'&&strlen(sum) >1))) continue;
			Xtoi(f, i);
			Xtoi(s, i);
			Xtoi(sum, i);
			if (cnt == 0) continue;
			a = atoi(f);
			b = atoi(s);
			c = atoi(sum);
			if (a + b == c) { P(d, i); flg = 1; break; }
			strcpy(f, tf);
			strcpy(s, ts);
			strcpy(sum, tsum);
		}
		if (!flg) puts("NA");
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:16:88: warning: comparison between pointer and integer
   16 |         while (~fscanf(stdin, "%[0123456789X]+%[0123456789X]=%[0123456789X]", f,s,sum) != NULL) {
      |                                                                                        ^~
/usr/bin/ld: /tmp/ccLT0FOT.o: in function `main':
main.c:(.text+0xff): undefined reference to `Xtoi'
/usr/bin/ld: main.c:(.text+0x113): undefined reference to `Xtoi'
/usr/bin/ld: main.c:(.text+0x127): undefined reference to `Xtoi'
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
#include<string.h>
char*p,E0[128],E1[128],da[128],db[128],dc[128],X;
C(){
	int ia,ib,ic,v;
	for(v=ia=ib=ic=0;dc[ic];){
		if(da[ia])
			v+=da[ia++]-'0';
		if(db[ib])
			v+=db[ib++]-'0';
		if(v%10+'0'!=dc[ic++])
			return 0;
		v/=10;
	}
	if(v||da[ia]||db[ib])
		return 0;
	return 1;
}
main(){
	for(;~scanf("%[^\n]\n",E0);){
		for(X='0';X<='9';X++){
			strcpy(E1,E0);
			while(p=strchr(E1,'X'))
				*p=X;
			sscanf(E1,"%[^+]+%[^=]=%s",da,db,dc);
			if(*da=='0'&&da[1]||*db=='0'&&db[1]||*dc=='0'&&dc[1])
				continue;
			strrev(da);
			strrev(db);
			strrev(dc);
			if(C()){
				printf("%c\n",X);
				break;
			}
		}
		if(X=='9'+1)
			puts("NA");
	}
}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | C(){
      | ^
main.c:19:1: error: return type defaults to 'int' [-Wimplicit-int]
   19 | main(){
      | ^~~~
main.c: In function 'main':
main.c:28:25: error: implicit declaration of function 'strrev'; did you mean 'strsep'? [-Wimplicit-function-declaration]
   28 |                         strrev(da);
      |                         ^~~~~~
      |                         strsep
Language: C

#include<iostream>
#include<algorithm>
#include<string>
#define all(c) c.begin(),c.end()
using namespace std;
string sum(string a,string b){
	int n=max(a.size(),b.size());
	for(;a.size()!=b.size();){
		if(a.size()<b.size())
		a+='0';
		else
		b+='0';
	}
	string s="";
	int flag=0;
	for(int i=0;i<n;i++){
		int x=(a[i]-'0')+(b[i]-'0')+flag;
		flag=0;
		if(x>=10){
			x-=10;
			flag=1;
		}
		s+='0'+x;
		
	}
	if(flag)
	s+='1';
	return s;
}
bool cal(string a,string b,string c,int x){
	bool flag=false;
	for(int i=0;i<a.size();i++){
		if(a[i]=='X'){
			a[i]='0'+x;
			flag=true;
		}
	}
	for(int i=0;i<b.size();i++){
		if(b[i]=='X'){
			b[i]='0'+x;
			flag=true;
		}
	}for(int i=0;i<c.size();i++){
		if(c[i]=='X'){
			c[i]='0'+x;
			flag=true;
		}
	}
	if(!flag)
	return false;
	if(sum(a,b)==c)
	return true;
	return false;
}
int main(){
	string s;
	while(cin>>s){
		int p,e,n=s.size();
		for(int i=0;i<n;i++){
			if(s[i]=='+'){
				p=i;
			}else if(s[i]=='='){
				e=i;
			}
		}
		string a=s.substr(0,p),b=s.substr(p+1,e-p-1),c=s.substr(e+1);
		int s=0;
		if((a.size()>1&&a[0]=='X')||(b.size()>1&&b[0]=='X')||(c.size()>1&&c[0]=='X')){
			s=1;
		}
		reverse(all(a));reverse(all(b));reverse(all(c));
		int ans=10;
		for(int i=s;i<=9;i++){
			if(cal(a,b,c,i)){
				if(ans!=10){
					ans=10;
					break;
				}else{
					ans=i;
				}
			}
		}
		if(ans==10)
		cout<<"NA"<<endl;
		else
		cout<<ans<<endl;
	}
	return 0;
}

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

#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
using vi = vector<int>;

string str;
string stra;
int id = 0;

vi number(){
  vi res;
  for (; isdigit(stra[id]); id++) {
    res.push_back(stra[id] - '0');
  }
  reverse(res.begin(),res.end());
  return res;
}
int solve(){
  stra = str;
  for (int i = 9; i >= 0; i--) {
    id = 0;
    for (int j = 0; j <(int)str.size(); j++) {
      if (str[j] == 'X') {
        stra[j] = i + '0';
      }
    }
    vi a = number();
    if (stra[id] == '+' ) {
      id++;
    }  
    vi b = number();
    a.resize(max(b.size() + 1,a.size()+1),0);
    for (size_t j = 0; j < b.size(); j++) {
      a[j] += b[j];
      if (a[j]>=10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }
    for (size_t j = b.size(); j < a.size()-1; j++) {
      if (a[j] >= 10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }
    if (stra[id] == '=') {
      id++;
    }
    b = number();

    if(a[a.size()-1]==0){
      a.pop_back();
    }
    if (a.size() != c.size()) {
      continue;
    }
    
    // if (a.size() >= b.size()) {
    //   b.resize(a.size(),0);
    // } else {
    //   a.resize(b.size(),0);
    // }
    int flag = 0;
    for (size_t j = 0; j < a.size(); j++) {
      if (a[j] == b[j]) {
        flag++;
      }
    }
    if (flag ==(int)a.size()) {
      return i;
    } 
    
  }
  return -1;
}
int main(){
  cin >> str;
  while(str.size()){
  int ans = solve();
  if (ans >= 0) {
    cout << ans << endl;
  } else {
    puts("NA");
  }
  str.clear();
  cin >> str;
}
  return 0;
}



Compiler output:
a.cc: In function 'int solve()':
a.cc:60:21: error: 'c' was not declared in this scope
   60 |     if (a.size() != c.size()) {
      |                     ^
Language: C++

#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<cmath>
using namespace std;
typedef vector<int> vi;

string plus_string(string a,string b)
{
  string c;
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  while(a.size()!=b.size())
    {
      if(a.size()<b.size())
	{
	  a.push_back('0');
	}
      else
	{
	  b.push_back('0');
	}
    }
  for(int i=0;i<(int)a.size();i++)
    {
      c.push_back('0');
    }
  int n=0;
  for(int i=0;i<a.size();i++)
    {
      if(n+(a[i]-'0')+(b[i]-'0')<=9)
	{
	  c[i]=a[i]+b[i]-'0'+n;
	  n=0;
	}
      else
	{
	  c[i]=a[i]+b[i]-'0'-10+n;
	  n=1;
	}
    }
  if(n==1)
    {
      c.push_back('1');
    }
  reverse(c.begin(),c.end());
  return c;
}

string change_x(string s,char c)
{
  for(int i=0;i<(int)s.size();i++)
    {
      if(s[i]=='X') s[i]=c;
    }
  return s;
}

int main()
{
  string s;
  string num1="",num2="";
  string ans="";
  string a,b,c;
  int plus,equal;
  bool clear;
  while(cin >> s)
    {
      clear=false;
      for(int i=0;i<(int)s.size();i++)
	{
	  if(s[i]=='+') plus=i;
	  else if(s[i]=='=') equal=i;
	}
      num1=s.substr(0,plus);
      num2=s.substr(plus+1,equal-plus-1);
      ans=s.substr(equal+1);
      for(int i=0;i<=9;i++)
	{
	  a=change_x(num1,i+'0');
	  b=change_x(num2,i+'0');
	  c=change_x(ans,i+'0');
	  if(plus_string(a,b)==c)
	    {
	      cout << i << endl;
	      clear=true;
	    }
	}
      if(!clear)cout << "NA" << endl;
    }
  return 0;
}



Compiler output:
a.cc: In function 'std::string plus_string(std::string, std::string)':
a.cc:13:3: error: 'reverse' was not declared in this scope
   13 |   reverse(a.begin(),a.end());
      |   ^~~~~~~
Language: C++

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
namespace mp = boost::multiprecision;
using namespace std;
#define INF 0x7FFFFFFF



int main(){
  string s;
  cin >> s;
  mp::cpp_int f=0;
  while(s.size()){
    f=0;
    for(int i=0;i<10;i++){
      string a,b,c,ab;
      int t;
      for(t=0;t<int(s.size())&&s[t]!='+';t++){
        if(s[t]!='X'){
          a.push_back(s[t]);
        }
        else{
          a.push_back(i+'0');
        }
      }
      for(t++;t<int(s.size())&&s[t]!='=';t++){
        if(s[t]!='X'){
          b.push_back(s[t]);
        }
        else{
          b.push_back(i+'0');
        }
      }
      for(t++;t<int(s.size());t++){
        if(s[t]!='X'){
          c.push_back(s[t]);
        }
        else{
          c.push_back(i+'0');
        }
      }
      reverse(a.begin(),a.end());
      reverse(b.begin(),b.end());
      reverse(c.begin(),c.end());
      int j;
      int k=0;
      int l=0;
      for(j=0;j<int(a.size())&&j<int(b.size());j++){
        k=0;
        if(a[j]-'0'+b[j]-'0'+l>=10){
          k++;
          ab.push_back(a[j]-'0'+b[j]+l-10);
        }
        else{
          ab.push_back(a[j]-'0'+b[j]+l);
        }
        l=k;
      }
      for(;j<int(a.size());j++){
        k=0;
        if(a[j]-'0'+l>=10){
          k++;
          ab.push_back(a[j]+l-10);
        }
        else{
          ab.push_back(a[j]+l);
        }
        l=k;
      }
      for(;j<int(b.size());j++){
        k=0;
        if(b[j]-'0'+l>=10){
          k++;
          ab.push_back(b[j]+l-10);
        }
        else{
          ab.push_back(b[j]+l);
        }
        l=k;
      }
      if(l>0){
        ab.push_back(l+'0');
      }
      if(ab==c){
        f++;
        cout << i << endl;
        break;
      }
    }
    if(f==0){
      cout << "NA" << endl;
    }
    s="";
    cin >> s;
  }
}



Compiler output:
a.cc:7:16: error: 'boost' has not been declared
    7 | namespace mp = boost::multiprecision;
      |                ^~~~~
a.cc:7:23: error: 'multiprecision' is not a namespace-name
    7 | namespace mp = boost::multiprecision;
      |                       ^~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:16:3: error: 'mp' has not been declared
   16 |   mp::cpp_int f=0;
      |   ^~
a.cc:18:5: error: 'f' was not declared in this scope
   18 |     f=0;
      |     ^
Language: C++

#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
using vi = vector<int>;

string str;
string stra;
int id = 0;

vi number(){
  vi res;
  for (;id<(int)str.size() && isdigit(stra[id]); id++) {
    res.push_back(stra[id] - '0');
  }
  reverse(res.begin(),res.end());
  return res;
}
int solve(){
  stra = str;
  for (int i = 9; i >= 1; i--) {
    id = 0;
    for (int j = 0; j <(int)str.size(); j++) {
      if (str[j] == 'X') {
        stra[j] = i + '0';
      }
    }
    vi a = number();
    if (stra[id] == '+' ) {
      id++;
    }  
    vi b = number();
    a.resize(max(b.size() + 1,a.size()+1),0);
    for (size_t j = 0; j < b.size(); j++) {
      a[j] += b[j];
      if (a[j]>=10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }
    for (size_t j = b.size(); j < a.size()-1; j++) {
      if (a[j] >= 10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }
    if (stra[id] == '=') {
      id++;
    }
    b = number();
    if (a.size() >= b.size()) {
      b.resize(a.size(),0);
    } else {
      a.resize(b.size(),0);
    }
    int flag = 0;
    for (size_t j = 0; j < a.size(); j++) {
      if (a[j] == b[j]) {
        flag++;
      }
    }
    if (flag ==(int)a.size()) {
      return i;
    } 
  }

    id = 0;
    for (int j = 0; j <(int)str.size(); j++) {
      if (str[j] == 'X') {
        if (j == 0) {
          return -1;
        } else if(str[j-1] == '=' || str[j-1] == '+'){
          return -1;
        }
        stra[j] = i + '0';
      }
    }
    vi a = number();
    if (stra[id] == '+' ) {
      id++;
    }  
    vi b = number();
    a.resize(max(b.size() + 1,a.size()+1),0);
    for (size_t j = 0; j < b.size(); j++) {
      a[j] += b[j];
      if (a[j]>=10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }
    for (size_t j = b.size(); j < a.size()-1; j++) {
      if (a[j] >= 10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }
    if (stra[id] == '=') {
      id++;
    }
    b = number();
    if (a.size() >= b.size()) {
      b.resize(a.size(),0);
    } else {
      a.resize(b.size(),0);
    }
    int flag = 0;
    for (size_t j = 0; j < a.size(); j++) {
      if (a[j] == b[j]) {
        flag++;
      }
    }
    if (flag ==(int)a.size()) {
      return i;
    } 
    
  
  return -1;
}
int main(){
  cin >> str;
  while(str.size()){
  int ans = solve();
  if (ans >= 0) {
    cout << ans << endl;
  } else {
    puts("NA");
  }
  str.clear();
  cin >> str;
}
  return 0;
}


Compiler output:
a.cc: In function 'int solve()':
a.cc:80:19: error: 'i' was not declared in this scope
   80 |         stra[j] = i + '0';
      |                   ^
a.cc:118:14: error: 'i' was not declared in this scope
  118 |       return i;
      |              ^
Language: C++

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <vector>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

vector<string> split(const string &str, char delim)
{
  vector<string> res;
  size_t current = 0, found;
  while((found = str.find_first_of(delim, current)) != string::npos)
  {
    res.push_back(string(str, current, found - current));
    current = found + 1;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}

vector<char> splus(string s,string s1)
{

	reverse(s.begin(),s.end());
	reverse(s1.begin(),s1.end());

	while(s.size() > s1.size())
	{
		s1 += '0';
	}

	while(s1.size() > s.size())
	{
		s += '0';
	}

	reverse(s.begin(),s.end());
	reverse(s1.begin(),s1.end());

	vector<char> ans;

	int up = 0;
	for(int i=s.size()-1 ; i >= 0;i--)
	{
		int t = (s[i] - '0') + (s1[i] - '0');
		if(up == 0)
		{
			if(t > 9)
			{
				up = (t/10);
				t %= 10;
				ans.push_back(t + '0');
			}
			else
			{
				ans.push_back(t + '0');
			}
		}
		else
		{
			t += up;
			up = 0;

			if(t > 9)
			{
				up = t/10;
				t %= 10;
				ans.push_back(t + '0');
			}
			else
			{
				ans.push_back(t + '0');
			}
		}
	}
	if(up != 0)
	{
		ans.push_back(up + '0');
		up = 0;
	}

	reverse(ans.begin(),ans.end());
	return ans;
}

int main()
{
	string s;
	while(cin >> s)
	{
		vector<string> _s = split(s,'+');
		vector<string> _s_1 = split(_s[1],'=');

		bool flag = true;
		rep(i,10)
		{
			string a = _s[0];
			string b = _s_1[0];
			string c = _s_1[1];

			if(a[0] == 'X' || b[0] == 'X' || c[0] == 'X')
			{
				i++;
			}			

			rep(j,a.size())
			{
				if(a[j] == 'X') a[j] =  i + '0';
			}

			rep(j,b.size())
			{
				if(b[j] == 'X') b[j] = i + '0';
			}

			rep(j,c.size())
			{
				if(c[j] == 'X') c[j] = i + '0';
			}

			vector<char> temp = splus(a,b);
			bool ok = true;
			rep(i,temp.size())
			{
				if(temp[i] != c[i])
				{
					ok = false;
				}
			}

			if(ok)
			{
				flag = false;
				cout << i << endl;
				break;
			}
		}

		if(flag)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'std::vector<char> splus(std::string, std::string)':
a.cc:27:9: error: 'reverse' was not declared in this scope
   27 |         reverse(s.begin(),s.end());
      |         ^~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

bool valid(const string& s)
{
  stringstream ss(s);
  string a, b, c;
  ss >> a >> b >> c;
  if (a.size() > 1u && a[0] == '0') return false;
  if (b.size() > 1u && b[0] == '0') return false;
  if (c.size() > 1u && c[0] == '0') return false;
  return (stoll(a) + stoll(b) == stoll(c));
}


int main()
{
  string s;
  while (cin >> s){
    for (int i = 0; i < 10; i++){
      string sc = s;
      for (auto& c : sc){
        if (c == 'X') c = '0' + i;
        if (!isdigit(c)) c = ' ';
      }
      if (valid(c)){
        cout << i << endl;
        goto END;
      }
    }
    cout << "NA" << endl;
END:;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:17: error: 'c' was not declared in this scope; did you mean 'sc'?
   55 |       if (valid(c)){
      |                 ^
      |                 sc
Language: C++

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

long long toLong(string str, int n)
{
	long long res = 0;
	for (int i = 0; i < str.size(); i++){
		if (str[i] != 'X'){
			res = res * 10 + str[i] - '0';
		}
		else {
			if (i == 0) return -1;
			res = res * 10 + n;
		}
	}
	return res;
}

int main()
{
	//char A[128], B[128], C[128];
	while (true){
		string str[3];
		string line;
		if (!(cin >> line)) return 0;
		
		for (int p = 0, i = 0; p < line.size(); p++){
			if (line[p] != '+' && line[p] != '='){
				str[i] += line[p];
			}
			else {
				i++;
			}
		}
		
		int res = -1;
		for (int i = 0; i <= 9; i++){
			if (toLong(str[0], i) + toLong(str[1], i) - toLong(str[2], i) == 0)){
				res = i;
			}
		}
		
		if (res != -1) printf("%d\n", res);
		else puts("NA");
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:92: error: expected primary-expression before ')' token
   38 |                         if (toLong(str[0], i) + toLong(str[1], i) - toLong(str[2], i) == 0)){
      |                                                                                            ^
Language: C++

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

long long toLong(string str, int n)
{
	long long res = 0;
	for (int i = 0; i < str.size(); i++){
		if (str[i] != 'X'){
			res = res * 10 + str[i] - '0';
		}
		else {
			if (i == 0 && n == 0) return -1;
			res = res * 10 + n;
		}
	}
	return res;
}

int main()
{
	//char A[128], B[128], C[128];
	while (true){
		string str[3];
		string line;
		if (!(cin >> line)) return 0;
		
		for (int p = 0, i = 0; p < line.size(); p++){
			if (line[p] != '+' && line[p] != '='){
				str[i] += line[p];
			}
			else {
				i++;
			}
		}
		
		int res = -1;
		for (int i = 0; i <= 9; i++){
			if (toLong(str[0], i) + toLong(str[1], i) - toLong(str[2], i) == 0)){
				res = i;
			}
		}
		
		if (res != -1) printf("%d\n", res);
		else puts("NA");
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:92: error: expected primary-expression before ')' token
   38 |                         if (toLong(str[0], i) + toLong(str[1], i) - toLong(str[2], i) == 0)){
      |                                                                                            ^
Language: C++

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

long long toLong(string str, int n)
{
	long long res = 0;
	for (int i = 0; i < str.size(); i++){
		if (str[i] != 'X'){
			res = res * 10 + str[i] - '0';
		}
		else {
			if (i == 0 && n == 0) return 100;
			res = res * 10 + n;
		}
	}
	return res;
}

int main()
{
	//char A[128], B[128], C[128];
	while (true){
		string str[3];
		string line;
		if (!(cin >> line)) return 0;
		
		for (int p = 0, i = 0; p < line.size(); p++){
			if (line[p] != '+' && line[p] != '='){
				str[i] += line[p];
			}
			else {
				i++;
			}
		}
		
		int res = -1;
		for (int i = 0; i <= 9; i++){
			if (toLong(str[0], i) + toLong(str[1], i) - toLong(str[2], i) == 0)){
				res = i;
			}
		}
		
		if (res != -1) printf("%d\n", res);
		else puts("NA");
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:92: error: expected primary-expression before ')' token
   38 |                         if (toLong(str[0], i) + toLong(str[1], i) - toLong(str[2], i) == 0)){
      |                                                                                            ^