Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from copy import deepcopy
def main():
    s=input()
    x,y=map(int,input().split())
    a=[0]*8000
    b=[0]*8000
    tmp=0
    T=True
    asize=0
    bsize=0
    for i in s:
        if i=="T":
            tmp=1-tmp
            T=True
        elif tmp==0:
            if T:
                asize+=1
                T=False
            a[asize-1]+=1
        else:
            if T:
                bsize+=1
                T=False
            b[bsize-1]+=1
    c={0}
    for i in range(asize):
        d=set()
        if i==0:
            if s[0]=="T":
                d.add(-a[i])
            d.add(a[i])
        else:
            for j in c:
                d.add(j+a[i])
                d.add(j-a[i])
        c=deepcopy(d)
    if not x in c:
        print("No")
        quit()
    c={0}
    for i in range(bsize):
        d=set()
        for j in c:
            d.add(j+b[i])
            d.add(j-b[i])
        c=deepcopy(d)
    if not y in c:
        print("No")
        quit()
    print("Yes")
if __name__=="__main__":
    main()


### FIXED CODE ###

s=input()
x,y=map(int,input().split())
a=[0]*8000
b=[0]*8000
tmp=0
T=True
asize=0
bsize=0
for i in s:
    if i=="T":
        tmp=1-tmp
        T=True
    elif tmp==0:
        if T:
            asize+=1
            T=False
        a[asize-1]+=1
    else:
        if T:
            bsize+=1
            T=False
        b[bsize-1]+=1
c={0}
for i in range(asize):
    d=set()
    if i==0:
        if s[0]=="T":
            d.add(-a[i])
        d.add(a[i])
    else:
        for j in c:
            d.add(j+a[i])
            d.add(j-a[i])
    c=d
if not x in c:
    print("No")
    quit()
c={0}
for i in range(bsize):
    d=set()
    for j in c:
        d.add(j+b[i])
        d.add(j-b[i])
    c=d
if not y in c:
    print("No")
    quit()
print("Yes")
### BUGGY CODE ###

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

for _ in range(k):
    r = [0]*(n+1)
    for i in range(n):
        r[max(i-a[i],0)] += 1
        r[min(i+a[i]+1,n)] -= 1
    for i in range(n-1):
        r[i+1] += r[i]
    a = r
    if a.count(n)==n:
        break
print(*a[:-1])


### FIXED CODE ###

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

for _ in range(k):
    r = [0]*(n+1)
    for i in range(n):
        r[max(i-a[i],0)] += 1
        r[min(i+a[i]+1,n)] -= 1
    for i in range(n-1):
        r[i+1] += r[i]
    a = r
    if a.count(n)==n:
        break
print(*a[:-1])
### BUGGY CODE ###

N = int(input())
count = 0
List = list(map(int, input().split()))
for i in range(N-2):
  for j in range(N-i-2):
    for k in range(N-i-j-2):
      a = List[i]
      b = List[i+j+1]
      c = List[i+j+k+2]
      if a+b>c and a+c>b and b+c>a:
        count += 1
print(count)

### FIXED CODE ###

import bisect
N = int(input())
count = 0
List = sorted(list(map(int, input().split())))
for i in range(N-2):
  for j in range(N-i-2):
    a = List[i]
    b = List[i+j+1]
    index = bisect.bisect_left(List, a+b)
    count += index-i-j-2
print(count)
### BUGGY CODE ###

N, W = map(int, input().split())
items = [[0, 0]]
v_max = 0
for _ in range(N):
    w, v = map(int, input().split())
    items.append([w, v])
    v_max = max(v_max, v)

dp = [[float("inf") for _ in range(N * v_max + 1)] for _ in range(N + 1)]

for i in range(N + 1):
    dp[i][0] = 0

ans = 0
for i in range(1, N + 1):
    for j in range(N * v_max + 1):
        if j - items[i][1] >= 0:
            dp[i][j] = min(dp[i - 1][j - items[i][1]] + items[i][0], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

        if i == N and dp[i][j] <= W:
            ans = max(ans, j)

print(ans)

### FIXED CODE ###

N, W = map(int, input().split())
items = [[0, 0]]
v_total = 0
for _ in range(N):
    w, v = map(int, input().split())
    items.append([w, v])
    v_total += v

dp = [[float("inf")] * (v_total + 1) for _ in range(N + 1)]

for i in range(N + 1):
    dp[i][0] = 0

ans = 0
for i in range(1, N + 1):
    for j in range(v_total + 1):
        if j - items[i][1] >= 0:
            dp[i][j] = min(dp[i - 1][j - items[i][1]] + items[i][0], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

        if i == N and dp[i][j] <= W:
            ans = max(ans, j)

print(ans)
### BUGGY CODE ###

n = int(input())
s = str(input())
r = []
g = []
b = []
for i in range(n):
    if s[i] == "R":
        r.append(i)
    elif s[i] == "G":
        g.append(i)
    else:
        b.append(i)
p = 0
for j in r:
    for k in g:
        for l in b:
            ls = [j,k,l]
            ls.sort()
            (a,c,d) = (ls[0],ls[1],ls[2])
            if (c-a) != (d-c):
                p += 1
print(p)

### FIXED CODE ###

n = int(input())
s = str(input())
r = 0
g = 0
b = 0
for i in range(n):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    else:
        b += 1
p = r*g*b
for i in range(n-2):
    for j in range(int(n/2)+1):
        if i + 2*j >n-1:
            break
        if s[i] != s[i+j] and s[i] != s[i+2*j] and s[i+2*j] != s[i+j]:
            p -= 1
print(p)
### BUGGY CODE ###


N = int(input())
arg = list(map(int, input().split()))


for n in range(N):
   print(len(list(filter(lambda x: x == n + 1, arg))))



### FIXED CODE ###

from collections import defaultdict, Counter

N = int(input())
arg = list(map(int, input().split()))

D = Counter(arg)

for n in range(N):
	print(D[n+1])
### BUGGY CODE ###

from fractions import gcd
def init(init_val,n):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def segfunc(x,y):
    if x*y == 0:
        return max([x,y])
    return gcd(x,y)

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res
N = int(input())
a = list(map(int,input().split()))
#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(N-1).bit_length()
seg=[ide_ele]*2*num

init(a,N)
res = 0
for i in range(N):
    tmp = gcd(query(0,i),query(i+1,N))
    if tmp >= res:
        res = tmp
print(res)


### FIXED CODE ###

from fractions import gcd
def init(init_val,n):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def segfunc(x,y):
    return gcd(x,y)

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res
N = int(input())
a = list(map(int,input().split()))
#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(N-1).bit_length()
seg=[ide_ele]*2*num

init(a,N)
res = 0
for i in range(N):
    tmp = gcd(query(0,i),query(i+1,N))
    if tmp >= res:
        res = tmp
print(res)
### BUGGY CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
from bisect import bisect_left,bisect_right


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

ret = 0
for a in range(N-1,1,-1):
  for b in range(a-1,0,-1):
    if Ln[a] >= Ln[b] + Ln[b-1]:
      continue
    else:
      c = b-1
      while Ln[a]<Ln[b]+Ln[c] and c>=0:
        ret += 1
        c -= 1
print(ret)

### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-


## Input
N = int(input())
Ln = list(map(int, input().split()))
Ln = sorted(Ln)

## Solve
ret = 0
for a in range(2,N):
  c = 0
  for b in range(a-1,0,-1):
    if c >= b:
      continue
    else:
      while (c<b and Ln[a]>=Ln[b]+Ln[c]):
        c += 1
      ret += max(b-c,0)
print(ret)
### BUGGY CODE ###

# ABC 152 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
snm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
p=nl()
ans=0
for i in range(n):
    if i==0:
        ans+=1
        continue
    if p[i]<=min(p[:i]):
        ans+=1
print(ans)

### FIXED CODE ###

# ABC 152 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
snm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
p=nl()
s=[]
ans=0
min_v=10**6
for i in range(n):
    if i==0:
        ans+=1
        s.append(p[i])
        min_v=min(min_v,p[i])
        continue
    if p[i]<=min_v:
        ans+=1
    s.append(p[i])
    min_v=min(min_v,p[i])
print(ans)
### BUGGY CODE ###

from collections import Counter

s = input()
mod1 = 673
mod2 = 3

num1 = 0
num2 = 0
li1 = []
li2 = []
for i, e in enumerate(s, 1):
    num1 *= 10
    num1 += int(e)
    num1 %= mod1
    inv = pow(pow(10, i + 1), mod1 - 2, mod1)
    li1.append(num1 * inv % mod1)

    num2 *= 10
    num2 += int(e)
    num2 %= mod2
    inv = pow(pow(10, i + 1), mod2 - 2, mod2)
    li2.append(num2 * inv % mod2)

li = [0] + [10 * e1 + e2 for e1, e2 in zip(li1, li2)]
c = Counter(li)

ans = 0
for v in c.values():
    ans += v * (v - 1) // 2

print(ans)


### FIXED CODE ###

from collections import Counter

s = input()
mod1 = 673
mod2 = 3

num1 = 0
num2 = 0
li1 = []
li2 = []
pw1 = 10
pw2 = 10
for i, e in enumerate(s, 1):
    num1 *= 10
    num1 += int(e)
    num1 %= mod1
    inv = pow(pw1, mod1 - 2, mod1)
    li1.append(num1 * inv % mod1)

    num2 *= 10
    num2 += int(e)
    num2 %= mod2
    inv = pow(pw2, mod2 - 2, mod2)
    li2.append(num2 * inv % mod2)

    pw1 *= 10
    pw1 %= mod1
    pw2 *= 10
    pw2 %= mod2

li = [0] + [10 * e1 + e2 for e1, e2 in zip(li1, li2)]
c = Counter(li)

ans = 0
for v in c.values():
    ans += v * (v - 1) // 2

print(ans)
### BUGGY CODE ###

def main():
    N, K, Q, *A = map(int, open(0).read().split())
    A = [K + A.count(i) for i in range(1, N + 1)]
    print("\n".join(["Yes" if Q < a else "No" for a in A]))
    return


main()


### FIXED CODE ###

from sys import stdin
from collections import Counter

lines = stdin.readlines()

N, K, Q = map(int, lines[0].split())
ans = [0] * N
A = Counter((int(i) - 1 for i in lines[1:]))
for k in A.keys():
    ans[k] += A[k]
print("\n".join(("Yes" if Q < K + a
                 else "No" for a in ans)))
### BUGGY CODE ###

n,*a=map(int,open(0).read().split())
b=[0]*61
for c in a:
  for i in range(61):b[i]+=2**i&c>0
print(sum(2**i*c*(n-c)for i,c in enumerate(b))%(10**9+7))

### FIXED CODE ###

n,*a=map(int,open(0).read().split())
b=[0]*61
for c in a:
  for i in range(61):b[i]+=2**i&c>0
print(sum(2**i*c*(n-c)for i,c in enumerate(b))%(10**9+7))
### BUGGY CODE ###

INT_MAX = (1<<31) - 1
_N,query_num = map(int, input().split())
queries = [list(map(int, input().split())) for i in range(query_num)]
N = 1<<17
N1 = N - 1
N2 = N1 // 2
arr_size = 2*N - 1
A = [INT_MAX]*(arr_size)
lazy_A = [-1]*(arr_size)

def tree_propagate(k):

    if(lazy_A[k] == -1):
        return

    if(k < N2):
        A[k*2+1] = A[k*2+2] = lazy_A[k*2+1] = lazy_A[k*2+2] = lazy_A[k]
        lazy_A[k] = -1
        return
    if(k < N1):
        A[k*2+1] = A[k*2+2] = lazy_A[k]
        lazy_A[k] = -1

def update(s,t,x,k,l,r):

    if (r <= s or t <= l):
        return
    if (s <= l and r <= t):
        A[k] = x
        if(k < N1):
            lazy_A[k] = x
        return

    tree_propagate(k)
    center = (l+r)//2
    update(s, t, x, k*2 + 1, l, center)
    update(s, t, x, k*2 + 2, center, r)

    A[k] = min(A[k*2+1], A[k*2+2])

def find(s,t,k,l,r):

    if (r <= s or t <= l):
        return INT_MAX

    if(s <= l and r <= t):
        return A[k]

    tree_propagate(k)
    center = (l+r)//2
    v_left = find(s, t, k*2 + 1, l, center)
    v_right = find(s, t, k*2 + 2, center, r)
    return min(v_left,v_right)

answers = []
for query in queries:
    if(query[0]==0):
        update(query[1],query[2]+1,query[3],0,0,N)
    else:
        answers.append(find(query[1],query[2]+1,0,0,N))

print("\n".join([str(ans) for ans in answers]))


### FIXED CODE ###

import sys
input = sys.stdin.readline
INT_MAX = (1<<31) - 1
_N,num = map(int, input().split())
Q = [list(map(int, input().split())) for i in range(num)]
N = 1<<17
N1 = N - 1
N2 = N1 // 2
ars = 2*N - 1
A = [INT_MAX]*(ars)
L = [-1]*(ars)

def propagate(k):

    if(L[k] == -1):
        return
    left = k*2+1
    right = k*2+2
    if(k < N2):
        A[left] = A[right] = L[left] = L[right] = L[k]
        L[k] = -1
        return
    if(k < N1):
        A[left] = A[right] = L[k]
        L[k] = -1

def update(s,t,x,k,l,r):

    if (r <= s or t <= l):
        return
    if (s <= l and r <= t):
        A[k] = x
        if(k < N1):
            L[k] = x
        return

    propagate(k)
    mid = (l+r)//2
    left = k*2 + 1
    right = k*2 + 2
    update(s, t, x, left, l, mid)
    update(s, t, x, right, mid, r)

    A[k] = min(A[left], A[right])

def find(s,t,k,l,r):

    if (r <= s or t <= l):
        return INT_MAX

    if(s <= l and r <= t):
        return A[k]

    propagate(k)
    mid = (l+r)//2
    left = k*2 + 1
    right = k*2 + 2
    v_left = find(s, t, left, l, mid)
    v_right = find(s, t, right, mid, r)
    return min(v_left,v_right)

res = []
for q in Q:
    # update
    if(q[0]==0):
        update(q[1],q[2]+1,q[3],0,0,N)
    # find
    else:
        res.append(find(q[1],q[2]+1,0,0,N))

print("\n".join([str(r) for r in res]))
### BUGGY CODE ###

K,S=map(int,input().split())
ans=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z==S:
                ans+=1

print(ans)

### FIXED CODE ###

K,S=map(int,input().split())
ans=0
for x in range(K+1):
    for y in range(K+1):
            z=S-x-y
            if 0<=z<=K:
                ans+=1

print(ans)
### BUGGY CODE ###

def main():
    sts=input()
    n= len(sts)
    s = []
    for c in sts:
        s.append(c)

    dp = [[0 for _ in range(13)]for _ in range(n)]

    ss = s[0]
    if ss == '?':
        for i in range(10):
            dp[0][i] = 1
    else:
        ss = int(ss)
        dp[0][ss] = 1

    for i in range(1,n):
        ss = s[i]
        if ss == "?":
            for k in range(10):
                for j in range(13):
                    dp[i][(j * 10 +k) % 13] += dp[i-1][j]
        else:
            ss = int(ss)
            for j in range(13):
                dp[i][(j * 10 +ss) % 13] += dp[i-1][j]

    print(dp[n-1][5] % (10**9+7))

main()

### FIXED CODE ###

def main():
    sts=input()
    n= len(sts)
    mod = 10**9+7
    s = []
    for c in sts:
        s.append(c)

    dp = [[0 for _ in range(13)]for _ in range(n)]

    ss = s[0]
    if ss == '?':
        for i in range(10):
            dp[0][i] = 1
    else:
        ss = int(ss)
        dp[0][ss] = 1

    for i in range(1,n):
        ss = s[i]
        if ss == "?":
            for k in range(10):
                for j in range(13):
                    dp[i][(j * 10 +k) % 13] += dp[i-1][j]
        else:
            for j in range(13):
                dp[i][(j * 10 +int(ss)) % 13] += dp[i-1][j]
        for j in range(13):
            dp[i][j]%= mod


    print(dp[n-1][5])

main()
### BUGGY CODE ###

N,d,a = map(int,input().split())

# N: 処理する区間の長さ

data0 = [0]*(N+1)
data1 = [0]*(N+1)
# 区間[l, r)に x を加算
def _add(data, k, x):
    while k <= N:
        data[k] += x
        k += k & -k
def add(l, r, x):
    _add(data0, l, -x*(l-1))
    _add(data0, r, x*(r-1))
    _add(data1, l, x)
    _add(data1, r, -x)

# 区間[l, r)の和を求める
def _get(data, k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s
def query(l, r):
    return _get(data1, r-1) * (r-1) + _get(data0, r-1) - _get(data1, l-1) * (l-1) - _get(data0, l-1)

xhl = []
for _ in range(N):
    x,h = map(int,input().split())
    xhl.append((x,h))

xhl = sorted(xhl)
xl = [x for x,h in xhl]

for idx in range(N):
    add(idx+1, idx+2, xhl[idx][1])

def ceil(a, b):
   return a // b + (a % b > 0)

import bisect

ans = 0
for i in range(N):
    hp = query(i + 1, i + 2)
    if hp > 0:
        count = ceil(hp, a)
        ans += count
        damage = count * a
        idx = bisect.bisect_right(xl, xl[i] + 2*d)
        add(i+1, idx+1, -damage)
print(ans)







### FIXED CODE ###

N,d,a = map(int,input().split())

# N: 処理する区間の長さ

data0 = [0]*(N+1)
data1 = [0]*(N+1)
# 区間[l, r)に x を加算
def _add(data, k, x):
    while k <= N:
        data[k] += x
        k += k & -k
def add(l, r, x):
    _add(data0, l, -x*(l-1))
    _add(data0, r, x*(r-1))
    _add(data1, l, x)
    _add(data1, r, -x)

# 区間[l, r)の和を求める
def _get(data, k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s
def query(l, r):
    return _get(data1, r-1) * (r-1) + _get(data0, r-1) - _get(data1, l-1) * (l-1) - _get(data0, l-1)

xhl = []
for _ in range(N):
    x,h = map(int,input().split())
    xhl.append((x,h))

xhl = sorted(xhl)
xl = [x for x,h in xhl]

for idx in range(N):
    add(idx+1, idx+2, xhl[idx][1])

def ceil(a, b):
   return a // b + (a % b > 0)

import bisect

ans = 0
for i in range(N):
    hp = query(i + 1, i + 2)
    if hp > 0:
        count = ceil(hp, a)
        ans += count
        damage = count * a
        idx = bisect.bisect_right(xl, xl[i] + 2*d)
        add(i+1, idx+1, -damage)
print(ans)
### BUGGY CODE ###

def isPrimeNumber(num):
  if num == 1:
    return False
  pn = 2
  while pn * pn <= num:
    if num % pn == 0:
      return False
    pn += 1
  return True

n = int(input())

l = [0] * n
r = [0] * n
for i in range(n):
  l[i], r[i] = map(int, input().split())
  
  
for i in range(n):
  ans = 0
  for j in range(l[i], r[i]+1, 2):
    if isPrimeNumber(j) and isPrimeNumber((j+1)/2):
      ans += 1
      
  print(ans)

### FIXED CODE ###

max_num = 10**5+5
eratos_thenes_sieve = [0,0] + [1]*max_num
n = 2 #素数
while n*n <= max_num:
  if eratos_thenes_sieve[n]:#
    for i in range(2*n, max_num, n):
      eratos_thenes_sieve[i] = 0
  n += 1
  
isLike2017 = [0] * max_num
cumulativeSums = [0]
for i in range(max_num):
  if eratos_thenes_sieve[i] and eratos_thenes_sieve[(i+1)//2]:
    isLike2017[i] = 1
  cumulativeSums.append(cumulativeSums[-1] + isLike2017[i])
  
  
q = int(input())

for i in range(q):
  l, r = map(int, input().split())
  print(cumulativeSums[r+1] - cumulativeSums[l])
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list()
C = list()
for i in range(M):
  x, y = map(int, input().split())
  B.append(x)
  C.append(y)
A.sort()
for i in range(M):
  for j in range(B[i]):
    if(A[j] < C[i]):
      A[j] = C[i]
    else:
      break
  A.sort()
print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [[0]*2 for i in range(M+N)]
for i in range(M):
  B[i] = list(map(int, input().split()))
for i in range(N):
  B[M+i] = [1, A[i]]
B=sorted(B ,key=lambda x:x[1],reverse=True)
i = 0
cnt = 0
ans = 0
while(cnt < N):
  if(cnt + B[i][0] < N):
    ans += B[i][0] * B[i][1]
    cnt += B[i][0]
  else:
    ans += (N - cnt) * B[i][1]
    cnt = N
  i += 1
print(ans)
### BUGGY CODE ###

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

y.sort()

a=0
b=0
c=0
ans=0
for i in range(x):
	a=y[i]
	for j in range(i+1,x):
		b=y[j]
		for k in range(j+1,x):
			c=y[k]
			if a+b>c:
				ans=ans+1
			else:
				break
print(ans)

### FIXED CODE ###

import bisect
x=int(input())
y=list(map(int, input().split()))
 
y.sort()
 
a=0
b=0
c=0
ans=0
for i in range(x):
	a=y[i]
	for j in range(i+1,x):
		b=y[j]
		c=bisect.bisect_left(y,a+b)
		ans=ans+c-j-1
print(ans)
### BUGGY CODE ###

def resolve():
    n = int(input())
    power = 1

    for i in range(1, n+1):
        power *= i

    print(power % (10**9 + 7))

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

import math
def resolve():
    n = int(input())
    power = 1

    power = power * math.factorial(n)

    print(power % (10**9 + 7))

if __name__ == '__main__':
    resolve()
### BUGGY CODE ###

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

def check(lst):
    # print (set(lst))
    if (N == lst[0]) and (len(set(lst[:-1])) == 1):
        return True
    else:
        return False

def move(lst):
    tmp = [0] * (N + 1)
    for i in range(N):
        a = lst[i]
        left = max(0, i - a)
        right = min(N, i + a + 1)
        tmp[left] += 1
        tmp[right] -= 1
    for i in range(N):
        tmp[i + 1] += tmp[i]
    return tmp

for i in range(K):
    A = move(A)
    if check(A):
        # print (i)
        break

print (*A[:-1])


### FIXED CODE ###

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

def check(lst):
    for i in range(N):
        if lst[i] != N:
            return False
    return True

def move(lst):
    tmp = [0] * (N + 1)
    for i in range(N):
        a = lst[i]
        left = max(0, i - a)
        right = min(N, i + a + 1)
        tmp[left] += 1
        tmp[right] -= 1
    for i in range(N):
        tmp[i + 1] += tmp[i]
    return tmp

for i in range(K):
    A = move(A)
    if check(A):
        # print (i)
        break

print (*A[:-1])
### BUGGY CODE ###

from collections import deque
d=deque(input())
qq=int(input())
for _ in range(qq):
  q=list(input().split())
  if len(q)==1:
    d.reverse()
  else:
    if q[1]=='1':
      d.appendleft(q[2])
    else:
      d.append(q[2])
print(''.join(list(d)))

### FIXED CODE ###

s=input()
qq=int(input())
re=0
l=''
r=''
f=1
for _ in range(qq):
  q=list(input().split())
  if len(q)==1:
    re+=1
    if f:
      f=0
    else:
      f=1
  else:
    t=q[2]
    if f:
      if q[1]=='1':
        l+=t
      else:
        r+=t
    else:
      if q[1]=='1':
        r+=t
      else:
        l+=t
if re%2==0:
  print(l[::-1]+s+r)
else:
  print(r[::-1]+s[::-1]+l)
### BUGGY CODE ###

K = int(input())
S = 7
if (1 <= K) and (K <= (10 ** 6)):

    for i in range(K+1):
        if int(S) % K != 0:
            S = S * 10 + 7
        else:
            print(i+1)
            break

    if i >= K:
        print('-1')

### FIXED CODE ###

K = int(input())
if K % 2 == 0:
    print(-1)
elif K % 5 == 0:
    print(-1)
else:
    S = 7
    for i in range(K+1):
        if S % K == 0:
            print(i+1)
            break
        else:
            S = S % K
            S = S * 10 + 7
    else:
        print(-1)