Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
import math
import numpy as np
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,D = IL()
print(max(A*B, C*D))

Fixed submission:
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,D = IL()
print(max(A*B, C*D))
Buggy python submission (verdict: Time Limit Exceeded):
K,A = list(map(int,input().split()))

ans = 0
for a in range(K+1):
  for b in range(K+1):
    for c in range(K+1):
      if a+b+c == A:
        ans += 1

print(ans)

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

ans = 0
for a in range(K+1):
  for b in range(K+1):
    c = A-(a+b)
    if 0 <= c <= K:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))

aa = dict.fromkeys(a)
f = 0
cnt = 0
for i in aa:
  if i == 0:
    if a.count(0) == 1:
      continue
    else:
      f = 1
  else:
    if a.count(i) == 2:
      cnt += 1
    else:
      f = 1
if f == 0:
  print(pow(2, cnt))
else:
  print(0)

Fixed submission:
mod = 1000000007

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

data = [0]*N
for i in a:
  data[i] += 1

cnt = 0
for i in range(1,len(data)):
  if data[i] == 2:
    cnt += 1
  elif data[i] == 0:
    continue
  else:
      print(0)
      exit()
print(pow(2, cnt) %mod)
Buggy python submission (verdict: Runtime Error):
H,W = list(map(int,input89.split()))
picture = [input() for i in range(H)]

for i in range(2*H):
  print(picture[i//2])

Fixed submission:
H,W = list(map(int,input().split()))
picture = [input() for i in range(H)]

for i in range(2*H):
  print(picture[i//2])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = list(map(int,input().split()))
ans = 0
for i in range(a,b+1):
  if i%x == 0:
    ans += 1
print(ans)

Fixed submission:
a,b,x = list(map(int,input().split()))
ax = (a-1)//x
bx = b//x

print(bx-ax)
Buggy python submission (verdict: Runtime Error):
list=input().split()
A=int(list[0])
B=int(list[1])
K=int(list[2])

if A >= K:
    print((A-K) + " " + B)
else:
    print("0 "+ str(max(B-(K-A),0)) )

Fixed submission:
list=input().split()
A=int(list[0])
B=int(list[1])
K=int(list[2])

if A >= K:
    print(str((A-K)) + " " + str(B))
else:
    print("0 "+ str(max(B-(K-A),0)) )
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

import math

def num_pair(n):
  res = 2 # 1 x n, n x 1
  for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
      res += 2
  if int(math.sqrt(n)) ** 2 == n:
    res -= 1
  return res

# a x b + c == n
# n - c == a x b

res = 0
for i in range(1, N):
  res += num_pair(i)

print(res)

Fixed submission:
N = int(input())

def num_divisors_table(n):
  table = [0] * (n + 1)
  for i in range(1, n + 1):
    for j in range(i, n + 1, i):
      table[j] += 1
  return table

table = num_divisors_table(1000000)

# a x b + c == n
# n - c == a x b

res = 0
for i in range(1, N):
  res += table[i]

print(res)
Buggy python submission (verdict: Runtime Error):
H, W, K = list(map(int, input().split()))

mat = [None] * H

m = {
  '.': 0,
  '#': 1
}

for i in range(H):
  mat[i] = list(map(lambda x: m[x], list(input())))

res = 0
pattern = set()

def total(mat):
  return sum([sum(r) for r in mat])

def fillH(mat, i):
  res = mat[i]
  mat[i] = [0] * W
  return res

def restoreH(mat, i, v):
  mat[i] = v

def fillV(mat, j):
  res = [None] * W
  for i in range(H):
    res[i] = mat[i][j]
    mat[i][j] = 0
  return res

def restoreV(mat, j, v):
  for i in range(H):
    mat[i][j] = v[i]

def DFS(mat, path):
  global pattern
  global res
  #print(mat, path)
  if total(mat) > K:
    for i in range(H):
      if not i in path[0]:
        v = fillH(mat, i)
        path[0] |= {i}
        DFS(mat, path)
        restoreH(mat, i, v)
        path[0].remove(i)
    for j in range(W):
      if not j in path[1]:
        v = fillV(mat, j)
        path[1] |= {j}
        DFS(mat, path)
        restoreV(mat, j, v)
        path[1].remove(j)
  elif total(mat) < K:
    return
  else:
    if not tuple(map(frozenset, path)) in pattern:
      pattern |= {tuple(map(frozenset, path))}
      res += 1

DFS(mat, [set(), set()])

print(res)

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

c = [None] * H

for i in range(H):
  c[i] = list(input())

res = 0

for h in range(2 ** H):
  for w in range(2 ** W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if ((h >> i) & 1) == 0 and ((w >> j) & 1) == 0 and c[i][j] == '#':
          cnt += 1
    #print(cnt)
    if cnt == K:
      res += 1

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import mul

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

m = reduce(mul, A)

if m > 10 ** 18:
  print('-1')
else:
  print(m)

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

mul = 1

A.sort()

for i in range(N):
  mul *= A[i]
  if mul == 0 or mul > 10 ** 18:
    break

if mul > 10 ** 18:
  print('-1')
else:
  print(mul)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

N = int(input())

@lru_cache(maxsize=None)
def gcd2(a, b):
  while b != 0:
    a, b = b, a % b
  return a

def gcd(a, b, c):
  return gcd2(gcd2(a, b), c)

res = 0

for i in range(1, N + 1):
  for j in range(1, N + 1):
    for k in range(1, N + 1):
      res += gcd(i, j, k)

print(res)


Fixed submission:
from functools import lru_cache

N = int(input())

@lru_cache(maxsize=None)
def gcd2(a, b):
  while b != 0:
    a, b = b, a % b
  return a

def gcd(a, b, c):
  return gcd2(gcd2(a, b), c)

res = 0

for i in range(1, N + 1):
  for j in range(i, N + 1):
    for k in range(j, N + 1):
      if i == j == k:
        res += gcd(k, j, i)
      elif i != j != k:
        res += gcd(k, j, i) * 6
      else:
        res += gcd(k, j, i) * 3

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

N = int(input())

@lru_cache(maxsize=None)
def gcd2(a, b):
  while b != 0:
    a, b = b, a % b
  return a

def gcd(a, b, c):
  return gcd2(gcd2(a, b), c)

res = 0

for i in range(1, N + 1):
  for j in range(1, N + 1):
    for k in range(1, N + 1):
      res += gcd(i, j, k)

print(res)


Fixed submission:
from functools import lru_cache

N = int(input())

@lru_cache(maxsize=None)
def gcd2(a, b):
  while b != 0:
    a, b = b, a % b
  return a

def gcd(a, b, c):
  return gcd2(gcd2(a, b), c)

res = 0

for i in range(1, N + 1):
  for j in range(i, N + 1):
    for k in range(j, N + 1):
      if i == j == k:
        res += gcd(k, j, i)
      elif i != j != k:
        res += gcd(k, j, i) * 6
      else:
        res += gcd(k, j, i) * 3

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

N = int(input())

@lru_cache(maxsize=None)
def gcd2(a, b):
  if b == 0:
    return a
  return gcd2(b, a % b)

def gcd(a, b, c):
  return gcd2(gcd2(a, b), c)

res = 0

for i in range(1, N + 1):
  for j in range(1, N + 1):
    for k in range(1, N + 1):
      res += gcd(i, j, k)

print(res)

Fixed submission:
from functools import lru_cache

N = int(input())

@lru_cache(maxsize=None)
def gcd2(a, b):
  while b != 0:
    a, b = b, a % b
  return a

def gcd(a, b, c):
  return gcd2(gcd2(a, b), c)

res = 0

for i in range(1, N + 1):
  for j in range(i, N + 1):
    for k in range(j, N + 1):
      if i == j == k:
        res += gcd(k, j, i)
      elif i != j != k:
        res += gcd(k, j, i) * 6
      else:
        res += gcd(k, j, i) * 3

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

res = 0

Rs = [i for i in range(N) if S[i] == 'R']
Gs = [i for i in range(N) if S[i] == 'G']
Bs = [i for i in range(N) if S[i] == 'B']

for r in Rs:
  for g in Gs:
    for b in Bs:
      i, j, k = sorted([r, g, b])
      if j - i != k - j:
        res += 1

print(res)


Fixed submission:
N = int(input())
S = input()

res = 0

Rn = S.count('R')
Gn = S.count('G')
Bn = S.count('B')

res = Rn * Gn * Bn

for p in range(1, N - 1):
  for q in range(1, min(p, N - p - 1) + 1):
    i, j, k = p - q, p, p + q
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      res -= 1

print(res)

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

res = 0

Rs = [i for i in range(N) if S[i] == 'R']
Gs = [i for i in range(N) if S[i] == 'G']
Bs = [i for i in range(N) if S[i] == 'B']

for r in Rs:
  for g in Gs:
    for b in Bs:
      i, j, k = sorted([r, g, b])
      if j - i != k - j:
        res += 1

print(res)


Fixed submission:
N = int(input())
S = input()

res = 0

Rn = S.count('R')
Gn = S.count('G')
Bn = S.count('B')

res = Rn * Gn * Bn

for p in range(1, N - 1):
  for q in range(1, min(p, N - p - 1) + 1):
    i, j, k = p - q, p, p + q
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      res -= 1

print(res)

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

res = 0

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      if j - i != k - j and S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        res += 1

print(res)


Fixed submission:
N = int(input())
S = input()

res = 0

Rn = S.count('R')
Gn = S.count('G')
Bn = S.count('B')

res = Rn * Gn * Bn

for p in range(1, N - 1):
  for q in range(1, min(p, N - p - 1) + 1):
    i, j, k = p - q, p, p + q
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      res -= 1

print(res)
Buggy python submission (verdict: Runtime Error):
import heapq
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

r.sort()

if A < X:
  p += r[-(X - A):]
  r = r[:-(X - A)]
  A = X

if B < Y:
  q += r[-(Y - B):]
  r = r[:-(Y - B)]
  B = Y

p.sort()
q.sort()

pq = deque((heapq.merge(p[A - X:], q[B - Y:])))

while pq[0] < r[-1]:
  pq.popleft()
  pq.append(r.pop())

print(sum(pq))

Fixed submission:
import heapq
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

r.sort()

if A < X:
  p += r[-(X - A):]
  r = r[:-(X - A)]
  A = X

if B < Y:
  q += r[-(Y - B):]
  r = r[:-(Y - B)]
  B = Y

p.sort()
q.sort()

pq = deque(heapq.merge(p[A - X:], q[B - Y:]))

while r and pq[0] < r[-1]:
  pq.popleft()
  pq.append(r.pop())

print(sum(pq))

Buggy python submission (verdict: Runtime Error):
import heapq
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

r.sort()

if A < X:
  p += r[C - (X - A):]
  r = r[:C - (X - A)]
  A = X

if B < Y:
  q += r[C - (Y - B):]
  r = r[:C - (Y - B)]
  B = Y

p.sort()
q.sort()

pq = deque((heapq.merge(p[A - X:], q[B - Y:])))

while pq[0] < r[-1]:
  pq.popleft()
  pq.append(r.pop())

print(sum(pq))

Fixed submission:
import heapq
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

r.sort()

if A < X:
  p += r[-(X - A):]
  r = r[:-(X - A)]
  A = X

if B < Y:
  q += r[-(Y - B):]
  r = r[:-(Y - B)]
  B = Y

p.sort()
q.sort()

pq = deque(heapq.merge(p[A - X:], q[B - Y:]))

while r and pq[0] < r[-1]:
  pq.popleft()
  pq.append(r.pop())

print(sum(pq))

Buggy python submission (verdict: Runtime Error):
import heapq
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()
r.sort()

pq = deque((heapq.merge(p[A - X:], q[B - Y:])))
r = deque(r)

while pq[0] < r[-1]:
  pq.popleft()
  pq.append(r.pop())

print(sum(pq))

Fixed submission:
import heapq
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

r.sort()

if A < X:
  p += r[-(X - A):]
  r = r[:-(X - A)]
  A = X

if B < Y:
  q += r[-(Y - B):]
  r = r[:-(Y - B)]
  B = Y

p.sort()
q.sort()

pq = deque(heapq.merge(p[A - X:], q[B - Y:]))

while r and pq[0] < r[-1]:
  pq.popleft()
  pq.append(r.pop())

print(sum(pq))
Buggy python submission (verdict: Runtime Error):
S = input()

if S == 'AAA' or S = 'BBB':
  print('No')
else:
  print('Yes')

Fixed submission:
S = input()
 
if S == 'AAA' or S == 'BBB':
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
import math
 
A, B = list(map(int, input().split()))
 
rangeA = [A / 0.08, (A + 1) / 0.08]
rangeB = [B / 0.1, (B + 1) / 0.1]
 
if rangeA[0] < rangeB[0]:
  if math.ceil(rangeB[0]) < rangeA[1]:
    print(math.ceil(rangeB[0]))
    exit(0)
elif rangeA[0] > rangeB[0]:
  if math.ceil(rangeA[0]) < rangeB[1]:
    print(math.ceil(rangeA[0]))
    exit(0)
else:  # rangeA[0] == rangeB[0]
  if math.ceil(rangeA[0]) < rangeB[1] and math.ceil(rangeA[0]) < rangeA[1]: 
    print(math.ceil(rangeA[0]))
  	exit(0)
print(-1)

Fixed submission:
import math
 
A, B = list(map(int, input().split()))
 
rangeA = [A / 0.08, (A + 1) / 0.08]
rangeB = [B / 0.1, (B + 1) / 0.1]
 
if rangeA[0] < rangeB[0]:
  if math.ceil(rangeB[0]) < rangeA[1]:
    print(math.ceil(rangeB[0]))
    exit(0)
elif rangeA[0] > rangeB[0]:
  if math.ceil(rangeA[0]) < rangeB[1]:
    print(math.ceil(rangeA[0]))
    exit(0)
else:  # rangeA[0] == rangeB[0]
  if math.ceil(rangeA[0]) < rangeB[1] and math.ceil(rangeA[0]) < rangeA[1]: 
    print(math.ceil(rangeA[0]))
    exit(0)
print(-1)
Buggy python submission (verdict: Runtime Error):
A, B, C = list(map(int, input().split()))

l = [0] * 9

l[A] += 1
l[B] += 1
l[C] += 1

if max(l) == 2:
  print('Yes')
else:
  print('No')

Fixed submission:
A, B, C = list(map(int, input().split()))
 
l = [0] * 10
 
l[A] += 1
l[B] += 1
l[C] += 1
 
if max(l) == 2:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

A.sort()

for i in range(N - 1):
    if A[i] == A[i + 1]:
        print('NO')
        return

print('YES')


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

A.sort()

for i in range(N - 1):
    if A[i] == A[i + 1]:
        print('NO')
        break
else:
    print('YES')

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

import math
from functools import reduce

print('YES' if reduce(math.gcd, A) == 1 else 'NO')

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

A.sort()

for i in range(N - 1):
    if A[i] == A[i + 1]:
        print('NO')
        break
else:
    print('YES')

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

import math
from functools import reduce

print('YES' if reduce(math.gcd, A) == 1 else 'NO')

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

A.sort()

for i in range(N - 1):
    if A[i] == A[i + 1]:
        print('NO')
        break
else:
    print('YES')
Buggy python submission (verdict: Runtime Error):
c1, _, _ = input().split()
_, c2, _ = input().split()
_, _, c3 = input().split()

print(c1 + c2 + c3)

Fixed submission:
s1 = input()
s2 = input()
s3 = input()

print(s1[0] + s2[1] + s3[2])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
m = 998244353

s = []
for i in range(k):
    l, r = list(map(int, input().split()))

    for j in range(l, r+1):
        s.append(j)

dp = [0] * n
dp[0] = 1
for i in range(n):
    for j in s:
        ind = i-j
        if ind >= 0:
            dp[i] += dp[ind]
            dp[i] %= 998244353

print(dp[n-1])

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

s = []
for i in range(k):
    l, r = list(map(int, input().split()))
    s.append((l, r))

dp = [0] * n
dp[0] = 1
totals = [0] * n
totals[0] = 1

for i in range(1, n):
    thisTotal = 0
    for l, r in s:
        indL = i-l
        if indL >= 0:
            indR = max(0, i-r)

            thisTotal += totals[indL] - totals[indR-1]

    dp[i] = (thisTotal%m)
    totals[i] = (totals[i-1] + thisTotal)%m

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
x = int(input)

print(1 if x == 0 else 0)

Fixed submission:
x = int(input())

print(1 if x == 0 else 0)
Buggy python submission (verdict: Runtime Error):
f = open("input.txt", "r")
a, b, c, d = list(map(int, f.readline().split()))

if b <= 0 and d <= 0:
    print(a*c)
elif b < 0 and d >= 0:
    print(max(c, 1)*b)
elif b >= 0 and d < 0:
    print(max(a, 1)*d)
else:
    print(b*d)

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

ans = []

if b <= 0 and d <= 0:
    ans.append(a*c)
if b < 0 and d >= 0:
    ans.append(max(c,1)*b)
if b >= 0 and d < 0:
    ans.append(max(a,1)*d)

ans.append(max(b*d, a*c))

print(max(ans))
Buggy python submission (verdict: Runtime Error):
X = int(input)

print("Yes" if X >= 30 else "No")

Fixed submission:
X = int(input())
 
print("Yes" if X >= 30 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = {}

for ai in a:
    if ai in d:
        d[ai] += 1
    else:
        d[ai] = 1

for i in range(n):
    d2 = d.copy()
    d2[a[i]] -= 1

    cnt = 0
    for value in d2.values():
        cnt += value*(value-1)//2

    print(cnt)

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

for ai in a:
    if ai in d:
        d[ai] += 1
    else:
        d[ai] = 1

cnt = sum([value*(value-1)//2 for value in d.values()])

for i in range(n):
    val = d[a[i]]
    res = cnt - val*(val-1)//2

    if val >= 3:
        res += (val-1)*(val-2)//2

    print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
in = list(map(int, input.split()))

P = round(sum(in)/N)

sum = 0
for i in range(N):
  sum += (in[i] - P)**2
  
print(sum)

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

P = round(sum(numbers)/N)

sum = 0
for i in range(N):
  sum += (numbers[i] - P)**2

print(sum)

Buggy python submission (verdict: Runtime Error):
in = input().split(' ')
in = list(map(int, in))
in.pop(0)

P = round(sum(in)/len(in))

sum = 0
for i in range(len(in)):
  sum += (in[i] - P)**2
  
print(sum)

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

P = round(sum(numbers)/N)

sum = 0
for i in range(N):
  sum += (numbers[i] - P)**2

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

h, w = list(map(int, raw_input().split()))
grid = [raw_input() for _ in range(h)]

ans = 0

for startx in range(w):
    for starty in range(h):
        for endx in range(w):
            for endy in range(h):
                if grid[starty][startx] == "#" or grid[endy][endx] == "#":
                    continue

                dist = [[10000]*w for _ in range(h)]
                dist[starty][startx] = 0

                q = deque([(startx, starty)])

                while q:
                    curx, cury = q.popleft()
                    if (curx, cury) == (endx, endy):
                        break

                    adj = [(1, 0), (-1, 0), (0, 1), (0, -1)]

                    for xo, yo in adj:
                        x, y = curx + xo, cury + yo

                        if x < 0 or x >= w or y < 0 or y >= h:
                            continue
                        if grid[y][x] == "#":
                            continue

                        newDist = dist[cury][curx] + 1
                        if newDist < dist[y][x]:
                            dist[y][x] = newDist
                            q.append((x, y))

                ans = max(ans, dist[endy][endx])

print(ans)

Fixed submission:
from collections import deque

h, w = list(map(int, input().split()))
grid = [input() for _ in range(h)]

ans = 0

for startx in range(w):
    for starty in range(h):
        if grid[starty][startx] == "#":
            continue

        dist = [[10000]*w for _ in range(h)]
        dist[starty][startx] = 0
        maxDist = 0

        q = deque([(startx, starty)])

        while q:
            curx, cury = q.popleft()

            adj = [(1, 0), (-1, 0), (0, 1), (0, -1)]

            for xo, yo in adj:
                x, y = curx + xo, cury + yo

                if x < 0 or x >= w or y < 0 or y >= h:
                    continue
                if grid[y][x] == "#":
                    continue

                newDist = dist[cury][curx] + 1
                if newDist < dist[y][x]:
                    dist[y][x] = newDist
                    q.append((x, y))

                    maxDist = max(maxDist, newDist)

        ans = max(ans, maxDist)

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

a = [0] * n
for i in range(n):
    a[d[i]] += 1

if a[0] == 1 and d[0] == 0:
    ans = 1
    for i in range(1, n):
        ans *= a[i-1]**a[i]

    print(ans % 998244353)
else:
    print(0)

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

a = [0] * n
for i in range(n):
    a[d[i]] += 1

if a[0] == 1 and d[0] == 0:
    ans = 1
    for i in range(1, n):
        ans *= a[i-1]**a[i]
        ans %= 998244353

    print(ans)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)

cnt = 0

for i in range(n-1, -1, -1):
    for j in range(i-1, -1, -1):
        imin = 0
        imax = j-1

        while imin <= imax:
            mid = (imin + imax)//2
            if l[mid] + l[j] >= l[i]+1:
                imax = mid-1
            else:
                imin = mid+1

        cnt += j-imin

print(cnt)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)

cnt = 0

for i in range(n):
    for j in range(i+1, n):
        x = bisect.bisect_left(l, l[i]+l[j])
        cnt += x-j-1

print(cnt)

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

cnt = 0

for i in range(n-1, -1, -1):
    for j in range(i-1, -1, -1):
        imin = 0
        imax = j-1

        while imin <= imax:
            mid = (imin + imax)//2
            if test[mid] + l[j] >= l[i]:
                imax = mid-1
            else:
                imin = mid+1

        cnt += j-imin

print(cnt)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)

cnt = 0

for i in range(n):
    for j in range(i+1, n):
        x = bisect.bisect_left(l, l[i]+l[j])
        cnt += x-j-1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l = sorted(l, reverse=True)

cnt = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[j] + l[k] > l[i]:
                cnt += 1
            else:
                break

print(cnt)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)

cnt = 0

for i in range(n):
    for j in range(i+1, n):
        x = bisect.bisect_left(l, l[i]+l[j])
        cnt += x-j-1

print(cnt)

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

if n <= 2:
    print(0)
else:
    cnt = 0

    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                l = sorted([li[i], li[j], li[k]])

                if l[0] + l[1] > l[2]:
                    cnt += 1

    print(cnt)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)

cnt = 0

for i in range(n):
    for j in range(i+1, n):
        x = bisect.bisect_left(l, l[i]+l[j])
        cnt += x-j-1

print(cnt)