Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
h_list=list(map(int,input().split()))
col_list=[[0]*n for _ in range(n)]
count=0
for _ in range(m):
  a,b=map(int,input().split())
  col_list[a-1][b-1]+=1
  col_list[b-1][a-1]+=1
for i in range(n):
  for j in range(n):
    if col_list[i][j]>=1 and h_list[i]<=h_list[j]:
      count+=1
      break
print(n-count)


Fixed submission:
n,m=map(int,input().split())
h_list=list(map(int,input().split()))
lst=[0]*n
for _ in range(m):
  a,b=map(int,input().split())
  if h_list[a-1]<=h_list[b-1]:
    lst[a-1]-=1
  if h_list[a-1]>=h_list[b-1]:
    lst[b-1]-=1
print(lst.count(0))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
h_list=list(map(int,input().split))
col_list=[[0]*n for _ in range(n)]
count=0
for _ in range(m):
  a,b=map(int,input().split)
  col_list[a-1][b-1]+=1

for i in range(n):
  for j in range(n):
    if col_list[i][j]>=1 and h_list[i]<=h_list[j]:
      count+=1
      break
print(n-count)


Fixed submission:
n,m=map(int,input().split())
h_list=list(map(int,input().split()))
lst=[0]*n
for _ in range(m):
  a,b=map(int,input().split())
  if h_list[a-1]<=h_list[b-1]:
    lst[a-1]-=1
  if h_list[a-1]>=h_list[b-1]:
    lst[b-1]-=1
print(lst.count(0))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
h_list=list(map(int,input().split))
col_list=[[0]*n]*n
count=0
for i in range(m):
  a,b=map(int,input().split)
  col_list[a-1][b-1]+=1

for i in range(n):
  for j in range(n):
    if col_list[i][j]>=1 and h_list[i]<=h_list[j]:
      count+=1
      break
print(n-count)


Fixed submission:
n,m=map(int,input().split())
h_list=list(map(int,input().split()))
lst=[0]*n
for _ in range(m):
  a,b=map(int,input().split())
  if h_list[a-1]<=h_list[b-1]:
    lst[a-1]-=1
  if h_list[a-1]>=h_list[b-1]:
    lst[b-1]-=1
print(lst.count(0))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*n
for i in range(n):
  a[i]=int(input().split())
num=sum(a)
tmp=num//(4*m)
count=0
for i in range(n):
  if a[i]>=tmp:
    count+=1
if count==m:
  print("Yes")
else:
  print("No")

Fixed submission:
n,m=map(int,input().split())
a=list(map(int, input().split()))
num=sum(a)
tmp=float(num)/float(4.0*m)
count=0
for i in range(n):
  if a[i]>=tmp:
    count+=1
if count>=m:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
ans=n
while True:
  if ans>=abs(ans-k):
    ans=abs(ans-k)
  else:
    break
print(ans)

Fixed submission:
n,k=map(int,input().split())
print(min(n,n-k*(n//k),abs(n-k*(n//k)-k)))
Buggy python submission (verdict: Runtime Error):
k,n=map(int,input().split())
a=list(map(int,input().split()))

ans=0
if max(a)<=(k/2.0) or min(a)>=(k/2.0):
  for i in range(n-1):
    ans+=abs(a[i+1]-a[i])
else:
  for i in range(n):
    if a[i]>k/2.0:
      a[i]-=k
    else:
      j=i
  for i in range(j):
     ans+=abs(a[i+1]-a[i])
  ans+=abs(a[n]-a[0])
  for i in range(j+1,n-1):
    ans+=abs(a[i+1]-a[i])
print(ans)

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

ans=0
if max(a)<=(k/2.0) or min(a)>=(k/2.0):
  for i in range(n-1):
    ans+=abs(a[i+1]-a[i])
else:
  max_=0
  for i in range(n-1):
    max_=max(max_,abs(a[i+1]-a[i]))
  max_=max(max_,abs(a[0]-(a[n-1]-k)))
  ans=k-max_
print(ans)

Buggy python submission (verdict: Runtime Error):
k,n=map(int,input().split())
a=list(map(int,input().split()))

ans=0
if max(a)<=k/2.0 or min(a)>=k/2.0:
  for i in range(n):
    ans+=abs(a[i+1]-a[i])
else:
  for i in range(n):
    if a[i]>k/2.0:
      a[i]-=k
    else:
      j=i
  for i in range(j):
     ans+=abs(a[i+1]-a[i])
  ans+=abs(a[n]-a[0])
  for i in range(j+1,n):
    ans+=abs(a[i+1]-a[i])
print(ans)

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

ans=0
if max(a)<=(k/2.0) or min(a)>=(k/2.0):
  for i in range(n-1):
    ans+=abs(a[i+1]-a[i])
else:
  max_=0
  for i in range(n-1):
    max_=max(max_,abs(a[i+1]-a[i]))
  max_=max(max_,abs(a[0]-(a[n-1]-k)))
  ans=k-max_
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y=map(int,input().split())
#a<b
def dis(a,b):
    return min (b-a,abs(a-x)+1+abs(b-y))

for k in range(1,n):
  count=0
  #i<j
  for i in range(1,n):
    for j in range(i+1,n+1):
      if dis(i,j)==k:
        count+=1
  print(count)

Fixed submission:
n,x,y=map(int,input().split())
#a<b
def dis(a,b):
    return min (b-a,abs(a-x)+1+abs(b-y))

# for k in range(1,n):
#   count=0
#   #i<j
#   for i in range(1,n):
#     for j in range(i+1,n+1):
#       if dis(i,j)==k:
#         count+=1
#   print(count)
ans=[0]*(n-1)
#i<j
for i in range(1,n):
  for j in range(i+1,n+1):
    ans[dis(i,j)-1]+=1
print(*ans,sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
L=int(input())
ans=0
tmp=0
#分割数
d=300
l=5
L_=int(L**(1/3))
for i in range(max(0,int(L_-l)*d),int(L_+l)*d):
  for j in range(max(0,int(L_-l)*d-i),int(L_+l)*d-i):
    tmp=(i/d)*(j/d)*(L-(i/d)-(j/d))
    ans=max(ans,tmp,0)
print(ans)

Fixed submission:
L=int(input())
print((L**3)/27)

Buggy python submission (verdict: Time Limit Exceeded):
L=int(input())
ans=0
tmp=0
#分割数
d=1000
l=5
L_=int(L**(1/3))
for i in range(max(0,int(L_-l)*d),int(L_+l)*d):
  for j in range(max(0,int(L_-l)*d-i),int(L_+l)*d-i):
    tmp=(i/d)*(j/d)*(L-(i/d)-(j/d))
    ans=max(ans,tmp,0)
print(ans)

Fixed submission:
L=int(input())
print((L**3)/27)

Buggy python submission (verdict: Runtime Error):
L=int(input())
ans=0
tmp=0
d=3
for i in range(int(L*d/1.45):
  for j in range(int((L*d-i)/1.45)):
    tmp=(i/d)*(j/d)*(L-(i/d)-(j/d))
    ans=max(ans,tmp,0)
print(ans)

Fixed submission:
L=int(input())
print((L**3)/27)

Buggy python submission (verdict: Runtime Error):
L=int(input())
ans=0
tmp=0
d=3
for i in range(L*d/2):
  for j in range(L*d-i):
    tmp=(i/d)*(j/d)*(L-(i/d)-(j/d))
    ans=max(ans,tmp,0)
print(ans)

Fixed submission:
L=int(input())
print((L**3)/27)

Buggy python submission (verdict: Time Limit Exceeded):
L=int(input())
ans=0
tmp=0
d=3
for i in range(L*d):
  for j in range(L*d-i):
    tmp=(i/d)*(j/d)*(L-(i/d)-(j/d))
    ans=max(ans,tmp,0)
print(ans)

Fixed submission:
L=int(input())
print((L**3)/27)
Buggy python submission (verdict: Runtime Error):
s=str(input())
if len(s)%2==1:
    print("No")
else:
    is_hitachi=1
    for i in range(int(len(s)/2)):
        if s[2i]!="h" or s[2i+1]!="i":
            is_hitachi=0
            break
    if is_hitachi==1:
        print("Yes")
    else:
        print("No")

Fixed submission:
s=str(input())
if len(s)%2==1:
    print("No")
else:
    is_hitachi=1
    for i in range(int(len(s)/2)):
        if s[2*i]!="h" or s[2*i+1]!="i":
            is_hitachi=0
            break
    if is_hitachi==1:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Runtime Error):
s=str(input())
if len(s)%2==1:
    print("No")
else:
    is_hitachi=1
    for i in range(len(s)/2):
        if s[2i]!="h" or s[2i+1]!="i":
            is_hitachi=0
            break
    if is_hitachi==1:
        print("Yes")
    else:
        print("No")

Fixed submission:
s=str(input())
if len(s)%2==1:
    print("No")
else:
    is_hitachi=1
    for i in range(int(len(s)/2)):
        if s[2*i]!="h" or s[2*i+1]!="i":
            is_hitachi=0
            break
    if is_hitachi==1:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
min_price=min(a)+min(b)
for i in range(M):
    m=list(map(int,input().split()))
    tmp_price=a[m[0]]+b[m[1]]-m[2]
    if min_price>tmp_price:
        min_price=tmp_price
print(min_price)

Fixed submission:
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
min_price=min(a)+min(b)
for i in range(M):
    tmp_price=10000
    m=list(map(int,input().split()))
    tmp_price=a[m[0]-1]+b[m[1]-1]-m[2]
    if min_price>tmp_price:
        min_price=tmp_price
print(min_price)

Buggy python submission (verdict: Runtime Error):
A,B,M=map(int,input().split())
a=list(map(int,input().split())
b=list(map(int,input().split())
min_price=min(a)+min(b)
for i in range(M):
    m=list(map(int,input().split())
    tmp_price=a[m[0]]+b[m[1]]-m[2]
    if min_price>tmp_price:
        min_price=tmp_price
print(min_price)

Fixed submission:
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
min_price=min(a)+min(b)
for i in range(M):
    tmp_price=10000
    m=list(map(int,input().split()))
    tmp_price=a[m[0]-1]+b[m[1]-1]-m[2]
    if min_price>tmp_price:
        min_price=tmp_price
print(min_price)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
s=[0]*M
c=[0]*M
ans=[0]*N
s_1i=[]
s_2i=[]
s_3i=[]
for i in range(M):
    s[i],c[i]=map(int,input().split())
flg=0
for i in range(M):
    if s[i]==1 and c[i]==0:
        flg+=1
for i in range(M):
    if s[i]==1:
        s_1i.append(c[i])
    elif s[i]==2:
        s_2i.append(c[i])
    elif s[i]==3:
        s_3i.append(c[i])
if len(s_1i)>=2:
    if s_1i.count(s_1i[0])!=len(s_1i):
        flg+=1
if len(s_2i)>=2:
    if s_2i.count(s_2i[0])!=len(s_2i):
        flg+=1
if len(s_3i)>=2:
    if s_3i.count(s_3i[0])!=len(s_3i):
        flg+=1
if flg>=1:
    print("-1")
else:
    if (1 not in s) and (N!=1):
        ans[0]=1
    for i in range(M):
        ans[s[i]-1]=c[i]
    for i inrange(N):
        print(ans[i],end="")

Fixed submission:
N=int(input())
if N%2==1:
    print(int(N/2)+1)
else:
    print(int(N/2))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
i=0
while N>K=**i:
    i+=1
print(i)

Fixed submission:
N,K=map(int,input().split())
i=0
while N>=K**i:
    i+=1
print(i)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
i=0
while N>=k**i:
    i+=1
print(i)

Fixed submission:
N,K=map(int,input().split())
i=0
while N>=K**i:
    i+=1
print(i)
Buggy python submission (verdict: Runtime Error):
N=int(input())
s=input()

#毎ステップ毎にカウントする処理→TLE
# ans=10**6
# for i in range(1,N):
#   ans=min(ans,s[:i-1].count("W")+s[i+1:].count("E"))
# print(ans)
ans=[]
ans.append(s[1:].count("E"))
tmp=ans[0]
for i in range(1:N):
  if s[i]=="E":
    tmp-=1
  if s[i-1]=="W":
    tmp+=1
  ans.append(tmp)
print(min(ans))

Fixed submission:
n=int(input())
s=input()

#毎ステップ毎にカウントする処理→TLE
# ans=10**6
# for i in range(1,N):
#   ans=min(ans,s[:i-1].count("W")+s[i+1:].count("E"))
# print(ans)
ans=[]
ans.append(s[1:].count("E"))
tmp=ans[0]
for i in range(1,n):
  if s[i]=="E":
    tmp-=1
  if s[i-1]=="W":
    tmp+=1
  ans.append(tmp)
print(min(ans))

Buggy python submission (verdict: Runtime Error):
N=int(input())
s=list(input())

#毎ステップ毎にカウントする処理→TLE
# ans=10**6
# for i in range(1,N):
#   ans=min(ans,s[:i-1].count("W")+s[i+1:].count("E"))
# print(ans)
ans=[]
ans[0]=s[1:].count("E")
tmp=ans[0]
for i in range(1:N):
  if s[i]=="E":
    tmp-=1
  if s[i-1]=="W":
    tmp+=1
  ans.append(tmp)
print(min(ans))

Fixed submission:
n=int(input())
s=input()

#毎ステップ毎にカウントする処理→TLE
# ans=10**6
# for i in range(1,N):
#   ans=min(ans,s[:i-1].count("W")+s[i+1:].count("E"))
# print(ans)
ans=[]
ans.append(s[1:].count("E"))
tmp=ans[0]
for i in range(1,n):
  if s[i]=="E":
    tmp-=1
  if s[i-1]=="W":
    tmp+=1
  ans.append(tmp)
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=list(input())

ans=10**6
for i in range(1,N):
  ans=min(ans,s[:i-1].count("W")+s[i+1:].count("E"))
print(ans)

Fixed submission:
n=int(input())
s=input()

#毎ステップ毎にカウントする処理→TLE
# ans=10**6
# for i in range(1,N):
#   ans=min(ans,s[:i-1].count("W")+s[i+1:].count("E"))
# print(ans)
ans=[]
ans.append(s[1:].count("E"))
tmp=ans[0]
for i in range(1,n):
  if s[i]=="E":
    tmp-=1
  if s[i-1]=="W":
    tmp+=1
  ans.append(tmp)
print(min(ans))
Buggy python submission (verdict: Runtime Error):
from itertools import product

s=input()

for op in product(["+","-"],repeat=len(s)-1):
  formula =""
  for i in range(len(s-1)):
    formula+=s[i]+op[i]
  formula+=s[-1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()

Fixed submission:
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])

if a+b+c+d==7:
  print("%d+%d+%d+%d=7"%(a,b,c,d))
  exit()
if a+b+c-d==7:
  print("%d+%d+%d-%d=7"%(a,b,c,d))
  exit()
if a+b-c+d==7:
  print("%d+%d-%d+%d=7"%(a,b,c,d))
  exit()
if a+b-c-d==7:
  print("%d+%d-%d-%d=7"%(a,b,c,d))
  exit()  
if a-b+c+d==7:
  print("%d-%d+%d+%d=7"%(a,b,c,d))
  exit()
if a-b+c-d==7:
  print("%d-%d+%d-%d=7"%(a,b,c,d))
  exit()
if a-b-c+d==7:
  print("%d-%d-%d+%d=7"%(a,b,c,d))
  exit()
if a-b-c-d==7:
  print("%d-%d-%d-%d=7"%(a,b,c,d))
  exit()

Buggy python submission (verdict: Runtime Error):
from itertools import product

s=input()

for op in product(["+","-"],repeat=len(s)-1):
  formula =""
  for i in range(len(s-1)):
    formula+=s[i]+op[i]
  formula+=s[1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()

Fixed submission:
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])

if a+b+c+d==7:
  print("%d+%d+%d+%d=7"%(a,b,c,d))
  exit()
if a+b+c-d==7:
  print("%d+%d+%d-%d=7"%(a,b,c,d))
  exit()
if a+b-c+d==7:
  print("%d+%d-%d+%d=7"%(a,b,c,d))
  exit()
if a+b-c-d==7:
  print("%d+%d-%d-%d=7"%(a,b,c,d))
  exit()  
if a-b+c+d==7:
  print("%d-%d+%d+%d=7"%(a,b,c,d))
  exit()
if a-b+c-d==7:
  print("%d-%d+%d-%d=7"%(a,b,c,d))
  exit()
if a-b-c+d==7:
  print("%d-%d-%d+%d=7"%(a,b,c,d))
  exit()
if a-b-c-d==7:
  print("%d-%d-%d-%d=7"%(a,b,c,d))
  exit()
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=[0]*N
for i in range(N):
  a[i]=int(input())
count=0

#loopの定義→同じインデックスを使用したら
loop=[]

# tmp=a[0]
# if tmp==2:
#   print(1)
#   exit()
tmp=1
while True:  
  tmp=a[tmp-1]
  count+=1
  if tmp==2:
    print(count)
    exit()
  if tmp-1 in loop:
    print(-1)
    exit()
  loop.append(tmp-1)
  

Fixed submission:
N=int(input())
a=[0]*N
for i in range(N):
  a[i]=int(input())
count=0

#loopの定義→同じインデックスを使用したら
#loop=[]
loop=set()

tmp=1
while True:  
  tmp=a[tmp-1]
  count+=1
  if tmp==2:
    print(count)
    exit()
  if tmp-1 in loop:
    print(-1)
    exit()
  loop.add(tmp-1)
Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z=s:
        count+=1
print(count)

Fixed submission:
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
      if k>=s-x-y>=0:
        count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x=map(int,input().split())
ans=0
for i in range(a,b+1):
  if i%x==0:
    ans+=1
print(ans)

Fixed submission:
a,b,x=map(int,input().split())
#TLE#########################
# ans=0
# for i in range(a,b+1):
#   if i%x==0:
#     ans+=1
# print(ans)
################################
print(b//x - (a-1)//x)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

# 1 ✕ 1 (int)
N = int(input().rstrip())

# N ✕ M (2D array)
A = list(map(int, input().rstrip().split()) for _ in range(N - 1))

items = [[-1] * (N) for _ in range(N)]
colors = [-1 for _ in range(N)]

for i in range(N - 1):
    a, b, w = A[i]
    items[a - 1][b - 1] = w
    items[b - 1][a - 1] = w


def dfs(v, c):
    colors[v] = c
    for i in range(N):
        w = items[v][i]
        if w == -1:
            continue

        cc = colors[i]
        nc = c if w % 2 == 0 else not c
        if cc != -1 and colors[i] != nc:
            return False
        if cc == -1 and not dfs(i, nc):
            return False

    return True


dfs(0, True)
for c in colors:
    print(int(not c))


Fixed submission:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (int)
N = int(input().rstrip())

# N ✕ M (2D array)
A = list(map(int, input().rstrip().split()) for _ in range(N - 1))

items = [[] for _ in range(N)]
colors = [-1 for _ in range(N)]

for i in range(N - 1):
    a, b, w = A[i]
    items[a - 1].append((b - 1, w))
    items[b - 1].append((a - 1, w))

queue = collections.deque()
queue.append(0)
colors[0] = 0
while queue:
    v = queue.popleft()
    c = colors[v]
    for k, w in items[v]:
        cc = colors[k]
        if cc == -1:
            nc = c if w % 2 == 0 else not c
            colors[k] = nc
            queue.append(k)

# def dfs(v, c):
#     colors[v] = c
#
#     cc = colors[k]
#
#     if cc == -1:
#         if not dfs(k, nc):
#             return False
#     else:
#         if colors[i] != nc:
#             return False
#
#
# return True
#
# dfs(0, True)
for c in colors:
    print(int(not c))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from itertools import *
from operator import itemgetter

def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    sorted_list = [(P[i], Y[i]) for i in range(M)]
    sorted_list.sort()

    group_list = dict((key, list(map(lambda x: x[1], items))) for key, items in groupby(sorted_list, key = itemgetter(0)))
    for i in range(N + 1):
        key = P[i]
        rank = group_list[P[i]].index(Y[i]) + 1
        print('{0:06d}'.format(key, rank) + '{0:06d}'.format(rank))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

dic = {}

def list_sort(x):
    values = dic[x]
    values.sort()

    return {x: values}

def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    for i in range(N):
        dic[i + 1] = []
    
    for i in range(M):
        dic[P[i]].append(Y[i])

    sorted_dic = {}
    for key in dic.keys():
        tmp = {}
        values = dic[key]

        values.sort()
        for i in range(len(values)):
            tmp[values[i]] = i + 1

        sorted_dic[key] = tmp


    for m in range(M):
        key = P[m]
        value = Y[m]
        sorted_ranked_dic = sorted_dic[key]
        rank = sorted_ranked_dic[value]

        print('{0:06d}'.format(key, rank) + '{0:06d}'.format(rank))



    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
x = int(input())

b = 0
while (x + b**5)**0.2 != int((x + b**5)**0.2) and b < 60:
    b += 1

if (x + b**5)**0.2 != int((x + b**5)**0.2):
    b = -1
    while (x + b**5)**0.2 != int((x + b**5)**0.2) and b > -60:
        b -= 1

a = int((x + b**5)**0.2)
print(a, b)

Fixed submission:
x = int(input())

for a in range(-200, 200):
    for b in range(-200, 200):
        if a**5 - b**5 == x:
            print(a, b)
            quit()

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

while (x + b**5)**(1/5) != int((x + b**5)**(1/5)) and b < 60:
    b += 1

if (x + b**5)**(1/5) != int((x + b**5)**(1/5)):
    b = -1
    while (x + b**5)**(1/5) != int((x + b**5)**(1/5)) and b > -60:
        b -= 1

a = int((x + b**5)**(1/5))
print(a, b)

Fixed submission:
x = int(input())

for a in range(-200, 200):
    for b in range(-200, 200):
        if a**5 - b**5 == x:
            print(a, b)
            quit()

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

answerNotFound = True
while (x + b**5)**(1/5) != int((x + b**5)**(1/5)) and b < 60:
    b += 1

if (x + b**5)**(1/5) != int((x + b**5)**(1/5)):
    b = -1
else:
    answerNotFound = False

if answerNotFound:
    while (x + b**5)**(1/5) != int((x + b**5)**(1/5)) and b > -60:
        b -= 1
        answerNotFound = True

if answerNotFound:
    print(int((x + b**5)**(1/5)), b)

Fixed submission:
x = int(input())

for a in range(-200, 200):
    for b in range(-200, 200):
        if a**5 - b**5 == x:
            print(a, b)
            quit()
Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = [int(x) for x in input().split()]

x = 2
answer = (a*1//b) - a*(1//b)
while x <= n:
    if (a*x//b) - a*(x//b) > answer:
        answer = (a*x//b) - a*(x//b)
    x += 1

print(answer)

Fixed submission:
a, b, n = [int(x) for x in input().split()]

y = min(b-1, n)

print((a*y)//b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
items = [input() for _ in range(n)]

print(len(list(set(items)))

Fixed submission:
n = int(input())
items = [input() for _ in range(n)]

print(len(list(set(items))))
Buggy python submission (verdict: Runtime Error):
n, blue, red = [int(x) for x in input().split()]

balls = "b"*blue + "r"*red

x = 0
if balls != "":
    x = n // len(balls) + 1

row = balls*x

print(row[:n].count("b"))


Fixed submission:
n, a, b = map(int, input().split())
period = a+b
times = n//period
k = n%period
n =  a if k >a else k
print(times*a + n)

Buggy python submission (verdict: Runtime Error):
n, blue, red = [int(x) for x in input().split()]

balls = "b"*blue + "r"*red
x = n // len(balls) + 1

row = balls*x

print(row[:n].count("b"))


Fixed submission:
n, a, b = map(int, input().split())
period = a+b
times = n//period
k = n%period
n =  a if k >a else k
print(times*a + n)

Buggy python submission (verdict: Runtime Error):
n, blue, red = [int(x) for x in input().split()]

row = ""
while len(row) <= n:
    row += "b"*blue + "r"*red

print(row[:n].count("b"))


Fixed submission:
n, a, b = map(int, input().split())
period = a+b
times = n//period
k = n%period
n =  a if k >a else k
print(times*a + n)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for _ in range(q):
    operation = input()
    if (operation[0] == '1'):
        s = s[::-1]
    else:
        if (operation[2] == '1'):

            s = operation[4] + s
        else:
            s += operation[4]


print(s)

Fixed submission:
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)