qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
s = []
for i in range(N):
    ss = int(input())
    s.append(ss)
ssum = sum(s)
s = sorted(s)
for val in s:
    if ssum % 10 == 0:
        if val % 10 != 0:
            ssum -= val
    else:
        break
print(ssum)

Fixed code:
N = int(input())
s = []
for i in range(N):
    ss = int(input())
    s.append(ss)
ssum = sum(s)
s = sorted(s)
for val in s:
    if ssum % 10 == 0:
        if val % 10 != 0:
            ssum -= val
    else:
        break
if ssum == sum(s) and ssum % 10 == 0 :
    print(0)
else:
    print(ssum)
Buggy code:
N=int(input())
S=list(int(input()) for _ range(N))
S=sorted(S)
ans=0
if sun(S)%10!=0:
  ans=sum(S)
for i in range(N):
  if (sum(S)-S[i])%10!=0:
    ans=sum(S)-S[i]
    break
    
print(ans)

Fixed code:
N=int(input())
S=list(int(input()) for _  in range(N))
S=sorted(S)
ans=0
if sum(S)%10!=0:
  ans=sum(S)
else:
    for i in range(N):
      if (sum(S)-S[i])%10!=0:
        ans=sum(S)-S[i]
        break
    
print(ans)
Buggy code:
a=sorted([int(input()) for _ in[0]*int(input())]);b=sum(a)
for x in a:
    if b%10!=0:b=0;break
    elif x%10!=0:b-=x
print(b)

Fixed code:
a=sorted([int(input()) for _ in[0]*int(input())]);b=sum(a)
for x in a:
    if b%10:break
    elif x%10:b-=x
print([0,b][b%10!=0])
Buggy code:
N = int(input())
sl = []
for n in range(N):
    sl.append(int(input()))

sum = sum(sl)
sorted_sl = sorted(filter(lambda s: s % 10 != 0,sl))
count = 0
while sum % 10 == 0 and count < len(sorted_sl):
    sum -= sorted_sl[count]
    count += 1

print(sum)

Fixed code:
N = int(input())
sl = []
for n in range(N):
    sl.append(int(input()))

sum = sum(sl)
sorted_sl = sorted(filter(lambda s: s % 10 != 0,sl))
if len(sorted_sl) == 0:
    print(0)
    exit()
count = 0
while sum % 10 == 0 and count < len(sorted_sl):
    sum -= sorted_sl[count]
    count += 1

print(sum)
Buggy code:
n = int(input())
S = sorted([int(input()) for _ in range(n)])
ans = 0
caution = 0
flag = 1
for s in S:
    ans += s
    if flag:
        if not s%10:
            caution = s
            flag = 0
if ans % 10 == 0:
    if caution:
        ans -= caution
    else:
        ans = 0
print(ans)        

Fixed code:
n = int(input())
S = sorted([int(input()) for _ in range(n)])
ans = 0
caution = 0
flag = 1
for s in S:
    ans += s
    if flag:
        if s % 10:
            caution = s
            flag = 0
if ans % 10 == 0:
    if caution:
        ans -= caution
    else:
        ans = 0
print(ans)
Buggy code:
# 2020/01/22
# AtCoder Beginner Contest 063 - C

# Input and Sum
n = int(input())
s_list = list()
s_sum = 0
for i in range(n):
    s = int(input())
    s_list.append(s)
    s_sum = s_sum + s

# Sort
s_list.sort()
print(s_list)

# Calc
i = 0
while s_sum > 0 and s_sum % 10 == 0:
    if s_list[i] % 10 != 0:
        s_sum = s_sum - s_list[i]
    i = i + 1
    if i >= n:
        s_sum = 0

ans = s_sum

# Output
print(ans)

Fixed code:
# 2020/01/22
# AtCoder Beginner Contest 063 - C

# Input and Sum
n = int(input())
s_list = list()
s_sum = 0
for i in range(n):
    s = int(input())
    s_list.append(s)
    s_sum = s_sum + s

# Sort
s_list.sort()

# Calc
i = 0
while s_sum > 0 and s_sum % 10 == 0:
    if s_list[i] % 10 != 0:
        s_sum = s_sum - s_list[i]
    i = i + 1
    if i >= n:
        s_sum = 0

ans = s_sum

# Output
print(ans)
Buggy code:
n=int(input())
s=[]
for i in range(n):
    s.append(int(input()))
total=sum(s)
s.sort()
if total%10!=0:
    print(total)
else:
    for i in s:
        if i%10!=0:
            total-=i
            if total%10!=0:
                break
if total%10==0:
    print(0)
else:
    print(total)


Fixed code:
n=int(input())
s=[int(input()) for x in range(n)]
total=sum(s)
s.sort()
if total%10==0:
    for i in s:
        if i%10!=0:
            total-=i
            if total%10!=0:
                break
if total%10==0:
    print(0)
else:
    print(total)
Buggy code:
mport sys

n = int(input())
nums = []
for _ in range(n):
    nums.append(int(input()))
s = sum(nums)
if s % 10 != 0:
    print(s)
else:
    nums.sort()
    for num in nums:
        t = s - num
        if t % 10 != 0:
            print(t)
            break
    else:
        print(0)

Fixed code:
import sys

n = int(input())
nums = []
for _ in range(n):
    nums.append(int(input()))
s = sum(nums)
if s % 10 != 0:
    print(s)
else:
    nums.sort()
    for num in nums:
        t = s - num
        if t % 10 != 0:
            print(t)
            break
    else:
        print(0)
Buggy code:
n=int(input())
s=[int(input()) for i in range(n)]
ten=[]
p=[]
for x in s:
    if x%10==0:ten.append(x)
    else:p.append(x)
ten=sum(ten)
if len(p)==0:print(0)
else:
	p=sorted(p)
    Sum=sum(p)
    print(Sum+ten-p[0] if Sum%10==0 else Sum+ten)

Fixed code:
n=int(input())
s=[int(input()) for i in range(n)]
ten=[]
p=[]
for x in s:
    if x%10==0:ten.append(x)
    else:p.append(x)
ten=sum(ten)
if len(p)==0:print(0)
else:
    p=sorted(p)
    Sum=sum(p)
    print(Sum+ten-p[0] if Sum%10==0 else Sum+ten)
Buggy code:
n = int(input())
cou = 0
num = 0
for i in range(n):
  a = int(input())
  if a % 10 != 0:num = min(a,num)
  cou += a
if cou % 10 == 0:
  if a % 10 == 0:
    print(0)
  else:
    print(cou -a)
else:
  print(cou)

Fixed code:
n = int(input())
cou = 0
num = 1000
for i in range(n):
  a = int(input())
  if a % 10 != 0:num = min(a,num)
  cou += a
if cou % 10 == 0:
  if num % 10 == 0:
    print(0)
  else:
    print(cou -num)
else:
  print(cou)
Buggy code:
n = int(input())
li = [0]
for i in range(n):li.append(int(input()))
li.sort()
if sum(li) % 10 == 0:
    for k in range(n+1):
        if (sum(li)-li[k]) % 10 != 0:
            print(sum(li))
            exit()
else:
    print(sum)
    exit()
print("0")


Fixed code:
n = int(input())
li = []
for i in range(n):li.append(int(input()))
li.sort()
if sum(li) % 10 == 0:
    for k in range(n):
        if (sum(li)-li[k]) % 10 != 0:
            print(sum(li)-li[k])
            exit()
else:
    print(sum(li))
    exit()
print("0")
Buggy code:
N = int(input())
S = [int(input()) for i in range(N)]
S.sort()
sum = sum(S)
if sum%10==0:
    for i in range(N):
        if (sum-S[i])%10!=0:
            sum -= S[i]
            print(sum)
            break
    print(0)
else:
    print(sum)

Fixed code:
N = int(input())
S = [int(input()) for i in range(N)]
S.sort()
sum = sum(S)
if sum%10==0:
    for i in range(N):
        if (sum-S[i])%10!=0:
            sum -= S[i]
            print(sum)
            exit()
    print(0)
else:
    print(sum)
Buggy code:
a = int(input())
list=[]
for i in range(a):
    list.append(int(input()))

if not sum(list)%10==0:
    print(sum(list))
else:
    for i in sorted(list):
        if not i%10==0:
            print(sum(list)-i)
            break
    print(0)

Fixed code:
a = int(input())
list=[]
for i in range(a):
    list.append(int(input()))

if not sum(list)%10==0:
    print(sum(list))
else:
    for i in sorted(list):
        if not i%10==0:
            print(sum(list)-i)
            exit()
    print(0)
Buggy code:
n=int(input())
l=[]
s=0
for i in range(n):
  a=int(input())
  s+=a
  if a%10!=0:
    l.append(a)
if len(l)==0:
  print(0)
else:
  print(s-min(l))
  

           

Fixed code:
n=int(input())
l=[]
s=0
for i in range(n):
  a=int(input())
  s+=a
  if a%10!=0:
    l.append(a)
if len(l)==0:
  print(0)
else:
  if s%10==0:
    print(s-min(l))
  else:
    print(s)
Buggy code:
n=int(input())
scr=[int(input()) for i in range(n)]
s=sum(scr)
if s%10==0:
  print(s)
  exit()
scr.sort()
for i in range(n):
  if scr[i]%10!=0:
    print(s-scr[i])
    exit()
print(0)

Fixed code:
n=int(input())
scr=[int(input()) for i in range(n)]
s=sum(scr)
if s%10!=0:
  print(s)
  exit()
scr.sort()
for i in range(n):
  if scr[i]%10!=0:
    print(s-scr[i])
    exit()
print(0)
Buggy code:
n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    for i in range(n):
        ans -= s[i]
        if ans % 10 != 0:
            print(ans)
            quit()

print(0)

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

s.sort()
ans = sum(s)
if ans % 10 != 0:
    print(ans)
    quit()
else:
    for i in range(n):
        if (ans-s[i]) % 10 != 0:
            print(ans-s[i])
            quit()

print(0)
Buggy code:
n=int(input())
s=[int(input()) for _ in range(n)]
p=sum(s)
if p%10!=0:
  print(p)
else:
  s.sort()
  for i in s:
    if i%10!=0:
      print(p-i)
      break

Fixed code:
n=int(input())
s=[int(input()) for _ in range(n)]
p=sum(s)
if p%10!=0:
  print(p)
else:
  s.sort()
  d=0
  for i in s:
    if i%10!=0:
      d=i
      break
  if d==0:
    print(0)
  else:
    print(p-d)
Buggy code:
N = int(input())
s_list = []
for i in range(N):
    s_list.append(int(input()))

sum_num = sum(s_list)

if sum_num % 10 != 0:
    print(sum_num)
    exit()
else:
    s_list.sort()
    tmp = sum_num
    for s in s_list:
        sum_num = tmp - s
        if sum_num % 10 != 0:
            print(sum_num)
            exit()
    print(sum_num)

Fixed code:
N = int(input())
s_list = []
for i in range(N):
    s_list.append(int(input()))

sum_num = sum(s_list)

if sum_num % 10 != 0:
    print(sum_num)
    exit()
else:
    s_list.sort()
    tmp = sum_num
    for s in s_list:
        if s % 10 == 0:
            continue
        sum_num = tmp - s
        if sum_num % 10 != 0:
            print(sum_num)
            exit()
        sum_num = tmp
    print(0)
Buggy code:
N = int(input())
s = [0]*N
for i in range(N):
    s[i] = int(input())

ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    flag = True
    for e in sorted(s):
        if e % 10 != 0:
            ans -= e
            flag = False
            break
    if flag:
        print(0)


Fixed code:
N = int(input())
s = [0]*N
for i in range(N):
    s[i] = int(input())

ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    flag = True
    for e in sorted(s):
        if e % 10 != 0:
            ans -= e
            flag = False
            break
    if flag:
        print(0)
    else:
        print(ans)
Buggy code:
N = int(input())
s = []
for i in range(N):
	s.append(int(input()))
Sum = sum(s)
s.sort()
print(s)
if(Sum % 10 == 0):
	for i in range(N):
		if  s[i]  % 10 != 0 and i !=  N-1:
			print(Sum-s[i])
			break
		if i == N-1:
			print(0)
else:
	print(Sum)

Fixed code:
N = int(input())
s = []
for i in range(N):
	s.append(int(input()))
Sum = sum(s)
s.sort()
if(Sum % 10 == 0):
	for i in range(N):
		if  s[i]  % 10 != 0 and i !=  N-1:
			print(Sum-s[i])
			break
		if i == N-1:
			print(0)
else:
	print(Sum)
Buggy code:
n = int(input())
s = [int(input()) for i in range(n)]
ans=0
m = sum(s)
if m%10==0:
    s.sort()
    for si in s:
        if si%10!=0:
            print(m-si)
            break
else:
    print(m)

Fixed code:
n = int(input())
s = [int(input()) for i in range(n)]
ans=0
m = sum(s)
if m%10==0:
    f = True
    s.sort()
    for si in s:
        if si%10!=0:
            print(m-si)
            f = False
            break
    if f:
        print(0)
else:
    print(m)
Buggy code:
import sys
n = int(input())
s = [int(input()) for i in range(n)]
s.sort()
m = sum(s)
if  m % 10 != 0:
  print(m)

else:
  for i in range(n):
    m -= s[i]
    if m % 10 != 0:
      print(m)
      sys.exit()
print(0)  



Fixed code:
import sys
n = int(input())
s = [int(input()) for i in range(n)]
s.sort()
m = sum(s)
if  m % 10 != 0:
  print(m)
else:
  for i in range(n):
    if s[i] % 10 != 0:
      m -= s[i]
      print(m)
      sys.exit()
  print(0)
Buggy code:
N = int(input())
s = [int(input()) for i in range(N)]
ans = sum(s)
s.sort()
for i in range(N):
    if (ans - s[i]) % 10 != 0:
        ans -= s[i]
        break

if ans == sum(s):
    print(0)
else:
    print(ans)

Fixed code:
N = int(input())
s = [int(input()) for i in range(N)]
ans = sum(s)
s.sort()
if ans % 10 != 0:
    print(ans)
else:
    for i in range(N):
        if (ans - s[i]) % 10 != 0:
            ans -= s[i]
            break
    if ans % 10 == 0:
        print(0)
    else:
        print(ans)
Buggy code:
n = int(input())
s = [int(input()) for i range(n)]
summ = sum(s)
ans = [0]*summ
for i in range(n):
  ans[i] -= a[i]
ans.sort(reverse = True)
for i in ans:
  if i % 10 != 0:
    print(i)
    break

Fixed code:
n = int(input())
s = [int(input()) for i in range(n)]
summ = sum(s)
ans = [summ]*n
for i in range(n):
  ans[i] -= s[i]
ans.sort(reverse = True)
if summ % 10 != 0:
  print(summ)
else:

  for i in ans:
    if i % 10 != 0:
      print(i)
      break
  else:
    print(0)
Buggy code:
s = [int(input()) for i in range(N)]
s_shadow = [i for i in s if i % 10 != 0]
ans = sum(s)
 
if ans % 10 == 0:
    if len(s_shadow) == 0:
        ans = 0
    
    else:
        ans = sum(s)-s_shadow[0]
        for i in s_shadow:
            ans = max(ans, anss-i)
            
print(ans)

Fixed code:
N = int(input())
s = [int(input()) for i in range(N)]
s_shadow = [i for i in s if i % 10 != 0]
ans = sum(s)
 
if ans % 10 == 0:
    if len(s_shadow) == 0:
        ans = 0
    
    else:
        ans = sum(s)-s_shadow[0]
        anss = sum(s)
        for i in s_shadow:
            ans = max(ans, anss-i)
            
print(ans)
Buggy code:
N = int(input())
s = [int(input()) for _ in range(N)]

if sum(s)%10 != 0:
    print(sum(s))
else:
    ans = sum(s)
    s.sort()
    for i in s:
        ans -= i
        if ans%10 != 0:
            print(ans)
            exit()
        ans += i
    print(ans)

Fixed code:
N = int(input())
s = [int(input()) for _ in range(N)]

if sum(s)%10 != 0:
    print(sum(s))
else:
    ans = sum(s)
    s.sort()
    for i in s:
        ans -= i
        if ans%10 != 0:
            print(ans)
            exit()
        ans += i
    print(0)
Buggy code:
n=int(input())
s=[]
for i in range(n):
    s.append(int(input()))
t=sorted(s)
u=sum(s)
if u%10!=0:
    print(u)
    exit()
for i in range(n):
    v=u-t[i]
    if v %10!=0:
        print(u)
        exit()
print(0)

Fixed code:
n=int(input())
s=[]
for i in range(n):
    s.append(int(input()))
t=sorted(s)
u=sum(s)
if u%10!=0:
    print(u)
    exit()
for i in range(n):
    v=u-t[i]
    if v %10!=0:
        print(v)
        exit()
print(0)
Buggy code:
import sys

input = sys.stdin.buffer.readline
n = int(input())
S = []
for _ in range(n):
    S.append(int(input()))
S.sort()
goukei = sum(S)
ans = 0
for i in range(n):
    temp = goukei - S[i]
    if temp % 10 == 0:
        temp = 0
    ans = max(ans, temp)

print(ans)


Fixed code:
import sys

input = sys.stdin.buffer.readline
n = int(input())
S = []
for _ in range(n):
    S.append(int(input()))
S.sort()
goukei = sum(S)
if goukei %10!=0:
    print(goukei)
    exit()
ans = 0
for i in range(n):
    temp = goukei - S[i]
    if temp % 10 == 0:
        temp = 0
    ans = max(ans, temp)

print(ans)
Buggy code:
N=int(input())
s=[int(input()) for i in range(N)]
import collections
table=collections.defaultdict(int)
for x in s:
  if x%10!=0:
    table[x]+=1
if sum(s)%10==0:
  if len(table)==0:
    print(0)
  else:
    table=list(table.keys())
    table.sort()
    print(sum(s) - table[0])

Fixed code:
N=int(input())
s=[int(input()) for i in range(N)]
import collections
table=collections.defaultdict(int)
for x in s:
  if x%10!=0:
    table[x]+=1
if sum(s)%10==0:
  if len(table)==0:
    print(0)
  else:
    table=list(table.keys())
    table.sort()
    print(sum(s) - table[0])
else:
  print(sum(s))
Buggy code:
n = int(input())
s = [int(input()) for i in range(n)]
s.sort()
j = sum([ i % 10 for i in s ])
if j == 0:
    ans = 0
else:
    for i in range(n):
        tmp = sum(s[:i+1])+sum(s[i:])
        if tmp % 10 != 0:
            ans = tmp
            break
print(ans)

Fixed code:
n = int(input())
s = [int(input()) for i in range(n)]
s.sort()
j = sum([ i % 10 for i in s ])
if j == 0:
    ans = 0
else:
    if sum(s) % 10 != 0:
        ans = sum(s)
    else:
        for i in range(n):
            tmp = sum(s)-s[i]
            if tmp % 10 != 0:
                ans = tmp
                break
print(ans)
Buggy code:
n = int(input())
s = [int(input()) for _ in range(n)]
sum_s = sum(s)
if sum_s%10==0:
    s = sorted(s)
    for i in range(n):
        if s[i]%10==0:
            sum_s -= s[i]
            break
    if sum_s%10==0:
        print(0)
    else:
        print(sum_s)
else:
    print(sum_s)

Fixed code:
n = int(input())
s = [int(input()) for _ in range(n)]
sum_s = sum(s)
if sum_s%10==0:
    s = sorted(s)
    for i in range(n):
        if s[i]%10!=0:
            sum_s -= s[i]
            break
    if sum_s%10==0:
        print(0)
    else:
        print(sum_s)
else:
    print(sum_s)
Buggy code:
import itertools

N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

m=sum(A)

if(m%10==0):
    A=sorted(A)
    for a in A:
        if a%10!=0:
            print(m-a)
            exit()

else:
    print(m)



Fixed code:
import itertools

N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

m=sum(A)

if(m%10==0):
    A=sorted(A)
    for a in A:
        if a%10!=0:
            print(m-a)
            exit()
    print(0)
else:
    print(m)
Buggy code:
def f(scores):
    res = sum(scores)
    if res % 10 == 0:
        candidates = list(score for score in scores if score % 10 != 0)
        if candidates:
            res -= min(candidates)
        else:
            res = 0
    return res

N = int(input())
scores = []
for _ in range(N):
    scores.append(int(input()))
f(scores)

Fixed code:

def f(scores):
    res = sum(scores)
    if res % 10 == 0:
        candidates = list(score for score in scores if score % 10 != 0)
        if candidates:
            res -= min(candidates)
        else:
            res = 0
    return res
 
N = int(input())
scores = []
for _ in range(N):
    scores.append(int(input()))
print(f(scores))
Buggy code:
N = int(input())
S = sorted([int(input()) for _ in range(N)])

ans = sum(S)

if ans % 10 == 0:
  # find numbers that are not multiples of 10 in order of decreasing.
  for s in S:
    if s % 10 != 0:
      ans -= s
      break
  # if all the numbers in the list are multiples of 10, the ans is 0.
  ans = 0

print(ans)


Fixed code:
N = int(input())
S = sorted([int(input()) for _ in range(N)])

ans = sum(S)

if ans % 10 == 0:
  # find numbers that are not multiples of 10 in order of decreasing.
  for s in S:
    if s % 10 != 0:
      ans -= s
      break
  # if all the numbers in the list are multiples of 10, the ans is 0.
  if ans == sum(S):
    ans = 0

print(ans)
Buggy code:
n = int(input())
num_list = []
sum_ = 0
for i in range(n):
    num_list.append(int(input()))
num_list.sort()
for i in range(n):
    sum_ += num_list[i]
if sum_ % 10 != 0:
    print(sum_)
else:
    for i in range(n):
        if num_list[i] % 10 != 0:
            sum_ -= num_list[i]
            print(sum_)
            break

Fixed code:
n = int(input())
num_list = []
sum_ = 0
for i in range(n):
    num_list.append(int(input()))
num_list.sort()
for i in range(n):
    sum_ += num_list[i]
sum_1 = sum_
if sum_ % 10 != 0:
    print(sum_)
else:
    for i in range(n):
        if num_list[i] % 10 != 0:
            sum_ -= num_list[i]
            print(sum_)
            break
for i in range(n):
    if num_list[i] % 10 == 0:
        sum_1 -= num_list[i]
if sum_1 == 0:
    print(sum_1)
Buggy code:
N = int(input())
p = [int(input()) for i in range(N)]
ans = sum(p)
s = list(filter(lambda x: x % 10 != 0, p))
print(len(s))
if ans % 10 == 0:
    if len(s) == 0:
        print(int(0))
    else:
        ans = ans - min(s)
        print(ans)
else:
    print(ans)

Fixed code:
N = int(input())
p = [int(input()) for i in range(N)]
ans = sum(p)
s = list(filter(lambda x: x % 10 != 0, p))
if ans % 10 == 0:
    if len(s) == 0:
        print(int(0))
    else:
        ans = ans - min(s)
        print(ans)
else:
    print(ans)
Buggy code:
n = int(input())
l = [int(input()) for i in range(n)]
wa = sum(l)
cnt = 0
for i in l:
    if i % 10:
        cnt += 10
if cnt == n:
    print(0)
    exit()
    
if wa % 10:
    print(wa)
else:
    l.sort()
    for i in l:
        if i % 10 != 0:
            ex = i
            break
    
    print(wa - ex)

Fixed code:
n = int(input())
l = [int(input()) for i in range(n)]
wa = sum(l)
cnt = 0
for i in l:
    if i % 10 == 0:
        cnt += 1
        
if cnt == n:
    print(0)
    exit()
    
if wa % 10 != 0:
    print(wa)
else:
    l.sort()
    for i in l:
        if i % 10 != 0:
            print(wa - i)
            break
Buggy code:
import sys
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

sum_S = sum(S)
if sum_S % 10 != 0:
    print(sum_S)
    sys.exit()

S.sort()

for s in S:
    if s % 10 != 0:
        print(sum_S - s)
else:
    print(0)
    sys.exit()


Fixed code:
import sys
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

sum_S = sum(S)
if sum_S % 10 != 0:
    print(sum_S)
    sys.exit()

S.sort()

for s in S:
    if s % 10 != 0:
        break
else:
    print(0)
    sys.exit()

print(sum_S - s)
Buggy code:
n=int(input())
s=[int(input()) for _ in range(n)]
t=sum(s)
if t%10!=0 or t==0:
  print(t)
else:
  s.sort()
  for i in s:
    if i%10!=0:
      print(t-i)
      break

Fixed code:
n=int(input())
s=[int(input()) for _ in range(n)]
t=sum(s)
if t%10!=0 or t==0:
  print(t)
else:
  ans=0
  s.sort()
  for i in s:
    if i%10!=0:
      ans=t-i
      break
  print(ans)
Buggy code:
n = int(input())
dList = []

for i in range(n):
  dList.append(int(input()))

dList.sort()

gokei = sum(dList)
if gokei % 10 == 0:
  for i in dList:
    if (gokei - i ) % 10 != 0:
      print(gokei -i)
      break
  print(0)
else:
  print(gokei)
  

Fixed code:
n = int(input())
dList = []

for i in range(n):
  dList.append(int(input()))

dList.sort()

gokei = sum(dList)
if gokei % 10 == 0:
  for i in dList:
    if (gokei - i ) % 10 != 0:
      print(gokei -i)
      exit(0)
  print(0)
else:
  print(gokei)
Buggy code:
N = int(input())
lis = []
all10 = True
res = 0
for _ in range(N):
    tmp = int(input())
    res += tmp
    lis.append(tmp)
    if all10 and tmp % 10 != 0:
        all10 = False

if all10:
    print(0)
    exit()
if res % 10 != 0:
    print(res)
    exit()
else:
    lis.sort()
    for i in lis:
        if i % 10 != 0:
            print(res-i)


Fixed code:
N = int(input())
lis = []
all10 = True
res = 0
for _ in range(N):
    tmp = int(input())
    res += tmp
    lis.append(tmp)
    if all10 and tmp % 10 != 0:
        all10 = False

if all10:
    print(0)
    exit()
if res % 10 != 0:
    print(res)
    exit()
else:
    lis.sort()
    for i in lis:
        if i % 10 != 0:
            print(res-i)
            exit()
Buggy code:
def main():
    n = int(input())
    a_list = sorted([int(input()) for _ in range(n)])
    maxv = sum(a_list)

    if maxv%10 != 0:
        print(maxv)
    else:
        flag = 1
        for i in range(n):
            if a_list[i]%10 != 0:
                ans = maxv - a_list[i]
                print(ans)
                flag = 1
                break
        if flag: print(0)


if __name__ == "__main__":
    main()

Fixed code:
def main():
    n = int(input())
    a_list = sorted([int(input()) for _ in range(n)])
    maxv = sum(a_list)

    if maxv%10 != 0:
        print(maxv)
    else:
        flag = 1
        for i in range(n):
            if a_list[i]%10 != 0:
                ans = maxv - a_list[i]
                print(ans)
                flag = 0
                break
        if flag: print(0)


if __name__ == "__main__":
    main()
Buggy code:
n = int(input())
S = []
for i in range(n):
  S.append(int(input()))
S.sort()
for i in range(n):
  total = sum(S) - S[i]
  if total % 10 == 0:
    continue
  else:
    print(total)
    break
else:
  print(0)

Fixed code:
n = int(input())
S = []
for i in range(n):
  S.append(int(input()))
S.sort()
if sum(S) % 10 != 0:
  print(sum(S))
else:
  for i in range(n):
    total = sum(S) - S[i]
    if total % 10 == 0:
      continue
    else:
      print(total)
      break
  else:
    print(0)