peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N,M = map(int,input().rstrip().split(" "))
ans = [[False for _ in range(N)] for _ in range(N)]

if N % 2 == 1:
    for i in range(1,M + 1):
        print(str(i) + " " + str(N - i))
else:
    for i in range(1,min(M + 1,(N - 1) // 2)):
        print(str(i) + " " + str(N - i - 2))
    if (N - 1) // 2 == M:
        print(str(N - 2) + " " + str(N - 1))
# Judge status: Accepted
#!/usr/bin/env python3
ans = [1e9] * int(input())
for i, x in enumerate(map(int, input().split())):
    ans[i] = min(ans[i], x)
    ans[i+1] = min(ans[i+1], x)
print(sum(ans))
# Judge status: Accepted
n,k = list(map(int, input().split()))
lst = [None for i in range(n)]

for i in range(n):
    a,b = list(map(int, input().split()))
    lst[i] = (a,b)

# print(lst)
lst.sort(key=lambda x:x[0])
# print(lst)

count = 0
for i in range(n):
    count += lst[i][1]
    if count>=k:
        print(lst[i][0])
        exit()
# Judge status: Accepted
N,M=map(int,input().split())
a = [list(map(int,input().split())) for l in range(N)]
a.sort()
cost=0
for i in range(N):
    if M<=a[i][1]:
        cost+=a[i][0]*M
        break
    elif M>a[i][1]:
        M-=a[i][1]
        cost+=a[i][0]*a[i][1]
print(cost)
# Judge status: Wrong Answer
import sys
N = input()
i = 0

while N.count(str(i)) < 3:
    i += 1
    if i > 9:
        print('No')
        sys.exit()

print('Yes')
# Judge status: Accepted
# A - Poor
def main():
    A, B, C = map(int, input().split())
    is_poor = (A == B and A != C) or (A == C and A != B) or (B == C and A != B)
    print("Yes" if is_poor else "No")


if __name__ == "__main__":
    main()
# Judge status: Accepted
n,a,b = map(int,input().split())
ans = 0

for i in range(n+1):
    numsum = sum([int(x) for x in list(str(i))])
    if b>= numsum >=a:
        ans+=i

print(ans)
# Judge status: Accepted
import sys

# import bisect
# map(int, sys.stdin.read().split())
from collections import Counter



def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = []
    for i in range(N):
        s =list(input())
        s.sort()
        s = "".join(s)
        S.append(s)

    C  = Counter(S)
    ans =0
    for key,value in C.items():
        ans +=value*(value-1)/2

    print(int(ans))


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import math
N = int(input())
ans = 0
ve = math.floor(math.sqrt(N))
for st in range(ve):
    tmp = math.floor(N/(st+1)-0.000001)
    score = 2*(tmp - st)
    if score > 0:
        score -= 1
    ans += score
# Judge status: Wrong Answer
c = str, input()

if c == "a" or "e" or "i" or "o" or "u":
    print("vowel")
else:
    print("consonant")
# Judge status: Accepted
a=int(input())
a=25-a
print("Christmas ", end="")
for i in range(a):
  print("Eve ", end="")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    ans = 0
    for j in range(60):
        x = 0
        for k in range(N):
            if i == k:
                continue
            if A[k] >> j & 1:
                x += 1
        if x % 2 == 1:
            ans += 2**i
    print(ans)
# Judge status: Wrong Answer
N = input()
if "9" in N:
  ans = "YES"
else:
  ans ="NO"
print(ans)
# Judge status: Accepted
r,g,b = input().split()
print('YES' if int(r+g+b)%4==0 else 'NO')
# Judge status: Wrong Answer
class Solution:
    def calc(self, a: int) -> int:
        return a+a*a+a*a*a
# Judge status: Accepted
n, a, b = map(int, input().split())
MOD = 10**9 + 7

def combination(n, k):
    from math import factorial
    numer = 1
    for i in range(k):
        numer *= (n-i)
        numer %= MOD
    denom = factorial(k) % MOD
    return numer * pow(denom, MOD-2, MOD)

total = pow(2, n, MOD) - 1
comb_a = combination(n, a)
comb_b = combination(n, b)
print((total - comb_a - comb_b) % MOD)
# Judge status: Accepted
# solution
import io

data=input()
if data[0]=="A"and data[2:-1].count("C")==1\
and data[1:].replace("C","c",1).islower()==True:
    print("AC")
else:print("WA")
# Judge status: Accepted
import sys
from collections import Counter
import math

counts = Counter(line.strip() for line in sys.stdin)

for key in ["AC", "WA", "TLE", "RE"]:
  if key not in counts:
    print("{} x 0".format(key))
  else:
    print("{} x {}".format(key, counts[key]))
# Judge status: Accepted
N = int(input())
mod = 1000000007

ans = (10**N - 2*(9**N) + 8**N) % mod
print(ans)
# Judge status: Accepted
a, b = list(map(int, input().split()))

if a*b <= 0:
  print("Zero")
elif a > 0:
  print("Positive")
elif b < 0 and (-a-b)%2 == 1:
  print("Positive")
else:
  print("Negative")
# Judge status: Wrong Answer
s=input()
n=len(s)
cnt=0
if n%2==0:
  for aa in s[:n//2][::-1]:
    for bb in s[n//2:n]:
      if aa!=bb:
        cnt+=1
  print(cnt)
else:
  for cc in s[:(n-1)//2][::-1]:
    for dd in s[(n+1)//2:n]:
      if cc!=dd:
        cnt+=1
  print(cnt)
# Judge status: Wrong Answer
S = input()
S = sorted(S)
for i in range(97, 123):
    if S.count(chr(i)) > 0:
      continue
    else:
      print(chr(i))
      break
# Judge status: Wrong Answer
n, x, y = map(int, input().split())
count = [0 for i in range(2001)]
diff = y - x - 1
for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x and y <= j:
            count[j - i - diff] += 1
            #print(i, j, j - i - diff, "!")
        else:
            count[j - i] += 1
            #print(i, j, j - i)
for k in range(1, n):
    print(count[k])
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = 0
for j,k in zip(a,b):
  if j<k:
    cou += (k-j)//2
  elif j>k:
    cou -= (j-k)
if cou>=0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N, K = map(int, input().split())
D = set(map(str, input().split()))

for i in range(N,10**5):
    l = set(list(str(i)))
    if l & D:
        continue
    print(i)
    break
# Judge status: Accepted
s = input()

b = [True] * 26
for c in s:
    b[ord(c) - ord('a')] = False

ans = 'None'
for i in range(26):
    if b[i]:
        ans = chr(ord('a') + i)
        break
print(ans)
# Judge status: Accepted
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

A=int(input())
B=int(input())
A2=min(A,B)
B2=max(A,B)
if(A2==1 and B2==2):
    print(3)
    sys.exit(0)

if(A2==2 and B2==3):
    print(1)
    sys.exit(0)

if(A2==1 and B2==3):
    print(2)
    sys.exit(0)
# Judge status: Accepted
n, k = map(int, input().split())
s = list(input()) #文字列はそのままだとイミュータブル
s[k-1] = chr(ord(s[k-1]) + 32)
print("".join(s))
# Judge status: Accepted
from scipy.special import comb

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

o,e = 0,0
for a in A:
    if a%2==0:
        e+=1
    else:
        o+=1

if P == 0:
    # select even cnt from o
    t = 0
    for i in range(0, o+1, 2):
        t += comb(o, i, True)
    print(2**e * t)
else:
    t = 0
    for i in range(1, o+1, 2):
        t += comb(o, i, True)
    print(2**e * t)
# Judge status: Accepted
k = int(input())
lunlun = [1,2,3,4,5,6,7,8,9]
i = 0
while len(lunlun) < k:
  p = lunlun[i]
  if str(p)[-1] == '0':
    lunlun.append(p*10)
    lunlun.append(p*10+1)
  elif str(p)[-1] == '9':
    lunlun.append(p*10+8)
    lunlun.append(p*10+9)
  else:
    lunlun.append(p*10+p%10-1)
    lunlun.append(p*10+p%10)
    lunlun.append(p*10+p%10+1)
  i += 1

print(lunlun[k-1])
# Judge status: Wrong Answer
n = int(input())
s = ['' for i in range(n)]
for i in range(n):
    s[i] = sorted(input())
ss = sorted(s)

ans = 0
for i in range (n-1):
    if ss[i] == ss[i+1]:
        count = 2
        i+=1
        while i != n-1 and ss[i] == ss[i+1]:
            count+=1
            i+=1
        ans+=(count*(count-1)//2)
print(ans)
# Judge status: Wrong Answer
A,B=map(int,input().split())
if A<=9 and B<=9:
    print("A*B")
else:
    print("-1")
# Judge status: Wrong Answer
X = int(input())
ans = 0
for i in range(1,X):
    X -= i
    ans += 1
    if X <= 0: break
print(ans)
# Judge status: Wrong Answer

def resolve():
    import sys
    input = sys.stdin.readline
    S = input().rstrip()

    result = 0
    length = len(S)
    if length < 4:
        return result

    for keta in range(4, length+1):
        for i in range(length - keta + 1):
            j = i + keta
            if int(S[i:j]) % 2019 == 0:
                result += 1
    
    print(result)



if __name__ == "__main__":
    resolve()
# Judge status: Accepted
n=int(input())
for i in range(int((2*n)**0.5-3),n+2):
  if i*(i+1)//2==n:
    for j in range(1,i+1):
      print(j)
    break
  elif i*(i+1)//2>n:
    k=i*(i+1)//2-n
    for j in range(1,i+1):
      if j!=k:
        print(j)
    break
# Judge status: Accepted
N,M = map(int,input().split())
D = [[]for i in range(N)]
AC = 0
WA = 0
for i in range(M):
  plobNum,res = input().split()
  D[int(plobNum)-1].append(res)

for prob in D:
  wa_ = 0
  for submit in prob:
    if submit == "WA" :
      wa_+=1
    elif submit == "AC":
      AC+=1
      WA +=wa_
      break

print("{} {}".format(AC,WA))
# Judge status: Wrong Answer
k = int(input())

if k%2 == 0:
  print((k//2)**2)
else:
  print((k/2)*((k/2)+1))
# Judge status: Wrong Answer
n=int(input())
d={}
for i in range(n):
    s=input()
    d[i]={}
    for c in s:
        if c in d[i]:
            d[i][c]+=1
        else:
            d[i][c]=1
k={chr(i)for i in range(97,123)}
for e in d:
    k&=set(d[e].keys())
for t in k:
    m=float('inf')
    for e in d:
        m=min(m,d[e][t])
    print(t*m,end='')
print('')
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = {}
    for i, a in enumerate(A):
        B[i - a] = B.get(i - a, 0) + 1
    r = 0
    for i, a in enumerate(A):
        B[i - a] -= 1
        r += B.get(a + i, 0)
    return r

print(main())
# Judge status: Accepted
H, A = map(int, input().split())
print(H//A if H % A == 0 else H//A+1)
# Judge status: Accepted
def main():
  import itertools
  s=list(input())
  n=len(s)

  for pm in itertools.product("+-", repeat=3):
    tmp=""
    for i,j in zip(s,pm):
      tmp+=i+j
    else:
      tmp+=s[-1]
    if eval(tmp)==7:
      print(tmp+"=7")
      exit()
  
  
if __name__=="__main__":
  main()
# Judge status: Wrong Answer
from collections import deque

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

graph = [[] for _ in range(n+1)]

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

dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

d = deque()
d.append(1)

while d:
 v = d.popleft()
 for i in graph[v]:
   if dist[i] != -1:
     continue
   dist[i] = dist[v] + 1
   d.append(i)

ans = dist[2:]
if len(ans) > 0:
    print('Yes')
    print(*ans, sep="\n")
else:
    print('No')
# Judge status: Accepted
from collections import defaultdict

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

d = defaultdict(int)

m = -1

for a in A:
    d[a] += 1
    d[a+1] += 1
    d[a-1] += 1
    m = max(d[a], d[a+1], d[a-1], m)

print(m)
# Judge status: Accepted
n,m = map(int,input().split())

s1 = set()
s2 = set()
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        s1.add(b)
    elif b == 1:
        s1.add(a)
    elif a == n:
        s2.add(b)
    elif b == n:
        s2.add(a)

if s1.isdisjoint(s2):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
# Judge status: Accepted
a, b, c = map(int, input().split())
into_a = a - b
remain_c = c - into_a

if remain_c > 0:
  print(remain_c)
else:
  print(0)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
broken = 0
flag = [0, 0]
for i in range(1,N + 1):
  if flag[1] != 0:
    break
  for j in range(len(A)):
    if A[j] == i:
      if len(A) != 1:
      	A = A[j + 1:]
      else:
        A = []
        flag[0] += 1
      break
    else:
      broken += 1
    if len(A) == i + 1:
      flag[1] += 1
if broken == 0 and flag[0] != 1:
  print(-1)
else:
  print(broken)
# Judge status: Accepted
def main():
    n = int(input())
    y = [0]*(n+1)
    res = 0
    for i in range(1,n+1):
        j = 1
        while True:
            if i*j > n:
                break
            y[i*j] += 1
            j += 1
        res += i*y[i]
    print(res)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import bisect as bi

li6 = [6 ** i for i in range(7)]
li9 = [9 ** i for i in range(6)]
print(li6)
print(li9)

def s69(n):
    if n < 6:
        return n
    else:
        s6 = li6[bi.bisect(li6, n) - 1]
        s9 = li9[bi.bisect(li9, n) - 1]
        return min(n // s6 + s69(n % s6), 1 + s69(n - s9))


print(s69(int(input())))
# Judge status: Wrong Answer
a, b, t = map(int, input().split())

the_number_of_times = (t + 0.5) // a
the_number_of_biscuits = b * the_number_of_times

print(the_number_of_biscuits)
# Judge status: Accepted
N=int(input())
A=int(input())
ans=N%500
if ans-A<=0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import math
import re
#import sympy

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



war=10**9+7

a=int(input())
if a<2:
    print(0)
    exit()

print((10**a-9**a-9**a+8**a)%war)
# Judge status: Accepted
s=int(input())
m=s//3
c=10**9+7
dp=[[0]*(m+1) for i in range(s+1)]
for i in range(3,s+1):
  dp[i][1]=1
su=[0]*(m+1)

for i in range(6,s+1):
  for j in range(2,i//3+1):
    su[j-1]=(su[j-1]+dp[i-3][j-1])%c
    dp[i][j]=su[j-1]
print(sum(dp[-1])%c)
# Judge status: Accepted
n = int(input())
rs = [list(input().split()) for _ in range(n)]


new_rs = sorted(rs, key=lambda x: - int(x[1]))


def mp_count(s):
    mps = {}
    for mp, _ in s:  # 2個の変数を用意しないと、1個の変数にリストがいい感じにおさまってしまう
        if mp not in mps:
            mps[mp] = 0
    return sorted(mps)


for m in mp_count(rs):
    for r in new_rs:
        if m == r[0]:
            print(rs.index(r) + 1)
# Judge status: Accepted
a,b = map(int,input().split())

l = [str(a)*b, str(b)*a]
l.sort()
print(l[0])
# Judge status: Accepted
import collections
n = int(input())
d = list(map(int, input().split()))
mod = 998244353
f = collections.Counter(d)
# print(f)
if d[0] != 0 or f[0] != 1:  # 0は一個だけ
    print(0)
    exit()
ans = 1
box = 1  # 値自体の個数を保存
maxd = max(d)

for i in range(maxd+1):
    ans = ans*box**f[i]
    ans %= mod
    box = f[i]
print(ans)
# Judge status: Accepted
import numpy as np
N, K = list(map(int,input().split()))
a = [int(input()) for i in range(N)]
a = sorted(a, reverse = True)
ans = np.zeros(len(a)-K+1)
for i in range(len(a)-K+1):
    ans[i] = a[i]-a[i+K-1]
print(int(ans.min()))
# Judge status: Wrong Answer
n = int(input())
alist = list(map(int, input().split(" ")))
blist = list(map(bin, alist))

print(blist)
# Judge status: Accepted
import sys
h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
    sys.exit()
count_1 = (h+1) // 2
count_2 = h // 2

loop_num = w // 2
add_num = w - (loop_num * 2)
print((count_1+count_2) * loop_num + (count_1 * add_num))
# Judge status: Wrong Answer
from collections import defaultdict
s = input()
t = input()
n = len(s)
changed = defaultdict(list)
for i in range(n):
    if s[i] != t[i]:
        changed[s[i]].append(t[i])
#print(changed)
flag = True
for lis in changed.values():
    if len(set(lis)) != 1:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N,M = map(int,input().split())
print(N*(N-1)//2 + M*(M-1)//2)
# Judge status: Wrong Answer
n = int(input())
s = (n+1)*n/2
print(s)
# Judge status: Accepted
n = int(input())
ps = tuple(map(int, input().split()))
qs = tuple(map(int, input().split()))

from itertools import permutations

l = list(permutations(range(1, n+1)))

print(abs(l.index(ps) - l.index(qs)))
# Judge status: Accepted
def solve():
    s = input()
    count = 0
    for i in range(len(s)):
        for j in range(i+1, len(s)):
            if s[i] == s[j]:
                count += 1
    print('YNeos'[count!=2::2])





if __name__ == '__main__':
    solve()
# Judge status: Accepted
S=list(input())
count=0
for i in range(3):
    if S[i]==S[i+1]:
        count=1
if count==1:
    print('Bad')
else:
    print('Good')
# Judge status: Accepted
from sys import stdin, stdout
import math
import bisect
import queue

n, k = map(int, stdin.readline().strip().split())

times = n // k

ans = n - k * times
ans = min(ans,abs(n - (times + 1) * k))

stdout.writelines(str(ans))
# Judge status: Wrong Answer
a,b = map(str, input().split())
print(a+b)
# Judge status: Accepted
a, b,k = map(int, input().split())
if a>=k:
    aa=a-k
    ba=b
elif a+b>=k:
    aa=0
    ba=b-(k-a)
else:
    aa=0
    ba=0

print("{} {}".format(aa,ba))
# Judge status: Accepted
N = input()

cnt = 0
for n in N:
    cnt += int(n)
    cnt %= 9

if cnt % 9 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
h = list(map(int,input().split()))
dp = [int(1e+10) for _ in range(n)]
dp[0],dp[1] = 0,abs(h[1]-h[0])
for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])
# Judge status: Wrong Answer
import math
N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
k = 0
total = 0
for j in range(N-1):
    for i in range(j + 1, N-1):
        total += ((xy[j][0] - xy[i][0])**2 + (xy[j][1]-xy[i][1])**2)**(1/2)
    k += 1
total = total * 2
print(total/N)
# Judge status: Accepted
N = int(input())
ans = [0 for _ in range(N)]
for z in range(1, 101):
  for y in range(1, 101):
    for x in range(1, 101):
      i = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if i <= N:
        ans[i-1] += 1
        
for j in ans:
  print(j)
# Judge status: Accepted
N=int(input())
if N % 9 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a>12:
    print(b)
elif 12>=a>=6:
    print(b/2)
else:
    print(0)
# Judge status: Accepted
N = int(input())
sum=0
for i in range(1,N+1):
    if (i%3!=0)&(i%5!=0):
        sum = sum + i
print(sum)
# Judge status: Accepted
h, n = map(int, input().split())
a = list(map(int, input().split()))

if h <= sum(a):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a, b = [int(i) for i in input().split()]
i = 0
while True:
    if a * i - i + 1 >= b:
        print(i)
        break
    i += 1
# Judge status: Accepted
A, B = map(int, input().split())
print(max(A+A-1, A+B, B+B-1))
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1,1000):
  for j in range(2, 10):
    if i**j <= n:
      ans = max(ans, i**j)
print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
if a<= c <= b:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
cnt_s = 0
cnt_b = 0

for i in range(n):
    if cnt_s <= a+b:
        print('Yes')
        cnt_s += 1
    elif cnt_s > a+b:
        print('No')
    elif cnt_s <= a+b and cnt_b <= b:
        print('Yes')
        cnt_b += 1
        cnt_s += 1
    else:
        print('No')
# Judge status: Wrong Answer
N = int(input())
A = [int(input()) for _ in range(N)]
a = sorted(set(A))
max_count = A.count(a[-1])
for i in range(N):
  if len(a) > 1:
    if A[i] != a[-1]:
      print(a[-1])
    else:
      if max_count < 1:
        print(a[-1])
      else:
        print(a[-2])
  else:
    print(a[-1])
# Judge status: Accepted
l = []
n = int(input())
r = 0
for i in [1 if x == 'R' else 0 for x in list(input())]:
    r += i
    l.append(r)

c = r - l[r-1]
print(c)
# Judge status: Accepted
N = int(input())

ans = 0
for i in range(N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)
# Judge status: Accepted
n = int(input())
c = 0
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        c += 1
    else:
        c = 0
    if c == 3:
        break
if c == 3:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(0, a+1):
    for j in range(0, b+1):
        for k in range(0, c+1):
            print(i,j,k)
            if i*500 + j*100 + k*50 == x:
                count += 1

print(count)
# Judge status: Accepted
L1 = list(map(int, input().split()))
L2 = list(map(int, input().split()))
L3 = list(map(int, input().split()))
L = L1 + L2 + L3
N = int(input())
A = [0]*9
for _ in range(N):
  i = int(input())
  if i in L:
    A[L.index(i)] = 1
if sum(A[:3])==3 or sum(A[3:6])==3 or sum(A[6:])==3:
  print('Yes')
elif A[0]+A[3]+A[6]==3 or A[1]+A[4]+A[7]==3 or A[2]+A[5]+A[8]==3:
  print('Yes')
elif A[0]+A[4]+A[8]==3 or A[2]+A[4]+A[6]==3:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a = list(map(int,input().split()))
x = a[0]
y = a[1]

n = a[0]
count = 0

while n <= y:
  n = n << 1
  count += 1
  
print(str(count))
# Judge status: Accepted
N=int(input())
p=1
for i in range(N):
  p*=(i+1)
  p=p%(10**9+7)
print(p)
# Judge status: Accepted
N=int(input())
l = input()
count0 = l[1:].count("E")
count=count0
mi=count0
for i in range(1, N):
    if l[i-1]=="W":
        count+=1
    if l[i]=="E":
        count-=1
    mi=min(mi,count)
print(mi)
# Judge status: Wrong Answer
n=int(input())
ans=10e5
for a in range(2,n//2+1):
    b=n-a
    ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


# Imperative solution
res = 0
rem = 0

for i in range(N):
    B[i] += rem
    mobs = min(A[i], B[i])
    rem = B[i] - mobs
    res += mobs

res += min(A[N], rem)
print(res)
# Judge status: Accepted
x,a,b=map(int,input().split())

flg=0
if b<a:
	b,a=a,b
	flg=1

ans = ["A","B"]

if 2*x<b+a:
	print(ans[flg])
else:
	print(ans[-1+flg])
# Judge status: Accepted
# -*- coding: utf-8 -*-
import math

a, b, h, m = (int(x) for x in input().split())

if h == 0: #1時まで
    angle = math.radians(5.5*m)
else:
    angle = math.radians(h*30-5.5*m)

x = math.sqrt(a**2+b**2-2*a*b*math.cos(angle))

print(x)
# Judge status: Wrong Answer
a=int(input())

 
print(a+1**2+a**3)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

sorted_a = sorted(a)
a_max = sorted_a[-1]

dif = []
for i,ai in enumerate(sorted_a[:n-1]):
    dif.append((i,abs(ai-(a_max/2))))

min_i = sorted(dif, key=lambda x:x[1])[0][0]
dif_min = sorted_a[min_i]

print(a_max, dif_min)
# Judge status: Accepted
n, p = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0] * 2 for _ in range(n + 1)]
dp[0][0] = 1

for i, e in enumerate(a, 1):
    for j in range(2):
        r = e % 2
        dp[i][j] = dp[i-1][j] + dp[i-1][(j-r)%2]

print(dp[n][p])
# Judge status: Accepted
from math import ceil
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(1)
print(min(ceil(a/(K-1))+ceil((N-1-a)/(K-1)),ceil((N-1)/(K-1))))
# Judge status: Accepted
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

S = input()
N = len(S)

l = S[:N//2]
r = S[N//2 + 1:]

if S == S[::-1] and l == l[::-1] and r == r[::-1]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = []
ans.append(min(A)+min(B))


for i in range(m):
    M = list(map(int,input().split()))
    tmp = A[M[0]-1] + B[M[1]-1] -M[2]
    ans.append(tmp)

print(min(ans))
# Judge status: Wrong Answer
n = int(input())
n0 = int(n/1.08)

while int(n0 * 1.08) < n:
    n0 += 1

if int(n0 * 1.08) == n:
    print(int(n0 * 1.08))
else:
    print(':(')
# Judge status: Wrong Answer
N = int(input())
S = input()
ans, gap = S.count('R') * S.count('G') * S.count('B'), 1
while gap * 2 + 1 < N:
    ans -= sum([1 for i in range(N - gap * 2)
                if {'R', 'G', 'B'} == {S[i], S[i + gap], S[i + 2 * gap]}])
    gap += 1
print(ans)