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

from collections import deque
l=lambda:[int(x) for x in input().split()]
H,W=l()
CH,CW=l()
DH,DW=l()
dh=DH-1
dw=DW-1
S=[[x=='#' for x in list(input())] for _ in range(H)]
q=deque([(0,CH-1,CW-1)])
checked=set()
def check(h,w,c,e):
    if h<0 or h>=H or w<0 or w>=W:
        return
    if S[h][w]:
        return
    if e==0:
        q.append((c,h,w))
    else:
        q.appendleft((c+e,h,w))

def main():
    while q:
        c,h,w=q.pop()
        if h==dh and w==dw:
            return c
        key=(h,w)
        if key in checked:
            continue
        checked.add(key)
        # walk
        check(h-1,w-0,c,0)
        check(h-0,w-1,c,0)
        check(h+1,w+0,c,0)
        check(h+0,w+1,c,0)
        # warp
        check(h,w-2,c,1)
        check(h,w+2,c,1)
        check(h-2,w,c,1)
        check(h+2,w,c,1)
        for i in [-2,-1,1,2]:
            for j in [-2,-1,1,2]:
                check(h+i,w+j,c,1)
    return -1
print(main())

### FIXED CODE ###

def l():
    return [int(x) for x in input().split()]
def main():
    H,W=l()
    ch,cw=l()
    dh,dw=l()
    ch-=1
    cw-=1
    dw-=1
    dh-=1
    s=[[-2 if x=='#' else -1 for x in list(input())] for _ in range(H)]
    pad1=[-2,-2]
    pad2=[[-2]*(W+4)]*2
    s=pad2+[pad1+x+pad1 for x in s]+pad2
    move1=[(-1,0),(1,0),(0,-1),(0,1)]
    move2=list(set([(i,j) for i in range(-2,3) for j in range(-2,3)])-set(move1)-set([(0,0)]))
    q1=[(0,ch+2,cw+2)]
    q2=[]
    s[ch+2][cw+2]=0
    def mark(c,h,w):
        #if 0<=h<H and 0<=w<W and s[h][w]==-1:
        if s[h][w]==-1:
            s[h][w]=c
            q1.append((c,h,w))
    while q1:
        #print(q1)
        c,h,w=q1.pop()
        for i,j in move1:
            mark(c,h+i,w+j)
        q2.append((c+1,h,w))
        if not q1:
            for c,h,w in q2:
                for i,j in move2:
                    mark(c,h+i,w+j)
            q2=[]
    ans=s[dh+2][dw+2]
    if ans>=0:
        print(ans)
    else:
        print(-1)
main()
### BUGGY CODE ###

L,R=map(int,input().split())
X=2019
for i in range (R-L):
    for j in range(R-L-i):
        if (L+i)*(L+i+j+1)%2019==0:
            X=0
            break
        elif X >(L+i)*(L+i+j+1)%2019:
            X=(L+i)*(L+i+j+1)%2019
print(X)


### FIXED CODE ###

L,R=map(int,input().split())
X=2019
for i in range (R-L):
    for j in range(R-L-i):
        if (L+i)*(L+i+j+1)%2019==0:
            X=0
            break
        elif X >(L+i)*(L+i+j+1)%2019:
            X=(L+i)*(L+i+j+1)%2019
    if X==0:
        break        
print(X)
### BUGGY CODE ###

import os, sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")
 
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7

def N(): return int(sys.stdin.readline())
def li(): return list(map(int, sys.stdin.readline().split()))
def bulk_li(): return list(map(lambda s: list(map(int, s.split())), sys.stdin.readlines()))

n, w = li()
wv = bulk_li()

# print(wv)
table = dict()

# 以下の条件で最大の価値の総和を返す
# i番目以降(i+1..n)の品物 / 残重量jのナップサック
def dp(i, j):
    if i == n:
        return 0
    if (i, j) in table:
        return table.get((i, j))

    w, v = wv[i]
    if w > j:
        return dp(i+1, j)

    table[(i, j)] = max(v + dp(i+1, j-w), dp(i+1, j))
    return table[(i, j)]

print(dp(0, w))


"""
"""


### FIXED CODE ###

import numpy as np
N, W = map(int, input().split())
ndp = np.full(1000*100+1, 10**11, dtype=np.int64)
ndp[0] = 0

for _ in range(N):
    w, v = map(int,input().split())

    np.minimum(ndp[:-v] + w, ndp[v:], out = ndp[v:])

print(np.max(np.where(ndp<=W)))

"""
https://atcoder.jp/contests/dp/submissions/6646897
から失敬

貪欲法はこの手の書き方で表現できるっぽい。
価値テープのなかで同価値のindexでは、より少ない重量の物品で済む方を残していく。
したがってテープの初期化は擬似infで行い、価値0の部分は重さも0で始める。

"""
### BUGGY CODE ###

N,M=map(int,input().split());D=[0]+[9e9]*(1<<N)
for i in range(M):
 a,_=input().split();s=sum(2**~-int(c)for c in input().split())
 for j in range(1<<N):t=s|j;D[t]=min(D[t],D[j]+int(a))
print(-1*(D[-2]>8e9)or D[-2])

### FIXED CODE ###

N,M=map(int,input().split());D=[0]+[9**9]*(1<<N)
for i in range(M):
 a=int(input().split()[0]);s=sum(1<<~-int(c)for c in input().split())
 for j in range(1<<N):D[s|j]=min(D[s|j],D[j]+a)
print(D[-2]%(9**9)or-1)
### BUGGY CODE ###

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

M = 10**9+7
ans = 0

def f(a, b, c):
    return a%M*b%M*c%M

for i in range(60):
    count = 0
    b = 1<<i
    for a in A:
        if (a&b) != 0:
            count += 1
    ans = (ans+f(count, N-count, b))%M

print(ans)


### FIXED CODE ###

N,*A=map(int,open(0).read().split())
print(sum((b:=1<<i)*(z:=sum(1 for a in A if a&b==0))*(N-z)%(mod:=10**9+7) for i in range(60))%mod)
### BUGGY CODE ###

def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    S = list(input())
    Sint = [1 if c == 'A' else 2 if c=='B' else 3 for c in S]
    N = len(S)

    ans = 0
    i = 0
    while i < N-2:
        if Sint[i] == 1 and Sint[i+1] == 2 and Sint[i+2] == 3:
            ans += 1
            Sint[i],Sint[i+1],Sint[i+2] = 2,3,1
            for j in range(i-1,-1,-1):
                if Sint[j] == 1:
                    ans += 1
                    Sint[j],Sint[j+1],Sint[j+2] = 2,3,1
                else:
                    break
            i += 2
        else:
            i += 1
    print(ans)



    
main()

### FIXED CODE ###

def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    S = list(input())
    S = [1 if c == 'A' else 2 if c=='B' else 3 for c in S]
    N = len(S)
    ans = 0
    continuous_one = 0
    i = 0

    while i < N-1:
        if S[i] == 1:
            continuous_one += 1
            i += 1
        elif S[i] == 2 and S[i+1] == 3:
            ans += continuous_one
            i += 2
        else:
            continuous_one = 0
            i += 1
    

    



    print(ans)



    
main()
### BUGGY CODE ###

a = int(input())
b = list(map(int, input().split()))
[print(b.count(i+1)) for i in range(a)]


### FIXED CODE ###

a = int(input())
b = list(map(int, input().split()))
c = [0 for i in range(a)]
for i in b:
  c[i-1] += 1
for j in c:
  print(j)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2000000001)
ab = abs; mn = min

def solve(n,k,ar,dp,x):
	if x>=n-2: return dp[x]
	if not dp[x] is -1: return dp[x]
	# for i in range(x+1,mn(n,x+k+1)):
	# 	t = ab(ar[x]-ar[i])+solve(n,k,ar,dp,i)
	# 	m = t if t<m else m
	dp[x] = mn(ab(ar[x]-ar[i])+solve(n,k,ar,dp,i) for i in range(x+1,mn(n,x+k+1)))
	# pr(f'{x} => {dp[x]}')
	return dp[x]

def main():
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [ab(ar[-2]-ar[-1]),0]
	# pr((n,k,ar,dp))
	pr(solve(n,k,ar,dp,0))

main()

### FIXED CODE ###

import sys
from functools import reduce
sys.setrecursionlimit(2000000001)

def solve(n,k,ar,dp,x):
	ab = abs; mn = min
	if x>=n-2: return dp[x]
	if not dp[x] is -1: return dp[x]
	# t = [ for i in range(x+1,mn(n,x+k+1))]
	t = map(lambda i:ab(ar[x]-ar[i])+solve(n,k,ar,dp,i), range(x+1,mn(n,x+k+1)))
	dp[x] = reduce(lambda a,b : a if a < b else b,t)
	return dp[x]

def main():
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	pr(solve(n,k,ar,dp,0))

main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from scipy.sparse.csgraph import floyd_warshall
    
def solve(s,t,edge):
    edge = floyd_warshall(edge)
 
    for i in range(n):
        for j in range(n):
            if edge[i][j]<=l:
                edge[i][j] = 1
            else:
                edge[i][j] = 0
 
    edge = floyd_warshall(edge)
 
    if edge[s-1][t-1] == float("inf"):
        return -1
    else:
        return int(edge[s-1][t-1] - 1)
      
n,m,l = map(int,input().split())
edge = [[0]*n for _ in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c
    
q = int(input())
for i in range(q):
  s,t = map(int,input().split())
  print(solve(s,t,edge))

### FIXED CODE ###

import sys
input = sys.stdin.readline
from scipy.sparse.csgraph import floyd_warshall
      
n,m,l = map(int,input().split())
edge = [[0]*n for _ in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c

edge = floyd_warshall(edge)
    
for i in range(n):
    for j in range(n):
        if edge[i][j]<=l:
            edge[i][j] = 1
        else:
            edge[i][j] = 0
                
edge = floyd_warshall(edge)

q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    if edge[s-1][t-1] == float("inf"):
        print(-1)
    else:
        print(int(edge[s-1][t-1] - 1))
### BUGGY CODE ###

def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(int, input().split(' ')))
    max_p_sum = 0
    sum_list = list()
    for n in range(0, N - K + 1, 1):
        hash_sum = sum(p_list[n: n + K])
        if max_p_sum < hash_sum:
            max_p_sum = hash_sum
            sum_list = p_list[n: n + K]
    expected_value = [(1 + s) / 2 for s in sum_list]
    print(sum(expected_value))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def expected_value(x):
    x = int(x)
    return (x + 1) / 2


def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(expected_value, input().split(' ')))
    cumulative_list = [0]
    for p in p_list:
        cumulative_list.append(cumulative_list[-1] + p)
    max_len = 0
    for i in range(0, N - K + 1):
        if max_len < cumulative_list[i + K] - cumulative_list[i]: max_len = cumulative_list[i + K] - cumulative_list[i]
    print(max_len)


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

def main():
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))
    d = {}
    d2 = {}
    d[0] = [0]
    s = 0
    for i in range(1, N+1):
        s = (s + A[i-1]) % K
        t = (s-i) % K
        if t in d:
            d[t].append(i)
        else:
            d[t] = [i]
        d2[i] = t
    a = 0
    for i in range(1, N+1):
        for j in d[d2[i]]:
            if i - K < j and j < i:
                a += 1
            if j >= i:
                break
    return a

print(main())


### FIXED CODE ###

def main():
    N, K = map(int,input().split())
    A = list(map(int, input().split()))
    s = 0
    d = {}
    d[0] = {0}
    r = 0
    l = [0] * (N + 1)
    for i, v in enumerate(A, start=1):
        if i - K >= 0:
           x = l[i - K]
           d[x].remove(i-K)
        s += v % K
        s %= K
        t = (s - i) % K
        l[i] = t
        if t in d:
            r += len(d[t])
            d[t].add(i)
        else:
            d[t] = {i}
    return r
print(main())
### BUGGY CODE ###

from collections import deque
from typing import List


def main():
    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        r = list(input())
        g.append(r)
    print(mm(h, w, g))


def mm(h: int, w: int, g: List[List[str]]) -> int:
    ret = 0
    for i in range(h):
        for j in range(w):
            if (g[i][j] == '#'):
                continue
            q = deque([(i, j, 0)])
            v = set()
            while q:
                ii, jj, cnt = q.popleft()
                v.add((ii, jj))
                ret = max(ret, cnt)
                # ↓
                if ii < h - 1 and g[ii + 1][jj] == '.' and (ii + 1, jj) not in v:
                    q.append((ii + 1, jj, cnt + 1))
                # →
                if jj < w - 1 and g[ii][jj + 1] == '.' and (ii, jj + 1) not in v:
                    q.append((ii, jj + 1, cnt + 1))
                # ↑
                if ii > 0 and g[ii - 1][jj] == '.' and (ii - 1, jj) not in v:
                    q.append((ii - 1, jj, cnt + 1))
                # ←
                if jj > 0 and g[ii][jj - 1] == '.' and (ii, jj - 1) not in v:
                    q.append((ii, jj - 1, cnt + 1))
    return ret


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque
from typing import List


def main():
    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        r = list(input())
        g.append(r)
    print(mm(h, w, g))


def mm(h: int, w: int, g: List[List[str]]) -> int:
    ret = 0
    for i in range(h):
        for j in range(w):
            if (g[i][j] == '#'):
                continue
            v = set()
            q = deque([(i, j, 0)])
            v.add((i, j))
            while q:
                ii, jj, cnt = q.popleft()
                ret = max(ret, cnt)
                # ↓
                if ii < h - 1 and g[ii + 1][jj] == '.' and (ii + 1, jj) not in v:
                    q.append((ii + 1, jj, cnt + 1))
                    v.add((ii + 1, jj))
                # →
                if jj < w - 1 and g[ii][jj + 1] == '.' and (ii, jj + 1) not in v:
                    q.append((ii, jj + 1, cnt + 1))
                    v.add((ii, jj + 1))
                # ↑
                if ii > 0 and g[ii - 1][jj] == '.' and (ii - 1, jj) not in v:
                    q.append((ii - 1, jj, cnt + 1))
                    v.add((ii - 1, jj))
                # ←
                if jj > 0 and g[ii][jj - 1] == '.' and (ii, jj - 1) not in v:
                    q.append((ii, jj - 1, cnt + 1))
                    v.add((ii, jj - 1))
    return ret


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

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

d = {}

for i in range(N):
    d[i+1] = []

for i in range(M):
    a, b = map(int,input().split())
    d[a].append(b)
    d[b].append(a)
que = [1]
checked = set([1])
ans = [-1]*(N-1)
while que:
    now = que.pop(0)
    for h in d[now]:
        if not h in checked:
            ans[h-2] = str(now)
            checked.add(h)
            que.append(h)
    
if len(checked) == N:
    print('Yes')
    print("\n".join(ans))
else:
    print('No')



### FIXED CODE ###

from collections import deque

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

d = {}

for i in range(N):
    d[i+1] = set()

for i in range(M):
    a, b = map(int,input().split())
    d[a].add(b)
    d[b].add(a)

que = deque([1])
checked = set()
ans = {1:-1}

while que:
    now = que.popleft()
    for h in d[now]:
        if not h in ans:
            ans[h] = now
            que.append(h)
    if len(ans) == N:
        break
    
if len(ans) == N:
    print('Yes')
    for i in range(N-1):
        print(ans[i+2]) 
else:
    print('No')
### BUGGY CODE ###

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

product = 1
for i in a:
    if i==0:
        product = 0
        break
    product *= i

if product > 10**18:
    print(-1)
else:
    print(product)


### FIXED CODE ###

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

product = 1

if 0 in a:
    product = 0
else:
    for i in a:
        product *= i
        if product > 10**18:
            product = -1
            break

print(product)
### BUGGY CODE ###

n = int(input())
import fractions

ans = 0
for i in range(1,n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            if i == j and j == k:
                ans += i
            
            elif len({i,j,k}) == 2:
                ans += fractions.gcd(fractions.gcd(i,j),k)*3
            
            elif len({i,j,k}) == 3:
                ans += fractions.gcd(fractions.gcd(i,j),k)*6
        
print(ans)

### FIXED CODE ###

n = int(input())
import math

ans = 0
for i in range(1,n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            if i == j and j == k:
                ans += i
            
            elif len({i,j,k}) == 2:
                ans += math.gcd(math.gcd(i,j),k)*3
            
            elif len({i,j,k}) == 3:
                ans += math.gcd(math.gcd(i,j),k)*6
        
print(ans)
### BUGGY CODE ###

# AGC009a
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # map(int, input().split())
    n = int(input())

    a = list()
    b = list()
    for _ in range(n):
        aa, bb = map(int, input().split())
        a.append(aa)
        b.append(bb)

    ans = 0
    dif = 0
    for i in range(n-1, -1, -1):
        while True:
            if (a[i]+dif) % b[i] == 0:
                break
            ans += 1
            dif += 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# AGC009a
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # map(int, input().split())
    n = int(input())

    a = list()
    b = list()
    for _ in range(n):
        aa, bb = map(int, input().split())
        a.append(aa)
        b.append(bb)

    ans = 0
    dif = 0
    for i in range(n-1, -1, -1):
        osu = b[i]-(a[i]+dif) % b[i] if (a[i]+dif) % b[i] != 0 else 0
        #print(a[i]+dif, b[i], osu, ans)
        ans += osu
        dif += osu
    print(ans)


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

S = input()
l = len(S)

count = 0
for i in range(0, l-3):
  for j in range(3, l):
    if i < (j-3):
      new_s = int(S[i:j+1])
      if new_s % 2019 == 0:
        count += 1
      else:
        continue
    else:
      continue
print(count)

### FIXED CODE ###

from collections import Counter
S=input()[::-1]
mod=2019

X = [0]
for i, s in enumerate(S):
  X.append((X[-1] + int(s)*pow(10, i, mod)) % mod)

C = Counter(X)
ans = 0
for v in C.values():
    ans += v * (v - 1) // 2
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
score = 1

for i in range(K):
    score *= A[i]

prev = score
for i,j in zip(range(K, N), range(N-K)):
    score /= A[j]
    score *= A[i]
    print("Yes" if score > prev else "No")
    prev = score

### FIXED CODE ###

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

for i,j in zip(range(K, N), range(N-K)):
    print("Yes" if A[i] > A[j] else "No")
### BUGGY CODE ###

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

for i in range(1, N+1):
  if A[i-1] == 1:
    count += N - i
    break
  else:
    for j in range(1, i+1):
      if A[j-1] < A[i-1]:
        count += 1
        break

ans = N - count
print(ans)

### FIXED CODE ###

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

M = N+1
ans = 0

for i in range(1, N+1):
  if M > A[i-1]:
    M = A[i-1]
    ans += 1

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

# 初期入力
N = int(input())
k = list(map(int, input().split()))

# 書かれている数字のぼーるがいくつあるか、辞書
from collections import Counter
A =Counter(k)

# 各数字を連続でとる場合の数
from math import factorial
def kumiawase_num(n, r): # 組み合わせ n「C」r
    if  n<r:
        return 0
    return factorial(n) // (factorial(n - r) * factorial(r))

# 順番付きの辞書
from collections import OrderedDict
D = OrderedDict()
D2 = OrderedDict()

for i,v in enumerate(k):
    D[i] =[ kumiawase_num(A[ij]-1,2) for ij,vj in A.items() if v == ij ]
    D2[i] = [ kumiawase_num(A[ij] ,2) for ij,vj in A.items() if v != ij ] 

D3 = [ sum(i) + sum(v) for i,v in zip(D.values(),D2.values()) ]      
print(*D3,sep="\n")

### FIXED CODE ###

from collections import Counter 
N = int(input())
A = list(map(int, input().split()))
c_A = Counter(A)
all =sum( [i*(i-1)//2 for i in c_A.values()] )

for i in range(N):
    ans =all -( c_A[A[i]] -1)
    print(ans)
### BUGGY CODE ###

d = {'A': True, 'B': False, 'C': False}

while True:
    try:
        a, t = input().split(',')
        d[a], d[t] = d[t], d[a]
    except:
        for k, v in d.items():
            if v:
                print(k)

### FIXED CODE ###

d = {'A': True, 'B': False, 'C': False}

while True:
    try:
        a, t = input().split(',')
        d[a], d[t] = d[t], d[a]
    except:
        for k, v in d.items():
            if v:
                print(k)
        break
### BUGGY CODE ###

import sys
from collections import defaultdict
input=sys.stdin.readline
d=defaultdict(int)
R,C,k=map(int,input().split())
for i in range(k):
  r,c,v=map(int,input().split())
  d[(r-1)*C+c-1]=v
dp=[[[0,0,0,0] for j in range(C+1)] for i in range(R+1)]
for i in range(1,R+1):
  for j in range(1,C+1):
    V=d[(i-1)*C+(j-1)]
    dp[i][j][0]=max(dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3],dp[i][j-1][0])
    dp[i][j][1]=max(dp[i-1][j][0]+V,dp[i-1][j][1]+V,dp[i-1][j][2]+V,dp[i-1][j][3]+V,dp[i][j-1][0]+V,dp[i][j-1][1])
    dp[i][j][2]=max(dp[i][j-1][1]+V,dp[i][j-1][2])
    dp[i][j][3]=max(dp[i][j-1][2]+V,dp[i][j-1][3])
print(max(dp[-1][-1]))

### FIXED CODE ###

import sys
input=sys.stdin.readline
R,C,k=map(int,input().split())
A=[[0]*C for i in range(R)]
for i in range(k):
  r,c,v=map(int,input().split())
  A[r-1][c-1]=v
dp0=[[0]*(C+1) for i in range(R+1)]
dp1=[[0]*(C+1) for i in range(R+1)]
dp2=[[0]*(C+1) for i in range(R+1)]
dp3=[[0]*(C+1) for i in range(R+1)]
for i in range(1,R+1):
  for j in range(1,C+1):
    V=A[i-1][j-1]
    dp0[i][j]=max(dp0[i-1][j],dp1[i-1][j],dp2[i-1][j],dp3[i-1][j],dp0[i][j-1])
    dp1[i][j]=max(dp0[i][j]+V,dp1[i][j-1])
    dp2[i][j]=max(dp1[i][j-1]+V,dp2[i][j-1])
    dp3[i][j]=max(dp2[i][j-1]+V,dp3[i][j-1])
print(max(dp0[-1][-1],dp1[-1][-1],dp2[-1][-1],dp3[-1][-1]))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
mod = p = 10**9+7
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

n, a, b = map(int, input().split())
nCa= 1
nCb= 1
for i in range(b):
    nCb = (nCb%p * (n-i)%p)%p
    nCb = nCb * mod_inv(i+1, p)
    if i+1 == a:
        nCa = nCb

ans = 2**n - 1- nCa%p - nCb%p
if ans < 0:
    print(0)
else:
    print(int(ans%p))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
mod = p = 10**9+7
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

n, a, b = map(int, input().split())
nCa= 1
nCb= 1
for i in range(b):
    nCb = (nCb%p * (n-i)%p)%p
    nCb = nCb * mod_inv(i+1, p)
    if i+1 == a:
        nCa = nCb

ans = 2**n - 1- nCa%p - nCb%p
if ans < 0:
    print(0)
else:
    print(int(ans%p))
### BUGGY CODE ###

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

for i in range(1 << N):
    s = sum(S)
    for j in range(N):
        if i & 1 << j:
            s -= S[j]
    # print(bin(i), s)
    if s % 10 != 0:
        print(s)
        break
else:
    print(0)


### FIXED CODE ###

N = int(input())
S = sorted([int(input()) for _ in range(N)])
s = sum(S)
if s % 10 != 0:
    print(s)
    exit()

for si in S:
    if si % 10 != 0:
        print(s - si)
        exit()

print(0)