Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math

my_value = int(input())

print("{} {}".format(pow(my_value, 2) * math.pi, 2 * math.pi * my_value))
2

Fixed submission:
import math

my_value = float(input())

print("{} {}".format(pow(my_value, 2) * math.pi, 2 * math.pi * my_value))

Buggy python submission (verdict: Runtime Error):
import math

my_value = int(input())

print("{} {}".format(pow(my_value, 2) * math.pi, 2 * math.pi * my_value))

Fixed submission:
import math

my_value = float(input())

print("{} {}".format(pow(my_value, 2) * math.pi, 2 * math.pi * my_value))

Buggy python submission (verdict: Runtime Error):
import math

my_value = int(input())

print("{} {}".format(pow(my_value, 2) * math.pi, 2 * math.pi * my_value))

Fixed submission:
import math

my_value = float(input())

print("{} {}".format(pow(my_value, 2) * math.pi, 2 * math.pi * my_value))
Buggy python submission (verdict: Runtime Error):

my_value_list = []

while True:
    try:
        my_value_list.append(input().split())
    except EOFError:
        break

for i in my_value_list:
    if my_value_list[i][2] == "+":
        print(int(my_value_list[i][]) + int(my_value_list[i][2]))
    elif my_value_list[i][2] == "-":
        print(int(my_value_list[i][0]) - int(my_value_list[i][2]))
    elif my_value_list[i][2] == "/":
        print(int(my_value_list[i][0]) // int(my_value_list[i][2]))
    elif my_value_list[i][2] == "*":
        print(int(my_value_list[i][0]) * int(my_value_list[i][2]))
    else:
        break

Fixed submission:

my_value_list = []

while True:
    try:
        my_value_list.append(input().split())
    except EOFError:
        break

for i in range(0, len(my_value_list)):
    if my_value_list[i][1] == "+":
        print(int(my_value_list[i][0]) + int(my_value_list[i][2]))
    elif my_value_list[i][1] == "-":
        print(int(my_value_list[i][0]) - int(my_value_list[i][2]))
    elif my_value_list[i][1] == "/":
        print(int(my_value_list[i][0]) // int(my_value_list[i][2]))
    elif my_value_list[i][1] == "*":
        print(int(my_value_list[i][0]) * int(my_value_list[i][2]))
    else:
        break
Buggy python submission (verdict: Runtime Error):
#
# my_value_list = []
#
# while True:
#     try:
#         my_value_list.append(input().split())
#     except EOFError:
#         break
#
# for i in range(0, len(my_value_list)):
#     if my_value_list[i][1] == "+":
#         print(int(my_value_list[i][0]) + int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "-":
#         print(int(my_value_list[i][0]) - int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "/":
#         print(int(my_value_list[i][0]) // int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "*":
#         print(int(my_value_list[i][0]) * int(my_value_list[i][2]))
#     else:
#         break

my_value = int(input())
my_value_list_str = input().split()

my_value_list = [int(i) for i in my_value_list_str]
my_value_list.sort()

print("{} {} {}".format(my_value_list[my_value], my_value_list[0], sum(my_value_list)))

Fixed submission:
#
# my_value_list = []
#
# while True:
#     try:
#         my_value_list.append(input().split())
#     except EOFError:
#         break
#
# for i in range(0, len(my_value_list)):
#     if my_value_list[i][1] == "+":
#         print(int(my_value_list[i][0]) + int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "-":
#         print(int(my_value_list[i][0]) - int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "/":
#         print(int(my_value_list[i][0]) // int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "*":
#         print(int(my_value_list[i][0]) * int(my_value_list[i][2]))
#     else:
#         break

my_value = int(input())
my_value_list_str = input().split()

my_value_list = [int(i) for i in my_value_list_str]
my_value_list.sort()

print("{} {} {}".format(my_value_list[0], my_value_list[my_value-1], sum(my_value_list)))
Buggy python submission (verdict: Runtime Error):
#
# my_value_list = []
#
# while True:
#     try:
#         my_value_list.append(input().split())
#     except EOFError:
#         break
#
# for i in range(0, len(my_value_list)):
#     if my_value_list[i][1] == "+":
#         print(int(my_value_list[i][0]) + int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "-":
#         print(int(my_value_list[i][0]) - int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "/":
#         print(int(my_value_list[i][0]) // int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "*":
#         print(int(my_value_list[i][0]) * int(my_value_list[i][2]))
#     else:
#         break

# ITP1???4_D
# my_value = int(input())
# my_value_list_str = input().split()
#
# my_value_list = [int(i) for i in my_value_list_str]
# my_value_list.sort()
#
# print("{} {} {}".format(my_value_list[0], my_value_list[my_value-1], sum(my_value_list)))


my_value_list = []
while True:
    try:
        my_value = input().split()
        my_value = [int(x) for x in my_value]
        my_value_list.append(my_value)
    except EOFError:
        break

for i in range(0, len(my_value_list)):
    if my_value_list[i][0] == 0 and my_value_list[i][1] == 0:
        break
    else:
        for j in my_value_list[i][1]:
            for k in my_value_list[i][0]:
                print("*")

Fixed submission:

array = []
while True:
    value = input().split()
    value = [int(x) for x in value]
    if value[0] == 0 and value[1] == 0:
        break
    else:
        array.append(value)

for i in range(0, len(array)):
    for j in range(0, array[i][0]):
        for k in range(0, array[i][1]):
            print("#", end="")
        print("")
    print("")
Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv
a = int(args[1])
b = int(args[2])

print(a*b)
print(2*a+2*b)

Fixed submission:
t = input()
t = t.split()
a = int(t[0])
b = int(t[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv
a = int(args[1])
b = int(args[2])

def P(x,y):
 print(x*y)
 print(2*x+2*y)
 return 0

P(a,b)

Fixed submission:
t = input()
t = t.split()
a = int(t[0])
b = int(t[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv
a = int(args[1])
b = int(args[2])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Fixed submission:
t = input()
t = t.split()
a = int(t[0])
b = int(t[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv
a = int(args[0])
b = int(args[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Fixed submission:
t = input()
t = t.split()
a = int(t[0])
b = int(t[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv
a = int(args[0])
b = int(args[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Fixed submission:
t = input()
t = t.split()
a = int(t[0])
b = int(t[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv
a = int(args[0])
b = int(args[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Fixed submission:
t = input()
t = t.split()
a = int(t[0])
b = int(t[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
a = int(a)
b = int(b)

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

Fixed submission:
t = input()
t = t.split()
a = int(t[0])
b = int(t[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)
Buggy python submission (verdict: Runtime Error):
Answer = []
flg = 1

def Taxed(p,q):
    T = int(p*(1+q/100))
    return T

while flg > 0:
    inp = input().split()
    x = int(inp[0])
    y = int(inp[1])
    s = int(inp[2])

    flg = x**2+y**2+s**2
    if flg == 0:
        break

    M = 0
    for i in range(1,s-1):
        for j in range(1,s-1):
            a = Taxed(i,x)
            b = Taxed(j,x)
            if (a+b) == s:
                M_temp = Taxed(i,y) + Taxed(j,y) 
                M = max(M,M_temp)
    Answer.append(M)

for k in range(0,len(Answer)):
    print(Answer[k])

Fixed submission:
c = 1
Answer = []

while c > 0:
    inp = input().split()
    n = int(inp[0])
    x = int(inp[1])
    c = n**2+x**2
    if c == 0:
        break

    flg = 0
    for i in range(1,min(int(x/3),n-1)):
        for j in range(i+1,min(int(x/2),n)):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    flg += 1
    Answer.append(flg)

for l in range(0,len(Answer)):
    print(Answer[l])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-


def search(n, m, tile, N, M):
    for dy, dx in zip([-1, -1, -1, 0, 0, 1, 1, 1], [-1, 0, 1, -1, 1, -1, 0, 1]):
        if 0 <= dy + n < N and 0 <= dx + m < M:
            if tile[dy + n][dx + m] == '1':
                tile[dy + n][dx + m] = '2'
                search(dy + n, dx + m, tile, N, M)


while True:
    M, N = map(int, input().split())
    if M == 0 and N == 0:
        break
    tile = [input().split() for n in range(N)]
    ans = 0
    for n in range(N):
        for m in range(M):
            if tile[n][m] == '1':
                tile[n][m] = '2'
                search(n, m, tile, N, M)
                ans += 1
    print(ans)




Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)


def search(n, m, tile, N, M):
    for dy, dx in zip([-1, -1, -1, 0, 0, 1, 1, 1], [-1, 0, 1, -1, 1, -1, 0, 1]):
        if 0 <= dy + n < N and 0 <= dx + m < M:
            if tile[dy + n][dx + m] == '1':
                tile[dy + n][dx + m] = '2'
                search(dy + n, dx + m, tile, N, M)


while True:
    M, N = map(int, input().split())
    if M == 0 and N == 0:
        break
    tile = [input().split() for n in range(N)]
    ans = 0
    for n in range(N):
        for m in range(M):
            if tile[n][m] == '1':
                tile[n][m] = '2'
                search(n, m, tile, N, M)
                ans += 1
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-


def search(n, m, tile, N, M):
    for dy, dx in zip([-1, -1, -1, 0, 0, 1, 1, 1], [-1, 0, 1, -1, 1, -1, 0, 1]):
        if 0 <= dy + n < N and 0 <= dx + m < M:
            if tile[dy + n][dx + m] == '1':
                tile[dy + n][dx + m] = '2'
                search(dy + n, dx + m, tile, N, M)


while True:
    M, N = map(int, input().split())
    if M == 0 and N == 0:
        break
    tile = [input().split() for n in range(N)]
    ans = 0
    for n in range(N):
        for m in range(M):
            if tile[n][m] == '1':
                tile[n][m] = '2'
                search(n, m, tile, N, M)
                ans += 1
    print(ans)




Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)


def search(n, m, tile, N, M):
    for dy, dx in zip([-1, -1, -1, 0, 0, 1, 1, 1], [-1, 0, 1, -1, 1, -1, 0, 1]):
        if 0 <= dy + n < N and 0 <= dx + m < M:
            if tile[dy + n][dx + m] == '1':
                tile[dy + n][dx + m] = '2'
                search(dy + n, dx + m, tile, N, M)


while True:
    M, N = map(int, input().split())
    if M == 0 and N == 0:
        break
    tile = [input().split() for n in range(N)]
    ans = 0
    for n in range(N):
        for m in range(M):
            if tile[n][m] == '1':
                tile[n][m] = '2'
                search(n, m, tile, N, M)
                ans += 1
    print(ans)
Buggy python submission (verdict: Runtime Error):
V=int(input())
 
G=[[] for i in range(V)]
d=[1001001001 for i in range(V)]
used=[False for i in range(V)]
 
import heapq
 
def dijkstra(s):
    q=[]
    d[s]=0
    heapq.heappush(q,(0, s))
     
    while(len(q)):
         
        p=heapq.heappop(q)
        v=p[1]
        used[v]=true
        if d[v]<p[0]:
            continue
        for e in G[v]:
            if (not used[e[0]]) and d[e[0]]>d[v]+e[1]:
                d[e[0]]=d[v]+e[1]
                 
                heapq.heappush(q, (d[e[0]], e[0]))
 
import sys
for l in sys.stdin:
    l=list(map(int,l.split()))
    u=l[0]
    k=l[1]
    G[u]=zip(*[iter(l[2:])]*2)
     
dijkstra(0)
for i, c in enumerate(d):
    print(i, d[i])

Fixed submission:
V=int(input())
 
G=[[] for i in range(V)]
d=[1001001001 for i in range(V)]
used=[False for i in range(V)]
 
import heapq
 
def dijkstra(s):
    q=[]
    d[s]=0
    heapq.heappush(q,(0, s))
     
    while(len(q)):
         
        p=heapq.heappop(q)
        v=p[1]
        used[v]=True
        if d[v]<p[0]:
            continue
        for e in G[v]:
            if (not used[e[0]]) and d[e[0]]>d[v]+e[1]:
                d[e[0]]=d[v]+e[1]
                 
                heapq.heappush(q, (d[e[0]], e[0]))
 
import sys
for l in sys.stdin:
    l=list(map(int,l.split()))
    u=l[0]
    k=l[1]
    G[u]=zip(*[iter(l[2:])]*2)
     
dijkstra(0)
for i, c in enumerate(d):
    print(i, d[i])
Buggy python submission (verdict: Runtime Error):

import numpy as np

##素数判定を行う関数
def prime(p):
    if p==2 or p==3:
        return True
    else:
        i = int(np.sqrt(p))
        while i>=2:
            if p%i==0:
                return False
                break
            i-=1
        return True
                
            

N = int(input())
count = 0

for i in range(N):
    a = int(input())
    if prime(a)==True:
        count+=1
        
print(count)


Fixed submission:

import math

##素数判定を行う関数
def prime(p):
    if p==2 or p==3:
        return True
    else:
        i = int(math.sqrt(p))
        while i>=2:
            if p%i==0:
                return False
                break
            i-=1
        return True
                
            

N = int(input())
count = 0

for i in range(N):
    a = int(input())
    if prime(a)==True:
        count+=1
        
print(count)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
i = 1
num = [0] * 13 #num[i] -> ?´???°???i???????????°??§????°??????°

while True:
    cnt = 0
    for j in range(1, i+1):
        if i % j == 0:
            cnt += 1

    if num[cnt] == 0:
        num[cnt] = i

    if num[n] > 0:
        ans = num[n]
        break

    i += 1

print(ans)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
i = 1
num = [0] * 13

while True:
    cnt = 0
    for j in range(1, i+1):
        if i % j == 0:
            cnt += 1

    if cnt > 12:
        i += 1
        continue

    if num[cnt] == 0:
        num[cnt] = i

    if num[n] > 0:
        ans = num[n]
        break

    i += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
i = 1
num = [0] * 13

while True:
    cnt = 0
    for j in range(1, i+1):
        if i % j == 0:
            cnt += 1
    if cnt >= 12:
        i += 1
        continue

    if num[cnt] == 0:
        num[cnt] = i

    if num[n] > 0:
        ans = num[n]
        break

    i += 1

print(ans)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
i = 1
num = [0] * 13

while True:
    cnt = 0
    for j in range(1, i+1):
        if i % j == 0:
            cnt += 1

    if cnt > 12:
        i += 1
        continue

    if num[cnt] == 0:
        num[cnt] = i

    if num[n] > 0:
        ans = num[n]
        break

    i += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,w = map(int,input().split())
v = [0] * (n+1)
w = [0] * (n+1)

for j in range(1, n+1):
    v[j], w[j] = map(int,input().split())

dp = [[0 for i in range(w+1)] for j in range(n+1)]

for j in range(1, n+1):
    for i in range(1, w+1):
        dp[j][i] = max(dp[j-1][i], dp[j-1][i-w[j]] + v[i])

print(max(dp))

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N,W = map(int,input().split())
v = [0] * (N+1)
w = [0] * (N+1)

for j in range(1, N+1):
    v[j], w[j] = map(int,input().split())

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for j in range(1, N+1):
    for i in range(1, W+1):
        if w[j] <= i:
            dp[j][i] = max(dp[j-1][i], dp[j-1][i-w[j]] + v[j])
        else:
            dp[j][i] = dp[j-1][i]

print(dp[N][W])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#D
n = int(input())
a = [int(input()) for j in range(n)]

dp = [1] * n
ans = 0
for i in range(n):
    dp[i] = 1
    for j in range(i):
        if a[j] < a[i]:
            dp[i] = max(dp[i], dp[j]+1)

    ans = max(ans, dp[i])

print(ans)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import bisect
#D2
n = int(input())
a = [int(input()) for j in range(n)]

dp = [a[0]]
for i in range(1,n):
    if dp[-1] < a[i]:
        dp.append(a[i])
        #print(0,dp)

    else:
        dp[bisect.bisect_left(dp, a[i])] = a[i]
        #print(1,bisect.bisect_left(dp, a[i]),dp)
print(len(dp))
Buggy python submission (verdict: Runtime Error):
def f(n,k,x):
    dis = [x[i+1]-x[i] for i in range(n-1)]#隣り合う家の距離を調べる
    dis.sort()#電線の数-1だけ隣り合う家同士の電線を配置しなくて良い
    return sum(dis[:n-k])#隣り合う家の距離が大きい順にkー1個は電線を配置しない
    
t = int(input())
for i in range(t):
    n,k = map(int,input().split())
    x = list(map(int,input().split()))
    print(ans)


Fixed submission:
def f(n,k,x):
    if n <= k-1:
        return 0
    dis = [x[i+1]-x[i] for i in range(n-1)]#隣り合う家の距離を調べる
    dis.sort()#電線の数-1だけ隣り合う家同士の電線を配置しなくて良い
    return sum(dis[:n-k])#隣り合う家の距離が大きい順にkー1個は電線を配置しない
    
t = int(input())
for i in range(t):
    n,k = map(int,input().split())
    x = list(map(int,input().split()))
    print(f(n,k,x))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
phrase=[tuple(map(int,input().split())) for i in range(n)]
m=int(input())
inf=float('inf')
def main(phrase):
    w=int(input())
    dp=[-1*inf for _ in range(w+1)]
    dp[0]=0
    for i in range(1,w+1):
        for x in phrase:
            s,l,p=x
            for k in range(s,l+1):
                if i-k<0:break
                dp[i]=max(dp[i-k]+p,dp[i])
    return dp[w] if dp[w]>=0 else -1
ans=[]
for i in range(m):
    res=main(phrase)
    if res==-1:
        print(-1)
        break
    ans.append(res)
    if i==m-1:
        for i in range(m):
            print(ans[i])


Fixed submission:
n=int(input())
phrase=[tuple(map(int,input().split())) for i in range(n)]
m=int(input())
inf=float('inf')
def main(phrase):
    point=[-1 for _ in range(394)]
    for x in phrase:
        s,l,p=x
        for k in range(s,l+1):
            point[k]=max(point[k],p)
    point[0]=0
    for i in range(1,394):
        for j in range(i):
            point[i]=max(point[i-j]+point[j],point[i])
    return point
ans=[]
dp=main(phrase)
for i in range(m):
    res=dp[int(input())]
    if res==-1:
        print(-1)
        break
    ans.append(res)
    if i==m-1:
        for i in range(m):
            print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
#JOI
def main():
    X=input()
    Y=input()
    dp=[[0 for y in range(1+len(Y))] for x in range(1+len(X))]
    for x in range(len(X)):
        for y in range(len(Y)):
            now=0
            dp[x][y]=max(dp[x-1][y],dp[x][y-1])
            for x1 in range(Y[:y+1].count(X[x])):
                idx=now+Y[now:y+1].index(X[x])
                now=idx+1
                dp[x][y]=max(dp[x-1][idx-1]+1,dp[x][y])
            now=0
            for y1 in range(X[:x+1].count(Y[y])):
                idx=now+X[now:x+1].index(Y[y])
                now=idx+1
                dp[x][y]=max(dp[idx-1][y-1]+1,dp[x][y])
    print(dp[len(X)-1][len(Y)-1])
for i in range(int(input())):
    main()


Fixed submission:
def main():
    X=input()
    Y=input()
    dp=[]
    for y in range(len(Y)):
        now=0
        for i  in range(len(dp)):
            d=dp[i]
            if Y[y] in X[now:d]:
                dp[i]=now+X[now:d].index(Y[y])
            now=d+1
        if Y[y] in X[now:]:
            dp.append(now+X[now:].index(Y[y]))
    return len(dp)
for i in range(int(input())):
    print(main())

Buggy python submission (verdict: Time Limit Exceeded):
#JOI
def main():
    X=input()
    Y=input()
    dp=[[0 for y in range(1+len(Y))] for x in range(1+len(X))]
    for x in range(len(X)):
        for y in range(len(Y)):
            now=0
            dp[x][y]=max(dp[x-1][y],dp[x][y-1])
            idx=Y[:y+1].rfind(X[x])
            if idx!=-1:
                dp[x][y]=max(dp[x-1][idx-1]+1,dp[x][y])
            idx=X[:x+1].rfind(Y[y])
            if idx!=-1:
                dp[x][y]=max(dp[idx-1][y-1]+1,dp[x][y])
    print(dp[len(X)-1][len(Y)-1])
for i in range(int(input())):
    main()


Fixed submission:
def main():
    X=input()
    Y=input()
    dp=[]
    for y in range(len(Y)):
        now=0
        for i  in range(len(dp)):
            d=dp[i]
            if Y[y] in X[now:d]:
                dp[i]=now+X[now:d].index(Y[y])
            now=d+1
        if Y[y] in X[now:]:
            dp.append(now+X[now:].index(Y[y]))
    return len(dp)
for i in range(int(input())):
    print(main())
Buggy python submission (verdict: Runtime Error):
num = int(raw_input())
print(num*num*num)

Fixed submission:
import sys

num = int(sys.stdin.readline())
print(num**3)
Buggy python submission (verdict: Runtime Error):
while True:
    a = list(map(str, input().split()))
    if a[0] == "0":
        break
    elif int(a[1]) <= 30:
        print(" ".join(a))
    elif int(a[1]) == 31 and int(a[2]) <= 4:
        print(" ".join(a))
    else:
        a[0] = "?"
        s = int(a[1])
        s -= 30
        a[1] = str(s)
        print(" ".join(a))


Fixed submission:
while True:
    a = list(map(str, input().split()))
    if a[0] == "#":
        break
    elif int(a[1]) <= 30:
        print(" ".join(a))
    elif int(a[1]) == 31 and int(a[2]) <= 4:
        print(" ".join(a))
    else:
        a[0] = "?"
        s = int(a[1])
        s -= 30
        a[1] = str(s)
        print(" ".join(a))
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
a=list(map(int,input().split()))
q=int(input())
for i in range(q):
    k=int(input())
    t=0
    max=n-1
    min=0
    while max-min>1:
        nn=math.floor((max-min)/2)
        if a[nn]==k:
            t=1
            print("1")
            break
        elif a[nn]>k:
            min=nn
        else :
            max=nn
    if t==0:
        print("0")


Fixed submission:
import math
n=int(input())
a=list(map(int,input().split()))
q=int(input())
for i in range(q):
    k=int(input())
    t=0
    max=n-1
    min=0
    while max-min>1:
        nn=math.floor((max+min)/2)
        if a[nn]==k:
            t=1
            print("1")
            break
        elif a[nn]<=k:
            min=nn
        elif a[nn]>=k:
            max=nn
    if t==0:
        if a[max]==k or a[min]==k:
            t=1
            print("1")
        else:
            print("0")