peterverebics/CodeNet_Python_118 huggingface dataset:
A,B,C,D=map(int,input().split())
while C>1 or A>1:
  C-=B
  A-=D
  if C<=0:
    print("Yes")
  elif A<=0:
    print("No")
I = input("")
i = I.split(" ")
A = int(i[0])
B = int(i[1])
C = int(i[2])
D = int(i[3])

n1 = C/B
n2 = A/D

if n1<=n2:
    print("Yes")
elif n1 - int(n1)==0:
    if n1-n2<1:
        print("Yes")
else:
    print("No")
a,b,c,d=map(int,input().split())

while True:
  a-=d
  if a<=0:
    print("No")
    break
  elif c<=0:
    print("Yes")
    break
# encoding="UTF-8"

A,B,C,D = map(int,input().split())
i=0
while i == 0:
    C -= B
    if C <= 0:
        print("Yes")
        break
    A -= D
    if A <= 0:
        print("NO")
        break
A, B, C, D = map(int, input().split())

i = int(C / B) + 1 #青木君のもんすたーがやられるのにかかる
j = int(A / D) + 1 #高橋君

if i <= j:
  print("Yes")
else:
  print("No")
A,B,C,D = map(int, input().split())
while True:
    C = C - B

    if C <= 0:
        print("YES")
        exit()
    A = A - D

    if A <= 0:
        print("NO")
        exit()
A,B,C,D=map(int,input().split())
 
while True:
    C= abs(C-B)
    if C<=0:
        print("YES")
        break
    A= abs(A-D)
    if A<=0:
        print("NO")
        break
import sys
import collections
import math

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


a,b,c,d = nm()
ao=math.floor(a/d)
su=math.floor(c/b)
if(ao<su):
    print("No")
else:
    print("Yes")
rist = input().split()
for i in range(100):
  if int(rist[2])-int(rist[1])<0:
    print("Yes")
    break
  else:
    rist[2] = int(rist[2])-int(rist[1])
 
  if int(rist[0])-int(rist[3])<0:
    print("No")
    break
  else:
    rist[0] = int(rist[0])-int(rist[3])
ABCD = list(map(int, input().split()))
A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]
if B%C != 0:
    if D*(B//C) >= A:
        print('No')
    else:
        print('Yes')
else:
    if D*(B//C - 1) >= A:
        print('No')
    else:
        print('Yes')
import math
A, B, C, D = list(map(int, input().split()))

#小数点に注意
#今回の場合は切り上げすること
n = math.ceil(A / D)
m = math.ceil(C / A)
if n >= m:
    print("Yes")
else:
    print("No")
a,b,c,d = map(int,input().split())
turn =0
while(a<=0 or c<=0):
  if(turn):
    a -= d
    turn ^= 1
  else:
    c -= b
    turn ^= 1
if(a<=0):
  print("No")
else:
  print("Yes")
a, b, c, d = map(int, input().split())

num1 = a//d
num2 = c//d

if num1>=num2:
  print('Yes')
else:
  print('No')
a,b,c,d=map(int,input().split())
x=c//b
y=a//d
if  x<=y:
  print("Yes")
else:
  print("No")
a, b, c, d = map(int, input().split())
print('Yes' if a//d <= c//b else 'No')
from sys import stdin, stdout  
import math
def main(): 
	a, b, c, d = [int(x) for x in stdin.readline().split()] 
	# h s h s
	print(math.ceil(c / b), c )
	print(math.ceil(a / d) , a)
	if math.ceil(c / b) <= math.ceil(a / d):
		stdout.write('Yes \n')
	else:
		stdout.write('No \n')
if __name__ == "__main__": 
	main()
w = input().split()
a=int(w[0])
b=int(w[1])
c=int(w[2])
d=int(w[3])

if a//d<c//b:
  print("Yes")
elif a//d>c//b:
  print("No")
elif a%d>c%b:
  print("No")
else:
  print("Yes")
a,b,c,d=map(int,input().split())
x=a//d
y=c//b
if y<x:
    print('Yes')
elif y==x:
    if c%b==0:
        print('Yes')
    else:
        if a%d==0:
            print('No')
        else:
            print('Yes')
            
else:
    print('No')
A,B,C,D = map(int,input().split())

A_attack = C / B
C_attack = A / D

if A_attack == 1 or C_attack == 1:
  if B >= D:
    print('Yes')
  else:
    print('No')  
elif A_attack < C_attack + 1:
  print('Yes')
else:
  print('No')
A, B, C, D = map(int, input().split())

gap = D - B

if gap > (C-D):
    print('No')
else:
    print('Yes')
a, b, c, d = [int(tmp) for tmp in input().split()]
while(a > 0 and c > 0 ) :
  c -= b
  if(c < 0 ) :
    print("Yes")
    break
  else :
    a-=d
    if(a<0) :
      print("No")
a,b,c,d=map(int,input().split())
a=a-d
c=c-b
if c<a:
    print("Yes")
else:
    print("No")
A, B, C, D = map(int, input().split())
flg = True
for i in range(max(A, C)):
    if i % 2 == 0:
        C -= B
        if C <= 0:
            flg = False
            print('Yes')
    else:
        A -= D
        if A <= 0:
            flg = False
            print('No')
    if not flg:
        break
# AtCoder
A, B, C, D = map(int, input().split())
if A-D <= C-B:
    print('No')
else:
    print('Yes')
A, B, C, D = map(int, input().split())
for i in range(100):
    C = C - B
    if C < 0:
        print('No')
        break
    A = A - D
    if A < 0:
        print('Yes')
        break
import sys
a,b,c,d = map(int,input().split())
t_1 = a//b
t_2 = a%b
a_1 = c//d
a_2 = c%d
if t_1>a_1:
  print('Yes')
  sys.exit()
elif  t_1<a_1:
  print('No')
  sys.exit()
elif t_2 < a_2:
  print('Yes')
  sys.exit()
else:
  print('No')
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    a, b, c, d = map(int, rl().split())
    if c % b != 0:
        print('No')
        exit()
    if a % d != 0:
        print('Yes')
        exit()
    

if __name__ == '__main__':
    solve()
ha, sa, hb, sb = map(int, input().split())
while True:
    ha = ha - sb
    if ha <= 0:
        print('No')
        break
    hb = hb - sa
    if hb <= 0:
        print('Yes')
a, b, c, d = map(int, input().split())

count = 0

for i in range(100):
  if count % 2 == 0:
    c -= b
    count += 1
    if c <= 0:
      print("Yes")
      break
  else:
    a -= d
    count += 1
    if a <= 0:
      print("No")
      break
def main():
    A, B, C, D = map(int, input().split())
    while True:
        C -= B
        if C <= 0:
            print("Yes")
            quit()
        A -= D
        if A <= 0:
            print("Np")
            quit()


if __name__ == "__main__":
    main()
i=0
a,b,c,d=map(int,input().split())
k=c//b
c-=b*k
a-=d*(k-1)
if(c!=0):
    print("No")
else:
    print("Yes")
a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
if int(c/b)-1>int(a/d):
  print("Yes")
else:
  print("No")
a, b, c, d = map(int, input().split())

for i in range(1,100):
    c = c - b
    if c == 0:
        break
    else:
        a = a - d
        if a == 0:
            break
if c == 0:
    print("Yes")
else:
    print("No")
A,B,C,D = map(int,input().split())

def battle(H,A):
    count = 0
    while H > 0:
        count += 1
        H -= A
    return count

t = battle(A,D)
a = battle(C,B)
if t < a:
    print("No")
else:
    print("yes")
a, b, c, d = map(int,input().split())

takahashi_hp = a / d
aoki_hp = b / c

if takahashi_hp >= aoki_hp:
    print('Yes')
else:
    print('No')
a,b,c,d=map(int,input().split())
while a<=0 or c<=0:
  c-=b
  a-=d
if a<=0 and c>0:
  print('No')
else:
  print('Yes')
a,b,c,d=map(int,input().split())
a=a-d
c=c-b
if c<=a:
    print("Yes")
else:
    print("No")
a, b, c, d = map(int, input().split())
print('YNeos'[a//d <= c//b::2])
A, B, C, D = map(int, input().split())
Tmon_ATcount = int(C / B)
Amon_ATcount = int(A / D)
if A <=  D:
  print("No")
elif Tmon_ATcount <= Amon_ATcount:
  print("Yes")
else:
  print("No")
a, b, c, d = map(int, input().split())
while a > 0 and c > 0:
  c -= b
  if c > 0:
    a -= d
  else:
    print('No')
  if a > 0:
    break
  else:
    print('Yes')
a,b,c,d = map(int,input().split())
if c%b == 0:
  x = c//b
else:
  x = c//b+1
if d%a == 0:
  y = a//d
else:
  y = a//d+1
if x == y:
  print("Yes")
elif x < y:
  print("Yes")
else:
  print("No")
a, b, c, d = map(int, input().split())
while 0 >= a or 0 >= c:
    c -= b
    if c > 0:
        a -= d
if a > c :
    print("Yes")
else:
    print("No")
A,B,C,D = map(int, input().split())
if (A and B and C and D) <=100 and (A and B and C and D) >=1:
    AOKI = C-B
    TAKA = A-D
    print(AOKI,TAKA)
    if AOKI>=0:
        print("Yes")
    else:
        print("NO")
A,B,C,D =input().split()
while(1):
    C = int(C)-int(B)
    if(int(C) <= 0):
        print("yes")
        break
    A = int(A)-int(D)
    if(int(A) <= 0):
        print("no")
        break
import math
a, b, c, d = map(int, input().split())

if math.ceil(c/b) >= math.ceil(a/d):
  print("Yes")
else:
  print("No")
a,b,c,d=map(int,input().split())
x=float(a/d)
y=float(c/b)
 
if x>=y:
  print("yes")
elif 0<y-x<1:
  print("yes")
else:
  print("no")
[A, B, C, D] = list(map(int, input().split()))
X = A / D
Y = C / B
if X >= Y:
    print('Yes')
else:
    print('No')
a, b, c, d = map(int, input().split())

x = a//d
y = c//b

if x == y:
    if c%b != 0 and a%d == 0:
        print("No")
    else:
        print("Yes")
elif x < y:
    print("Yes")
else:
    print("No")
a,b,c,d = map(int,input().split())
if (c//a) <= (d//b):
 print("Yes")
else:
 print("No")
a, b, c, d = map(int, input().split())
if c%b ==0 :
    e = c//b
else:
    e = c//b + 1
    
if a%d ==0:
    f = a//d 
else:
    f = a//d +1
if f >e:
    print("Yes")
else:
    print("No")
a,b,c,d=map(int,input().split())

for i in range(1000) :
    a=a-d
    if a>0:
        c=c-d
        if c>0:
            continue
        else: #c<=0
            print('Yes')
            break
    else: #a<=0
        print('No')
        break
A,B,C,D=map(int,input().split())
if A//D+A%D>=C//B+C%B:
    print("Yes")
if C//B+C%B>A//D+A%D:
    print("No")
a,b,c,d = list(map(int,input().split()))
print('Yes' if a-d>=c-b else 'No')
a,b,c,d,=map(int,input().split())
def func(a,b,c,d):
    while a>=0 and c>=0:
        c-=b
        a-=d
    return "Yes" if a>=c else "No"
print(func(a,b,c,d))
a, b, c, d = map(int,input().split())

while True:
    a -= d
    c -= b
    if a <= 0:
        print('No')
        break
    else:
        print('Yes')
        break
a, b, c, d = [int(x) for x in input().split()]
print(["No", "Yes"][ (a + b) > (c + d)])
A,B,C,D = map(int,input().split())
while A > 0 and C >0:
  C -= B
  if C <= 0:
    break
  A -= C
if A <= 0:
  print('No')
else:
  print('Yes')
a,b,c,d=map(int,input().split())
print("Yes" if c//b+c%b>0<=a//d+a%d>0 else "No")
a,b,c,d= map(int, input().split())
e=a//d
f=c//b
if a%d!=0:
  e+=1
if c%b!=0:
  f+=1
if e<=f:
  print("Yes")
else:
  print("No")
s = [input() for i in range(1)] 
li = list(map(int, s[0].split()))
for i in range(0,101):
    if i % 2 == 0:
        li[2] = li[2] - li[1]
        if li[2] <= 0:
            print("Yes")
            break
    if i % 2 == 1:
        li[0] = li[0] - li[3]
        if li[0] <= 0:
            print("No")
            break
A,B,C,D = map(int,input().split())

if A == C and D > B:
    print("No")
elif A == C and D < B:
    print("Yes")
elif int(C/B) == int((A/D)+1):
    print("Yes")
else:
    print("No")
a, b, c, d = map(int,input().split())
while True:
    c = c - b
    a = a - d
    if c < 0:
        print('No')
        break
    elif a < 0:
        print('Yes')
        break
    else:
        pass
A,B,C,D=map(int,input().split())
while A==0 or C==0:
     A-=D
     C-=B
if A>C:
	print('Yes')
else:
	print('No')
A, B, C, D =  map(int, input().split())
x = A
y = C
T_count = 0 
A_count = 0
for i in range(100):
    x = x-C
    if x >= 0:
        T_count += 1 
    else:T_count += 0

for j in range(100):
    y = y-A
    if y >= 0:
        A_count += 1 
    else:T_count += 0

if T_count <= A_count:
    print('Yes')
else:print('No')
a, b, c, d = map(int, input().split())
takahashi = c//b
aoki = a//d + 1
if takahashi > aoki:
    print("Yes")
else:
    print("No")
A, B, C, D = list(map(int, input().split()))

a_count = A // D + (1 if A % D else 0)
t_count = C // B + (1 if C % B else 0)
ans = 'No' if t_count < a_count else 'Yes'
#  print(t_count, a_count)
print(ans)
a, b, c, d = map(int,input().split())
while True:
    c = c - b
    a = a - d
    if c <= 0:
        print('No')
        break
    elif a <= 0:
        print('Yes')
        break
    else:
        pass
a,c,b,d=map(int,input().split())
for i in range(1):
    a=a-d
    c=c-b
if a<=0:
    print("No")
else:
    print("Yes")
A,B,C,D=map(int,input().split())
if((C/B==A/D)and(C%B!=0 and A%D==0)):
    print("No")
elif((C/B>A/D)and(A%D==0)):
    print("No")
else:
    print("Yes")
a, b, c, d = map(int, input().split())
m1 = a//d
m2 = c//b
if m1 < m2-1:
  print("No")
else:
  print("Yes")
a,b,c,d = map(int, input().split())
if a%d ==0:
  ao = a/d
else:
  ao = a/d +1
if c%b ==0:
  taka = c/b
else:
  taka = c/b +1

if taka> ao:
  print('No')
else:
  print('Yes')
a, b, c, d = map(int, input().split()) 
if a // (d + 1) > c // b:
  print("Yes")
else:
  print("No")
a, b, c, d = map(int, input().split())
while a > 0 and c > 0:
    c -= b
    if c>0:
        a -= d
    else:
        print("yes")
    if a<0:
        print("no")
A,B,C,D = (int(x) for x in input().split())

t_attacks = C/B
if C%B > 0:
    t_attacks = t_attacks + 1

t_life = A - D*(t_attacks-1)

if t_life > 0:
    print("Yes")
else:
    print("No")
A, B, C, D = map(int, input().split())

ct = 0
for _ in range(100000):
  C -= A
  ct += 1
  
  if C <= 0:
    break
  
ca = 0
for _ in range(100000):
  A -= D
  ca += 1
  
  if A <= 0:
    break
    
print('No' if ct == ca else 'Yes')
ad,ao,bd,bo=map(int,input().split())
aTurn=int(float(ad)/bo)*2+1
bTurn=int(float(bd)/ao)*2
if aTurn>bTurn:
  print("Yes")
else:
  print("No")
a, b, c, d = map(int, input().split())

if c - b <= 0:
    print("Yes")

elif a - d <= 0:
    print("No")
A, B, C, D = map(int, input().split())
print('Yes' if -(-D//B) <= -(-A//C) else 'No')
A, B, C, D = map(int, input().split(' '))

i = 1

while (A > 0 and C >0):
    if i% 2 ==1:
        C = C - B
    else:
        A = A- D
    i += 1

if C == 0:
    print('Yes')
else:
    print('No')
A, B, C, D = list(map(int, input().split()))
while A > 0 and C > 0:
    C = C - B
    A = A - D
if A > B:
    print("Yes")
else:
    print("No")
a, b, c, d = map(int, input().split())

if b//d >= c//a:
    print("Yes")
else:
    print("No")
a, b, c, d = map(int, input().split())
taka = a // d + a % d
ao = c // b + c % b

if taka >= ao:
    print("Yse")
else:
    print("No")
A ,B ,C ,D= list(map(int, input().split()))

ans1=0
ans2=0
for i in range(101):
    A=A-i*D
    if A <1 :
        ans1 = i
        break
for j in range(100):
    C=C-j*B
    if  C< 1:
        ans2 = j
        break
if i>=j:
    print('Yes')
else:
    print('No')
A, B, C, D = map(int, input().split())
a=0
c=0
while C-B>0:
    C-=B
    a+=1
while A-D>0:
    A-=D
    c+=1
print(a,c)
print("Yes") if c>=a else print("No")
a,b,c,d = map(int,input().split())

takahashi = a
aoki = c

for i in range(1,101):
    if i%2 == 0:
        aoki -= b
    else:
        takahashi -= d

    if takahashi <= 0:
        print('No')
        break
    elif aoki <= 0:
        print('Yes')
        break
A, B, C, D = map(int, input().split())
print("Yes") if D//A + 1 <= C//B + 1 else print("No")
A, B, C, D = map(int, input().split())

if C//B == A//D:
  if C%B > A%D:
    print('No')
  else:
    print('Yes')  
else:
  if C//B > A//D:
    if C//B - A//D == 1:
      print('Yes')
    else:
      print('No')  
  elif C//B < A//D:  
      print('Yes')
A,B,C,D = list(map(int, input().split()))

takahashi = -(-C // B)
aoki = -(-A // D)

if(takahashi >= aoki):
    print("Yes")

else:
    print("No")
a, b, c, d = map(int, input().split())

x = a//d
y = c//b

if x == y:
    if c%b != 0 and a%d == 0:
        print("No")
    else:
        print("Yes")
elif x > y:
    print("Yes")
else:
    print("No")
def check(a,b,c,d):
	while(a>0 and c>0):
		c-=b
		if(c<0):
			return 1
		a-=d
		if(a<0):
			return 0
	if(a<0):
		return 0
	if(c < 0):
		return 1
inp1=list(map(int,input().strip().split()))[:4]
a,b,c,d=inp1[0],inp1[1],inp1[2],inp1[3]
if(check(a,b,c,d)):
	print("Yes")
else:
	print("No")
a,b,c,d=map(int,input().split())
if a+b>d+c: print('yes')
else: print('no')
A, B, C, D = map(int, input().split())
a = int(C // B) + 1
c = int(A // D) + 1
if a <= c:
    print("Yes")
else:
    print("No")
import math
a,b,c,d = map(int,input().split())
print("Yes" if math.ceil(c/b) >= math.ceil(d/a) else "No")
A, B, C, D = map(int, input().split())
while A > 0 and C > 0:
    C = C - B
    A = A - D
if A == 0:
    ans = 'No'
else:
    ans = 'Yes'
print(ans)
A,B,C,D = map(int, input().split())
a = C//B
b = A//D
if C%B != 0:
    a = a + 1
elif A%D != 0:
    b = b + 1

if a < b:
    print("Yes")
else:
    print("No")
a, b, c, d = map(int, input().split())

if c % b == 0:
    takahashi = c // b
else:
    takahashi = c // b + 1

if a % d == 0:
    aoki = a // d
else:
    aoki = a // d + 1

print(takahashi)
print(aoki)

if takahashi <= aoki:
    print("Yes")
else:
    print("No")
a,b,c,d=list(map(int,input().split(" ")))
if c%b==0:
  taro=c//b
else:
  taro=c//b+1
if a%d==0:
  sasaki=a//d
else:
  sasaki=a//d+1

if taro<=sasaki:
  print("yes")
else:
  print("No")
A, B, C, D = map(int, input().split())
ans = 0
for i in range(100):
  C -= B
  if B <= 0:
    ans = 1
    break
  A -= D
  if D <= 0:
    break
if ans == 1:
  print('Yes')
else:
  print('No')
import sys 
try:
	sys.stdin = open('input.txt', 'r') 
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for tt in range(1):
	# n = int(input())
	a,b,c,d = map(int,input().split())
	# l = list(map(int,input().split()))
	if a+b >= c+d:
		print ("Yes")
	else:
		print("No")
w = input().split()
a=int(w[0])
b=int(w[1])
c=int(w[2])
d=int(w[3])

if a//d<c//b:
  print("Yes")
elif a//d>c//b:
  print("No")
elif a%d<c%b:
  print("No")
else:
  print("Yes")
a,b,c,d = map(int, input().split())
timea = a//d
timeb = c//b
if timea >= timeb:
    print("Yes")
    exit()
print("No")
def main():
  n, mods = 0, [1]+[0]*2019
  d = 1
  for i, j in enumerate(reversed(input())):
    # n = (n+int(j)*pow(10, i, 2019))%2019
    n = (n+int(j)*d)%2019
    d=d*10%2019
    mods[n] += 1
  print(sum([i*(i-1)//2 for i in mods]))
main()
s=input()[::-1]
ans=0
u=0
d=1
l=[0]*2019
l[0]=1
for i in map(int,s):
  u=(u+i*d)%2019
  l[u]+=1
  d=d*10%2019
for i in l:
  ans+=i*(i-1)//2
print(ans)
# for i in range(10):
# 	print( 10 ** i % 2019)



s = list(map(int, list(input())))
n = len(s)
MODULO = 2019

power = 1
prefix_ = [0 for _ in range(n+1)]
for i in range(n-1, -1, -1):
	prefix_[i] = (prefix_[i+1] + power*s[i]) % MODULO
	power *= 10
	power %= MODULO

seen = {}
ans = 0
for item in prefix_:
	ans += seen.get(item, 0)
	seen[item] = seen.get(item, 0) + 1

# print(s)
# print("prefix_", prefix_)
# print("unique", len(set(prefix_)))
# print("all", len(prefix_))
print(ans)
S = input()[::-1]
digits = 1
Sum, ans = 0, 0
l = [0] * 2019
l[0] = 1

for c in S:
  Sum += int(c) * digits % 2019
  Sum %= 2019
  l[Sum] += 1
  digits = digits * 10 % 2019

for i in range(len(l)):
  ans += l[i] * (l[i] - 1) // 2
  
print(ans)
s = input()
n = len(s)
p = 0
ten = 1
cnt = [0] * 2019
cnt[0] = 1
ans = 0
for i in reversed(s):
    p = (p + int(i) * ten) % 2019
    ans += cnt[p]
    cnt[p] += 1
    ten = ten * 10 % 2019

print(ans)
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)
s = input()
mods = [0]*2019
mods[0] = 1
accu = 0
for i, j in enumerate(reversed(s)):
    accu += int(j)*pow(10, i, 2019)
    accu %= 2019
    mods[accu] += 1
ans = 0
for i in mods:
    ans += i*(i-1)//2
print(ans)
s = input()
mod = 2019

temp = [1]
for i in range(len(s) - 1):
    temp.append(temp[-1] * 10 % mod)
temp.reverse()
temp2 = []
for i in range(len(s)):
    temp2.append(int(s[i]) * temp[i])
temp3 = [0]
for i in range(len(s)):
    temp3.append((temp3[-1] + temp2[i]) % mod)
temp4 = {}
for i in temp3:
    temp4.setdefault(i, 0)
    temp4[i] += 1
ans = 0
for i in temp4.values():
    ans += (i * (i - 1) // 2)
print(ans)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict 
def main():
    s = input() 
    n = len(s)
    T = [0]
    P = 2019
    dd = defaultdict(int) 
    dd[0] += 1
    for i in range(1, n+1):
        x = (int(s[-i])*pow(10, i-1, P) + T[i-1])%P
        T.append(x)
        dd[x] += 1
    ans = 0
    for i in dd.values():
        ans += i*(i-1)//2
    print(ans)
if __name__ == '__main__':
    main()
S = input() [::-1]
ans = 0
mod = 0
ten = 1
count = [0]* 2019
count[0] = 1
for i in range(len(S)):
    mod = (mod + int(S[i]) * ten) % 2019
    ten = ten*10 % 2019
    count[mod] += 1
for c in count:
    ans += c*(c-1)//2
print(ans)
import sys
input = sys.stdin.readline

s = list(input())
n = len(s)-1

res = 0

d = dict()
mod = 2019
d[0] = 1

tmp = 0
for i in range(n-1,-1,-1):
    tmp = (tmp + int(s[i])*pow(10,n-1-i,mod))%mod
    if tmp in d:
        res += d[tmp]
        d[tmp] += 1
    else:
        d[tmp] = 1

print(res)
S=input()
N=len(S)

a=0
t=1
d=[0]*2019
d[0]=1
for i in range(N):
  a+=int(S[N-1-i])*t
  a%=2019
  t*=10
  t%=2019
  d[a]+=1

ans=0
for n in d:
  ans += n*(n-1)//2
print(ans)
from collections import defaultdict


def resolve():
    s = input()

    cnt = defaultdict(int)
    cnt[0] += 1
    tmp = 0
    for i, c in enumerate(s[::-1]):
        c = int(c)
        tmp = (tmp + c * pow(10, i, 2019)) % 2019
        cnt[tmp] += 1

    ans = sum(c * (c - 1) // 2 for c in cnt.values())
    print(ans)


resolve()
s = input()
s_len = len(s)
n = 2019
mod_list = [0] * n
mod_list[0] = 1

p = 1
d = 0
for t in reversed(s):
    d += int(t) * p
    m = d % n
    mod_list[m] += 1
    p *= 10
    p %= 2019

result = sum(i * (i - 1) // 2 for i in mod_list)
print(result)
S = input()
Sliststr = list(S)
Slist = [int(s) for s in Sliststr]
Smod = [0]
mod10 = [1]
count = [0]*2019
ans = 0
for i in range(len(S)-1):
  mod10.append(mod10[i]*10%2019)
for i in range(len(S)):
  Smod.append((Smod[i]+Slist[-i-1]*mod10[i])%2019)
for i in range(len(Smod)):
  count[Smod[i]] += 1
for i in range(2019):
  ans += count[i] * (count[i]-1) // 2
print(ans)
from collections import Counter

S = input()

x = [0]
dec = 1
for s in S[::-1] :
  x.append((x[-1] + dec * int(s)) % 2019)
  dec *= 10
  dec %= 2019

ret = 0
for v in Counter(x).values() :
  ret += v * (v - 1) // 2
print(ret)
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) # 答えの出力
S = input()
M = 2019

cnt = [0] * M
cnt[0] = 1
N = 0
ans = 0
for i, n in enumerate(map(int, S[::-1])):
    N = (N + n * pow(10, i, M)) % M
    ans += cnt[N]
    cnt[N] += 1
print(ans)
M=2019
a=i=0
d=[1]+[0]*M
p=1
for j in input()[::-1]:i=(i+int(j)*p)%M;a+=d[i];d[i]+=1;p=p*10%M
print(a)
S = input()
N = len(str(S))
P = 2019
list_a = [0] * P
list_a[0] += 1
counter = 0
temp = 0
power = 1
for i in range(N):
    temp += pow(10, i, P) * int(S[N - i - 1])
    temp %= P
    counter += list_a[temp]
    list_a[temp] += 1
print(counter)
S = input()
count = 0
exist = [0]*2019
flg = False
N = len(S)
sum = 0
for i, s in enumerate(reversed(S)):
    sum += (int(s) * pow(10, i, 2019)) % 2019
    exist[sum % 2019] += 1
for e in exist:
    if e > 1:
        count += e*(e-1)//2
count += exist[0]
print(count)
from collections import Counter

S=input()

rlist=[0]
for i in range(len(S)):
  rlist.append((rlist[-1]+int(S[-i-1])*pow(10,i,2019))%2019)
  
c = Counter(rlist)
c[0] -= 1

def nC2(n):
  return n*(n-1)//2
  
ans = c[0]
for k in c.keys():
  if c[k] >= 2:
    ans += nC2(c[k])
    
print(ans)
s=input()
s= s[::-1]

S=[0,]
cnt=[0]*2019
cnt[0]=1
d=1
num=0
for i in range(len(s)):
    num += int(s[i])*d
    num %= 2019
    d *= 10
    d%= 2019
    # S.append((int(S[i]) + int(s[i]) * 10**i) % 2019)
    cnt[num]+=1

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

print(ans)
S=str(input())
l=len(S)
ans=0
dig=1
mod=[0]*2019
mod[0]=1
t=0
for i in range(l):
    t=(t+int(S[-i-1])*dig)%2019
    mod[t]+=1
    dig=(dig*10)%2019
    
for j in mod:
    ans=ans+(j*(j-1))//2
print(ans)
import collections
S = input()
N = len(S)
mod = 2019
div = [0]*(N+1)
for i in range(N):
    div[i+1] = (div[i] + int(S[N-1-i])*pow(10,i,mod))%mod
d = collections.Counter(div[1::])
ans = d[0]
for i in d.values():
    ans += i*(i-1)//2
print(ans)
import numpy as np
import sys
import math

S = input()

mm = [0] * (2019)
mm[0] = 1
a = [0] * (len(S) + 1 ) 
T = 0
ten = 1
ll = len(S)
for i in range(ll):
    if i > 0:
        ten = ( ten * 10 ) % 2019
    a[i+1] =  ( a[i] + (int(S[ll-1-i])*ten ) ) % 2019
    mm[ a[i+1] ] += 1
    #print(s)

ans = 0

for m in mm:
    ans += int( (m * (m-1) ) / 2 )

print(ans)