Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
    from bisect import bisect
    n,k=map(int,input().split())
    x=list(map(int,input().split()))
    g=bisect(x,0)
    if x[n-1]<=0 or x[0]>=0:
        print(max(abs(x[k-1]),abs(x[0])))
    else:
        if g>=k:
            s=g-k
        else:
            s=0
        t=0
        while s<=n-k:
            if x[s]<0 and x[s+k-1]>0:
                if t==0:
                    t=min(2*abs(x[s])+x[s+k-1],abs(x[s])+2*x[s+k-1])
                else:
                    t=min(t,2*abs(x[s])+x[s+k-1],abs(x[s])+2*x[s+k-1])
            else:
                t=min(t,max(abs(x[s]),abs(x[s+k-1])))
            s+=1
        print(t)

Fixed submission:
def resolve():
    from bisect import bisect
    n,k=map(int,input().split())
    x=list(map(int,input().split()))
    g=bisect(x,0)
    if x[n-1]<=0:
        print(abs(x[n-k]))
    elif x[0]>=0:
        print(x[k-1])
    else:
        if g>=k:
            s=g-k
        else:
            s=0
        t=0
        while s<=n-k:
            if x[s]<0 and x[s+k-1]>0:
                if t==0:
                    t=min(2*abs(x[s])+x[s+k-1],abs(x[s])+2*x[s+k-1])
                else:
                    t=min(t,2*abs(x[s])+x[s+k-1],abs(x[s])+2*x[s+k-1])
            else:
                t=min(t,max(abs(x[s]),abs(x[s+k-1])))
            s+=1
        print(t)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
k=int(input())
ans=set()
for i in range(n):
    for j in range(i+1,n+1):
        ans.add(s[i:j])
ans=sorted(list(ans))
print(ans[k-1])

Fixed submission:
s=input()
n=len(s)
k=int(input())
ans=set()
for i in range(n):
    for j in range(i+1,min(i+k+1,n+1)):
        ans.add(s[i:j])
ans=sorted(list(ans))
print(ans[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w=map(int,input().split())
s=[input() for _ in range(h)]
d=[[1,0],[-1,0],[0,1],[0,-1]]
bcnt=0
for i in range(h):
    bcnt+=s[i].count('#')
dist=[[1000]*w for _ in range(h)]
chk=[[0]*w for _ in range(h)]
r=deque()
r.append([0,0])
dist[0][0]=0
while r:
    x,y=r.popleft()
    chk[y][x]=1
    for dx,dy in d:
        nx=x+dx
        ny=y+dy
        nd=dist[y][x]
        if nx>=0 and nx<=w-1 and ny>=0 and ny<=h-1:
            if chk[ny][nx]==1 or s[ny][nx]=='#':
                continue
            dist[ny][nx]=min(dist[ny][nx],nd+1)
            r.append([nx,ny])
if dist[h-1][w-1]==1000:
    print(-1)
else:
    print(h*w-dist[h-1][w-1]-1-bcnt)

Fixed submission:
from collections import deque
h,w=map(int,input().split())
s=[input() for _ in range(h)]
d=[[1,0],[-1,0],[0,1],[0,-1]]
bcnt=0
for i in range(h):
    bcnt+=s[i].count('#')
dist=[[-1]*w for _ in range(h)]
r=deque()
r.append([0,0])
dist[0][0]=0
while r:
    x,y=r.popleft()
    for dx,dy in d:
        nx=x+dx
        ny=y+dy
        nd=dist[y][x]
        if nx>=0 and nx<=w-1 and ny>=0 and ny<=h-1:
            if dist[ny][nx]>-1 or s[ny][nx]=='#':
                continue
            dist[ny][nx]=nd+1
            r.append([nx,ny])
if dist[h-1][w-1]==-1:
    print(-1)
else:
    print(h*w-dist[h-1][w-1]-1-bcnt)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n=int(input())
e=[[] for _ in range(n+1)]
l=[[0]*(n+1) for _ in range(n+1)]
dist=[-1]*(n+1)
for i in range(n-1):
    a,b,c=map(int,input().split())
    e[a].append(b)
    e[b].append(a)
    l[a][b]=c
    l[b][a]=c
q,k=map(int,input().split())
a=deque()
a.append((k,0))
while a:
    x,d=a.popleft()
    dist[x]=d
    for j in e[x]:
        if dist[j]!=-1:
            continue
        else:
            a.append((j,d+l[x][j]))
ans=[]
for i in range(q):
    x,y=map(int,input().split())
    ans.append(dist[x]+dist[y])
print(*ans,sep="\n")

Fixed submission:
from collections import deque
n=int(input())
e=[[] for _ in range(n+1)]
dist=[-1]*(n+1)
for i in range(n-1):
    a,b,c=map(int,input().split())
    e[a].append((b,c))
    e[b].append((a,c))
q,k=map(int,input().split())
a=deque()
a.append((k,0))
while a:
    x,d=a.popleft()
    dist[x]=d
    for j,nc in e[x]:
        if dist[j]!=-1:
            continue
        else:
            a.append((j,d+nc))
ans=[]
for i in range(q):
    x,y=map(int,input().split())
    ans.append(dist[x]+dist[y])
print(*ans,sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n=int(input())
e=[[] for _ in range(n+1)]
l=[[0]*(n+1) for _ in range(n+1)]
dist=[-1]*(n+1)
for i in range(n-1):
    a,b,c=map(int,input().split())
    e[a].append(b)
    e[b].append(a)
    l[a][b]=c
    l[b][a]=c
q,k=map(int,input().split())
a=deque()
a.append((k,0))
while a:
    x,d=a.popleft()
    dist[x]=d
    for j in e[x]:
        if dist[j]!=-1:
            continue
        else:
            a.append((j,d+l[x][j]))
ans=[]
for i in range(q):
    x,y=map(int,input().split())
    ans.append(dist[x]+dist[y])
print(*ans,sep="\n")

Fixed submission:
from collections import deque
n=int(input())
e=[[] for _ in range(n+1)]
dist=[-1]*(n+1)
for i in range(n-1):
    a,b,c=map(int,input().split())
    e[a].append((b,c))
    e[b].append((a,c))
q,k=map(int,input().split())
a=deque()
a.append((k,0))
while a:
    x,d=a.popleft()
    dist[x]=d
    for j,nc in e[x]:
        if dist[j]!=-1:
            continue
        else:
            a.append((j,d+nc))
ans=[]
for i in range(q):
    x,y=map(int,input().split())
    ans.append(dist[x]+dist[y])
print(*ans,sep="\n")
Buggy python submission (verdict: Runtime Error):
X = int(input())

if 400 <= X < 600:
    result = 8
elif X < 800:
    result = 7
elif X < 1000:
    result = 6
elif X < 1200:
    result = 5
elif X < 1400:
    result = 4
elif X < 1600:
    result = 3
elif X < 1800:
    result = 2
elif X < 200:
    result = 1

print(result)


Fixed submission:
X = int(input())
 
if 400 <= X < 600:
    result = 8
elif X < 800:
    result = 7
elif X < 1000:
    result = 6
elif X < 1200:
    result = 5
elif X < 1400:
    result = 4
elif X < 1600:
    result = 3
elif X < 1800:
    result = 2
elif X < 2000:
    result = 1
 
print(result)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
print((set(range(1, 3 + 1)) - {A, B})[0])

Fixed submission:
A = int(input())
B = int(input())
print(list(set(range(1, 3 + 1)) - {A, B})[0])
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max(A - 2 * B), 0)

Fixed submission:
A, B = map(int, input().split())
print(max(A - 2 * B, 0))
Buggy python submission (verdict: Runtime Error):
import numpy as np

A, B = map(int, input().split())
gcd = np.gcd(A, B)
result = 1
d = 2
while d * d <= gcd:
    e = 0
    while gcd % d == 0:
        gcd //= d
        e += 1
    if e > 0:
        result += 1
    d += 1
if gcd > 1:
    result += 1
print(result)

Fixed submission:
def gcd(x, y):
    while y != 0:
        r = x % y
        x = y
        y = r
    return x

A, B = map(int, input().split())
gcd = gcd(A, B)
result = 1
d = 2
while d * d <= gcd:
    e = 0
    while gcd % d == 0:
        gcd //= d
        e += 1
    if e > 0:
        result += 1
    d += 1
if gcd > 1:
    result += 1
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

a = np.argsort(P)
left = [i for i in range(N)]
right = [i for i in range(N)]
result = 0
for i in range(1, N):
    k = a[i - 1]
    extend_left = k - 1 >= 0 and P[k - 1] < i
    extend_right = k + 1 < N and P[k + 1] < i
    if extend_left and extend_right:
        L = left[k - 1]
        R = right[k + 1]
    elif extend_left:
        L = left[k - 1]
        R = k
    elif extend_right:
        R = right[k + 1]
        L = k
    else:
        L = k
        R = k
    right[L] = R
    left[R] = L
    if L - 1 >= 0:
        if L - 2 >= 0 and P[L - 2] < i:
            LL = left[L - 2]
        else:
            LL = L - 1
        result += ((L - 1) - LL + 1) * (R - k + 1) * i;
    if R + 1 < N:
        if R + 2 < N and P[R + 2] < i:
            RR = right[R + 2]
        else:
            RR = R + 1
        result += (RR - (R + 1) + 1) * (k - L + 1) * i;
print(result)

Fixed submission:
def argsort(a):
    return list(map(lambda z: z[1], sorted(zip(a, range(len(a))))))

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

a = argsort(P)
left = [i for i in range(N)]
right = [i for i in range(N)]
result = 0
for i in range(1, N):
    k = a[i - 1]
    extend_left = k - 1 >= 0 and P[k - 1] < i
    extend_right = k + 1 < N and P[k + 1] < i
    if extend_left and extend_right:
        L = left[k - 1]
        R = right[k + 1]
    elif extend_left:
        L = left[k - 1]
        R = k
    elif extend_right:
        R = right[k + 1]
        L = k
    else:
        L = k
        R = k
    right[L] = R
    left[R] = L
    if L - 1 >= 0:
        if L - 2 >= 0 and P[L - 2] < i:
            LL = left[L - 2]
        else:
            LL = L - 1
        result += ((L - 1) - LL + 1) * (R - k + 1) * i;
    if R + 1 < N:
        if R + 2 < N and P[R + 2] < i:
            RR = right[R + 2]
        else:
            RR = R + 1
        result += (RR - (R + 1) + 1) * (k - L + 1) * i;
print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [input() for i in range(N)]

count_AB = [s[i].count("AB") for i in range(N)]

headB = 0
tailA = 0
headB_and_tailA = 0
for i in range(N):
    #print("i =", i)
    if s[i][0] == 'B':
        if s[i][-1] != 'A':
            #print("headB")
            headB += 1
        else:
            headB_and_tailA += 1
            #print("both")
    elif s[i][-1] == 'A':
        tailA += 1
        #print("tailA")

"""
print("both =", headB_and_tailA)
print("headB = ", headB)
print("tailA = ", tailA)
"""
result = sum(count_AB) + min(headB, tailA)
headB -= min(headB, tailA)
tailA -= min(headB, tailA)
for _ in range(headB_and_tailA):
    if tailA > 0:
        result += 1
    elif tailB > 0:
        result += 1
    else:
        tailA += 1
#print("sum = ", sum(count_AB))
    
print(result)


Fixed submission:
N = int(input())
s = [input() for i in range(N)]

count_AB = [s[i].count("AB") for i in range(N)]

headB = 0
tailA = 0
headB_and_tailA = 0
for i in range(N):
    #print("i =", i)
    if s[i][0] == 'B':
        if s[i][-1] != 'A':
            #print("headB")
            headB += 1
        else:
            headB_and_tailA += 1
            #print("both")
    elif s[i][-1] == 'A':
        tailA += 1
        #print("tailA")

"""
print("both =", headB_and_tailA)
print("headB = ", headB)
print("tailA = ", tailA)
"""
result = sum(count_AB) + min(headB, tailA)
headB -= min(headB, tailA)
tailA -= min(headB, tailA)
for _ in range(headB_and_tailA):
    if tailA > 0:
        result += 1
    elif headB > 0:
        result += 1
    else:
        tailA += 1
#print("sum = ", sum(count_AB))
    
print(result)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
if A > B:
    result = A + (A - 1)
elif A < B:
    reuslt = B + (B - 1)
else:
    result = A + B
print(result)

Fixed submission:
A, B = map(int, input().split())
if A > B:
    result = A + (A - 1)
elif A < B:
    result = B + (B - 1)
else:
    result = A + B
print(result)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))
d = math.gcd(A[0], A[1])
for i in range(2, N):
    d = math.gcd(d, A[i])
print(d)

Fixed submission:
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a

N = int(input())
A = list(map(int, input().split()))
d = gcd(A[0], A[1])
for i in range(2, N):
    d = gcd(d, A[i])
print(d)

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

N = int(input())
A = list(map(int, input().split()))
d = gcd(A[0], A[1])
for i in range(2, N):
    d = gcd(d, A[i])
print(d)

Fixed submission:
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a

N = int(input())
A = list(map(int, input().split()))
d = gcd(A[0], A[1])
for i in range(2, N):
    d = gcd(d, A[i])
print(d)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
print(f"{N % K != 0:d}")

Fixed submission:
N, K = map(int, input().split())
print(0 if N % K == 0 else 1)
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
def solve():
    if A + B - 1 <= N and N <= A * B:
        s = []
        q = (N - B) // (A - 1)
        r = (N - B) % (A - 1)
        if r == 0:
            q -= 1
            r = A - 1
        for i in range(B - q - 1):
            s.append(N - i)
        for i in range(r + 1):
            s.append(A * q + 1 + i)
        for i in range(q - 1, -1, -1):
            for j in range(A):
                s.append(A * i + j + 1)
        return " ".join(map(str, s))
    else:
        return "-1"
print(solve())

Fixed submission:
N, A, B = map(int, input().split())
def solve():
    if A + B - 1 <= N and N <= A * B:
        if A == 1:
            return [i for i in range(N, 0, -1)]
        s = []
        q = (N - B) // (A - 1)
        r = (N - B) % (A - 1)
        if r == 0:
            q -= 1
            r = A - 1
        for i in range(B - q - 1):
            s.append(N - i)
        for i in range(r + 1):
            s.append(A * q + 1 + i)
        for i in range(q - 1, -1, -1):
            for j in range(A):
                s.append(A * i + j + 1)
        return s
    else:
        return [-1]
print(" ".join(map(str, solve())))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
print(*a[-1::-2],*a[n%2::2])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
print(*a[-1::-2]+a[n%2::2])
Buggy python submission (verdict: Time Limit Exceeded):
# O(EV)
def bellman_ford(s):
    d = [0]*n # 各頂点への最小コスト
    d[s] = 0 # 自身への距離は0
    x=s
    for tt in range(k):
        update = False # 更新が行われたか
        aa,bb,cc=g[x][0],g[x][1],g[x][2]
        if d[bb] < d[aa] + cc:
                d[bb] = d[aa] + cc
                update = True
            
        if not update:
            break

        x=bb
    return d

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

g=[]
p=list(map(int,input().split()))
c=list(map(int,input().split()))

if max(c)<0:
    print(max(c))
    exit()

for i in range(n):
    g.append((i,p[i]-1,c[p[i]-1]))

ans=0

for i in range(n):
  ans=max(ans,max(bellman_ford(i)))

print(ans)

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

ans=float('inf')*-1

for i in range(n):
    visited=[i]
    pin=0
    now=i
    for j in range(k):
        now=p[now]-1
        pin+=c[now]
        ans=max(ans,pin)
        visited+=[now]

        if visited[0]==visited[-1]:
            if pin>0:
                pin*=(k//(len(visited)-1)-1)
                ans=max(ans,pin)

                for s in range(k%(len(visited)-1)+len(visited)-1):
                    now=p[now]-1
                    pin+=c[now]
                    ans=max(ans,pin)

                break

            else:
                break

print(ans)
Buggy python submission (verdict: Runtime Error):
R,C,k=map(int,input().split())
h=[]
w=[]
v=[]

for i in range(k):
  ss,tt,uu=map(int,input().split())
  h.append(ss-1)
  w.append(tt-1)
  v.append(uu)
  
dp=[[[0]*(C+1) for i in range(R+1)] for _ in range(k+1)]

for i in range(k):
  for s in range(R+1):
    cnt=0
    for t in range(C+1):
      if h[i]>s or w[i]>t:
        dp[i+1][s][t]=dp[i][s][t]

      else:
        s==h[i] and t==w[i]:
          

      if dp[i+1][s][t]!=dp[i+1][s][t-1]:
        cnt+=1

print(dp[-1][-1][-1])

Fixed submission:
r,c,k=map(int,input().split())
lst=[[0]*(c+1) for i in range(r+1)]
for i in range(k):
  s,t,u=map(int,input().split())
  lst[s][t]=u


dp1=[[0]*(c+1) for i in range(r+1)]
dp2=[[0]*(c+1) for i in range(r+1)]
dp3=[[0]*(c+1) for i in range(r+1)]

for i in range(1,r+1):
  for j in range(1,c+1):
    dp1[i][j]=max(dp1[i][j-1],dp1[i-1][j]+lst[i][j],dp2[i-1][j]+lst[i][j],dp3[i-1][j]+lst[i][j])
    dp2[i][j]=max(dp2[i][j-1],dp1[i][j-1]+lst[i][j])
    dp3[i][j]=max(dp3[i][j-1],dp2[i][j-1]+lst[i][j])

print(max(dp1[-1][-1],dp2[-1][-1],dp3[-1][-1],0))
Buggy python submission (verdict: Runtime Error):
k=int(input())
if k%2==0:
  print(-1)
  exit()
  
ans=1
pin=7
mod=k

for i in range(1000000):
  if pin%k==0:
    print(ans)
    exit()
    
  cnt+=1
  pin*=10
  pin+=7
  pin%=mod
  

print('-1')
  


Fixed submission:
k=int(input())
ans='-1'
a=7
for i in range(1,10**6+1):
  if a%k==0:
    ans=i
    break

  a=((10*a)+7)%k
    
print(ans)

Buggy python submission (verdict: Runtime Error):
k=int(input())
if k%2==0:
  print(-1)
  exit()
  
ans=1
pin=7
mod=k

for i in range(1000000):
  if pin%k==0:
    print(ans)
    exit()
    
  cnt+=1
  pin*=10
  pin+=7
  

print('-1')
  

Fixed submission:
k=int(input())
ans='-1'
a=7
for i in range(1,10**6+1):
  if a%k==0:
    ans=i
    break

  a=((10*a)+7)%k
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
x=[]
y=[]

for i in range(n):
  if s[i]=='R':
    x+=[i]
  elif s[i]=='W':
    y+=[i]
    
ans=0

while True:
    if len(y)==0:
      print(ans)
      break
    elif x[-1]>y[0]:
      x.pop()
      y.pop(0)
      ans+=1
      continue
    
    else:
      print(ans)
      break

Fixed submission:
n=int(input())
s=list(input())
x=[]
y=[]

for i in range(n):
  if s[i]=='R':
    x+=[i]
  elif s[i]=='W':
    y+=[i]
    
ans=0


while True:
    if len(y)==0:
      print(ans)
      break
    elif len(x)==0:
      print(ans)
      break
    elif x[-1]>y[0]:
      x.pop()
      y.pop(0)
      ans+=1
      continue
    
    else:
      print(ans)
      break

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
x=[]
y=[]

for i in range(n):
  if s[i]=='R':
    x+=[i]
  elif s[i]=='W':
    y+=[i]
    
ans=0
if y==[]:
  print(ans)
else:
  while True:
    if x[-1]>y[0]:
      x.pop()
      y.pop(0)
      ans+=1
      continue
    
    else:
      print(ans)
      break

Fixed submission:
n=int(input())
s=list(input())
x=[]
y=[]

for i in range(n):
  if s[i]=='R':
    x+=[i]
  elif s[i]=='W':
    y+=[i]
    
ans=0


while True:
    if len(y)==0:
      print(ans)
      break
    elif len(x)==0:
      print(ans)
      break
    elif x[-1]>y[0]:
      x.pop()
      y.pop(0)
      ans+=1
      continue
    
    else:
      print(ans)
      break
Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
  if sum(a[:i+1])>k:
    break
  elif sum(a[:i+1])+sum(b)<=k:
      ans=max(ans,i+m+1)
  else:  
    for j in range(m):
      if sum(a[:i+1])+sum(b[:j+1])<=k:
        continue
      else:
        ans=max(ans,i+j+1)
        break
print(ans)

Fixed submission:
import itertools
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]+list(map(int,input().split()))
a=list(itertools.accumulate(a))
b=list(itertools.accumulate(b))
ans=0
for i in range(m+1):
  x=k-b[i]
  y=bisect.bisect_right(a,x)
  z=i+y
  if x<0:
      z=0
  ans=max(ans,z)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
  if sum(a[:i+1])>k:
    break
  elif sum(a[:i+1])+sum(b)<=k:
      ans=max(ans,i+m+1)
  for j in range(m):
    if sum(a[:i+1])+sum(b[:j+1])<=k:
      continue
    else:
      ans=max(ans,i+j+1)
      break
print(ans)

Fixed submission:
import itertools
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]+list(map(int,input().split()))
a=list(itertools.accumulate(a))
b=list(itertools.accumulate(b))
ans=0
for i in range(m+1):
  x=k-b[i]
  y=bisect.bisect_right(a,x)
  z=i+y
  if x<0:
      z=0
  ans=max(ans,z)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(n):
  j=n//i
  ans+=j*(j+1)//2
print(ans)

Fixed submission:
n=int(input())
ans=0
for i in range(1,n+1):
  j=n//i
  ans+=i*j*(j+1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
a=int(input())

Fixed submission:
s=input()
if s==s.upper():
  print('A')
else:
  print('a')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
q=int(input())
for i in range(q):
  s,t=list(map(int,input().split()))
  a=[t if j==s else j for j in a]
  print(sum(a))

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

cnt=[0]*(10**5+1)

for i in a:
  cnt[i]+=1

xxx=sum(a)

q=int(input())

for i in range(q):
  l,r=map(int,input().split())
  pin=cnt[l]
  cnt[r]+=pin
  cnt[l]=0

  xxx+=(r-l)*pin

  print(xxx)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
s=a[0]
for i in a[1:]:
  s^=i
  
ans=''

for i in a:
  x=s^i
  ans+=str(x)
  ans+=' '

print(ans[:-1])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=a[0]
for i in a[1:]:
  s^=i
  
ans=''

for i in a:
  x=s^i
  ans+=str(x)
  ans+=' '

print(ans[:-1])
Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  print(x)
else:
  ans=0
  for i in range(101):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
print(ans)


Fixed submission:
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  ans=x
else:
  ans=0
  for i in range(101):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
print(ans)

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  print(x)
else:
  ans=0
  for i in range(n):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
  if ans==0:
    for j in range(2*x,101):
      if j not in a:
        ans=j
        break
print(ans)


Fixed submission:
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  ans=x
else:
  ans=0
  for i in range(101):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
print(ans)

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  print(x)
else:
  ans=0
  for i in range(n-1):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
  if ans==0:
    for j in range(2*x,101):
      if j not in a:
        ans=j
        break
print(ans)

Fixed submission:
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  ans=x
else:
  ans=0
  for i in range(101):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
  print(0)
else:
  cnt=1
  for i in a:
    cnt*=i
    if cnt>10**18:
      cnt=-1
      break
print(cnt)  

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
  print(0)
else:
  cnt=1
  for i in a:
    cnt*=i
    if cnt>10**18:
      cnt=-1
      break
  print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=1
lst=list(map(int,input().split()))
for i in lst:
  x*=i
if x<=10**18:
  print(x)
else:
  print('-1')


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
  print(0)
else:
  cnt=1
  for i in a:
    cnt*=i
    if cnt>10**18:
      cnt=-1
      break
  print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=1
lst=list(map(int,input().split()))
for i in lst:
  x*=i
if x<=10**18:
  print(x)
else:
  print('-1')

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
  print(0)
else:
  cnt=1
  for i in a:
    cnt*=i
    if cnt>10**18:
      cnt=-1
      break
  print(cnt)