Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, M = list(map(int, input().split()))
can = []
for i in range(1, M // 2 + 1):
	if M % i == 0:
		if N <= M // i:
			can.append(i)
		else:
			break

if N == 1:
	print(M)
else:
	print(max(can))



Fixed submission:
import numpy as np
N, M = list(map(int, input().split()))
can = []
for i in range(1, int(np.sqrt(M)) + 1):
	if M % i == 0:
		if N <= M // i:
			can.append(i)
		if N <= i:
			can.append(M // i)

if N == 1:
	print(M)
else:
	print(max(can))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = list(map(int, input().split()))
can = []
for i in range(1, M+1):
	if M % i == 0:
		if N <= M // i:
			can.append(i)
		else:
			break

print(max(can))


Fixed submission:
import numpy as np
N, M = list(map(int, input().split()))
can = []
for i in range(1, int(np.sqrt(M)) + 1):
	if M % i == 0:
		if N <= M // i:
			can.append(i)
		if N <= i:
			can.append(M // i)

if N == 1:
	print(M)
else:
	print(max(can))
Buggy python submission (verdict: Runtime Error):
def make_time(l, k):
	r = []
	for i in range(k-1, len(l)):
		r.append(l[i] - l[i-k+1])
	for i in range(len(l)-1, k-2, -1):
		r.append(l[i] - l[i-k+1])
	return r

if __name__ == '__main__':
	N, K  = list(map(int, input().split()))
	x = list(map(int, input().split()))
	x_time = make_time(x, K)
	times = [(x_time[i] + abs(x[i])) for i in range(N)]
	print(min(times))

Fixed submission:
def make_time(l, k):
	r = []
	for i in range(k-1, len(l)):
		r.append(l[i] - l[i-k+1])
	return r

if __name__ == '__main__':
	N, K  = list(map(int, input().split()))
	x = list(map(int, input().split()))
	x_time = make_time(x, K)
	times1 = [(x_time[i] + abs(x[i])) for i in range(N - K + 1)]
	x.reverse()
	x_time.reverse()
	times2 = [(x_time[i] + abs(x[i])) for i in range(N - K + 1)]
	times = times1 + times2
	print(min(times))
Buggy python submission (verdict: Runtime Error):
 A,B = map(int,input().split())
 
 
  def kaibun(m, n):
      key = 0
      for i in range(m,n+1):
          s = i//10000
          t = i%10
          u = i//1000 % 10
          v = i//10 % 10
          if (s==t)&(u==v):
              key += 1
      return key
 
  print(kaibun(A,B))

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


def kaibun(n):
	key = 0
	for i in range(1,n+1):
		if str(i) == str(i)[::-1]:
			key += 1
	return key

print(kaibun(B)-kaibun(A-1))

Buggy python submission (verdict: Runtime Error):
 A,B = map(int,input().split())
   ...:
   ...:
   ...: def kaibun(m, n):
   ...:     key = 0
   ...:     for i in range(m,n+1):
   ...:         s = i//10000
   ...:         t = i%10
   ...:         u = i//1000 % 10
   ...:         v = i//10 % 10
   ...:         if (s==t)&(u==v):
   ...:             key += 1
   ...:     return key
   ...:
   ...: print(kaibun(A,B))

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


def kaibun(n):
	key = 0
	for i in range(1,n+1):
		if str(i) == str(i)[::-1]:
			key += 1
	return key

print(kaibun(B)-kaibun(A-1))
Buggy python submission (verdict: Time Limit Exceeded):
X, Y = list(map(int,input().split()))

N = X

if X % Y == 0:
	print(-1)

else:
	while  N % Y != 0:
		N += X
	print(N - X)


Fixed submission:
X, Y = list(map(int,input().split()))

N = X

if X % Y == 0:
	print(-1)

else:
	while  N % Y == 0:
		N += X
	print(N)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [[0, 0, 0]]
for _ in range(n):
	data = list(map(int, input().split()))
	l.append(data)

message = "Yes"
for i in range(len(l)):
	t_delta = abs(l[i][0] - l[i + 1][0])
	x_delta = abs(l[i][1] - l[i + 1][1])
	y_delta = abs(l[i][2] - l[i + 1][2])
	t_minus_d = t_delta - x_delta - y_delta
	if (t_minus_d < 0) or (t_minus_d % 2 != 0):
		message = "No"
		break
print(message)


Fixed submission:
n = int(input())
l = [[0, 0, 0]]
for _ in range(n):
	data = list(map(int, input().split()))
	l.append(data)

message = "Yes"
for i in range(len(l) - 1):
	t_delta = abs(l[i][0] - l[i + 1][0])
	x_delta = abs(l[i][1] - l[i + 1][1])
	y_delta = abs(l[i][2] - l[i + 1][2])
	t_minus_d = t_delta - x_delta - y_delta
	if (t_minus_d < 0) or (t_minus_d % 2 != 0):
		message = "No"
		break
print(message)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from collections import Counter
N = int(input()) 
A = Counter(map(int, input().split()))
Q = int(input())
for i in range(Q):
    sum = 0
    b, c = map(int, input().split())
    if A[b] != 0:
        A[c] += A[b]
        A[b] = 0
    for n in A:
        sum += A[n] * n
    print(sum)

Fixed submission:
#!/usr/bin/env python3
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
d = Counter(A)
Q = int(input())
ans = sum(A)
for i in range(Q):
    b, c = map(int, input().split())
    ans += (c-b) * d[b]
    d[c] += d[b]
    d[b] = 0
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) 
A = list(map(int, input().split()))
Q = int(input()) 
for i in range(Q):
    b, c = map(str, input().split())
    if int(b) in A:
        A = [int(str(a).replace(b, c)) for a in A]
    print(sum(A))

Fixed submission:
#!/usr/bin/env python3
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
d = Counter(A)
Q = int(input())
ans = sum(A)
for i in range(Q):
    b, c = map(int, input().split())
    ans += (c-b) * d[b]
    d[c] += d[b]
    d[b] = 0
    print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input()) 
A = list(map(int, input().split()))
Q = int(input()) 
for i in range(q):
    b, c = map(str, input().split())
    if int(b) in A:
        A = [int(str(a).replace(b, c)) for a in A]
    print(sum(A))

Fixed submission:
#!/usr/bin/env python3
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
d = Counter(A)
Q = int(input())
ans = sum(A)
for i in range(Q):
    b, c = map(int, input().split())
    ans += (c-b) * d[b]
    d[c] += d[b]
    d[b] = 0
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input()) 
A = list(map(int, input().split()))
q = int(input()) 
for i in range(q):
    b, c = map(str, input().split())
    if int(b) in A:
        A = [int(str(a).replace(b, c)) for a in A]
    print(sum(A))

Fixed submission:
#!/usr/bin/env python3
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
d = Counter(A)
Q = int(input())
ans = sum(A)
for i in range(Q):
    b, c = map(int, input().split())
    ans += (c-b) * d[b]
    d[c] += d[b]
    d[b] = 0
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input()) 
A = list(map(str, input().split()))
q = int(input()) 
for i in range(q):
    b, c = map(str, input().split())
    A = [int(str(a).replace(b, c)) for a in A]
    print(sum(A))

Fixed submission:
#!/usr/bin/env python3
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
d = Counter(A)
Q = int(input())
ans = sum(A)
for i in range(Q):
    b, c = map(int, input().split())
    ans += (c-b) * d[b]
    d[c] += d[b]
    d[b] = 0
    print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
from decimal import Decimal
a, b = input().split()
a = Decimal(int(a))
b = Decimal(b)
print(int(a * b))

Fixed submission:
#!/usr/bin/env python3
n = int(input()) 
A = list(map(int, input().split()))
b = 1
i = 10**18
A = sorted(A)
for a in A:
  if b > i:
    break
  b *= a
print(-1 if b > i else b)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np
from decimal import Decimal
n = int(input()) 
A = list(map(Decimal, input().split()))
i = 10 ** 18
ans = int(np.prod(A))
if ans > i:
    print(-1)
else:
    print(ans)

Fixed submission:
#!/usr/bin/env python3
n = int(input()) 
A = list(map(int, input().split()))
b = 1
i = 10**18
A = sorted(A)
for a in A:
  if b > i:
    break
  b *= a
print(-1 if b > i else b)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np
n = int(input()) 
A = list(map(int, input().split()))
i = 10 ** 18
ans = np.prod(A)
elif ans > i:
    print(-1)
else:
    print(int(ans))

Fixed submission:
#!/usr/bin/env python3
n = int(input()) 
A = list(map(int, input().split()))
b = 1
i = 10**18
A = sorted(A)
for a in A:
  if b > i:
    break
  b *= a
print(-1 if b > i else b)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input()) 
A = list(map(int, input().split()))
i = 10 ** 18
ans = 1
for a in A:
    ans = ans * a
if ans > i:
    print(-1)
else:
    print(ans)

Fixed submission:
#!/usr/bin/env python3
n = int(input()) 
A = list(map(int, input().split()))
b = 1
i = 10**18
A = sorted(A)
for a in A:
  if b > i:
    break
  b *= a
print(-1 if b > i else b)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
a, b, c, k = map(int, input().split())
A = [1] * a
B = [0] * b
C = [-1] * c
A.extend(B)
A.extend(C)
print(sum(A[:k]))

Fixed submission:
#!/usr/bin/env python3
a, b, c, k = map(int, input().split())
if a + b <= k:
    print(a - (k - (a + b)))
    exit()
elif a <= k:
    print(a)
else:
    print(k)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input()) 
l = list(map(int, input().split()))
[print(l.count(i)) for i in range(1, n+1)]
    

Fixed submission:
#!/usr/bin/env python3
import collections
n = int(input()) 
l = sorted(list(map(int, input().split())))
c = collections.Counter(l)
[print(c[i]) for i in range(1, n+1)]

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input()) 
l = sorted(list(map(int, input().split())))
[print(l.count(i)) for i in range(1, n+1)]
    

Fixed submission:
#!/usr/bin/env python3
import collections
n = int(input()) 
l = sorted(list(map(int, input().split())))
c = collections.Counter(l)
[print(c[i]) for i in range(1, n+1)]

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input()) 
l = list(map(int, input().split()))
for i in range(1, n+1):
    print(l.count(i))

Fixed submission:
#!/usr/bin/env python3
import collections
n = int(input()) 
l = sorted(list(map(int, input().split())))
c = collections.Counter(l)
[print(c[i]) for i in range(1, n+1)]

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input()) 
l = list(map(int, input().split()))
for i in range(1, n+1):
    print(l.count(i))

Fixed submission:
#!/usr/bin/env python3
import collections
n = int(input()) 
l = sorted(list(map(int, input().split())))
c = collections.Counter(l)
[print(c[i]) for i in range(1, n+1)]
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
import itertools
k = int(input()) 
l = list(range(1, k + 1))
ans = 0
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
for v in itertools.product(l, repeat=3):
    ans += gcd(*list(v))
print(ans)

Fixed submission:
import math
n = int(input())
ans = 0
for i in range(1, n + 1):
  for j in range(1, n + 1):
    g = math.gcd(i, j)
    for k in range(1, n + 1):
      ans += math.gcd(g, k) 
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, a, b = map(int, input().split())
s = "b" * a
r = "r" * b
ans = ""
for i in range(n):
    ans += s
    ans += r
    if len(ans) >= n:
        break
print(ans[:n].count("b"))


Fixed submission:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
x = n // (a + b)
r = n % (a + b)
print(a * x + r) if r < a else print((a * (x + 1)))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, a, b = map(int, input().split())
ans = ""
s = "b" * a
t = "r" * b
while(True):
    if len(ans) <= n:
        ans += s
        if len(ans) <= n:
            ans += t
        else:
            print(ans[:n].count("b"))
            break
    else:
        print(ans.count("b"))
        break


Fixed submission:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
x = n // (a + b)
r = n % (a + b)
print(a * x + r) if r < a else print((a * (x + 1)))
Buggy python submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
d = {}
for _ in range(M):
  s, c = input().split()
  if s in d and d[s] != c:
    print("-1")
    sys.exit()
  else:
    d[s] = c
if N == 3:
  if d["1"] == "0":
    print("-1")
    sys.exit()
  else:
    if "1" not in d:
      a = "1"
    else:
      a = d["1"]
    if "2" in d:
      b = d["2"]
    else:
      b = "0"
    if "3" in d:
      c = d["3"]
    else:
      c = "0"
  print(a + b + c)
  sys.exit()
  
if N == 2:
  if d["2"] == "0":
    print("-1")
    sys.exit()
  else:
    if "2" in d:
      b = d["2"]
    else:
      b = "0"
    if "3" in d:
      c = d["3"]
    else:
      c = "0"
  print(b + c)
  sys.exit()
  
if N == 1:
  if d["3"] == "0":
    print("-1")
    sys.exit()
  else:
    if "3" in d:
      c = d["3"]
    else:
      c = "0"
  print(c)

Fixed submission:
import sys
N, M = map(int, input().split())
d = {}
for _ in range(M):
  s, c = input().split()
  if s in d and d[s] != c:
    print("-1")
    sys.exit()
  else:
    d[s] = c
    
if N == 3:
  if "1" in d and d["1"] == "0":
    print("-1")
    sys.exit()
  else:
    if "1" not in d:
      a = "1"
    else:
      a = d["1"]
    if "2" in d:
      b = d["2"]
    else:
      b = "0"
    if "3" in d:
      c = d["3"]
    else:
      c = "0"
  print(a + b + c)
  sys.exit()
  
if N == 2:
  if "1" in d and d["1"] == "0":
    print("-1")
    sys.exit()
  else:
    if "1" in d:
      b = d["1"]
    else:
      b = "1"
    if "2" in d:
      c = d["2"]
    else:
      c = "0"
  print(b + c)
  sys.exit()
  
if N == 1:
  if "1" in d and d["1"] == "0":
    print("0")
    sys.exit()
  else:
    if "1" in d:
      c = d["1"]
    else:
      c = "0"
  print(c)
Buggy python submission (verdict: Time Limit Exceeded):
i = int(input())
S = [input() for _ in range(i)]
d = {}
l = []
max = 1
for s in list(set(S)):
  if S.count(s) == max:
    max = S.count(s) 
    l.append(s)
  elif S.count(s) > max:
    max = S.count(s) 
    l = []
    l.append(s)    
#keys = sorted([k for k, v in d.items() if v == max])
for key in sorted(l):
  print(key)

Fixed submission:
import collections
i = int(input())
S = collections.Counter([input() for _ in range(i)])
max_v = max(S.values())
[print(s) for s in sorted([s for s in S if S[s] == max_v])]

Buggy python submission (verdict: Time Limit Exceeded):
i = int(input())
S = [input() for _ in range(i)]
d = {}
max = 1
for s in list(set(S)):
  if S.count(s) >= max:
    max = S.count(s) 
    d[s] = S.count(s)
keys = sorted([k for k, v in d.items() if v == max])
for key in keys:
  print(key)

Fixed submission:
import collections
i = int(input())
S = collections.Counter([input() for _ in range(i)])
max_v = max(S.values())
[print(s) for s in sorted([s for s in S if S[s] == max_v])]

Buggy python submission (verdict: Time Limit Exceeded):
i = int(input())
S = [input() for _ in range(i)]
d = {}
max = 0
for s in list(set(S)):
  if S.count(s) >= max:
    max = S.count(s) 
    d[s] = S.count(s)
keys = sorted([k for k, v in d.items() if v == max])
for key in keys:
  print(key)

Fixed submission:
import collections
i = int(input())
S = collections.Counter([input() for _ in range(i)])
max_v = max(S.values())
[print(s) for s in sorted([s for s in S if S[s] == max_v])]

Buggy python submission (verdict: Time Limit Exceeded):
i = int(input())
S = [input() for _ in range(i)]
d = {}
max = 0
for s in list(set(S)):
  if S.count(s) >= max:
    max = S.count(s) 
    d[s] = S.count(s)
keys = sorted([k for k, v in d.items() if v == max])
for key in keys:
  print(key)

Fixed submission:
import collections
i = int(input())
S = collections.Counter([input() for _ in range(i)])
max_v = max(S.values())
[print(s) for s in sorted([s for s in S if S[s] == max_v])]

Buggy python submission (verdict: Time Limit Exceeded):
i = int(input())
S = [input() for _ in range(i)]
d = {}
max = 0
for s in list(set(S)):
  d[s] = S.count(s)
  if S.count(s) > max:
    max = S.count(s) 
keys = sorted([k for k, v in d.items() if v == max])
for key in keys:
  print(key)

Fixed submission:
import collections
i = int(input())
S = collections.Counter([input() for _ in range(i)])
max_v = max(S.values())
[print(s) for s in sorted([s for s in S if S[s] == max_v])]
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
l = len(H)
if K != 0:
    if len(H) <= K:
        print(0)
        sys.exit()
    for i in range(K):
        H.pop(0)
    if len(H)==0:
        print(0)
    else:
        print(sum(H))
else:
    print(sum(H))

Fixed submission:
#!/usr/bin/env python3
import sys
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
l = len(H)
if K != 0:
    if len(H) <= K:
        print(0)
    else:
        print(sum(H[K:]))
else:
    print(sum(H))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
l = len(H)
if K != 0:
    for i in range(K):
        if len(H)==0:
            print(0)
            sys.exit()
        else:
            H.pop(0)
    if len(H)==0:
        print(0)
    else:
        print(sum(H))
else:
    print(sum(H))

Fixed submission:
#!/usr/bin/env python3
import sys
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
l = len(H)
if K != 0:
    if len(H) <= K:
        print(0)
    else:
        print(sum(H[K:]))
else:
    print(sum(H))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input())
l = list(map(int, input().split()))
ans = 1
if len(l) == 1:
    print(1)
    exit()
if len(l) > 1 and l[0] >= l[1]:
    ans += 1
for i in range(2, n):
    if min(l[:i]) > l[i]:
        ans += 1
print(ans)


Fixed submission:
#!/usr/bin/env python3
n = int(input())
l = list(map(int, input().split()))
ans = 1
min_l = l[0]
for i in range(1, n):
    if min_l > l[i]:
        ans += 1
        min_l = l[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input())
l = list(map(int, input().split()))
ans = 1
for i in range(1, n):
    flag = True
    #print("i", i)
    for s in range(i):
        #print("s", s)
        if l[s] < l[i]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)


Fixed submission:
#!/usr/bin/env python3
n = int(input())
l = list(map(int, input().split()))
ans = 1
min_l = l[0]
for i in range(1, n):
    if min_l > l[i]:
        ans += 1
        min_l = l[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import math
a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))


Fixed submission:
#!/usr/bin/env python3
import fractions
a, b = map(int, input().split())
f = fractions.gcd(a, b)
ans = a * b // f
print(ans)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import math
a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))


Fixed submission:
#!/usr/bin/env python3
import fractions
a, b = map(int, input().split())
f = fractions.gcd(a, b)
ans = a * b // f
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
i = 1
min = 1000000000000
for _ in range(N):
  if N % i == 0:
    j = N/i
    sum = j + i
    if sum < min:
      min = sum
      ans = i-1+j-1
    else:
      break
  i += 1
print(ans)

Fixed submission:
import math
N = int(input())
i = 1
min = 9000000000000
for _ in range(1, int(math.sqrt(N)+1)):
  if N % i == 0:
    j = N/i
    sum = j + i
    if sum < min:
      min = sum
      ans = i-1+j-1
    else:
      break
  i += 1
print(int(ans))
Buggy python submission (verdict: Runtime Error):
 A, B = map(int, input().split())
if A < B*2:
  print(0)
else:
  print(A-B*2)

Fixed submission:
A, B = map(int, input().split())
if A < B*2:
  print(0)
else:
  print(A-B*2)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for b in range(N):
    for a in range(b):
        print()
        ab = L[a] + L[b]
        r = bisect_left(L, ab)
        cnt += r - (b + 1) 
print(cnt)

Fixed submission:
from bisect import bisect_left
 
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
cnt = 0
 
# 2番目に長い棒bを固定
for b in range(N):
    # bより短い棒aを一つずつ探索
    for a in range(b):
        ab = L[a] + L[b]
        # 二分探索でa+bより短い棒（c<a+bが成り立つc）の範囲を求める
        r = bisect_left(L, ab)
        # cの範囲のうちbの範囲を除外して、cの本数を求める
        cnt += r - (b + 1)
 
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = sorted(list(map(int, input().split())))
a = 0
for i in range(len(L)-2):
  if L[i] >= L[i+1] + L[i+2]:
    L.pop(i)
for i in list(itertools.combinations(L,3)):
  if (i[0]<i[1]+i[2]) and (i[1]<i[0]+i[2]) and (i[2]<i[1]+i[0]):
    a += 1
print(a)

Fixed submission:
from bisect import bisect_left
 
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
cnt = 0
 
# 2番目に長い棒bを固定
for b in range(N):
    # bより短い棒aを一つずつ探索
    for a in range(b):
        ab = L[a] + L[b]
        # 二分探索でa+bより短い棒（c<a+bが成り立つc）の範囲を求める
        r = bisect_left(L, ab)
        # cの範囲のうちbの範囲を除外して、cの本数を求める
        cnt += r - (b + 1)
 
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = list(map(int, input().split()))
a = 0
for i in list(itertools.combinations(L,3)):
  if (i[0]<i[1]+i[2]) and (i[1]<i[0]+i[2]) and (i[2]<i[1]+i[0]):
    a += 1
print(a)

Fixed submission:
from bisect import bisect_left
 
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
cnt = 0
 
# 2番目に長い棒bを固定
for b in range(N):
    # bより短い棒aを一つずつ探索
    for a in range(b):
        ab = L[a] + L[b]
        # 二分探索でa+bより短い棒（c<a+bが成り立つc）の範囲を求める
        r = bisect_left(L, ab)
        # cの範囲のうちbの範囲を除外して、cの本数を求める
        cnt += r - (b + 1)
 
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, K, Q = map(int, input().split())
p = [K] * N
m = [1] * N
for i in range(Q):
  A = int(input())
  p = [p[i] - m[i] for i in range(len(p))]
  #p = p - m
  p[A-1] = p[A-1] + 1
  if sum(p) == 0:
    break
for s in p:
  if s > 0:
    print('Yes')
  else:
    print('No')

Fixed submission:
import numpy as np
N, K, Q = map(int, input().split())
p = np.array([K - Q] * N)
for i in range(Q):
  A = int(input())
  p[A-1] = p[A-1] + 1
for s in p:
  if s > 0:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K, Q = map(int, input().split())
p = np.array([K] * N)
m = np.array([1] * N)
for i in range(Q):
  A = int(input())
  #p = [p[i] - m[i] for i in range(len(p))]
  p = p - m
  p[A-1] = p[A-1] + 1
  if sum(p) == 0:
    break
for s in p:
  if s > 0:
    print('Yes')
  else:
    print('No')

Fixed submission:
import numpy as np
N, K, Q = map(int, input().split())
p = np.array([K - Q] * N)
for i in range(Q):
  A = int(input())
  p[A-1] = p[A-1] + 1
for s in p:
  if s > 0:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
p = [K] * N
m = [1] * N
for i in range(Q):
  A = int(input())
  p = [p[i] - m[i] for i in range(len(p))]
  p[A-1] = p[A-1] + 1
for s in p:
  if s > 0:
    print('Yes')
  else:
    print('No')

Fixed submission:
import numpy as np
N, K, Q = map(int, input().split())
p = np.array([K - Q] * N)
for i in range(Q):
  A = int(input())
  p[A-1] = p[A-1] + 1
for s in p:
  if s > 0:
    print('Yes')
  else:
    print('No')