Harryxun/stf_run huggingface dataset:
fin=open('in','r')
input=lambda:fin.readline().strip()

p=int(input())
fact=[0]*p
inv=[0]*p
def f(x,m=p-2):
	ans=1
	while m:
		if m&1:ans=ans*x%p
		x=x*x%p
		m>>=1
	return ans
fact[0]=inv[0]=1
for i in range(1,p):
	fact[i]=fact[i-1]*i%p
	inv[i]=inv[i-1]*f(i)%p
r=list(map(int,input().split()))
c=[i for i in range(p) if r[i] == 1]
#sum of -((x-j)^(p-1)-1)
# (-j + x)^(p-1) = sum((-j)^i * x^(p-1-i) * binom(p-1,i))
coeff=[0]*p
for j in c:
	for i in range(p-1,-1,-1):
		if i&1:coeff[p-1-i]-=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p
		else:coeff[p-1-i]+=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p
	coeff[0]-=1
	coeff=[((-t)%p+p)%p for t in coeff]
print(*coeff)

### FIXED CODE ###

#fin=open('in','r')
#input=lambda:fin.readline().strip()

p=int(input())
fact=[0]*p
inv=[0]*p
def f(x,m=p-2):
	ans=1
	while m:
		if m&1:ans=ans*x%p
		x=x*x%p
		m>>=1
	return ans
fact[0]=inv[0]=1
for i in range(1,p):
	fact[i]=fact[i-1]*i%p
	inv[i]=inv[i-1]*f(i)%p
r=list(map(int,input().split()))
c=[i for i in range(p) if r[i] == 1]
#sum of -((x-j)^(p-1)-1)
# (-j + x)^(p-1) = sum((-j)^i * x^(p-1-i) * binom(p-1,i))
coeff=[0]*p
for j in c:
	for i in range(p-1,-1,-1):
		if i&1:coeff[p-1-i]+=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p
		else:coeff[p-1-i]-=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p
	coeff[0]+=1
coeff=[(t%p+p)%p for t in coeff]
print(*coeff)
input_s = int(input())
h = s / 3600
rest_s = s % 3600
m = rest_s / 60
s = rest_s % 60
print('{}:{}:{}'.format(h, m, s))



### FIXED CODE ###

input_s = int(input())
h = input_s // 3600
rest_s = input_s % 3600
m = rest_s // 60
s = rest_s % 60
print('{}:{}:{}'.format(h, m, s))
# D - Cake 123

import heapq
import itertools

x, y, z, k = map(int,input().split())

if x*y*z<3000:
    a = list(int(x) for x in input().split())
    b = list(int(x) for x in input().split())
    c = list(int(x) for x in input().split())

    anslist = []
    ip = list(itertools.product(a, b, c))   
    for i in range(len(ip)):
        heapq.heappush(anslist, sum(ip[i])*-1)

    for i in range(k):
        print(heapq.heappop(anslist)*-1)

else:
    a = list(int(x)*-1 for x in input().split())
    b = list(int(x)*-1 for x in input().split())
    c = list(int(x)*-1 for x in input().split())
    inf = 10**18

    heapq.heapify(a)
    heapq.heapify(b)
    heapq.heapify(c)

    la = [inf]
    lb = [inf]
    lc = [inf]

    while len(la)*len(lb)*len(lc)<3000:
        if a[0]<=b[0]<=c[0]:
            tmp = heapq.heappop(a)
            heapq.heappush(a, inf)
            la.append(tmp*-1)
        elif a[0]>b[0]<=c[0]:
            tmp = heapq.heappop(b)
            heapq.heappush(b, inf)
            lb.append(tmp*-1)
        else:
            tmp = heapq.heappop(b)
            heapq.heappush(c, inf)
            lc.append(tmp*-1)

    anslist = []
    ip = list(itertools.product(la, lb, lc))   
    for i in range(len(ip)):
        heapq.heappush(anslist, sum(ip[i])*-1)

    for i in range(k):
        print(heapq.heappop(anslist)*-1)

### FIXED CODE ###

# D - Cake 123

import heapq
import itertools

x, y, z, k = map(int, input().split())

A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
C = list(int(c) for c in input().split())

hq = []
for i, j in itertools.product(A, B):
    heapq.heappush(hq, (i+j)*-1)

AB = []
while len(hq)>0 and len(AB)<=k:
    AB.append(heapq.heappop(hq)*-1)

hq = []
for i, j in itertools.product(AB, C):
    heapq.heappush(hq, (i+j)*-1)

for _ in range(k):
    print(heapq.heappop(hq)*-1)
s=input()
ans=0
for moji in s:
  if mojl == '2':
    ans += 1
    
print(ans)


### FIXED CODE ###

s=input()
ans=0
for moji in s:
  if moji == '2':
    ans += 1
    
print(ans)
l,r = map(int,input().split())
x = []
for i in range(l,r-1):
  for j in range(i+1,r):
    res = (i*j)%2019
    x.append(res)
xs = sorted(x)
print(x[1])

### FIXED CODE ###

l,r = map(int,input().split())
x = []
if r-l>2019:
  print(0)
else:
  for i in range(l,r):
    for j in range(i+1,r+1):
      res = (i*j)%2019
      x.append(res)
  print(min(x))
a=input("")
b='Sunny'
c='Cloudy'
d='Rainy'
if a=b:
print(c)
elif a=c:
print(d)
else:
print(b)


### FIXED CODE ###

a = input()
b = 'Sunny'
c = 'Cloudy'
d = 'Rainy'
if a == b:
 print(c)
if a == c:
 print(d)
if a == d:
 print(b)
num_n = raw_input()
ele_n = raw_input()
num_m = raw_input()
ele_m = raw_input()
   
n = int(ele_n.split())
m = int(ele_m.split())
  
def solve(i, t):
   if t == 0:
      return True
   if i >= num_n or t > sum(n):
      return False
   res = solve(i + 1, t) or solve(i + 1,t - n[i])
   return res
  
for t in m:
   if solve(0, t):
      print "yes"
   else:
      print "no"

### FIXED CODE ###

_ = int(input())
hoge = [int(x) for x in input().split()]
_ = int(input())

def exSearch(i, m):
    if m == 0:
        return True
    if i >= len(hoge) or m > sum(hoge):
        return False
    res = exSearch(i+1, m) or exSearch(i+1, m-hoge[i])
    return res

if __name__ == '__main__':
    
    for val in (int(x) for x in input().split()):
        if exSearch(0, val):
            print ('yes')
        else:
            print ('no')
#input
h, w = list(map(int, input().split()))

c = [0 for i in range(10)]
for i in range(10):
    c[i] = list(map(int, input().split()))

wall = [0 for i in range(w)]

for i in range(h):
    wall[i] = list(map(int, input().split()))

#solve
#1へのコスト
costone = [(10**3) + 1 for i in range(11)]
#-1, 1はコストがかからないため０で初期化
costone[1] = 0
#-1の処理
costone[10] = 0
#ワーシャルフロイド法を使う
#iは出発、jは経由,
for i in range(10):
    for j in range(10):
        for k in range(10):
            c[i][k] = min(c[i][k], c[i][j] + c[j][k])
#costoneを更新
for i in range(10):
    costone[i] = min(costone[i], c[i][1])
sum = 0
for i in range(h):
    for j in range(w):
        sum += costone[wall[i][j]]
print(sum)


### FIXED CODE ###

from scipy.sparse.csgraph import floyd_warshall

#input
h, w = list(map(int, input().split()))

c = [0 for i in range(10)]
for i in range(10):
    c[i] = list(map(int, input().split()))

wall = []

for i in range(h):
    wall.append(list(map(int, input().split())))

#solve
#1へのコスト
costone = [(10**3) + 1 for i in range(11)]
#-1, 1はコストがかからないため０で初期化
costone[1] = 0
#-1の処理
costone[10] = 0
#ワーシャルフロイド法を使う
#iは出発、jは経由,
c = floyd_warshall(c)
##for i in range(10):
##    for j in range(10):
##        for k in range(10):
##            c[i][k] = min(c[i][k], c[i][j] + c[j][k])
#costoneを更新
for i in range(10):
    costone[i] = min(costone[i], c[i][1])
sum = 0


for i in range(h):
    for j in range(w):
        sum += costone[wall[i][j]]
print(int(sum))
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h,w=map(int,input().split())
    for i in range(h):
        s=[_ for _ in input().split()]
        for j in range(w):
            if s[j]=="snuke":
                print(chr(ord('A')+j)+str(i+1))
                sys.exit()

if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    if s in ["KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA","AKIHABR","AKIHBAR","AKIHBRA","KIHABAR","KIHABRA","KIHBARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA","AKIHABARA"]:
        print("YES")
    else:print("NO")

if __name__=='__main__':
    main()
def bfs(b):
    mem=[[False for i in range(n)]for j in range(2)]
    st=[0,0]
    for i in range(2):
        while b[i][st[i]+1]==1:
            st[i]+=1
    mem[0][st[0]]=True
    mem[1][st[1]]=True
    que=[[0,0,0],[1,0,0]]
    while len(que)!=0:
        d=que.pop(0)
        des=(d[0]+1)%2
        cst=d[2]+1
        for i in range(3):
            fl=d[1]+i
            if fl>n:break
            state=b[des][fl]
            if state!=2 and fl==n-1:
                return cst
            if state==0:
                if mem[des][fl]==False:
                    que.append([des,fl,cst])
                    mem[des][fl]=True
            elif state==1:
                k=1
                while True:
                    if fl+k>=n:return cst
                    if b[des][fl+k]!=1:
                        if mem[des][fl+k-1]==False:
                            que.append([des,fl+k-1,cst])
                            mem[des][fl+k-1]=True
                        break
                    else: k+=1

            elif state==2:
                k=1
                while True:
                    if b[des][fl-k]!=2:
                        if mem[des][fl-k]==False:
                            que.append([des,fl-k,cst])
                            mem[des][fl-k]=True
                        break
                    else:k+=1  
    return 0
while True:
    n=int(input())
    if n==0:break
    b=[[int(p)for p in input().split(" ")],[int(p)for p in input().split(" ")]]
    count=bfs(b)
    print(str(count)if count!=0 else "NA")

### FIXED CODE ###

def bfs(b):
    mem=[[False for i in range(n)]for j in range(2)]
    st=[0,0]
    for i in range(2):
        if b[i][0]!=1:continue
        while st[i]<n-1 and b[i][st[i]+1]==1:
            st[i]+=1
        if st[i]==n-1:return 0
    mem[0][st[0]]=True
    mem[1][st[1]]=True
    que=[[0,st[0],0],[1,st[1],0]]
    while len(que)!=0:
        d=que.pop(0)
        des=(d[0]+1)%2
        cst=d[2]+1
        for i in range(3):
            fl=d[1]+i
            if fl>=n:break
            state=b[des][fl]
            if state!=2 and fl==n-1:
                return cst
            if state==0:
                if mem[des][fl]==False:
                    que.append([des,fl,cst])
                    mem[des][fl]=True
            elif state==1:
                k=1
                while True:
                    if fl+k>=n:return cst
                    if b[des][fl+k]!=1:
                        if mem[des][fl+k-1]==False:
                            que.append([des,fl+k-1,cst])
                            mem[des][fl+k-1]=True
                        break
                    else: k+=1

            elif state==2:
                k=1
                while True:
                    if b[des][fl-k]!=2:
                        if mem[des][fl-k]==False:
                            que.append([des,fl-k,cst])
                            mem[des][fl-k]=True
                        break
                    else:k+=1  
    return -1
while True:
    n=int(input())
    if n==0:break
    b=[[int(p)for p in input().split(" ")],[int(p)for p in input().split(" ")]]
    count=bfs(b)
    print(str(count)if count>=0 else "NA")
a,b,c = map(int, input().split(" "))
cnt = 0
for i in range(a,b+1)
 if c%i == 0 : cnt += 1
print(cnt)
  

### FIXED CODE ###

a,b,c = map(int, input().split())
cnt = 0
for i in range(a,b+1):
 if c%i == 0 : cnt += 1
print(cnt)
x,y = map(int, input().split())

ans = abs(abs(x)-abs(y))
if x > y and abs(x) != abs(y) and x*y > 0:
	ans+=2
elif x*y < 0 or (x>y and x==0) or (x>y and y==0):
	ans+=1a

print(ans)


### FIXED CODE ###

x,y = map(int, input().split())

ans = abs(abs(x)-abs(y))
if x > y and abs(x) != abs(y) and x*y > 0:
	ans+=2
elif x*y < 0 or (x>y and x==0) or (x>y and y==0):
	ans+=1

print(ans)
N = int(input())
A = list(map(int, input().split()))
C = sum(A)
D = [0]*(10**5)
for n in range(N):
    D[A[n]] += 1
Q = int(input())
Z = []
for q in range(Q):
    x, y = map(int, input().split())
    if D[x]:
        C = C - x*D[x]
        C = C + y*D[x]
        Z.append(C)
        if D[y]:
            D[y] += 1*D[x]
        else:
            D[y] = D[x]
        D[x] = 0
    else:
        Z.append(C)
for z in Z:
    print(z)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = [0]*(N+1)
for n in range(N):
    B[n+1] = B[n] + A[n]
C = B.pop()

Z = {}
for n in range(N):
    Z[A[n]] = 0
for n in range(N):
    Z[A[n]] += 1

D = []
Q = int(input())
for q in range(Q):
    x, y = map(int, input().split())
    if x in Z:
        C = C - x*Z[x]
        C = C + y*Z[x]
        D.append(C)
        if x == y:
            continue
        if y in Z:
            Z[y] += 1*Z[x]
        else:
            Z[y] = Z[x]
        Z.pop(x)
    else:
        D.append(C)
for d in D:
    print(d)
class unionFind():
	def __init__(self,n):
		self.tree=[-1]*n
	def find(self, x):
        if self.tree[x] < 0:
            return x
        else:
            #self.tree[x] = self.find(self.id[x])
            return self.find(self.id[x])
	def union(self,x,y):
		xr=self.find(x)
		yr=self.find(y)
		if xr!=yr:
			if self.tree[xr]<self.tree[yr]:
				self.tree[yr]=xr
			elif self.tree[xr]>self.tree[yr]:
				self.tree[xr]=yr
			else:
				self.tree[xr]-=1
				self.tree[yr]=xr
			return True
		
		return False
def main():
	ans=0
	n,m=map(int,input().split())
	a=unionFind(n)
	li=[x-1 for x in list(map(int,input().split()))]
	for _ in range(m):
		x,y=map(int,input().split())
		a.union(x-1,y-1)
	for x in range(n):
		ans += a.find(x)==a.find(li[x])
	return ans
print(main())



### FIXED CODE ###

from collections import defaultdict
import sys
sdin = sys.stdin.readline

class UnionFind:
    def __init__(self, node:int) -> None:
        self.n = node
        self.par = [i for i in range(self.n)]
        self.rank = [0 for i in range(self.n)]
        
    def find(self, x:int) -> int:
        if x == self.par[x]:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def unite(self, x:int, y:int) -> bool:
        if self.isSame(x,y):
            #print("x and y has already united")
            return False
        
        rx = self.find(x)
        ry = self.find(y)
        
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
        else:
            self.par[ry] = rx
            
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
                
        return True
    
    def isSame(self, x:int, y:int) -> bool:
        return self.find(x) == self.find(y)

    

        
N, M = map(int, sdin().split())
P = list(map(int, sdin().split()))
XY = []
for i in range(M):
    XY.append(list(map(int, sdin().split())))


root_node = defaultdict(list)

uf = UnionFind(N)
for x,y in XY:
    x -= 1
    y -= 1
    uf.unite(x,y)

for i in range(N):
    uf.find(i)
    
par = uf.par

for i,root in enumerate(par):
    root_node[root].append(i)
    
ans = 0
for node_list in root_node.values():
    num_list = []
    for i in node_list:
        num_list.append(P[i]-1)
    
    ans += len(set(node_list)&set(num_list))
            
print(ans)
n, a, b = [int(i) for i in input().split()]
x = (n // (a + b)) + 1
balls = [*["b"] * a, *["r"] * b] * x
ans = 0
for i in range(n):
    if balls[i] == "b":
        ans += 1
print(ans)


### FIXED CODE ###

n, a, b = [int(i) for i in input().split()]
ans = (n // (a + b)) * a
rem = n % (a + b)
ans += min(rem, a)
print(ans)
import string
count = {x: 0 for x in string.ascii_lowercase}

s = input()
s.lower()

for c in s:
    if 'a' <= c <= 'z':
        count[c] += 1

for key, num in count:
    print("{0} : {1}".format(key, num))

### FIXED CODE ###

a = [chr(i) for i in range(97, 123)]
line = ''
while True:
    try:
        line += input().lower()
    except:
        break
for c in a:
    print("{0} : {1}".format(c, line.count(c)))
n = int(input())
s = input()
cnt = 0
for i in range(n):
    if(s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C"):
        cnt +=1
print(cnt)                

### FIXED CODE ###

n = int(input())
s = input()
cnt = 0
for i in range(n-2):
    if(s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C"):
        cnt +=1
print(cnt)
S = input()
if S = 'Sunny':
  print('Cloudy')
elif S = 'Cloudy':
  print('Rainy')
else:
  print('Sunny')


### FIXED CODE ###

S = input()
if S =='Sunny':
  print('Cloudy')
elif S == 'Cloudy':
  print('Rainy')
else:
  print('Sunny')
import random

n = int(input())
m = []
for i in range(n):
    m.append(input())  

# l = list(range(n-1))
ll = []
for j in range(n):
    ll.append(m[random.randrange(n-1)])
print(len(set(ll)))

### FIXED CODE ###

import random

n = int(input())
m = []
for i in range(n):
    m.append(input())  

# ll = []
# for j in range(n):
#     ll.append(m[random.randrange(n)])
print(len(set(m)))
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007

    N, M = mi()
    A = iif(M)
    DA = []
    left = 0
    for i in range(M):
        da = A[i] - left
        if da == 0 and left != 0:
            print(0)
            return
        else:
            DA.append(da-1)
        left = A[i] + 1
    if A[-1] != N:
        DA.append(N - A[-1] - 1)

    F = [1, 1]
    for i in range(100000):
        F.append(F[i] + F[i+1])

    ans = 1
    for i in DA:
        ans *= F[i]

    print(ans % mod)

    return

main()


### FIXED CODE ###

import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007

    F = [1, 1]
    for i in range(100000):
        F.append(F[i] + F[i+1])

    N, M = mi()

    if M == 0:
        print(F[N] % mod)
        return

    A = iif(M)
    DA = []
    left = 0
    for i in range(M):
        da = A[i] - left
        if da == 0 and left != 0:
            print(0)
            return
        else:
            DA.append(da-1)
        left = A[i] + 1
    if A[-1] != N:
        DA.append(N - A[-1] - 1)


    ans = 1
    for i in DA:
        ans *= F[i]

    print(ans % mod)

    return

main()
n, m = map(int, input().split())
l = []
cnt = 0
for i in range (m):
    a, b = map(int, input().split()) 
    if (a in l) or (b in l):
        l.append(a)
        l.append(b)
        
    else:
        l.append(a)
        l.append(b)
        cnt += 1
        
    l =list(set(l))

l = set(l)
x = n - len(l) 

print(cnt+x-1)  

### FIXED CODE ###

k = int(input())
print('ACL'*k)
A, B = map(int, raw_input().split())

if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')

### FIXED CODE ###

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

if a > 8 or b > 8:
  print(':(')
else:
  print('Yay!')
s = (input())
#a,b = map(int,input().split())
n = len(s)
b = n//2
s1 = s[0:b]
s2 = s[b+1:]
#print(s1,s2)
for i in range(len(s1)//2):
    if s1[i] == s1[-i-1]:
        flag1 = True
    else:
        flag1 = False
        break
for i in range(len(s2)//2):
    if s2[i] == s2[-i-1]:
        flag2 = True
    else:
        flag2 = False
        break
if flag1 and flag2:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = (input())
#a,b = map(int,input().split())
n = len(s)
b = n//2
s1 = s[0:b]
s2 = s[b+1:]
#print(s1,s2)
if n == 3:
    if s[0] == s[-1]:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
        
flag1 = True
for i in range(len(s1)//2):
    if s1[i] == s1[-i-1]:
        flag1 = True
    else:
        flag1 = False
        break

if flag1 and (s1 == s2):
    print("Yes")
else:
    print("No")
import numpy as np
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()
a = np.ndarray(a)
def update(a):
    b = np.zeros((n, n))
    for i in range(n):
        b[i, max(0, i-int(a[i])):min(n, i+int(a[i])+1)] = 1
    return np.sum(b, axis=0)
end = np.fill(n, n)

for i in range(k):
    if np.all(a == end):
        break
    a = update(a)
for i in range(n):
    print(str(int(a[i]))+" ",end = "" )

### FIXED CODE ###

import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()


end = [n]*n

for i in range(min(k, 41)):
    b = [0]*(n+1)
    for j in range(n):
        b[max(j-a[j], 0)] +=1
        if j+a[j] <n:
            b[j+a[j]+1] -=1
    for j in range(1,n):
        b[j] += b[j-1]
    a = b[:n]

for i in range(n):
    print(str(int(a[i]))+" ",end = "" )
print(chr(ord(input()) + 1))

### FIXED CODE ###

a = input()

print(chr(ord(a) + 1))
h,w,m,*t = map(int,open(0).read().split())
a = [[0]*w for _ in range(h)]
ht = [0]*h
wt = [0]*w
for i in range(m):
  y,x = t[i*2]-1,t[i*2+1]-1
  a[y][x] += 1
  ht[y] += 1
  wt[x] += 1
htm = max(ht)
wtm = max(wt)
htt = [i for i in range(h) if ht[i]==htm]
wtt = [i for i in range(w) if wt[i]==wtm]
ans = htm+wtm-1
for i in htt:
  for j in wtt:
    if a[i][j] == 0:
      print(ans + 1)
      exit()
print(ans)

### FIXED CODE ###

h,w,m = map(int,input().split())
t = [tuple(map(lambda x:int(x)-1,input().split())) for _ in range(m)] 
ht = [0]*h
wt = [0]*w
for y,x in t:
  ht[y] += 1
  wt[x] += 1
htm = max(ht)
wtm = max(wt)
htt = [i for i in range(h) if ht[i]==htm]
wtt = [i for i in range(w) if wt[i]==wtm]
ans = htm+wtm-1
t = set(t)
for i in htt:
  for j in wtt:
    if (i,j) not in t:
      print(htm+wtm)
      exit()
print(htm+wtm-1)
[a,b] = int(input()).split
c = a*b
d = a*2 + b*2
print(c d)

### FIXED CODE ###

a,b = [int(x) for x in input().split()]
print(a*b,(a+b)*2)
n,k = map(int,input().split())

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

h.sort()
sumh = 0
for i in range(1,k+1):
    sumh += h[i*-1]
print(sum(h)-sumh)


### FIXED CODE ###

n,k = map(int,input().split())

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

h.sort(reverse=True)

if k == 0 :
    print(sum(h))
elif k <= n :
    for i in range(k):
        h[i] = 0
    print(sum(h))
else :
    print(0)
int a,b
if a*b/2 %= 0:
	print("Even")
else:
	print("Odd")

### FIXED CODE ###

a,b = map(int,input().split())
c = a*b
if c % 2 ==0:
  print("Even")
else:
  print("Odd")
#copy code
from fractions import gcd
n=int(input())
a=[int(i) for i in input().split()]
c=a[0]
for i in a:
    c=gcd(c,a)
print(c)


### FIXED CODE ###


n=int(input())
a=[int(i) for i in input().split()]
c=a[0]
def gcd(x,y):
    while y:
        x,y=y,x%y
    return x

for i in a:
    c=gcd(c,i)
print(c)
def main():
    n, q = split_and_to_int(input().strip())
    s = input().strip()

    res = ""
    for _ in range(q):
        l, r = split_and_to_int(input())
        n = 0
        for i in range(l-1, r-1):
            if s[i] == 'A' and s[i+1] == 'C':
                n += 1
                i += 1
        res += f"{n}\n"

    print(res)


def split_and_to_int(s):
    return [int(i) for i in s.split()]


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, q = map(int, input().split())
    s = input()

    # 累積出現数を格納: 指定される番号が1始まりなのでズラして格納
    p = [0] * (n+1)
    for i in range(n):
        p[i+1] = p[i] + (1 if s[i:i+2] == "AC" else 0)

    for i in range(q):
        l, r = map(int, input().split())
        # 終端(=l-1)から始端-1(=r-1)の累積出現数を引いた数が指定区間内での出現回数
        print(p[r-1] - p[l-1])


if __name__ == '__main__':
    main()
S = input()
N = int(input())
fN = sum([int(S[i]) for i in range(len(S))])
if N%fN == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

S = input()
N = int(S)
fN = sum([int(si) for si in S])
if N%fN == 0:
  print('Yes')
else:
  print('No')