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:
				if (d2 > 0 and d1 < 0) or (d2 < 0 and d1 > 0):
					d2 //= -d1
					d2 = -d2
				else: d2 //= d1
			S[top] = d2
		else: S[top] = k
		top += 1
	print(S[top-1])

Python: # -*- coding: utf-8 -*-
# 写経した
import re
class Num:
    def __str__(self):
        return str(self.x)
    def __init__(self, value):
        self.x = value
    def __add__(self, value):
        return Num(self.x + value.x)
    def __sub__(self, value):
        return Num(self.x - value.x)
    def __mul__(self, value):
        return Num(self.x * value.x)
    def __truediv__(self, value):
        return Num(int(self.x / value.x))
      
N = int(input())
for i in range(N):
    s = input()[:-1]
    s = re.sub(r'(\d+)',r'Num(\1)',s)
    print(eval(s))

Python: import sys
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    for _ in range(int(sys.stdin.readline())):
        print(eval(sys.stdin.readline()[:-2]))
 
solve()

Python: # -*- coding: utf-8 -*-

import sys
import os

n = int(input())

for i in range(n):
    command = input().strip()
    command = command.replace('=', '')
    print(eval(command))

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:
  if x in'+-*/':t=S.pop();S+=[str(int(eval(S.pop()+x+t)))]
  else:S+=[x]
 print(*S)

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)

print(unfold_brackets("(((3+2)*(5+4))+2)"))

Python: def ReversePolishNotation(string):

    priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2}

    stack = []
    signStack = ["Sentinel"]
    isContinue = False

    for item in string[:-1]:

        if str.isnumeric(item):
            if not isContinue:
                stack.append(item)
                isContinue = True
            else:
                stack[-1] += item
            continue
        elif item == "(":
            signStack.append(item)
        elif item == ")":
            while signStack[-1] != "(":
                stack.append(signStack.pop())
            signStack.pop()
        else:
            while priority[item] <= priority[signStack[-1]] and signStack[-1] != "(" and signStack[-1] != "Sentinel":
                stack.append(signStack.pop())

            signStack.append(item)

        isContinue = False

    while signStack[-1] != "Sentinel":
        stack.append(signStack.pop())

    return stack


def Calculate(formulaList):

    signs = ["+", "-", "*", "/"]

    stack = []

    for item in formulaList:

        if item not in signs:
            stack.append(item)
        else:
            num1 = int(stack.pop())
            num2 = int(stack.pop())

            result = 0

            if item == "+":
                result = num2 + num1
            elif item == "-":
                result = num2 - num1
            elif item == "*":
                result = num2 * num1
            else:
                result = num2 / num1 // 1

            stack.append(result)

    return int(stack[0])


inputCount = int(input())

for lp in range(inputCount):
    formula = input()

    rpn = ReversePolishNotation(formula)
    answer = Calculate(rpn)

    print(answer)

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: N = int(input())
for i in range(N):
    print(int(eval(input().strip("="))))

Python: # -*- coding: utf-8 -*-

import sys
import os

n = int(input())

for i in range(n):
    command = input().strip()
    command = command.replace('=', '')
    command = command.replace('/', '//')
    print(command)
    print(int(eval(command)))