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)
	}
}

Python: # AOJ 0109 Smart Calculator
# Python3 2018.6.18 bal4u

INF = 1000000010
LEFT  = INF+1
RIGHT = INF+2
PLUS  = INF+3
MINUS = INF+4
MUL   = INF+5
DIV   = INF+6
token = { '+':PLUS, '-':MINUS, '*':MUL, '/':DIV }
rank = { PLUS:2, MINUS:2, MUL:3, DIV:3, LEFT:1, RIGHT:1 }

S, top = [0]*200, 0
Q, end = [0]*200, 0

def getInt():
	global id
	global buf
	k = ''
	while buf[id] >= '0' and buf[id] <= '9':
		k += buf[id]
		id += 1
	return int(k)

n = int(input())
for i in range(n):
	buf = list(input())
	id, f, top, end = 0, True, 0, 0
	while True:
		if buf[id] == '=':
			while top > 0:
				top -= 1
				Q[end] = S[top]
				end += 1
			break;
		if buf[id] == '-' and f and buf[id+1] >= '0' and buf[id+1] <= '9':
			id += 1
			Q[end] = -getInt()
			end += 1
			f = False
			continue
		
		f = False
		if buf[id] >= '0' and buf[id] <= '9':
			Q[end] = getInt()
			end += 1
		elif buf[id] == ')':
			while S[top - 1] != LEFT:
				top -= 1
				Q[end] = S[top]
				end += 1
			top -= 1
			id += 1
		elif buf[id] == '(':
			S[top] = LEFT
			top += 1
			id += 1
			f = True
		else:
			k = token[buf[id]]
			id += 1
			while top > 0:
				if rank[k] <= rank[S[top-1]]:
					top -= 1
					Q[end] = S[top];
					end += 1
				else: break
			S[top] = k;
			top += 1
	top = 0
	for i in range(end):
		k = Q[i]
		if k > INF:
			d1, d2 = S[top-1], S[top-2]
			top -= 2
			if k == PLUS: d2 += d1
			elif k == MINUS: d2 -= d1
			elif k == MUL: d2 *= d1
			else:
				d2 //= d1
				if d2 < 0: d2 += 1	## -5 // 2 = -3 (Pythonでは)
			S[top] = d2
		else: S[top] = k
		top += 1
	print(S[top-1])

Python: 
import re
n = int(input())
for i in range(n):
    s = raw_input().split('=')
    print(s)
    print(eval(s[0]))

Python: from inspect import currentframe
from sys import exit, stderr

tokens = []
cur = 0
def debug(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???') + str(id(arg)) +' = '+repr(arg) for arg in args), file=stderr)
def parse_expr():
    global cur
    if tokens[cur] == "=":
        return
    lhs = parse_mul()
    while(tokens[cur] == "+" or tokens[cur] == "-"):
        if tokens[cur] == "+":
            cur += 1
            lhs += parse_mul()
        elif tokens[cur] == "-":
            cur += 1
            lhs -= parse_mul()
        # debug(lhs, cur)
    return lhs

def parse_mul():
    global cur
    lhs = parse_term()
    while(tokens[cur] == "*" or tokens[cur] == "/"):
        if tokens[cur] == "*":
            cur += 1
            lhs *= parse_term()
        elif tokens[cur] == "/":
            cur += 1
            divisor = parse_term()
            if lhs < 0 and lhs % divisor != 0:
                lhs //= divisor
                lhs += 1
            else:
                lhs //= divisor
    return lhs

def parse_term():
    global cur
    if tokens[cur].isdigit():
        lhs = int(tokens[cur])
        cur += 1
        while(tokens[cur].isdigit()):
            lhs *= 10
            lhs += int(tokens[cur])
            cur += 1
    elif tokens[cur] == "(":
        cur += 1
        lhs = parse_expr()
        if tokens[cur] != ")":
            raise Exception("not closed")
        cur += 1
    return lhs

N = int(input())
for _ in range(N):
    src = list(str(input()))
    tokens = [tok for tok in src if tok != " "]
    cur = 0

    print(parse_expr())

Python: def digit():
    global S
    global cur
    if S[cur].isdigit():
        n = int(S[cur])
        cur += 1
        return n
def number():
    global S
    L = len(S)
    global cur
    n = digit()
    while (cur < L and S[cur].isdigit()):
        n = n*10 + digit()
    return n
def expression():
    global S
    global cur
    L = len(S)
    a = term()
    while (cur < L and (S[cur] == '+' or S[cur] == '-')):
        op = S[cur]
        cur += 1
        b = term()
        if op == '+':
            a += b
        else:
            a -= b
    return a
import math
def term():
    global S
    global cur
    L = len(S)
    a = factor()
    while (cur < L and (S[cur] == '*' or S[cur] == '/')):
        op = S[cur]
        cur += 1
        b = factor()
        if op == '*':
            a *= b
        else:
            a = math.trunc(a/b)
    return a
def factor():
    global S
    global cur
    if (S[cur] != '('):
        return number()
    else:
        cur += 1
        n = expression()
        if S[cur] == ')':
            cur += 1
            return n

N = int(input().strip())
for _ in range(N):
    S = str(input().strip())
    S = S[:-1]
    cur = 0
    ans = expression()
    print(ans)

Python: from collections import deque

def eva(l, r, op):
    if op == "+":
        return l + r
    elif op == "-":
        return l - r
    elif op == "*":
        return l * r
    elif op == "/":
        return l // r


def calc(exp,brac=None):
    i = 0 # ループカウンタ?
    num = deque() # 数字をためておく
    ops = deque() # +-をためておく
    ope = "" # */を保存
    
    if not brac:
        # 対応する括弧の位置を記録しておいて計算量を削減
        brac = [-1 for j in range(len(exp))]
        tmpbrac = []
        for j in range(len(exp) - 1, 0, -1):
            if exp[j] == ')':
                tmpbrac.append(j)
            elif exp[j] == '(':
                brac[j] = tmpbrac.pop()

    # かっこの中身と乗除算
    while i < len(exp):
        # かっこの中身は再帰的に計算
        if exp[i] == '(':
            num.append(calc(exp[i + 1:brac[i]],brac))
            i = brac[i]
            if ope:
                r = num.pop()
                l = num.pop()
                num.append(eva(l, r, ope))
                ope = ""
        elif exp[i] in ["*", "/"]:
            ope = exp[i]
        elif exp[i] in ["+", "-"]:
            ops.append(exp[i])
        elif exp[i] == "=":
            pass
        else:
            temp = "" # 数値 2桁以上にも対応させる
            while i < len(exp) and exp[i].isnumeric():
                temp += exp[i]
                i += 1
            i -= 1 # 最後の数字に戻る(最後にi+=1しているのでこれでいい)
            num.append(int(temp))
            if ope:
                r = num.pop()
                l = num.pop()
                num.append(eva(l, r, ope))
                ope = ""
        i += 1
    while len(ops) != 0:
        num.appendleft(eva(num.popleft(),num.popleft(),ops.popleft()))

    return num[0]


n = int(input())
for i in range(n):
    exp = input()
    print(calc(exp))

Python: for _ in[0]*int(input()):
 L=[];t=''
 for e in input()[:-1]:
  if e.isdigit():t+=e
  else:
   if t:L+=[t];t=''
   L+=e
 if t:L+=t
 P,S=[],[]
 table={"*":2,"/":2,"+":1,"-":1,"(":0,")":0}
 for i in L:
  if i in'*/+-':
   while S and table[S[-1]]>=table[i]:P+=S.pop()
   S+=i
  elif"("==i:S+=i
  elif")"==i:
   while"("!=S[-1]:P+=S.pop()
   S.pop()
  else:P+=[i]
 while S:P+=S.pop()
 for x in P:
  if x in'+-*/':t=S.pop();S+=[str(int(eval(S.pop()+x+t)))]
  else:S+=[x]
 print(*S)