Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
count,total = list(map(int,input().split()))
ret1 = -1
ret2 = -1
ret3 = -1
NF = True
if total <= count * 10000:
	for i in range(count + 1):
		rCount = count - i
		if total-10000*i <= rCount * 5000:
			for j in range(rCount + 1):
				if (i*10000 + j*5000 + (count-i-j)*1000) == total:
					ret1 = i
					ret2 = j
					ret3 = count-i-j
                    NF = False
				break
if NF:
  ret1 = -1
  ret2 = -1
  ret3 = -1
print(str(ret1) + " " + str(ret2) + " " + str(ret3))

Fixed submission:
count,total = list(map(int,input().split()))
ret1 = -1
ret2 = -1
ret3 = -1
NF = True
if total <= count * 10000:
	for i in range(count + 1):
		rCount = count - i
		if total-10000*i <= rCount * 5000:
			for j in range(rCount + 1):
				if (i*10000 + j*5000 + (count-i-j)*1000) == total:
					ret1 = i
					ret2 = j
					ret3 = count-i-j
					NF = False
					break
if NF:
	ret1 = -1
	ret2 = -1
	ret3 = -1
print(str(ret1) + " " + str(ret2) + " " + str(ret3))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = 1
wari = 10**9+7
for i in range( 1,n + 1):
	p  *= i
print(str(p%wari))

Fixed submission:
n = int(input())
p = 1
wari = 10**9+7
for i in range( 1,n + 1):
	p  = (p*i)%wari
print(str(p%wari))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())

print(len([None for i in range(a, b+1) if not i%x]))

Fixed submission:
a, b, x = map(int, input().split())

B = b // x
A = (a - 1) // x

print(B - A)
Buggy python submission (verdict: Time Limit Exceeded):
#くじ引き

import numpy
import re
import math

def calc_max_num(int_list):
	"""
	listから最大操作回数を算出
	:param int_list:
	:return:
	"""
	count = 0
	even_flag = False
	while True:
		for i in int_list:
			if i % 2 == 1:
				even_flag = True
		if even_flag is True:
			break
		else:
			for i in int_list:
				i /= 2
			count += 1
	return count


def main():
	"""
	テストコード実行
	:return:
	"""
	line = input()
	int_num = int(line)
	line = input()
	line_list = re.split(" +", line)
	int_list = [int(s) for s in line_list]
	print(calc_max_num(int_list))


if __name__ == '__main__':
	main()


Fixed submission:
#くじ引き

import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	n = input()
	a = list(map(int, input().split()))
	ans = float("inf") #無限大を挿入
	for i in a:
		# 2値で変換した際の右に並ぶ0の数が2で割ることのできる回数
		# rfindで1の値を持つ最大インデックスを求め、その分だけ引く
		# 計算した回数の最小値を求める
		ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
	print(round(ans))

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):

if __name__ == "__main__":
  input1 = input()
  input2 = input()

  print (input1*input1 - input2)



Fixed submission:

input1 = int(input())
input2 = int(input())

print (input1*input1 - input2)

Buggy python submission (verdict: Runtime Error):

input1 = input()
input2 = input()

print (input1*input1 - input2)


Fixed submission:

input1 = int(input())
input2 = int(input())

print (input1*input1 - input2)
Buggy python submission (verdict: Runtime Error):
moji = {a: b for a, b in zip("abcdefghijklmnopqrstuvwxyz", range(26))}

s = list(raw_input())
k = int(raw_input())

for i, e in enumerate(s):
    if 26 - moji[e] <= k:
        s[i] = "a"
        k -= 26 - moji[e]

k = k % 26 if k >= 0 else 0
if k != 0:
    s[-1] = "abcdefghijklmnopqrstuvwxyz"[(moji[s[-1]] + k) % 26]

print "".join(s)


Fixed submission:
s = raw_input()
print s[:4], s[4:]
Buggy python submission (verdict: Runtime Error):
import sys                        
n = raw_input()
num = n.count('o')
print(700+(num*100))

Fixed submission:
import sys                        
n = input()
num = n.count('o')
print(700+(num*100))
Buggy python submission (verdict: Runtime Error):
n, x=[int(i) for i in input().split()]

m = [None for i in range(n)]

for i in range(n):
    m[i] = int(input())

# print(n, x, m)

# print(sum(m), min(m))

cnt = n

x -= sum(m)

cnt += x // min(m)

print(cnt)
n, x=[int(i) for i in input().split()]

m = [None for i in range(n)]

for i in range(n):
    m[i] = int(input())

# print(n, x, m)

# print(sum(m), min(m))

cnt = n

x -= sum(m)

cnt += x // min(m)

print(cnt)


Fixed submission:
n, x=[int(i) for i in input().split()]

m = [None for i in range(n)]

for i in range(n):
    m[i] = int(input())

cnt = n
x -= sum(m)
cnt += x // min(m)

print(cnt)
Buggy python submission (verdict: Runtime Error):
 s = input()

alp = [chr(i) for i in range(97, 97+26)]

flag = [False for i in range(26)]

for c in s:
    for i in range(26):
        if c == alp[i]:
            flag[i] = True


def pr():
    for i in range(26):
        if flag[i] == False:
            return alp[i]

    return 'None'

print(pr())


Fixed submission:
s = input()

alp = [chr(i) for i in range(97, 97+26)]

flag = [False for i in range(26)]

for c in s:
    flag[ord(c) - ord("a")] = True


def pr():
    for i in range(26):
        if not flag[i]:
            print(alp[i])
            return

    print('None')
    return

pr()
Buggy python submission (verdict: Runtime Error):
a, b, c = [int(i) for i in input().split()]

if a > b:
  swap(a, b)

if b > c:
  swap(b, c)

if a > b:
  swap(a, b)

print(a+b)


Fixed submission:
a, b, c = [int(i) for i in input().split()]

if a > b:
  a, b = b, a

if b > c:
  b, c = c, b

if a > b:
  a, b = b, a

print(a+b)
Buggy python submission (verdict: Runtime Error):
n, m = input().split()
n = int(n)
m = int(m)
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

s = 0

map = [[0 for i in range(n)] for j in range(m)]

yokomap = [0] * n
tatemap = [0] * m

for i in range(n-1):
    for j in range(m-1):
        yokomap = (i+1) * (n-1-i)
        tatemap = (j+1) * (m-1-j)
        map[i][j] = yokomap * tatemap

for i in range(n-1):
    for j in range(m-1):
        yoko = x[i+1] - x[i]
        tate = y[j+1] - y[j]
        s += yoko * tate * map[i][j]
        s %= (10**9 + 7)


print(s)


Fixed submission:
n, m = input().split()
n = int(n)
m = int(m)
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

def sum(a, n):
    sum_a = 0
    for i in range(0, n):
        sum_a += i * a[i] - (n-1-i) * a[i]
    return sum_a

sum_x = sum(x,n)
sum_y = sum(y,m)

s = sum_x * sum_y % (10**9 + 7)

print(s)

Buggy python submission (verdict: Runtime Error):
n, m = input().split()
n = int(n)
m = int(m)
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

s = 0

map = [[0 for i in range(n)] for j in range(m)]

yokomap = [0] * n
tatemap = [0] * m

for i in range(n-1):
    for j in range(m-1):
        yokomap = (i+1) * (n-1-i)
        tatemap = (j+1) * (m-1-j)
        map[i][j] = yokomap * tatemap

for i in range(n-1):
    for j in range(m-1):
        yoko = x[i+1] - x[i]
        tate = y[j+1] - y[j]
        s += yoko * tate * map[i][j]

s %= (10**9 + 7)

print(s)

Fixed submission:
n, m = input().split()
n = int(n)
m = int(m)
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

def sum(a, n):
    sum_a = 0
    for i in range(0, n):
        sum_a += i * a[i] - (n-1-i) * a[i]
    return sum_a

sum_x = sum(x,n)
sum_y = sum(y,m)

s = sum_x * sum_y % (10**9 + 7)

print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = input().split()
n = int(n)
m = int(m)
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

s = 0

for i in range(n-1):
    for j in range(i+1, n):
        for k in range(m-1):
            for l in range(k+1,m):
                tate = x[j] - x[i]
                yoko = y[l] - y[k]
                s += tate * yoko

s %= (10**9 + 7)

print(s)


Fixed submission:
n, m = input().split()
n = int(n)
m = int(m)
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

def sum(a, n):
    sum_a = 0
    for i in range(0, n):
        sum_a += i * a[i] - (n-1-i) * a[i]
    return sum_a

sum_x = sum(x,n)
sum_y = sum(y,m)

s = sum_x * sum_y % (10**9 + 7)

print(s)
Buggy python submission (verdict: Runtime Error):
W, a, b = [int(i) for i in input().split()]

if a > b:
    a, b = b, a

print(b-(a+W))


Fixed submission:
a,b = input().split()

if (a == 'H' and b == 'H') or (a == 'D' and b == 'D'):
    print('H')
else:
    print('D')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())


power = 1

for i in range(1,n+1):
    power *= i

print(power%(10**9+7))


Fixed submission:
n = int(input())


power = 1

for i in range(1,n+1):
    power *= i
    if power > (10**9+7):
        power %= (10**9+7)

print(power)
Buggy python submission (verdict: Runtime Error):
s = input()

# t = ['dream', 'dreamer', 'erase', 'eraser']

s = s[::-1]
for i in range(4):
    t[i] = t[i][::-1]

# print(s,t)

tmp = s

while tmp != '':
    d = tmp[:5] == 'maerd'
    dr = tmp[:7] == 'remaerd'
    e = tmp[:5] == 'esare'
    er = tmp[:6] == 'resare'
    # print(tmp[:5])
    # print(d,dr,e,er)

    if d:
        tmp = tmp[5:]
    elif e:
        tmp = tmp[5:]
    elif dr:
        tmp = tmp[7:]
    elif er:
        tmp = tmp[6:]
    else:
        print('NO')
        break

if tmp == '':
    print('YES')


Fixed submission:
s = input()

# t = ['dream', 'dreamer', 'erase', 'eraser']

s = s[::-1]
# for i in range(4):
#     t[i] = t[i][::-1]

# print(s,t)

tmp = s

while tmp != '':
    d = tmp[:5] == 'maerd'
    dr = tmp[:7] == 'remaerd'
    e = tmp[:5] == 'esare'
    er = tmp[:6] == 'resare'
    # print(tmp[:5])
    # print(d,dr,e,er)

    if d:
        tmp = tmp[5:]
    elif e:
        tmp = tmp[5:]
    elif dr:
        tmp = tmp[7:]
    elif er:
        tmp = tmp[6:]
    else:
        print('NO')
        break

if tmp == '':
    print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))
ans = 0
a,b = 0,0
lst2=[0]

for i in range(n):
    lst2.append(lst2[-1]+lst[i])

temp = set()

for i in range(n):
    l = lst2.count(i)
    if l > 1 and i not in temp:
        temp.add(i)
        ans += l*(l-1)//2
print(ans)


"""
6
1 3 -4 2 2 -2


7
1 -1 1 -1 1 -1 1

5
1 -2 3 -4 5


0 0 0 0 0
"""

Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
ans = 0
a,b = 0,0
lst2=[0]
d = {0:1}
for i in range(n):
    s = lst2[-1]+lst[i]
    lst2.append(s)
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1

temp = set()

for i in d:
    l = d[i]
    if l > 1 and i not in temp:
        temp.add(i)
        ans += l*(l-1)//2
print(ans)


"""
6
1 3 -4 2 2 -2


7
1 -1 1 -1 1 -1 1

5
1 -2 3 -4 5


0 0 0 0 0
"""

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))
ans = 0
a,b = 0,0
lst2=[0]
for i in range(n):
    lst2.append(sum(lst[:i+1]))

temp = set()

for i in range(n):
    l = lst2.count(i)
    if l > 1 and i not in temp:
        temp.add(i)
        ans += l*(l-1)//2
print(ans)


"""
6
1 3 -4 2 2 -2


7
1 -1 1 -1 1 -1 1

5
1 -2 3 -4 5


0 0 0 0 0
"""

Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
ans = 0
a,b = 0,0
lst2=[0]
d = {0:1}
for i in range(n):
    s = lst2[-1]+lst[i]
    lst2.append(s)
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1

temp = set()

for i in d:
    l = d[i]
    if l > 1 and i not in temp:
        temp.add(i)
        ans += l*(l-1)//2
print(ans)


"""
6
1 3 -4 2 2 -2


7
1 -1 1 -1 1 -1 1

5
1 -2 3 -4 5


0 0 0 0 0
"""

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
lst = list(map(int, input().split()))
ans = 0
a,b = 0,0
lst2=[0]
for i in range(n):
    lst2.append(sum(lst[:i+1]))

temp = []
for i in range(n):
    if lst2.count(i) > 1 and i not in temp:
        temp.append(i)
        ans += lst2.count(i)*(lst2.count(i)-1)//2
print(ans)


"""
6
1 3 -4 2 2 -2


7
1 -1 1 -1 1 -1 1

5
1 -2 3 -4 5


0 0 0 0 0
"""

Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
ans = 0
a,b = 0,0
lst2=[0]
d = {0:1}
for i in range(n):
    s = lst2[-1]+lst[i]
    lst2.append(s)
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1

temp = set()

for i in d:
    l = d[i]
    if l > 1 and i not in temp:
        temp.add(i)
        ans += l*(l-1)//2
print(ans)


"""
6
1 3 -4 2 2 -2


7
1 -1 1 -1 1 -1 1

5
1 -2 3 -4 5


0 0 0 0 0
"""
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
d = {i: {chr(i): 0 for i in range(ord('a'), ord('z')+1)} for i in range(n)}
d2 = {i: {chr(i): 0 for i in range(ord('a'), ord('z')+1)} for i in range(m)}
for i in range(n):
    s = input()
    for j in s:
        d[i][j] += 1
    for j in range(len(s)):
        d2[j][s[j]] += 1

k = [0 for i in range(n)]
k2 = [0 for i in range(m)]

f = True
for i in range(n):
    for j in range(n):
        if d[i] == d[j]:
            k[i] += 1


for i in range(m):
    for j in range(m):
        if d2[i] == d2[j]:
            k2[i] += 1

k2 = sorted(k2)
k = sorted(k)
if n % 2:
    if len(k) > 1:
        if k[1] < 2:
            f = False
else:
    if k[0] < 2:
        f = False

if m % 2:
    if len(k) > 1:
        if k2[1] < 2:
            f = False
else:
    if k2[0] < 2:
        f = False

if f:
    print('YES')
else:
    print('NO')

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

m1 = l[n//2 - 1]
m2 = l[n//2]
for i in range(len(l0)):
    if l0[i] < m2:
        print(m2)
    elif l0[i] > m1:
        print(m1)
    elif l0[i] == m1:
        print(m2)
    elif l0[i] == m2:
        print(m1)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
l0 = list(map(int, input().split()))
mini = max(l0) + 1
maxii = 0
for i in l0:
    if i != max(l0) and (abs(max(l0)/2 - i)) < mini:
        mini = max(l0)/2 - i
        maxii = i

print(max(l0), maxii)

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

l0 = sorted(l0)
m = l0.pop()

mini = m + 1
maxii = 0
ans = 0
for i in range(len(l0)):
    if l0[i] < m/2:
        ipred = l0[i]
        continue
    if abs((m/2 - l0[i-1])) >= abs((m/2 - l0[i])):
        ans = m, l0[i]
    else:
        ans = m, l0[i-1]
    break

if not ans:
    print(m, ipred)
else:
    for i in ans:
        print(i, end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
l0 = list(map(int, input().split()))
mini = math.factorial(max(l0))
maxii = 0
for i in l0:
    if i != max(l0) and math.factorial(max(l0)-i)*math.factorial(i) < mini:
        mini = math.factorial(max(l0)-i)*math.factorial(i)
        maxii = i

print(max(l0), maxii)

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

l0 = sorted(l0)
m = l0.pop()

mini = m + 1
maxii = 0
ans = 0
for i in range(len(l0)):
    if l0[i] < m/2:
        ipred = l0[i]
        continue
    if abs((m/2 - l0[i-1])) >= abs((m/2 - l0[i])):
        ans = m, l0[i]
    else:
        ans = m, l0[i-1]
    break

if not ans:
    print(m, ipred)
else:
    for i in ans:
        print(i, end=' ')
Buggy python submission (verdict: Runtime Error):
import math

def slv(A, B):
    A, B = (A, B) if A > B else (B, A)
    
    s = A * B
    c = math.floor(math.sqrt(A * B))
    
    if A == B:
        return 2 * c - 2
    elif c * c < s:
        return 2 * c - 2
    elif c * (c - 1) < s:
        return 2 * c - 3

Q = int(input())
for q in range(Q):
    A, B = map(int, input().split())
    print(slv(A, B))

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

lst.sort()

mini = lst[0]
av = lst[1]
max = lst[2]

d = max - av
ans1 = 0
mini += d
d2 = max - mini

if d2 % 2:
    d2 = (d2 + 1) // 2
    ans1 += 1

else:
    d2 = d2 // 2

ans1 += d + d2

ans2 = 0
mini = lst[0]
av = lst[1]
max = lst[2]

d = max - av

mini += d

d2 = max + 1 - mini

if d2 % 2:
    d2 = (d2 + 1) // 2
    ans2 += 1
else:
    d2 = d2 // 2

ans2 += d + d2 + 1

print(min(ans1, ans2))
Buggy python submission (verdict: Runtime Error):
n = raw_input()
print (n*(n-1)/2)


Fixed submission:
n = int(raw_input())
print (n*(n+1)/2)
Buggy python submission (verdict: Runtime Error):
import copy
n = int(input())
N = int(n/2-1)
x = list(map(int, input().split()))
y = sorted(x)

for i in range(n):
    Y  = copy.deepcopy(y)
    Y.remove(x[i])
    print(Y[N)


Fixed submission:
a, b, x = map(int, input().split())
if x<a: print('NO')
elif x>a+b: print('NO')
else:print('YES')

Buggy python submission (verdict: Runtime Error):
import copy
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)

for i in range(n):
    Y  = copy.deepcopy(y)
    Y.remove(x[i])
    print(Y[int(n/2 -1)])
  


Fixed submission:
a, b, x = map(int, input().split())
if x<a: print('NO')
elif x>a+b: print('NO')
else:print('YES')

Buggy python submission (verdict: Runtime Error):
import copy
n = int(input())
x = list(map(int, input().split()))

for i in range(n):
    x_in  = copy.deepcopy(x)
    del x_in[i]
    x_in.sort()
    print(x_in[int(n/2 -1)])
    x_in  = []


Fixed submission:
a, b, x = map(int, input().split())
if x<a: print('NO')
elif x>a+b: print('NO')
else:print('YES')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = len(set(list(map(int,[input for i in range(n)]))))
print(a)

Fixed submission:
n = int(input())
a = len(set(list(map(int,[input() for i in range(n)]))))
print(a)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
ans = 0
for i in range(n):
    if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += 1
print(ans)

Fixed submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
ans = float('inf')
for i in a:
    ans = min(ans, len(bin(i) - bin(i).rfind('1') - 1)
print(round(ans))


Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = float('inf')
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind('1') - 1)
print(round(ans))

Buggy python submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
ans = float('inf')
for i in a:
    ans = min(ans, len(bin(i) - bin(i).rfind('1') - 1)
print(round(ans))


Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = float('inf')
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind('1') - 1)
print(round(ans))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")
    

Fixed submission:
a, b, c = input().split()

res = "".join([a[0].upper(), b[0].upper(), c[0].upper()])
print(res)

Buggy python submission (verdict: Runtime Error):
a, b, c = input().split()

res = "".join([a[0].upper(), b[0].upper(), c[0].upper()])
print(res

Fixed submission:
a, b, c = input().split()

res = "".join([a[0].upper(), b[0].upper(), c[0].upper()])
print(res)
Buggy python submission (verdict: Runtime Error):
# 入力
n = int(input())
loc_list = []
for _ in range(n):
  loc_list.append(list(map(int, input().split())))

# 処理
ans = True
prev_loc = [0, 0, 0]
for loc in loc_list:
  # 現在の位置から次の位置へ移動可能かどうかを判定
  if not movable(prev_loc, loc):
    ans = False
    break
  prev_loc = loc

if ans:
  print("Yes")
else:
  print("No")
  
# 動けるかどうかの判定
def movable(prev_loc, loc):
  dt = loc[0] - prev_loc[0]
  dx = abs(loc[1] - prev_loc[1])
  dy = abs(loc[2] - prev_loc[2])
  # 時間内に届かない
  if dx + dy > dt:
    return False
  if dx + dy % 2 == dt % 2:
    return True
  else:
    return False
  
  

Fixed submission:
# 動けるかどうかの判定
def movable(prev_loc, loc):
  dt = loc[0] - prev_loc[0]
  dx = abs(loc[1] - prev_loc[1])
  dy = abs(loc[2] - prev_loc[2])
  # 時間内に届かない
  if dx + dy > dt:
    return False
  if (dx + dy) % 2 == dt % 2:
    return True
  else:
    return False

# 入力
n = int(input())
loc_list = []
for _ in range(n):
  loc_list.append(list(map(int, input().split())))

# 処理
ans = True
prev_loc = [0, 0, 0]
for loc in loc_list:
  # 現在の位置から次の位置へ移動可能かどうかを判定
  if not movable(prev_loc, loc):
    ans = False
    break
  prev_loc = loc

if ans:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=[]
for i in [0]*n:
    d.append([int(x) for x in input().split()])
from itertools import product
ans=0
for i,j in product(range(n),range(n)):
    flag=0
    for k in range(n):
        if d[i][j]>d[i][k]+d[k][j]:
            print(-1)
            import sys
            sys.exit()
        if d[i][j]==d[i][k]+d[k][j] and (k!=i and k!=j and i!=j ):
            flag=1
    if flag==0:
        ans+=d[i][j]
print(ans//2)

Fixed submission:
n=int(input())
d=[]
for i in [0]*n:
    d.append([int(x) for x in input().split()])
from itertools import product
ans=0
for i,j in product(range(n),range(n)):
    flag=0
    for k in range(n):
        if d[i][j]>d[i][k]+d[k][j]:
            print(-1)
            import sys
            sys.exit()
        if d[i][j]==d[i][k]+d[k][j] and (k!=i and k!=j and i!=j ):
            flag=1
    if flag==0:
        ans+=d[i][j]
print(ans//2)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,R=[int(x) for x in input().split()]
r=[int(x) -1 for x in input().split()]
d=[[float("inf") for _ in [0]*n] for _ in [0]*n]
for i in range(n):
    d[i][i]=0
path=[]
for i in [0]*m:
    a,b,c=[int(x) for x in input().split()]
    d[a-1][b-1]=d[b-1][a-1]=c
    path.append(a-1)
    path.append(b-1)
path=set(path)
from itertools import permutations
def Long(args):
    ans=0
    c=0
    tmp=[]
    for i in args:
        tmp.append(i)
        if i in r:
            c+=1
        if c==len(r):
            break
    args=tmp
    for i in range(len(args)-1):
        if ans==float("inf"):
            return ans
        ans+=d[args[i+1]][args[i]]
    return ans
print(min(Long(i) for i in permutations(path)))

Fixed submission:
n,m,R=[int(x) for x in input().split()]
r=[int(x) -1 for x in input().split()]
d=[[float("inf") for _ in [0]*n] for _ in [0]*n]
for i in range(n):
    d[i][i]=0
for i in [0]*m:
    a,b,c=[int(x) for x in input().split()]
    d[a-1][b-1]=d[b-1][a-1]=c
from itertools import product,permutations
for k,i,j in product(range(n),range(n),range(n)):
    if d[i][j] >d[i][k]+d[k][j]:
        d[i][j]=d[i][k]+d[k][j]
def Long(args):
    ans=0
    for i in range(len(args)-1):
        ans+=d[args[i+1]][args[i]]
    return ans
print(min(Long(i) for i in permutations(r)))

Buggy python submission (verdict: Time Limit Exceeded):
n,m,R=[int(x) for x in input().split()]
r=[int(x) -1 for x in input().split()]
d=[[float("inf") for _ in [0]*n] for _ in [0]*n]
for i in range(n):
    d[i][i]=0
for i in [0]*m:
    a,b,c=[int(x) for x in input().split()]
    d[a-1][b-1]=d[b-1][a-1]=c
from itertools import permutations
def Long(args):
    ans=0
    c=0
    tmp=[]
    for i in args:
        tmp.append(i)
        if i in r:
            c+=1
        if c==len(r):
            break
    args=tmp
    for i in range(len(args)-1):
        if ans==float("inf"):
            return ans
        ans+=d[args[i+1]][args[i]]
    return ans
print(min(Long(i) for i in permutations(range(n))))

Fixed submission:
n,m,R=[int(x) for x in input().split()]
r=[int(x) -1 for x in input().split()]
d=[[float("inf") for _ in [0]*n] for _ in [0]*n]
for i in range(n):
    d[i][i]=0
for i in [0]*m:
    a,b,c=[int(x) for x in input().split()]
    d[a-1][b-1]=d[b-1][a-1]=c
from itertools import product,permutations
for k,i,j in product(range(n),range(n),range(n)):
    if d[i][j] >d[i][k]+d[k][j]:
        d[i][j]=d[i][k]+d[k][j]
def Long(args):
    ans=0
    for i in range(len(args)-1):
        ans+=d[args[i+1]][args[i]]
    return ans
print(min(Long(i) for i in permutations(r)))
Buggy python submission (verdict: Runtime Error):
x,t=[int(x) for x in input().split()]
print(max(0,x-t)

Fixed submission:
x,t=[int(x) for x in input().split()]
print(max(0,x-t))