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

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

def ten_to_bi(n):
    result_of_binary = ""
    while n>0:
        result_of_binary = result_of_binary + str(int(n%2))
        n = int((n-(n%2))/2)
    return(result_of_binary)

def bi_to_ten(bi):
    result_of_ten = 0
    for i in range(len(bi)):
        result_of_ten = result_of_ten + int(bi[i])*(2**i)
    return(result_of_ten)

def xor_bi(n,m):
    result_of_xor_bi = ""
    if len(m)>len(n):
        temp=n
        n,m = m,temp
    for i in range(len(n)-len(m)):
        m = m + "0"
    for i in range(len(n)):
        if n[i]==m[i]:
            result_of_xor_bi = result_of_xor_bi + "0"
        else:
            result_of_xor_bi = result_of_xor_bi + "1"
    return(result_of_xor_bi)
    
b = [ten_to_bi(a[i]) for i in range(N)]
c = "0"
for i in range(N-1):
    c = xor_bi(c,b[i+1])
d=[bi_to_ten(c)]

for i in range(N-1):
    c = xor_bi(c,xor_bi(b[i],b[i+1]))
    d.append(bi_to_ten(c))

Ans = ""
for i in range(N):
    Ans = Ans + str(d[i]) + " "

print(Ans)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
S = 0
for i in range(N):
    S ^= a[i]

Ans = ""
for i in range(N):
    print(S^a[i])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
 
b=list(set(a))
c=0
for i in range(len(b)):
    er = a.count( b[i] ) - b[i]
    if er<0:
        er = a.count( b[i] )
    c+=er
print(c)

### FIXED CODE ###

from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)
### BUGGY CODE ###

N,M=map(int,input().split())
list1=list(map(int,input().split()))
list2=[]
for _ in range(M):
  B,C=map(int,input().split())
  list2+=[C]*B
list2.sort(reverse=True)
list2=list2[:N]
list3=list1+list2
list3.sort(reverse=True)
list5=list3[:N]
SUM=sum(list5)
print(SUM)

### FIXED CODE ###

N,M = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort()
 
listBC = [list(map(int, input().split())) for i in range(M)]
listBC = sorted(listBC, key=lambda x: x[1], reverse=True)
countB = 0
 
for i in range(M):
  B, C = listBC[i][0], listBC[i][1]
  listA += [C]*B
  countB += B
  if countB >= N:
    break

listA.sort(reverse=True)
print(sum(listA[:N]))
### BUGGY CODE ###


N, M = map(int, input().split())

AB_list = [list(map(int,input().split())) for i in range(N)]
check = [0]*N
B = 0
flag = 0
payment = 0
for i in range(1, M+1):
    for j in range(0, N):
        if (AB_list[j][0] <= i) and (check[j] == 0) and (AB_list[j][1] > B):
            B = AB_list[j][1]
            c = j
            flag = 1
        
    payment = payment + B
    if flag == 1:
        check[c] = 1
    B = 0

print(payment)

### FIXED CODE ###

from heapq import heappush, heappop
import sys
input = sys.stdin.buffer.readline

N, M = map(int,input().split())
work = [[] for _ in range(10**5+1)]
ava = []
ans = 0

for i in range(N):
    A, B = map(int,input().split())
    work[A].append(-B)

for i in range(1, M+1):
    if len(work[i]) > 0:
        for j in work[i]:
            heappush(ava, j)
    if len(ava) > 0:
        ans -= heappop(ava)
print(ans)
### BUGGY CODE ###

N,K=map(int,input().split())
p=input().split()
P=[int(z) for z in p]
hopes=[(1+a)/2 for a in P]
def goukei(i):
    return sum(hopes[:i+1])
numbers=[]
for a in range(N):
    numbers.append(goukei(a))
answers=[]
for a in range(N-K):
    i=numbers[a+K]-numbers[a]
    answers.append(i)
answers.append(numbers[K-1])
print(max(answers))



### FIXED CODE ###

N,K=map(int,input().split())
p=input().split()
P=[int(z) for z in p]
hopes=[(1+a)/2 for a in P]
S=sum(hopes[:K])
answers=[S]
for a in range(1,N-K+1):
    S=S+hopes[a+K-1]-hopes[a-1]
    answers.append(S)
print(max(answers))
### BUGGY CODE ###

n,m = map(int,input().split())
h_input = list(map(int,input().split()))
A = [0]*m
B = [0]*m
for i in range(m):
    A[i],B[i] = map(int,input().split())

ans=0
for i in range(n):
    h1 = h_input[i]
    h2 = 0
    flag = True
    for j in range(m):
        if A[j]-1==i:
            h2 = h_input[B[j]-1]
        if B[j]-1==i:
            h2 = h_input[A[j]-1]
        if h2>=h1:
            flag=False
            break
    if flag:
        ans+=1
        
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
h_inputs = [int(i) for i in input().split()]
ab_inputs = [[int(j) for j in input().split()]for i in range(m)]

map_li = [1]*n
for line in ab_inputs:
    a,b = line[0],line[1]
    if h_inputs[a-1]>h_inputs[b-1]:
        map_li[b-1]=0
    if h_inputs[a-1]<h_inputs[b-1]:
        map_li[a-1]=0
    if h_inputs[a-1]==h_inputs[b-1]:
        map_li[a-1]=0
        map_li[b-1]=0
print(sum(map_li))
### BUGGY CODE ###


n=int(input())
s=str(input())
"""
n = 8
s = ".#####.#"
print(s)
print(len(s))
"""
def search(n,s):
    memo = []
    countwb=0
    now = s[0]
    count = 0
    if now == "#":
        memo.append(0)
    while(count<n):
        if s[count]==now:
            countwb+=1
        else:
            memo.append(countwb)
            countwb = 1
            now = s[count]
        count+=1
    memo.append(countwb)
    #print("memo",memo)

    count_b = []
    c_b = 0
    for  i in range(1,len(memo),2):
            c_b += memo[i]
            count_b.append(c_b)
    #print(count_b)

    count_w = []
    c_w = 0
    for  i in range(0,len(memo),2):
            c_w += memo[i]
            count_w.append(c_w)
    #print(count_w)

    #白白．．．黒黒にする
    w_b = 0
    if len(memo)%2==1:
        #最後が白
        w_b += memo[-1]
        if len(count_w)>1:
            new_n = n -  memo[-1]
            new_s = s[:int(-1*memo[-1])]
            #print("new_n",new_n)
            #print("new_s",new_s)
            w_b += search(new_n,new_s)
    else:
        #最後が黒
        if len(count_b)>1:
            new_n = n -  memo[-1]
            new_s = s[:int(-1*memo[-1])]
            #print("new_n",new_n)
            #print("new_s",new_s)
            w_b += search(new_n,new_s)
    #print("w_b",w_b)
    #全部白にする
    allw = 0
    if count_b!=[]:
        allw = count_b[-1]
    #print("allw",allw)
    #全部黒にする
    allb = 0
    if count_w!=[]:
        allb = count_w[-1]
    #print("allb",allb)

    return min(w_b,allb,allw)

print(search(n,s))

### FIXED CODE ###

n=int(input())
s=str(input())

#n = 9
#s = "........."
#print(s)
#print(len(s))

memo = []
countwb=0
now = s[0]
count = 0
if now == "#":
    memo.append(0)
while(count<n):
    if s[count]==now:
        countwb+=1
    else:
        memo.append(countwb)
        countwb = 1
        now = s[count]
    count+=1
memo.append(countwb)
#print(memo)

memo_r=[]
for i in range(len(memo)):
    memo_r.append(memo[-1*(i+1)])
#print(memo_r)

count_w = []
c_w = 0
if len(memo_r)%2==1:
    count_w.append(0)
    for  i in range(0,len(memo_r),2):
            c_w += memo_r[i]
            count_w.append(c_w)
else:
    count_w.append(0)
    count_w.append(0)
    for  i in range(1,len(memo_r),2):
            c_w += memo_r[i]
            count_w.append(c_w)
#print(count_w)

count_b = []
count_b.append(0)
count_b.append(0)
c_b = 0
for  i in range(1,len(memo),2):
        c_b += memo[i]
        count_b.append(c_b)
#print(count_b)

count_list = []
for i in range(len(count_b)):
    temp = count_w[-1*(i+1)]+count_b[i]
    count_list.append(temp)
#print(count_list)

print(min(count_list))
### BUGGY CODE ###

def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,k = i2()
h = intl()

dp = [0]*n
m = 10
for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[i] - h[0])
    else:
        dp[i] = min([int(abs(h[i] - h[i-p]) + dp[i-p]) for p in range(1,k+1) if i-p >= 0])
print(dp[-1])

### FIXED CODE ###

def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,k = i2()
h = intl()

dp = [0]*n
m = 10
for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[i] - h[0])
    else:
        dp[i] = min([int(abs(h[i] - h[i-p]) + dp[i-p]) for p in range(1,k+1) if i-p >= 0])
#print(dp)
print(dp[-1])
### BUGGY CODE ###

from fractions import gcd

def factorization(n):
    pf_cnt = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            pf_cnt[i] = cnt

    if temp != 1: pf_cnt[temp] = 1
    if not pf_cnt: pf_cnt[n] = 1
    return pf_cnt


def main():
    n = int(input())
    al = list(map(int, input().split()))

    # al_fac = [0]*n
    for i, a in enumerate(al):
        fac = factorization(a)
        # al_fac[i] = fac

    gcd_l = [1]*n
    gcd_r = [1]*n

    gcd_l[0] = al[0]
    gcd_r[-1] = al[-1]

    for i in range(1,n):
        next_l = al[i]
        gcd_l[i] = gcd(next_l, gcd_l[i-1])

        next_r = al[n-i-1]
        gcd_r[n-i-1] = gcd(next_r, gcd_r[n-i])


    ans = max(gcd_r[1], gcd_l[n-2])
    for i in range(1,n-1):
        curr_gcd = gcd(gcd_l[i-1], gcd_r[i+1])
        ans = max(ans, curr_gcd)

    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

from fractions import gcd

def factorization(n):
    pf_cnt = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            pf_cnt[i] = cnt

    if temp != 1: pf_cnt[temp] = 1
    if not pf_cnt: pf_cnt[n] = 1
    return pf_cnt


def main():
    n = int(input())
    al = list(map(int, input().split()))

    gcd_l = [1]*n
    gcd_r = [1]*n

    gcd_l[0] = al[0]
    gcd_r[-1] = al[-1]

    for i in range(1,n):
        next_l = al[i]
        gcd_l[i] = gcd(next_l, gcd_l[i-1])

        next_r = al[n-i-1]
        gcd_r[n-i-1] = gcd(next_r, gcd_r[n-i])


    ans = max(gcd_r[1], gcd_l[n-2])
    for i in range(1,n-1):
        curr_gcd = gcd(gcd_l[i-1], gcd_r[i+1])
        ans = max(ans, curr_gcd)

    print(ans)


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

import sys
input = sys.stdin.readline
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
b = [list(map(int, input().split())) for _ in range(h)]
m = (h + w - 1) * 80 + 1
dp = [[[False] * m for _ in range(w)] for _ in range(h)]
dp[0][0][abs(b[0][0] - a[0][0])] = True
for i in range(h):
    for j in range(w):
        x = abs(b[i][j] - a[i][j])
        for k in range(m):
            if i > 0:
                if 0 <= abs(x + k) < m:
                    dp[i][j][abs(x + k)] |= dp[i-1][j][k]
                if 0 <= abs(x - k) < m:
                    dp[i][j][abs(x - k)] |= dp[i-1][j][k]
            if j > 0:
                if 0 <= abs(x + k) < m:
                    dp[i][j][abs(x + k)] |= dp[i][j-1][k]
                if 0 <= abs(x - k) < m:
                    dp[i][j][abs(x - k)] |= dp[i][j-1][k]

for i in range(m):
    if dp[h-1][w-1][i]:
        print(i)
        exit()

### FIXED CODE ###

import sys
input = sys.stdin.readline
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
b = [list(map(int, input().split())) for _ in range(h)]
ab = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        ab[i][j] = abs(a[i][j] - b[i][j])

m = 12800
dp = [[0] * w for _ in range(h)]
dp[0][0] = (1 << (m + ab[0][0])) | (1 << (m - ab[0][0]))
for i in range(h):
    for j in range(w):
        for dx, dy in [(1, 0), (0, 1)]:
            nx, ny = i + dx, j + dy
            if 0 <= nx < h and 0 <= ny < w:
                dp[nx][ny] = dp[nx][ny] | (dp[i][j] << ab[nx][ny])
                dp[nx][ny] = dp[nx][ny] | (dp[i][j] >> ab[nx][ny])

#print(dp[-1][-1])
for i in range(m+1):
    if (dp[h-1][w-1] >> i) & 1:
        ans = m - i

print(ans)
### BUGGY CODE ###

n, x = map(int, input().split())
A = list(map(int, input().split()))

def segfunc(x, y):
    return min(x, y)

def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])

def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2])

def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element
ide_ele = 10**9+1

# num: n以上の最小の2のべき乗
num = 2**(n-1).bit_length()
seg = [ide_ele]*2*num

init(A)

ans = 10**19
for k in range(n):
    t = k*x
    for i in range(n):
        if k <= i:
            t += query(i-k, i+1)
        else:
            t += min(query(0, i+1), query(n-(k-i), n))
    ans = min(t, ans)
print(ans)


### FIXED CODE ###

import sys

n, x = map(int,sys.stdin.readline().split())
A = list(map(int,sys.stdin.readline().split()))

ans = 10**18
mins = [a for a in A]
for k in range(n):
    for i in range(n):
        if k <= i:
            mins[i] = min(A[i-k], mins[i])
        else:
            mins[i] = min(A[n-(k-i)], mins[i])
    ans = min(sum(mins)+k*x, ans)
print(ans)
### BUGGY CODE ###

def cmb(n,k, MOD):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

MOD = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
ascA = sorted(a)

fac  = [0 for _ in range(n-1)]
finv = [0 for _ in range(n-1)]
inv  = [0 for _ in range(n-1)]

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,n-1):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

sum_ = 0
for i in range(n-k+1):
    for j in range(i+k-1, n):
        f = ascA[j]-ascA[i]
        c = cmb(j-i-1, k-2, MOD)
        #print("%d %d"%(f,c))
        sum_ = (sum_ + (f*c) % MOD) % MOD

print(sum_)


### FIXED CODE ###

def cmb(n,k, MOD):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

MOD = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
ascA = sorted(a)

MAX_N = n
fac  = [0 for _ in range(MAX_N)]
finv = [0 for _ in range(MAX_N)]
inv  = [0 for _ in range(MAX_N)]

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,MAX_N):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

sum_ = 0
for i in range(n-k+1):
    f = ascA[n-i-1] - ascA[i]
    c = cmb(n-i-1, k-1, MOD)
    sum_ = (sum_ + (f*c)%MOD) % MOD
    '''
    for j in range(i+k-1, n):
        f = ascA[j]-ascA[i]
        c = cmb(j-i-1, k-2, MOD)
        #print("%d %d"%(f,c))
        sum_ = (sum_ + (f*c) % MOD) % MOD
    '''

print(sum_)
### BUGGY CODE ###

A=list(map(int,input().split()))
count=0
while len(A) !=0:
  count+=1
  while count < A.count(A[0]):
    A=A.remove(A[0])
print(count)

### FIXED CODE ###

N=int(input())
z=[]
for num in range(101):
  z.append(0)
counter=0
while counter < N:
  d=int(input())
  z[d]=1
  counter+=1
result=sum(z)
print(result)
### BUGGY CODE ###

import numpy as np

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

num_A = [A.count(i) for i in range(10**5+1)]

for i in range(Q):
    b, c = map(int, input().split())
    num_A[c] += num_A[b]
    num_A[b] = 0
    print(sum(np.array(num_A)*np.array([j for j in range(10**5+1)])))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

num_A = [0 for i in range(10**5+1)]
first = 0

for a in A:
    num_A[a] += 1
    first += a

for i in range(Q):
    b, c = map(int, input().split())
    first += c*num_A[b]
    first -= b*num_A[b]
    num_A[c] += num_A[b]
    num_A[b] = 0
    print(first)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
for _ in range(Q):
    l,r = map(int,input().split())
    print(S[l-1:r].count('AC'))


### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
s = [0]
cnt = 0
for i in range(N-1):
    if S[i:i+2] == 'AC':
        cnt += 1
    s.append(cnt)
for _ in range(Q):
    l,r = map(int,input().split())
    print(s[r-1]-s[l-1])
### BUGGY CODE ###

import sys
import bisect
input = sys.stdin.readline
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    f = list(map(int,input().split()))
    if sum(a)<=k:
        print(0)
    else:
        a.sort()
        f.sort(reverse=True)
        mul=[]
        for i in range(n):
            mul.append([a[i]*f[i],a[i]])
        mul.sort(reverse=True)
        for _ in range(k):
            mul[0][0]-=(mul[0][0]//mul[0][1])
            mul[0][1]-=1
            if mul[0][0]<mul[1][0]:
                mul.sort(reverse=True)
        print(mul[0][0])
main()

### FIXED CODE ###

def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder
    # ord(c) chr(2) alphabet <=> number
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    f = list(map(int,input().split()))
    a.sort()
    f.sort(reverse=True)
    ok = 10**12
    ng=-1

    while ok-ng>1:
        mid=(ok+ng)//2
        cnt=0
        for x,y in enumerate(a):
            cnt+=max(0,y-mid//f[x])
        if cnt>k:
            ng=mid
        else:
            ok=mid
    print(ok)
main()
### BUGGY CODE ###

def main():
    ans = 0
    m = 2019
    div_list = [0]*m
    div_list[0] += 1
    S = list(input())
    N = len(S)

    num = 0
    for i in range(N):
        num += 10**i*int(S.pop())
        div_list[num%m] += 1

    for item in div_list:
        ans += int(item*(item-1)/2)

    print(ans)

if __name__ == "__main__":
    main()




### FIXED CODE ###

from sys import stdin
input = stdin.readline

def main():
    S = list(input())
    S.pop()
    m = 2019
    div_list = [0]*m
    num = 0
    for i, l in enumerate(reversed(S)):
        num += pow(10, i, m)*int(l)
        div_list[num%m] += 1

    div_list[0] += 1
    ans = 0
    for item in div_list:
        ans += int(item*(item-1)/2)

    print(ans)

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

I=9**9
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I]*h*w
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[t]<=d[s]:break
   q+=t,;d[t]=d[s]+1
print(d[~w+f*w+g]%I-1)

### FIXED CODE ###

I=9**9
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I]*h*w
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[t]<=d[s]:break
   if d[t]==I:q+=t,;d[t]=d[s]+1
print(d[~w+f*w+g]%I-1)
### BUGGY CODE ###

a , b , x = map(int,input().split())
cnt = 0
for i in range(a , b+1):
    if i % x == 0:
        cnt += 1
print(cnt)


### FIXED CODE ###

a , b , x = map(int,input().split())
cnt = 0
a = (a - 1 ) // x
b //= x
print(b - a)
### BUGGY CODE ###

def get_sum(n, index, s, slist):
    if index == n:
        if s % 10 == 0:
            s = 0
        return s
    left = get_sum(n, index + 1, s + slist[index], slist)
    right = get_sum(n, index + 1, s, slist)
    return max(left, right)


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

sum = 0
print(get_sum(N, 0, sum, sl))


### 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,m=map(int,input().split())
L=[list(map(int,input().split())) for i in range(m)]
#print(L)
M=0
ans = set(range(L[M][0],L[M][1]+1))
for M in range(m):
  a=set(range(L[M][0],L[M][1]+1))
  ans = a&ans
  #print(ans)
print(len(list((ans))))


### FIXED CODE ###

import numpy as np
n,m=map(int,input().split())
L=[list(map(int,input().split())) for i in range(m)]
list = np.asarray(L)

MAX=np.max(list,axis=0)
MIN=np.min(list,axis=0)

ans = MIN[1]-MAX[0]+1
if ans>0:
  print(MIN[1]-MAX[0]+1)
else:
  print(0)
### BUGGY CODE ###

h,n=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]

dp=[float('inf')]*(h+1)
dp[0]=0
for a,b in AB:
  for i in range(h):
    if i+a>=h:
      dp[h]=min(dp[h],dp[i]+b)
    else:
      dp[i+a]=min(dp[i+a],dp[i]+b)
print(dp[h])

### FIXED CODE ###

h,n=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]

dp=[float('inf')]*(h+1)
dp[0]=0
for a,b in AB:
  for i in range(h):
    if i+a>=h:
      dp[h]=min(dp[h],dp[i]+b)
    else:
      dp[i+a]=min(dp[i+a],dp[i]+b)
print(dp[h])
### BUGGY CODE ###

n = int(input())
s = list(input())

ww = [0]*n
ee = [0]*n
ww[-1] = s.count('W')
ee[-1] = s.count('E')
for i in range(n-1):
  ww[i] = s[:i+1].count('W')
  ee[i] = s[:i+1].count('E')
      
l = [0]*n
l[0] = ee[-1]
l[-1] = ww[-2]
for i in range(1,n-1):
  l[i] = ww[i-1] + ee[-1] - ee[i]
    
  
print(min(l))


### FIXED CODE ###

import sys

n, s = sys.stdin.read().split()

def main():
    cnt = s.count('E')
    cur = 'E'
    res = [cnt]
    for c in s:
        if cur == 'W': cnt += 1
        if c == 'E': cnt -= 1
        res.append(cnt)
        cur = c
    print(min(res))
    
if __name__ ==  '__main__':
    main()
### BUGGY CODE ###

class BIT:
    '''https://tjkendev.github.io/procon-library/python/range_query/bit.html'''
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def query(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)
      
N,Q=map(int,input().split())
*A,=map(int,input().split())
bit = BIT(N)
for i in range(N):
  bit.add(i+1,A[i])
for i in range(Q):
  q,a,b = map(int,input().split())
  if q:
    print(bit.query(a,b))
  else:
    bit.add(a+1,b)

### FIXED CODE ###

class BIT:
    '''https://tjkendev.github.io/procon-library/python/range_query/bit.html'''
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def query(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)
      
N,Q=map(int,input().split())
*A,=map(int,input().split())
bit = BIT(N)
for i in range(N):
  bit.add(i+1,A[i])
for i in range(Q):
  q,a,b = map(int,input().split())
  if q:
    print(bit.query(a,b))
  else:
    bit.add(a+1,b)