Harryxun/stf_run huggingface dataset:
K = int(input())
A,B = map(int,input().split())
 
if A%K==0 or B%K==0 or B-A >= K　and A <= K <= B:
  print('OK')
else:
  print('NG')

### FIXED CODE ###

K = int(input())
A,B = map(int,input().split())

count = 0

for i in range(A,B+1):
  if i%K ==0:
    count +=1
  else:
    count+=0

if count >0:
  print('OK')
else:
  print('NG')
def f_c():

    n = int(input())
    s = ["".join(sorted(input())) for _ in range(n)]

    c = 0
    for _ in range(n):
        si = s.pop()
        if si in s:
            c += s.count(s2)
    print(c)

if __name__ == "__main__":
    f_c()


### FIXED CODE ###

def f_c():

    n = int(input())
    d = {}
    dc = {}
    for _ in range(n):
        s = "".join(sorted(input()))
        if s in d:
            dc[s] += d[s]
            d[s] += 1
        else:
            d[s] = 1
            dc[s] = 0
    print(sum(dc.values()))

if __name__ == "__main__":
    f_c()
n, m = map(int, input())
print(n + max(0, (m-2*n)//4) if m>=2 else "0")

### FIXED CODE ###

n, m = map(int, input().split())
print(min(n, m//2)+max(0, (m-n*2)//4))
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(a):
  if a[a[i] - 1] == i + 1:
    ans += 1
print(ans // 2)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
  if a[a[i] - 1] == i + 1:
    ans += 1
print(ans // 2)
N = int(input())

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



b = sorted(list(set(A)))

x = set(b)

res = x

if b[0]==1:
    print(1)
    exit()

if b[0]==b[-1]:
    print(0)
    exit()

if N == 1:
    print(1)


daburi = []

c = sorted(A)
for i in range(1,N):
    if c[i] == c[i-1]:
        daburi.append(c[i])

daburi = set(daburi)
#print(daburi)

f = False
res = 0


i = 0

s = set(b)

while len(s) >= res:
    for j in x:
        if b[i] == j: 
            continue
        if j%b[i]== 0 :
            s.discard(j)
#            print(s)
    i+=1
    res+=1

print(len(s))

### FIXED CODE ###

N = int(input())

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


b = sorted(list(A))
dp = [0]*(max(A)+1)

m_a = max(A)+1
for i in b:
    dp[i] += 1
    if dp[i]==1 :
        for j in range(i*2, m_a,i):
            dp[j] +=100

print(dp.count(1))
a, b = map(int,input().split())
d = (int)a/b
r = a%b
f = a/b
print("%d %d %f" %(d,r,f))

 

### FIXED CODE ###

a, b = map(int,input().split())
d = a // b 
r = a % b
f = a / b
print("%d %d %f" %(d,r,f))
#両端のりんごの味は、(L, L+N-1)
N, L = map(int, input().split(''))
sum_all = N(L+((N+1)/2)-1)

if L*(L+N-1) <= 0:
  print(sum_all)
elif L < 0:
  print(sum_all - L - N + 1)
else:
  print(sum_all - L)

### FIXED CODE ###

#両端のりんごの味は、(L, L+N-1)
N, L = map(int, input().split())
sum_all = N*(L+((N+1)/2)-1)

if L*(L+N-1) <= 0:
  print(int(sum_all))
elif L < 0:
  print(int(sum_all - L - N + 1))
else:
  print(int(sum_all - L))
num = int(input())
lst = list(map(int,input().split()))
count = 0
counta == 0
for i in range(num):
  if lst[i] % 2 == 0:
    count += 1
    if lst[i] % 3 == 0 or lst[i] % 5 == 0:
      counta += 1
if count == counta:
  print("APPROVED")
else:
  print("DENIED")

### FIXED CODE ###

num = int(input())
lst = list(map(int,input().split()))
count = 0
counta = 0
for i in range(num):
  if lst[i] % 2 == 0:
    count += 1
    if lst[i] % 3 == 0 or lst[i] % 5 == 0:
      counta += 1
if count == counta:
  print("APPROVED")
else:
  print("DENIED")
def cut_and_count(N: int, S: str) -> int:
    l, r = set([]), set([])
    for c in S:
        r.add(c)

    max_len = 0
    for c in S:
        l.add(c)
        r.discard(c)

        temp = len(l & r)
        max_len = max(max, temp)

    return max_len


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = cut_and_count(N, S)
    print(ans)


### FIXED CODE ###

def cut_and_count(N: int, S: str) -> int:
    l, r = {}, {}
    for c in S:
        if c not in r:
            r[c] = 1
        else:
            r[c] += 1

    max_len = 0
    for c in S:
        if c not in l:
            l[c] = 1
        else:
            l[c] += 1
        r[c] -= 1

        ls = set(k for k, v in l.items() if v > 0)
        rs = set(k for k, v in r.items() if v > 0)

        temp = len(ls & rs)
        max_len = max(max_len, temp)

    return max_len


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = cut_and_count(N, S)
    print(ans)
K=int(input())
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[K+1])


### FIXED CODE ###

K=int(input())
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[K-1])
jewel = [i for i in input().split('\n')]
value = [int(i) for i in jewel[1].split()]
cost = [int(i) for i in jewel[2].split()]
diff = [i-j for i,j in zip(value, cost)]
price = 0
for i in sorted(diff):
    if i>0:
        price += i

print(price)

### FIXED CODE ###

jewel = int(input())
value = [int(i) for i in input().split()]
cost = [int(i) for i in input().split()]
diff = [i-j for i,j in zip(value, cost)]
price = 0
for i in sorted(diff):
    if i>0:
        price += i

print(price)
def searchInsert(nums, target):
    l = 0
    r = len(nums) - 1
    while (l <= r):
        mid = (l + r) // 2
        if target == nums[mid]:
            return mid
        elif target > nums[mid]:
            l = mid + 1
        else:
            r = mid - 1
    return l
x,y=map(int,input().split())
a=set(list(map(int,input().split())))
if y==0:
    print(x)
else:
    b=[i for i in range(1,101)]
    b=set(b)
    c=list(b-a)
    t=searchInsert(c,x)

    print(min(c[t],c[t-1]))


### FIXED CODE ###


x,y=map(int,input().split())
a=set(list(map(int,input().split())))
if y==0:
    print(x)
else:
    b=[i for i in range(-5,105)]
    b=set(b)
    c=list(b-a)
    c.append(x)
    c.sort()

    r=c.index(x)
    
    p=abs(c[r]-c[r-1])
    q=abs(c[r]-c[r+1])
    if p==q:
            print(min(c[r-1],c[r+1]))
    elif p>q:
            print(c[r+1])
    else:
            print(c[r-1])
n, m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]


class UnionFind:
    def __init__(self, n):
        self.__par = list(range(n))
        self.__siz = [1]*len(self.__par)

    def root(self, ix):
        if self.__par[ix] == ix:
            return ix
        return self.root(self.__par[ix])

    def unite(self, ix, iy):
        rx = self.root(ix)
        ry = self.root(iy)
        if rx == ry:
            return
        self.__siz[ry] += self.__siz[rx]
        self.__par[rx] = ry

    def isAkin(self, ix, iy):
        return self.root(ix) == self.root(iy)

    def size(self, ix):
        return self.__siz[self.root(ix)]


uf = UnionFind(n)
for i in l:
    uf.unite(i[0]-1, i[1]-1)

res = 0
for i in range(n):
    res = max(res, uf.size(i))
print(res)


### FIXED CODE ###

l=lambda:map(int, input().split())
n,m=l()
p=[-1]*n
def r(x):
  if p[x]<0:return x
  p[x]=r(p[x]);return r(p[x])
def u(x,y):
  x,y=r(x),r(y)
  if x==y: return  
  p[x]+=p[y]
  p[y]=x
def e(x,y):
  return r(x)==r(y)
def s(x):
  return -p[r(x)]
for _ in range(m):
  a,b=l()
  u(a-1,b-1)
print(-min(p))
N=int(input())
P=list(map(int,input().split()))
cnt=0
for i in range(N):
    M=min(P[:i+1])
    if M==P[i]:
        cnt+=1
print(cnt)

### FIXED CODE ###

N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)
H_new=H[K:]
print(sum(H_new))
N = str(input())
if N=="SAT":
  print("1")
if N=="FRY":
  print("2")
if N=="THU":
  print("3")
if N=="WED":
  print("4")
if N=="TUE":
  print("5")
if N=="MON":
  print("6")
if N=="SUN":
  print("7")


### FIXED CODE ###

N = str(input())
if N=="SAT":
  print("1")
elif N=="FRI":
  print("2")
elif N=="THU":
  print("3")
elif N=="WED":
  print("4")
elif N=="TUE":
  print("5")
elif N=="MON":
  print("6")
else:
  print("7")
import collections
n = int(input())
s = input()
ans = []
for i in range(1,n-1):
    counter = 0
    seg = s[0:i]
    another = s[i:n]
    d = collections.Counter(seg)
    for k in d:
        if k in another:
            counter += 1
    ans.append(counter)
print(max(ans))

### FIXED CODE ###

import collections
n = int(input())
s = input()
ans = []
if n != 2:
    for i in range(1,n-1):
        counter = 0
        seg = s[0:i]
        another = s[i:n]
        d = collections.Counter(seg)
        for k in d:
            if k in another:
                counter += 1
        ans.append(counter)
    print(max(ans))
else:
    if s[0] == s[1]:
        print('1')
    else:
        print('0')
import math
        
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
ans = T[0]

for i in range(1, N):
    ans = int((ans * T[i]) / math.gcd(ans, T[i]))

print(ans)
    



### FIXED CODE ###

import math
        
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
ans = T[0]

for i in range(1, N):
    ans = ans * T[i] // math.gcd(ans, T[i])

print(ans)
n = int(input())
A = list(input().split())
for i in range(n):
    A[i] = int(A[i])
m = int(input())
B = list(input().split())
for i in range(m):
    B[i] = int(B[i])

def solve(x,y):
    if x==n:
        S[y] = 1
    else:
        solve(x+1,y)
        if y+A[x] < 2001:
            solve(x+1,y+A[x]
            
S = [0]*2001
solve(0,0)
    
for i in range(m):
    if S[B[i]] == 1:
        print("yes")
    else:
        print("no")




### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
m = int(input())
B = list(map(int,input().split()))

T = [[0]*2001 for i in range(n)]

T[0][0] = 1
T[0][A[0]] = 1
for i in range(1,n):
    for j in range(2001):
        T[i][j] = T[i-1][j]
        if (j - A[i] >=0) and (T[i-1][j-A[i]] == 1):
            T[i][j] = 1
    
for i in range(m):
    if T[n-1][B[i]] == 1: print("yes")
    else: print("no")
from collections import deque
n, m = map(int, input().split())
ab = [[] for i in range(n+1)]

for i in range(m):
  a, b = map(int,input().split())
  ab[a].append(b)
  ab[b].append(a)

ans = [-1]*(n+1)
que = deque([1])

while que:
  q = que.popleft()
  for i in ab[q]:
    if ans[i] == -1:
      que.append(i)
      ans[i] = q

print("Yes")

for i range(2,n+1):
  print(ans[i])

### FIXED CODE ###

from collections import deque
n, m = map(int, input().split())
ab = [[] for i in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    ab[a].append(b)
    ab[b].append(a)

ans = [-1]*(n+1)
que = deque([1])

while que:
    q = que.popleft()
    for i in ab[q]:
        if ans[i] == -1:
            que.append(i)
            ans[i] = q

print("Yes")

for i in range(2,n+1):
    print(ans[i])
N,K=map(int,input().split())
A=list(map(int,input().split()))

genzaichi=1
rireki=set()
houmon=[0]*(N+1)
flag=0

for i in range(1,K+1):
    genzaichi=A[genzaichi-1]
    if genzaichi not in rireki:
        houmon[genzaichi]=i
        rireki.append(genzaichi)
    else:
        roop_from=genzaichi
        x=houmon[roop_from]
        roop=i-x
        flag=1
        break

if flag==0:
    print(genzaichi)
else:
    genzaichi=roop_from
    K=(K-x)-((K-x)//roop)*roop
    for i in range(K):
        genzaichi=A[genzaichi-1]
    print(genzaichi)

### FIXED CODE ###

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

genzaichi=1
rireki=set()
houmon=[0]*(N+1)
flag=0

for i in range(1,K+1):
    genzaichi=A[genzaichi-1]
    if genzaichi not in rireki:
        houmon[genzaichi]=i
        rireki.add(genzaichi)
    else:
        roop_from=genzaichi
        x=houmon[roop_from]
        roop=i-x
        flag=1
        break

if flag==0:
    print(genzaichi)
else:
    genzaichi=roop_from
    K=(K-x)-((K-x)//roop)*roop
    for i in range(K):
        genzaichi=A[genzaichi-1]
    print(genzaichi)
a = int(input())
b = [input().split() for i in range(a)]
c = 0

for i in range(a):
  c += b[i][1]-b[i][0]+1
print(c)

### FIXED CODE ###

a = int(input())
b = [input().split() for i in range(a)]
c = 0

for i in range(a):
  c = c + int(b[i][1]) - int(b[i][0]) + 1
print(c)
n=int(input())
A=list(map(int,input().split()))
q=int(input())
BC=[list(map(int,input().split())) for i in range(q)]
Alist=[0]*(10**5)
ans=[]

for a in A:
    Alist[a]+=1

sum=0
for i in range(1,len(Alist)):
    sum+=i*Alist[i]

for bc in BC:
    sum=sum-bc[0]*Alist[bc[0]]+bc[1]*Alist[bc[0]]
    Alist[bc[1]]+=Alist[bc[0]]
    Alist[bc[0]]=0
    ans.append(sum)
ans='\n'.join(map(str,ans))
print(ans)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
q=int(input())
BC=[list(map(int,input().split())) for i in range(q)]
Alist=[0]*(10**5+1)
ans=[]

for a in A:
    Alist[a]+=1

sum=0
for i in range(1,len(Alist)):
    sum+=i*Alist[i]

for bc in BC:
    sum=sum-bc[0]*Alist[bc[0]]+bc[1]*Alist[bc[0]]
    Alist[bc[1]]+=Alist[bc[0]]
    Alist[bc[0]]=0
    ans.append(sum)
ans='\n'.join(map(str,ans))
print(ans)
d = input()

if d == "A":
    print("T")
    
else if d == "T":
    print("A")

else if d == "C":
    print("G")
    
else:
    print("C")


### FIXED CODE ###

b = input()
ans = ""
for i in range(len(b)):
    if b[i] == "A":
        ans += "T"
    elif b[i] == "T":
        ans += "A"
    elif b[i] == "C":
        ans += "G"
    else:
        ans += "C"
print(ans)
N,M,K = list(map(int,input().split(' ')))

friend_list = [0]*(N+1)
bad_list = [0]*(N+1)
group = {}

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

def union(x,y):
    x = find(x)
    y = find(y)
    parent[x] = y

def find(x):
    if parent[x] == x:
        return x
    else:
        parent[x]= find(parent[x])
        return parent[x]



for i in range(M):
    A,B = list(map(int,input().split(' ')))
    friend_list[A]+=1
    friend_list[B]+=1
    
    union(A,B)

for i in range(1,N+1):
    oya = find(i)
    parent[i] = oya
    #print(oya)
    if oya in group:
        group[oya] = group[oya]+1
    else:
        group[oya]=1

for i in range(K):
    A,B = list(map(int,input().split(' ')))
    if find(A)==find(B):
        bad_list[A]+=1
        bad_list[B]+=1
    
    #union(A,B)



#print(parent)
#print('parent')

#print('friend')
#print(friend_list)
#print('bad')
#print(bad_list) 
#print(group)

kouho = [0]*N

for i in range(1,N+1):
    oya = find(i)
    abc = group[oya]-friend_list[i]-bad_list[i]-1
    kouho[i-1] = abc

for k in kouho:
    print(k,end=" ")
print()

#print(parent)

### FIXED CODE ###

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

friend_list = [0]*(N+1)
bad_list = [0]*(N+1)
group = {}

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

def find(i):
    rireki = []
    while parent[i] != i:
        rireki.append(i)
        i = parent[i]
    for r in rireki:
        parent[r]=i
    return i

def union(i, j):
    i = find(i)
    j = find(j)
    parent[j] = i



for i in range(M):
    A,B = list(map(int,input().split(' ')))
    friend_list[A]+=1
    friend_list[B]+=1
    
    union(A,B)

for i in range(1,N+1):
    oya = find(i)
    parent[i] = oya
    #print(oya)
    if oya in group:
        group[oya] = group[oya]+1
    else:
        group[oya]=1

for i in range(K):
    A,B = list(map(int,input().split(' ')))
    if find(A)==find(B):
        bad_list[A]+=1
        bad_list[B]+=1
    
    #union(A,B)



#print(parent)
#print('parent')

#print('friend')
#print(friend_list)
#print('bad')
#print(bad_list) 
#print(group)

kouho = [0]*N

for i in range(1,N+1):
    oya = find(i)
    abc = group[oya]-friend_list[i]-bad_list[i]-1
    kouho[i-1] = abc

for k in kouho:
    print(k,end=" ")
print()

#print(parent)
ch_S = input()
ch_T = input()

ind_S = []
ind_T = []
for i in list("abcdefghijklmnopqrstuvwxyz"):
    L = [ch_S.find(i)]
    ind_S.append(L, )
    R = [ch_T.find(i)]
    ind_T.append(R,)

if set(ind_S) == set(ind_T):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

S = input()
T = input()
ls = [0]*26
lt = [0]*26
al = [chr(ord('a')+i) for i in range(26)]
for i in range(S.__len__()):
    si = al.index(S[i])
    ti = al.index(T[i])
    ls[si] += 1
    lt[ti] += 1
ls.sort()
lt.sort()
if ls == lt:
    print("Yes")
else:
    print("No")
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.sort()
d = {}
for i in range(N):
    a = A[i]
    if a not in d.keys():
        d[a] = 1
    else:
        d[a] += 1
if len(d.keys()) == 1:
    if d.keys()[0] == 0:
        print("Yes")
    else:
        print("No")
elif len(d.keys()) == 2:
    keys = list(sorted(list(d.keys())))
    if d[keys[0]] == N // 3:
        print("Yes")
    else:
        print("No")
elif len(d.keys()) == 3:
    keys = list(d.keys())
    if keys[0] ^ keys[1] ^ keys[2] == 0:
        if d[keys[0]] == d[keys[1]] == d[keys[2]]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

### FIXED CODE ###

# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.sort()
d = {}
for i in range(N):
    a = A[i]
    if a not in d.keys():
        d[a] = 1
    else:
        d[a] += 1
if len(d.keys()) == 1:
    if list(d.keys())[0] == 0:
        print("Yes")
    else:
        print("No")
elif len(d.keys()) == 2:
    keys = list(sorted(list(d.keys())))
    if d[keys[0]] == N // 3:
        print("Yes")
    else:
        print("No")
elif len(d.keys()) == 3:
    keys = list(d.keys())
    if keys[0] ^ keys[1] ^ keys[2] == 0:
        if d[keys[0]] == d[keys[1]] == d[keys[2]]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")
import math

A, B, C, D = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

allnum =  B -A +1
if A%C==0:
    Csta = A
else:    
    Csta = A + (C-A%C)
if B%C==0:
    Cowa = B
else:    
    Cowa = B -B%C

if A%D==0:
    Dsta = A
else:    
    Dsta = A + (D-A%D)
if B%D==0:
    Dowa = B
else:    
    Dowa = B -B%D     

E = lcm(C, D)
if A%E==0:
    Esta = A
else:    
    Esta = A + (E-A%E)
if B%E==0:
    Eowa = B
else:    
    Eowa = B -B%E     

if A>Csta or B<Csta:
    Cnum = 0
else:
    Cnum = (Cowa-Csta+C)/C

if A>Dsta or B<Dsta:
    Dnum = 0
else:
    Dnum = (Dowa-Dsta+D)/D

if A>Esta or B<Esta:
    Enum = 0
else:
    Enum = (Eowa-Esta+E)/E


num = allnum - Cnum - Dnum + Enum
print(int(num))


### FIXED CODE ###

A, B, C, D = map(int, input().split())

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

allnum =  B -A +1
E = lcm(C, D)

Cnum = (B//C) - ((A-1)//C)
Dnum = (B//D) - ((A-1)//D)
Enum = (B//E) - ((A-1)//E)

num = allnum - Cnum - Dnum + Enum
print(int(num))
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])


def AirportBus1(x=0):
    y = x
    for i in range(x, n):
        if t[x]+k < t[i] or i-x >= c:
            y = i
            break
    if y == x:
        l.append(t[x:n])
        return
    l.append(t[x:y])
    AirportBus1(y)
    
def AirportBus2(x=0):
    y = x
    for i in range(x, n):
        if t[x]-k > t[i] or i-x >= c:
            y = i
            break
    if y == x:
        r.append(t[x:n])
        return
    r.append(t[x:y])
    AirportBus2(y)

l = []    
AirportBus1()
t.sort(reverse = True)
r = []
AirportBus2()

ans1 = 0
for lis in l:
    ans1 += -(-len(lis) // c)

ans2 = 0
for lis in r:
    ans2 += -(-len(lis) // c)

print(min(ans1,ans2))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])


def AirportBus(x=0,ans=0):
    y = x
    for i in range(x, n):
        if t[x]+k < t[i] or i - x >= c:
          y = i
          break
    if y == x:
      print(ans+1)
      return
    ans += 1
    AirportBus(y,ans)
    
AirportBus()
def calendar():
    m, d = map(int, x.split())
    res = []
    for month in range(1, m + 1):
        for day in range(2, d + 1):
            for x in range(2, d + 1):
                if x * day == month:
                    temp = str(day) + str(x)
                    temp = int(temp)
                    if temp <= d:
                        res.append(temp)
    print(len(res))


calendar()


### FIXED CODE ###

def calendar():
    m, d = map(int, input().split())
    res = []
 
    for month in range(1, m + 1):
        for day in range(2, 10):
            for x in range(2, 10):
                if x * day == month:
                    temp = str(day) + str(x)
                    temp = int(temp)
                    if temp <= d:
                        res.append(temp)
    return len(res)
 
 
print(calendar())
cnt=0
for i in range(len(n)):
    if n[0]==0:
        if i%2==0 and n[i]!=0 :
            cnt+=1
        if i&2==1 and n[i]!=1 :
            cnt+=1
    else:
        if i%2==0 and n[i]!=1 :
            cnt+=1
        if i&2==1 and n[i]!=0 :
            cnt+=1
print(cnt-1)

### FIXED CODE ###

n=input()
cnt=0
for i in range(len(n)):
    if n[0]=="0":
        if i%2==0 and n[i]=="1" :
            cnt+=1
        if i%2==1 and n[i]=="0" :
            cnt+=1
    else:
        if i%2==0 and n[i]=="0" :
            cnt+=1
        if i%2==1 and n[i]=="1" :
            cnt+=1
print(cnt)
S = input()
T = input()

for i in range(len(S) - len(T) + 1):
    flag = True
    for j in range(len(T)):
        if S[i+j] != T[j]:
            flag = False
    if flag:
        break
            
if flag:
    res = ''
    for i in range(len(S)):
        if S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)
    
else:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
if tmp == -1:
    print('UNRESTORABLE')
else:
    res = ''
    count = 0
    for i in range(len(S)):
        if start <= i < start + len(T):
            res += T[count]
            count += 1
        elif S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)
                
            

### FIXED CODE ###

S = input()
T = input()


    
if True:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
    if tmp == -1:
        print('UNRESTORABLE')
    else:
        res = ''
        count = 0
        for i in range(len(S)):
            if tmp <= i < tmp + len(T):
                res += T[count]
                count += 1
            elif S[i] == '?':
                res += 'a'
            else:
                res += S[i]

        print(res)
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string S;
    cin >> S;
    ll N = S.size();
    vector<int> CNT(2019, 0);
    CNT[0] = 1;
    ll base = pow(10, N);
    ll num = 0;

    rep(i, N) {
        base /= 10;
        num = num * 10 + (S[i] - '0');
        ++CNT[(num*base)%2019];
    }
    int ans = 0;
    for(auto cnt : CNT) {
        ans += (cnt * (cnt - 1)) / 2;
    }
    cout << ans << endl;
    return 0;
}

### FIXED CODE ###

S = list(map(int, list(input())))[::-1]
N = len(S)
CNT = [0]*2019
CNT[0] = 1
num = 0
d = 0
for i in range(N):
    num += S[i]*pow(10, d, 2019)
    num %= 2019
    CNT[num] += 1
    d += 1
ans = 0 
for cnt in CNT:
    ans += (cnt*(cnt - 1)) // 2
print(ans)