Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
r = int(input())

men = (r**2) / 3.141592
sen = (r * 2) / 3.141592
print('%.6f %.6f' % (men,sen))

Fixed submission:
import math
PI = math.pi

r = input()
men = r*r * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))

Buggy python submission (verdict: Runtime Error):
import math
r = int(input())
PI = math.pi
men = (r**2) * PI
sen = (r * 2) * PI
print('%.6f %.6f' % (men,sen))

Fixed submission:
import math
PI = math.pi

r = input()
men = r*r * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))

Buggy python submission (verdict: Runtime Error):
import math
r = int(input())
PI = math.pi
men = (r**2) * PI
sen = (r * 2) * PI
print('%.6f %.6f' % (men,sen))

Fixed submission:
import math
PI = math.pi

r = input()
men = r*r * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))

Buggy python submission (verdict: Runtime Error):
import math
r = int(input())
PI = math.pi
men = (r**2) * PI
sen = (r + r) * PI
print('%.6f %.6f' % (men,sen))

Fixed submission:
import math
PI = math.pi

r = input()
men = r*r * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))

Buggy python submission (verdict: Runtime Error):
import math
PI = math.pi

r = int(input())
men = r**2 * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))

Fixed submission:
import math
PI = math.pi

r = input()
men = r*r * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))

Buggy python submission (verdict: Runtime Error):
import math
PI = math.pi

r = int(row_input())
men = r**2 * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))

Fixed submission:
import math
PI = math.pi

r = input()
men = r*r * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))

Buggy python submission (verdict: Runtime Error):
import math
PI = math.pi

r = int(input())
men = r*r * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))

Fixed submission:
import math
PI = math.pi

r = input()
men = r*r * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))
Buggy python submission (verdict: Runtime Error):
def dfs(n):
    global t
    S[n] = t
    DP[n]=1
    for i in A[n][2:]:
        if not DP[i]:
            t += 1
            dfs(i)
    t += 1
    F[n] = t
n = int(input())
d = deque()
A = [0]*(n+1)
S = [0]*(n+1)
F = [0]*(n+1)
DP = [0]*(n+1)
for i in range(n):
    A[i+1] = [int(i) for i in input().split()]
t = 1
dfs(1)
for i in range(1,n+1):
    tmp = "{} {} {}".format(i,S[i],F[i])
    print(tmp)


Fixed submission:
def dfs(n):
    global t
    S[n] = t
    DP[n]=1
    for i in A[n][2:]:
        if not DP[i]:
            t += 1
            dfs(i)
    t += 1
    F[n] = t
n = int(input())
A = [0]*(n+1)
S = [0]*(n+1)
F = [0]*(n+1)
DP = [0]*(n+1)
for i in range(n):
    A[i+1] = [int(i) for i in input().split()]
t = 0
for i in range(1,n+1):
    if not DP[i]:
        t+=1
        dfs(i)
for i in range(1,n+1):
    tmp = "{} {} {}".format(i,S[i],F[i])
    print(tmp)
Buggy python submission (verdict: Runtime Error):
import heapq

n = int(input())
#A = [[int(i) for i in input().split()] for i in range(n)]
h = []
DP = {}
heapq.heappush(h,(0,0))
c = 0
while(len(DP)<n):
    tmp = heapq.heappop(h)
    if tmp[1] in DP:
        continue
    c += tmp[0]
    DP[tmp[1]] = 1
    for i,j in enumerate(A[tmp[1]]):
        if j > 0 and not i in DP:
            heapq.heappush(h,(j,i))
print(c)


Fixed submission:
import heapq

n = int(input())
A = [[int(i) for i in input().split()] for i in range(n)]
h = []
DP = {}
heapq.heappush(h,(0,0))
c = 0
while(len(DP)<n):
    tmp = heapq.heappop(h)
    if tmp[1] in DP:
        continue
    c += tmp[0]
    DP[tmp[1]] = 1
    for i,j in enumerate(A[tmp[1]]):
        if j > -1 and not i in DP:
            heapq.heappush(h,(j,i))
print(c)
Buggy python submission (verdict: Runtime Error):
#ALDS1_3-A Elementary data structures - Stack
A=input().split()
while(len(A)>1):
    for i in range(len(A)):
        if(A[i]=="+"):
            A[i]=int(A[i-2])+int(A[i-1])
            A=A[i:]
            break
        elif(A[i]=="-"):
            A[i]=int(A[i-2])-int(A[i-1])
            A=A[i:]
            break
        elif(A[i]=="*"):
            A[i]=int(A[i-2])*int(A[i-1])
            A=A[i:]
            break
print(A[0])

Fixed submission:
A=input().split()
B=[]
for i in A:
 if i.isdigit():
  B.append(int(i))
 else:
  if i=="+":
   B[-1]=B[-2]+B[-1]
   del B[-2]
  elif i=="-":
   B[-1]=B[-2]-B[-1]
   del B[-2]
  elif i=="*":
   B[-1]=B[-2]*B[-1]
   del B[-2]
print(B[0])

Buggy python submission (verdict: Runtime Error):
#ALDS1_3-A Elementary data structures - Stack
A=input().split()
while(len(A)>1):
    for i in range(len(A)):
        if(A[i]=="+"):
            A[i]=int(A[i-2])+int(A[i-1])
            A=A[i:]
            break
        elif(A[i]=="-"):
            A[i]=int(A[i-2])-int(A[i-1])
            A=A[i:]
            break
        elif(A[i]=="*"):
            print(A)
            A[i]=int(A[i-2])*int(A[i-1])
            A=A[i:]
            break
print(A[0])

Fixed submission:
A=input().split()
B=[]
for i in A:
 if i.isdigit():
  B.append(int(i))
 else:
  if i=="+":
   B[-1]=B[-2]+B[-1]
   del B[-2]
  elif i=="-":
   B[-1]=B[-2]-B[-1]
   del B[-2]
  elif i=="*":
   B[-1]=B[-2]*B[-1]
   del B[-2]
print(B[0])
Buggy python submission (verdict: Runtime Error):
n=input()
S=input().split()
q=input()
T=input().split()
c=0
for(t in T):
    if(t in S):c+=1
print(c)

Fixed submission:
n=input()
S=input().split()
q=input()
T=input().split()
c=0
for t in T:
    if(t in S):c+=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
#ALDS1_4-B BinarySearch
n=input()
S=input().split()
q=input()
T=input().split()
c=0
for t in T:
    if(t in S):c+=1
print(c)

Fixed submission:
#ALDS1_4-B BinarySearch
input()
S=input().split()
input()
T=input().split()
print(len(set(S)&set(T)))

Buggy python submission (verdict: Time Limit Exceeded):
#ALDS1_4-B BinarySearch
import heapq

S = []
T = []
n=input()
S = input().split()
q=input()
T = input().split()
c=0
heapq.heapify(S)
for t in T:
    if(t in S):c+=1
        
print(c)

Fixed submission:
#ALDS1_4-B BinarySearch
input()
S=input().split()
input()
T=input().split()
print(len(set(S)&set(T)))

Buggy python submission (verdict: Time Limit Exceeded):
#ALDS1_4-B BinarySearch
import heapq

S = []
T = []
n=input()
S = input().split()
q=input()
T = input().split()
c=0
heapq.heapify(S)
heapq.heapify(T)
for t in T:
    if(t in S):c+=1
        
print(c)

Fixed submission:
#ALDS1_4-B BinarySearch
input()
S=input().split()
input()
T=input().split()
print(len(set(S)&set(T)))

Buggy python submission (verdict: Time Limit Exceeded):
#ALDS1_4-B BinarySearch
c=0
n=input()
S = input().split()
q=input()
T = input().split()
for t in T:
    if( t in set(S)):c+=1
print(c)

Fixed submission:
#ALDS1_4-B BinarySearch
input()
S=input().split()
input()
T=input().split()
print(len(set(S)&set(T)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [(i,int(j)) for i,j in enumerate(input().split())]
A = sorted(A, key=lambda x: x[1])
B = [1]*n
ans=0
for i,j in A:
    ans+=sum(B[:i])
    B[i]=0
print(ans)


Fixed submission:
class BIT:
    def __init__(self, n):
        self.bit = [0]*(n+1)
    
    def sumB(self, i):
        s = 0
        while(i>0):
            s+=self.bit[i]
            i -= i & -i
        return s
    
    def addB(self, i, x):
        while(i < len(self.bit)):
            self.bit[i] += x
            i += i & -i
            
n = int(input())
A = [(i+1,int(j)) for i,j in enumerate(input().split())]
A = sorted(A, key=lambda x: x[1])
b = BIT(n)
for i in range(n):b.addB(i+1,1)
ans=0
for i,j in A:
    ans+=b.sumB(i-1)
    b.addB(i,-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [(i,int(j)) for i,j in enumerate(input().split())]
A = sorted(A, key=lambda x: x[1])
B = [1]*n
ans=0
for i,j in A:
    ans+=sum(B[:i])
    B[i]=0
print(ans)


Fixed submission:
class BIT:
    def __init__(self, n):
        self.bit = [0]*(n+1)
    
    def sumB(self, i):
        s = 0
        while(i>0):
            s+=self.bit[i]
            i -= i & -i
        return s
    
    def addB(self, i, x):
        while(i < len(self.bit)):
            self.bit[i] += x
            i += i & -i
            
n = int(input())
A = [(i+1,int(j)) for i,j in enumerate(input().split())]
A = sorted(A, key=lambda x: x[1])
b = BIT(n)
for i in range(n):b.addB(i+1,1)
ans=0
for i,j in A:
    ans+=b.sumB(i-1)
    b.addB(i,-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [(i,int(j)) for i,j in enumerate(input().split())]
A = sorted(A, key=lambda x: x[1])
B = [1]*n
ans=0
for i,j in A:
    ans+=sum(B[:i])
    B[i]=0
print(ans)


Fixed submission:
class BIT:
    def __init__(self, n):
        self.bit = [0]*(n+1)
    
    def sumB(self, i):
        s = 0
        while(i>0):
            s+=self.bit[i]
            i -= i & -i
        return s
    
    def addB(self, i, x):
        while(i < len(self.bit)):
            self.bit[i] += x
            i += i & -i
            
n = int(input())
A = [(i+1,int(j)) for i,j in enumerate(input().split())]
A = sorted(A, key=lambda x: x[1])
b = BIT(n)
for i in range(n):b.addB(i+1,1)
ans=0
for i,j in A:
    ans+=b.sumB(i-1)
    b.addB(i,-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
class Line:
    def __init__(self,p1,p2):
        if p1[1] < p2[1]:self.s=p2;self.e=p1
        elif p1[1] > p2[1]:self.s=p1;self.e=p2
        else:
            if p1[0] < p2[0]:self.s=p1;self.e=p2
            else:self.s=p2;self.e=p1
def dot(a,b):return a[0]*b[0] + a[1]*b[1]
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
def dif(a,b):return [x-y for x,y in zip(a,b)]
def InterSection(l,m):
    a = dif(l.e,l.s);b = dif(m.e,l.s);c = dif(m.s,l.s)
    d = dif(m.e,m.s);e = dif(l.e,m.s);f = dif(l.s,m.s)
    g = lambda a, b : cross(a,b)==0 and dot(a,b)>0 and dot(b,b)<dot(a,a)
    if g(a,b) or g(a,c) or g(d,e) or g(d,f):return True
    elif l.s == m.e or l.s == m.s or l.e == m.e or l.e == m.s:return True
    elif cross(a,b) * cross(a,c) >= 0 or cross(d,e) * cross(d,f) >= 0:return False
    else:return True

q = int(input())
for i in range(q):
    x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()]
    a = [x0,y0] ; b = [x1,y1] ; c = [x2,y2] ; d = [x3,y3]
    l1 = Line(b,1) ; l2 = Line(b,1)
    if InterSection(l1,l2):print(1)
    else:print(0)

Fixed submission:
def cross(a,b):return a[0]*b[1] - a[1]*b[0]

q = range(int(input()))
for i in q:
    a,b,c,d,e,f,g,h = [int(x) for x in input().split()]
    A = [c-a,d-b]; B = [e-a,f-b]; C = [g-a,h-b];
    D = [g-e,h-f]; E = [a-e,b-f]; F = [c-e,d-f];
    if max(a,c) < min(e,g) or max(e,g) < min(a,c) or max(b,d) < min(f,h) or max(f,h) < min(b,d):
        print("0")
    elif cross(A,B) * cross(A,C) <= 0 and cross(D,E) * cross(D,F) <= 0:
        print("1")
    else:
        print("0")
Buggy python submission (verdict: Runtime Error):
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
def dif(a,b):return [x-y for x,y in zip(a,b)]

x = range(int(input()))
t = 1
P,Q = [],[]
for _ in x:P+=[[int(i) for i in input().split()]]
for i in x:Q+=[dif(P[i],P[i-1])]
for i in x:if cross(Q[i-1],Q[i]) < 0: t *= False
print(t)

Fixed submission:
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
def dif(a,b):return [x-y for x,y in zip(a,b)]

x = range(int(input()))
t = 1
P,Q = [],[]
for _ in x:P+=[[int(i) for i in input().split()]]
for i in x:Q+=[dif(P[i],P[i-1])]
for i in x:
    if cross(Q[i-1],Q[i]) < 0: t *= False
print(t)
Buggy python submission (verdict: Runtime Error):
#ITP1_10-D Distance2
n = int(input())
x = float().split(" ")
y = float().split(" ")

d1=0.0
for i in range(n):
    d1 += abs(x[i]-y[i])
print(d1)

d2=0.0
for i in range(n):
    d2 += (x[i]-y[i])**2
print(d2**0.5)

d3=0.0
for i in range(n):
    d3 += (x[i]-y[i])**3
print(d3**(1.0/3.0))

d_inf=0.0
for i in range(n):
    if abs(x[i]-y[i])>d_inf:
        d_inf = x[i]-y[i]
print(d_inf)

Fixed submission:
#ITP1_10-D Distance2
n = int(input())
x = [float(x) for x in input().split(" ")]
y = [float(x) for x in input().split(" ")]

d1=0.0
for i in range(n):
    d1 += abs(x[i]-y[i])
print(d1)

d2=0.0
for i in range(n):
    d2 += (x[i]-y[i])**2
print(d2**(1/2))

d3=0.0
for i in range(n):
    d3 += abs((x[i]-y[i])**3)
print(d3**(1/3))

d_inf=0.0
for i in range(n):
    if abs(x[i]-y[i])>d_inf:
        d_inf = abs(x[i]-y[i])
print(d_inf)
Buggy python submission (verdict: Runtime Error):
#ITP1_11-B Dice 2
rep=[
    [0,0,0,0,0],
    [2,3,5,4,2],
    [3,1,4,6,3],
    [1,2,6,5,1],
    [1,5,6,2,1],
    [1,3,6,4,1],
    [2,4,5,3,2]
]
d = input().split(" ")
q = int(input())

for i in range(q):
    a,b = [int(x) for x in input().split(" ")]
    for j in range(4):
        if(rep[a][j]==b):
            print(rep[a][j+1])

Fixed submission:
#ITP1_11-B Dice 2
rep=[
    [1,2,4,3,1],
    [2,0,3,5,2],
    [0,1,5,4,0],
    [0,4,5,1,0],
    [0,2,5,3,0],
    [1,3,4,2,1]
]
d = input().split(" ")
q = int(input())
dic={}
for i in range(6):
    dic.update({d[i]:i})
for i in range(q):
    a,b = input().split(" ")
    for j in range(4):
        top=dic[a]
        front = dic[b]
        if(d[rep[top][j]]==d[front]):
            print(d[rep[top][j+1]])

Buggy python submission (verdict: Runtime Error):
#ITP1_11-B Dice 2
rep=[
    [0,0,0,0,0],
    [2,3,5,4,2],
    [3,1,4,6,3],
    [1,2,6,5,1],
    [1,5,6,2,1],
    [1,3,6,4,1],
    [2,4,5,3,2]
]
d = input().split(" ")
q = int(input())

for i in range(q):
    a,b = [int(x) for x in input().split(" ")]
    for j in range(4):
        if(rep[a][j]==b):
            print(rep[a][j+1])

Fixed submission:
#ITP1_11-B Dice 2
rep=[
    [1,2,4,3,1],
    [2,0,3,5,2],
    [0,1,5,4,0],
    [0,4,5,1,0],
    [0,2,5,3,0],
    [1,3,4,2,1]
]
d = input().split(" ")
q = int(input())
dic={}
for i in range(6):
    dic.update({d[i]:i})
for i in range(q):
    a,b = input().split(" ")
    for j in range(4):
        top=dic[a]
        front = dic[b]
        if(d[rep[top][j]]==d[front]):
            print(d[rep[top][j+1]])
Buggy python submission (verdict: Time Limit Exceeded):
def isPrime(num):
    if num == 1:
        return False
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False
    else:
        for i in range(3, int(num ** 0.5) + 1, 2):
            if num % i == 0:
                return False

        return True


while True:
    try:
        n = int(input())
    except EOFError:
        break

    count = 0
    for i in range(1, n + 1):
        count += 1 if isPrime(i) else 0

    print(count)



Fixed submission:
# coding: utf-8

LIMIT = 999999

prime = [0, 1] + [0 if i % 2 == 0 else 1 for i in range(3, LIMIT + 1)]

for i in range(3, int(LIMIT ** 0.5) + 1):
    if prime[i - 1]:
        for j in range(i ** 2, LIMIT + 1, i):
            prime[j - 1] = 0

while True:
    try:
        n = int(input())
    except EOFError:
        break

    print(sum(prime[:n]))
Buggy python submission (verdict: Time Limit Exceeded):
def primes(n):
    primes = [2]
    if n < 2:
        return []
    
    for i in range(3, n + 1, 2):
        isPrime = True
        for prime in primes:
            if i % prime == 0:
                isPrime = False
                break
        if isPrime:
            primes.append(i)
    
    return primes

n = int(input())
l = [int(input()) for _ in range(n)]

print(len([x for x in l if x in primes(max(l))]))


Fixed submission:
def isPrime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False

    for i in range(3, int(x ** 0.5) + 1, 2):
        if x % i == 0:
            return False

    return True

n = int(input())
cnt = 0
for _ in range(n):
    i = int(input())
    cnt += isPrime(i)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
def primesUpTo(n):
    primes = [2]
    if n < 2:
        return []

    for i in range(3, n + 1, 2):
        isPrime = True
        for prime in primes:
            if prime ** 2 > n:
                break
            if i % prime == 0:
                isPrime = False
                break
        if isPrime:
            primes.append(i)

    return primes

n = int(input())
l = [int(input()) for _ in range(n)]
primes = primesUpTo(max(l))

print(len([x for x in l if x in primes]))


Fixed submission:
def isPrime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False

    for i in range(3, int(x ** 0.5) + 1, 2):
        if x % i == 0:
            return False

    return True

n = int(input())
cnt = 0
for _ in range(n):
    i = int(input())
    cnt += isPrime(i)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
def primesUpTo(n):
    primes = [2]
    if n < 2:
        return []

    for i in range(3, n + 1, 2):
        isPrime = True
        for prime in primes[1:]:
            if prime > n ** (1 / 2):
                break
            if i % prime == 0:
                isPrime = False
                break
        if isPrime:
            primes.append(i)

    return primes

n = int(input())
l = [int(input()) for _ in range(n)]
primes = primesUpTo(max(l))

print(len([x for x in l if x in primes]))


Fixed submission:
def isPrime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False

    for i in range(3, int(x ** 0.5) + 1, 2):
        if x % i == 0:
            return False

    return True

n = int(input())
cnt = 0
for _ in range(n):
    i = int(input())
    cnt += isPrime(i)

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = list(map(int, input().split()))

queue = [input().split() for y in range(n)]
time = 0;

while True:
    if int(queue[0][1]) <= q:
        time += int(queue[0][1])
        print(queue[0][0], time)
        if len(queue) == 1:
            break
        queue.pop(0)
    else:
        time += q
        queue[0][1] = str(int(queue[0][1]) - q)
        queue = queue[1:] + queue[:1]



Fixed submission:
n, quantum = list(map(int, input().split()))
queue = []
sumOfTime = 0

for _ in range(n):
    name, time = input().split()
    queue.append([name, int(time)])

while len(queue) > 0:
    name, time = queue.pop(0)
    if time > quantum:
        sumOfTime += quantum
        queue.append([name, time - quantum])
    else:
        sumOfTime += time
        print(name, sumOfTime)
Buggy python submission (verdict: Runtime Error):
input()
line = reverse(input().split())
print(' '.join(line))

Fixed submission:
input()
print(" ".join(input().split()[::-1]))
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m = map(int, input().split())

A = np.empty((0, m), int)
b = np.empty((0, 1), int)

for i in range(n):
    A = np.append(A, np.array([list(map(int, input().split()))]), axis=0)

for i in range(m):
    b = np.append(b, np.array([list(map(int, input().split()))]), axis=0)

c = np.dot(A, b)

for i in range(n):
    print(int(c[i]))

Fixed submission:
n, m = list(map(int, input().split()))

A = [list(map(int, input().split())) for i in range(n)]
bt = [int(input()) for i in range(m)]

for i in range(n):
    print(sum([x * y for (x, y) in zip(A[i], bt)]))
Buggy python submission (verdict: Runtime Error):
while 1:
    d, w, h = map(int, raw_input().split())
    dmin = min(d**2 + w**2, w**2+h**2, h**2+d**2)
    if dmin == 0:
        break
    n = input()
    for i in range(n):
        r = input()
        if dmin < 2*r**2:
            print 'OK'
        else:
            print 'NA'

Fixed submission:
while True:
    d, w, h = [int(x) for x in input().split()]
    minrad = min(d*d+w*w,w*w+h*h,h*h+d*d)
    if minrad == 0:
        break
    n = int(input())
    for i in range(n):
        r = int(input())
        if 4*r*r > minrad:
            print('OK')
        else:
            print('NA')
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
    eq = input().replace("=","")
    print(eval(eq))

Fixed submission:
import re

class Num:
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return str(self.x)

    def __add__(self, other):
        return Num(self.x + other.x)

    def __sub__(self, other):
        return Num(self.x - other.x)

    def __truediv__(self, other):
        return Num(int(self.x / other.x))

    def __mul__(self, other):
        return Num(self.x * other.x)

    def __neg__(self):
        return Num(-self.x)

n = int(input())
for _ in range(n):
    expr = input()[0:-1]
    expr = re.sub(r'(\d+)', r'Num(\1)', expr)
    print(eval(expr))

Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
    eq = input().replace("/","//")
    print(eval(eq))

Fixed submission:
import re

class Num:
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return str(self.x)

    def __add__(self, other):
        return Num(self.x + other.x)

    def __sub__(self, other):
        return Num(self.x - other.x)

    def __truediv__(self, other):
        return Num(int(self.x / other.x))

    def __mul__(self, other):
        return Num(self.x * other.x)

    def __neg__(self):
        return Num(-self.x)

n = int(input())
for _ in range(n):
    expr = input()[0:-1]
    expr = re.sub(r'(\d+)', r'Num(\1)', expr)
    print(eval(expr))

Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
    eq = input().replace("/","//").replace("=","")
    print(eval(eq))

Fixed submission:
import re

class Num:
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return str(self.x)

    def __add__(self, other):
        return Num(self.x + other.x)

    def __sub__(self, other):
        return Num(self.x - other.x)

    def __truediv__(self, other):
        return Num(int(self.x / other.x))

    def __mul__(self, other):
        return Num(self.x * other.x)

    def __neg__(self):
        return Num(-self.x)

n = int(input())
for _ in range(n):
    expr = input()[0:-1]
    expr = re.sub(r'(\d+)', r'Num(\1)', expr)
    print(eval(expr))
Buggy python submission (verdict: Runtime Error):
from math import gcd
while True:
    a = list(map(int, input().split()))
    if a.count(0) == 6:
        break
    x = a[0] % a[1]
    ix = 1
    while x != 1:
        x = a[0] * x % a[1]
        ix += 1
    y = a[2] % a[3]
    iy = 1
    while y != 1:
        y = a[2] * y % a[3]
        iy += 1
    z = a[4] % a[5]
    iz = 1
    while z != 1:
        z = a[4] * z % a[5]
        iz += 1
    ixy = ix * iy // gcd(ix, iy)
    print(ixy * iz // gcd(ixy, iz))

Fixed submission:
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

def rooptimes(ai, mi):
    x = ai % mi
    i = 1
    while x != 1:
        x = ai * x % mi
        i += 1
    return(i)

while True:
    a = list(map(int, input().split()))
    if a.count(0) == 6:
        break
    ix = rooptimes(a[0], a[1])
    iy = rooptimes(a[2], a[3])
    iz = rooptimes(a[4], a[5])

    ixy = ix * iy // gcd(ix, iy)
    print(ixy * iz // gcd(ixy, iz))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
snum = list(map(int, input().split()))
q = input()
qnum = list(map(int, input().split()))
c = 0
for i in qnum:
    if i in snum:
        c += 1

print(c)

Fixed submission:
s = input()
snum = set(map(int, input().split()))
q = input()
qnum = list(map(int, input().split()))
c = 0
for i in qnum:
    if i in snum:
        c += 1

print(c)
Buggy python submission (verdict: Time Limit Exceeded):
numbers = []
while True:
    n = int(input())
    if n == 0:
        break
    numbers.append(n)
leng = len(numbers) + 1
for i in range(1,leng):
    for n in numbers:
        print('Case ' + str(i) + ': ' + str(n))

Fixed submission:
num = []
while True:
    n = int(input())
    if n == 0:
        break
    else:
        num.append(n)


for i, n in enumerate(num):
    i = i+1
    print('Case '+ str(i) + ': ' + str(n))

Buggy python submission (verdict: Time Limit Exceeded):
numbers = []
while True:
    n = input()
    if n == '0':
        break
    numbers.append(n)
leng = len(numbers) + 1
for i in range(1,leng):
    for n in numbers:
        print('Case ' + str(i) + ': ' + n)

Fixed submission:
num = []
while True:
    n = int(input())
    if n == 0:
        break
    else:
        num.append(n)


for i, n in enumerate(num):
    i = i+1
    print('Case '+ str(i) + ': ' + str(n))