Harryxun/stf_run huggingface dataset:
S=str(input())
print(S.count(”1”))

### FIXED CODE ###

s=str(input())
if s=="111":
  print(3)
elif s=="000":
  print(0)
elif s=="001" or s=="010" or s=="100":
  print(1)
else:
  print(2)
x, y = map(int, input())
print(x*y//2)

### FIXED CODE ###

x, y, z = map(int, input().split())
print(x*y//2)
k = input()
a, b = map(int, input().split())
 
for i in range(a,b):
  if i%k == 0:
    print("OK")
    break
else:
  print("NG")

### FIXED CODE ###

k = int(input())
a, b = map(int, input().split())
 
for i in range(a,b+1):
  if i%k == 0:
    print("OK")
    break
else:
  print("NG")
x=int(input())print(x*x*x)

### FIXED CODE ###

x=int(input()) 
print(x*x*x)
n = int(input())

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

if 0 aList:
  print(0)
else:
  for i in range(n):
    if i == 0:
      continue
    result = result * aList[i]

  enemy = 10 ** 18

  if result < enemy:
    print(result)
  else:
    print(-1)

### FIXED CODE ###

n = int(input())
 
aList = list(map(int,input().split()))
 
if 0 in aList:
  print(0)
else:
  result = 1
  for a in aList:
    result = result * a
    if result > 10 ** 18:
      result = -1
      break
  print(result)
N,Q = list(map(int,input().split()))
S = input()
L = []
R = []
for i in range(Q):
    a = list(map(int,input().split()))
    L.append(a[0])
    R.append(a[1])

S_count = []
count = 0
A_flag = False

for i in range(len(S)):
    if A_flag == True:
        if S[i] == "C" :
            count += 1
    else:
        if S[i] == "A" :
            A_flag = True
        else:
            A_flag = False
    S_count.append(count)

for i in range(Q):
    print(S_count[R[i]] - S_count[L[i]])

### FIXED CODE ###

#c
N,Q = list(map(int,input().split()))
S = input()
L = []
R = []
for i in range(Q):
    a = list(map(int,input().split()))
    L.append(a[0])
    R.append(a[1])

S_count = []
count = 0
A_flag = False

for i in range(len(S)):
    if A_flag == True:
        if S[i] == "C" :
            count += 1
   
    if S[i] == "A" :
        A_flag = True
    else:
        A_flag = False
    S_count.append(count)

for i in range(Q):
    print(S_count[R[i] - 1] - S_count[L[i] - 1])
s = input()
ans = ""
for i in range(len(s)):
    if s[i] = "0":
        ans.append("0")
    elif s[i] = "1":
        ans.append("1")
    elif s[i] = "B":
        ans.rstrip()
print(ans)

### FIXED CODE ###

s = input()
ans = ""
for i in range(len(s)):
    if s[i] == "0":
        ans = ans + "0"
    elif s[i] == "1":
        ans = ans + "1"
    elif s[i] == "B":
        ans = ans[:len(ans)-1]
print(ans)
A,B,C,X = map(int, input().split())

cnt = 0
for i in range(0, A+1):
        for j in range(0, B+1):
                for k in range(0, C+1):
                        if int(500*i + 100*j + 50*k) == X:
                            cnt += 1
                     
print(cnt)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(0, A+1):
        for j in range(0, B+1):
                for k in range(0, C+1):
                        if int(500*i + 100*j + 50*k) == X:
                            cnt += 1
                     
print(cnt)
import sys
sys.setrecursionlimit(int(1e9))



class uft:
  def __init__(self, N):
    self.__N = N
    self.__arr = [-1] * (N + 1)
  def fp(self, x):
    if self.__arr[x] < 0:
      return x
    else:
      self.__arr[x] = self.fp(self.__arr[x])
      return self.__arr[x]
  def add(self, x, y):
    if x == y:
      return 1
    px = self.fp(x)
    py = self.fp(y)
    if px > py:
      px, py = py, px
    self.__arr[px] += self.__arr[py]
    self.__arr[py] = px
  def groups(self):
    ret = -1
    for i in self.__arr:
      if i < 0:
        ret += 1
    return ret
  
N, M = map(int, input().split()) 
UFT = uft(N)

for i in range(M):
  A, B = map(int, input().split())
  UFT.add(A-1,B-1)
print(UFT.groups() -1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(int(1e9))

class uft:
  def __init__(self, N):
    self.__N = N
    self.__arr = [-1] * (N + 1)
  def fp(self, x):
    if self.__arr[x] < 0:
      return x
    else:
      self.__arr[x] = self.fp(self.__arr[x])
      return self.__arr[x]
  def add(self, x, y):
    px = self.fp(x)
    py = self.fp(y)
    if px > py:
      px, py = py, px
    if px == py:
      return 1
    self.__arr[px] += self.__arr[py]
    self.__arr[py] = px
  def groups(self):
    ret = -1
    for i in self.__arr:
      if i < 0:
        ret += 1
    return ret
  def show_arr(self):
    print(self.__arr)
  
N, M = map(int, input().split()) 
UFT = uft(N)

for i in range(M):
  A, B = map(int, input().split())
  UFT.add(A,B)
print(UFT.groups() -1)
N=int(input())
A=list(input())
cnt=0

for n in range(N):
    if A[n]=="A":
        if A[n+1]=="B":
            if A[n+2]=="C":
                cnt+=1
            else:
                continue
        else:
            continue
    else:
        continue

print(cnt)


### FIXED CODE ###

N=int(input())
A=list(input())
cnt=0

for n in range(N):
    if n==N-1 or n==N-2:
        continue
    elif A[n]=="A":
        if A[n+1]=="B":
            if A[n+2]=="C":
                cnt+=1
            else:
                continue
        else:
            continue
    else:
        continue

print(cnt)
K=int(input())
X,Y=map(int,input().split())
if K%2==1:
  print(-1)
else:
  raise Exception

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from itertools import product
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    K=int(input())
    X,Y=map(int,input().split())
    
    def is_on_square(x0,y0,x1,y1):
        return (abs(x1-x0)==K and y0-K<=y1<=y0+K) or (abs(y1-y0)==K and x0-K<=x1<=x0+K)
    
    rX=X-Y
    rY=X+Y
    x,y=0,0
    ans=[]
    while True:
        # 残り一打
        if max(abs(x-rX),abs(y-rY))==K:
            ans.append((rX,rY))
            break
        # 残り二打以内の可能性あり
        elif abs(x-rX)<=K*2 and abs(y-rY)<=K*2:
            for nx,ny in list(product((x+K,x-K),(rY+K,rY-K)))+list(product((rX+K,rX-K),(y+K,y-K))):
                if is_on_square(x,y,nx,ny) and is_on_square(rX,rY,nx,ny) and (nx+ny)%2==0:
                    x,y=nx,ny
                    break
            else:
                # Kが奇数なら一打後残り二打になる
                if K%2:
                    if x<rX:
                        x+=K
                    else:
                        x-=K
                    if y<rY:
                        y+=K
                    else:
                        y-=K
                else:
                    ans=[]
                    break
        
        else:
            # x==rX or y==rYに寄せる
            if abs(x-rX)<abs(y-rY):
                if abs(x-rX)>=K:
                    if x>rX:
                        x-=K
                    else:
                        x+=K
                    if y>rY:
                        y-=K
                    else:
                        y+=K
                else:
                    x=rX
                    if y>rY:
                        y-=K
                    else:
                        y+=K
                    if (x+y)%2:
                        x+=1
            else:
                if abs(y-rY)>=K:
                    if x>rX:
                        x-=K
                    else:
                        x+=K
                    if y>rY:
                        y-=K
                    else:
                        y+=K
                else:
                    y=rY
                    if x>rX:
                        x-=K
                    else:
                        x+=K
                    if (x+y)%2:
                        y+=1
        ans.append((x,y))
    
    if not ans:
        print(-1)
    else:
        print(len(ans))
        for x,y in ans:
            print((y+x)//2,(y-x)//2)
                
        

if __name__ == '__main__':
    main()
a = input()
b = input()

c = (a - b) % 2 
if c == 0:
  abs_a = abs(a)
  abs_b = abs(b)
  ans = max(abs_a, abs_b) - (((max(abs_a, abs_b)/2) - min(abs_a, abs_b))/2)
  print(ans)
else:
  print("IMPOSSIBLE")

### FIXED CODE ###

inp = input().split(" ")
a = int(inp[0])
b = int(inp[1])
 
c = (a - b) % 2 
if c == 0:
  abs_a = abs(a)
  abs_b = abs(b)
 
  m = (max(abs_a, abs_b) - min(abs_a, abs_b)) /2
  ans = max(abs_a, abs_b) - m
  print(int(ans))
else:
  print("IMPOSSIBLE")
a, b, k = map(int, input().split())

res = []
for i in range(1, min(a, b)):
    if a % i == 0 and b % i == 0:
        res.append(i)

res.sort(reverse=True)
print(res[k-1])


### FIXED CODE ###

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

res = []
for i in range(1, 101):
    if a % i == 0 and b % i == 0:
        res.append(i)

res.sort(reverse=True)
print(res[k-1])
N, K = map(int, input().split())
ans = N - K + 1
for i in range(1, K + 1):
    if i > N - K + 1:
        ans = 0
    print(int(ans % 1000000007))
    ans = ans * (N - K + 1 - i) / (i + 1) * (K - i) / i


### FIXED CODE ###

N, K = map(int, input().split())
ans = N - K + 1
for i in range(1, K + 1):
    if i > N - K + 1:
        ans = 0
    print(ans % 1000000007)
    ans = ans * (N - K + 1 - i) * (K - i)
    ans = ans // ((i + 1) * i)
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = a.sort(reverse = True)
b = sum(a)
c = 0
d = "Yes"
l = 1 / (4 * m)
b = b * l
while c < m:
  if a[c] < b:
    d = "No"
  c += 1
print(d)

### FIXED CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
b = 0
c = 0
d = ""
l = 1 / (4 * m)
for i in a:
    b += i
b = b * l
while c < m:
  if a[c] < b:
    d = "No"
  else:
    d = "Yes"
  c += 1
print(d)
N=input()
if N[2]='2' and N[2]='4' and N[2]='5' and N[2]='7' andN[2]='9':
    print('hon')
elif N[2]='0' and N[2]='1' and N[2]='6' and N[2]='8':
    print('pon')
else:
    print('bon')

### FIXED CODE ###

N=input()
B=0
B=len(N)
B=B-1
#print(B,N)
if N[B]=='2' or N[B]=='4' or N[B]=='5' or N[B]=='7' or N[B]=='9':
    print('hon')
elif N[B]=='0' or N[B]=='1' or N[B]=='6' or N[B]=='8':
    print('pon')
else:
    print('bon')
x_ = list(map(int, input().split()))

for i in range(x_):
  if x_[i] == 0:
    print(i)

### FIXED CODE ###

x_ = list(map(int, input().split()))
 
for i in range(len(x_)):
  if x_[i] == 0:
    print(i+1)
from math import atan
a,b,x=map(int, input().split())
ans=None
V=(a**2)*b
if x>=V/2:
  #S=(x/a**2*b)*a*b
  #S=0.5*a*y
  #y=2S/a
  #tan(ans)=y/a
  #atan(y/a)=ans
  S=(x/a**2*b)*a*b
  y=2S/a
  ans=atan(y/a)
else:
  #S=(x/a**2*b)*a*b
  #S=0.5*b*y
  #y=2S/b
  #ans=90-atan(y/b)
  S=(x/a**2*b)*a*b
  y=2S/b
  ans=90-atan(y/b)
  
print(ans)

### FIXED CODE ###

from math import atan,degrees
a,b,x=map(int, input().split())
ans=None
V=(a**2)*b
if x>=V/2:
  #S=(x/a**2*b)*a*b
  #S=0.5*a*y
  #y=2S/a
  #tan(ans)=y/a
  #atan(y/a)=ans
  S=((V-x)/V)*a*b
  y=2*S/a
  ans=degrees(atan(y/a))
  #print(S, y, ans)
else:
  #S=(x/a**2*b)*a*b
  #S=0.5*b*y
  #y=2S/b
  #ans=90-atan(y/b)
  S=(x/V)*a*b
  y=2*S/b
  ans=90-degrees(atan(y/b))
  
print(ans)
n = int(raw_input())

for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split())
    a = (y2-y1)/(x2-x1)
    c = (y4-y3)/(x4-x3)
    if a == c:
        print "YES"
    else:
        print "NO"

### FIXED CODE ###

n = int(raw_input())

for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split())
    if abs((y4-y3)*(x2-x1)-(y2-y1)*(x4-x3)) < 1e-10:
        print "YES"
    else:
        print "NO"
True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
        
    for h in range(H):
        for w in range(W):
            if  (h + w) % 2 == 0:
                print('#', end='???')
                
            else:
                print('.', end='???')
                
        print()

### FIXED CODE ###

while True:
 
    H,W =[int(i) for i in input().split()]
 
    if H == W == 0:
        break
 
    for h in range(H):
        for w in range(W):
            if (h+w) % 2 ==0:
                print('#', end='')
            else :
                print('.' ,end='')
        print()
    print()
n = int(input())
s = input()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWSYZ"
b = ""
for i in s:
    j = (s.index(i) + n) % 26
    b += s[j]
print(b)

### FIXED CODE ###

n = int(input())
s = input()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
b = ""
for i in s:
    j = (alpha.index(i) + n) % 26
    b += alpha[j]
print(b)
A, B = [int(i) for i in input().split()]
List_9 = []
for i in range(1, 10):
    for j in range(1, 10):
        List_9.append(i * j)
        
if A * B in List_9:
    print(A * b)
else:
    print(-1)

### FIXED CODE ###

A, B = [int(i) for i in input().split()]

if A < 10 and B < 10:
  print(A * B)
else:
  print(-1)
a, b = map(int, input().split())
A = str(bin(a))[2:]
if A[-1] == '0':
    if (b-a+1)%2 == 0:
        mae = '0'
    else:
        mae = str(bin(int(A[:-1], 2)+int((b-a)/2)))[2:]
    if (b-a+1)%4 == 0 or (b-a+1)%4 == 1:
        print(int(mae+'0', 2))
    else:
        print(int(mae+'1', 2))
else:
    if (b-a+1)%2 == 0:
        mae = '0'
    else:
        mae = str(bin(int(A[:-1], 2)+int((b-a)/2)))[2:]
    if (b-a+1)%4 == 0 or (b-a+1)%4 == 3:
        print(int(mae+'0', 2))
    else:
        print(int(mae+'1', 2))


### FIXED CODE ###

a, b = map(int, input().split())
A = str(bin(a))[2:]
B = str(bin(b))[2:]
if A[-1] == '0':
    if (b-a+1)%2 == 0:
        mae = '0'
    else:
        if a <= 1:
            c = '0'
        else:
            c = A[:-1]
        mae = str(bin(int(c, 2)+int((b-a)/2)))[2:]
    if (b-a+1)%4 == 0 or (b-a+1)%4 == 1:
        print(int(mae+'0', 2))
    else:
        print(int(mae+'1', 2))
else:
    if (b-a+1)%2 == 0:
        if a <= 1:
            c = '0'
        else:
            c = A[:-1]
        if b <= 1:
            d = '0'
        else:
            d = B[:-1]

        mae = str(bin(int(c, 2)^int(d, 2)))[2:]
    else:
        mae = A[:-1]
    if (b-a+1)%4 == 0 or (b-a+1)%4 == 3:
        print(int(mae+'0', 2))
    else:
        print(int(mae+'1', 2))
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W,D = Is()
d = dict()
for i in range(H):
    s = Is()
    for j,e in enumerate(s):
        d[e] = (i,j)
Q = I()
for q in range(Q):
    l,r = Is()
    maho = 0
    for k in range(l,r,D):
        maho += abs(d[k+D][0] - d[k][0]) + abs(d[k+D][1] - d[k][1])
    print(maho)

### FIXED CODE ###

import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
print(n//3)
import math
import sys
sys.setrecursionlimit(10**5)
n = int(input())
s = int(input())

if n < s:
    print (-1)
    exit()

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n%b

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

if n == 1:
    print (-1)
    exit()

for i in range(2, int(math.sqrt(n))+2):
    if f(i, n) == s:
        print (i)
        exit()

for p in range(1, int(math.sqrt(n))+2):
    b = (n-s)//p + 1
    if f(b, n) == s:
        print (b)
        exit()
print (-1)

### FIXED CODE ###

import math
import sys
sys.setrecursionlimit(10**5)
n = int(input())
s = int(input())

if n < s:
    print (-1)
    exit()

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n%b

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

if n == 1:
    print (-1)
    exit()

for i in range(2, int(math.sqrt(n))+2):
    if f(i, n) == s:
        print (i)
        exit()

for p in range(int(math.sqrt(n))+1, 0, -1):
    b = (n-s)//p + 1
    if b != 1 and f(b, n) == s:
        print (b)
        exit()
print (-1)

# for i in range(2, 100):
#     print (i, f(i,100))
n=int(input())
s=input()
count=0
for i in range(len(s))
    if s[i]=="A":
        if s[i+1]=="B":
            if s[i+2]=="C":
                count+=1
print(count)


### FIXED CODE ###

n=int(input())
s=input()
count=0
for i in range(n):
    if s[i]=="A":
        if i+1<n and s[i+1]=="B":
            if i+2<n and s[i+2]=="C":
                count+=1
print(count)
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(1,n+1):
    b.append(a[i-1] - i)
b.sort
if n % 2 != 0:
    B = b[int((n+1)/2)]
    ans = 0
    for i in range(n):
        ans += abs(a[i]-i-1-B)
    print(ans)
else:
    big = b[int((n+2)/2)]
    smo = b[int(n/2)]
    smoB = int((big+smo)/2)
    bigB = smoB + 1
    big = smo = 0
    for i in range(n):
        big += abs(a[i]-i-1-bigB)
    for i in range(n):
        smo += abs(a[i]-i-1-smoB)
    print(min(big,smo))

### FIXED CODE ###

from statistics import median 
n = int(input())
a = list(map(int,input().split()))
ls = []
for i in range(n):
    ls.append(a[i] - i - 1)
b = median(ls)
if b % 1 == 0:
    ans = 0
    b = int(b)
    for i in range(n):
        ans += abs(a[i] - (b + i + 1))
    print(ans)
else:
    bigans = smallans = 0
    for i in range(n):
        bigans += abs(a[i] - (int(b) + i + 2))
        smallans += abs(a[i] - (int(b) + i + 1))
    print(min(bigans,smallans))
N, M = map(int, input().split())
to = [[] for _ in range(N)]
count = 0

for _ in range(M):
    A, B = map(lambda x:int(x) - 1, input().split())
    to[A].append(B)
    to[B].append(A)


def dfs(v, to, seen):
    global count
    seen[v] = True
    count += 1
    for nv in to[v]:
        if seen[nv] == True:
            continue
        dfs(nv, to, seen)


def main():
    global count
    seen = [False] * N
    cnts = []
    for i in range(N):
        if not seen[i]:
            dfs(i, to, seen)
            cnts.append(count)
            count = 0
    
    print(max(cnts))


if __name__ == "__main__":
    main()



### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)


N, M = map(int, input().split())
to = [[] for _ in range(N)]
count = 0

for _ in range(M):
    A, B = map(lambda x:int(x) - 1, input().split())
    to[A].append(B)
    to[B].append(A)


def dfs(v, to, seen):
    global count
    seen[v] = True
    count += 1
    for nv in to[v]:
        if seen[nv]:
            continue
        dfs(nv, to, seen)


def main():
    global count
    seen = [False] * N
    cnts = []
    for i in range(N):
        if not seen[i]:
            dfs(i, to, seen)
            cnts.append(count)
            count = 0
    
    print(max(cnts))


if __name__ == "__main__":
    main()
z = input()
m,l = z.split()
s = int(m) * int(l)
n = int(m)*2 + int(l)*2

print({} {}.format(s,n))

### FIXED CODE ###

z = input()
m,l = z.split()
s = int(m) * int(l)
n = int(m)*2 + int(l)*2

print("{} {}".format(str(s),str(n)))
s= input()
l = list(s)
ans= "Yes"
if(s != s[::1]):
    ans = "No"
    break
else:
    s1 = s[:len(s)//2]
    s2 = s[len(s)//2+1:]
    if s1!=s2:
        print("No")
    else:
        print("Yes")
print(ans)


### FIXED CODE ###

s= str(input())
if s != s[::-1]:
    print("No")
    exit()
else:
    s1 = s[:len(s)//2]
    s2 = s[len(s)//2+1:]
    if (s1!=s2):
        print("No")
    else:
        print("Yes")
s = input()
print(s.count(1))

### FIXED CODE ###

s = input()
print(s.count("1"))
import itertools
import sys
import numpy as np
from collections import Counter
import bisect

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
M = 1000000007
N = int(input())
left = list(map(int, input().split()))

indices = Counter()
for i, x in enumerate(left):
    indices[x] += 1


def dp(t, n1, n2, n3):
    cached = t.get((n1, n2, n3))
    if cached is not None:
        return cached
    remaining = n1 + n2 + n3
    assert remaining > 0
    last_cnt = left[remaining - 1] + 1
    res = 0
    if last_cnt == n1:
        res += dp(t, n1 - 1, n2, n3)
        res %= M
    if last_cnt == n2:
        res += dp(t, n1, n2 - 1, n3)
        res %= M
    if last_cnt == n3:
        res += dp(t, n1, n2, n3 - 1)
        res %= M
    # print(f"{remaining}: ({n1},{n2},{n3}) => {res}")
    t[n1, n2, n3] = res
    return res


def solve():
    h = [0, 0, 0]
    for i in range(N):
        k = indices[i]
        if k == 3:
            h[0] = h[1] = h[2] = i + 1
        elif k == 2:
            h[0] = h[1] = i + 1
        elif k == 1:
            h[0] = i + 1
        else:
            break
    assert sum(h) == N
    t = dict()
    t[0, 0, 0] = 1
    res = dp(t, h[0], h[1], h[2])
    return res * len(set(itertools.permutations(h))) % M


print(solve())


### FIXED CODE ###

import itertools
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 9)
M = 1000000007
N = int(sys.stdin.readline())
left = list(map(int, sys.stdin.read().split()))
counter = Counter(left)


def dp(t, ns):
    cached = t.get(ns)
    if cached is not None:
        return cached
    remaining = sum(ns)
    assert remaining > 0
    last_cnt = left[remaining - 1] + 1
    n1, n2, n3 = ns
    res = 0
    if last_cnt == n1:
        res += dp(t, tuple(sorted([n1 - 1, n2, n3])))
        res %= M
    if last_cnt == n2:
        res += dp(t, tuple(sorted([n1, n2 - 1, n3])))
        res %= M
    if last_cnt == n3:
        res += dp(t, tuple(sorted([n1, n2, n3 - 1])))
        res %= M
    # print(f"{remaining}: ({n1},{n2},{n3}) => {res}")
    t[ns] = res
    return res


def solve():
    h = [0, 0, 0]
    for i in range(N):
        k = counter[i]
        if k == 3:
            h[0] = h[1] = h[2] = i + 1
        elif k == 2:
            h[0] = h[1] = i + 1
        elif k == 1:
            h[0] = i + 1
        else:
            break
    if sum(h) != N:
        return 0
    t = dict()
    t[0, 0, 0] = 1
    res = dp(t, tuple(sorted(h)))
    return (res * len(set(itertools.permutations(h)))) % M


print(solve())
import numpy as np
A=[int(input()) for i in range(5)]
B=[]
for i in range(5):
    if int(str(A[i])[-1])!=0 and len(str(A[i]))>2:
        B.append(int(str(A[i])[:-3]+str(A[i]+1)+'0'))
    elif int(str(A[i])[-1])!=0 and len(str(A[i]))==2:
        B.append(int(str(int(str(A[i])[0])+1)+'0'))
    elif int(str(A[i])[-1])!=0 and len(str(A[i]))==1:
        B.append(10)
    else:
        B.append(int(A[i]))
a=np.array(A)
b=np.array(B)
np.array(B)-np.array(A)
tmp=np.sort(b-a)
return sum(tmp)+sum(a)-tmp[-1]

### FIXED CODE ###

import numpy as np
A=[int(input()) for i in range(5)]
B=[]
for i in range(5):
    if int(str(A[i])[-1])!=0 and len(str(A[i]))>2:
        B.append(int(str(A[i])[:-2]+str(int(str(A[i])[-2])+1)+'0'))
    elif int(str(A[i])[-1])!=0 and len(str(A[i]))==2:
        B.append(int(str(int(str(A[i])[0])+1)+'0'))
    elif int(str(A[i])[-1])!=0 and len(str(A[i]))==1:
        B.append(10)
    else:
        B.append(int(A[i]))
a=np.array(A)
b=np.array(B)
np.array(B)-np.array(A)
tmp=np.sort(b-a)
print(sum(tmp)+sum(a)-tmp[-1])
n = int(input())
a = [int(input()) for i in range(n)]
c = 0
p = 0
while True:
    c = a[c]
    p += 1
    if c == 1:
        print(p)
        exit()
    elif c == 0 and p > 1:
        print(-1)
        exit()


### FIXED CODE ###

n = int(input())
a = [0] + [int(input()) for i in range(n)]
c = a[1]
p = 1
while c > 2:
    d = a[c]
    a[c] = 0
    c = d
    p += 1

if c == 2:
    print(p)
else:
    print(-1)
p=[input().split() for i in range(2)]

(p[0][0]-p[1][0])*(p[0][1]-p[1][1])

### FIXED CODE ###

p=[list(map(int,input().split())) for i in range(2)]

print((p[0][0]-p[1][0])*(p[0][1]-p[1][1]))
from fractions import gcd
print(gcd(*set(map(int, input().split(" ")))))

### FIXED CODE ###

from fractions import gcd
print(gcd(*list(map(int, input().split(" ")))))
#D
n, m = list(map(int, input().split()))
alist = list(map(int, input().split()))
for i in range(m) :
    b, c = list(map(int, input().split()))
    alist += [c] * min(n, b)
alist.sort()
print(sum(alist))

### FIXED CODE ###

a, b = list(map(int, input().split()))
if a > 12 :
    print(b)
elif a > 5 :
    print(b//2)
else :
    print(0)
S = input()
cnt = 0
for i in s:
    if i == "o":
        cnt += 1
print(cnt * 100 + 700)


### FIXED CODE ###

S = input()
cnt = 0
for i in S:
    if i == "o":
        cnt += 1
print(cnt * 100 + 700)
l = map(int, raw_input().split())
print(l[0]*l[1], (l[0]+l[1])*2)

### FIXED CODE ###

a, b = map(int, input().split())
area = a*b
length = 2*(a+b)
print(area, length)