Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
s = sorted(set(int(an.split())))
print(sum(s))


Fixed submission:
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
s = sorted(set(map(int, an.split())))
print(s[-1] - s[0])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
s = sorted(set(an.split()))
print(sum(s))


Fixed submission:
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
s = sorted(set(map(int, an.split())))
print(s[-1] - s[0])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()

s = set(sorted(an.split()))
print(sum(s))


Fixed submission:
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
s = sorted(set(map(int, an.split())))
print(s[-1] - s[0])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
lit = sorted(map(int, an.split()))
color = {}

for i in range(400, 3199, 399):
    color[i] = filter(lambda x: i-400 < x <i , lit)
color[3200] = filter(lambda x: x>=3200, lit)

c = len(color)
if color.has_key(3200):
    c -= - 1

if c >= 8:
    print('8 8')
else:
    rainbow = len(color[3200])
    mini = c
    c += rainbow
    maxi = 8 if c >= 8 else c
    print('{} {}'.format(mini, maxi))


Fixed submission:
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
lit = sorted(map(int, an.split()))
color = {}

for i in range(400, 3201, 400):
    color[i] = list(filter(lambda x: i-400 <= x <i , lit))
rainbow = list(filter(lambda x: x>=3200, lit))
label = 0

for v in color.values():
    if len(v) != 0:
        label += 1
        
if label == 0 and len(rainbow) > 0:
    print('1 {}'.format(len(rainbow)))
else:
    print('{} {}'.format(label, label + len(rainbow)))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N = input()
S = input()

res = ''
left, right = 0, 0
lit = S.split(')(')
for i, l in enumerate(lit):
    if len(lit) > 1:
        kakko = l + ')' if i % 2 == 0 else '(' + l
    j = 0
    while True:
        if len(kakko)-1 < j:
            break
        if kakko[j] == '(':
            if len(kakko) - 2 > j:
                if kakko[j+1] == ')':
                    res += '()'
                    j += 2
                else:
                    left += 1
                    j += 1
            else:
                left += 1
                j += 1
        else:
            if left != 0:
                left -= 1
            res = '(' + res + ')'
            j += 1
    part = '(' * left + ')' * left
    res  += part
print(res)


Fixed submission:
# -*- coding: utf-8 -*-
import sys, re

N = input()
S = input()
# pattern = re.compile(r'\)\(')
sentence = ''
left, right = 0, 0
# lit = []
for s in S:
    sentence += s
    if s == '(':
        left += 1
    else:
        right += 1
    if left - right < 0:
        sentence = '(' + sentence
        left += 1
if left - right > 0:
    sentence = sentence + ')' * (left - right)
print(sentence)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import sys, itertools

N = int(input())
Sn = sorted([int(input()) for i in range(N)])

total = sum(Sn)
if total % 10 != 0:
    print(total)
    sys.exit()

sub_set = set(Sn)
for i in range(2, N):
    comb = [sum(l) for l in itertools.combinations(Sn, i)]
    for c in comb:
        sub_set.add(c)

for sub in sorted(sub_set):
    if (total - sub) % 10 != 0:
        print(total - sub)
        break
else:
    print(0)


Fixed submission:
# -*- coding:utf-8 -*-

n = input()
n = n.split(' ')
res = int(n[0]) + int(n[1])
if res > 9:
    print('error')
else:
    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
import sys

N = int(input())
Sn = sorted([int(input()) for i in range(N)])
total = sum(Sn)
if total % 10 != 0:
    print(total)
    sys.exit()
else:
    i = 0
    while True:
        total -= Sn[i]
        if total % 10 != 0:
            print(total)
            sys.exit()

print(0)

Fixed submission:
# -*- coding:utf-8 -*-
import sys

N = int(input())
Sn = sorted([int(input()) for i in range(N)])
total = sum(Sn)
if total % 10 != 0:
    print(total)
    sys.exit()
else:
    i = 0
    while True:
        if (total - Sn[i]) % 10 != 0:
            print(total - Sn[i])
            sys.exit()
        i += 1
        if i == N:
            break
print(0)
Buggy python submission (verdict: Runtime Error):
def gcd (a,b):
    if b == 0:
        return a
        
    return gcd(b, a % b)

inp = input().split()
inp = [int(x) for x in inp]

p = input().split()
p = [int(x) for x in p]

ans = gcd(abs(inp[1]-p[0]), abs(inp[1]-p[1]))
for i in range(len(p)):
    ans = gcd(ans, abs(inp[1]-p[i]))

print(ans)

Fixed submission:
def gcd (a,b):
    if b == 0:
        return a
        
    return gcd(b, a % b)

inp = input().split()
inp = [int(x) for x in inp]

p = input().split()
p = [int(x) for x in p]

ans = gcd(abs(inp[1]-p[0]), abs(inp[1]-p[0]))
for i in range(len(p)):
    ans = gcd(ans, abs(inp[1]-p[i]))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
ans = []
inp = [int(x) for x in input().split()]

n = inp[0]
k = inp[1]

for a in range(1, n+1):
    for b in range(1, n+1):
        for c in range(1, n+1):
            if (a+b) % k == 0 and (b+c) % k == 0 and (c+a) % k == 0:
                ans.append([a, b, c])

print(len(ans))

Fixed submission:
inp = [int(x) for x in input().split()]
n = inp[0]
k = inp[1]

num = [x for x in range(0, n+1, k)]
ans = (len(num)-1) ** 3

if k % 2 == 0:
    c = 0
    for i in range(1, n+1):
        if i % k == k / 2:
             c += 1
    ans += c ** 3
    

print(ans)
Buggy python submission (verdict: Runtime Error):
test_cases = input()

for test_case in range(test_cases):
	A, B, C, D = map(int, raw_input().split(' '))

	last_take = max(1, (A - C + B - 1) // B)
	A -= last_take * B

	if A < 0 or B > D:
		print "No"
	elif B == D or B <= C: 
		print "Yes"
	else:
		printed = False

		for i in range(10000):
			x = (C - A) // (D - B) + 1
			A += (D - B) * x
			last_take = max(1, (A - C + B - 1) // B)
			A -= last_take * B

			if A < 0:
				print "No"
				printed = True
				break
			
		if printed is False:
			print "Yes"


Fixed submission:
N = input()

v = map(int, raw_input().split(' '))

found = 0

i = 0
while i < N:
	j = i
	while j < N - 1 and v[i] == v[j + 1]:
		j += 1

	found += (j - i + 1) / 2

	i = j + 1

print found
Buggy python submission (verdict: Runtime Error):
n = input()

v = map(int, raw_input().split(' '))

dict = {}

sum = 0

for i in range(n):
	sum += v[i]
	if sum not in dict:
		dict[sum] = 0

	dict[sum] += 1

res = 0

sum = 0

for i in v:
	res += dict[sum]
	sum += i
	dict[sum] -= 1

print res


Fixed submission:
n = input()

v = map(int, raw_input().split(' '))

dict = {}

sum = 0

for i in range(n):
	sum += v[i]
	if sum not in dict:
		dict[sum] = 0

	dict[sum] += 1

res = 0

sum = 0

if sum in dict:
	res += dict[sum]

sum += v[0]

for i in range(1, n):
	sum += v[i]
	dict[sum] -= 1
	res += dict[sum]

print res
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n = input()
v = map(int, raw_input().split(' '))

if sum(v) % ((n * (n + 1)) / 2) != 0:
	print "NO"
	sys.exit()

while sum(v) > 0:
	biggest, second_biggest = 0, 0
	for i in range(n):
		if v[i] > v[biggest]:
			second_biggest = biggest
			biggest = i
		elif v[i] > v[second_biggest]:
			second_biggest = i

	times = (v[biggest] - v[second_biggest] + n - 1) / n

	for i in range(biggest, -1, -1):
		v[i] -= n - (biggest - i)
	for i in range(biggest + 1, n):
		v[i] -= i - biggest

	if min(v) < 0:
		print "NO"
		sys.exit()

if sum(v) == 0:
	print "YES"
else:
	print "NO"

Fixed submission:
import sys

n = input()
v = map(int, raw_input().split(' '))
startHere = [0 for i in range(n)]

if sum(v) % ((n * (n + 1)) / 2) != 0:
	print "NO"
	sys.exit()

operations = sum(v) / ((n * (n + 1)) / 2)

for i in range(n):
	diff = v[(i + 1) % n] - v[i]

	startHere[i] = (operations - diff) / n

contribution = 0
gathered = 0

for i in range(n):
	v[i] -= contribution
	gathered += startHere[i % n]
	contribution += gathered

for i in range(n):
	v[i] -= contribution
	gathered -= startHere[i % n]
	contribution -= startHere[i % n] * n
	contribution += gathered

if min(startHere) >= 0 and sum(startHere) == operations and min(v) == 0 and max(v) == 0:
	print "YES"
else:
	print "NO"
Buggy python submission (verdict: Time Limit Exceeded):
n = input()

v = [[0, 0] for i in range(n)]
for i in range(n):
	v[i] = map(int, raw_input().split(' '))

a, b = 1, 1

for i in range(n):
	while a * v[i][1] != b * v[i][0]:
		if a * v[i][1] < b * v[i][0]:
			a += 1
		else:
			b += 1

print a + b


Fixed submission:
n = input()

v = [[0, 0] for i in range(n)]
for i in range(n):
	v[i] = map(int, raw_input().split(' '))

a, b = 1, 1

for i in range(n):
	change = v[i][0] * b - a * v[i][1]
	while change != 0:
		if change < 0:
			additions = (-change + v[i][0] - 1) / v[i][0]
			change += additions * v[i][0]
			b += additions
		if change > 0:
			additions = (change + v[i][1] - 1) / v[i][1]
			change -= additions * v[i][1]
			a += additions

print a + b
Buggy python submission (verdict: Runtime Error):
s = input()

n=len(s)
print(s[0] + n + s[-1])


Fixed submission:
s = input()

n=len(s) - 2
print(s[0], end="")
print(n, end="")
print(s[-1])
Buggy python submission (verdict: Runtime Error):
n= int(input())

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

k = len(filter(lambda(x, x%4), a))
j = len(filter(lambda(x, x%2), a))-k
i = len(a)-j-k

if (j > 0) and (i+1 <= k):
    print("Yes")
if (j == 0) and (i-1 <= k):
    print("Yes")
else:
    print("No")


Fixed submission:
n= int(input())

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

k = len(list(filter(lambda x: x%4 == 0, a)))
j = len(list(filter(lambda x: x%2 == 0, a)))-k
i = len(a)-j-k

if (j > 0) and (i <= k):
    print("Yes")
elif (j == 0) and (i-1 <= k):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
    a, b = map(int, input().split(" "))
     
    if (a%3 ==0) or (b%3 ==0) or ((a+b)%3 ==0):
        print("Possible")
    else:
        print("Impossible")


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

if (a+b)%3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")

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

if (a%3 ==0) or (b%3 ==0) or ((a+b)%3 ==0)):
    print("Possible")
else:
    print("Impossible")

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

if (a+b)%3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split(" "))
ls = list(map(int, input().split(" ")))

ls.sort()

print(ls[:k].sum())

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

if (a+b)%3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")

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

if (a+b) %3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")


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

if (a+b)%3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")

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

if (a+b) %3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")


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

if (a+b)%3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split(" "))

l = map(int, input().split(" "))
l.sort()

sum = 0
for i in range(n-k-1, n-1):
    sum = sum + l[i]

print(sum)


Fixed submission:
n, k = map(int, input().split(" "))

l = list(map(int, input().split(" ")))
l.sort()

sum = 0
for i in range(n-k, n):
    sum = sum + l[i]

print(sum)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split(" "))

l = map(int, input().split(" "))
l.sort()

sum = 0
for i in range(n-k,n):
    sum = sum + l[i]

print(sum)


Fixed submission:
n, k = map(int, input().split(" "))

l = list(map(int, input().split(" ")))
l.sort()

sum = 0
for i in range(n-k, n):
    sum = sum + l[i]

print(sum)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split(" "))

l = map(int, input().split(" "))
l.sort()

sum = 0
for i in range(n-k,n):
    sum += l[i]

print(sum)

Fixed submission:
n, k = map(int, input().split(" "))

l = list(map(int, input().split(" ")))
l.sort()

sum = 0
for i in range(n-k, n):
    sum = sum + l[i]

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

def iseven(str, n):
    for i in range(0, n/2):
        if str[i] != str[i+n/2]:
            return False
    else:
        return True


for i in range(2, n, 2):
    if iseven(s, n-i):
        print(i)


Fixed submission:
s = input()
n = len(s)
def iseven(str, n):
    for i in range(0, n//2):
        if str[i] != str[i+n//2]:
            return False
    else:
        return True


for i in range(2, n, 2):
    if iseven(s, n-i):
        print(n-i)
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split(" ")))

b=[]
for item in a:
    b.append(item)
    b.reverse()


for item in b:
    print(item, end=" ")


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

b1=[]
b2=[]
b=[]
for i in range(0, n-1, 2):
    b1.append(a[i])
    b2.append(a[i+1])

if n%2 == 1:
    b1.append(a[n-1])
    b1.reverse()
    b.extend(b1)
    b.extend(b2)
else:
    b2.reverse()
    b.extend(b2)
    b.extend(b1)

for item in b:
    print(item, end=" ")

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

b=[]
for item in a:
    b.append(item)
    b.reverse()
    print(item,b)

for item in b:
    print(item, end=" ")


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

b1=[]
b2=[]
b=[]
for i in range(0, n-1, 2):
    b1.append(a[i])
    b2.append(a[i+1])

if n%2 == 1:
    b1.append(a[n-1])
    b1.reverse()
    b.extend(b1)
    b.extend(b2)
else:
    b2.reverse()
    b.extend(b2)
    b.extend(b1)

for item in b:
    print(item, end=" ")

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

b=[]
for item in a:
    b.append(item)
    b.reverse

for item in b:
    print(item, end=" ")


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

b1=[]
b2=[]
b=[]
for i in range(0, n-1, 2):
    b1.append(a[i])
    b2.append(a[i+1])

if n%2 == 1:
    b1.append(a[n-1])
    b1.reverse()
    b.extend(b1)
    b.extend(b2)
else:
    b2.reverse()
    b.extend(b2)
    b.extend(b1)

for item in b:
    print(item, end=" ")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
 
light=0
 
for i in range(n):
    light=a[light]
    if light == 1:
        print(i)
        break
else:
    print(-1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input())-1)
 
light=0
 
for i in range(1,n+1):
    light=a[light]
    if light == 1:
        print(i)
        break
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

light=1

for i in range(n):
    light=a[light]
    if light == 2:
        print(i)
        break
else:
    print(-1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input())-1)
 
light=0
 
for i in range(1,n+1):
    light=a[light]
    if light == 1:
        print(i)
        break
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

light=1

for i in range(n):
    light=a[light]
    if light = 2:
        print(i)
        break
else:
    print(-1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input())-1)
 
light=0
 
for i in range(1,n+1):
    light=a[light]
    if light == 1:
        print(i)
        break
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input())

light=1

for i in range(n):
    light=a[light]
    if light = 2:
        print(i)
        break
else:
    print(-1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input())-1)
 
light=0
 
for i in range(1,n+1):
    light=a[light]
    if light == 1:
        print(i)
        break
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split(" "))
(n, m) = (n, m) if n>m else (m, n)
M=1000000007

def newfact(n):
    
    return ((n * newfact(n-1)) % M if n > 1 else 1)

if n > m+1:
    print(0)
elif n == m:
    print((2 * newfact(n) * newfact(m)) % M)
else:
    print((newfact(n) * newfact(m)) % M)

Fixed submission:
n, m = map(int, input().split(" "))
(n, m) = (n, m) if n>m else (m, n)
M=1000000007

def newfact(n):
    ans=1
    for i in range(1, n+1):
        ans = (ans*i)%M
    return ans

if n > m+1:
    print(0)
elif n == m:
    print((2 * newfact(n) * newfact(m)) % M)
else:
    print((newfact(n) * newfact(m)) % M)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split(" "))
n, m = n, m if n>m else m, n
M=1000000007

def newfact(n):
    return (n * newfact(n-1)) % M

if n > m+1:
    print(0)
elif n == m:
    print((2 * newfact(n) * newfact(m)) % M)
else:
    print((newfact(n) * newfact(m)) % M)



Fixed submission:
n, m = map(int, input().split(" "))
(n, m) = (n, m) if n>m else (m, n)
M=1000000007

def newfact(n):
    ans=1
    for i in range(1, n+1):
        ans = (ans*i)%M
    return ans

if n > m+1:
    print(0)
elif n == m:
    print((2 * newfact(n) * newfact(m)) % M)
else:
    print((newfact(n) * newfact(m)) % M)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split(" ")))

colors=[]
if list(filter(lambda x:x<3200, a)):
    f=lambda x:x<400
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:400<=x<800
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:800<=x<1200
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:1200<=x<1600
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:1600<=x<2000
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2000<=x<2400
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2400<=x<2800
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2800<=x<3200
    colors.append(1 if list(filter(f, a)) else 0)

    print(sum(colors), sum(colors)+len(list(filter(lambda x:3200<=x, a)))

else:
    print(1, n)



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

colors=[]
if list(filter(lambda x:x<3200, a)):
    f=lambda x:x<400
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:400<=x<800
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:800<=x<1200
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:1200<=x<1600
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:1600<=x<2000
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2000<=x<2400
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2400<=x<2800
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2800<=x<3200
    colors.append(1 if list(filter(f, a)) else 0)

    print(sum(colors), sum(colors)+len(list(filter(lambda x:3200<=x, a))))

else:
    print(1, n)
Buggy python submission (verdict: Runtime Error):
s = input()

str=[]
for char in s:
    str.append(char)

str.sort()

for char in str:
    if str.count(char) > 1:
        print "no"
        break
else:
    print "yes"


Fixed submission:
s = input()

str=[]
for char in s:
    str.append(char)

str.sort()

for char in str:
    if str.count(char) > 1:
        print("no")
        break
else:
    print("yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

if sum(s) % 10 != 0:
    print(sum(s))
elif filter(lambda x:x%10>0,s) == False:
    print(0)
else:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))



Fixed submission:
n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

s.sort(key=lambda x:x%10)

if sum(s) % 10 != 0:
    print(sum(s))
elif s[-1] % 10>0:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

if sum(s) % 10 != 0:
    print(sum(s))
else:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))



Fixed submission:
n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

s.sort(key=lambda x:x%10)

if sum(s) % 10 != 0:
    print(sum(s))
elif s[-1] % 10>0:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s=[]
for i in range(n):
    s.append(int(input())

if sum(s) % 10 != 0:
    print(sum(s))
else:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))



Fixed submission:
n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

s.sort(key=lambda x:x%10)

if sum(s) % 10 != 0:
    print(sum(s))
elif s[-1] % 10>0:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
(h, w) = map(int, input().split(" "))

a=[]
for i in range(h):
        a.append(input())

print("#" * (w+2))

for i in range(h):
    print("#"+a+"#")

print("#" * (w+2))



Fixed submission:
(h, w) = map(int, input().split(" "))

a=[]
for i in range(h):
        a.append(input())

print("#" * (w+2))

for i in range(h):
    print("#"+a[i]+"#")

print("#" * (w+2))

Buggy python submission (verdict: Runtime Error):
(h, w) = map(int, input().split(" "))

a=[]
for i in range(h):
        a.append(input().split(" "))

print("#" * (w+2))

for i in range(h):
    print("#", end="")
    for j in range(w):
        print(aline[i][j], end="")
    print("#")

print("#" * (w+2))



Fixed submission:
(h, w) = map(int, input().split(" "))

a=[]
for i in range(h):
        a.append(input())

print("#" * (w+2))

for i in range(h):
    print("#"+a[i]+"#")

print("#" * (w+2))

Buggy python submission (verdict: Runtime Error):
(h, w) = map(int, input().split(" "))

a=[]
for i in range(h):
        aline[i] = input().split(" ")

print("#" * (w+2))

for i in range(h):
    print("#", end="")
    for j in range(w):
        print(aline[i][j], end="")
    print("#")

print("#" * (w+2))



Fixed submission:
(h, w) = map(int, input().split(" "))

a=[]
for i in range(h):
        a.append(input())

print("#" * (w+2))

for i in range(h):
    print("#"+a[i]+"#")

print("#" * (w+2))