Harryxun/stf_run huggingface dataset:
n = int(input())
s = list(input())


ans = []
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
    if s[i] + s[j] + s[k] not in ans:
      ans.append(s[i] + s[j] + s[k])
      
print(len(ans))

### FIXED CODE ###

n = int(input())
s = input()
ans = 0
for i in range(10):
    a = s.find(str(i))
    if a == -1: continue
    for j in range(10):
        b = s.find(str(j), a + 1)
        if b == -1: continue
        for k in range(10):
            if s.find(str(k), b + 1) != -1:
                ans += 1
print(ans)
N, A, B = map(int, input().split())
ball = ""

while len(ball) < N:
  ball += "b" * A
  ball += "r" * B

ball_n = ball[:N]
print(ball_n.count("b"))

### FIXED CODE ###

N, A, B = map(int, input().split())
stck = N // (A + B) * A
remn = N % (A + B)
stck += min(remn, A)
print(stck)
def pin(type=int):
  return map(type,input().split())
counter = [0]*4
for i in range(3):
  a,b=pin()
  counter[a]+=1
  counter[b]+=1
ans=1
for j in counter:
  if j>3 or j<1:
    ans=0
print(["NO","YES"][ans])
    
	

### FIXED CODE ###

def pin(type=int):
  return map(type,input().split())
counter = [0]*4
for i in range(3):
  a,b=pin()
  counter[a-1]+=1
  counter[b-1]+=1
ans=1
for j in counter:
  if j>2 or j<1:
    ans=0
print(["NO","YES"][ans])
from math import factorial

n, k = map(int, input().split())
p = factorial(n - k + 1)

def fac(n, r):
    return factorial(n) // factorial(n - r) * factorial(r)
for i in range(1, k + 1):
    print( (fac(n - k + 1, i) * fac(k - 1, i - 1)) % (10 ** 9 + 7))


### FIXED CODE ###

from math import factorial

n, k = map(int, input().split())
def fac(n, r):
    return factorial(n) // (factorial(max(0, n - r)) * factorial(r))
for i in range(1, k + 1):
    print( (fac(n - k + 1, i) * fac(k - 1, i - 1)) % (10 ** 9 + 7))
n,m = map(int, input().strip().split(" "))

homework = list(map(int, input().strip().split(" ")))

day = n - sum(homework)

if day >= 0:
  
  print(day)
  
else:
  
  print(-1)


### FIXED CODE ###

import math

R = int(input())

print(R * 2 * math.pi)
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
	ans = (b-a) // 2
else:
	ans = min(a-1, n-b) + 1 + (b−a−1)//2
print(ans)


### FIXED CODE ###

n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
	ans = (b-a) // 2
else:
	ans = min(a-1, n-b) + 1 + (b-a-1)//2
print(ans)
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-.py
#
import collections

n = int(input())
l = [str(input()) for i in range(n)]
# l = ["beat", "vet", "beet", "bed", "vet", "bet", "beet"]
c = collections.Counter(l)
number_of_words = len(c)
ans_before_sort = [c.most_common()[0][0]]

for i in range(number_of_words):
    if c.most_common()[i][1] == c.most_common()[i+1][1]:
        ans_before_sort.append(c.most_common()[i+1][0])
    else:
        break

ans_after_sort = sorted(ans_before_sort)
print('\n'.join(ans_after_sort))


### FIXED CODE ###

#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-.py
#
import collections

n = int(input())
l = [str(input()) for i in range(n)]
# l = ["beat", "vet", "beet", "bed", "vet", "bet", "beet"]
c = collections.Counter(l)
number_of_words = len(c)
counted_list = c.most_common()
ans_before_sort = [counted_list[0][0]]

for i in range(number_of_words-1):
    if counted_list[i][1] == counted_list[i+1][1]:
        ans_before_sort.append(counted_list[i+1][0])
    else:
        break

ans_after_sort = sorted(ans_before_sort)
print('\n'.join(ans_after_sort))
a, b, h = map(int, input().split())
S = (a+b)/2 * h
S = int(S)
print(S)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
# A,B,C,D = int(input()) for i in range(4)
A = int(input())
B = int(input())
C = int(input())
D = int(input())
AB = A * B
CD = C * D

if AB == CD:
  print(AB)
else:
  print(AB) if AB > CD else print(CD)


### FIXED CODE ###

A,B,C,D = map(int, input().split())
print(max(A*B,C*D))
#coding: UTF-8
import math
N = int(input())
#print(N)

ans = [0]*N

for i in range(1,N+1):
  if i <=5:
    ans[i] = 0
    continue
  cnt = 0
  m = int(math.sqrt(i))
  #平方根までやればよい
  for x in range(1,m):
    if i - x**2 <= 4:
      continue
    for y in range(x,m):
      if i - x**2 -y**2 <= 3:
        continue
      for z in range(y,m):
        a = (x+y+z)**2 -x*y -y*z - z*x
        if a == i:
          if x==y==z:
            cnt += 1
          elif x==y or y==z:
            cnt += 3
          else:
            cnt += 6
  ans[i-1] = cnt
print('\n'.join(map(str, ans)))

### FIXED CODE ###

#coding: UTF-8
import math
N = int(input())
#print(N)

ans = [0]*10001

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      a = x**2+y**2+z**2+x*y+y*z+z*x
      if a <=10000:
        ans[a] += 1
    
for i in range(1,N+1):
  print(ans[i])
import sympy
def euqlid(x,y):
    if x < y:
        tmp = x
        x  = y
        y = tmp
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
k = euqlid(a, b)
data = sympy.factorint(k)
print(len(data) + 1)


### FIXED CODE ###

import math
def euqlid(x,y):
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
if a < b:
    tmp = a
    a = b
    b = tmp
k = euqlid(a, b)
sum = 0
i = 2
if k == 1:
    print(1)
    exit()
while i <= math.sqrt(k):
    flag = False
    while k % i == 0:
        k = k // i
        flag = True
    if flag:
        sum += 1
    i += 1
if i <= k:
    sum += 1
print(sum + 1)
a, b, c = input().split()


print(max(c, b//a))

### FIXED CODE ###

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


print(min(c, b//a))
a, b = int(input()), int(input())
S = a * b
R = 2 * (a+b)
print(S, R)

### FIXED CODE ###

a, b = map(int, raw_input().split())
print(str(a*b) + " " + str(2*(a+b)))
from math import sqrt, factorial
from sys import setrecursionlimit
setrecursionlimit(100000)

def inpl(): return list(map(int, input().split()))
N = int(input())
S = int(input())

RN = int(sqrt(N))
RN += ((RN+1)**2 == N)

def func(b, N):
    tmp = 0
    while N:
        N, d = divmod(N, b)
        tmp += d
    return tmp

for b in range(2, RN+1):
    tmp = func(b, N)
    if tmp == S:
        print(b)
        break
else:
    for x in range(1, RN+1):
        num = N-S+x
        if num%x:
            continue
        b = num//x
        if N//b + N%b == S:
            print(b)
            break
    else:
        print(-1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
from math import sqrt
n = int(input())
s = int(input())

def f(b, n):
    ans = 0
    while n >= b:
        ans += n%b
        n = n//b
    return ans + n

if n==s:
    print(n+1)
    exit()

for b in range(2, int(sqrt(n))+1):
    if f(b, n) == s:
        print(b)
        break
else:
    for p in range(1, int(sqrt(n))+1)[::-1]:
        d, m = divmod(p+n-s, p)
        if m == 0 and d >= 2 and f(d, n) == s:
            print(d)
            break
    else:
        print(-1)
# D

# 10^12 < 2^40

def hard_log2(N):
    
    r = 1
    l = 0
    while N >= 2*r:
        r *= 2
        l += 1
    return r, l

def maximize(r_list, K, N):
    
    if K == 0:
        return 0
    
    L, M = hard_log2(K)
    
    if r_list[M] >= N - r_list[M]:
        return maximize(r_list, L-1, N)+r_list[M]*(2**M)
    else:
        R = 0
        while 2**M > K-L:
            R += (N-r_list[M])*(2**M)
            M -= 1
        
        return max(maximize(r_list, K-L, N)+R, maximize(r_list, L-1, N))

def main_d(A_list, N, K):
    r_list = [0]*40
    for i in range(40):
        for A in A_list:
            if (A % 2**(i+1)) >= 2**i:
                r_list[i] += 1
    L, M = hard_log2(K)
    R = 0
    for i in range(M+1, 40):
        R += r_list[i]*(2**i)
    return R + maximize(r_list, K, N)
    

if __name__ == "__main__":
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    res = main_d(A_list, N, K)
    print(res)

### FIXED CODE ###

# D

# 10^12 < 2^40

def hard_log2(N):
    
    r = 1
    l = 0
    while N >= 2*r:
        r *= 2
        l += 1
    return r, l

def maximize_simple(r_list, K, N):
    if K == 0:
        return 0
    R = 0
    L, M = hard_log2(K)
    for i in range(M+1):
        R += max(r_list[i], N - r_list[i])*(2**i)
        
    return R

def maximize(r_list, K, N):
    
    if K == 0:
        return 0
    
    L, M = hard_log2(K)
    
    if r_list[M] >= N - r_list[M]:
        return maximize_simple(r_list, L-1, N)+r_list[M]*(2**M)
    else:
        R = (N-r_list[M])*(2**M)
        m = M - 1
        while 2**m > K-L and m >=0:
            R += r_list[m]*(2**m)
            m -= 1
        
        return max(maximize(r_list, K-L, N)+R, maximize_simple(r_list, L-1, N)+r_list[M]*(2**M))

def main_d(A_list, N, K):
    r_list = [0]*41
    for i in range(41):
        for A in A_list:
            if (A % 2**(i+1)) >= 2**i:
                r_list[i] += 1
    if K == 0:
        R = 0
        for i in range(41):
            R += r_list[i]*(2**i)
        return R
    else:
        L, M = hard_log2(K)
        R = 0
        for i in range(M+1, 41):
            R += r_list[i]*(2**i)
        return R + maximize(r_list, K, N)
    

if __name__ == "__main__":
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    res = main_d(A_list, N, K)
    print(res)
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
l=list(range(1,m+1))
l=list(itertools.combinations_with_replacement(l,4))
ans=0
for i in l:
  kari=0
  for j in range(q):
    if i[abcd[j][1]-1]-i[abcd[j][0]-1]==abcd[j][2]:
      kari+=abcd[j][3]
  ans=max(ans,kari)
print(ans)

### FIXED CODE ###

import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
l=list(range(1,m+1))
l=list(itertools.combinations_with_replacement(l,n))
ans=0
for i in l:
  kari=0
  for j in range(q):
    if i[abcd[j][1]-1]-i[abcd[j][0]-1]==abcd[j][2]:
      kari+=abcd[j][3]
  ans=max(ans,kari)
print(ans)
from collections import defaultdict

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

dict = defaultdict(int)

for i in range(M):
  B, C = map(int, input().split())
  dict[C] += B

idx = 0
for k, v in sorted(dict.items(), key=lambda x: -x[0]):
  for _ in range(v):
    if A[idx] < k:
      A[idx] = k
      idx += 1
    else:
      print(sum(A))
      exit()

print(sum(A))
  

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

from collections import defaultdict

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

dict = defaultdict(int)

for i in range(M):
  B, C = map(int, input().split())
  dict[C] += B

idx = 0
for k, v in sorted(dict.items(), key=lambda x: -x[0]):
  for _ in range(v):
    if idx+1 <= len(A):
      if A[idx] < k:
      	A[idx] = k
      	idx += 1
      else:
        print(sum(A))
        exit()
    else:
      print(sum(A))
      exit()
      
      
print(sum(A))
S = input()
if S[:2] == "00":
  if S[2:] > 12:
  	print("NA")
  else:
    print("YYMM")
elif S[2:] == "00":
  if S[:2] > 12:
  	print("NA")
  else:
    print("MMYY")
elif int(S[:2]) > 12 and int(S[2:]) > 12:
  print("NA")
elif int(S[:2]) < 13 and int(S[2:]) < 13:
  print("AMBIGUOUS")
elif int(S[:2]) < 13:
  print("MMYY")
else:
  print("YYMM")

### FIXED CODE ###

S = input()
if S[:2] == "00":
  if int(S[2:]) > 12 or S[2:] == "00":
  	print("NA")
  else:
    print("YYMM")
elif S[2:] == "00":
  if int(S[:2]) > 12:
  	print("NA")
  else:
    print("MMYY")
elif int(S[:2]) > 12 and int(S[2:]) > 12:
  print("NA")
elif int(S[:2]) < 13 and int(S[2:]) < 13:
  print("AMBIGUOUS")
elif int(S[:2]) < 13:
  print("MMYY")
else:
  print("YYMM")
s = input()

max_plus = len(s) - 1

numList = [int(c) for c in s]

sMax = (1 << max_plus) - 1

ans = 0

for plus_pos in range(sMax + 1):
    sum = 0

    num = numList[0]

    for i in range(max_plus):
        if ((plus_pos >> i) & 1) == 1:
            sum += num
            num = numList[i + 1]
        else:
            num = num * 10 + numList[i + 1]

    sum += num
    ans += sum

print(ans)s = input()

max_plus = len(s) - 1

numList = [int(c) for c in s]

sMax = (1 << max_plus) - 1

ans = 0

for plus_pos in range(sMax + 1):
    sum = 0

    num = numList[0]

    for i in range(max_plus):
        if ((plus_pos >> i) & 1) == 1:
            sum += num
            num = numList[i + 1]
        else:
            num = num * 10 + numList[i + 1]

    sum += num
    ans += sum

print(ans)

### FIXED CODE ###

s = input()

max_plus = len(s) - 1

numList = [int(c) for c in s]

sMax = (1 << max_plus) - 1

ans = 0

for plus_pos in range(sMax + 1):
    sum = 0

    num = numList[0]

    for i in range(max_plus):
        if ((plus_pos >> i) & 1) == 1:
            sum += num
            num = numList[i + 1]
        else:
            num = num * 10 + numList[i + 1]

    sum += num
    ans += sum

print(ans)
i = 0

while i == 0:
    x = raw_input()
    a, op, b = x.split()
    a = int(a)
    b = int(b)
    
    if op == "+":
        print ("%d" &(a+b))
    elif op == "-":
        print ("%d" &(a-b))
    elif op == "*":
        print ("%d" &(a*b))
    elif op == "/":
        print ("%d" &(a/b))
    elif op == "?":
        i == 1

### FIXED CODE ###

i = 1

while i == 1:
    x = raw_input()
    a, op, b = x.split(" ")
    a = int(a)
    b = int(b)
    
    if op == "?":
        i = 0
    elif op == "+":
        print ("%d" %(a+b))
    elif op == "-":
        print ("%d" %(a-b))
    elif op == "*":
        print ("%d" %(a*b))
    else:
        print("%d" %(a/b))
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
query, X = [], {}

for i in range(Q):
    q = int(input())
    query.append(q)
    X[q] = i
query.sort()

near_s = [0 for _ in range(Q)]
near_t = [0 for _ in range(Q)]
j = 0
while j < Q and query[j] < S[0]:
    near_s[j] = [0, S[0]]
    j += 1    
for i in range(A-1):
    while j < Q and S[i] < query[j] < S[i+1]:
        near_s[j] = [S[i], S[i+1]]
        j += 1
near_s = near_s[:j] + [[S[A-1],0] for _ in range(Q-j)]

j = 0
while j < Q and query[j] < T[0]:
    near_t[j] = [0, T[0]]
    j += 1
for i in range(B-1):
    while j < Q and T[i] < query[j] < T[i+1]:
        near_t[j] = [T[i], T[i+1]]
        j += 1
near_t = near_t[:j] + [[T[B-1],0] for _ in range(Q-j)]

ans = [0]*Q
for i in range(Q):
    q, s0, s1, t0, t1 = query[i], *near_s[i], *near_t[i]
    l1 = q - min(s0, t0)
    l2 = max(s1, t1) - q
    l3 = s1 - t0 + min(s1 - q, q - t0)
    l4 = t1 - s0 + min(t1 - q, q - s0)
    if s0 == 0:
        l1, l4 = float('inf'), float('inf')
    if s1 == 0:
        l2, l3 = float('inf'), float('inf')
    if t0 == 0:
        l1, l3 = float('inf'), float('inf')
    if t1 == 0:
        l2, l4 = float('inf'), float('inf')
    ans[X[q]] = min(l1, l2, l3, l4)

for a in ans:
    print(a)

### FIXED CODE ###

A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
query, X = [], {}

for i in range(Q):
    q = int(input())
    query.append(q)
    X[q] = i
query.sort()

near_s = [0 for _ in range(Q)]
near_t = [0 for _ in range(Q)]
j = 0
while j < Q and query[j] < S[0]:
    near_s[j] = [0, S[0]]
    j += 1    
for i in range(A-1):
    while j < Q and S[i] < query[j] < S[i+1]:
        near_s[j] = [S[i], S[i+1]]
        j += 1
near_s = near_s[:j] + [[S[A-1],0] for _ in range(Q-j)]

j = 0
while j < Q and query[j] < T[0]:
    near_t[j] = [0, T[0]]
    j += 1
for i in range(B-1):
    while j < Q and T[i] < query[j] < T[i+1]:
        near_t[j] = [T[i], T[i+1]]
        j += 1
near_t = near_t[:j] + [[T[B-1],0] for _ in range(Q-j)]

ans = [0]*Q
for i in range(Q):
    q, s0, s1, t0, t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1]
    l1 = q - min(s0, t0)
    l2 = max(s1, t1) - q
    l3 = s1 - t0 + min(s1 - q, q - t0)
    l4 = t1 - s0 + min(t1 - q, q - s0)
    if s0 == 0:
        l1, l4 = float('inf'), float('inf')
    if s1 == 0:
        l2, l3 = float('inf'), float('inf')
    if t0 == 0:
        l1, l3 = float('inf'), float('inf')
    if t1 == 0:
        l2, l4 = float('inf'), float('inf')
    ans[X[q]] = min(l1, l2, l3, l4)

for a in ans:
    print(a)
h = int(input())
mount = [int(_) for _ in input().split()]
count = 0
for i in range(len):
  if i = 0:
    count += 1
  else:
    if mount[i]>mount[i-1]:
      count += 1
print (count)

### FIXED CODE ###

h = int(input())
mount = [int(_) for _ in input().split()]
count = 0
for i in range(h):
  if i == 0:
    count += 1
  else:
    for j in range(i):
      if mount[i]<mount[j]:
        break
    else:
      count += 1
print (count)
def add(r):
    if r.next==[]:
        pass
    else:
        for v in r.next:
            v.val+=r.val
            add(v)

class Vertex:
    def __init__(self):
        self.val=0
        self.next=[]

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

V=[Vertex() for i in range(N)]

for i in range(N-1):
    a,b=map(int,input().split())
    V[a-1].next.append(V[b-1])

for i in range(Q):
    p,x=map(int,input().split())
    V[p-1].val+=x

add(V[0])

for v in V:
    print(v.val,end=' ')

### FIXED CODE ###

from collections import deque

N,Q=map(int,input().split())
out=[set() for i in range(N+1)];out[0]=None # 頂点は1-initial
for j in range(N-1):
    a,b=map(int,input().split())
    out[a].add(b)
    out[b].add(a)
# print(out) #DB

a=[0 for i in range(N+1)];a[0]=None

for k in range(Q):
    p,x=map(int,input().split())
    a[p]+=x

# print(a) #DB

q=deque()
q.append(1)
while q:
    u=q.popleft()
    for v in out[u]:
        a[v]+=a[u]
        q.append(v)
        out[v].remove(u)
        # print(q) #DB
    out[u].clear()

print(*a[1:])
W,H,x,y = map(int, input().split())
out1 = W*H/2
out2 = 0
if (x,y) = (W/2,H/2):
  out2 = 1
print(out1, out2)

### FIXED CODE ###

W,H,x,y = map(int, input().split())
out1 = W*H/2
out2 = 0
if (x,y) == (W/2,H/2):
  out2 = 1
print(out1, out2)
a, b, c = map(int, input().split())

if a == b:
  print(c)
elif a == c:
  print(b):
else:
  print(a)

### FIXED CODE ###

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

if a == b:
  print(c)
elif a == c:
  print(b)
else:
  print(a)
import sys
from  heapq import heappush, heappop, heapify

N=input()

par=[ i for i in range(N) ]

def root(x):
	if par[x]==x:
		return x
	else:
		par[x]=root( par[x] )
		return par[x]

def same(x,y):
	return root(x)==root(y)

def unite(x,y):
	x=root(x)
	y=root(y)
	if x==y: return
	par[x]=y



X=[]
Y=[]
for i in range(N):
	x,y=map(int, sys.stdin.readline().split()) 
	X.append( (x,i) )
	Y.append( (y,i) )

X.sort(key=lambda x: x[0])
Y.sort(key=lambda x: x[0])

hq=[]
for i in range(N-1):
	d=abs( X[i+1][0]-X[i][0] )
	x1=X[i][1]
	x2=X[i+1][1]
	heappush( hq, (d,x1,x2) )

	d=abs( Y[i+1][0]-Y[i][0] )
	x1=Y[i][1]
	x2=Y[i+1][1]
	heappush( hq, (d,x1,x2) )


ans=0
while hq:
	d,a,b=heappop(hq)
	if not same(a,b):
		ans+=d
		unite(a,b)
		
print ans


### FIXED CODE ###

# -*- coding: utf-8 -*-
import heapq
import sys
sys.setrecursionlimit(10**6)
N = input()
a = []
for i in range(N):
	x,y=map(int,raw_input().split())
	a.append((i,x,y))

#a => point,x,y
a1=sorted(a, key=lambda x: x[1])
a2=sorted(a, key=lambda x: x[2])


#Union Find
#初めは各頂点が根
par=[ i for i in range(N) ]
#木の根を求める
def root(x):
	if par[x]==x:
		return x
	else:
		r=root(par[x])
		#経路圧縮
		par[x]=r
		return r
#xとyが同じ集合に属するか
def same(x,y):
	return root(x)==root(y)

#xとyが同じ根に所属していた場合、連結
def unite(x,y):
	x=root(x)
	y=root(y)
	if x==y:
		return
	else:
		par[x]=y


b=[]
for i in range(N-1):
	# len_x,x,y
	heapq.heappush( b, ( abs(a1[i+1][1]-a1[i][1]),a1[i][0],a1[i+1][0],  ))

for i in range(N-1):
	# len_y,x,y
	heapq.heappush( b, ( abs(a2[i+1][2]-a2[i][2]),a2[i][0],a2[i+1][0],  ))

#print "# b"
#print b


ans=0
cnt=0
for i in range(len(b)):
	if cnt==N-1:
		break
	val=heapq.heappop(b)
	#２点が同じ根でない場合は、木を結合する
	if not same(val[1],val[2]):
		unite(val[1],val[2])
		ans+=val[0]
		cnt+=1

print ans
input(x)

print(x**3)


### FIXED CODE ###

x = int(input())

print(x**3)
import math
a, b, c, d = map(int, input().split())

c_count = b//c
d_count = b//d
# 最小公倍数で割る
c_d = b//(c*d//math.gcd(c, d))

print(b - c_count - d_count + c_d - (a-1 - (a-1)//c - (a-1)//d + (a-1)//(c*d//math.gcd(c, d))))

### FIXED CODE ###

from fractions import gcd
a, b, c, d = map(int, input().split())

c_count = b//c
d_count = b//d
# 最小公倍数で割る
c_d = b//(c*d//gcd(c, d))

print(b - c_count - d_count + c_d - (a-1 - (a-1)//c - (a-1)//d + (a-1)//(c*d//gcd(c, d))))
a,b=map(int,input().split())

c=0
for i in range(a,b+1):
  s=list(map(str,i))
  if s=reversed(s):
    c+=1
print(c)

### FIXED CODE ###

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

c=0
for i in range(a,b+1):
  s=str(i)
  if s==s[::-1]:
    c+=1
print(c)
import numpy as np
from collections import Counter

N = int(input())
A = Counter(map(int, input().split()))
S = (None, A[3] + A[2] + A[1], A[3] + A[2], A[3])

dp = np.zeros((S[1] + 1, S[2] + 1, S[3] + 1), dtype=float)
for l in range(1, S[1] + 1):
    for m in range(S[2] + 1):
        if l < m:
            break
        mk = min(m + 1, S[3] + 1)
        dp[l][m][:mk] = (dp[l - 1][m][:mk] * (l - m) + dp[l][m - 1][:mk] * (m - np.arange(mk)) + N) / l

        matr = np.tile(np.arange(mk) / l, (mk, 1))
        matr[np.tri(mk, dtype=bool)] = 1
        matr = np.multiply.accumulate(matr, axis=1)
        matr[np.tri(mk, k=-1, dtype=bool)] = 0

        dp[l][m][:mk] = dp[l][m][:mk] @ matr
print(dp[S[1]][S[2]][S[3]])


### FIXED CODE ###

from collections import Counter

N = int(input())
A = Counter(map(int, input().split()))
S = [None, A[3] + A[2] + A[1], A[3] + A[2], A[3]]

dp = [[[0] * (S[3] + 1) for _ in range(S[2] + 1)] for __ in range(S[1] + 1)]

for l in range(1, S[1] + 1):
    for m in range(S[2] + 1):
        if l < m:
            break
        for k in range(S[3] + 1):
            if m < k:
                break
            dp[l][m][k] = (dp[l - 1][m][k] * (l - m) + dp[l][m - 1][k] * (m - k) + dp[l][m][k - 1] * k + N) / l
print(dp[S[1]][S[2]][S[3]])
import math

a, b = map(int, input().split())
x = math.gcd(a, b)
k = []
for i in range(1, x+1):
    if x % i == 0:
        k.append(i)
cnt = 0
for n in k:
    if n == 1:
        cnt += 1
    elif n == 2:
        cnt += 1
    else:
        flg = ""
        for p in range(2, n):
            if n % p == 0:
                flg = "composite"
                break
            else:
                flg = "prime"
        if flg == "prime":
            cnt += 1
print(cnt)


### FIXED CODE ###

import math

def gcd(n, m):
    while m != 0:
        n, m = m, n % m
    return n

a, b = map(int, input().split())
g = gcd(a, b)
g_2 = int(math.sqrt(g))
cnt = 1

for i in range(2, g_2+1):
    if g % i == 0:
        while g % i == 0:
            g //= i
        cnt += 1
if g > 1:
    cnt += 1

print(cnt)
d = []
e = [0,0,0,0,0]
f = [74,24,14,4,2]
for i in prime_list:
  a = n
  b = 0
  c = 1
  while a // (i**c) > 0:
    b += a // (i**c)
    c += 1
  else:
    d.append(b)
count = 0
len_d = len(d)-1
for k in f:
  for i,j in enumerate(d):
    if j < k:
      e[count] = i
      count += 1
      break
    elif i == len_d:
      e[count] = i+1
      count += 1
      break


print(e[0]+e[1]*(e[4]-1)+e[2]*(e[3]-1)+(e[3]*(e[3]-1)//2)*(e[4]-2))

### FIXED CODE ###

n = int(input())
prime_list = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
d = []
e = [0,0,0,0,0]
f = [74,24,14,4,2]
for i in prime_list:
  a = n
  b = 0
  c = 1
  while a // (i**c) > 0:
    b += a // (i**c)
    c += 1
  else:
    d.append(b)
count = 0
len_d = len(d)-1
for k in f:
  for i,j in enumerate(d):
    if j < k:
      e[count] = i
      count += 1
      break
    elif i == len_d:
      e[count] = i+1
      count += 1
      break



print(e[0]+e[1]*(e[4]-1)+e[2]*(e[3]-1)+(e[3]*(e[3]-1)//2)*(e[4]-2))
a,b,c,k = map(int,input().split())

if  k < a:
    print(k)
elif k < a + b:
    print(a)
nelse:
    print(2*a + b - k)

### FIXED CODE ###


a,b,c,k = map(int,input().split())

if  k < a:
    print(k)
elif k < a + b:
    print(a)
else:
    print(2*a + b - k)
K = int(input())
if K % 2 == 0:
    print(-1)
else:
    a = 7
    count = 1
    while True:
        if a % K == 0:
            break
        a = (a * 10) + 7
        count += 1
print(count)

### FIXED CODE ###

K = int(input())
a = 7
count = 1
for i in range(K):
    if a % K == 0:
        break
    a = (a * 10 + 7) % K
    count += 1
if count == K + 1:
    print(-1)
else:
    print(count)