Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

class WarshallFloyd():
    def __init__(self, N):
        self.N = N
        self.d = [[float("inf") for i in range(N)]
                  for i in range(N)]  # d[u][v] : 辺uvのコスト(存在しないときは'inf')

    def add(self, u, v, c, directed=False):
        """
        0-indexedであることに注意
        u = from, v = to, c = cost
        directed = Trueなら、有向グラフである
        """
        if directed is False:
            self.d[u][v] = c
            self.d[v][u] = c
        else:
            self.d[u][v] = c

    def WarshallFloyd_search(self):
        # これを d[i][j]: iからjへの最短距離 にする
        # 本来無向グラフでのみ全域木を考えるが、二重辺なら有向でも行ける
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(
                        self.d[i][j], self.d[i][k] + self.d[k][j])
        for i in range(self.N):
            self.d[i][i] = 0
        return self.d

n,m,l = na()
g = WarshallFloyd(n)

for i in range(m):
    a,b,c = na()
    g.add(a-1,b-1,c)

gg = WarshallFloyd(n)
d = g.WarshallFloyd_search()

for i in range(n):
    for j in range(n):
        if d[i][j] <= l:
            gg.add(i,j,1)

q = ni()
dd = gg.WarshallFloyd_search()

for i in range(q):
    s,t = na()
    print(-1 if dd[s-1][t-1] == float('inf') else dd[s-1][t-1]-1)

Fixed submission:
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

class WarshallFloyd():
    def __init__(self, N):
        self.N = N
        self.d = [[float("inf") for i in range(N)]
                  for i in range(N)]  # d[u][v] : 辺uvのコスト(存在しないときは'inf')

    def add(self, u, v, c, directed=False):
        """
        0-indexedであることに注意
        u = from, v = to, c = cost
        directed = Trueなら、有向グラフである
        """
        if directed is False:
            self.d[u][v] = c
            self.d[v][u] = c
        else:
            self.d[u][v] = c

    def WarshallFloyd_search(self):
        # これを d[i][j]: iからjへの最短距離 にする
        # 本来無向グラフでのみ全域木を考えるが、二重辺なら有向でも行ける
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(
                        self.d[i][j], self.d[i][k] + self.d[k][j])
        for i in range(self.N):
            self.d[i][i] = 0
        return self.d

n,m,l = na()
g = WarshallFloyd(n)

for i in range(m):
    a,b,c = na()
    g.add(a-1,b-1,c)

gg = WarshallFloyd(n)
d = g.WarshallFloyd_search()

for i in range(n):
    for j in range(n):
        if d[i][j] <= l:
            gg.add(i,j,1)

q = ni()
dd = gg.WarshallFloyd_search()

for i in range(q):
    s,t = na()
    print(-1 if dd[s-1][t-1] == float('inf') else dd[s-1][t-1]-1)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import collections

n = ni()
balls = []
dis = []

for i in range(n):
    x,y = na()
    for b in balls:
        dis.append(str(abs(b[0]-x))+'_'+str(abs(b[1]-y)))
    balls.append([x,y])

c = collections.Counter(dis)
u = c.most_common()[0][1]

print(n-u)

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import collections

n = ni()

if n == 1:
    print(1)
    exit()

balls = []
dis = []

for i in range(n):
    x,y = na()
    for b in balls:
        k = '_1' if (b[0]-x)*(b[1]-y) > 0 else '_0'
        dis.append(str(abs(b[0]-x))+'_'+str(abs(b[1]-y))+k)
    balls.append([x,y])

c = collections.Counter(dis)
m = c.most_common()

if len(m) == 1:
    print(1)
    exit()

u = m[0][1]

print(n-u)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()
dp = []
for i in range(h):
    s = ns()
    c = 0
    lst = []
    for j in s:
        if j == '.':
            c += 1
        else:
            for k in range(c):
                lst.append(c)
            lst.append(0)
            c = 0
    for k in range(c):
        lst.append(c)
    dp.append(lst)

ans = 0
for i in range(w):
    a = 0
    c = 0
    for j in range(h):
        t = dp[j][i]
        if t == 0:
            a = max(t,a)
            ans = max(ans,a+c)
            a = 0
            c = 0
        else:
            a = max(t,a)
            c += 1
    ans = max(ans,a+c)

print(ans-1)

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()
dp = []
for i in range(h):
    s = ns()
    c = 0
    lst = []
    for j in s:
        if j == '.':
            c += 1
        else:
            for k in range(c):
                lst.append(c)
            lst.append(0)
            c = 0
    for k in range(c):
        lst.append(c)
    dp.append(lst)

ans = 0
for i in range(w):
    a = 0
    c = 0
    for j in range(h):
        t = dp[j][i]
        if t == 0:
            a = max(t,a)
            ans = max(ans,a+c)
            a = 0
            c = 0
        else:
            a = max(t,a)
            c += 1
    ans = max(ans,a+c)

print(ans-1)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
import bisect
 
n,q = na()
s = ns()
x = []
 
for r in range(len(s)):
  if s[r] == 'A':
    if s[r+1] == 'C':
      x.append(r)
 
for i in range(q):
  l,r = na()
  k = [j for j in x if j >= l-1 and j <= r-2]
  print(len(k))

Fixed submission:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
import bisect
 
n,q = na()
s = ns()
x = []
 
for r in range(len(s)-1):
  if s[r] == 'A':
    if s[r+1] == 'C':
      x.append(r)
 
for i in range(q):
  l,r = na()
  b = bisect.bisect_left(x,l-1)
  a = bisect.bisect_right(x,r-2)
  c = a-b if a-b>0 else 0
  print(c)

Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import bisect

n,q = na()
s = ns()
x = []

for r in range(len(s)):
  if s[r] == 'A':
    if s[r+1] == 'C':
      x.append(r)

for i in range(q):
  l,r = na()
  b = bisect.bisect_left(x,l-1)
  a = bisect.bisect_right(x,r-2)
  c = a-b if a-b>0 else 0
  print(c)

Fixed submission:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
import bisect
 
n,q = na()
s = ns()
x = []
 
for r in range(len(s)-1):
  if s[r] == 'A':
    if s[r+1] == 'C':
      x.append(r)
 
for i in range(q):
  l,r = na()
  b = bisect.bisect_left(x,l-1)
  a = bisect.bisect_right(x,r-2)
  c = a-b if a-b>0 else 0
  print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,q = na()
s = ns()

for i in range(q):
  l,r = na()
  a = s[l-1:r].count('AC')
  print(a)

Fixed submission:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
import bisect
 
n,q = na()
s = ns()
x = []
 
for r in range(len(s)-1):
  if s[r] == 'A':
    if s[r+1] == 'C':
      x.append(r)
 
for i in range(q):
  l,r = na()
  b = bisect.bisect_left(x,l-1)
  a = bisect.bisect_right(x,r-2)
  c = a-b if a-b>0 else 0
  print(c)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
print(m*(m-1)//2-m//2)

for i in range(n):
    a = n-1-i if n%2 == 0 else n-2-i
    for j in range(i,n):
        if j != a:
            print(i+1,j+1)

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
print(n*(n-1)//2-n//2)

for i in range(n):
    a = n-1-i if n%2 == 0 else n-2-i
    for j in range(i+1,n):
        if j != a:
            print(i+1,j+1)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a,b = na()
p = na()
c = [0,0,0]

for i in p:
    if i <= a:
        c[0] += 1
    elif a+1 < p <= b:
        c[1] += 1
    else:
        c[2] += 1

print(c)

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a,b = na()
p = na()
c = [0,0,0]

for i in p:
    if i <= a:
        c[0] += 1
    elif a+1 <= i <= b:
        c[1] += 1
    else:
        c[2] += 1

print(min(c))
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import heapq
import bisect

n = ni()
a = na()
ls = []
nibeki = [2**i for i in range(1,31)]

for i in a:
    heapq.heappush(ls,-i)

s = {}
ans = 0

for _ in range(n):
    m = -heapq.heappop(ls)
    if m in s and s[m] > 0:
        s[m] -= 1
        ans += 1
        continue
    b = bisect.bisect_right(nibeki,m)
    dif = 0 if b > 0 and nibeki[b-1] == m else nibeki[b]-m
    if m in s:
        s[dif] += 1
    else:
        s[dif] = 1

print(ans)

Fixed submission:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import heapq

n = ni()
a = na()
ls = []

for i in a:
    heapq.heappush(ls,-i)

s = {}
ans = 0

for _ in range(n):
    m = -heapq.heappop(ls)
    if m in s and s[m] > 0:
        s[m] -= 1
        ans += 1
        continue
    dif = 2**m.bit_length()-m
    if dif in s:
        s[dif] += 1
    else:
        s[dif] = 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = []

for i in range(n):
    a.append(ni())

a.sort()
k = n//2

if n%2 == 0:
    ans = (sum(a[t+1:])-sum(a[:t-1]))*2+a[t]-a[t-1]
    print(ans)
else:
    x = 2*(sum(a[t+1:])-sum(a[:t-1])) - a[t-1] - a[t]
    y = 2*(sum(a[t+2:])-sum(a[:t])) + a[t+1] + a[t]
    print(max(x,y))

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = []

for i in range(n):
    a.append(ni())

a.sort()
t = n//2

if n%2 == 0:
    ans = (sum(a[t+1:])-sum(a[:t-1]))*2+a[t]-a[t-1]
    print(ans)
else:
    x = 2*(sum(a[t+1:])-sum(a[:t-1])) - a[t-1] - a[t]
    y = 2*(sum(a[t+2:])-sum(a[:t])) + a[t+1] + a[t]
    print(max(x,y))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
sys.setrecursionlimit(10**6)

n,m = na()
k = m//n
ans = 0
for i in range(1,k+1)[::-1]:
    if m%i == 0:
        ans = i
        break

print(ans)


Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

#約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n,m = na()
k = m/n
a = make_divisors(m)
ans = 0
for i in a:
    if i <= k:
        ans = max(ans,i)

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,y = ni()
ans = [-1,-1,-1]
for i in range(n+1):
  for j in range(n-i+1):
    a = 10000*i + 5000*j + 1000*(n-i-j)
    if a == y:
      ans = [i,j,ni-j]

print(ans)

Fixed submission:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,y = na()
ans = [-1,-1,-1]
for i in range(n+1):
  for j in range(n-i+1):
    a = 10000*i + 5000*j + 1000*(n-i-j)
    if a == y:
      ans = [i,j,n-i-j]

print(ans[0],ans[1],ans[2])
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
ans = 0
r = 0
l = len(s)-1
while r < l:
  if s[r] == s[l]:
    r += 1
    l -= 1
  elif s[r] == "x":
    ans += 1
    r += 1
  elif s[l] == "x":
    rns += 1
    l -= 1
  else:
    print(-1)
    exit()

print(r)

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
ans = 0
r = 0
l = len(s)-1
while r < l:
  if s[r] == s[l]:
    r += 1
    l -= 1
  elif s[r] == "x":
    ans += 1
    r += 1
  elif s[l] == "x":
    ans += 1
    l -= 1
  else:
    print(-1)
    exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

k = ni()
n = 50

a = k//n
b = k&n
c = n-1+x

ans = [str(c+n-b+1)]*b + [str(c-b)]*(n-b)

print(n)
print(''.join(ans))

Fixed submission:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

k = ni()
n = 50

a = k//n
b = k%n
c = n-1+a

ans = [str(c+n-b+1)]*b + [str(c-b)]*(n-b)

print(n)
print(' '.join(ans))
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

import numpy as np
a = list(np.cumsum(a))

import bisect

ma = bisect.bisect_right(a,a[-1]/2)+1
mi = bisect.bisect_left(a,a[-1]/2)-1

ma = ma if ma < n-1 else n-2
mi = mi if mi > 0 else 0
mid = mi+1 if n>2 else mi

print(min(abs(a[-1]-a[ma]*2), abs(a[-1]-a[mi]*2), abs(a[-1]-a[mid]*2)))

Fixed submission:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

import numpy as np
a = list(np.cumsum(a))

ans = 100000000000000000

for i in range(n-1):
    ans = min(ans, abs(a[-1]-a[i]*2))

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

import numpy as np
a = list(np.cumsum(a))

import bisect
print(a)

ma = bisect.bisect_right(a,a[-1]/2)+1
mi = bisect.bisect_left(a,a[-1]/2)-1

ma = ma if ma < n-1 else n-2
mi = mi if mi > 0 else 0
mid = mi+1 if n>2 else mi

print(min(abs(a[-1]-a[ma]*2), abs(a[-1]-a[mi]*2), abs(a[-1]-a[mid]*2)))

Fixed submission:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

import numpy as np
a = list(np.cumsum(a))

ans = 100000000000000000

for i in range(n-1):
    ans = min(ans, abs(a[-1]-a[i]*2))

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

class WarshallFloyd():
    def __init__(self, N):
        self.N = N
        self.d = [[float("inf") for i in range(N)]
                  for i in range(N)]  # d[u][v] : 辺uvのコスト(存在しないときは'inf')

    def add(self, u, v, c, directed=False):
        """
        0-indexedであることに注意
        u = from, v = to, c = cost
        directed = Trueなら、有向グラフである
        """
        if directed is False:
            self.d[u][v] = c
            self.d[v][u] = c
        else:
            self.d[u][v] = c

    def WarshallFloyd_search(self):
        # これを d[i][j]: iからjへの最短距離 にする
        # 本来無向グラフでのみ全域木を考えるが、二重辺なら有向でも行ける
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(
                        self.d[i][j], self.d[i][k] + self.d[k][j])
        for i in range(self.N):
            self.d[i][i] = 0
        return self.d

n,m = na()
g = WarshallFloyd(n)
abc = []

for i in range(m):
    a,b,c = na()
    g.add(a,b,c)
    abc.append([a,b,c])

dp = g.WarshallFloyd_search()

ans = 0
for a,b,c in abc:
    if dp[a][b] < c:
        ans += 1

print(ans)

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

class WarshallFloyd():
    def __init__(self, N):
        self.N = N
        self.d = [[float("inf") for i in range(N)]
                  for i in range(N)]  # d[u][v] : 辺uvのコスト(存在しないときは'inf')

    def add(self, u, v, c, directed=False):
        """
        0-indexedであることに注意
        u = from, v = to, c = cost
        directed = Trueなら、有向グラフである
        """
        if directed is False:
            self.d[u][v] = c
            self.d[v][u] = c
        else:
            self.d[u][v] = c

    def WarshallFloyd_search(self):
        # これを d[i][j]: iからjへの最短距離 にする
        # 本来無向グラフでのみ全域木を考えるが、二重辺なら有向でも行ける
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(
                        self.d[i][j], self.d[i][k] + self.d[k][j])
        for i in range(self.N):
            self.d[i][i] = 0
        return self.d

n,m = na()
g = WarshallFloyd(n)
abc = []

for i in range(m):
    a,b,c = na()
    g.add(a-1,b-1,c)
    abc.append([a-1,b-1,c])

dp = g.WarshallFloyd_search()

ans = 0
for a,b,c in abc:
    if dp[a][b] < c:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()
co = ['A','B','C','D','E','F','G','H','I','J']

for i in range(h):
    s = nn()
    if 'snuke' in s:
        j = s.index('snuke')
        print(co[j]+str(i+1))
        exit()

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()
co = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(h):
    s = nn()
    if 'snuke' in s:
        j = s.index('snuke')
        print(co[j]+str(i+1))
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,x = na()
a = na()
dp = [i for i in a]
ans = sum(dp)

for i in range(1,n):
    for j in range(n):
        dp[(j+i)%n] = min(dp[(j+i)%n], a[j])
    ans = min(ans, sum(dp)+x*i)

print(ans)

Fixed submission:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,x = na()
a = na()
dp = [i for i in a]
ans = sum(dp)

for i in range(1,n):
    for j in range(n):
        dp[(j+i)%n] = min(dp[(j+i)%n], a[j])
    ans = min(ans, sum(dp)+x*i)

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,i = na()
a = na()
dp = [i for i in a]
ans = sum(dp)

for i in range(1,n):
    for j in range(n):
        dp[(j+i)%n] = min(dp[(j+i)%n], a[j])
    ans = min(ans, sum(dp)+x*i)

print(ans)

Fixed submission:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,x = na()
a = na()
dp = [i for i in a]
ans = sum(dp)

for i in range(1,n):
    for j in range(n):
        dp[(j+i)%n] = min(dp[(j+i)%n], a[j])
    ans = min(ans, sum(dp)+x*i)

print(ans)