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

RL = [0] * (10 ** 7 + 10)
for i in range(1, 10 ** 7 + 10):
    RL[i] = RL[i-1] + i

print("step")

ans = 0
for i in range(1, N+1):
    a = N // i
    #print(i, a)
    ans += RL[a] * i

print(ans)
# Judge status: Wrong Answer
n,m = map(int,input().split())
n-=2
m-=2
print(n*m)
# Judge status: Accepted
string = input()
N=int(input())
Que = []
for i in range(N):
	Que.append(input())

init = ""
end = ""
rev = 2
for Q in Que:	
	if int(Q[0]) == 1:
		if rev != 1:
			rev=1
		else:
			rev=2
	elif int(Q[0])==2:
		T,F,C = Q.split(' ')
		if rev == 1:
			if int(F) == 1:
				F =2
			else:
				F = 1
		if int(F) == 1:
			init = init+C
		elif int(F) == 2:
			end = end + C
final = init[-1::-1]+string+end
if rev == 1:
	print(final[-1::-1])
else:
	print(init[-1::-1]+string+end)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

f, t = 0, 0
for i in a:
    if i % 4 == 0:
        f += 1
    elif i % 2 == 0:
        t += 1
print('Yes' if f*2 + t >= n or n // 2 <= f else 'No')
# Judge status: Accepted
n = int(input())
for i in range(n,1000):
    if i % 111 == 0:
        print(i)
        break
# Judge status: Accepted
import math
from functools import reduce
from itertools import product
K=int(input())
gcd=0.
for i in range(K):
    for j in range(K):
        a=math.gcd(i+1,j+1)
        for k in range(K):
            gcd+=math.gcd(a,k+1)
print(int(gcd))
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

cnt = {}

for item in a:
    if item not in cnt:
        cnt[item] = 0
    cnt[item] += 1

A = list(set(a))

candidate = []

for item in A:
    if cnt[item] == 1:
        candidate.append(item)

judge = [True] *(10**6 + 1)

for item in A:
    for i in range(2, ((10**6)//item) + 1):
        judge[item*i] = False

ans = 0

for item in candidate:
    if judge[item]:
        ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
s = list(input())
alph = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
ans = 0
for i in range(1, n):
    x = s[0 : i]
    y = s[i : n]
    c = 0
    for j in alph:
        if j in x and j in y:
            c += 1
    if ans < c:
        ans = c
print(ans)
# Judge status: Accepted
import itertools

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

if a > b:
    print(0)
    exit()

if a != b and n == 1:
    print(0)
    exit()

print((b-a)*(n-2)+1)
# Judge status: Accepted
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

money=1000
kabu=0
for i in range(n-1):
  if a[i]<a[i+1]:
    t_kabu=money//a[i]
    kabu+=t_kabu
    money-=t_kabu*a[i]
  elif a[i]>a[i+1]:
    money+=kabu*a[i]
    kabu=0

money+=kabu*a[n-1]
print(money)
# Judge status: Accepted
N, X = map(int,input().split())
S = map(int,input().split())
S = sorted(S)
cnt = 0

for s in S:
  X -= s
  if X >= 0:
    cnt += 1
  else:
    break

if X > 0:
  cnt -= 1
    
print(cnt)
# Judge status: Accepted
from copy import copy
N,K = map(int, input().split())
p=list(map(int, input().split()))
expP = [(1+i)/2 for i in p]
id_H = N-K
id_T = N
minus = sum(expP[:id_H])
minimum = minus
for i in range(id_H):
    minus -= expP[id_H - i -1]
    minus += expP[id_T - i -1]
    if minus < minimum:
        minimum = copy(minus)
ans = sum(expP) - minimum
print(ans)
# Judge status: Accepted
from collections import Counter
def main():
    S = list(input())
    c = Counter(S)
    if ((c["N"] == 0 and c["S"] == 0) or (c["N"] > 0 and c["S"] > 0)) and ((c["W"] == 0 and c["E"] == 0) or (c["W"] > 0 and c["E"] > 0)):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
C = [0] * 9
for a in A:
    C[min(8, a//400)] += 1
s = sum([c > 0 for c in C[:-1]])
print(C)
print(max(s, 1), s + C[-1])
# Judge status: Accepted
N, A, B = map(int, input().split())

answer = N // (A + B) * A
if  N % (A + B) <= A:
    answer += N % (A + B)
else:
    answer += A

print(answer)
# Judge status: Accepted
N, M = map(int, input().split())
a = [N]*M

for i in range(N):
    A = list(map(int, input().split()))[1:]

    for j in A:
        a[j-1] -= 1


count = 0
for i in a:
    if i == 0:
        count += 1

print(count)
# Judge status: Accepted
import math
import itertools

N,D= map(int,input().split())
X = []
count=0
for x in range(N):
    X.append(list(map(int,input().split()))) 

listArray = list(itertools.combinations(X, 2))

for X in listArray:
    sumX = 0
    for x in range(D):
        subX = X[0][x] - X[1][x]
        sumX += subX**2
     
    if math.sqrt(sumX).is_integer():
        count += 1
    
print(count)
# Judge status: Accepted
k = int(input())
s = input()

print(s if len(s) <= k else s[:k] + "...")
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K,S = map(int,read().split())

if S > N:
    A = [S] * K + [1] * (N-K)
else:
    A = [S] * K + [S+1] * (N-K)

print(*A)
# Judge status: Accepted
K = int(input())
S = input()

if len(S) <= K:
  print(S)
else:
  print(S[:K]+"...")
# Judge status: Accepted
r, g, b = map(int, input().split())
num = int(str(r)+str(g)+str(b))

if  num %4 == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
# PyPy3

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

dp = [[0]*(W+1) for _ in range(N+1)]
    
def npsk_1(N, W):
    for i in range(N):
        w, v = map(int, input().split())
        for j in range(W+1):
            if j  >= w:
                dp[i+1][j] = max(dp[i][j], dp[i][j - w] + v)
            else:
                dp[i+1][j] = dp[i][j]
    
    print(dp[N][W])

npsk_1(N, W)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = [0]*(N+1)
for a in A:
    B[a]+=1
C = [0]*(N+1)
for i in range(N+1):
    C[i] = (B[i]-1)*B[i]//2
S = sum(C)
for k in range(N):
    s = A[k]
    ans = S-C[s]
    b = B[s]-1
    print(ans+(b-1)*b//2)
# Judge status: Wrong Answer
K, X = input().split()
if 500 * K >= X:
    print("Yes")
elif 500 * K < X:
    print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
d = {}
ans = 0
for i in a:
    d[i] = d.get(i,0) + 1
for key in d:
    ans += d[key]*(d[key]-1)//2
for i in a:
    print(ans + 1 - d[i])
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
diff = b-a
ans = diff // x
if a % x == 0:
    ans += 1

print(ans)
# Judge status: Accepted
N=int(input())
l=[]
for i in range(N):
    l.append(list(map(int,input().split())))
L=sorted(l,key=lambda x:x[1])

time=0
error=0
for j in range(N):
    time += L[j][0]
    if time > L[j][1]:
        error += 1
if error >0:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
S = input()

right = S[-len(S) // 2:][::-1]

print(len(S) // 2 - sum(S[i]==right[i] for i in range(len(S) // 2)))
# Judge status: Wrong Answer
a = list(input())
b = list(input())
for x,y in zip(a,b):
  print(x+y, end = "")
# Judge status: Accepted
n=int(input())
cnt=0

def digit(k):
    ret=0
    while k!=0:
        k//=10
        ret+=1
    return ret
    
for i in range(n):
    if digit(i+1)%2==1: cnt+=1
print(cnt)
# Judge status: Accepted
A,B,C=map(int,input().split())
X=min(C,A-B)
print(C-X)
# Judge status: Accepted
print('YNeos'[int(input())<30::2])
# Judge status: Accepted
a,b,c=map(int,input().split())
a,b = min(a,b),max(a,b)
if c in range(a,b+1):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
S = input()

st = 0
en = 0

for i in range(len(S)):
    if S[i] == "A" and st == 0:
        st = i

    if S[i] == "Z":
        en = i

print(en - st + 1)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(set(map(int, input().split())))

#print(A)

while not any(a % 2 for a in A):
    A = [a // 2 for a in A]

#print(A)
#print(all(a % 2 for a in A))

if not all(a % 2 for a in A):
    print(0)
    exit()
    
#print(1)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b // gcd(a, b)
    
ans = 1
for i in A:
    ans = lcm(ans, i)

#print(ans)
print((M // ans + 1) // 2)
# Judge status: Accepted
from fractions import gcd
n,m = map(int, input().split())
a = list(map(int, input().split()))
b = []
lcm = 1
for i in a:
    b.append(i//2)
for i in b:
  lcm = lcm // gcd(lcm,i) * i
ans = m // lcm
sum = 0
for i in b:
  if (lcm // i) % 2 == 1:
    sum += 1
if sum != len(a):
  print(0)
elif ans%2 ==1:
    print((ans+1)//2)
else:
    print(ans//2)
# Judge status: Accepted
s = input()
l = [s[0], s[1], s[2], s[3]]
l.sort()
if l[0] == l[1] != l[2] == l[3]:
    print('Yes')
else: print('No')
# Judge status: Accepted
a,b,c,k = map(int, input().split())
if a>=k:
    print(k)
elif a<k and a+b>=k:
    print(a)
else :
    print(2*a+b-k)
# Judge status: Accepted
a, b, c, k = map(int, open(0).read().split())
for i in range(k):
    if a >= b:
        b *= 2
        continue
    if b >= c:
        c *= 2
if a < b < c:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
s=input()
c=1
for i in range(0,3):
  if s[i]==1:
    c+=1
    
print(c)
# Judge status: Wrong Answer
a,b,c=map(str,input().split())
print('A'+b.lower()+'C')
# Judge status: Accepted
s = input()
alp = "abcdefghijklmnopqrstuvwxyz"
for i in alp:
	if i not in s:
		print (i)
		exit()
print ("None")
# Judge status: Accepted
import bisect
 
n = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
 
ans = 0
for b in B:
    a_ind = bisect.bisect_left(A, b)
    c_ind = bisect.bisect_right(C, b)
    ans += a_ind*(n-c_ind)
print(ans)
# Judge status: Accepted
a = [int(e) for e in input().split()]

for i in range(len(a)):
    if a[i] == 0:
        print(i+1)
        break
# Judge status: Accepted
a,b,x = map(int,input().split())
 
if a > x :
  print('NO')
elif x-a <= b:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    x, n= map(int, input().split())
    if n == 0:
        print(x)
        return
    P=[]
    P = list(map(int, input().split()))
    
    for i in range(100):
        a = x-i
        b = x+i
        if a not in P:
            print(a)
            return
        elif b not in P:
            print(b)
            return
    


main()
# Judge status: Accepted
a,b=map(int,input().split())
c=(a*(a-1)+b*(b-1))//2
print(c)
# Judge status: Wrong Answer
N = input()
if N[0] == N[-1]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math

d=ni()

x=0
y=1
cnt=0
dd=0
while True:
  cnt+=1
  dd=(dd+d)%360
  r = math.radians(dd)
  x += math.sin(r)
  y += math.cos(r)

  # print("{}, {}".format(x,y))

  if abs(x)<10**(-10) and abs(y)<10**(-10):
    break
print(cnt+1)
# Judge status: Wrong Answer
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

ans = ''

ans += 'U' * dx
ans += 'R' * dy
ans += 'D' * dx
ans += 'L' * dy
ans += 'L'
ans += 'U' * (dx + 1)
ans += 'R' * (dy + 1)
ans += 'D'
ans += 'R'
ans += 'D' * (dx + 1)
ans += 'L' * (dy + 1)
ans += 'U'

print(ans)
# Judge status: Accepted
A, B, C, D = map(int, input().split())
print(max(0, min(B, D) - max(A, C)))
# Judge status: Wrong Answer
n = int(input())
cost = [0]*n
start = [0]*n
freaq = [0]*n
dp = [[0]*n for _ in range(n)]

for i in range(n-1):
    cost[i],start[i],freaq[i] = map(int,input().split())
    dp[i][i] = start[i]

freaq[n-1] = 1

t = 0

for i in range(n-1):
    for j in range(i+1):
        t = dp[j][i]
        t += cost[i]
        t += t%freaq[i+1]
        t = max(t,start[i+1])
        dp[j][i+1] = t

for i in range(n):
    print(dp[i][n-1])
# Judge status: Accepted
N,M=map(int,input().split())

if M>=N*2:
    M-=N*2
    N+=M//4
    print(N)
else:
    print(M//2)
# Judge status: Accepted
N = int(input())
A = map(int,input().split())
B = set(A)

if N == len(B):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N, K = map(int, input().split())
result = [0] * N

for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        result[a-1] = 1
    A.clear()

print(result.count(0))
# Judge status: Accepted
S=input()

i=1
while i<len(S):
    ans=len(S[:-i])
    if ans%2==0:
        if S[:-i][:ans//2]==S[:-i][ans//2:]:
            print(ans)
            break
    i+=1
# Judge status: Wrong Answer
def is_prime(n, k=100):
    n = abs(n)
    if n == 2:
        return True
    if n < 2 or n&1 == 0:
        return False
    for i in range(3, k):
        x, y = n, i
        while y:
            x, y = y, x%y
        if x != 1:
            continue
        if pow(2, n-1, n) != 1:
            return False
    return True


X = int(input())

while True:
    if is_prime(X):
        print(X)
        break
    X += 1
# Judge status: Accepted
n = int(input())
lst = list(map(int, input().split()))
for i in range(n - 1):
  a, b = min(lst[i], lst[i + 1]), max(lst[i], lst[i + 1]) # a < b
  while a != 0:
    a, b = b % a, a
  lst[i + 1] = b
print(lst[n - 1])
# Judge status: Wrong Answer
a=input()
c=int(a)
b=0
if c%2!=0:
	b=b+1
if c%3!=0:
	b=b+1
if c%4!=0:
	b=b+1
if c%5!=0:
	b=b+1
if c%6!=0:
	b=b+1
if c%7!=0:
	b=b+1
if c%8!=0:
	b=b+1
if c%9!=0:
	b=b+1
if c<=81:
    if b<8:
        print("Yes")
    elif c==1:
        print("Yes")
        
    else:
      	print("No")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
x = list(map(int,input().split()))
y = x.copy()
y.sort()
z = set(x)
t1 = y[n//2-1]
t2 = y[n//2]
idx = dict([])
idx[y[0]] = 0
l = y[0]
cnt = 0
for i in y:
    if i == l:
        continue
    else:
        idx[i] = cnt
        l = i
    cnt += 1

for i in x:
    t = idx[i]
    if t<n//2:
        print(t2)
    else:
        print(t1)
# Judge status: Accepted
K = int(input())
A, B = list(map(int, input().split()))
r = K - A % K
if r == K:
    r = 0
if B - A >= r:
    print('OK')
else:
    print('NG')
# Judge status: Accepted
N=int(input())
ans=N
for i in range(N+1):
    cnt=0
    t=i
    while t>0:
        cnt+=t%6
        t//=6
    j=N-i
    while j>0:
        cnt+=j%9
        j//=9
    ans = min(ans,cnt)
print(ans)
# Judge status: Accepted
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    S = list(input())
    numb = 0
    numw = S.count(".")
    answer = numb + numw
    for i in range(N):
        if S[i] == "#":
            numb += 1
        else:
            numw -= 1
        if answer > numb + numw:
            answer = numb + numw

    print(answer)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())

if n == 25:
	print("Christmas") 
elif n == 24:
	print("Christmas Eve") 
elif n == 23:
	print("Christmas Eve Eve") 
else:
	print("Christmas Eve Eve Eve")
# Judge status: Accepted
a,b,c=map(int,input().split())
if a-b == b-c:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
N = int(input())
S = input()
 
oE = S.count("E")
Wo = 0

L = []
for i in range(N):
    if i == 0:
        if S[i] == "E":
            oE -= 1
    else:
        if S[i-1] == "W":
            Wo += 1
        if S[i] == "E":
            oE -= 1
    L.append(Wo + oE)
    if Wo + oE == 1:
        break
print(L)
# Judge status: Wrong Answer
X, Y, Z = map(int, input().split())

print(X//(Z+Y))
# Judge status: Wrong Answer
N = int(input())
div = 2
ans = []
while N // 2 > 0:
    ans.append(N % 2)
    N //= 2

ans.reverse()
print("".join(map(lambda x: str(x), ans)))
# Judge status: Accepted
n,a,b = map(int,input().split())
s = list(input())
cap = a+b

for i in s:
    if i == 'a' and cap > 0:
        print('Yes')
        cap -= 1
    elif i == 'b' and cap > 0 and b > 0:
        print('Yes')
        cap -= 1
        b -= 1
    else:
        print('No')
# Judge status: Wrong Answer
from math import log2
from heapq import heappop, heapify, heappush
def main():
    n, m = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A = [-log2(a) for a in A]
    heapify(A)
    for _ in range(m):
        a = heappop(A)
        a += 1
        heappush(A, a)
    print(sum([int(pow(2, -a)) for a in A if a <= 0]))

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

l = []

for i in range(N):
    total_li = sum(candies_i[i:])
    total_lj = sum(candies_j[:i+1])
    total = total_li + total_lj
    l.append(total)

print(max(l))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
ans = 0

for i in range(n):
  if (i+1)%2 == 1 and a[i]%2 ==1:
    ans += 1
print(ans)
# Judge status: Accepted
N, M = list(map(int, input().split()))
d = [list(map(int, input().split())) for _ in range(N)]
ans = 0
d.sort()
for i in d:
    if i[1] <= M:
        ans += i[0] * i[1]
        M -= i[1]
        if M == 0:
            break
    else:
        ans += i[0] * M
        break

print(ans)
# Judge status: Accepted
def solve(string):
    x = int(string)
    a = {i**5: i for i in range(-10000, 10000)}
    for i in range(-10000, 10000):
        if x + i ** 5 in a:
            return str(f"{a[x+i**5]} {i}")


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
d = max(a)
f = d
for v in a:
  if abs(v-d/2) < abs(f-d/2):
    f = v
print(d,f)
# Judge status: Accepted
s = input()
t = input()
ans = 'UNRESTORABLE'
for i in range(len(s)-len(t), -1, -1):
    valid = True
    for j in range(len(t)):
        if s[i+j] != '?' and s[i+j] != t[j]:
            break
    else:
        ans = (s[:i] + t + s[i+len(t):]).replace('?', 'a')
        break
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
ab = a * b
if ab % 2:
    print('Odd')
else:
    print('Even')
# Judge status: Wrong Answer
N = int(input())
print((N // 1000 + 1) * 1000 - N)
# Judge status: Accepted
import sys
readline = sys.stdin.readline

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

K = min(100, K)
while K:
    K -= 1
    table = [0]*(N+1)
    for i in range(N):
        a = A[i]
        table[max(0, i-a)] += 1
        table[min(N, i+a+1)] -= 1
    
    for i in range(1, N):
        table[i] += table[i-1]
    
    A = table[:-1]

print(*A)
# Judge status: Accepted
k = int(input())
s = list(input())

print("".join(s[:k]) + ("..." if len(s) > k else ""))
# Judge status: Accepted
N = int(input())
b = list(map(int,input().split()))
box = [0 for i in range(N)]

for i in range(N-1,-1,-1):
  rest = 0
  for j in range(2 * (i+1),N+1,i+1):
    rest += box[j-1]
  box[i] = (b[i] - rest)%2
print(sum(box))
if sum(box):
  for idx,i in enumerate(box):
    if i == 1:
      print(idx+1)
# Judge status: Wrong Answer
import sys
n, a, b, c, d = map(int, input().split())
s = input()
if c > d:
    s = s[:d-1] + '#' + s[d:]
count1, count2 = 0, 0
for i in range(a-1, c):
    if count1 == 3:
        print('Yes')
        sys.exit()
    elif count2 == 2:
        print('No')
        sys.exit()
    elif s[i] == '#':
        count2 += 1
        count1 = 0
    elif s[i] == '.':
        count1 += 1
        count2 = 0
print('Yes')
# Judge status: Accepted
n = int(input())

if n <600:
    print(8)
elif n <800:
    print(7)
elif n <1000:
    print(6)
elif n <1200:
    print(5)
elif n <1400:
    print(4)
elif n <1600:
    print(3)
elif n <1800:
    print(2)
elif n <2000:
    print(1)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**5)

h,n=map(int,input().split())
magic=[]
for i in range(n):
  magic.append(tuple(map(int,input().split())))

memo={}
def d(hp):
  if hp<=0:
    return 0
  if hp in memo:
    return memo[hp]
  mn=10**10
  for i in magic:
    mn=min(mn,d(hp-i[0])+i[1])
  memo[hp]=mn
  return mn

for i in range(1,h-1):
  d(i)
print(d(h))
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())

d = 0
d = a + b
d = d * c / 2
print(d)
# Judge status: Accepted
s = input()
n = len(s)
count = 0
for i in range(n):
    if (i & 1) ^ int(s[i]):
        count += 1
print(min(count,n-count))
# Judge status: Accepted
x,y = map(int,input().split())
m = 10**9+7
if not((x+y)%3== 0 and abs(x-y)<=(x+y)//3):
    print(0);exit()

def comb(n,k):
    #if 2 * k > n:
        #k = n - k
    a = 1
    for i in range(1,k+1):
        a *= (n - ( i - 1)) * pow(i,m-2,m)
        a = a%m
    return a

n = (x+y)//3
k = x-n
print(comb(n,k))
# Judge status: Accepted
n=int(input())
m=0
l=0
for i in range(n):
  A,B=map(int,input().split())
  if (A==B):
    m+=1
  else:
    m=0
  if (m==3):
    print("Yes")
    l=1
    break

if (l==0):
  print("No")
# Judge status: Accepted
def main():
    A, B = map(int, input().split(" "))
    L = []
    L.append(A)
    L.append(B)
    L.append(A - 1)
    L.append(B - 1)
    L.sort(reverse=True)
    print(L[0] + L[1])


if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():
    S = list(input())
    N = len(S)
    t = 0
    A = [0] * 2019
    A[0] += 1
    d = 1
    for s in reversed(S):
        d *= 10
        d %= 2019
        t += (int(s) * d)
        t %= 2019
        A[t] += 1
    result = sum([a*(a-1)//2 for a in A])
    print(result)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N,X = map(int, input().split())
L = list(map(int, input().split()))

cnt=1
d=0
for i in range(N):
    if d+L[i]<=X:
        cnt+=1
        d=d+L[i]
    else:
        break
print(cnt)
# Judge status: Accepted
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    X = input()
    answer = 0
    cnt_s = 0
    for x in X:
        if x == "S":
            cnt_s += 1
            continue
        if cnt_s > 0:
            cnt_s -= 1
        else:
            answer += 1
    answer += cnt_s
    print(answer)


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

if S == 1e9:
    ans = [S] * K + [1] * (N - K)
else:
    ans = [S] * K + [S + 1] * (N - K)
print(*ans)
# Judge status: Wrong Answer
import math

x=0
y=9
for _ in range(5):
  i=int(input())
  x+=math.ceil(i/10)*10
  if i%10<y:
    y=i%10
print(x+y-10)
# Judge status: Wrong Answer
n="1234567876"

ans=753
for i in range(len(n)-2):
  a=int(n[i:i+3])
  if a==753:
    print(0)
    exit()
  b=abs(753-a)
  ans=min(b,ans)
  
print(ans)
# Judge status: Wrong Answer
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

dx = b - a
dv = v - w

if dv <= 0:
    print('NO')

elif dx % dv == 0 and dx // dv <= t:
    print('YES')

else:
    print('NO')
# Judge status: Accepted
from sys import stdin

A=stdin.readline()

print(A[0],end='')
print(A[1],end='')
print(A[2])
# Judge status: Wrong Answer
S = input()
T = input()
# print(S, T)

NUMBER_OF_ALPHABETS = 26
S_length = len(S)
if S_length < NUMBER_OF_ALPHABETS:
    print('Yes')
else:
    print('No')

# 同一文字は同一位置でなければならない
# 未使用文字が存在する場合: スワップしながら可能か？
# 未使用文字が存在しない場合: 他文字と被るかどうか？
# Judge status: Accepted
s = input()
ans = sorted(set(s) ^ set('abcdefghijklmnopqrstuvwxyz'))
print('None' if len(ans) == 0 else ans[0])
# Judge status: Accepted
q, h, s, d = map(int, input().split())
n = int(input())

u = min(s, 4*q, 2*h)

ans = min(u*n, d*(n//2) + u*(n%2))
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
print("YES" if (10*b+c)%4==0 else "NO")
# Judge status: Accepted
a,b=map(int,input().split())
if a*b<=0:
  ans='Zero'
elif a>0 and b>0:
  ans='Positive'
elif abs(a-b)%2!=0 :
  ans='Positive'
else:
  ans='Negative'
print(ans)
# Judge status: Wrong Answer
n=int(input())
A=[]
for i in range(n):
    A.append(list(map(int,input().split())))
prev=-100000
sum=0
tick=-10000000
for i in range(len(A)):
    max=0
    print("**",prev)
    for j in range(len(A[i])):
        if(j!=tick and max<A[i][j]):
            max=A[i][j]
            prev=j
            print(A[i][j],prev)
    sum=sum+max
    tick=prev
print(sum)