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: def f1(line):
    p = None
    q = None
    for i, s in enumerate(line):
        if s == '(':
            p = i
        elif s == ')':
            q = i
        if q:
            break
    else:
        return f2(line)
    before = line[:p]
    after = line[q + 1:]
    x = f2(line[p + 1:q])
    return f1(before + str(x) + after)


def f2(f_line):
    foo = []
    digit = ''
    for x in f_line:
        if x.isdigit():
            digit += x
        else:
            foo.append(int(digit))
            foo.append(x)
            digit = ''
    foo.append(int(digit))
    return f3(foo, 'first')


def f3(foo, flg):
    if len(foo) == 1:
        return foo[0]
    target = None
    for i, fo in enumerate(foo):
        if flg == 'first':
            target = f4(foo, fo, i)
        elif flg == 'second':
            target = f5(foo, fo, i)
        if target:
            break
    else:
        flg = 'second'
        return f3(foo, flg)
    foo = foo[:i-1] + [target] + foo[i+2:]
    return f3(foo, flg)


def f4(foo, fo, i):
    target = None
    if fo == '*':
        target = foo[i-1] * foo[i+1]
    elif fo == '/':
        target = int(foo[i-1] / foo[i+1])
    return target


def f5(foo, fo, i):
    target = None
    if fo == '+':
        target = foo[i-1] + foo[i+1]
    elif fo == '-':
        target = foo[i-1] - foo[i+1]
    return target


for _ in range(int(input())):
    ans = f1(input()[:-1])
    print(ans)

Python: from collections import deque
from sys import stderr

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):
    i = 0
    num = deque()
    ops = deque()
    ope = ""
    while i < len(exp):
        try:
            if exp[i] == '(':
                end = 1
                s = 1
                while True:
                    if exp[i+end] == "(":
                        s += 1
                    elif exp[i+end] == ")":
                        s -= 1
                    if s == 0:
                        break
                    end += 1
                num.append(calc(exp[i+1:i+end]))
                i += end
                if ope:
                    l = num.pop()
                    r = num.pop()
                    num.append(eva(l, r, ope))
                    ope = ""
            if exp[i] in ["*", "/"]:
                ope = exp[i]
            elif exp[i] in ["+", "-"]:
                ops.append(exp[i])
            elif exp[i] == "=":
                pass
            else:
                temp = ""
                j = 0
                while i + j < len(exp) and exp[i+j].isnumeric():
                    temp += exp[i+j]
                    j += 1
                num.append(int(temp))
                i += j - 1
                if ope:
                    num.append(eva(num.pop(), num.pop(), ope))
                    ope = ""
            i += 1
        except:
            stderr.write(exp)
    while len(ops) != 0:
        l = num.popleft()
        r = num.popleft()
        num.appendleft(eva(l,r,ops.popleft()))
    
    return num[0]


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

# N = int(input())
# for i in range(N):
#     print(int(eval(input().replace("/", "//").strip("="))))

Python: n=int(input())
for T in range(n):
    s=input()[0:-1]
    s=s.replace('/','//')
    print(eval(s))

Python: R={"*":2,"/":2,"+":1,"-":1,"(":0,")":0}
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=[],[]
 for i in L:
  if"("==i:S+=i
  elif")"==i:
   while"("!=S[-1]:P+=S.pop()
   S.pop()
  elif i in R:
   while S and R[S[-1]]>=R[i]:P+=S.pop()
   S+=i
  else:P+=[i]
 while S:P+=S.pop()
 for x in P:S+=[str(int(eval(S.pop(-2)+x+S.pop())))if x in"+-*/"else x]
 print(*S)

Python: # Edit: 2014/09/26
# Lang: Python3
# Time: 0.xxs
#

if __name__ == "__main__":
    n = int(input())
    for i in range(n):
        print(eval(input().strip("=").replace("/","//")))

Python: import sys

input()
for i in sys.stdin.readlines():
        print(int(eval(i[:-2].replace('/', '//'))))

Python: def calc(eqt):
  l = eqt.split("+",maxsplit=1)
  if len(l) == 2:
    return (calc(l[0])+calc(l[1]))
  l = eqt.split("-",maxsplit=1)
  if len(l) == 2:
    return (calc(l[0])-calc(l[1]))
  l = eqt.split("*",maxsplit=1)
  if len(l) == 2:
    return (calc(l[0])*calc(l[1]))
  l = eqt.split("/",maxsplit=1)
  if len(l) == 2:
    return (calc(l[0])/calc(l[1]))
  return (int(eqt))

def unfold_brackets(eqt):
  l = eqt.split(')',maxsplit=1)
  if len(l) == 1:
    return calc(eqt)
  else:
    ll = l[0].rsplit('(',maxsplit=1)
    ll.append(l[1])
    ll[1] = str(calc(ll[1]))
    l="".join(ll)
    return unfold_brackets(l)

n=int(input())
datasets=[input() for i in range(n)]
for line in datasets:
  l = line.split("=",maxsplit=1)[0]
  print(unfold_brackets(l))

Python: R={"*":2,"/":2,"+":1,"-":1,"(":0,")":0}
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=[],[]
 for i in L:
  if"("==i:S+=i
  elif")"==i:
   while"("!=S[-1]:P+=S.pop()
   S.pop()
  elif i in R:
   while S and R[S[-1]]>=R[i]:P+=S.pop()
   S+=i
  else:P+=[i]
 while S:P+=S.pop()
 for x in P:
  S+=[str(eval(S.pop(-2)+x+S.pop()))if x in"+-*/"else x]
 print(*S)

Python: n=int(input())
s=""
for i in range(n):
    s=raw_input()
    print(eval(s[0:-1]))

Python: def calc(eqt):
  l = eqt.split("+",maxsplit=1)
  if len(l) == 2:
    return (calc(l[0])+calc(l[1]))
  l = eqt.split("-",maxsplit=1)
  if len(l) == 2:
    return (calc(l[0])-calc(l[1]))
  l = eqt.split("*",maxsplit=1)
  if len(l) == 2:
    return (calc(l[0])*calc(l[1]))
  l = eqt.split("/",maxsplit=1)
  if len(l) == 2:
    return (calc(l[0])//calc(l[1]))
  return (int(eqt))

def unfold_brackets(eqt):
  l = eqt.split(')',maxsplit=1)
  if len(l) == 1:
    return calc(eqt)
  else:
    ll = l[0].rsplit('(',maxsplit=1)
    ll.append(l[1])
    ll[1] = str(calc(ll[1]))
    l="".join(ll)
    return unfold_brackets(l)

n=int(input())
datasets=[None]*n
for i in range(0,n):
  datasets[i] = input()
for line in datasets:
  l = line.split("=",maxsplit=1)[0]
  print(unfold_brackets(l))