Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
xorz = list(map(int, input().split()))

xorall = 0
for i in xorz:
    xorall ^= i

res = ""
for i in range(N):
    numx = xorall ^ xorz[i]
    res += str(numx)
    if i < N-1:
        res += " "


print(res)


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

xorall = 0
for i in xorz:
    xorall ^= i

numx = [0]*N
for i in range(N):
    numx[i] = xorall ^ xorz[i]

for i in range(N):
    print(numx[i]),
Buggy python submission (verdict: Runtime Error):
#3
#0 1 1 2

N = int(input())+1
leaves = list(map(int, input().split()))

nod = 0
total = 0

maxx = [0]*(N+1)
#toward
maxx[0] = 1
for i in range(1, N+1):
    notleave = maxx[i-1] - leaves[i-1]
    maxx[i] = notleave*2

#backward
for i in range(1, N+1):
    ii = N-i
    #at least need newnod nodes
    newnod = int((nod+1)/2) + leaves[ii]
    if newnod > 2**ii:
        total = -1
        break
    #maximum is?
    newnod = nod + leaves[ii]
    if newnod > maxx[ii]: newnod = maxx[ii]
    total += newnod
    nod = newnod

print(total)


Fixed submission:
import math
#3
#0 1 1 2

N = int(input())+1
leaves = list(map(int, input().split()))

nod = 0
total = 0

maxx = [0]*(N+1)
#toward
maxx[0] = 1
if N == 1 and leaves[0] == 1:
    total = 1
else:
    for i in range(1, N):
        notleave = maxx[i-1] - leaves[i-1]
        if notleave <= 0:
            total = -1
            break
        maxx[i] = notleave*2
        if maxx[i] < leaves[i]:
            total = -1
            break
        # if i == N-1:
        #     total += leaves[i]
        # else:
        #     total += maxx[i]



    #backward
    for i in range(1, N+1):
        ii = N-i
        #at least need newnod nodes
        newnod = int((nod+1)/2) + leaves[ii]
        if newnod > maxx[ii]:
            total = -1
            break
        #maximum is?
        newnod = nod + leaves[ii]
        if newnod > maxx[ii]: newnod = maxx[ii]
        if newnod <= 0:
            total = -1
            break
        total += newnod
        nod = newnod


if total <= 0: total = -1
print(total)
Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
A = map(int, raw_input().split())
 
#N = 200000
#A = [200000]*N
 
count = [0]*(N+2)
for i in range(N):
    id = A[i]
    count[id] = count[id]+1
 
sumN = long(0)
for i in range(N+1):
    sumN = sumN + long(long(count[i]*(count[i]-1))/2)
 
#print answer
for i in range(N):
    id = A[i]
    sumz = sumN - (count[id] - 1)
    print(sumz)

Fixed submission:
N = int(raw_input())
A = map(int, raw_input().split())

#N = 200000
#A = [200000]*N

count = [0]*(N+2)
for i in range(N):
    id = A[i]
    count[id] = count[id]+1

sumN = long(0)
for i in range(N+1):
    sumN = sumN + long(long(count[i]*(count[i]-1))/2)

#print answer
for i in range(N):
    id = A[i]
    sumz = sumN - (count[id] - 1)
    print(sumz)
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())

m = []
for i in range(H):
    m.append(input().rstrip('\n'))

wei = [[0]*(W+1) for _ in range(H+1)]
for h in range(H):
    for w in range(W):
        if m[h][w] == '.':
             wei[h][w] = wei[h][w-1] + 1
        else:
            wei[h][w] = 0
    #reverse
    for wz in range(W-1, -1, -1):
        if wei[h][wz] > 0 and wei[h][wz] < wei[h][wz+1]:
                wei[h][wz] = wei[h][wz + 1]

hei = [[0]*(W+1) for _ in range(H+1)]
for w in range(W):
    for h in range(H):
        if m[h][w] == '.':
             hei[h][w] = hei[h-1][w] + 1
        else:
            hei[h][w] = 0

    #reverse
    for hz in range(H-1, -1, -1):
        if hei[hz][w] > 0 and hei[hz][w] < hei[hz+1][w]:
            hei[hz][w] = hei[hz+1][w]

ans = 0
for h in range(H):
    for w in range(W):
       val = wei[h][w] + hei[h][w] - 1
       if ans < val:
           ans = val

print(ans)


Fixed submission:
H, W = map(int, input().split())

m = []
for i in range(H):
    m.append(input().rstrip('\n'))

wei = [[0]*(W+1) for _ in range(H+1)]
for h in range(H):
    for w in range(W):
        if m[h][w] == '.':
             wei[h][w] = wei[h][w-1] + 1
        else:
            wei[h][w] = 0
    #reverse
    for wz in range(W-1, -1, -1):
        if wei[h][wz] > 0 and wei[h][wz] < wei[h][wz+1]:
                wei[h][wz] = wei[h][wz + 1]

hei = [[0]*(W+1) for _ in range(H+1)]
for w in range(W):
    for h in range(H):
        if m[h][w] == '.':
             hei[h][w] = hei[h-1][w] + 1
        else:
            hei[h][w] = 0

    #reverse
    for hz in range(H-1, -1, -1):
        if hei[hz][w] > 0 and hei[hz][w] < hei[hz+1][w]:
            hei[hz][w] = hei[hz+1][w]

ans = 0
for h in range(H):
    for w in range(W):
       val = wei[h][w] + hei[h][w] - 1
       if ans < val:
           ans = val

print(ans)
Buggy python submission (verdict: Runtime Error):

N, Q = map(int, input().split())
S = input().rstrip('\n')
count = [0]*(N+2)

for i in range(N):
    if S[i] == 'A' and S[i+1] == 'C':
        count[i+1] = 1

#累積和
for i in range(1, N+1):
    count[i] += count[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(count[r-1] - count[l-1])




Fixed submission:

N, Q = map(int, input().split())
S = input().rstrip('\n')
count = [0]*(N+2)

for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        count[i+1] = 1

#累積和
for i in range(1, N+1):
    count[i] += count[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(count[r-1] - count[l-1])

Buggy python submission (verdict: Runtime Error):

N, Q = map(int, input().split())
S = input().rstrip('\n')
count = [0]*(N+1)

for i in range(N):
    if S[i] == 'A' and S[i+1] == 'C':
        count[i+1] = 1

#累積和
for i in range(1, N+1):
    count[i] += count[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(count[r-1] - count[l-1])




Fixed submission:

N, Q = map(int, input().split())
S = input().rstrip('\n')
count = [0]*(N+2)

for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        count[i+1] = 1

#累積和
for i in range(1, N+1):
    count[i] += count[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(count[r-1] - count[l-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
num = list(map(int, input().split()))

sumz = np.zeros(N+1, dtype=int)
count = np.zeros(N+1, dtype=int)
for i in range(1, N+1):
    sumz[i] = sumz[i-1] + num[i-1]

sortedsumz = np.sort(sumz)

def CC(a, b):
    ans = 1
    mulz = 1
    for i in range(b-a+1, b+1):
        ans *= i
    for i in range(1,a+1):
        mulz *= i
    return int(ans/mulz)

ways = 0
for i in range(1, N+1):
    if sortedsumz[i] == sortedsumz[i-1]:
        count[i] = count[i-1]+1
    elif count[i-1] >= 1:
        ways += CC(2, count[i-1]+1)

    #if sortedsumz[i-1] == 0:
    #    nzero += 1

if count[N] >= 1:
    ways += CC(2, count[N] + 1)
print(ways)


Fixed submission:
import numpy as np
N = int(input())
num = list(map(int, input().split()))

sumz = np.zeros(N+1, dtype=int)
count = np.zeros(N+1, dtype=int)
for i in range(1, N+1):
    sumz[i] = sumz[i-1] + num[i-1]

sortedsumz = np.sort(sumz)

def CC(a, b):
    ans = 1
    mulz = 1
    for i in range(b-a+1, b+1):
        ans *= i
    for i in range(1,a+1):
        mulz *= i
    return int(ans/mulz)

ways = 0
for i in range(1, N+1):
    if sortedsumz[i] == sortedsumz[i-1]:
        count[i] = count[i-1]+1
    elif count[i-1] >= 1:
        ways += CC(2, count[i-1]+1)

    #if sortedsumz[i-1] == 0:
    #    nzero += 1

if count[N] >= 1:
    ways += CC(2, count[N] + 1)
print(ways)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, C = map(int, input().split())

xv = [(0, 0)]
for i in range(N):
    x, v = map(float, input().split())
    xv.append((x, v))
sumA = np.zeros(N+1, dtype=float)
sumB = np.zeros(N+1, dtype=float)

xv.sort(key=lambda tup:tup[0])
for i in range(N):
    sumA[i+1] = sumA[i] + xv[i+1][1]
    sumB[i+1] = sumB[i] + xv[N-i][1]

for i in range(N):
    if sumA[i+1] < xv[i+1][0]: sumA[i+1] = 0
    else: sumA[i+1] -= xv[i+1][0]
    if sumB[i+1] < C - xv[N-i][0]: sumB[i+1] = 0
    else: sumB[i+1] -= C - xv[N-i][0]

ans = 0
for i in range(N):
    #when to turn back?
    valB = -xv[i][0] + max(sumB[:N-i+1])
    if valB < 0:
        ans = max(ans, sumA[i])
    else:
        ans = max(ans, sumA[i] + valB)

print(int(ans))


Fixed submission:
import numpy as np
N, C = map(int, input().split())

xv = [(0, 0)]
for i in range(N):
    x, v = map(float, input().split())
    xv.append((x, v))

sumA = np.zeros(N+2, dtype=float)
sumB = np.zeros(N+2, dtype=float)

xv.sort(key=lambda tup:tup[0])
xv.append((C,0))

for i in range(N+1):
    sumA[i+1] = sumA[i] + xv[i+1][1]
    sumB[i+1] = sumB[i] + xv[N-i][1]

maxA = [0]*(N+1)
maxB = [0]*(N+1)
for i in range(N):
    if sumA[i+1] < xv[i+1][0]: sumA[i+1] = 0
    else: sumA[i+1] -= xv[i+1][0]
    if sumB[i+1] < C - xv[N-i][0]: sumB[i+1] = 0
    else: sumB[i+1] -= C - xv[N-i][0]

    maxA[i + 1] = maxA[i]
    if sumA[i+1] > maxA[i]:
        maxA[i+1] = sumA[i+1]
    maxB[i + 1] = maxB[i]
    if sumB[i+1] > maxB[i]:
        maxB[i+1] = sumB[i+1]

ans = 0
for i in range(N):
    #when to turn back?
    #valB = -xv[i][0] + max(sumB[:N-i+1])
    valB = -xv[i][0] + maxB[N - i]
    if valB < 0:
        ans = max(ans, sumA[i])
    else:
        ans = max(ans, sumA[i] + valB)

    #when to turn back?
    valA = -C+xv[N-i+1][0] + maxA[N-i]
    if valA < 0:
        ans = max(ans, sumB[i])
    else:
        ans = max(ans, sumB[i] + valA)

print(int(ans))
Buggy python submission (verdict: Runtime Error):
s, t = [input() for i in range(2)]
c = []
for i in range(len(s) - len(t)):
  d = 0
  for a, b in zip(s[i:i+len(t)], t):
    if a != b:
      d += 1
  c.append(d)
print(min(c))

Fixed submission:
s, t = [input() for i in range(2)]
c = []
for i in range(len(s) - len(t) + 1):
  d = len(t)
  for a, b in zip(s[i:], t):
    if a == b:
      d -= 1
  c.append(d)
print(min(c))

Buggy python submission (verdict: Runtime Error):
s, t = [input() for i in range(2)]
c = []
for i in range(len(s) - len(t)):
  d = len(t)
  for a, b in zip(s[i:i+len(t)], t):
    if a == b:
      d -= 1
  c.append(d)
print(min(c))

Fixed submission:
s, t = [input() for i in range(2)]
c = []
for i in range(len(s) - len(t) + 1):
  d = len(t)
  for a, b in zip(s[i:], t):
    if a == b:
      d -= 1
  c.append(d)
print(min(c))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
  for j in range(i+1, n):
    b.append(a[i] % (10 ** 9 + 7) * (a[j] % (10 ** 9 + 7))
print(sum(b) % (10 ** 9 + 7))

Fixed submission:
s, t = [input() for i in range(2)]
c = []
for i in range(len(s) - len(t) + 1):
  d = len(t)
  for a, b in zip(s[i:], t):
    if a == b:
      d -= 1
  c.append(d)
print(min(c))
Buggy python submission (verdict: Runtime Error):
n, x, t = map(int, input().split())
if n % x == 0:
  print((n // x) * t)
else:
  print(((n // x) + 1) * t

Fixed submission:
n, x, t = map(int, input().split())
if n % x == 0:
  print((n // x) * t)
else:
  print((n // x + 1) * t)
Buggy python submission (verdict: Runtime Error):
n = list(input())
a = 0
for i in n:
  a += i
  
if a % 9 == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
n = list(map(int, input()))
print("Yes" if sum(n) % 9 == 0 else "No")

Buggy python submission (verdict: Runtime Error):
n = list(input())
print("Yes" if sum(n) % 9 == 0 else "No")

Fixed submission:
n = list(map(int, input()))
print("Yes" if sum(n) % 9 == 0 else "No")
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
s = []
if n == 0:
  print(x)
else:
  a = sorted([i for i in list(map(int, input().split())) if i != x])
  for i in range(n):
    s.append(abs(a[i] - x))
  b = a[s.index(min(s))]
  print(b)

Fixed submission:
x, y = map(int, input().split())
a = []
for i in range(0, x+1):
  a.append(2 * i + 4 * (x - i))
print("Yes" if y in a else "No")

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
for i in range(0, x+1):
  a.append(2 * i + 4 * (3 - i))
print("Yes" if y in a else "No")

Fixed submission:
x, y = map(int, input().split())
a = []
for i in range(0, x+1):
  a.append(2 * i + 4 * (x - i))
print("Yes" if y in a else "No")
Buggy python submission (verdict: Runtime Error):
n = int(input()[len(n - 1)])
a = [2, 4, 5, 7, 9]
b = [0, 1, 6, 8]

if n in a:
  print("hon")
elif n in b:
  print("pon")
else:
  print("bon")

Fixed submission:
n = input()
n = int(n[len(n) -1])
a = [2, 4, 5, 7, 9]
b = [0, 1, 6, 8]

if n in a:
  print("hon")
elif n in b:
  print("pon")
else:
  print("bon")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
print("Yes" if s == t[:-1] "No")

Fixed submission:
s = input()
t = input()
print("Yes" if s == t[:len(t) - 1] else "No")
Buggy python submission (verdict: Runtime Error):
s, w = map(int, input().split())
print("unsafe" s <= w else "safe")

Fixed submission:
s, w = map(int, input().split())
print("safe" if s > w else "unsafe")

Buggy python submission (verdict: Runtime Error):
s, w = map(int, input().split())
print("safe" s > w else "unsafe")

Fixed submission:
s, w = map(int, input().split())
print("safe" if s > w else "unsafe")
Buggy python submission (verdict: Runtime Error):
print("No" if len(set(input()) == 1 else "Yes")

Fixed submission:
n = input()
print("No" if n.count("A") == 3 or n.count("B") == 3 else "Yes")
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
s = ""
while len(s) < n:
  s += "b" * a + "r" * b
print(s[:n].count("b"))
    

Fixed submission:
n, a, b = map(int, input().split())
s = n // (a + b)
t = n % (a + b)
print(s * a + min(t, a))

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
s = ""
whlie len(s) < n:
  s += "b" * a + "r" * b
print(s[:n+1].count("b"))
    

Fixed submission:
n, a, b = map(int, input().split())
s = n // (a + b)
t = n % (a + b)
print(s * a + min(t, a))
Buggy python submission (verdict: Runtime Error):
n = input()
print((n // 2) + (n % 2))

Fixed submission:
n = int(input())
print((n // 2) + (n % 2) )
Buggy python submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [i for i in range(n)]

for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j] == 0
print("Yes" if any(i.count(0) == 3 for i in a))
print("Yes" if any(i.count(0) == 3 for i in zip(*a)))


Fixed submission:
s = " 012 345 678 036 147 258 048 246 "
a = [input().split() for i in range(3)]
b = a[0] + a[1] + a[2]

for i in [input()for i in range(int(input()))]:
  if i in b:
    s = s.replace(str(b.index(i)), "")
print("Yes" if "  " in s else "No")
Buggy python submission (verdict: Runtime Error):
print "Yes" if len(set(input().split())) == 2 else "No"

Fixed submission:
print("Yes" if len(set(input().split())) == 2 else "No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
print("APPROVED" if all(i % 5 == 0 or i % 3 == 0 for i in a if i % 2 == 0 else "DENIED")

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print("APPROVED" if all(i % 5 == 0 or i % 3 == 0 for i in a if i % 2 == 0) else "DENIED")
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
print(n // a + 1 if a >= b else n // b + 1)

Fixed submission:
a = int(input())
b = int(input())
n = int(input())
t = max(a, b)
print((n + t - 1) // t)
Buggy python submission (verdict: Runtime Error):
s, t = input().split()
print(" ".join(t, s))

Fixed submission:
s, t = input().split()
print( t + s)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
n = [1, 2, 3].remove(a).remove(b)
print(n[0])

Fixed submission:
a = int(input())
b = int(input())
c = 6 - a - b
print(c)
Buggy python submission (verdict: Runtime Error):
s = input()
t = 0
for i in range(len(s)):
  if s[i] != s[::-1][i]:
    t += 1
ptint(t//2)

Fixed submission:
s = input()
t = 0
for i in range(len(s)):
  if s[i] != s[::-1][i]:
    t += 1
print(t//2)

Buggy python submission (verdict: Runtime Error):
s = input()
t = 0
for i in range(len(s)):
  if s[i] != s[::-1][i]:
    t += 1
ptint(t)

Fixed submission:
s = input()
t = 0
for i in range(len(s)):
  if s[i] != s[::-1][i]:
    t += 1
print(t//2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
a = []
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      a.append(s[i] + s[j] + s[k])
print(len(set(a)))

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(10):
  idx1=s.find(str(i))
  for j in range(10):
    idx2=s.find(str(j),idx1+1,n)
    for k in range(10):
      idx3=s.find(str(k),idx2+1,n)
      if idx1==-1 or idx2==-1 or idx3==-1:
        continue
      else:
        ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
a = {}
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      a.append(s[i] + s[j] + s[k])
print(len(s))

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(10):
  idx1=s.find(str(i))
  for j in range(10):
    idx2=s.find(str(j),idx1+1,n)
    for k in range(10):
      idx3=s.find(str(k),idx2+1,n)
      if idx1==-1 or idx2==-1 or idx3==-1:
        continue
      else:
        ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = 0
for i in range(1, n):
  for j in range(i+1, n):
    if i + j == n:
      a += 1
print(a)
 

Fixed submission:
n = int(input())
print(n // 2 if n % 2 == 1 else (n - 1) // 2 )

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = 0
for i in range(1, n):
  for j in range(i+1, n):
    if i + j == n:
      a += 1
print(a)
 

Fixed submission:
n = int(input())
print(n // 2 if n % 2 == 1 else (n - 1) // 2 )
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(a - (2 * b) if a > 2b else 0)

Fixed submission:
a, b = map(int, input().split())
print(a - (2 * b) if a > (2 * b) else 0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
b = sum(map(int, input().split()))
c = map(int, input().split())
s = 0
for i in range(n-1):
  if a[i+1] - a[i] == 1:
    s += c[a[i] - 1]
print(b + s)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = sum(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for i in range(n-1):
  if a[i+1] - a[i] == 1:
    s += c[a[i] - 1]
print(b + s)
Buggy python submission (verdict: Runtime Error):
a, s = input().split()
print(s if int(a) < 3200 else "red")

Fixed submission:
a = int(input())
b = input()
print("red" if a < 3200 else b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a:
  s += 1 / a
print(1 / s)
  

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a:
  s += 1 / i
print(1 / s)
Buggy python submission (verdict: Runtime Error):
n, a* = map(int, open(0).read().split())
t = 0
for i in range(1, n-1):
  if sorted(a[i-1:i+2]).index(a[i]) == 1:
    t += 1
print(t)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
t = 0
for i in range(1, n-1):
  if sorted(a[i-1:i+2]).index(a[i]) == 1:
    t += 1
print(t)

Buggy python submission (verdict: Runtime Error):
n, a* = map(int, open(0).read().split())
t = 0
for i in range(1, n-1):
  if sorted([i-1:i+2]).index(a[i]) == 1:
    t += 1
print(t)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
t = 0
for i in range(1, n-1):
  if sorted(a[i-1:i+2]).index(a[i]) == 1:
    t += 1
print(t)
Buggy python submission (verdict: Runtime Error):
a = int(input())
print("Bad" if a[0] == a[1] or a[1] == a[2] or a[2] == a[3] else "Good")

Fixed submission:
a = input()
print("Bad" if a[0] == a[1] or a[1] == a[2] or a[2] == a[3] else "Good")
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
a = sorted([l + i for i in range(n)], key=abs)
print(sum(s[1:]))



Fixed submission:
n, l = map(int, input().split())
a = sorted([l + i for i in range(n)], key=abs)
print(sum(a[1:]))

Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
a = sorted([l + i - 1 for i in range(1, n-1)])
print(sum(a) - a[0] if abs(a[0]) > abs(a[-1]) else sum(a) - a[-1])


Fixed submission:
n, l = map(int, input().split())
a = sorted([l + i for i in range(n)], key=abs)
print(sum(a[1:]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(1, n):
  s.append(abs(a[:i] - a[i:]))
print(min(s))
  

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(1, n):
  s.append(abs(sum(a[:i]) - sum(a[i:])))
print(min(s))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(1, n):
  s.append(abs(a[:i] - a[i:]))
print(max(s))
  

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(1, n):
  s.append(abs(sum(a[:i]) - sum(a[i:])))
print(min(s))
Buggy python submission (verdict: Runtime Error):
a = []
for i in range(5):
  a.append(int(input()))
a.sort()
j = int(input)
k = a[4] - a[0]
if k <= j:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a = []
for i in range(5):
  a.append(int(input()))
a.sort()
j = int(input())
k = a[4] - a[0]
if k <= j:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
b = []
a = [int(input()) for i in range(5)]
for i in a:
  if i % 10 != 0:
    b.append(10 - (i % 10))

print(sum(a) + sum(b) - max(b))

Fixed submission:
a = [int(input()) for i in range(5)]
b = [9 - (i - 1) % 10 for i in a]
print(sum(a) + sum(b) - max(b))

Buggy python submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]
b = [10 - i % 10 for i in a if i % 10 != 0]
print(sum(a) + sum(b) - max(b))

Fixed submission:
a = [int(input()) for i in range(5)]
b = [9 - (i - 1) % 10 for i in a]
print(sum(a) + sum(b) - max(b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 0
for i in range(n):
  v, c = map(int, input().split())
  if c == "JPY":
    a += v
  else:
    a += v * 380000.0
print(a)

Fixed submission:
n = int(input())
a = 0
for i in range(n):
  v, c = input().split()
  v = float(v)
  if c == "JPY":
    a += v
  else:
    a += v * 380000.0
print(a)
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, raw_input().split())
m = A + B
print(min(A, B), max(0, m - N))

Fixed submission:
n, a, b = map(int, input().split())
print(min(a, b), max(0, (a + b) - n))
Buggy python submission (verdict: Time Limit Exceeded):
s = int(input())
a = [s]
i = 1
while True:
  if s % 2 == 0:
    s = s // 2
  else:
    s = 3 * s + 1
  if s in a:
    print(len(a) + 1)
  a.append(s)

Fixed submission:
s = int(input())
a = [s]
i = 1
while True:
  if s % 2 == 0:
    s = s // 2
  else:
    s = 3 * s + 1
  if s in a:
    print(len(a) + 1)
    break
  a.append(s)

Buggy python submission (verdict: Runtime Error):
s = int(input())
a = [s]
while True:
  if s % 2 == 0:
    s = s // 2
  else:
    s = 3 * s + 1
  if s in a:
    print(s)
    break
  s.append(s)

Fixed submission:
s = int(input())
a = [s]
i = 1
while True:
  if s % 2 == 0:
    s = s // 2
  else:
    s = 3 * s + 1
  if s in a:
    print(len(a) + 1)
    break
  a.append(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
t, a = map(int, input().split())
b = [abs(a - (t - i * 0.006)) for i in list(map(int, input().split()))]
print(b.index(min(b) + 1))


Fixed submission:
n = int(input())
t, a = map(int, input().split())
b = [abs(a - (t - i * 0.006)) for i in list(map(int, input().split()))]
print(b.index(min(b)) + 1)
Buggy python submission (verdict: Runtime Error):
n = input()
print(n.reverse() if len(n) == 3 else n)

Fixed submission:
n = input()
print(n[::-1] if len(n) == 3 else n)
Buggy python submission (verdict: Runtime Error):
n, t = map(int, input().split())
a = []
for i in range(n):
  c, s = map(int, input().split())
  if s <= t:
    a.append(c)
print(min(a))

Fixed submission:
n, t = map(int, input().split())
a = []
for i in range(n):
  c, s = map(int, input().split())
  if s <= t:
    a.append(c)
print("TLE" if len(a) == 0 else min(a))