Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

S = input()
#S = 'abcdefghijklmnopqrstuvwxyz'*200
K = ii()
N = len(S)
'''
N = len(S)
d = defaultdict(int)
for i in range(N+1):
    for j in range(N-i+1):
        d[S[j:j+i+1]] += 1
l = sorted(d.keys())
#print(l)
print(l[K])
'''

alphabets = list('abcdefghijklmnopqrstuvwxyz')
#print(len(alphabets))
l = []
for alpha in alphabets:
    for i, m in enumerate(S):
        if m == alpha:
            for j in range(N-i):
                if S[i:i+j+1] not in l:
                    l.append(S[i:i+j+1])
                    K -= 1
    if K <= 0:
        l = sorted(l)
        #print(l)
        print(l[K-1])
        exit()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
import itertools #list(accumulate(A))

S = input()
K = ii()
N = len(S)


alphabets = list('abcdefghijklmnopqrstuvwxyz')
l = []

for alpha in alphabets:
    for i, m in enumerate(S):
        if m == alpha:
            flag = 1
            for j in range(1, min(K+1, N-i+1)):
                l.append(S[i:i+j])
    #print(set(l))
    l = sorted(set(l))
    if len(l) >= K:
        print(l[K-1])
        exit()
### BUGGY CODE ###

N =  int(input())
A = [int(input()) for i in range(N)]
li = list(set(A))
count = 0
for i in range(len(li)):
    if A.count(li[i])%2!=0:
        count += 1
print(count)

### FIXED CODE ###

import collections as co
N = int(input())
A = [int(input()) for i in range(N)]
c = co.Counter(A)
count = 0
for a,b in c.most_common():
    if b%2==1:
        count += 1
print(count)
### BUGGY CODE ###

"""
python3 c.py < input.txt
"""
import math
import itertools as it
import heapq

N,K=map(int, input().split())
S=input()
T=[S[0]]
U=[1]
for c in S[1:]:
    if c==T[-1]:
        U[-1]=U[-1]+1
    else:
        T.append(c)
        U.append(1) 
M=len(U)
V=[U[0]]
for i in range(1,M):
    V.append(V[-1]+U[i])

X=[]
for l in range(M):
    if T[l]=="0":
        ll=max(0, l-1)
        r=max(l, min(M-1, l+2*(K-1)+1))
        X.append((ll, r))
    else:
        X.append((0,0))
#print(T)
#print(U)
#print(V)
#print(X)
#print([([0]+V)[r+1]-([0]+V)[l] for (l,r) in X])
print(max([([0]+V)[r+1]-([0]+V)[l] for (l,r) in X]))

### FIXED CODE ###

"""
python3 c.py < input.txt
"""
import math
import itertools as it
import heapq

N,K=map(int, input().split())
S=input()
T=[S[0]]
U=[1]
for c in S[1:]:
    if c==T[-1]:
        U[-1]=U[-1]+1
    else:
        T.append(c)
        U.append(1) 
M=len(U)
V=[U[0]]
for i in range(1,M):
    V.append(V[-1]+U[i])

X=[]
for l in range(M):
    if T[l]=="0":
        ll=max(0, l-1)
        r=max(l, min(M-1, l+2*(K-1)+1))
        X.append((ll, r))
    else:
        X.append((0,0))
V=[0]+V
#print(T)
#print(U)
#print(V)
#print(X)
#print([([0]+V)[r+1]-([0]+V)[l] for (l,r) in X])
print(max([V[r+1]-V[l] for (l,r) in X]))
### BUGGY CODE ###

from collections import deque, _heapq
N, K = map(int, input().split())
V = deque(map(int, input().split()))

class Money:
    def __init__(self):
        self.yen = 0
        self.red = []

    def value(self):
        return self.yen + sum(self.red)

    def add(self, yen):
        if yen >= 0:
            self.yen += yen
        else:
            self.red.append(yen)

    def remove(self, yen):
        if yen >= 0:
            self.yen -= yen
        else:
            self.red.remove(yen)

#mny = Money()
def get(cnt, mny, lstop, rstop):
    ans = mny.value()

    if cnt <= 0:
        return ans

    if len(V) > 0:

        if lstop == 0:
            w = V.popleft()
            mny.add(w)
            ans = max(ans, get(cnt-1, mny, lstop, rstop))
            mny.remove(w)
            V.appendleft(w)
        elif lstop > 0:
            lstop -= 1

        if rstop == 0:
            w = V.pop()
            mny.add(w)
            ans = max(ans, get(cnt-1, mny, -1, rstop))
            mny.remove(w)
            V.append(w)

    if len(mny.red) > 0:
        w = min(mny.red)
        mny.red.remove(w)

        V.appendleft(w)
        ans = max(ans, get(cnt-1, mny, -1, rstop))
        V.popleft()

        V.append(w)
        ans = max(ans, get(cnt-1, mny, lstop, -1))
        V.pop()

        mny.red.append(w)    

    return ans

print(get(K, Money(), 0, 0))


### FIXED CODE ###

from collections import deque, _heapq
N, K = map(int, input().split())
V = deque(map(int, input().split()))

class Money:
    def __init__(self):
        self.yen = 0
        self.red = []

    def value(self):
        return self.yen + sum(self.red)

    def add(self, yen):
        if yen >= 0:
            self.yen += yen
        else:
            self.red.append(yen)

    def remove(self, yen):
        if yen >= 0:
            self.yen -= yen
        else:
            self.red.remove(yen)

#mny = Money()
def get(cnt, mny, lstop, rstop):
    ans = mny.value()

    if cnt <= 0:
        return ans

    if len(V) > 0:

        if lstop == 0:
            w = V.popleft()
            mny.add(w)
            ans = max(ans, get(cnt-1, mny, lstop, rstop))
            mny.remove(w)
            V.appendleft(w)
        elif lstop > 0:
            lstop -= 1

        if rstop == 0:
            w = V.pop()
            mny.add(w)
            ans = max(ans, get(cnt-1, mny, -1, rstop))
            mny.remove(w)
            V.append(w)

    if len(mny.red) > 0:
        w = min(mny.red)
        mny.red.remove(w)

        V.appendleft(w)
        ans = max(ans, get(cnt-1, mny, -1, -1))
        V.popleft()

        mny.red.append(w)    

    return ans

print(get(K, Money(), 0, 0))
### BUGGY CODE ###

import numpy as np

N = int(input())

for n in range(1, N + 1):
    cnt = 0
    th = int(np.sqrt(n)) + 1
    for x in range(1, th):
        thy = int(np.sqrt(n - x ** 2)) + 1
        for y in range(1, thy):
            try:
                thz = int(np.sqrt(n - x ** 2 - y ** 2)) + 1
            except ValueError:
                continue
            for z in range(1, thz):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    cnt += 1
    print(cnt)

### FIXED CODE ###

import numpy as np

N = int(input())
res = np.zeros(N+1)

th = int(np.sqrt(N)) + 1
for x in range(1, th):
    for y in range(1, x + 1):
        for z in range(1, y + 1):
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if n > N:
                continue
            if x == y and y == z:
                res[n] += 1
            elif x == y or y == z or z == x:
                res[n] += 3
            else:
                res[n] += 6
for i in range(1, N+1):
    print(int(res[i]))
### BUGGY CODE ###

import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,u,v = map(int,ipt().split())
    way = [[] for _ in range(n+1)]
    for _ in range(n-1):
        a,b = map(int,ipt().split())
        way[a].append(b)
        way[b].append(a)

    ta = [-1]*(n+1)
    tt = [-1]*(n+1)
    ta[v] = 0 #AOKI
    qa = queue.Queue()
    qt = queue.Queue()
    qt.put((0,u))
    qa.put((0,v))
    while (not qt.empty()) or (not qa.empty()):
        nqt = queue.Queue()
        nqa = queue.Queue()
        while not qt.empty():
            ti,pi = qt.get()
            if ta[pi] != -1:
                continue
            for i in way[pi]:
                if ta[i] == -1:
                    tt[i] = ti+1
                    nqt.put((ti+1,i))
        while not qa.empty():
            ti,pi = qa.get()
            for i in way[pi]:
                if ta[i] == -1:
                    ta[i] = ti+1
                    nqa.put((ti+1,i))
        qt = nqt
        qa = nqa
    ma = 0
    for i,tti in enumerate(tt[1::]):
        tai = ta[i+1]
        if tti == -1:
            continue
        if ma < tti+(tai-tti)//2:
            ma = tti+(tai-tti)//2
    print(ma)


    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,u,v = map(int,ipt().split())
    way = [[] for _ in range(n+1)]
    for _ in range(n-1):
        a,b = map(int,ipt().split())
        way[a].append(b)
        way[b].append(a)

    ta = [-1]*(n+1)
    tt = [-1]*(n+1)
    ta[v] = 0 #AOKI
    tt[u] = 0
    qa = queue.Queue()
    qt = queue.Queue()
    qt.put((0,u,-1))
    qa.put((0,v,-1))

    while not qa.empty():
        ti,pi,pp = qa.get()
        for i in way[pi]:
            if i == pp:
                continue
            if ta[i] == -1:
                ta[i] = ti+1
                qa.put((ti+1,i,pi))

    while not qt.empty():
        ti,pi,pp = qt.get()
        if ta[pi] <= ti:
            continue
        for i in way[pi]:
            if i == pp:
                continue
            if ta[i] > ti:
                tt[i] = ti+1
                qt.put((ti+1,i,pi))

    ma = 0
    for i in range(1,n+1):
        if tt[i] == -1:
            continue
        if ma < tt[i]+max(0,ta[i]-tt[i]-1):
            ma = tt[i]+max(0,ta[i]-tt[i]-1)
    print(ma)


    return

if __name__ == '__main__':
    main()
### BUGGY CODE ###

s = list(input().strip().replace('BC', 'D'))
n = len(s)
end = n - 1

count = 0

if n >= 3:
  i = 0
  while i < end:
    if s[i] == 'A' and s[i + 1] == 'D':
      s[i] = 'D'
      s[i + 1] = 'A'
      count = count + 1

      j = i - 1
      while j >= 0 and s[j] == 'A':
        s[j] = 'D'
        s[j + 1] = 'A'
        count = count + 1
        j = j - 1

    i = i + 1

print(count)

### FIXED CODE ###

s = input().strip().replace('BC', 'D')
n = len(s)

count = 0
a_count = 0
for i in range(n):
  if s[i] == 'A':
    a_count += 1
  elif a_count > 0 and s[i] == 'D':
    count += a_count
  else:
    a_count = 0

print(count)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
def main():
    L,R = map(int,input().split())
    LR = R-L
    M = []
    for i in range(LR):
        for j in range(LR):
            M.append(((L+i)*(L+1+j))%2019)
    print(min(M))
if __name__ == '__main__':
    main()

### FIXED CODE ###

# -*- coding: utf-8 -*-
def main():
    L,R = map(int,input().split())
    LR = R-L
    M = []
    if L <= 2019 <= R:
        print(0)
        exit()
    for i in range(LR):
        for j in range(LR):
            M.append(((L+i)*(L+1+j))%2019)
            if ((L+i)*(L+1+j))%2019 == 0:
                print(0)
                exit()
    print(min(M))
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n,m = map(int,input().split())

a = sorted(list(map(int,input().split())),reverse=True)
for i in range(m):
    a[0] = a[0]/2
    a = sorted(a,reverse=True)
print(sum(list(map(int,a))))

### FIXED CODE ###

def main():
    import heapq
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    heap = []
    for i in range(n):
        heapq.heappush(heap,-1*a[i])
    for i in range(m):
        a = int(heapq.heappop(heap)/2)
        heapq.heappush(heap,a)
    print(-1*sum(heap))



if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
ans = 1
for x in range(1, n + 1):
    ans = ans * x
print(ans % 1000000007)

### FIXED CODE ###

n = int(input())
ans = 1
for x in range(1, n + 1):
    ans = x * ans % (10**9 + 7)
print(ans)
### BUGGY CODE ###

from collections import deque
s=list(str(input()))
s=deque(s)
q=int(input())
for i in range(q):
    que=list(input().split())
    if len(que)==1:
        s=list(s)
        s=s[::-1]
    else:
        if int(que[1])==1:
            s=deque(s)
            s.appendleft(que[2])
        elif int(que[1])==2:
            s=deque(s)
            s.append(que[2])
s=list(s)
print(''.join(s)) 

### FIXED CODE ###

from collections import deque
s=list(str(input()))
s=deque(s)
q=int(input())
cnt=0
for i in range(q):
    que=list(input().split())
    if len(que)==1:
        cnt+=1
    if len(que)!=1 and cnt%2==0:
        if int(que[1])==1:
            s.appendleft(que[2])
        elif int(que[1])==2:
            s.append(que[2])
    if len(que)!=1 and cnt%2!=0:
        if int(que[1])==1:
            s.append(que[2])
        elif int(que[1])==2:
            s.appendleft(que[2])
if cnt%2!=0:
    s.reverse()
print(''.join(s))
### BUGGY CODE ###

import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
mod = 10**9+7

def gcm(a,b):
    while(a%b!=0):
        a,b = b,a%b
    return b


def main():
    N = I()
    A = LI()

    LLCM = [0]*N
    LLCM[0] = A[0]

    for i in range(1,N):
        LLCM[i] = LLCM[i-1]*A[i] // gcm(LLCM[i-1],A[i])

    B = [0]*N
    for i in range(N):
        B[i] = LLCM[N-1] * pow(A[i],mod-2,mod)
        B[i] %= mod

    ans = 0
    for i in range(N):
        ans += B[i]
        ans %= mod

    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
mod = 10**9+7

def gcm(a,b):
    while(a%b!=0):
        a,b = b,a%b
    return b


def main():
    N = I()
    A = LI()

    l = A[0]

    for i in range(1,N):
        l = l*A[i] // gcm(l,A[i])
        
    B = [0]*N
    for i in range(N):
        B[i] = l * pow(A[i],mod-2,mod)

    ans = 0
    for i in range(N):
        ans += B[i]

    print(ans%mod)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

from collections import Counter

def main():
    n = int(input())
    count = 0
    lists =[]
    count_dict = Counter()

    for i in range(n):
        input_data = ''.join(sorted(input()))
        if input_data in lists:
            count += count_dict[input_data]
            count_dict[input_data] += 1
        else:
            count_dict[input_data] = 1
            lists.append(input_data)

    print(count)


if __name__ == '__main__' :
    main()

### FIXED CODE ###

from collections import Counter

n = int(input())
count = 0
lists =[]
count_dict = Counter()

for i in range(n):
    input_data = ''.join(sorted(input()))
    if input_data in count_dict:
        count += count_dict[input_data]
        count_dict[input_data] += 1
    else:
        count_dict[input_data] = 1

print(count)
### BUGGY CODE ###

N,M = map(int,input().split())
lists = []
for i in range(M):
    L,R = map(int,input().split())
    lists.append(list(range(L,R+1)))
if len(lists) == 1:
    print(len(lists[0]))
    exit()
for i in range(M-1):
    lists[i+1] = set(lists[i]) & set(lists[i+1])
    ans = lists[-1]
print(len(ans))

### FIXED CODE ###

N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
ans = list(range(max(L),min(R)+1))
print(len(ans))
### BUGGY CODE ###

N, K = [int(i) for i in input().split()]
ps = [int(i) for i in input().split()]
cs = [int(i) for i in input().split()]

global_max = -10**10
past_score = [[]]*N
past_time = [[]]*N
for n in range(N):
    score = 0
    itta = [0]*N
    iru = n
    k = 0
    while k < K:
        score += cs[ps[iru]-1]
        k += 1
        if itta[iru] == 1:
            # print('itta')
            # print(f'iru is {iru}')
            # print(f'score is {score}')
            # print(f'past_score is {past_score}')
            if score > past_score[iru]:
                # print('plus loop')
                T = k - past_time[iru]  # 周期
                # print(f'周期は {T}')
                if K - k > (2 * T) + 1:
                    # print(f'繰り返しは{((K-k)//T - 1)}回')
                    # print('それによって', (((K-k)//T - 1)*(score - past_score[iru])))
                    score += (((K-k)//T - 1)*(score - past_score[iru]))
                    k += T * ((K-k)//T - 1)
                    # print(f'new score is {score}')
                    # print(f'new k is {k}')
            else:
                # print('break!')
                break
        itta[iru] = 1
        # print(iru)
        # print(ps[iru]-1)
        # print(f'score is {score}')
        global_max = max(score, global_max)
        past_score[iru] = score
        past_time[iru] = k
        iru = ps[iru]-1
print(global_max)


### FIXED CODE ###

N, K = [int(i) for i in input().split()]
ps = [int(i) for i in input().split()]
cs = [int(i) for i in input().split()]

global_max = -10**10
past_score = [[]]*N
past_time = [[]]*N
for n in range(N):
    score = 0
    itta = [0]*N
    iru = n
    k = 0
    while k < K:
        score += cs[ps[iru]-1]
        k += 1
        if itta[iru] == 1:
            # print('itta')
            # print(f'iru is {iru}')
            # print(f'score is {score}')
            # print(f'past_score is {past_score}')
            if score > past_score[iru]:
                # print('plus loop')
                T = k - past_time[iru]  # 周期
                # print(f'周期は {T}')
                if K - k > (2 * T) + 1:
                    # print(f'繰り返しは{((K-k)//T - 1)}回')
                    # print('それによって', (((K-k)//T - 1)*(score - past_score[iru])))
                    score += (((K-k)//T - 1)*(score - past_score[iru]))
                    k += T * ((K-k)//T - 1)
                    # print(f'new score is {score}')
                    # print(f'new k is {k}')
            else:
                # print('break!')
                break
        itta[iru] = 1
        # print(iru)
        # print(ps[iru]-1)
        # print(f'score is {score}')
        global_max = max(score, global_max)
        past_score[iru] = score
        past_time[iru] = k
        iru = ps[iru]-1
print(global_max)
### BUGGY CODE ###

import copy
from math import factorial as f
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
I=list(map(int,input().split()))
for j in range(N):
    counter=[0 for i in range(N+1)]
    A=copy.deepcopy(I)
    A.pop(j)
    B=[]
    for i in A:
        counter[i]+=1
    for i in counter:
        if i>1:
            B.append(f(i)/(f(2)*f(i-2)))
    print(int(sum(B)))

### FIXED CODE ###

import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
A=list(map(int,input().split()))
counter=[0 for i in range(N+1)]
ans2=[0 for i in range(N+1)]
B=[]
for i in A:
    counter[i]+=1
ans=[0 for i in range(N+1)]
for i,value in enumerate(counter):
    if value>0:
        ans[i]=(value*(value-1)//2)
        ans2[i]=((value-1)*(value-2)//2)
total=sum(ans)
for i in A:
    temp=total
    temp-=ans[i]
    temp+=ans2[i]
    print(temp)
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
c=0
for i in range(n):
	for j in range(i+1,n):
		if l[j]+l[i] == j-i:
			c+=1
print(c)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
c=0
x=[]
y={}
for i in range(n):
	x.append(l[i]+i)
	if (i-l[i]) in y: 
		y[i-l[i]]+=1
	else:
		y[i-l[i]]=1
for i in x:
	if i in y :
		c+=y[i]

	
print(c)
### BUGGY CODE ###

n=int(input()) #　a1
ap = [int(input()) for i in range(n)]

psum=[]

for a in ap:
  if ap.count(a)%2==0:
    ap.remove(a)
  else:
    psum.append(a)

print(len(psum))

### FIXED CODE ###

n=int(input()) #　a1
s=set()
for i in range(n):
  s^={input()}
print(len(s))
### BUGGY CODE ###

n = int(input())
L = [int(i) for i in input().split()]
cnt = 0
ans = 1
for i in sorted(set(L),reverse=True):
  if L.count(i)>=4 and cnt==0:
    print(i*i)
    exit()
  elif 2<=L.count(i)<4:
    ans *= i
    cnt += 1
    if cnt == 2:
      break
  elif L.count(i)>=4 and cnt==1:
    ans *=i
    print(ans)
    exit()
print(0 if cnt<2 else ans)

### FIXED CODE ###

from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]
d = defaultdict(int)
for a in A:
  d[a] += 1
x = 1
cnt = 0
d = sorted(d.items(), key=lambda x:-x[0])
for i, j in d:
  if x == 1 and j >= 4:
    print(i**2)
    exit()
  if j >= 2:
    x *= i
    cnt += 1
    if cnt == 2:
      break
if cnt >= 1:
  print(x)
else:
  print(0)
### BUGGY CODE ###

# D Knapsack 1
import sys

sys.setrecursionlimit(10**8)

n, w = map(int,input().split())
wv_list = [[int(x) for x in input().split()] for y in range(n)]

dp = [[float("-Inf")] * (w+1) for _ in range(n+1)]
dp[0] = [0]*(w+1)
memo = [[False] * (w+1) for _ in range(n+1)]
memo[0] = [True] * (w+1)

def dp_solve(dp, wv_list, i, j):
    if memo[i][j]:
        return dp[i][j]
    _w,_v = wv_list[i-1]
    _ret = 0
    if j-_w < 0:
        _ret = dp_solve(dp, wv_list, i-1, j)
    else:
        _ret = max(dp_solve(dp, wv_list, i-1, j), dp_solve(dp, wv_list, i-1, j-_w) + _v)
    dp[i][j] = _ret
    memo[i][j] = True
    return _ret

print(dp_solve(dp, wv_list, n, w))

### FIXED CODE ###

# D Knapsack 1

from collections import deque

n, w = map(int,input().split())
wv_list = deque([[int(x) for x in input().split()] for y in range(n)])

dp = [[float("-Inf")] * (w+1) for _ in range(n+1)]
dp[0] = [0]*(w+1)

for i in range(n):
    _w,_v = wv_list.popleft()
    for j in range(w+1):
        if j-_w < 0:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-_w]+_v)

print(dp[n][w])
### BUGGY CODE ###

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

ans = []
for i in range(1<<n):
    x = 0
    for j in range(n):
        if (i>>j) & 1:
            x += s[j]
    if x % 10 == 0:
        ans.append(0)
    else:
        ans.append(x)

print(max(ans))

### FIXED CODE ###

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

sum_s = sum(s)
if sum_s % 10 != 0:
    print(sum_s)
    exit()

if all([1 if x % 10 == 0 else 0 for x in s]):
    print(0)
else:
    for i in range(n):
        if s[i] % 10 == 0:
            s[i] = 101
    s.sort()
    ans = sum_s - s[0]
    print(ans)