peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
color = input()

kosuu = input()

trashc = input()

_ = 0

color = color.split()
kosuu = kosuu.split()
trashc = trashc.split()


while True:
  if(trashc[0] == color[_]):
    if(int(kosuu[_]) > 0):
    	answer = int(kosuu[_]) -1
    	break
    else:
      answer = 0
      break
      
  _= _+1
    
print(answer)
# Judge status: Accepted
from collections import defaultdict
import bisect
def f():
    return []

d=defaultdict(f)
n=int(input())
a=list(map(int,input().split()))
x=[i+1+a[i] for i in range(n)]
y=[i+1-a[i] for i in range(n)]
for i in range(n):
    d[y[i]].append(i)

ans=0
for i in range(n):
    ans+=len(d[x[i]])
print(ans)
# Judge status: Accepted
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n-1, -1, -1):
    if (a[i][0]+cnt)%a[i][1] != 0:
        cnt += a[i][1] - ((a[i][0]+cnt)%a[i][1])
print(cnt)
# Judge status: Accepted
import sys
import math

from collections import Counter

# input処理を高速化する
input = sys.stdin.readline

N=int(input())
Keihin =[]
for i in range(N):
    syouhin = input()
    Keihin.append(syouhin)

c=Counter(Keihin)
print(len(list(c.keys())))
# Judge status: Accepted
n = int(input())
c = {}
m = 0
for i in range(n):
    s = input()
    if s in c:
        c[s] += 1
    else:
        c[s] = 1
    if m < c[s]:
        m = c[s]

ans = []

for i in c:
    if m == c[i]:
        ans.append(i)

ans = sorted(ans)

for i in ans:
    print(i)
# Judge status: Accepted
n = int(input())

arr = []
for i in range(1,10):
    for j in range(1,10):
        arr.append(i*j)

if n in arr:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
dp = list(range(n+1))
dp[0] = 0
for i in range(1, n+1):
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power]+1)
        power *= 6
    power = 1
    while power < i:
        dp[i] = min(dp[i], dp[i-power]+1)
        power *= 9
print(dp[n])
# Judge status: Accepted
# -*- coding: utf-8 -*-
S = list(input())
S[3] = '8'
print(''.join(S))
# Judge status: Accepted
a,b,c = map(int, input().split())
if a + b < c:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
n = "keyence "
s = input()
cnt = 0


for i in s:
    if n[0] == i:
        n = n[1:]
        if cnt > 0:
            cnt = -1
    elif n[0] != i:
        if cnt == -1:
            break
        cnt += 1

if n == " ":
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
a, b = [int(i) for i in input().split()]
if a*b%2:
  c = a*b
else:
  c = a*b+1
print(c)
# Judge status: Accepted
N = int(input())

x = 0
while x < N:
    x = x + 1000

output = x - N
print(output)
# Judge status: Accepted
A,B,M=map(int,input().split())
a= list(map(int,input().split()))
b= list(map(int,input().split()))

waribiki=[]

for _ in range(M):
    waribiki.append(list(map(int,input().split())))

MIN=min(a)+min(b)

for wari in waribiki:
    x=wari[0]-1
    y=wari[1]-1
    value=wari[2]
    total=a[x]+b[y]-value
    if(total < MIN):
        MIN=total

print(MIN)
# Judge status: Accepted
n,m = map(int,input().split())
if(2*n >= m):
    print(m//2)
else:
    m -= 2*n
    print(n + (m//4))
# Judge status: Accepted
A, B, C = input().split()
if C != A == B:
    print("Yes")
elif A != B == C:
    print("Yes")
elif B != C == A:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = input()
a = len(s)
if s[a-1] == 's':   
    print(s+'es')
else:
    print(s+'s')
# Judge status: Accepted
a,s,c,k = map(int,input().split())
if a>=k:
  print(k)
elif a+s>=k:
  print(a)
else:
  print(a - (k-a-s))
# Judge status: Wrong Answer
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
for i in range(n):
    ans += a[i] // 2
    a[i] %= 2

for i in range(n - 1, 0, -1):
    num = min(a[i - 1], a[i])
    ans += num

print(ans)
# Judge status: Accepted
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A2.reverse()

for i in range(N-1):
  A1[i+1] += A1[i]
  A2[i+1] += A2[i]
  
ans = 0
for i in range(N):
  ans = max(ans, A1[i]+A2[N-1-i])
  
print(ans)
# Judge status: Wrong Answer
def main():
  ans = 0
  n,m = map(int, input().split())
  if n == m == 1:
      ans = 1
  elif n == 1:
      ans = m-2
  else:
      ans = (n-2)*(m-2)
  print(ans)

if __name__ == '__main__':
  main()
# Judge status: Wrong Answer
N, K = map(int, input().split())
S = input()

unhappy = 0
if S[0] == "L":
    unhappy += 1
if S[-1] == "R":
    unhappy += 1
for i in range(1, N-1):
    if S[i:i+2] == "RL":
        unhappy += 2

if unhappy > 3:
    if unhappy > K:
        print(N-(unhappy-2*K))
    else:
        print(N-1)
else:
    print(N-1)
# Judge status: Accepted
S = input()
T = input()
s = {d:[] for d in set(S)}
t = {d:[] for d in set(T)}

for i, (j,k) in enumerate(zip(S,T)):
    s[j] += [i]
    t[k] += [i]
a = sorted(s.values())
b = sorted(t.values())

print('Yes' if a==b else "No")
# Judge status: Wrong Answer
S= input()
i=0

while True:
    flag = False
    if S[i:i+7] == "dreamer":
        i += 7
        flag = True

    if S[i:i+6] == "eraser":
        i += 6
        flag = True
    
    if S[i:i+5] == "erase" or S[i:i+5] == "dream":
        i += 5
        flag = True

    if not flag:
        break

if i == len(S):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]

b = sorted(a)

for i in a:
    if i == b[-1]:
        print(b[-2])
    else:
        print(b[-1])
# Judge status: Accepted
import heapq

n, m = map(int, input().split())
lis = []
for i in range(m + 1):
    lis.append([])

for i in range(n):
    a, b = map(int, input().split())
    if a <= m:
        lis[a].append(-b)

cnd = []
heapq.heapify(cnd)
res = 0

for j in range(1, m + 1):
    for e in lis[j]:
        heapq.heappush(cnd, e)
    if cnd:
        res += -heapq.heappop(cnd)
print(res)
# Judge status: Wrong Answer
s=str(input())
t=str(input())
temps=list(set(s))
tempt=list(set(t))
temps=sorted(list(temps))
tempt=sorted(list(tempt))
for i in range(0,len(temps)):
  temps[i]=s.count(temps[i])
for i in range(0,len(tempt)):
  tempt[i]=t.count(tempt[i])
if temps==tempt:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import math
n = int(input())
for i in range(int(math.sqrt(n)),-1,-1):
    if n%i == 0:
        if i == 1:
            print((n//i)-1)
        else:
            print(n//i)
        exit()
# Judge status: Accepted
s=len(input())
print("x"*s)
# Judge status: Wrong Answer
N = int(input())
num = 0

for i in range(N):
    if(i%3 != 0 and i%5 !=0):
        num += i

print(num)
# Judge status: Accepted
N=int(input())
for c in range(100//4+1):
  for d in range(100//7+1):
    if c*4+d*7==N:
      print("Yes")
      exit()
print("No")
# Judge status: Wrong Answer
N = int(input())
H = list(map(int, input().split()))

kugiri = []
tmp = 0
for i in range(1,N):
    if H[i-1] < H[i]:
        tmp += 1
        kugiri.append(tmp)
        continue
    tmp += 1
kugiri = [0] + kugiri + [N-1]

ans = 0
for i in range(1,len(kugiri)):
    tmp = kugiri[i] - kugiri[i-1]
    ans = max(ans,tmp)
print(ans)
# Judge status: Accepted
r = int(input())
R = int(r*r)
print(R)
# Judge status: Wrong Answer
n = int(input())
A=[0]*n
maxd = 0
smax = 0
for i in range(n):
	A[i] = int(input())
	if A[i] >= maxd:
		smax = maxd
		maxd =A[i]
for i in range(n):
	if A[i]==maxd:
		print(smax)
	else:
		print(maxd)
# Judge status: Wrong Answer
A, B, K = map(int, input().split())
l = list()
a = 0
c = 0
if A > B:
    c = A
else:
    c = B
for i in range(1, c + 1):
    if A % i == 0 and B % i == 0:
        l.append(i)
        
for i in range(len(l)):
    if i + 1 == K:
        a = l[i]

print(a)
# Judge status: Accepted
from collections import Counter
abc = Counter(input().split())
if len(abc) == 2:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
社員数 = int(input())
部下数 = [0] * 社員数

for 上司 in map(int, input().split(' ')):
    部下数[上司-1] += 1

for 部下 in 部下数:
    print(部下)
# Judge status: Accepted
s=list(input())
k=int(input())
tmp=0
for i in s:
    ans=i
    if ans!="1":
        break
    else:
        tmp+=1
if tmp>=k:
    print("1")
else:
    print(ans)
# Judge status: Accepted
N=int(input())
S=input()
x=0
M=0
for i in range(len(S)):
  if S[i]=='I':
    M=max(x+1,M)
    x=x+1
  else:
    x=x-1
print(M)
# Judge status: Accepted
s = input()

for i in range(len(s)):
    if (i + 1) % 2 == 1 and s[i] == "L":
        print("No")
        break
    elif (i + 1) % 2 == 0 and s[i] == "R":
        print("No")
        break
else:
    print("Yes")
# Judge status: Wrong Answer
N, K = map(int,input().split())
print(N%K)
# Judge status: Wrong Answer
import math
list = input().split()
a=int(int(list[0]))
b=int(float(list[1])*100)
ans = a*b
print(ans)
# Judge status: Wrong Answer
#!/usr/bin/env python3
import sys

N = int(input())
a = [int(s) for s in input().split()]
b = [0]*N
sum_box = 0
index = 2
list_box = []

for i in range(N-1,-1,-1):
    if (i+1) <= N//index:
        index += 1

    if sum(b[i::(N//(index-1))]) % 2 != a[i]:
        b[i] = 1
        sum_box += 1
        list_box.append(str(i+1))
        
print(sum_box)
    
if sum_box > 0:
    print(''.join(list_box))
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i500 in range(a+1):
  for i100 in range(b+1):
    for i50 in range(c+1):
      total = (i500*500) + (i100*100) + (i50*50)
      if total == x:
        cnt += 1

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

if N!=100:
    print(N*(100**D))
else:
    print(101*(100**D))
# Judge status: Accepted
s = input()
print("x" * len(s))
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
print(c-(a-b))
# Judge status: Wrong Answer
if __name__ == "__main__":
    N, W = map(int, input().split())
    dp = [0] * (W+1)

    for i in range(N):
        weight, value = map(int, input().split())
        for w in range((W - weight)+1):
        # for w in range((W - weight), -1, -1):
            dp[w + weight] = max(dp[w + weight], dp[w] + value)

        # dp = new_dp

    print(dp)
    print(dp[-1])











"""
6 15
6 5
5 6
6 4
6 6
3 5
7 2


3 8
3 30
4 50
2 60
"""
# Judge status: Accepted
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

A = sorted([a for a,_ in AB])
B = sorted([b for _,b in AB])

if N % 2 == 1: # 奇数
    MIN = A[(N + 1) // 2 - 1]
    MAX = B[(N + 1) // 2 - 1]

else: # 偶数
    MIN = A[N // 2 - 1] + A[N // 2]
    MAX = B[N // 2 - 1] + B[N // 2]

print(MAX - MIN + 1)
# Judge status: Accepted
n = int(input())
X = list(map(int, input().split()))
x = sorted(X)
l = x[n//2-1]
r = x[n//2]
for i in range(n):
    if X[i] <= l:
        print(r)
    else:
        print(l)
# Judge status: Wrong Answer
x=int(input())
if x<=100:
    print(0)
    exit()
if x>=2000:
    print(1)
    exit()
else:
    t=x//100
    a=x%100
    if t<=a<=t*5:
        print(1)
    else:
        print(0)
# Judge status: Wrong Answer
def isu(x , y , z):

    ans = x // (y + z)

    return ans if (x % (y + z) * (y + z)) + z < x else ans - 1
def main():
    x , y , z = map(int , input().split())
    print(isu(x , y , z))


if __name__ == '__main__':
    main()
# Judge status: Accepted
k = int(input())
l = k // 2
m = (k + 1) // 2
print(l * m)
# Judge status: Accepted
import math
n, d = map(int, input().split())
xy = [map(int, input().split()) for _ in range(n)]
cnt = 0

for x, y in xy:
    if math.sqrt(x**2 + y**2) <= d:
        cnt += 1

print(cnt)
# Judge status: Accepted
data  = [int(_) for _ in input().split()]
enemy = [int(_) for _ in input().split()]

if len(enemy) < data[1]:
    print(0)
    exit()
elif data[1] == 0:
    print(sum(enemy))
else:
    enemy.sort()
    
    print(sum(enemy[:-data[1]]))
# Judge status: Accepted
s = int(input())

a = [s]
used = [0] * (10**6+1)
used[s] = 1
for i in range(2, 10**6+2):
    if a[-1] % 2 == 0:
        a.append(val := a[-1]//2)
    else:
        a.append(val := 3*a[-1]+1)

    if used[val]:
        print(i)
        break
    else:
        used[val] = 1
# Judge status: Accepted
s = input()
s = s[:-2]
while False in [s[i]==s[i+len(s)//2] for i in range(len(s)//2)]:
    s = s[:-2]
print(len(s))
# Judge status: Wrong Answer
a, b, c, k = map(int, input().split())
print(a-(k-a-b))
# Judge status: Wrong Answer
n = int(input())
ans = n // 2

if n % 2:
    print(ans)
else:
    print(ans + 1)
# Judge status: Accepted
x = int(input())

N = x // 11
M = x % 11

if M == 0:
  ans = 0
elif M <= 6:
  ans = 1
else:
  ans = 2

print(2*N + ans)
# Judge status: Wrong Answer
a, b = input().split()
c = int(a + b)

ok = False
for i in range(1, 10 * 6):
    if c == i * i:
        ok = True
        break

if ok:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from string import ascii_lowercase
alp=ascii_lowercase
ans=[float("inf")]*26
n=int(input())
for i in range(n):
    cnt=[0]*26
    s=input()
    for j in s:
        p=alp.index(j)
        cnt[p]+=1
    for j in range(26):
        ans[j]=min(ans[j],cnt[j])
output=[]
for i in range(26):
    for j in range(ans[i]):
        output.append(alp[i])
print("".join(output))
# Judge status: Accepted
n = int(input())
if n <= 999:
    print('ABC')
else:
    print('ABD')
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def f(x):
    if x == 0:
        return 1
    if x == 1:
        return x
    else:
        return x * f(x-1)

nlist = list(range(1, n+1))

po = 0
for i in range(n):
    po += f(n-i-1)*nlist.index(p[i])
    nlist.remove(p[i])
po+=1
nlist = list(range(1, n+1))
qo = 0
for i in range(n):
    qo += f(n-i-1)*nlist.index(q[i])
    nlist.remove(q[i])
qo+=1
print(abs(po-qo))
# Judge status: Accepted
import math
a,b,c=map(int,input().split())
if 4*a*b<(c-a-b)*(c-a-b) and c>a+b:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
MOD = 10**9+7

a = 8
b = 1
c = 1
d = 0

for _ in range(N-1):
    at = a * 8
    bt = b * 9 + a * 1
    ct = c * 9 + a * 1
    dt = b * 1 + c * 1 + d * 10
    a = at % MOD
    b = bt % MOD
    c = ct % MOD
    d = dt % MOD

print(d)
# Judge status: Accepted
def main():
    S = input()
    print('x' * len(S))


main()
# Judge status: Accepted
#abc083 c Multiple Gifts 
x, y = map(int, input().split())
a = x
ans = 0
while a <= y:
    a *= 2
    ans += 1
print(ans)
# Judge status: Wrong Answer
from collections import Counter
N = int(input())
An = list(map(int, input().split()))
counter = Counter(An)
cnt = 0
for c in counter.values():
    cnt += c * c-1 // 2
for a in An:
    print(cnt - (counter[a] - 1))
# Judge status: Wrong Answer
n,k = map(int,input().split())
x = list(map(int,input().split()))
lst = []
for x_ in x:
    if x_ < 0:
        lst.append((abs(x_), -1))
    else:
        lst.append((x_, 1))
lst.sort(key=lambda x:x[0])

pn = [0,0]
for i in range(k):
    if lst[i][1]==1:
        pn[0] = lst[i][0]
    else:
        pn[1] = lst[i][0]

print(min(pn)*2+max(pn))
# Judge status: Wrong Answer
from itertools import combinations_with_replacement

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

query = tuple(tuple(map(int, input().split())) for _ in range(Q))

ans = 0
for comb in combinations_with_replacement(range(1, M+1), N):
    print(comb)
    score = 0
    for a, b, c, d in query:
        if comb[b-1] - comb[a-1] == c:
            score += d
    ans = max(ans, score)
print(ans)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cont = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                cont += 1

print(cont)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

cnt_m, cnt_z = 0, 0

for a in A:
    if a < 0:
        cnt_m += 1
    elif a == 0:
        cnt_z += 1

B = list(map(abs, A))

if cnt_m % 2 == 0 or cnt_z > 0:
    print(sum(B))
else:
    print(sum(B) - min(B)*2)
# Judge status: Accepted
from fractions import gcd

def lcm(a,b): return a*b//gcd(a,b)

n=int(input())
a=[int(i) for i in input().split()]
l=1
mod=10**9+7
for i in range(n):
    l=lcm(l,a[i])
ans=0
for i in a:
    ans+=l//i
print(ans%mod)
# Judge status: Accepted
a = list(map(int,input().split()))
print(sum(a)+max(a)*(2**int(input())-1))
# Judge status: Accepted
D,N = map (int, input ().split ())
if N == 100:
  X = (100**D)*(N+1)
else:
  X = (100**D)*N
print (X)
# Judge status: Accepted
# coding: utf-8


def main():
    N = int(input())
    ans = 0
    B = list(map(int, input().split()))
    ans += B[0] + B[-1]

    for i in range(1, N - 1):
        ans += min(B[i - 1], B[i])

    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N=int(input())
a=[]
b=a
for _ in range(N):
  a_=int(input())
  a.append(a_)
x=max(a)
if a.count(x)>=2:
  for i in range(N):
    print(x)
else:
  for i in range(N):
    if a[i]==x:
      b.sort()
      print(b[-2])
    else:print(x)
# Judge status: Wrong Answer
n = int(input())
al = list(map(int, input().split()))
al.sort()
t = al[0]
ans = t
for a in al:
    if a % t == 0:
        continue
    else:
        ans = 1
print(ans)
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
lisa=[]
lisb=[]
for i in range(1,a+1):
  if a%i==0:
    lisa.append(i)
for j in range(1,b+1):
  if b%j==0:
    lisb.append(j)
for l in lisa:
  if l in lisb:
    k-=1
    if k==0:
      print(l)
      break
# Judge status: Wrong Answer
A,B,C=map(int,input().split())

if C**0.5*(10**5)>A**0.5*(10**5)+B**0.5*(10**5):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import fractions
N = int(input())
A = [int(x) for x in input().split()]
kouho_set = set()
kouho_set = [0] * (N + 1)
kouho_set[0] = set()
kouho_set[0].add(A[1])
nowgcd = A[0]
for i in range(1, N):
    kouho_set[i] = set()
    for j in kouho_set[i-1]:
        kouho_set[i].add(fractions.gcd(A[i], j))
    kouho_set[i].add(nowgcd)
    nowgcd = fractions.gcd(A[i], nowgcd)
# print(kouho_set)
print(max(kouho_set[N-1]))
# Judge status: Accepted
N=int(input())
v=sorted(list(map(int,input().split())))
for i in range(N-1):
  v[i+1]=(v[i]+v[i+1])/2

print(v[N-1])
# Judge status: Accepted
N, K = map(int,input().split())
ans = 0
for i in range(1,N+1):
    c = 0
    while(i < K):
        i *= 2
        c += 1
    ans +=  1 / 2 ** c
print(1/N * ans)
# Judge status: Accepted
import functools
import operator

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
ans = 0
v = sum(A)
for i in range(N-1):
    v -= A[i]
    ans += A[i]*v
print(ans%mod)
# Judge status: Wrong Answer
#!/usr/bin/env python3

A,B,C = [int(i) for i in input().split()]

M = []
for i in range(1,100+1):
    if (A*i)%B in M:
        break
    else:
        M.append((A*i)%B)

if C in M:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N, K = map(int, input().split())
print(K-(N//K))
# Judge status: Wrong Answer
n, m = map(int, input().split())
AB = []
for i in range(n):
    a, b  = map(int, input().split())
    AB.append((a, b))
AB.sort(key=lambda ab: -ab[1])
counts = [0] * m
used = [False] * m
total = 0
score = 0
for a, b in AB:
    if a > m:
        continue
    for i in range(a - 1 + counts[a - 1], m):
        if used[i]:
            continue
        used[i] = True
        counts[a - 1] += 1
        total += 1
        score += b
        break
    if total == m:
        break
print(b)
# Judge status: Accepted
import itertools
N,K = [int(hoge) for hoge in input().split()]
RSP = [int(hoge) for hoge in input().split()]
T = input()
Hand = [[] for i in range(K)]

for n,d in enumerate(T):
    if d == "r":
        t = 2
    elif d == "s":
        t = 0
    else:
        t = 1
    Hand[n%K].append(t)

ans = 0
for k in Hand:
    Hands = itertools.groupby(k)
    for h in Hands:
        l = len(list(h[1]))
        ans +=  RSP[h[0]] * ((l+1)//2)
    
print(ans)
# Judge status: Wrong Answer
def main(a, b):
    ans = 0

    for i in range(a, b + 1):
        s = str(i)

        if s[:len(s) // 2] == s[(len(s) // 2) + 1:]:
            ans += 1

    print(ans)


if __name__ == "__main__":
    a, b = map(int, input().split())
    main(a, b)
# Judge status: Wrong Answer
x,a,b = map(int, input().split())
if b - a < x and b - a > 0 :
    print("safe")
elif b - a < x and b - a < 0 :
    print("delicious")
else:
    print("dangerous")
# Judge status: Accepted
N,K=map(int,input().split())
S=input()
s=S[:K-1]
s+=S[K-1].swapcase()
s+=S[K:]
print(s)
# Judge status: Accepted
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
# Judge status: Wrong Answer
N=int(input())
print(N*(N+1))
# Judge status: Wrong Answer
N=int(input())
nn=N
import math
sq=int(math.sqrt(N))+10000

i=2
ans=0
count1=0
count2=1
while sq>=i:
    if nn%i==0:
        nn//=i
        count1+=1
        if count1//count2>0:
            ans+=1
            count2+=1
            count1=0
    else:
        i+=1
        count1=0
        count2=1

if ans==0 and N>=2:
    ans+=1

print(ans)
# Judge status: Accepted
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if p[i] == i+1:
    p[i],p[i+1] = p[i+1],p[i]
    ans += 1
if p[-1] == N:
  ans += 1
print(ans)
# Judge status: Wrong Answer
s = input()
ans = 'No'


if 'hi' in s:
  ans = 'Yes'

print(ans)
# Judge status: Wrong Answer
def main():
    N,Y=map(int,input().split())

    for i in range(Y//10000+1):
        tY=Y-10000*i
        for j in range(tY//5000+1):
            k=(tY-5000*j)//1000
            if i+j+k==N:
                print(i,j,k)
                return

    print(-1 -1 -1)

main()
# Judge status: Wrong Answer
S = input()

if S == 'Sunny':
    print('cloudy')

elif S == 'cloudy':
    print('Rainy')

elif S == ' ':
    print('Sunny')
# Judge status: Accepted
s = input()
n = len(s)
dp = [0]*(n+1)
t = 0
for e,i in enumerate(s,1):
    if i=='<' :
        dp[e]=dp[e-1]+1
# print(dp)
t = 0
for e in range(n-1,-1,-1):
    i = s[e]
    # print(t)
    if i=='>' :
        dp[e]=max(dp[e],dp[e+1]+1)
# print(dp)
print(sum(dp))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
    print(0)
    exit()

ans = 1
for i in a:
    ans *= i
    if ans > 10 ** 18:
        print("-1")
        exit()

print(ans)
# Judge status: Wrong Answer
import sys
x = input()
x1 = list(x)
h = len(x)
x = int(x)

if x>2000:
  print('1')
  sys.exit()

elif x<100:
  print('0')
  sys.exit()
a1 = int(x1[h-1])
a2 = int(x1[h-2])

if 0 < a1 < 5:
  c1 = 1
elif a1 == 0:
  c1 = 0
else:
  c1 = 2

c2 = a2*2
if int(x1[0])+int(x1[1]) < c1+c2:
  print('0')
else:
  print('1')
# Judge status: Accepted
n = int(input())
li = []
for i in range(n-1):
    c,s,f = map(int,input().split())
    li.append((c,s,f))
for i in range(n-1):
    cur = li[i][1]+li[i][0]
    for j in range(i+1,n-1):
        c,s,f = li[j]
        cur = max(s,-(-cur//f)*f)+c
    print(cur)
print(0)
# Judge status: Accepted
N,W=map(int,input().split())
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(1,N+1):
  w,v=map(int,input().split())
  for j in range(1,W+1):
    if j>=w:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v)
    else:
      dp[i][j]=dp[i-1][j]
print(dp[-1][-1])
# Judge status: Accepted
n=int(input())
if 400<=n<=599:
    print(8)
elif 600<=n<=799:
    print(7)
elif 800 <= n <= 999:
    print(6)
elif 1000<=n<=1199:
    print(5)
elif 1200<=n<=1399:
    print(4)
elif 1400<=n<=1599:
    print(3)
elif 1600<=n<=1799:
    print(2)
else:
    print(1)
# Judge status: Accepted
K = int(input())
A, B = map(int,input().split())
if A % K == 0 or B % K == 0:
    print("OK")
else:
    if (A // K + 1)*K <= B:
        print("OK")
    else:
        print("NG")
# Judge status: Accepted
h,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
inf=10**10
dp=[inf]*(h+1)
dp[-1]=0

for a,b in ab:
    for i in range(h,0,-1):
        if i-a>=0:
            dp[i-a]=min(dp[i-a],dp[i]+b)
        else:
            dp[0]=min(dp[0],dp[i]+b)
print(dp[0])
# Judge status: Wrong Answer
a = int(input())
s = 0
for i in range(a):
  s += i
print(s)