Go: package main

import (
	"bufio"
	"fmt"
	"go/token"
	"go/types"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())
	for i := 0; i < n; i++ {
		stdin.Scan()
		exp := strings.TrimRight(stdin.Text(), "=")
		res, _ := types.Eval(token.NewFileSet(), nil, token.NoPos, exp)
		fmt.Println(res.Value)
	}
}

C++: #include<iostream>
#include<queue>
#include<string>
#include<cctype>
#include<cassert>
using namespace std;

//????¨???????????¶????????????¨???????????????
class CAL{
private:
  string m_str;
  size_t m_cur;
  int digit();
  int number();
  int term();
  int expression();
  int factor();
  int calterm();
public:
  CAL(string str);
  int cal();
};

//?????????????????????
CAL::CAL(string str):
  m_cur(0)
{
  m_str = str;
  m_str.resize(m_str.size() - 1);
}

//??????????????°????????°????????????
int CAL::digit()
{
  assert(isdigit(m_str[m_cur]));
  int n = m_str[m_cur++] - '0';
  return n;
}

//??°??????????????¨?????¨???????????°?????¨????????????
int CAL::number()
{
  int n = digit();
  while(m_cur < m_str.size() && isdigit(m_str[m_cur]))
    n = n*10 + digit();
  return n;
}

//???????????¨?????????????°???\
int CAL::term()
{
  int a = number();
  while(m_cur < m_str.size() && (m_str[m_cur] == '*' || m_str[m_cur] == '/')){
    char op = m_str[m_cur++];
    int b = number();
    if(op == '*') a *= b; else if(op == '/') a /= b;
  }
  return a;
}

//??¬??§???????????????????????????
int CAL::expression()
{
  int a = term();
  while(m_cur < m_str.size() && (m_str[m_cur] == '+' || m_str[m_cur] == '-')){
    char op = m_str[m_cur++];
    int b = term();
    if(op == '+') a += b; else if(op == '-') a -= b;
  }
  return a;
}

//??¬??§???????????????????????°?????¨?????????????????????number()??????????????????
int CAL::factor()
{
  if(m_str[m_cur] != '(') return number();
  m_cur += 1;
  int n = expression();
  assert(m_str[m_cur] == ')');
  m_cur += 1;
  return n;
}

//??¬??§????????£?????´?????????????????¨?????????????°???\
int CAL::calterm()
{
  int a = factor();
  while(m_cur < m_str.size() && (m_str[m_cur] == '*' || m_str[m_cur] == '/')){
    char op = m_str[m_cur++];
    int b = factor();
    if(op == '*') a *= b; else if(op == '/') a /= b;
  }
  return a;
}

//??¬??§????????£?????´???????????????????????????????¨????
int CAL::cal()
{
  int a = calterm();
  while(m_cur < m_str.size() && (m_str[m_cur] == '+' || m_str[m_cur] == '-')){
    char op = m_str[m_cur++];
    int b = calterm();
    if(op == '+') a += b; else if(op == '-') a -= b;
  }
  return a;
}

int main()
{
  int N;
  cin >> N;
  queue<int> answer;
  string str;
  for(int i = 0; i < N; ++i){
    cin >> str;
    CAL a(str);
    answer.push(a.cal());
  }
  while(!answer.empty()){
    cout << answer.front() << endl;
    answer.pop();
  }
}

C++: #include <iostream>
#include <string>
#include <sstream>
using namespace std;

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


string foo2(string s){
	cout<<s<<endl;
	bool f=true;
	rep(i,s.size()){
		if(i==0){
			if(s[0]=='-');
			else f=false;
		}
		else{
			if(s[i]>='0'&&s[i]<='9'){

			}
			else{
				f=false;
			}
		}
	}
	if(f) return s;
	// bool f=false;
	rep(i,s.size()){
		if(s[i]=='*'||s[i]=='/'){
			int xl=i,xr=i;
			f=true;
			while(1){
				if(xl==0) break;
				else if(s[xl-1]>='0'&&s[xl-1]<='9'){
					xl--;
				}
				else{
					
					break;
				}
			}
			while(1){
				if(xr==s.size()-1) break;
				else if(s[xr+1]>='0'&&s[xr+1]<='9'){
					xr++;
				}
				else{
					
					break;
				}
			}
			stringstream ss1,ss2;
			// cout<<s.substr(xl,xr-xl+1)<<endl;
			ss1<<s.substr(xl,xr-xl+1);
			int a,b;
			char t;
			ss1>>a;
			// cout<<"a "<<a<<endl;
			ss1>>t;
			ss1>>b;
			ss2<<s.substr(0,xl);
			int tt;
			if(t=='*'){
				tt=a*b;
			}
			else{
				tt=a/b;
			}
			ss2<<tt;
			ss2<<s.substr(xr+1);
			ss2>>s;
			// cout<<"foo2 "<<s<<" "<<endl;
			return foo2(s);
		}
	}
	rep(i,s.size()){
		if(s[i]=='+'||s[i]=='-'){
			int xl=i,xr=i;
			f=true;
			while(1){
				if(xl==0) break;
				else if(s[xl-1]>='0'&&s[xl-1]<='9'){
					xl--;
				}
				else{
					break;
				}
			}
			while(1){
				if(xr==s.size()-1) break;
				else if(s[xr+1]>='0'&&s[xr+1]<='9'){
					xr++;
				}
				else{
					break;
				}
			}
			stringstream ss1,ss2;
			ss1<<s.substr(xl,xr-xl+1);
			int a,b;
			char t;
			ss1>>a;
			ss1>>t;
			ss1>>b;
			ss2<<s.substr(0,xl);
			int tt;
			if(t=='+'){
				tt=a+b;
			}
			else{
				tt=a-b;
				// cout<<tt<<endl;
			}
			ss2<<tt;
			ss2<<s.substr(xr+1);
			ss2>>s;
			return foo2(s);
		}
	}
	return s;
}

string foo1(string s){
	// cout<<s<<endl;
	int xl=-1,xr=-1;
	rep(i,s.size()){
		if(s[i]=='('){
			xl=i;
		}
		else if(s[i]==')'){
			xr=i;
			break;
		}
	}
	if(xr!=-1){
		return foo1(s.substr(0,xl)+foo2(s.substr(xl+1,xr-xl-1))+s.substr(xr+1));
	}
	return foo2(s);
}

string solve(string s){
	return foo1(s);
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		s=s.substr(0,s.size()-1);
		s=solve(s);
		cout<<s<<endl;
	}
}

C++: #include<iostream>
#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;
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int t;
int N;
int d[110], f[110];
vector<vector<int> > adj(110);
void dfs(int cur){
    d[cur] = t;
    t += 1;
    //cerr << "visiting " << cur << " " << t << endl;
    for(int i = 0; i < adj[cur].size(); ++i){
        int dst = adj[cur][i];
        if(d[dst] == 0){
            dfs(dst);
        }
    }
    f[cur] = t;
    t++;
}

int main(){
    cin >> N;
    t = 1;
    int u, k;
    for(int i = 0; i < N; ++i){
        d[i] = 0;
        f[i] = 0;
    }
    for(int i = 0; i < N; ++i){
        cin >> u >> k;
        for(int j = 0; j < k; j++){
            int v;
            cin >> v;
            adj[u].push_back(v);
        }
        sort(adj[u].begin(), adj[u].end());
    }
    for(int i = 1; i < N+1; ++i){
        if(d[i] == 0) dfs(i);
    }
    
    for(int i = 1; i < N+1; ++i){
        cout << 1 << " " << d[i] << " " << f[i] << endl;
    }
}