peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
input=sys.stdin.buffer.readline

# a1 = 0としてよい

A = [0,None,None]
B = [None,None,None]

bl = True
for i in range(3):
  C = [int(x) for x in input().split()]
  for j,c in enumerate(C):
    if A[i] is None:
      A[i] = c - B[j]
    if B[j] is None:
      B[j] = c - A[i]
    if A[i]+B[j] != c:
      bl = False

answer = 'Yes' if bl else 'No'
print(answer)
# Judge status: Accepted
n=int(input())
for i in range(1,10):
  if n%i==0 and n//i<10:
    print('Yes')
    exit()
print('No')
# Judge status: Accepted
a,b = input().split()
n = int(a+b)
if (n ** .5).is_integer():
    print('Yes')
else:
    print('No')
# Judge status: Accepted
L = list(map(int, input().split()))
list.sort(L)
print(L[0]+L[1])
# Judge status: Wrong Answer
l,r,d = map(int,input().split())
b = l/d
a = r/d
if d==1:
  b-=1

print(int(a)-int(b))
# Judge status: Accepted
t=input()
print(t.replace('?','D'))
# Judge status: Accepted
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())
abcd = [[int(i) for i in input().split()] for _ in range(q)]
s = 0
for p in combinations_with_replacement(range(1, m + 1), n):
    t = 0
    for a, b, c, d in abcd:
        t += d * (p[b - 1] - p[a - 1] == c)
    s = max(s, t)
print(s)
# Judge status: Wrong Answer
N,M = map(int,input().split())
A = list(map(int,input().split()))
import heapq
heapq.heapify(A)
for i in range(M):
    a = A.pop()
    a = a//2
    heapq.heappush(A,a)
ans = sum(A)
print(ans)
# Judge status: Accepted
N=int(input())
s = sorted(list(map(int,input().split())))
print(abs(sum(s[:N:2])-sum(s[1:N:2])))
# Judge status: Accepted
ans = sum(map(int, input().split()))
if ans > 21:
  print('bust')
else:
  print('win')
# Judge status: Wrong Answer
n,k,*a = map(int,open(0).read().split())
def func(b):
  c = k
  for i in a:
    if b == 0:
      c -= (i+1)
    else:
      c -= i//b
    if c < 0:
      return False
  return True
l = 0
r = max(a)
while(r>l):
  lr = (l+r)//2
  if func(lr):
    r = lr
  else:
    l = lr + 1
print(r)
# Judge status: Wrong Answer
N=int(input())
print('Yes' if N%4==0 or N%7==0 or (N%7)%4==0 else 'No')
# Judge status: Accepted
num_ate_food = int(input())

total_cost = num_ate_food * 800
cash_back = 0

if num_ate_food >= 15:
    cash_back = (num_ate_food // 15) * 200

total_paid = total_cost - cash_back
print(total_paid)
# Judge status: Accepted
def main():
    inside_rate, outside_rate = map(int, input().split())
    correction = 0
    if inside_rate < 10:
        correction = 100 * (10 - inside_rate)
    print(outside_rate + correction)
main()
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
cnt = 0

if N == 1:
    print(0)
    exit()

for i in range(1, N):
    if A[i] >= A[i - 1]:
        continue
    else:
        cnt += A[i - 1] - A[i]
        A[i] = A[i - 1]
print(cnt)
# Judge status: Accepted
h, n = map(int, input().split())

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

dp = [float("inf")] * (h+1)
dp[0] = 0

for i in range(h):
    for j in range(n):
        next_index = min(i + A[j], h)
        dp[next_index] = min(dp[next_index], dp[i] + B[j])

print(dp[-1])
# Judge status: Accepted
h, a = map(int, input().split())

cnt = 0
while h > 0:
    h -= a
    cnt += 1

print(cnt)
# Judge status: Accepted
print("YES" if int(input().replace(" ", "")) % 4 == 0 else "NO")
# Judge status: Accepted
import copy

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

As = [copy.copy(Bs[0])]
As.extend(copy.copy(Bs))

#print(Bs)
#print(As)

for index, B in enumerate(Bs):
#    print(Bs)
#    print(As)
    if B < As[index]:
        As[index] = B

#print(As)
print(sum(As))
# Judge status: Accepted
n, m = map(int, input().split())

X = [0]*n
C = [1]*n
X[0] = 1

for i in range(m):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    if X[x] == 1:
        X[y] = 1
        if C[x] == 1:
            X[x] = 0
        C[x] -= 1
        C[y] += 1
    else:
        C[x] -= 1
        C[y] += 1

ans = sum(X)
print(ans)
# Judge status: Accepted
n =int(input())
ans = 0
for i in range(1,n+1):
  ans += i
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())

ans = 0
for i in range(a, b+1, 1):
    i = str(i)
    if i==i[::-1]:
        ans+=1
print(ans)
# Judge status: Wrong Answer
import sys
import math
import bisect

def main():
    a, b, c = map(int, input().split())
    #a, b = (b, a)
    a, b = b, a
    b, c = c, b
    print('%d %d %d' % (a, b, c))

if __name__ == "__main__":
    main()
# Judge status: Accepted
K,X=map(int,input().split())
print("Yes" if 500*K>=X else "No")
# Judge status: Wrong Answer
def nyu():
    L,R = map(int,input().split())
    return L,R


def convert(LL,LR):
    LL = LL % 2019
    LR = LR % 2019

    return LL,LR

def kansu(LL,LR):

    ans = 2020

    for ll in range(LL,LR):
        for lr in range(LL+1,LR+1):
            tmp  = (ll * lr) % 2019
            if ans > tmp:
                ans = tmp

    print(ans)

ML,MR = nyu()
ML,MR = convert(ML,MR)
kansu(ML,MR)
# Judge status: Accepted
N=int(input())
k=0
s=0
m=0
L=list(map(int,input().split()))
for i in range(N):
  if L[i]==i+1:
    m+=1
  else:
    s+=m//2+m%2
    m=0
s+=m//2+m%2
print(s)
# Judge status: Accepted
import math
A,B,H,M=map(int,input().split())
b=2*math.pi*(M/60)
a=2*math.pi*((H/12) + (M/(60*12)))
t=abs(a-b)
if t>math.pi:
  t=2*math.pi-t
print(math.sqrt(A**2+B**2-2*A*B*math.cos(t)))
# Judge status: Wrong Answer
list = [int(input()) for i in range(5)]
K = int(input())
lists = sorted(list)
no = 0
for I in range(4):
  if lists[no+1] - lists[no] <= K:
    no += 1
  else:
    print(":(")
    exit()
print("Yay!")
# Judge status: Wrong Answer
x,y,z=map(int,input().split())
print((x-1)//(y+z))
# Judge status: Wrong Answer
x, n = map(int, input().split())
seisulist = list(map(int, input().split()))
if n != 0 and max(seisulist) > x:
    size = max(seisulist) + 1
else:
    size = x + 1
numlist = [i for i in range(-1*size,size) if i not in seisulist]
xretu = [x]*len(numlist)
hikizan = [abs(s-t) for (s, t) in zip(numlist, xretu)]
sa = min(hikizan)
if x-sa not in seisulist:
    print(x-sa)
else:
    print(x+sa)
# Judge status: Wrong Answer
S=input()
T=input()
l=len(S)
if S==T:
    print("Yes")
    exit()

for i in range(l):
    tmp=S[-1]
    S=S.strip(S[-1])
    new_string=tmp+S
    
    if new_string==T:
        print("Yes")
        exit()
    
    S=new_string

print("No")
# Judge status: Accepted
from collections import deque

k = int(input())

q = deque(range(1, 10))
for _ in range(k):
    x = q.popleft()
    if x % 10 != 0:
        q.append(x*10 + x%10 - 1)
    q.append(x*10 + x%10)
    if x % 10 != 9:
        q.append(x*10 + x%10 + 1)

print(x)
# Judge status: Accepted
#!/usr/bin/env python3
s = input()
t = input()
n = len(s)
ans = 0
for i in range(n):
    if s[i] != t[i]:
        ans += 1
print(ans)
# Judge status: Accepted
K = int(input())
sevens = 7
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    while True:
        if sevens % K == 0:
            print(i)
            break
        sevens = (sevens % K)*10+7
        i += 1
# Judge status: Wrong Answer
s = list(map(str, input().split()))
counter = 0

for si in s:
    if si == '1':
        counter += 1
print(counter)
# Judge status: Wrong Answer
N, A, B, C, D = map(int, input().split())
s = input()
flag = True

if C > D:
    if "..." in s[B-2:D+1]:
        flag = False
    if "##" in s:
        print("Yes")
    else:
        if flag:
            print("No")
        else:
            print("Yes")
else:
    if "##" in s:
        print("No")
    else:
        print("Yes")
# Judge status: Accepted
X  = int(input())

if 400 <= X < 600:
    A = 8
if 600 <= X < 800:
    A = 7
if 800 <= X < 1000:
    A = 6
if 1000 <= X < 1200:
    A = 5
if 1200 <= X < 1400:
    A = 4
if 1400 <= X < 1600:
    A = 3
if 1600 <= X < 1800:
    A = 2
if 1800 <= X < 2000:
    A = 1

print(A)
# Judge status: Wrong Answer
n=int(input())

lis=[1 for i in range(10**7)]


for i in range(2,10**7+1):
    for j in range(1,(10**7)//i+1):
        lis[i*j-1]+=1
print("A")
s=0
for i in range(n):
    s+=lis[i]*(i+1)

print(s)
# Judge status: Wrong Answer
N = int(input())
v = sorted(list(map(int, input().split())))
for i in range(N-1):
    a = (v[i]+v[i+1])/2
    v[i+1] = int(a)
    v[i] = 'A'
    a = 0
print(v[-1])
# Judge status: Accepted
N = int(input())

if N%1000 == 0:
  print(0)
else:
  print(1000-N%1000)
# Judge status: Wrong Answer
N,K=map(int,input().split())
h=[int(input()) for _ in range(N)]
h.sort()
a=max(h[:K])
b=min(h[:K])
c=max(h[-K:])
d=min(h[-K:])
print(min(a-b,c-d))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
joushi = [0 for _ in range(N)]
for Ai in A:
    joushi[Ai-1] += 1

for ans in joushi:
    print(ans)
# Judge status: Accepted
#n=int(input())
n,k=map(int,input().split())
l=list(map(int,input().split()))
mul=1
for i in range(k):
  mul=mul+l[i]
z=mul
j=0
for i in range(k,n):
  z=z-l[j]
  z=z+l[i]
  if z>mul:
    print('Yes')
  else:
    print('No')
  j+=1
  mul=z
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    print('ABC'if N < 1000 else 'ABD')


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
ans = 10**18
total = sum(A)
acc = 0
for a in A:
  acc += a
  ans = min(ans, abs(total - acc * 2))
print(ans)
# Judge status: Accepted
a,b,c,d = map(int,input().split())
for i in range(10**10):
    if i%2 == 0:
        c-=b
    else:
        a-=d
    if a <= 0:
        print("No")
        break
    elif c <= 0:
        print("Yes")
        break
# Judge status: Wrong Answer
n=input()
ans=0
for i in range(len(n)):
    ans+=int(n[i])
if ans==n[0]:
    ans+=9
print(ans)
# Judge status: Accepted
N,K=map(int, input().split())
*A,=map(int, input().split())

print(((N-1)+(K-1)-1)//(K-1))
# Judge status: Accepted
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
ab = sorted(ab,key=lambda x: x[1])
now = 0
for i in ab:
    if i[1] >= now + i[0]:
        now += i[0]
    else:
        print("No")
        exit()
print("Yes")
# Judge status: Wrong Answer
import numpy as np

n, m = map(int, input().split())
probability = [0 for _ in range(n)]
ball = [1 for _ in range(n)]
probability[0] = 1
for i in range(m):
    x, y = map(int, input().split())
    prob = probability[x-1]
    probability[x-1] = prob * (ball[x-1] - 1) / ball[x-1]
    probability[y-1] += prob / ball[x-1]
    ball[x-1] -= 1
    ball[y-1] += 1
print(np.sum(np.array(probability) > 0))
# Judge status: Wrong Answer
n = int(input())
ans = n%1000
if (0<=ans and ans<=500):
    print(ans)
else:
    print(1000 - ans)
# Judge status: Accepted
w,h,n=map(int,input().split())
lx=0
rx=w
sy=h
iy=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        lx=max(lx,x)
    elif a==2:
        rx=min(rx,x)
    elif a==3:
        iy=max(iy,y)
    else:
        sy=min(sy,y)
x=rx-lx
y=sy-iy
if x<0 or y<0:
    print(0)
    exit()
print(x*y)
# Judge status: Wrong Answer
a, b = map(str,input().split())
print(a+b)
# Judge status: Wrong Answer
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
list1 = [i for i in range(1, n + 1)]
ans_a = 0
ans_b = 0
for i in range(n):
    if p[i] != 1:
        ans_a += (p[i]-1)** (n-i-1)
    if q[i] != 1:
        ans_b += (q[i]-1) ** (n-i-1)
print(ans_a)
print(ans_b)
# Judge status: Wrong Answer
N, M = map(int, input().split())
sc = []
tf = True
for i in range(M):
  sc.append(list(map(int, input().strip().split())))
num = []
for i in range(N):
  num.append(0)
sc.sort()
for i in range(M-1):
  if sc[i][0] == sc[i+1][0] and sc[i][1] != sc[i+1][1]:
    tf = False
for i in sc:
  if i[0] == 1 and i[1] == 0:
    tf = False
  else:
    num[i[0]-1] = i[1]
if tf and num[0] == 0:
  num[0] = 1
string = ""
for i in num:
  string += str(i)
if tf == True:
  print(string)
else:
  print(-1)
# Judge status: Wrong Answer
from math import floor

N = [int(_) for _ in input().split()]

H, W = N[0], N[1]


def solve(H, W):
    
    if H == 1 or W == 1:
        return 1
    
    cnt = int(H * W / 2)
    return cnt

print(solve(H, W))
# Judge status: Wrong Answer
import sys
S = input()
T = input()
s = len(S)
t = len(T)
if s < t:
    print('UNRESTORABLE')

for i in range(s - t, 0, -1):
    OK = True
    for j in range(t):
        if S[i + j] != T[j] and S[i + j] != '?':
            OK = False
    if OK:
        for j in range(t):
            SS = S[:i] + T + S[i + j + 1:]
            SS = SS.replace('?', 'a')
        print(SS)
        sys.exit()

print('UNRESTORABLE')
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
x = l[0]
y = sum(l[1:])

if x < y:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = input()

print("×"*len(n))
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))
d = {}
for i in l:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1
sumz = sum(l)
for _ in range(int(input())):
    b,c = map(int, input().split())
    if b in d:
        sumz = sumz +( ((d[b]*c) - (d[b]*b)) )
        if c not in d:
            d[c] = d[b]
        else:
            d[c] += d[b]
        del d[b]
    print(sumz)
# Judge status: Wrong Answer
from itertools import combinations
N = int(input())
town = []
for n in range(N):
    x, y = map(int,input().split())
    town.append((x,y))

ans = 0
for i,j in combinations(town,2):
    ans += ((i[0]-j[0])**2 + (i[1]-j[1])**2)**0.5
print ((N-1)*ans/N)
# Judge status: Accepted
x, a, b = map(int, input().split())

if abs(x - a) > abs(x - b):
    print('B')
else:
    print('A')
# Judge status: Accepted
import collections
N = int(input())
A = collections.Counter(int(input()) for T in range(N)).most_common()
Num = 0
for T in range(len(A)):
    if A[T][1]%2!=0:
        Num += 1
print(Num)
# Judge status: Accepted
l = list(map(int, input().split()))
l = sorted(l)
if l[0] + l[1] == l[2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s=input()
if len(s)==len(set(s)):
    print('yes')
else:
    print('no')
# Judge status: Wrong Answer
A, B = map(int, input().split())

count = 0
for i in range(A, B):
    n = list(str(i))
    _n = n[::-1]
    if n == _n:
        count += 1

print(count)
# Judge status: Accepted
import numpy as np

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

A=[0 for _ in range(N)]
B=[0 for _ in range(N)]
C=[0 for _ in range(N)]

for i in range(M):
    p,S = input().split()
    p = int(p)-1
    if S == "AC":
        A[p] = 1
        C[p] = B[p]
    elif A[p]==0:
        B[p] += 1
    
A = np.array(A)
C = np.array(C)
print(np.sum(A), np.sum(C))
# Judge status: Accepted
A, B, K = map(int, input().split())

l = []
for i in range(1, 1000):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])
# Judge status: Wrong Answer
N = int(input())
H = list(map(int, input().split()))

flg = 1
for i in range(N-1):
    if H[i] - H[i+1] >= 2:
        flg = 0
        break
    if H[i] - H[i+1] == 1:
        if i == 0:
            continue
        if H[i-1] == H[i]:
            flg = 0
            break
        H[i] -= 1
if flg == 1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A,B,C=map(int,input().split())
if A*C<=B:
    print(C)
else:
    print(int(B/A))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

Sum = sum(A)
ans = 0
for i in range(N):
  Sum = Sum-A[i]
  AA = Sum*A[i]
  ans += AA
  ans = ans%(10**9 + 7)
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
q = -((-B+1)//(A-1))
 
print(q)
# Judge status: Accepted
n, k = map( int, input().split() )
r, s, p = map( int, input().split() )
t = str( input() )

t_list = [ c for c in t ]
for i in range( k, n ):
    if t_list[ i ] == t_list[ i - k ]:
        t_list[ i ] = "x"

score = 0
for hand in t_list:
    if hand == "r":
        score += p
    elif hand == "s":
        score += r
    elif hand == "p":
        score += s

print( score )
# Judge status: Accepted
S = input()
while True:
    S = S[:-1]
    if len(S)%2 == 0:
        if S[:len(S)//2] == S[len(S)//2:]:
            print(len(S))
            exit(0)
# Judge status: Accepted
s = input()

dDic = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1 }

print(int(dDic[s]))
# Judge status: Wrong Answer
n, k = (int(x) for x in input().split())

num = 0
for x in range(k, n + 1):
    minnum = sum(i for i in range(k))
    maxnum = sum (i for i in range(n - k + 1,n + 1))
    num += maxnum - minnum + 1

print(num)
# Judge status: Wrong Answer
n=int(input())
a=sorted(list(map(int,input().split())))
b=set()
ans=0
d={}
cnt=0
for i in range(n-1):
    cnt+=1
    if i==n-2 and a[i]==a[i+1]:
        cnt+=1
        d[a[i]]=cnt
        break    
    if a[i]!=a[i+1]:
        d[a[i]]=cnt
        cnt=0
for i in d.keys():
    if d[i]>=i:
        ans+=d[i]-i
    else:
        ans+=d[i]
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A.sort()

result = {}

for i in range(N):
  if A[i] not in result:
    result[A[i]] = 1
  else:
    result[A[i]] += 1
  
count = 0

for i in result.keys():
  if result[i] > i:
    count += abs(i-result[i])
  elif result[i] < i:
    count += result[i]

  
print(count)
# Judge status: Accepted
a,b=map(int,input().split())
for i in range(1,b):
    if a*i%b==0:
        print(a*i)
        break
else:
    print(a*b)
# Judge status: Wrong Answer
def readints():
    return list(map(int, input().split()))


a, b, c, d = map(int, input().split())
if (abs(a-b) <= d or abs(b-c) <= d) or abs(a-c) <= d:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
T, A = [int(i) for i in input().split(" ")]
temp = [T-0.006*int(h) for h in input().split(" ")]

place = 0
diff_min = 60

for cnt, t in enumerate(temp):
  if abs(A-t) < diff_min:
    diff_min = abs(A-t)
    place = cnt

print(place)
# Judge status: Accepted
A, B, C, K = map(int, input().split())
print((A-B)*(-1)**(K%2))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
x = [0]
for i in a:
    x.append(x[-1]+i)
ans = 10**11
for i in x[1:-1]:
    ans = min(ans,abs(i*2-x[-1]))
print(ans)
# Judge status: Accepted
#
import sys
import math
import numpy as np
import itertools


# いくつか入力
n,k = (int(i) for i in input().split())

a = n % k
c = k - a

print(min(a,c))
# Judge status: Accepted
# ABC166 B

def main():
    n, k = map(int, input().split())
    
    sunuke = [0] * n

    for i in range(k):
        d = int(input())
        A = list(map(int, input().split()))

        for j in A:
            sunuke[j-1] += 1
    
    print(sunuke.count(0))



if __name__ == '__main__':
    main()
# Judge status: Accepted
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
c = {"r": p, "s": r, "p": s}

ans = 0
wins = [False] * k

for i in range(n):
    if not wins[i % k] or t[i] != t[i-k]:
        ans += c[t[i]]
        wins[i % k] = True
    else:
        wins[i % k] = False

print(ans)
# Judge status: Accepted
from sys import stdin, setrecursionlimit
from collections import deque
from bisect import bisect_left


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = deque()
    for ai in a:
        idx = bisect_left(ans, ai)
        if idx == 0:
            ans.appendleft(ai)
        else:
            ans[idx - 1] = ai

    print(len(ans))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
# Judge status: Wrong Answer
a, b = map(int, input().split())
print('Evan' if a*b%2==0 else 'Odd')
# Judge status: Wrong Answer
N = int(input())
a = []
a = input().split()

count = 0

for i in range(int(N/2)):
  cd = 2 * i - 1
  jd = int(a[cd])
  if jd % 2 == 1:
    count += 1
    

print(count)
# Judge status: Accepted
N, M = map(int, input().split())

ans = []

for i in range(M):
    if N % 2 != 0 or (M + (i + 1)) - (M - (i)) < N // 2:
        tmp = [str(M - (i)), str(M + (i + 1))]
    else:
        tmp = [str(M - (i)), str(M + (i + 2))]
    tmp = ' '.join(tmp)
    ans.append(tmp)
print(*ans, sep='\n')
# Judge status: Accepted
n = input()

hons = ["2", "4", "5", "7", "9"]

pons = ["0", "1", "6", "8"]

ans = ""

for i in hons:
    if n[-1] == i:
        ans = "hon"

for i in pons:
    if n[-1] == i:
        ans = "pon"

if n[-1] == "3":
    ans = "bon"

print(ans)
# Judge status: Accepted
import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = map(int, input().split())
    Aplus = [0] * N
    for i, a in enumerate(A):
        Aplus[i] = i + a + 1
    A_counter = Counter(Aplus)

    ans = 0
    for i in range(1, N + 1):
        key = i * 2 - Aplus[i-1]
        ans += A_counter[key]
        if key == Aplus[i - 1]:
            ans -= 1
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
def combinations_count(n):
  return n*(n-1)//2
s = input()
l = len(s)
lis = []
for i in reversed(range(l)):
  if i == l-1:
    lis.append(int(s[l-1])%2019)
    tem = int(s[l-1])
    tem2 = 1
  else:
    tem2 = (10*tem2)%2019
    kk = (int(s[i])*tem2+tem)%2019
    tem = kk
    lis.append(kk)
lis.append(0)
lis.sort()
ll = len(lis)
ans = 0
tem = 1
for i in range(1, ll):
  if lis[i-1] == lis[i]:
    tem += 1
  elif tem >= 2:
    ans += combinations_count(tem)
    tem = 1
print(ans)
# Judge status: Accepted
#B
import math
n=int(input())
ans=None
for i in range(1,54000):
    if math.floor(i*1.08)==n:
        ans=i
        break
    if i==n-1:
        ans=":("
print(ans)
# Judge status: Accepted
X,N = map(int,input().split())

min = 100

if N !=0:
  Plist = list(map(int,input().split()))
  anslist = [i for i in range(102)]
  anslist.append(-1)
  #anslist.remove(0)
  Plist = sorted(Plist)
  #print (anslist)
  for i in range(N):
    anslist.remove(Plist[i])
    temp =100
  for i in range(len(anslist)):
    if min >abs(anslist[i]-X) :
      min = abs(anslist[i]-X)
      temp = anslist[i]
  print (temp)
else :
  print (X)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

ans = 0

if (1 not in a):
    print(-1)
else:
    for i in range(1,n):
        if (i not in a):
            break
        else:
            ain = a.index(i)
            ans += ain
            del a[i:ain]
    print(ans)
# Judge status: Accepted

import bisect


def main():
  n = int(input())
  a = [int(input()) for _ in range(n)]

  tail = []
  len_tail = 0
  for ai in a:
    idx = bisect.bisect_right(tail, -ai, lo=0, hi=len_tail) 
    if idx == len_tail:
      tail.append(-ai)
      len_tail += 1
    else:
      tail[idx] = - ai

  print(len_tail )


if __name__ == "__main__":
  main()
# Judge status: Wrong Answer
n = int(input())
s = [0] * n
for i in range(n):
    s[i] = int(input())

ans = 0
for i in range(n ** 2):
    score = 0
    for j in range(n):
        if i >> j & 1:
            score += s[j]
        
    if score % 10 != 0:
        ans = max(ans, score)

print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
if n*2 < m:
    while n*2 <= m:
        if m - 2*n > 100000:
            m -= 60000
            n += 30000
        elif m - 2*n > 10000:
            m -= 6000
            n += 3000
        else:
            m -= 2
            n += 1
    print(n - 1)
else:
    print(m//2)
# Judge status: Wrong Answer
N,M = map(int,(input().split()))
ab = [int(input().replace(' ',''))for _ in range(M)]
#print(ab)
abc=''
ans = []
for i in ab:
    abc+=str(i)
#print(int(abc))

for j in range(1,N+1):
    print(abc.count(str(j)))
# Judge status: Accepted
a = list(map(int, input().split()))

a.sort()

if a[0]+a[1] == a[2]:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N, X, Y = (int(x) for x in input().split())
line = [(i,i+1) for i in range(1,N)]
line.insert(X-1, (X,Y))

dis = [[N*2]*(N+2) for _ in range(N+2)]
for i in range(1, N):
    for j in range(i+1, N+1):
        if i <= X and Y <= j:
            dis[i][j] = (X-i) + (j-Y) + 1
        else:
            dis[i][j] = j-i

fdis = sum(dis, [])
fdis = [x for x in fdis if x != N*2]
for k in range(1,N):
    print(fdis.count(k))
# Judge status: Accepted
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=list(map(int,input().split(" ")))
print("Yes") if (c[0] in a and c[1] in a) or (c[0] in b and c[1] in b) else print("No")