Language: C++

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

std::string find(std::vector<std::string>&v, long long a, bool b){

	std::string res;

	if (b){
		for (long long i = a - 1; i >= 0; i--){
			if (v[i] != "T"){
				res = v[i];
				v[i] = "T";
				break;
			}
		}
	}

	if (!b){
		for (long long i = a + 1; i < v.size(); i++){
			if (v[i] != "T"){
				res = v[i];
				v[i] = "T";
				break;
			}
		}
	}

	return res;
}

long long tolong long(std::string str){

	long long res;
	std::stringstream z;

	z << str;
	z >> res;

	return res;

}

std::string tostring(long long a){

	std::string str;
	std::stringstream z;

	z << a;
	z >> str;

	return str;

}

std::string keisan(std::string lhs, std::string rhs, long long t){

	long long a, b, c;

	a = tolong long(lhs);
	b = tolong long(rhs);

	if (t == 1)c = a + b;
	if (t == 2)c = a - b;
	if (t == 3)c = a * b;
	if (t == 4)c = a / b;

	return tostring(c);

}

std::string keisan2(std::vector<std::string> &v){

	long long res = 0;

	for (long long i = 0, j = 0, c = 0; i < v.size(); i++){

		if (v[i] == "("){
			if (c == 0)j = i;
			c++;
		}

		if (v[i] == ")"){
			c--;
			if (c == 0){
				std::vector<std::string>w;
				for (long long p = j + 1; p < i; p++)w.push_back(v[p]);
				v[j] = keisan2(w);
				for (long long p = j + 1; p <= i; p++)v[p] = "T";
			}
		}
	}


	for (long long i = 0; i < v.size(); i++){
		if (v[i] == "*"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 3);
			v[i] = v[i + 1] = "T";
		}
		if (v[i] == "/"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 4);
			v[i] = v[i + 1] = "T";
		}
	}

	for (long long i = 0; i < v.size(); i++){
		if (v[i] == "+"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 1);
			v[i] = v[i + 1] = "T";
		}

		if (v[i] == "-"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 2);
			v[i] = v[i + 1] = "T";
		}
	}

	v[v.size() - 1] = "T";
	for (long long i = 0; i < v.size(); i++){
		if (v[i] != "T")res = tolong long(v[i]);
	}
	return tostring(res);

}


long long main(){

	long long n;
	std::cin >> n;

	for (long long i = 0; i < n; i++){

		std::string str;

		std::cin >> str;

		std::vector<std::string> v;

		for (long long i = 0, j = 0; i < str.size(); i++){

			if (!(str[i] >= '0'&&str[i] <= '9')){
				if (i - j > 0)v.push_back(str.substr(j, i - j));
				v.push_back(str.substr(i, 1));
				j = i + 1;
			}
		}

		std::cout << keisan2(v) << std::endl;
	}

	return 0;
}

Compiler output:
a.cc:34:18: error: expected initializer before 'long'
   34 | long long tolong long(std::string str){
      |                  ^~~~
a.cc: In function 'std::string keisan(std::string, std::string, long long int)':
a.cc:62:13: error: 'tolong' was not declared in this scope; did you mean 'ulong'?
   62 |         a = tolong long(lhs);
      |             ^~~~~~
      |             ulong
a.cc: In function 'std::string keisan2(std::vector<std::__cxx11::basic_string<char> >&)':
a.cc:122:39: error: 'tolong' was not declared in this scope; did you mean 'ulong'?
  122 |                 if (v[i] != "T")res = tolong long(v[i]);
      |                                       ^~~~~~
      |                                       ulong
At global scope:
cc1plus: error: '::main' must return 'int'