Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x = int(input())
ans = 1
for i in range(x, 0, -1):
  m = i
  div = []
  for j in range(2,int(m**0.5)+2):
    if m%j==0:
      count = 0
      while m%j ==0:
        m //= j
        count += 1
      div.append(count)
  if m!= 1:
    div.append(1)
  count = div[0]
  for c in div:
    if c!= count or count ==1:
      break
  else:
    print(i)
    exit()
print(ans)



Fixed submission:
x = int(input())
if x==1:
  print(1)
  exit()
ans = 1
for i in range(x, 0, -1):
  m = i
  div = []
  for j in range(2,int(m**0.5)+2):
    if m%j==0:
      count = 0
      while m%j ==0:
        m //= j
        count += 1
      div.append(count)
  if m!= 1:
    div.append(1)
  count = div[0]
  for c in div:
    if c!= count or count ==1:
      break
  else:
    print(i)
    exit()
print(ans)

Buggy python submission (verdict: Runtime Error):
x = int(input())
for i in range(x, 0, -1):
  ans = i
  div = []
  for j in range(2,(x**0.5)+1):
    count = 0
    if i%j ==0:
      while i%j==0:
        i //= j
        count += 1
      div.append(count)
  if len(div) == 1 and div[0] > 1:
    print(ans)

Fixed submission:
x = int(input())
if x==1:
  print(1)
  exit()
ans = 1
for i in range(x, 0, -1):
  m = i
  div = []
  for j in range(2,int(m**0.5)+2):
    if m%j==0:
      count = 0
      while m%j ==0:
        m //= j
        count += 1
      div.append(count)
  if m!= 1:
    div.append(1)
  count = div[0]
  for c in div:
    if c!= count or count ==1:
      break
  else:
    print(i)
    exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
P = list(map(int,input().split()))

uf = {i+1:i+1 for i in range(1,n+1)}

def get_parent(i):
  lst = []
  while uf[i] != i:
    lst.append(i)
    i = uf[i]
  for l in lst[:-1]:
    uf[l] = i
  return i

def unite(uf,i,j):
  p = get_parent(i)
  uf[get_parent(j)] = p

def same(i,j):
  return get_parent(i) == get_parent(j)

for _ in range(m):
  x,y = map(int,input().split())
  unite(x,y)

ans = 0
for i in range(1,n+1):
  ans += int(same(P[i-1],uf[i]))
print(ans)

Fixed submission:
n,m = map(int,input().split())
P = list(map(int,input().split()))
uf = {i:-1 for i in range(1,n+1)}

def get_p(i):
  while uf[i] != i:
    if uf[i] == -1:
      return i
    i = uf[i]
  return i

for _ in range(m):
  x,y = map(int,input().split())
  if x > y:
    x,y = y,x
  if uf[x]== uf[y] == -1:
    uf[x] = x
    uf[y] = x
  elif uf[x] != -1 and uf[y] != -1:
    p = get_p(x)
    uf[x] = p
    index = y
    while index != uf[index]:
      index = uf[y]
      uf[y] = p
      y = index
    else:
      uf[index] = p
  else:
    if uf[x] == -1:
      p = get_p(y)
    else:
      p = get_p(x)
    uf[x] = p
    uf[y] = p

ans = 0  
for i, p in enumerate(P):
  if get_p(i+1) == get_p(p):
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
A = list(map(int,input().split()))
A.sort()
k = int(input())
ans = sum(A[:2]) + A[3]*(2**k)
print(ans)

Fixed submission:
A = list(map(int,input().split()))
A.sort()
k = int(input())
ans = sum(A[:2]) + A[2]*(2**k)
print(ans)

Buggy python submission (verdict: Runtime Error):
A = list(map(int,input().split()))
A.sort()
k = int(input())
ans = sum(A[:2]) + A[3]*(2**k)

Fixed submission:
A = list(map(int,input().split()))
A.sort()
k = int(input())
ans = sum(A[:2]) + A[2]*(2**k)
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
figure = [input() for _ in range(H)]
D = [(1,0), (-1, 0), (0,1), (0,-1)]

for h in range(H):
  for w in range(W):
    if figure[h][w] == '#':
      for dh,dw in D:
        nh, nw = h+dh, w+dw
        if not (0 <= nh <=H and 0 <= nw <= W):
          continue
        if figure[nh][nw] == '#':
          break
      else:
        print('No')
        exit()
print('Yes')

Fixed submission:
H,W = map(int,input().split())
figure = [input() for _ in range(H)]
D = [(1,0), (-1, 0), (0,1), (0,-1)]

for h in range(H):
  for w in range(W):
    if figure[h][w] == '#':
      for dh,dw in D:
        nh, nw = h+dh, w+dw
        if not (0 <= nh <H and 0 <= nw < W):
          continue
        if figure[nh][nw] == '#':
          break
      else:
        print('No')
        exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
s = input(s)
l = ['a','b','c']
for c in s:
  l.remove(c)
print('Yes' if l ==[] else 'No')

Fixed submission:
s = input()
l = ['a','b','c']
for c in s:
  if c in l:
    l.remove(c)
print('Yes' if l ==[] else 'No')
Buggy python submission (verdict: Runtime Error):
_ = input()
A = list(map(int,input().split()))
if 'Y' in A:
  print('Four')
else:
  print('Three')

Fixed submission:
_ = input()
A = list(input().split())
if 'Y' in A:
  print('Four')
else:
  print('Three')
Buggy python submission (verdict: Runtime Error):
n = int(input())
AS = list(map(int,input().split()))

points = [0,0]#alice,bob
i = 0
while AS:
  point = max(AS)
  points[i] += point
  AS.remove(point)
  i = 1-i
print(point[0]-point[1])

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

points = [0,0]#alice,bob
i = 0
while AS:
  point = max(AS)
  points[i] += point
  AS.remove(point)
  i = 1-i
print(points[0]-points[1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

from itertools import accumulate

A = list(accumulate(A))
B = list(accumulate(B[::-1]))[::-1]

ans = 0
for i in range(n):
  ans = max(A[i]+B[i])
print(ans)

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

from itertools import accumulate

A = list(accumulate(A))
B = list(accumulate(B[::-1]))[::-1]



ans = 0
for i in range(n):
  ans = max(A[i]+B[i], ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=  input()
s[3] = '8'
print(s)

Fixed submission:
s= input()
if s[:4]=='2017':
  print('2018'+s[4:])
else:
  print(s)
Buggy python submission (verdict: Runtime Error):
n = input()
x = int(input())
fx = 0
for i in n:
  fx += int(i)
print('Yes' if x%fx ==0 else 'No')

Fixed submission:
n = input()
a = 0
for i in n:
  a += int(i)
print('Yes' if int(n) % a == 0 else 'No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
F = []
for i in range(n):
  f = list(map(int,input().split()))
  shop = []
  for j in range(5):
    shop.append([f[2*j],f[2*j+1]])
  F.append(shop)
P = [list(map(int,input().split())) for _ in range(n)]

import numpy as np
ans = -float('inf')
for i in range(1,2**10):
  index =format(i,'b').zfill(10)
  open_j = [int(j) for j in index]
  open_j = np.array(open_j).reshape(5,2)
  score = 0
  for j in range(n):
    count = 0
    for k in range(5):
      for l in range(2):
        if F[j][k][l] and open_j[k][l]:
          count += 1
    score += P[j][count]
  ans = max(ans,score)
print(ans)

Fixed submission:
n = int(input())         
import numpy as np

open = np.array([list(map(int,input().split())) for i in range(n)])
p  = np.array([list(map(int,input().split())) for i in range(n)])

max_p = -999999999999
                     
for j in range(1,2**10):  
  store = [0,0,0,0,0,0,0,0,0,0] 
  flag = True          
  for k in range(10):  
    if j %2 ==1 : 
      store[k] = 1 
    j = int(j/2)                           
#store = np.array([1,0,1,0,0,0,0,0,0,0]) 
  days = [sum(i) for i in store * open] 
  score = 0                            
  for i in range(n):                   
          score += p[i][days[i]]
  if score > max_p: 
    max_p = score            
print(max_p)
Buggy python submission (verdict: Runtime Error):
import collections
n,c  = map(int,input().split())                     
channels = [list(map(int,input().split())) for i in range(n)]
print(channels)
channel_set = [list(range(i[0],i[1]+1)) for i in channels]
channels = []                                                
for ch in channel_set:
    channels.extend(ch)                                   
print(channels)                                  
#map(int,input().split())                                           c = collections.Counter(channels)
print(c.most_common()[0][1])

Fixed submission:
N,C = map(int,input().split())

def inc(n):
  return n+1
def dec(n):
  return n-1

history = {}
for i in range(N):
  s,t,c = map(int,input().split())
  s *= 2
  t *= 2
  #print(history)
  if (t-1) in history and c in history[t-1]:
    history[t-1].pop(c)
  else:
    if t in history:
      history[t][c] = dec
    else:history[t] = {c:dec}
  if (s) in history and c in history[s]:
    history[s].pop(c)
  else:
    #history[s-0.5][c] = inc
    if s-1 in history:
      history[s-1][c] = inc
    else:
      history[s-1] = {c:inc}
maximum = 0
counter = 0
for i in range(100000*2):
  if i in history:
    for func in history[i].values():
      counter = func(counter)
    if counter > maximum:
      maximum = counter
#print(history)
print(maximum)
Buggy python submission (verdict: Runtime Error):
s = input()

def func(ac,s,op):
  next = s[0]
  if len(s) ==1:
    if ac + next == 7:
      print(str+'+'+s[0]+'=7')
      exit(0)
    if ac - next == 7:
      print(str+'-'+s[0]+'=7')
      exit(0)
  else:
    func(ac+next,s[1:],op+'+'+str(next))
    func(ac-next,s[1:],op+'-'+str(next))
  
func(int(s[0]),s[1:],s[0])

Fixed submission:
s = input()
n = []
op = []

def calc(lst,n,op):
  if lst:
    op.append('+')
    p = calc(lst[:-1],n+lst[-1],op)
    if p:
      return p
    op.pop()
    op.append('-')
    n = calc(lst[:-1],n-lst[-1],op)
    if n:
      return n
    op.pop()
  else:
    if n == 7:
      return op
    else:
      return None
  
    

for i in range(3):
  n.append(int(s[3-i]))
op = calc(n,int(s[0]),op)
print('{}{}{}{}{}{}{}=7'.format(s[0],op[0],s[1],op[1],s[2],op[2],s[3]))
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
c = [[int(i) for i in input().split()] for _ in range(10)]
A = {i:0 for i in range(10)}
for _ in range(h):
  for i in input().split():
    A[int(i)] += 1
    

for k in range(10):
  for i in range(10):
    for j in range(10):
      c[i][j] = min(c[i][k] + c[k][j],c[i][j])
      

ans = 0
for i in range(10):
  ans += c[i][1] * A[i]
print(ans)




Fixed submission:
h,w = map(int,input().split())
c = [[int(i) for i in input().split()] for _ in range(10)]
A = {i:0 for i in range(10)}
for _ in range(h):
  for i in input().split():
    if i != '-1':
      A[int(i)] += 1
    

for k in range(10):
  for i in range(10):
    for j in range(10):
      c[i][j] = min(c[i][k] + c[k][j],c[i][j])
      

ans = 0
for i in range(10):
  ans += c[i][1] * A[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
AS = list(int,input().split())
AS.sort()
BS = list(int,input().split())
BS.sort()
CS = list(int,input().split())
CS.sort()
import bisect
AB  = [0 for _ in range(n)]
BC  = [0 for _ in range(n)]
a = 0
for b in range(n):
  AB[b] = bisect.bisect_left(AS,BS[b])
  
for b in range(n):
  BC[b] = n-bisect.bisect_left(CS,BS[b])

ans = 0
for i in range(n):
  ans += AB[b] * BS[b]
print(ans)
    

Fixed submission:
n = int(input())
AS = list(map(int,input().split()))
AS.sort()
BS = list(map(int,input().split()))
CS = list(map(int,input().split()))
CS.sort()
import bisect
  
ans = 0
for b in range(n):
  ans += bisect.bisect_left(AS,BS[b])*(n-bisect.bisect_right(CS,BS[b]))

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()[::-1]
t = input()[::-1]
for i,c in enumerate(s):
  if (c == t[0] or c == '?') and (i+len(t) < len(s)-1):
    for j in range(len(t)):
      if t[j] != s[i+j] and s[i+j] != '?':
        break
    else:
      for j in range(len(t)):
        s[i+j] =  t[j]
      print(s.replace('?', 'a')[::-1])
      break
else:
  print('UNRESTORABLE')



Fixed submission:
r = int(input())
g = int(input())   
print(2 * g -r)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
graph = {i+1:[] for i in range(1,n+1)}

for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
  
bridge = set([])

ans = 0
while 1:
  count = 0
  for i in range(1,n+1):
    if len(graph[i]) == 1:
      count += 1
      a = graph[i]
      graph[a].remove(i)
      graph[i] = []
  ans += count
  if count == 0:
    break
  else:
    count = 0
print(ans)
  

Fixed submission:
n,m = map(int,input().split())
graph = {i:[] for i in range(1,n+1)}

for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
  
bridge = set([])

ans = 0
while 1:
  count = 0
  for i in range(1,n+1):
    if len(graph[i]) == 1:
      count += 1
      a = graph[i][0]
      graph[a].remove(i)
      graph[i] = []
  ans += count
  if count == 0:
    break
  else:
    count = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
an = list(map(int,input().split()))

odd = filter((lambda x:x%2==1),an)
div4 = filter((lambda x:x%4 ==0),an)
div2 = set(an).difference(set(odd)).difference(set(div4))
if len(div2) == 0:
  div4.append(0)
if len(odd) <= len(div4)+1:
  print('Yes')
else:
  print('No')

Fixed submission:
_ = int(input())
an = list(map(int,input().split()))

odd = list(filter((lambda x:x%2==1),an))
div4 = list(filter((lambda x:x%4 ==0),an))
div2 = set(an).difference(set(odd)).difference(set(div4))
if len(div2) == 0:
  div4.append(0)
if len(odd) <= len(div4):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
from collections import deque

B = deque([])

for i in range(n):
  if i %2:
    B.appendleft(A[i])
  else:
    B.append(A[i])
    
if n%2:
  B = B[::-1]
print(*B)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
from collections import deque

B = deque([])

for i in range(n):
  if i %2:
    B.appendleft(A[i])
  else:
    B.append(A[i])
B = list(B)
if n%2:
  B = B[::-1]
print(*B)

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

B = []

for i in range(n):
  if i %2:
    B = [A[i]] + B
  else:
    B.append(A[i])
    
if n%2:
  B = B[::-1]
print(*B)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
from collections import deque

B = deque([])

for i in range(n):
  if i %2:
    B.appendleft(A[i])
  else:
    B.append(A[i])
B = list(B)
if n%2:
  B = B[::-1]
print(*B)

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

B = []

for i in range(n):
  if i %2:
    B = [A[i]] + B
  else:
    B = B.append(A[i])
    
if n%2:
  B = B[::-1]
print(*B)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
from collections import deque

B = deque([])

for i in range(n):
  if i %2:
    B.appendleft(A[i])
  else:
    B.append(A[i])
B = list(B)
if n%2:
  B = B[::-1]
print(*B)

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

B = []

for i in range(n):
  if i %2:
    B = [A[i]] + B
  else:
    B = B + [A[i]]
    
if n%2:
  B = B[::-1]
print(*B)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
from collections import deque

B = deque([])

for i in range(n):
  if i %2:
    B.appendleft(A[i])
  else:
    B.append(A[i])
B = list(B)
if n%2:
  B = B[::-1]
print(*B)

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

B = []

for i in range(n):
  if i %2:
    B = [A[i]] + B
  else:
    B = B + [A[i]]
    
if n%2:
  B = B[::-1]
print(*B)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
from collections import deque

B = deque([])

for i in range(n):
  if i %2:
    B.appendleft(A[i])
  else:
    B.append(A[i])
B = list(B)
if n%2:
  B = B[::-1]
print(*B)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))

col = [0 for _ in range(9)]
for a in A:
  if a >= 3200:
    col[8] += 1
  col[a//400] += 1
print(sum(col[:-1]), sum(col))

Fixed submission:
n = int(input())
ai = list(map(int,input().split()))
aj = list(map(lambda x:int(x/400),ai))
rainbow = 0
for e in aj:
  if e >= 8:
    rainbow += 1
ak= set(aj)
ans = 0
for e in ak:
  if e < 8:
    ans += 1
print(max(1,ans) ,end='')
print(' ' ,end = '')
print(ans+ rainbow)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
graph = {i:[] for i in range(1, n+1)}
for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
for i in range(1, n+1):
  print(len(graphp[i]))

Fixed submission:
n,m = map(int,input().split())
graph = {i:[] for i in range(1, n+1)}
for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
for i in range(1, n+1):
  print(len(graph[i]))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())

if a%2 or b%2 or c%2:
  print(0)
  exit()
elif a==b==c:
  print(-1)
  exit()
  
ans =0
while 1:
  if all(a%2==0, b%2==0, c%2==0):
    ans += 1
  else:
    print(ans)
    exit()
  a, b, c = (b+c)//2, (a+c)//2, (b+a)//2

Fixed submission:
a,b,c = map(int,input().split())

if a%2 or b%2 or c%2:
  print(0)
  exit()
elif a==b==c:
  print(-1)
  exit()
  
ans =0
while 1:
  if all((a%2==0, b%2==0, c%2==0)):
    ans += 1
  else:
    print(ans)
    exit()
  a, b, c = (b+c)//2, (a+c)//2, (b+a)//2
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
graph = {i+1:[] for i in range(n)}
for _ in range(m):
  a,b = map(int,input(),split())
  graph[a].append(b)
  graph[b].append(a)

count = 0
def func(path,p):
  if len(path) == n:
    count += 1
    return
  for i in graph[p]:
    if i in path:
      continue
    func(path+[i],i)
print(count)

Fixed submission:
n,m = map(int,input().split())
graph = {i+1:[] for i in range(n)}
for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)

def func(path,p,count):
  if len(path) == n:
    return count + 1
  for i in graph[p]:
    if i in path:
      continue
    count = func(path+[i],i,count)
  return count
print(func([1],1,0))
Buggy python submission (verdict: Runtime Error):
n = int(input().split())
T = list(map(int,input().split()))
ans = sum(T)
m = int(input())
for i in range(m):
  p, x = map(int,input().split())
  print(ans-T[p-1]+x)
  

Fixed submission:
n = int(input())
T = list(map(int,input().split()))
ans = sum(T)
m = int(input())
for i in range(m):
  p, x = map(int,input().split())
  print(ans-T[p-1]+x)
Buggy python submission (verdict: Runtime Error):
s = input()

while s:
  if len(s) > 6 and s[0:7] == 'dreamer':
    s = s[7:]
    if s != [] and s[0] == 'a':
      s = 'er' + s
    continue
  elif len(s)>5 and s[0:6] == 'eraser':
    s = s[6:]
    continue
  elif len(s) > 4 and s[0:5] in ('dream', 'erase'):
    s = s[5:]
    continue
  else:
    print('NO')
    exit(0)
print('YES')

Fixed submission:
s = input()
dp = [0 for i in range(len(s)+1)]
dp[0] = 1
words = ['eraser', 'erase', 'dreamer', 'dream']

for i in range(len(s)):
  i += 1
  for sent in words:
    before = i - len(sent)
    if before < 0:
      continue
    if dp[before] == 1 and s[before:i] == sent:
      dp[i] = 1
print('YES' if dp[-1] else 'NO')

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

while s:
  if s[0:7] == 'dreamer':
    s = s[7:]
    if s != [] and s[0] == 'a':
      s = 'er' + s
    continue
  elif s[0:6] == 'eraser':
    s = s[6:]
    continue
  elif s[0:5] in ('dream', 'erase'):
    s = s[5:]
    continue
  else:
    print('NO')
    exit(0)
print('YES')

Fixed submission:
s = input()
dp = [0 for i in range(len(s)+1)]
dp[0] = 1
words = ['eraser', 'erase', 'dreamer', 'dream']

for i in range(len(s)):
  i += 1
  for sent in words:
    before = i - len(sent)
    if before < 0:
      continue
    if dp[before] == 1 and s[before:i] == sent:
      dp[i] = 1
print('YES' if dp[-1] else 'NO')

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

while s:
  if s[0:7] == 'dreamer':
    s = s[7:]
    if s[0] == 'a':
      s = 'er' + s
    continue
  elif s[0:6] == 'eraser':
    s = s[6:]
    continue
  elif s[0:5] in ('dream', 'erase'):
    s = s[5:]
    continue
  else:
    print('NO')
    exit(0)
print('YES')

Fixed submission:
s = input()
dp = [0 for i in range(len(s)+1)]
dp[0] = 1
words = ['eraser', 'erase', 'dreamer', 'dream']

for i in range(len(s)):
  i += 1
  for sent in words:
    before = i - len(sent)
    if before < 0:
      continue
    if dp[before] == 1 and s[before:i] == sent:
      dp[i] = 1
print('YES' if dp[-1] else 'NO')
Buggy python submission (verdict: Runtime Error):
n = int(input())
r = 10**7+1
l = 1

def f(n):
  return n**2+n

while r-l>1:
  if f((l+r)//2)>n:
    r = (l+r)//2
  else:
    l = (l+r)//2
l = l+1
rm = (l+1)*l//2-n
ans = list(range(1, l+1))
ans.remove(rm)
for a in ans:
  print(a)

Fixed submission:
n = int(input())
r = 10**7+1
l = 1

def f(n):
  return (n**2+n)//2

while r-l> 1:
  if f((l+r)//2)>n:
    r = (l+r)//2
  else:
    l = (l+r)//2

l = l+1
rm = (l+1)*l//2-n
ans = list(range(1, l+1))
ans.remove(rm)
for a in ans:
  print(a)
Buggy python submission (verdict: Runtime Error):
w,h,n = map(int,input().split())
d = {1:0,2:h,3:0,4:w}
for _ in range(n):
  x,y,a = map(int,input().split())
  if a %2:
    d[a] = max(d[a],[x,y][a//2]) 
  else:
    d[a] = min(d[a],[x,y][a//2])

if d[1] > d[2] or d[3] > d[4]:
  print(0)
else:
  ans = (d[2]-d[1]+1) * (d[4]-d[3]+1)
  print(ans)

Fixed submission:
h,w,n = map(int,input().split())
d = {1:0,2:h,3:0,4:w}
for _ in range(n):
  x,y,a = map(int,input().split())
  if a %2:
    d[a] = max(d[a],[x,y][a//2]) 
  else:
    d[a] = min(d[a],[x,y][a//2-1])

if d[1] > d[2] or d[3] > d[4]:
  print(0)
else:
  ans = (d[2]-d[1]) * (d[4]-d[3])
  print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
cand = []

def func(ac,yet,sum):
  next = int(yet[0])
  
  
  if len(yet) ==1:
    cand.append(sum+ ac+ next)
    cand.append(sum+ ac*10+ next)
  else:
    func(next, yet[1:],ac+sum)
    func(ac*10+next, yet[1:],sum)

func(int(s[0]),s[1:],0)
print(sum(cand))

Fixed submission:
s = input()
n = len(s)
ans = 0

for i in range(2**(n-1)):
  form = s
  bit = []
  for _ in range(n-1):
    bit.append(i%2)
    i =  i//2

  for j in range(n-1):
    if bit[j]:
      form = form[:n-j-1] + '+' + form[n-j-1:]

    
  ans += eval(form)
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
ans = 0

for i in range(2**(n-1)):
  form = s
  bit = []
  for _ in range(n-1):
    bit.append(i%2)
    i =  i//2
  
  for j in range(n):
    if bit[j]:
      form = form[:n-j] + '+' + form[n-j:]
    
  ans += form.eval()
print(ans)

Fixed submission:
s = input()
n = len(s)
ans = 0

for i in range(2**(n-1)):
  form = s
  bit = []
  for _ in range(n-1):
    bit.append(i%2)
    i =  i//2

  for j in range(n-1):
    if bit[j]:
      form = form[:n-j-1] + '+' + form[n-j-1:]

    
  ans += eval(form)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

def f(a,b):
  return (a in s and b not in s) or (b in s and a not in s):
  
if f('W', 'E') or f('N', 'S'):
  print('No')
else:
  print('Yes')

Fixed submission:
s = input()

def f(a,b):
  return (a in s and b not in s) or (b in s and a not in s)
  
if f('W', 'E') or f('N', 'S'):
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

from operator import mul
from functools import reduce

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

N = int(input())
A = list(map(int, input().split()))

total = reduce(mul, A)
if total > 10 ** 18:
    print(-1)
else:
    print(total)


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

total = A[0]
limit = 10 ** 18

for a in A[1:]:
    total *= a
    if total > limit:
        print(-1)
        exit()
print(total)