Harryxun/stf_run huggingface dataset:
def main():
    N = int(input())

    lst = erastosthenes(N)
    plist = [i for i in range(3, N + 1, 2) if lst[i]]
    plist = [2] + plist

    mod = 1000000007
    ans = 1
    for p in plist:
        cnt = 0
        i = 1
        while 1:
            x = p ** i
            if x > N:
                break
            cnt += N // x
            i += 1
        ans = (ans % mod * (cnt + 1) % mod) % mod
    print(ans)

def erastosthenes(n):
    prime = [0, 1] * ((n + 1) // 2)
    if not n % 2:
        prime += [0]
    prime[1], prime[2] = 0, 1

    sqrt = n ** 0.5
    i = 3
    while i <= sqrt:
        for j in range(i ** 2, n, i):
            prime[j] = 0
        i += 2
    return prime

main()


### FIXED CODE ###

def main():
    N = int(input())

    if N == 1:
        print(1)
        return

    lst = erastosthenes(N)
    plist = [i for i in range(3, N + 1, 2) if lst[i]]
    plist = [2] + plist

    mod = 1000000007
    ans = 1
    for p in plist:
        cnt = 0
        i = 1
        while 1:
            x = p ** i
            if x > N:
                break
            cnt += N // x
            i += 1
        ans = ans * (cnt + 1) % mod
    print(ans)

def erastosthenes(n):
    prime = [0, 1] * ((n + 1) // 2)
    if not n % 2:
        prime += [0]
    prime[1], prime[2] = 0, 1

    sqrt = n ** 0.5
    i = 3
    while i <= sqrt:
        for j in range(i ** 2, n + 1, i):
            prime[j] = 0
        i += 2
    return prime

main()
n,m = map(int, input().split())
neighbors = {key:[] for key in range(1, n+1)}
answers = {key:0 for key in range(1, n+1)}
answers[1] = 1
for i in range(m):
    a,b = map(int, input().split())
    neighbors[a].append(b)
    neighbors[b].append(a)
hosts = neighbors[1]
now = 1
def register(hs, n):
    for h in hs:
        if answers[h] == 0:
            answers[h] = n
            register(neighbors[h], h)
register(hosts, now)
flag = 0
for key, item in answers.items():
    if item == 0:
        flag = 1
if flag == 0:
    print("Yes")
    for key, item in answers.items():
        if key != 1:
            print(item)
else:
    print("No")

### FIXED CODE ###

n,m = map(int, input().split())
neighbors = {key:[] for key in range(1, n+1)}
answers = {key:0 for key in range(1, n+1)}
answers[1] = 1
for i in range(m):
    a,b = map(int, input().split())
    neighbors[a].append(b)
    neighbors[b].append(a)

def register(hs):
    newhs = []
    for h in hs:
        for i in neighbors[h]:
            if answers[i] == 0:
                answers[i] = h
                newhs.append(i)
    return newhs

hosts = [1]
while True:
    hosts = register(hosts)
    if len(hosts) == 0:
        break

flag = 0
for key, item in answers.items():
    if item == 0:
        flag = 1
if flag == 0:
    print("Yes")
    for key, item in answers.items():
        if key != 1:
            print(item)
else:
    print("No")
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

v = [a,b,c,d,e]

import math

times = [ math.ceil(a/10)*10,
          math.ceil(b/10)*10,
          math.ceil(c/10)*10,
          math.ceil(d/10)*10,
          math.ceil(e/10)*10 ]

digit1 = [a - a//10*10,
          b - b//10*10,
          c - c//10*10,
          d - d//10*10,
          e - e//10*10]

m = 10
tt = 0
idx = 99

for i in range(5):
    tt += times[i]
    if 0 < digit1[i] and digit1[i] < m:
        m = digit1[i]
        idx = i

print('{}'.format(tt - times[idx] + v[idx]))


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

v = [a,b,c,d,e]

import math

times = [ math.ceil(a/10)*10,
          math.ceil(b/10)*10,
          math.ceil(c/10)*10,
          math.ceil(d/10)*10,
          math.ceil(e/10)*10 ]

digit1 = [a - a//10*10,
          b - b//10*10,
          c - c//10*10,
          d - d//10*10,
          e - e//10*10]

m = digit1[0]
tt = 0
idx = 0

for i in range(5):
    tt += times[i]
    if 0 < digit1[i] and digit1[i] < m:
        m = digit1[i]
        idx = i

print('{}'.format(tt - times[idx] + v[idx]))
def q3():
    import math
    A,B,C,D = (int(i) for i in input().split())

    def lcm(x, y):
        """ 最小公倍数を求める """
        return (x * y) // math.gcd(x, y)

    num_C = B // C - (A - 1) // C  # Cで割り切れる個数
    num_D = B // D - (A - 1) // D  # Dで割り切れる個数
    num_CD = B // lcm(C, D) - (A - 1) // lcm(C, D)  # CとDの最小公倍数で割り切れる個数
    num_all = num_C + num_D - num_CD  # 全ての割り切れる個数
    ans = B - A + 1 - num_all
    print(ans)

if __name__ == '__main__':
    q3()

### FIXED CODE ###

def q3():
    """ C - Anti-Division """
    from fractions import gcd  # 3.4.3ではmath.gcdは無い
    A,B,C,D = (int(i) for i in input().split())

    def lcm(x, y):
        """ 最小公倍数を求める """
        return (x * y) // gcd(x, y)

    num_C = B // C - (A - 1) // C  # Cで割り切れる個数
    num_D = B // D - (A - 1) // D  # Dで割り切れる個数
    lcm_CD = lcm(C, D)
    num_CD = B // lcm_CD - (A - 1) // lcm_CD  # CとDの最小公倍数で割り切れる個数
    num_all = num_C + num_D - num_CD  # 全ての割り切れる個数
    ans = B - A + 1 - num_all
    print(ans)


if __name__ == '__main__':
    q3()
import sys
from collection import defaultdict
import math

def calc(num):
    if num<=1:
        return 1
    else:
        num_sqrt=math.floor(math.sqrt(num))
        prime_list=make_prime_list_2(num_sqrt)

        dict_counter=defaultdict(int)
        for prime in prime_list:
            while num % prime==0:
                dict_counter[prime]+=1
                num //=prime
        if num !=1:
            dict_counter[num]+=1

        dict_counter=dict(dict_counter)

        return dict_counter
def main():
    num=input()
    eight_counter=[]
    calc_result=calc(num)
    for i in range(num):
        if calc_result==8:
            eight_counter.append(num)
        else:
            pass
    print(len(eight_counter))

main()

### FIXED CODE ###

def calculate_num_of_divisor(N):
    yakusuu = []
    for i in range(1, N+1):
        if N % i == 0:
            yakusuu.append(i)
    return len(yakusuu)

N = int(input())
count = []
for i in range(N+1):
    if i % 2 == 1 and calculate_num_of_divisor(i) == 8:
        count.append(i)
print(len(count))
n, m = map(int, input().split())
S, C = [], []
ans = -1

for _ in range(m):
  s, c = map(int, input().split())
  S.append(s)
  C.append(c)
  
for num in range(10 ** (max(S) - 1), 10 ** n):
  num = str(num)
  f = 1
  for s, c in zip(S, C):
    s = s - 1
    if int(num[s]) != c:
      f = 0
      break
      
  if f:
    ans = num
    break
    
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
 
num = [-1] * n
ans = -1
f = 1
 
for _ in range(m):
  s, c = map(int, input().split())
  if s == 1 and c == 0:
    if n == 1:
      ans = 0
    f = 0
    break
    
  i = num[s - 1]
  if i == -1:
    num[s-1] = c
  elif i == c:
    continue
  else:
    f = 0
    break
  
if num[0] == -1:
  if n == 1:
    num[0] = 0
  else:
    num[0] = 1
  
if f:
  num = [0 if n == -1 else n for n in num]
  ans = ''.join(map(str, num))
  
print(ans)
n=int(input())
l=[list(input())]
b=True
for i in range(n-1):
  w=list(input())
  if l[-1][-1]==w[0]:
    l.append(w)
  else:
    b=False
    break
if len(set(l))==n and b==True:
  print("Yes")
else:
  print("No")
  

  


### FIXED CODE ###

n=int(input())
b=True
l=[]
w=input()
l.append(w)
for i in range(n-1):
  w=input()
  if w in l or w[0]!=l[-1][-1]:
    b=False
    break
  else:
    l.append(w)
if b:
  print("Yes")
else:
  print("No")
def main():
    n = int(input())
    matrix = [int(num) for num in (input().split() for i in range(2))]

    candies = [sum(matrix[0][:d+1]) + sum(matrix[1][d:]) for d in range(n)]
    print(max(candies))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    matrix = []
    matrix.append([int(num) for num in input().split()])
    matrix.append([int(num) for num in input().split()])

    candies = [sum(matrix[0][:d+1]) + sum(matrix[1][d:]) for d in range(n)]
    print(max(candies))


if __name__ == '__main__':
    main()
N,K = map(int,input().split())
H = map(int,input().split()).sort()

print(sum(H[0:N-K]))

### FIXED CODE ###

N,K = map(int,input().split())
H = [int(x) for x in input().split()]
H.sort()

if N >= K:
    print(sum(H[0:N-K]))
else:
    print(0)
import math
N = int(input())
T = []

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

for i in range(N):
    T.append(int(input()))

    

if len(T) > 2:
    g = lcm(T[0],T[1])
    for i in range(3,N-1):
        g = lcm(g,T[i+1])
    print(g)
elif len(T) == 2:
    print(g)
else:
    print(T[0])

### FIXED CODE ###

import math
N = int(input())
T = []

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

for i in range(N):
    T.append(int(input()))

    

if len(T) > 2:
    g = lcm(T[0],T[1])
    for i in range(3,N-1):
        g = lcm(g,T[i+1])
    print(g)
elif len(T) == 2:
    g = lcm(T[0],T[1])
    print(g)
else:
    print(T[0])
import numpy as np

def solve(n, a, lst):
  m = max(max(lst), a)
  ans = np.zeros((n+1, n+1, n*m+1))
  #ans[i][j][k] : lst[:i]までの中からj枚選んで合計kにする選び方
  for i in range(n+1):
    for j in range(n+1):
      for k in range(n*m+1):
        if i == 0 and j == 0 and k == 0:
          ans[i][j][k] = 1
        elif i >= 1 and k < lst[i-1]:
          ans[i][j][k] = ans[i-1][j][k]
        elif i >= 1 and lst[i-1] <= k and j >= 1:
          ans[i][j][k] = ans[i-1][j-1][k-lst[i-1]] + ans[i-1][j][k]
        else:
          ans[i][j][k] = 0
  ret = 0
  for i in range(1,n+1):
    ret += ans[-1][i][i*a]
  return int(ret)

if __name__ == "__main__":
  n, a = map(int,input().split())
  x_list = [int(i) for i in input().split()]
  ans = solve(n,a,x_list)
  print(ans)


### FIXED CODE ###

def solve(n, a, lst):
  m = max(max(lst), a)
  ans = [[[0]*(n*m+1) for i in range(n+1)] for j in range(n+1)]
  #ans[i][j][k] : lst[:i]までの中からj枚選んで合計kにする選び方
  for i in range(n+1):
    for j in range(n+1):
      for k in range(n*m+1):
        if i == 0 and j == 0 and k == 0:
          ans[i][j][k] = 1
        elif i >= 1 and k < lst[i-1]:
          ans[i][j][k] = ans[i-1][j][k]
        elif i >= 1 and lst[i-1] <= k and j >= 1:
          ans[i][j][k] = ans[i-1][j-1][k-lst[i-1]] + ans[i-1][j][k]
        else:
          ans[i][j][k] = 0
  ret = 0
  for i in range(1,n+1):
    ret += ans[-1][i][i*a]
  return int(ret)

if __name__ == "__main__":
  n, a = map(int,input().split())
  x_list = [int(i) for i in input().split()]
  ans = solve(n,a,x_list)
  print(ans)
from itertools import*
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i = list(permutations(range(1,n+1))).index
print(abs(i(a) - i(b)))

### FIXED CODE ###

from itertools import*
i = list(permutations(range(1,int(input())+1))).index
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
print(abs(i(a) - i(b)))
N = int(input())
count=0
for i in range(N):
  p,q=map(int,input().split(' '))
  if count<3:
	if p==q:
      count+=1
    else:
      count=0
  else:
    pass
if count>=3:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N= int(input())
count=0
for i in range(N):
  p,q=map(int,input().split(' '))
  if count<3:
    if p==q:
      count+=1
    else:
      count=0
  else:
    pass

if count>=3:
  print('Yes')
else:
  print('No')
n = int(input())
A = list(map(int, input().split()))
a = list(set(A))
a.sort(reverse = True)
B = []
for i in a:
    if A.count(i) >= 2:
        B.append(i)
if len(B) <= 1:
    print(0)
else:
    print(B[0]*B[1])

### FIXED CODE ###

x,a,b = map(int,input().split())
if abs(x-a) < abs(x-b):
    print("A")
else:
    print("B")
N,M=map(int,input().split())

A=list(map(int,input().split()))
A.sort()
dc=[]

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

dc.sort(key=lambda x: x[1],reverse=True)
bf=False
i=0

for l in dc:
    B,C=l
    if bf or i>=N:
        break
    while B>0:
        if A[i]<C:
            A[i]=C
            B-=1
            i+=1
        else:
            bf=True
            i+=1
            break

print(sum(A))


### FIXED CODE ###

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

A=list(map(int,input().split()))
A.sort()
dc=[]

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

dc.sort(key=lambda x: x[1],reverse=True)
bf=False
i=0
for l in dc:
    B,C=l
    if bf:
        break
    while B>0:
        if i<N and A[i]<C:
            A[i]=C
            B-=1
            i+=1
        else:
            bf=True
            break


print(sum(A))
n,k=map(int,input().split())
for i in rep(k,n+1+1):
    l=(i-1)*i//2
    r=(n-i+1+n)*i//2
    ans+=(r-l+1)
    ans%=10**9+7
print(ans)

### FIXED CODE ###

from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)];rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

show_flg=False
show_flg=True

ans=0

n,k=LI()

for i in range(k,n+1+1):
    #r=(n+n-k+1)*k//2-(k-1)*k//2+1
    r=(n+n-i+1)*i//2-(i-1)*i//2+1
    r%=mo
    ans+=r
    #show(i,r)


print(ans%mo)
N=int(input());t=[0]*(N+1);x=[0]*(N+1);y=[0]*(N+1);flag=1
for i in range(N):t[i+1],x[i+1],y[i+1]=map(int,input().split())
for i in range(N):a=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])-t[i+1]+t[i];flag=0;break if a>0 or a%2
print("Yes" if flag else "No")  

### FIXED CODE ###

N = int(input())
t = [0 for i in range(N + 1)]
x = [0 for i in range(N + 1)]
y = [0 for i in range(N + 1)]
for i in range(N):
    t[i + 1], x[i + 1], y[i + 1] = map(int, input().split())
flag = 1
for i in range(N):
    dl = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    dt = t[i + 1] - t[i]
    if dl > dt or (dl - dt) % 2 == 1:
        flag = 0
        break
if flag == 1:
    print("Yes")
else:
    print("No")
N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
    exit()
    
A = sorted(A)
check_list = [0] * (10**6 + 1)

cnt = 0
for i in range(len(A)):
    tmp = A[i]
    while True:
        check_list[tmp] += 1
        if tmp > 10**6:
            break
        tmp += A[i]

for a in A:
    if check_list[a] == 1:
        cnt += 1
print(cnt)

### FIXED CODE ###

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

if N == 1:
    print(1)
    exit()
    
check_list = [0] * (10**6 + 1)

cnt = 0
for i in range(len(A)):
    tmp = A[i]
    while True:
        if tmp > A[-1]:
            break
        check_list[tmp] += 1
        tmp += A[i]

for a in A:
    if check_list[a] == 1:
        cnt += 1
print(cnt)
a, b = map(str, input().split())

ans = b * 100
ans *= a
ans /= 100
print(ans//1)

### FIXED CODE ###

from decimal import Decimal, ROUND_DOWN
a, b = map(str, input().split())
a = Decimal(a)
b = Decimal(b)

print((a*b).quantize(Decimal("0"), rounding=ROUND_DOWN))
cul_list=raw_input().split()
cul_process=[]
ope_cnt=0
result=1
l=len(cul_list)
for i in range(l):
	if cul_list[i]=='+':
		cul_process.append(int(cul_list[i-2])+int(cul_list[i-1]))
		ope_cnt+=1
	elif cul_list[i]=='-':
		cul_process.append(int(cul_list[i-2])-int(cul_list[i-1]))
		ope_cnt+=1
	elif cul_list[i]=='*':
		if cul_list[i-1]=='+' or cul_list[i-1]=='-':
			for j in range(ope_cnt):
				result*=cul_process[j]
			cul_process.append(result)
			ope_cnt=0
		else:
			cul_process.append(int(cul_list[i-1]*int(cul_list[i-2])))
			ope_cnt+=1
print(cul_process[-1])

### FIXED CODE ###


Stack=[]
def push(x):
    Stack.append(x)

def pop():
    return Stack.pop()

def solve():
    s_list=raw_input().split()
    for i in range(len(s_list)):
        if s_list[i]=='+':
            b=pop()
            a=pop()
            push(a+b)
        elif s_list[i]=='-':
            b=pop()
            a=pop()
            push(a-b)
        elif s_list[i]=='*':
            b=pop()
            a=pop()
            push(a*b)
        else:
            push(int(s_list[i]))
    print(pop())

def main():
    if __name__=="__main__":
        solve()

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

A0=list(range(N))
temp=0

for i in range(N):
  temp=A[temp]
#  print(temp)

print(temp)

### FIXED CODE ###

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

A0=list(range(N))

def calc_zero(n):
    return n * 0

A0 = list(map(calc_zero, A0))

temp=0
tempv=[]

for i in range(K):
  if A0[temp]>=1:
    loop=i-A0[temp]
    t=(K-A0[temp])%loop
    temp=tempv[A0[temp]+t-1]
    break
  else:
    A0[temp]=i
    temp=A[temp]-1
    tempv.append(temp)

print(temp+1)
x = input()
y = x ** 3
print int(y)

### FIXED CODE ###

x = input()
print(int(x) ** 3)
N = int(input())
A = [map(int,input().split())]
B = [map(int,input().split())]
C = [map(int,input().split())]
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    B.append(C[A[i]-1])
print(sum(B))


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    B.append(C[A[i]-1])
print(sum(B))
import sys
n=int(input())
s=[input() for i in range(n)]
t=[2*(i.count("("))-len(i) for i in s]
if sum(t)!=0:
    print("No")
    sys.exit()
st=[[t[i]] for i in range(n)]

for i in range(n):
    now,mi=0,0
    for j in s[i]:
        if j=="(":
            now+=1
        else:
            now-=1
        mi=min(mi,now)
    st[i].append(mi)
#st.sort(reverse=True,key=lambda z:z[1])
u,v,w=list(filter(lambda x:x[1]>=0,st)),list(filter(lambda x:x[1]<0 and x[0]>=0,st)),list(filter(lambda x:x[1]<0 and x[0]<0,st))
v.sort(reverse=True)
v.sort(reverse=True,key=lambda z:z[1])
w.sort(reverse=True)
w.sort(key=lambda z:z[1])
lu=len(u)
lv=len(v)
now2=0
for i in range(n):
    if i<lu:
        now2+=u[i][0]
    elif i<lu+lv:
        if now2+v[i-lu][1]<0:
            print("No")
            break
        now2+=v[i-lu][0]
    else:
        #いや、間違ってるのここなんかーーい
        if now2+w[i-lu-lv][1]<0:
            k
            print("No")
            break
        now2+=w[i-lu-lv][0]
else:
    print("Yes")

### FIXED CODE ###

import sys
n=int(input())
s=[input() for i in range(n)]
t=[2*(i.count("("))-len(i) for i in s]
if sum(t)!=0:
    print("No")
    sys.exit()
st=[[t[i]] for i in range(n)]

for i in range(n):
    now,mi=0,0
    for j in s[i]:
        if j=="(":
            now+=1
        else:
            now-=1
        mi=min(mi,now)
    st[i].append(mi)
#st.sort(reverse=True,key=lambda z:z[1])
u,v,w=list(filter(lambda x:x[1]>=0,st)),list(filter(lambda x:x[1]<0 and x[0]>=0,st)),list(filter(lambda x:x[1]<0 and x[0]<0,st))
v.sort(reverse=True)
v.sort(reverse=True,key=lambda z:z[1])
w.sort(key=lambda z:z[0]-z[1],reverse=True)
lu=len(u)
lv=len(v)
now2=0
for i in range(n):
    if i<lu:
        now2+=u[i][0]
    elif i<lu+lv:
        if now2+v[i-lu][1]<0:
            print("No")
            break
        now2+=v[i-lu][0]
    else:
        #いや、間違ってるのここなんかーーい
        if now2+w[i-lu-lv][1]<0:
            print("No")
            break
        now2+=w[i-lu-lv][0]
else:
    print("Yes")
n=int(input())
x=input()
t=int(x,2)
c=x.count('1')
from functools import *
@lru_cache(None)
def popcount(x):
  if x==0: return 0
  return popcount(x%bin(x).count('1'))+1
for i in range(n):
  if int(x[i]):
    d=c-1
    print(popcount((t-pow(2,n-i-1,d))%d)+1)
  else:
    d=c+1
    if c<1: print(0)
    print(popcount((t+pow(2,n-i-1,d))%d)+1)

### FIXED CODE ###

n=int(input())
x=input()
t=int(x,2)
c=x.count('1')
a=t%-~c
b=0 if c<2 else t%~-c
for i in range(n):
  if int(x[i]):
    if c<2: print(0); continue
    else: t=(b-pow(2,n-i-1,c-1))%~-c
  else: t=(a+pow(2,n-i-1,c+1))%-~c
  z=1
  while t:
    d=bin(t).count('1')
    t%=d
    z+=1
  print(z)
n = int(input())

def zorome(n):
	l = []
	while n > 0:
		l.append(n%10)
		n = n//10
	return l

for i in range(n, 1000):
	ll = zorome(n)
	if ll[0] == ll[1] and ll[1] == ll[2]:
		break
	n += 1
print(n)

### FIXED CODE ###

n,m,x,y = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

xs2 = sorted(xs)
ys2 = sorted(ys)
for i in range(x+1, y+1):
	if xs2[-1] < i <= ys2[0]:
		print("No War")
		quit()
print("War")
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import math

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)/math.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(int(b-a+1-ans))

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import fractions

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)//fractions.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(b-a+1-ans)
if (R - L) // 2019 > 0:
    print(0)
elif (R - L) != (R % 2019 - L % 2019):
    print(0)
else:
    print(min(L * (L + 1) % 2019, R * (R - 1) % 2019, L * R % 2019))


### FIXED CODE ###

L, R = map(int, input().split())

if (R - L) // 2019 > 0:
    print(0)
elif (R - L) != (R % 2019 - L % 2019):
    print(0)
else:
    answer = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            tmp = i * j % 2019
            if tmp < answer:
                answer = tmp
    print(answer)
N = input()
count = 0
c = 0
for i in range(N):
    d1,d2,d3 = input().split()
    if (d1==d2)&(d2==d3):
        count+=1
        if count=3:
            c =1
            sys.exit()
    else:
        count=0
if count=1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
count = 0
c = 0
for i in range(N):
    d1,d2 = input().split()
    if d1==d2:
        count+=1
        if count==3:
            c =1

    else:
        count=0
if c==1:
    print('Yes')
else:
    print('No')
s = input()
ans = 0
for i in range(3):
  if s[i] == 'R'
  	ans += 1
  else:
    if ans == 1:
      break
print(ans)

### FIXED CODE ###

s = input()
ans = 0
for i in range(3):
  if s[i] == 'R':
  	ans += 1
  else:
    if ans == 1:
      break
print(ans)