Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[]
if(lst!=[]):
    for a in lst:
         fl.append(int(a))
else:
    print(X)
for a in range(101):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break


Fixed submission:
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[]
if(N!=0):
    for a in lst:
         fl.append(int(a))
for a in range(101):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break

Buggy python submission (verdict: Runtime Error):
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[]
if(lst!=[]):
    for a in lst:
         fl.append(int(a))
else:
    print(X)
for a in range(len(fl)):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break

Fixed submission:
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[]
if(N!=0):
    for a in lst:
         fl.append(int(a))
for a in range(101):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break

Buggy python submission (verdict: Runtime Error):
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[];
if(lst!=[]):
    for a in lst:
         fl.append(int(a))
else:
    print(X)
for a in range(len(fl)):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break


Fixed submission:
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[]
if(N!=0):
    for a in lst:
         fl.append(int(a))
for a in range(101):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break

Buggy python submission (verdict: Runtime Error):
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[];
for a in lst:
    fl.append(int(a))
for a in range(len(fl)):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break


Fixed submission:
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[]
if(N!=0):
    for a in lst:
         fl.append(int(a))
for a in range(101):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break
Buggy python submission (verdict: Runtime Error):
n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for x in arr:
  d[x] = d.get(x,0)+1

mxN = 10**6 + 1
rp = [True]*mxN


for i in range(2,len(rp)):
  if i not in d or not rp[i]:continue
  for j in range(i+i,mxN,i):
    if j in d: rp[j] = False

#reason for tle



for k,v in d.items():
  if v > 1:rp[k] = False

ans = sum([(1 if rp[x] else 0) for x in cset])
print(ans)





Fixed submission:
n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for x in arr:
  d[x] = d.get(x,0)+1

mxN = 10**6 + 1
rp = [True]*mxN

if 1 in d:
  if d[1] > 1:
    print(0)
    exit()
  else:
    print(1)
    exit()
for i in range(2,len(rp)):
  if i not in d or not rp[i]:continue
  for j in range(i+i,mxN,i):
    if j in d: rp[j] = False

#reason for tle



for k,v in d.items():
  if v > 1:rp[k] = False

ans = sum([(1 if rp[x] else 0) for x in arr])
print(ans)
Buggy python submission (verdict: Runtime Error):
x = input()
print(chr(ord(x)+1)

Fixed submission:
x = input()
y = chr(ord(x) + 1)
print(y)
Buggy python submission (verdict: Runtime Error):
a = []
n = int(input())

for i in range(1,n+1):
  name,score = map(int,input().split())
  a.append([name,-int(score),i])
  
a.sort()
for n,s,idx in a:
  print(idx)
 


Fixed submission:
a = []
n = int(input())

for i in range(1,n+1):
  name,score =input().split()
  a.append([name,-int(score),i])
  
a.sort()
for n,s,idx in a:
  print(idx)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
print(max([a+a -1, b+b-1, a+b])

Fixed submission:
a,b = map(int,input().split())
print(max([a+a-1,b+b-1,a+b]))
Buggy python submission (verdict: Runtime Error):
s = input()
c1 = 1 if s[0] == '0' else 0
a = []
a.append('1')
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c1+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
a = []
c2 = 1 if s[0]=='1' else 0
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c2+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
    
print(min(c1,c2))
  

    
    



Fixed submission:
s = input()
c1 = 1 if s[0] == '0' else 0
a = []
a.append('1')
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c1+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
a = []
a.append('0')
c2 = 1 if s[0]=='1' else 0
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c2+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
    
print(min(c1,c2))
Buggy python submission (verdict: Runtime Error):
from math import gcd

a,b,k = map(int,input().split())

g = gcd(a,b)

cnt = 0
for i in range(g,0,-1):
  if a%i == 0 and b%i == 0:
    # print('i is now ',i)
    cnt+=1
    if cnt == k:
      print(i)
      break


Fixed submission:
# from math import gcd
def gcd(a,b):
    if b == 0:return a
    return gcd(b,a%b)

a,b,k = map(int,input().split())

g = gcd(a,b)

cnt = 0
for i in range(g,0,-1):
  if a%i == 0 and b%i == 0:
    # print('i is now ',i)
    cnt+=1
    if cnt == k:
      print(i)
      break
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
for _ in n:
  m,t = input().split()
  m = float(m)
  if t == 'JPY':ans+=m
  else:ans+= m*380000.0
print(ans)
 


Fixed submission:
n = int(input())
ans = 0
for _ in range(n):
    m,t = input().split()
    m = float(m)
    if t == 'JPY':ans+=m
    else:ans+= m*380000.0
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
n = int(input())
arr = [int(x) for x in input().split()]


ans = arr[0]

for i in range(1,n):
    ans = gcd(ans,arr[i])

print(ans)


Fixed submission:
# from math import gcd
def gcd(a,b):
    if b == 0 :return a
    return gcd(b,a%b)


n = int(input())
arr = [int(x) for x in input().split()]


ans = arr[0]

for i in range(1,n):
    ans = gcd(ans,arr[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
print(sum[:k])

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
print(sum(a[:k]))
Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
a = []
if n != 0 : a = list(map(int,input().split()))
tmp = 114514
ret = -114514
for i in range(-10,110):
  if not i in a and abs(x-i) < tmp
  ret = i
  tmp = abs(x-i)
print(ret)

Fixed submission:
x,n = map(int,input().split())
a = []
if n != 0 : a = list(map(int,input().split()))
tmp = 114514
ret = -114514
for i in range(-10,110):
  if not i in a and abs(x-i) < tmp:
    ret = i
    tmp = abs(x-i)
print(ret)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline
def main():
  n = int(input())
  a = list(map(int,input().split())).sort()
  if a[0] == 0:
    print(0)
    return
  ret = 1
  for i in a:
    ret *= i
    if ret > 10**18:
      print(-1)
      return
  print(ret)
main()

Fixed submission:
from sys import stdin
input = stdin.readline
def main():
  n = int(input())
  a = list(map(int,input().split()))
  a.sort()
  if a[0] == 0:
    print(0)
    return
  ret = 1
  for i in a:
    ret *= i
    if ret > 10**18:
      print(-1)
      return
  print(ret)
main()
Buggy python submission (verdict: Runtime Error):
f = int(input()) / 3.0
print("{.9f}".format(f * f * f))


Fixed submission:
f = int(input()) / 3.0
print("{:.9f}".format(f * f * f))

Buggy python submission (verdict: Runtime Error):
f = int(input()) / 3.0
return(f * f * f)

Fixed submission:
f = int(input()) / 3.0
print("{:.9f}".format(f * f * f))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
d = map(lambda x: (int(x) + 1) / 2, input().split())
ret = sum(d[:k])
tmp = ret
for i in range(k,n):
  tmp = tmp + d[i] - d[i-k]
  ret = max(ret,tmp)
print(ret)

Fixed submission:
n,k = map(int,input().split())
d = list(map(lambda x: (int(x) + 1) / 2, input().split()))
ret = sum(d[:k])
tmp = ret
for i in range(k,n):
  tmp = tmp + d[i] - d[i-k]
  ret = max(ret,tmp)
print(ret)
Buggy python submission (verdict: Runtime Error):
# from math import gcd
from fraction import gcd

n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in a:
    ans = ans * i // gcd(ans, i)
mod = 10**9+7
print(sum(map(lambda x: ans // x, a)) % mod)

Fixed submission:
# from math import gcd
from fractions import gcd

n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in a:
    ans = ans * i // gcd(ans, i)
mod = 10**9+7
print(sum(map(lambda x: ans // x, a)) % mod)
Buggy python submission (verdict: Runtime Error):
s = input()
l = len(s)
ret = 0
for i in range(l): ret += (s[l] != s[-l-1])
print(ret//2)

Fixed submission:
s = input()
l = len(s)
ret = 0
for i in range(l): 
  ret += (s[i] != s[-i-1])
print(ret//2)
Buggy python submission (verdict: Runtime Error):
def main():
  n = int(input())
  i = int(sqrt(n)) + 1
  while i * i > n: i -= 1
  while i >= 1:
    if n % i == 0
      print(i+n//i)
      return
    i -= 1
main()


Fixed submission:
def main():
  n = int(input())
  i = int((n)**0.5) + 1
  while i * i > n: i -= 1
  while i >= 1:
    if n % i == 0:
      print(i+n//i-2)
      return
    i -= 1
main()
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
dp = [2**63]*4096
dp[0] = 0
for i in range(m):
  a,b = map(int,input().split())
  mask = 0
  c = list(map(int,input().split()))
  for i in c:
    mask |= ( 1 << i-1 )
  nxtdp = dp[:]
  for j in range(1 << n):
    if (j | mask) != j: continue
    for k in range(1 << n):
      if j == (k | mask):
        nxtdp[j] = min(nxtdp[j], dp[k] + a)
  dp = nxtdp
print(dp[(1<<n)-1] if dp[(1<<n)-1] < 2**63 else -1)

Fixed submission:
n,m = map(int,input().split())
dp = [2**63]*4096
dp[0] = 0
for i in range(m):
  a,b = map(int,input().split())
  mask = 0
  c = list(map(int,input().split()))
  for i in c:
    mask |= ( 1 << i-1 )
  nxtdp = dp[:]
  for j in range(1 << n):
    if dp[j] < 2 ** 63:
      nxtdp[j | mask] = min(nxtdp[j | mask], dp[j] + a)
  dp = nxtdp
print(dp[(1<<n)-1] if dp[(1<<n)-1] < 2**63 else -1)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
dp = [2**63]*4096
dp[0] = 0
for i in range(m):
  a,b = map(int,input().split())
  mask = 0
  c = list(map(int,input().split()))
  for i in c:
    mask |= ( 1 << i-1 )
  nxtdp = dp[:]
  for j in range(1 << n):
    if (j | mask) != j: continue
    for k in range(1 << n):
      if j == (k | mask):
        nxtdp[j] = min(nxtdp[j], dp[k] + a)
  dp = nxtdp
print(dp[(1<<n)-1] if dp[(1<<n)-1] < 2**63 else -1)

Fixed submission:
n,m = map(int,input().split())
dp = [2**63]*4096
dp[0] = 0
for i in range(m):
  a,b = map(int,input().split())
  mask = 0
  c = list(map(int,input().split()))
  for i in c:
    mask |= ( 1 << i-1 )
  nxtdp = dp[:]
  for j in range(1 << n):
    if dp[j] < 2 ** 63:
      nxtdp[j | mask] = min(nxtdp[j | mask], dp[j] + a)
  dp = nxtdp
print(dp[(1<<n)-1] if dp[(1<<n)-1] < 2**63 else -1)
Buggy python submission (verdict: Runtime Error):
d = {"A":"T", "T":"A", "G":"C", "C","G"}
print(d[input()])

Fixed submission:
d = {"A":"T", "T":"A", "G":"C", "C":"G"}
print(d[input()])
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
a = sort(a)
print(a[0]*a[1]//2)

Fixed submission:
a = list(map(int,input().split()))
a = sorted(a)
print(a[0]*a[1]//2)
Buggy python submission (verdict: Runtime Error):
s = input()
flag = True
flag = flag and s[0] == 'A'
Ccount = 0
for i in range(1,len(s)):
  if ord('a') <= ord(s[i]) and ord(s[i]) <= 'z': continue
  if s[i] == 'C' and 2 <= i and i <= len(s)-2:
    Ccount += 1
  else:
    flag = False
print("AC" if flag and Ccount == 1 else "WA")

Fixed submission:
s = input()
flag = True
flag = flag and s[0] == 'A'
Ccount = 0
for i in range(1,len(s)):
  if ord('a') <= ord(s[i]) and ord(s[i]) <= ord('z'): continue
  if s[i] == 'C' and 2 <= i and i <= len(s)-2:
    Ccount += 1
  else:
    flag = False
print("AC" if flag and Ccount == 1 else "WA")
Buggy python submission (verdict: Runtime Error):
n = input()
l = list(map(int,input().split()))
print(sum(l)-n)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
print(sum(l)-n)

Buggy python submission (verdict: Runtime Error):
n = input()
l = list(map,input().split())
print(sum(l)-n)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
print(sum(l)-n)
Buggy python submission (verdict: Runtime Error):
x = int(input())
ret = 0
for b in range(1,int(sqrt(x))+2):
    for p in range(2,10):
        if b**p <= x and ret < b**p: ret = b**p
print(ret)

Fixed submission:
x = int(input())
ret = 0
for b in range(1,int(x**0.5)+2):
    for p in range(2,11):
        if b**p <= x and ret < b**p: ret = b**p
print(ret)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
m = [map((lambda x: 0 if x == '#' else 1),list(input())) for i in range(h)]
white = sum(list(map(sum,m)))

q = [[0,0,0]]
m[0][0] = 0
while len(q)!=0:
    qtop = pop(0)
    x = qtop[0]
    y = qtop[1]
    d = qtop[2]
    if x == h-1 and y == w-1:
        print(ret-d)
        break
    if 0 < x and m[x-1][y] == 1:
        m[x-1][y] = 0
        q.append([x-1,y,d+1])
    if h-1 > x and m[x+1][y] == 1:
        m[x+1][y] = 0
        q.append([x+1,y,d+1])
    if 0 < y and m[x][y-1] == 1:
        m[x][y-1] = 0
        q.append([x,y-1,d+1])
    if w-1 > y and m[x][y+1] == 1:
        m[x][y+1] = 0
        q.append([x,y+1,d+1])
else:
    print(-1)

Fixed submission:
h,w = map(int,input().split())
m = [list(map((lambda x: 0 if x == '#' else 1),list(input()))) for i in range(h)]
ret = sum(list(map(sum,m)))

q = [[0,0,0]]
m[0][0] = 0
while len(q)!=0:
    qtop = q.pop(0)
    x = qtop[0]
    y = qtop[1]
    d = qtop[2]
    if x == h-1 and y == w-1:
        print(ret-d-1)
        break
    if 0 < x and m[x-1][y] == 1:
        m[x-1][y] = 0
        q.append([x-1,y,d+1])
    if h-1 > x and m[x+1][y] == 1:
        m[x+1][y] = 0
        q.append([x+1,y,d+1])
    if 0 < y and m[x][y-1] == 1:
        m[x][y-1] = 0
        q.append([x,y-1,d+1])
    if w-1 > y and m[x][y+1] == 1:
        m[x][y+1] = 0
        q.append([x,y+1,d+1])
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
from math import ceil
n,h = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i] , b[i] = map(int,input().split())
bs = list(sorted(b,reverse=True))
ma = max(a)
ret = 0
while ret < n:
    if bs[0] => ma:
        h -= bs[0]
        bs.pop(0)
        ret += 1
        if h <= 0 : break
    else:
        break

if h > 0: ret += ceil(h/ma)
print(ret)


Fixed submission:
from math import ceil
n,h = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i] , b[i] = map(int,input().split())
bs = list(sorted(b,reverse=True))
ma = max(a)
ret = 0
while ret < n:
    if bs[0] > ma:
        h -= bs[0]
        bs.pop(0)
        ret += 1
        if h <= 0 : break
    else:
        break

if h > 0: ret += ceil(h/ma)
print(ret)
Buggy python submission (verdict: Runtime Error):
s = input()
l = len(s)
limit = [max(i+1,l-i-1) for i in range(l-1) if s[i] != s[i+1]]
print(min(limit))


Fixed submission:
s = input()
l = len(s)
limit = [max(i+1,l-i-1) for i in range(l-1) if s[i] != s[i+1]]
limit.append(l)
print(min(limit))
Buggy python submission (verdict: Runtime Error):
luca = [2,1]
for i in range(2,86):
    luca.append(luca[i-2] + luca[i-1])
print(luca[int(input())])

Fixed submission:
luca = [2,1]
for i in range(2,100):
    luca.append(luca[i-2] + luca[i-1])
print(luca[int(input())])

Buggy python submission (verdict: Time Limit Exceeded):
def luca(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return luca(n-1) + luca(n-2)

print(luca(int(input())))

Fixed submission:
luca = [2,1]
for i in range(2,100):
    luca.append(luca[i-2] + luca[i-1])
print(luca[int(input())])
Buggy python submission (verdict: Runtime Error):
n = int(input())
k = (int(input()))
a = [(1<<x)+k*(n-x) for x in range(1,n)]
print(min(a))


Fixed submission:
n = int(input())
k = (int(input()))
a = [(1<<x)+k*(n-x) for x in range(n+1)]
print(min(a))
Buggy python submission (verdict: Runtime Error):
def main():
    s = list(input())
    wox = [i for i in s if i != "x"]
    wowr = list(reversed(wox))
    for i in range(len(wox)//2+1):
        if wox[i] != wowr[i]:
            return -1
    sr = list(reversed(s))
    si = ri = 0
    ret = 0
    while si < len(s) and ri < len(sr):
        if s[si] == sr[ri]:
            si += 1
            ri += 1
        elif s[si] == "x":
            si += 1
            ret += 1
        else:
            ri += 1
            ret += 1
    return (ret + len(s) - min(si,ri))//2
print(main())


Fixed submission:
def main():
    s = list(input())
    wox = [i for i in s if i != "x"]
    if len(wox) == 0: return 0
    wowr = list(reversed(wox))
    for i in range(len(wox)//2+1):
        if wox[i] != wowr[i]:
            return -1
    sr = list(reversed(s))
    si = ri = 0
    ret = 0
    while si < len(s) and ri < len(sr):
        if s[si] == sr[ri]:
            si += 1
            ri += 1
        elif s[si] == "x":
            si += 1
            ret += 1
        else:
            ri += 1
            ret += 1
    return (ret + len(s) - min(si,ri))//2
print(main())
Buggy python submission (verdict: Runtime Error):
l,k = map(int,input().split())
print(sum(sorted(map(int,input().split())[:k]))

Fixed submission:
n,k = map(int,input().split())
print(sum(sorted(map(int,input().split()))[n-k:]))
Buggy python submission (verdict: Runtime Error):
k,s = int(input().split())
ret = 0
for i in range(k+1):
    bmax = min(k,bpc)+1
    bmin = max(0,s-i-k)
    if bmin < bmax : ret += bmax - bmin
print(ret)

Fixed submission:
k,s = map(int,input().split())
ret = 0
for i in range(k+1):
    bmax = min(k,s-i)+1
    bmin = max(0,s-i-k)
    if bmin < bmax : ret += bmax - bmin
print(ret)
Buggy python submission (verdict: Runtime Error):
n = int(input())
k = list(map(int,input().split()))
r = 0
for i in range(n):
  if k[k[i]] == i: r += 1
print(r//2)

Fixed submission:
n = int(input())
k = list(map(int,input().split()))
r = 0
for i in range(n):
  if k[k[i]-1] == i+1: r += 1
print(r//2)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
s=7
x=10000000
for i in range(x):
    if(s%k==0):
        print(i+1)
        break
    s=s*10+7
if(s%k!=0):
    print("-1")
    


Fixed submission:
k=int(input())
s=7
x=10000000
for i in range(x):
    if(s%k==0):
        print(i+1)
        break
    s=(s%k)*10+7
if(s%k!=0):
    print("-1")

Buggy python submission (verdict: Time Limit Exceeded):
k=input()
r=int(k)
s=7
j=0
l=len(k)-1
if(r%2==0):
  print("-1")
elif(k[l]=='1' or k[l]=='3' or k[l]=='7' or k[l]=='9'):
    while(1):
        j=j+1
        if(s%r==0):
            break
        s=s*10+7
    print(j)
else:
    print("-1")

Fixed submission:
k=int(input())
s=7
x=10000000
for i in range(x):
    if(s%k==0):
        print(i+1)
        break
    s=(s%k)*10+7
if(s%k!=0):
    print("-1")

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
s=7
j=0
if(k%2==0):
  print("-1")
else:
    while(1):
        j=j+1
        if(s%k==0):
            break
        s=s*10+7
    print(j)
    

Fixed submission:
k=int(input())
s=7
x=10000000
for i in range(x):
    if(s%k==0):
        print(i+1)
        break
    s=(s%k)*10+7
if(s%k!=0):
    print("-1")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = map(int, input().split(' '))

ans = 1

for i in a:
	ans = ans * i
	
if ans > 1000000000000000000:
	print(-1)
else:
	print(ans)


Fixed submission:

n = int(input())
v = list(map(int, input().split(' ')))

ans = 1

if 0 in v:
	print(0)
	exit(0)

for item in v:
	ans = ans * item
	if ans > 1000000000000000000:
		print(-1)
		exit(0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
if k==1 or n%k==0:
    ans=0
else:
    if n/2<k:
        x=abs(n-k)
        y=abs(x-k)
        ans=min(n,min(x,y))
    else:
        while 1:
            x=abs(n-k)
            y=abs(x-k)
            n=min(n,min(x,y))
            if n<k:
                x=abs(n-k)
                y=abs(x-k)
                ans=min(n,min(x,y))
                break
print(ans)


Fixed submission:
n,k=map(int,input().split())
if k==1 or n%k==0:
    ans=0
else:
    if n/2<k:
        x=abs(n-k)
        y=abs(x-k)
        ans=min(n,min(x,y))
    else:
        x=n%k
        y=abs(x-k)
        ans=min(x,y)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
if k==1 or n%k==0:
    ans=0
else:
    tp=-1
    while 1:
        x=abs(n-k)
        if tp==x:
            break
        tp=x
        y=abs(x-k)
        n=min(n,min(x,y))
    ans=min(n,min(x,y))
print(ans)


Fixed submission:
n,k=map(int,input().split())
if k==1 or n%k==0:
    ans=0
else:
    if n/2<k:
        x=abs(n-k)
        y=abs(x-k)
        ans=min(n,min(x,y))
    else:
        x=n%k
        y=abs(x-k)
        ans=min(x,y)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
s=[]
x=[]
for i in range(a):
    s.append('b')
for i in range(b):
    s.append('r')
for i in range(10**100):
    x.append(s)

x=list(x)
ans=0
for i in range(n):
    if x[i]=='b':
        ans+=1
print(ans)


Fixed submission:
n,a,b=map(int,input().split())
c=a+b
if n<=c:
    if n<=a:
        ans=n
    else:
        ans=a
else:
    x=n//c
    y=x*a
    z=x*c
    t=n-z
    if t<=a:
        ans=y+t
    else:
        ans=y+a
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
q=int(input())
for i in range(q):
    x=list(input())
    if len(x)==1:
        s=list(reversed(s))
    else:
        if x[2]=='1':
            s.insert(0,x[4])
        else:
            s.append(x[4])
print(''.join(s))


Fixed submission:
import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines
from collections import deque

S=deque(readline().rstrip().decode())
Q=int(readline())
query=readlines()

flag=False
for q in query:
    if q[0]==ord('1'):
        flag= not flag
    else:
        _,f,c=q.decode().split()
        f=int(f)
        if flag^(f==1):
            S.appendleft(c)
        else:
            S.append(c)
ans=''.join(S)
if flag:
    ans=ans[::-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
q=int(input())
for i in range(q):
    x=list(input())
    if len(x)==1:
        s=list(reversed(s))
    else:
        if x[2]=='1':
            s.insert(0,x[4])
        else:
            s.append(x[4])
print(''.join(s))


Fixed submission:
import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines
from collections import deque

S=deque(readline().rstrip().decode())
Q=int(readline())
query=readlines()

flag=False
for q in query:
    if q[0]==ord('1'):
        flag= not flag
    else:
        _,f,c=q.decode().split()
        f=int(f)
        if flag^(f==1):
            S.appendleft(c)
        else:
            S.append(c)
ans=''.join(S)
if flag:
    ans=ans[::-1]
print(ans)