Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
return max(a) - min(a)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(max(a) - min(a))
Buggy python submission (verdict: Runtime Error):
k = int(input())
sunuke_list = [1,2,3,4,5,6,7,8]
def s(n):
    n_charlist = list(str(n))
    return sum(list(map(int, n_charlist)))
def combine_int(i,n):
    i_charlist = list(str(i))
    n_charlist = ['9'] * n
    ret_charlist = i_charlist + n_charlist
    ret_str = ''.join(ret_charlist)
    return int(ret_str)
for n in range(1,13):
    i = n-1
    while((i+1)/(s(i)+9*n) <= (i+2)/(s(i+1)+9*n)):
        sunuke_list.append(combine_int(i,n))
        i += 1
for i in range(k):
    print(sunuke_list[i])


Fixed submission:
k = int(input())
sunuke_list = [1,2,3,4,5,6,7,8]
def s(n):
    n_charlist = list(str(n))
    return sum(list(map(int, n_charlist)))
def combine_int(i,n):
    i_charlist = list(str(i))
    n_charlist = ['9'] * n
    ret_charlist = i_charlist + n_charlist
    ret_str = ''.join(ret_charlist)
    return int(ret_str)
for n in range(1,14):
    if n >= 12:
        i = n-2
    else:
        i = n-1
    while((i+1)/(s(i)+9*n) <= (i+2)/(s(i+1)+9*n)):
        sunuke_list.append(combine_int(i,n))
        i += 1
for i in range(k):
    print(sunuke_list[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + a[i]
l = 0
r = 0
count = 0
while(r + 1 < n):
    if (cum[r] - cum[l]) & a[r+1] == 0:
        r += 1
        count += 1
    else:
        j += 1
print(count)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + a[i]
l = 0
r = 0
count = 0
while(r < n or l < n):
    if r < n and (cum[r] - cum[l]) & a[r] == 0:
        r += 1
    else:
        count += r - l
        l += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
prebit = [0 for _ in range(20)]
prem = 0
def binl(x, accl):
    if len(accl) == 20:
        return accl
    else:
        accl.append(x%2)
        return binl(x//2, accl)
ans = 0
for i in range(1, n+1):
    m = prem+1
    b = binl(a[i-1], [])
    for j in range(20):
        if b[j] == 1:
            m = min(m, i - prebit[j])
            prebit[j] = i
    prem = m
    ans += m
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + a[i]
l = 0
r = 0
count = 0
while(r < n or l < n):
    if r < n and (cum[r] - cum[l]) & a[r] == 0:
        r += 1
    else:
        count += r - l
        l += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
prebit = [0 for _ in range(20)]
prem = 0
def binl(x, accl):
    if len(accl) == 20:
        return accl
    else:
        accl.append(x%2)
        return binl(x//2, accl)
ans = 0
for i in range(1, n+1):
    m = i
    b = binl(a[i-1], [])
    for j in range(20):
        if b[j] == 1:
            m = min(m, i - prebit[j])
            prebit[j] = i
    prem = min(m, prem+1)
    ans += prem
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + a[i]
l = 0
r = 0
count = 0
while(r < n or l < n):
    if r < n and (cum[r] - cum[l]) & a[r] == 0:
        r += 1
    else:
        count += r - l
        l += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
dp = [[0 for _ in range(21)] for _ in range(n+1)]
def binl(x, accl):
    if len(accl) == 20:
        return accl
    else:
        accl.append(x%2)
        return binl(x//2, accl)
ans = 0
for i in range(1, n+1):
    m = i
    b = binl(a[i-1], [])
    for j in range(20):
        if b[j] == 1:
            dp[i][j] = i
            m = min(m, i - dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
    dp[i][20] = min(m, dp[i-1][20]+1)
    ans += dp[i][20]
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + a[i]
l = 0
r = 0
count = 0
while(r < n or l < n):
    if r < n and (cum[r] - cum[l]) & a[r] == 0:
        r += 1
    else:
        count += r - l
        l += 1
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
def all(s, k):
    if s == '':
        return {}
    ret = set()
    for i in range(k):
        if i < len(s):
            ret.add(s[:(i+1)])
    return ret.union(all(s[1:], k))
koho = sorted(list(all(s,k)))
print(koho[k-1])


Fixed submission:
s = input()
k = int(input())
n = len(s)
koho = set()
for i in range(n):
    for j in range(k):
        if i + j < n:
            koho.add(s[i:(i+j+1)])
so = sorted(list(koho))
print(so[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
class Unionfind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x
    def union(self, x, y):
        xl = self.find(x)
        yl = self.find(y)
        if xl != yl:
            if self.table[xl] <= self.table[yl]:
                self.table[yl] = xl
                self.table[xl] -= 1
            else:
                self.table[xl] = yl
                self.table[yl] -= 1
n, m = map(int, input().split())
p = list(map(int, input().split()))
edges = [tuple(map(int, input().split())) for _ in range(m)]
place = Unionfind(n)
d = {}
for x, y in edges:
    place.union(x-1, y-1)
loot = [0] * n
for i in range(n):
    loot[i] = place.find(i)
    if loot[i] not in d:
        d[loot[i]] = [p[i]-1]
    else:
        d[loot[i]].append(p[i]-1)
counter = 0
for i in range(n):
    if i in d[loot[i]]:
        counter += 1
print(counter)


Fixed submission:
class Unionfind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x
    def union(self, x, y):
        xl = self.find(x)
        yl = self.find(y)
        if xl != yl:
            if self.table[xl] <= self.table[yl]:
                self.table[yl] = xl
                self.table[xl] -= 1
            else:
                self.table[xl] = yl
                self.table[yl] -= 1
n, m = map(int, input().split())
p = list(map(int, input().split()))
edges = [tuple(map(int, input().split())) for _ in range(m)]
place = Unionfind(n)
d = {}
for x, y in edges:
    place.union(x-1, y-1)
loot = [0] * n
for i in range(n):
    loot[i] = place.find(i)
    if loot[i] not in d:
        d[loot[i]] = {p[i]-1}
    else:
        d[loot[i]].add(p[i]-1)
counter = 0
for i in range(n):
    if i in d[loot[i]]:
        counter += 1
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
n, c = map(int, input().split())
sushi = [tuple(map(int, input().split())) for _ in range(n)]
def sumv(s):
    ret = 0
    for _, v in s:
        ret += v
    return ret
# counter clock wize till i
ccw = []
for i in range(n):
    score = sumv(sushi[:i+1]) - sushi[i][0]
    maxscore = score
    for j in range(1, n-i):
        score += sushi[n-j][1]
        maxscore = max(maxscore, score - (c - sushi[n-j][0]) - sushi[i][0])
    ccw.append(maxscore)
# clock wize till i
cw = []
for i in range(n):
    score = sumv(sushi[n-i-1:]) - (c - sushi[n-i-1][0])
    maxscore = score
    for j in range(n-i-1):
        score += sushi[j][1]
        maxscore = max(maxscore, score - sushi[j][0] - (c - sushi[n-i-1][0]))
    cw.append(maxscore)
print(max(max(ccw), max(cw), 0))


Fixed submission:
n, c = map(int, input().split())
sushi = [tuple(map(int, input().split())) for _ in range(n)]
sushi = [(0, 0)] + sushi
cclkmax = [0] * (n+1)
cumvalue = 0
for i in range(1, n+1):
    cumvalue += sushi[i][1]
    cclkmax[i] = max(cclkmax[i-1], cumvalue - sushi[i][0])
maxscore = cclkmax[n]
cum = 0
for i in range(n, 0, -1):
    cum += sushi[i][1]
    score = cclkmax[i-1] + cum - 2*(c - sushi[i][0])
    maxscore = max(maxscore, score)
clkmax = [0] * (n+1)
cumvalue = 0
for i in range(n, 0, -1):
    cumvalue += sushi[i][1]
    clkmax[i] = max(clkmax[(i+1)%(n+1)], cumvalue - (c - sushi[i][0]))
maxscore = max(maxscore, clkmax[1])
cum = 0
for i in range(1, n+1):
    cum += sushi[i][1]
    score = clkmax[(i+1)%(n+1)] + cum - 2*sushi[i][0]
    maxscore = max(maxscore, score)
print(maxscore)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
a.sort()
diff1 = a[1] - a[0]
diff2 = a[2] - a[1]
diff3 = a[2] - a[0]
if diff1 % 2 == 0:
    if diff3 % 2 == 0:
        print((diff3 + diff2)//2)
    else:
        print(diff3//2 + diff2//2 + 1)
else:
    if diff3 % 2 == 0:
        print(diff3//2 + diff2//2 + 2)
    else:
        prnit(diff3//2 + diff2//2 + 2)


Fixed submission:
a = list(map(int, input().split()))
a.sort()
diff1 = a[1] - a[0]
diff2 = a[2] - a[1]
diff3 = a[2] - a[0]
if diff1 % 2 == 0:
    if diff3 % 2 == 0:
        print((diff3 + diff2)//2)
    else:
        print(diff3//2 + diff2//2 + 1)
else:
    if diff3 % 2 == 0:
        print(diff3//2 + diff2//2 + 2)
    else:
        print(diff3//2 + diff2//2 + 2)
Buggy python submission (verdict: Time Limit Exceeded):
h, w, d = map(int, input().split())
board = [list(map(int, input().split())) for _ in range(h)]
q = int(input())
quest = [tuple(map(int, input().split())) for _ in range(q)]
enumboard = []
for i in range(h):
    for j in range(w):
        enumboard.append((board[i][j], i, j))
enumboard.sort(key = lambda x: x[0])
for l, r in quest:
    ret = 0
    for x in range(l, r, d):
        ret += abs(enumboard[x+d-1][1] - enumboard[x-1][1]) + abs(enumboard[x+d-1][2] - enumboard[x-1][2])
    print(ret)

Fixed submission:
h, w, d = map(int, input().split())
board = [list(map(int, input().split())) for _ in range(h)]
q = int(input())
quest = [tuple(map(int, input().split())) for _ in range(q)]
enumboard = []
for i in range(h):
    for j in range(w):
        enumboard.append((board[i][j], i, j))
enumboard.sort(key = lambda x: x[0])
cumboard = [0 for _ in range(h*w)]
for i in range(d, h*w):
    cumboard[i] = cumboard[i-d] + abs(enumboard[i][1] - enumboard[i-d][1]) + abs(enumboard[i][2] - enumboard[i-d][2])
for l, r in quest:
    print(cumboard[r-1] - cumboard[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
favor = [tuple(input().split()) for _ in range(n)]
square = [[0 for _ in range(k)] for _ in range(k)]
initscore = 0
for xc, yc, c in favor:
    x = int(xc)
    y = int(yc)
    x %= 2*k
    y %= 2*k
    if (x in range(k) and y in range(k)) or (x in range(k, 2*k) and y in range(k, 2*k)):
        if c == 'B':
            square[x%k][y%k] += 1
        else:
            square[x%k][y%k] -= 1
            initscore += 1
    else:
        if c == 'B':
            square[x%k][y%k] -= 1
            initscore += 1
        else:
            square[x%k][y%k] += 1
cum = [[0 for _ in range(k+1)] for _ in range(k+1)]
for i in range(k):
    for j in range(k):
        cum[i+1][j+1] = cum[i+1][j] + cum[i][j+1] - cum[i][j] + square[i][j]
maxscore = 0
for i in range(k):
    for j in range(k):
        score1 = 2*cum[i][j] + cum[k][k] - cum[i][k] - cum[k][j]
        score2 = cum[k][k] - score1
        maxscore = max(maxscore, initscore + max(score1, score2))
print(maxscore)

Fixed submission:
n, k = map(int, input().split())
favor = [tuple(input().split()) for _ in range(n)]
square = [[0 for _ in range(k)] for _ in range(k)]
initscore = 0
for xc, yc, c in favor:
    x = int(xc)
    y = int(yc)
    x %= 2*k
    y %= 2*k
    if (x in range(k) and y in range(k)) or (x in range(k, 2*k) and y in range(k, 2*k)):
        if c == 'B':
            square[x%k][y%k] += 1
        else:
            square[x%k][y%k] -= 1
            initscore += 1
    else:
        if c == 'B':
            square[x%k][y%k] -= 1
            initscore += 1
        else:
            square[x%k][y%k] += 1
cum = [[0 for _ in range(k+1)] for _ in range(k+1)]
for i in range(k):
    for j in range(k):
        cum[i+1][j+1] = cum[i+1][j] + cum[i][j+1] - cum[i][j] + square[i][j]
maxscore = 0
for i in range(k):
    for j in range(k):
        score = cum[i][k] + cum[k][j] - 2*cum[i][j]
        maxscore = max(maxscore, max(cum[k][k] - score, score))
print(maxscore + initscore)
Buggy python submission (verdict: Runtime Error):
n, h = map(int, input().split())
katana = [tuple(map(int, input().split())) for _ in range(n)]
maxa = 0
for a, _ in katana:
    maxa = max(maxa, a)
bgreedy = 0
count = 0
katana.sort(lambda x: x[1], reverse = True)
for a, b in katana:
    if b < maxa:
        break
    bgreedy += b
    count += 1
    if h <= bgreedy:
        print(count)
        exit()
print(count + (h - bgreedy)//maxa + int((h-bgreedy) % maxa != 0))

Fixed submission:
n, h = map(int, input().split())
katana = [tuple(map(int, input().split())) for _ in range(n)]
maxa = 0
for a, _ in katana:
    maxa = max(maxa, a)
bgreedy = 0
count = 0
katana.sort(key = lambda x: x[1], reverse = True)
for a, b in katana:
    if b < maxa:
        break
    bgreedy += b
    count += 1
    if h <= bgreedy:
        print(count)
        exit()
print(count + (h - bgreedy)//maxa + int((h-bgreedy) % maxa != 0))
Buggy python submission (verdict: Time Limit Exceeded):
n, m, r = map(int, input().split())
v = list(map(int, input().split()))

inf = 10 ** 18
d = [[inf for _ in range(n)] for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

import itertools
ans = 10 ** 18
for a in itertools.permutations(v):
    dis = 0
    for i in range(r-1):
        dis += d[a[i+1]-1][a[i]-1]
    ans = min(ans, dis)
print(ans)

Fixed submission:
n, m, r = map(int, input().split())
v = list(map(int, input().split()))

inf = 10 ** 18
d = [[inf for _ in range(n)] for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

import itertools
ans = 10 ** 18
for a in itertools.permutations(v):
    dis = 0
    for i in range(r-1):
        dis += d[a[i+1]-1][a[i]-1]
    ans = min(ans, dis)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, m, r = map(int, input().split())
distination = set(map(int, input().split()))
inf = 10 ** 9
d = [[inf for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
for i in range(n):
    for j in range(n):
        for k in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = inf
for p in itertools.permutations(distination):
    cost = 0
    for i in range(r-1):
        cost += d[p[i]-1][p[i+1]-1]
    ans = min(ans, cost)
print(ans)

Fixed submission:
n, m, r = map(int, input().split())
v = list(map(int, input().split()))

inf = 10 ** 18
d = [[inf for _ in range(n)] for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

import itertools
ans = 10 ** 18
for a in itertools.permutations(v):
    dis = 0
    for i in range(r-1):
        dis += d[a[i+1]-1][a[i]-1]
    ans = min(ans, dis)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if p[i] == i+1:
        print(p)
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
if p[-1] == n:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
if p[n-1] == n:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [input() for _ in range(2)]
if n == 1:
    print(3)
    exit()
law = 10 ** 9 + 7
dp = [[0 for _ in range(2)] for _ in range(n)] # 直前の色と同じかどうか
dp[0][0] = 3
dp[0][1] = 0
dp[1][0] = 0
dp[1][1] = 6
sideway = s[0][1] == s[0][2]
for i in range(2, n):
    if sideway:
        sideway = False
        if s[0][i-2] == s[1][i-2]: # |=
            dp[i][0] = 0
            dp[i][1] = sum(dp[i-1])
        else: # ==
            dp[i][0] = 0
            dp[i][1] = dp[i-1][0] * 2 + dp[i-1][1]
    else:
        if s[0][i] == s[1][i]:
            sideway = False
            if s[0][i-1] == s[1][i-1]: # ||
                dp[i][0] = 0
                dp[i][1] = sum(dp[i-1]) * 2
            else: # =|
                dp[i][0] = 0
                dp[i][1] = sum(dp[i-1])
        else:
            sideway = True
            if s[0][i-1] == s[1][i-1]: # |-
                dp[i][0] = 0
                dp[i][1] = sum(dp[i-1]) * 2
            else: # =-
                dp[i][0] = sum(dp[i-1])
                dp[i][1] = 2 * sum(dp[i-2]) - dp[i][0]
    dp[i][0] %= law
    dp[i][1] %= law
print(sum(dp[i-1]))

Fixed submission:
n = int(input())
s = [input() for _ in range(2)]

ans = 1
law = 10 ** 9 + 7

i = 0
while i < n:
    if s[0][i] == s[1][i]:
        if i == 0:
            ans *= 3
        else:
            ans *= 3 - len({s[0][i-1], s[1][i-1]})
        i += 1
    else:
        if i == 0:
            ans *= 6
        else:
            if s[0][i-1] == s[1][i-1]:
                ans *= 2
            else:
                ans *= 3
        i += 2
    ans %= law
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10 ** 9 + 7
def extGCD(a, b):
    if b == 0:
        return a, 1, 0
    g, y, x = extGCD(b, a%b)
    y -= a//b * x
    return g, x, y

def moddiv(a, b):
    _, inv, _ = extGCD(b, mod)
    return (a * inv) % mod

N = 10 ** 5 + 10
fact = [0] * (N)
fact[0] = 1
for i in range(1, N):
    fact[i] = (fact[i-1] * i) % mod

def comb(a, b):
    return moddiv(moddiv(fact[a], fact[a-b]), fact[b])

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

searched = set()
for dup, x in enumerate(a):
    if x in searched:
        break
    else:
        searched.add(x)
first = a.index(a[dup])

for k in range(1, n+2):
    ans = comb(n+1, k)
    if k - 1 <= n - dup + first:
        ans -= comb(n - dup + first, k - 1)
    print(ans % mod)

Fixed submission:
mod = 10 ** 9 + 7
def extGCD(a, b):
    if b == 0:
        return a, 1, 0
    g, y, x = extGCD(b, a%b)
    y -= a//b * x
    return g, x, y

def moddiv(a, b):
    _, inv, _ = extGCD(b, mod)
    return (a * inv) % mod

N = 10 ** 5 + 10
fact = [0] * (N)
fact[0] = 1
for i in range(1, N):
    fact[i] = (fact[i-1] * i) % mod

def comb(a, b):
    return moddiv(moddiv(fact[a], fact[a-b]), fact[b])

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

searched = set()
for dup, x in enumerate(a):
    if x in searched:
        break
    else:
        searched.add(x)
first = a.index(a[dup])

for k in range(1, n+2):
    ans = comb(n+1, k)
    if k - 1 <= n - dup + first:
        ans -= comb(n - dup + first, k - 1)
    print(ans % mod)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

inf = 10 ** 18
dis = [inf] * n
dis[0] = 0

for z in range(n+1)
    update = False
    for a, b, c in edge:
        a -= 1
        b -= 1
        if dis[a] != inf and dis[b] > dis[a] - c:
            dis[b] = dis[a] - c
            update = True
            if z == n:
                print('inf')
                exit()
print(-dis[n-1])

Fixed submission:
n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

inf = 10 ** 18
dis = [inf] * n
dis[0] = 0

for z in range(2*n+1):
    update = False
    for a, b, c in edge:
        a -= 1
        b -= 1
        if dis[a] != inf and dis[b] > dis[a] - c:
            dis[b] = dis[a] - c
            update = True
            if b == n - 1 and z >= n - 1:
                print('inf')
                exit()
print(-dis[n-1])

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

inf = 10 ** 18
dis = [inf] * n
dis[0] = 0

for z in range(n+1):
    update = False
    for a, b, c in edge:
        a -= 1
        a -= 1
        if dis[a] != inf and dis[b] > dis[a] - c:
            dis[b] = dis[a] - c
            update = True
    if not update:
        break

if z == n:
    print('inf')
else:
    print(-dis[n-1])

Fixed submission:
n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

inf = 10 ** 18
dis = [inf] * n
dis[0] = 0

for z in range(2*n+1):
    update = False
    for a, b, c in edge:
        a -= 1
        b -= 1
        if dis[a] != inf and dis[b] > dis[a] - c:
            dis[b] = dis[a] - c
            update = True
            if b == n - 1 and z >= n - 1:
                print('inf')
                exit()
print(-dis[n-1])
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if b - a == c - b:
    print('YES')
else: prin('NO')

Fixed submission:
a, b, c = map(int, input().split())
if b - a == c - b:
    print('YES')
else: print('NO')
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(max(a*b, c*d))

Fixed submission:
a, b, c, d = map(int, input().split())
print(max(a*b, c*d))
Buggy python submission (verdict: Runtime Error):
h, w, n = map(int, input().split())
a = {tuple(map(int, input().split())) for _ in range(n)}

d = {}
c = [0] * 9

def next(x, y):
    ret = []
    for i in range(max(0, x-2), min(h-2, x+1)):
        for j in range(max(0, y-2), min(w-2, y+1)):
            ret.append((i, j))
    return ret

for x, y in a:
    x -= 1
    y -= 1
    for s, t in next(x, y):
        if (s, t) not in d:
            count = 0
            for i in range(3):
                for j in range(3):
                    if (s + i + 1, t + j + 1) in a:
                        count += 1
            d[(s, t)] = count
            c[count] += 1

c[0] = (h-2) * (w-2) - sum(c)

for x in c:
    print(x)

Fixed submission:
h, w, n = map(int, input().split())
a = {tuple(map(int, input().split())) for _ in range(n)}

d = {}
c = [0] * 10

def next(x, y):
    ret = []
    for i in range(max(0, x-2), min(h-2, x+1)):
        for j in range(max(0, y-2), min(w-2, y+1)):
            ret.append((i, j))
    return ret

for x, y in a:
    x -= 1
    y -= 1
    for s, t in next(x, y):
        if (s, t) not in d:
            count = 0
            for i in range(3):
                for j in range(3):
                    if (s + i + 1, t + j + 1) in a:
                        count += 1
            d[(s, t)] = count
            c[count] += 1

c[0] = (h-2) * (w-2) - sum(c)

for x in c:
    print(x)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
c,d==map(int,input().split())
e=int(input())
if abs(a-c)>e*abs(b-d):
  print('YES')
else:
  print('NO')

Fixed submission:
a,b=map(int,input().split())
c,d=map(int,input().split())
e=int(input())
if abs(a-c)<=e*(b-d):
  print('YES')
else:
  print('NO')