Harryxun/stf_run huggingface dataset:
import fractions
import sys
#import numpy as np

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def main():
    N = int(input())
    for i in range(N):
        if i == 0:
            tmp = int(input())
        else:
            a = int(input())
            b = lcm_base(a, tmp)
            tmp = b
    print(b)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import fractions
import sys
#import numpy as np

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def main():
    N = int(input())
    for i in range(N):
        if i == 0:
            tmp = int(input())
        else:
            a = int(input())
            b = lcm_base(a, tmp)
            tmp = b
    if N == 1:
        print(tmp)
    else:
        print(b)


if __name__ == "__main__":
    main()
odds=sum(A)
evens=N-odds 
if odds>0:
    ans=2**evens 
    ans*=2**(odds-1)
    print(ans)
else:
    if P==0:
        print(2**evens)
    else:
        print(0)


### FIXED CODE ###

N,P=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
    A[i]%=2

odds=sum(A)
evens=N-odds 
if odds>0:
    ans=2**evens 
    ans*=2**(odds-1)
    print(ans)
else:
    if P==0:
        print(2**evens)
    else:
        print(0)
n,k,c = map(int, input().split())
s = str(input())
t = [0 for i in range(n)]
u = [0 for i in range(n)]
i,x,y = 0,0,0
j = n-1
while i < n and x <= k:
    if s[i] == "o":
        t[i] = 1
        x += 1
        i += c
    i += 1

while j >= 0 and y <= k:
    if s[j] == "o":
        u[j] = 1
        y += 1
        j += -c
    j += -1

for i in range(0,n):
    if t[i] == 1 and u[i] == 1:
        print(i+1)

### FIXED CODE ###

a,b,c = map(int, input().split())
print(c,a,b)
n = int(input())
c = 0
for i in range(n):
    a,b = map(int,input().split())
    if b == 'JPY':
        c += a
    else:
        c +=380000*a
print(c)

### FIXED CODE ###

n = int(input())
c = 0
for i in range(n):
    a,b = input().split()
    if b == 'JPY':
        c += int(a)
    else:
        c +=380000*float(a)
print(c)
s = input()
t = input()

s = [_ for _ in s]
t = [_ for _ in t]

count = 0
for i in 3:
  if s[i] == t[i]:
    count += 1
print(count)

### FIXED CODE ###

s = str(input())
t = str(input())

s = [_ for _ in s]
t = [_ for _ in t]

count = 0
for i in range(3):
  if s[i] == t[i]:
    count += 1
print(count)
K = int(input())


if K%2 == 0:
	print ((K//2)**2)
else:
	print ((K//2)*((K//2)+1)


### FIXED CODE ###

k = int(input())

if k % 2 == 0:
    print((k//2)**2)
else:
    print((k//2)*((k//2)+1))
s = input()
print(s[0]+str(lent(s)-2)+s[-1])

### FIXED CODE ###

s = input()
print(s[0]+str(len(s)-2)+s[-1])
S = int(input())
h = int(S / 3600)
m = int(S / 60)
m = m % 60
s = S % 60
print({0}:{1}:{2}.format(h,m,s))

### FIXED CODE ###

S = int(input())
h = int(S / 3600)
m = int(S / 60)
m = m % 60
s = S % 60
print("{0}:{1}:{2}".format(h,m,s))
import math

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

x = [X]
dic = []

x += list(map(int, input().split()))
x.sort()

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)

### FIXED CODE ###

import fractions

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(len(dic) - 1):
    ans = min(ans, fractions.gcd(dic[i], dic[i + 1]))

print(ans)
N = input()
S = input()
list_S = list(S)
N1 = 0
X = list_S.count('.')

if num == X:
    print('0')
else:
    for N in list_S:
        if list_S[N1] == '.':
            N1 += 1
        else:
            list_SS = list_S[N1:]
            X1 = list_SS.count('.')
            print(X1)
            break

### FIXED CODE ###

N = int(input())
S = input()                                                      
list_S = list(S)
N1 = 0
list_X =[]
X = list_S.count('.')
list_X.append(X)
    
for color in list_S:
    if list_S[N1] == '.':
        X -= 1
        list_X.append(X)
        N1 +=1
    else:
        X += 1
        list_X.append(X)
        N1 +=1

X = list_S.count('#') 
list_X.append(X)

X_MIN = min(list_X)
print(X_MIN)
s=input()
list=list(s)

a=700
print(list)
for i in range(len(list))
	if list[i]=="○":
		a=a+700
	else:
		a=a
print(a)

### FIXED CODE ###

s=input()
list=list(s)

a=700
#print(list)
for i in range(len(list)):
	if list[i]=="o":
		#print(list[i])
		a=a+100
	else:
		a=a
print(a)
N, M = list(map(int ,input().split()))
X = list(map(int, input().split()))
dis = []
if N >= M:
    print(0)
else:
    X.sort()
    for i in range(M):
        dis.append(abs(X[i+1] - X[i]))
    dis.sort()
    print(dis)
    ans = sum(dis[:-(N-1)])
    print(ans)

### FIXED CODE ###

N, M = list(map(int ,input().split()))
X = list(map(int, input().split()))
dis = []
if N >= M:
    print(0)
else:
    X.sort()
    for i in range(M-1):
        dis.append(abs(X[i+1] - X[i]))
    dis.sort(reverse=True)
    ans = max(X) - min(X) - sum(dis[:N-1])
    print(ans)
x = input()
cube = x * x * x
print(cube)



### FIXED CODE ###

x = int(input())
print(x ** 3)
a,b=map(int,input()split())
g=b
while a<b:
  g^=a
  a+=1
print(g)

### FIXED CODE ###

def calculate(A):
  c=(int((A+1)/2))%2
  if A%2==0:
    c=c^A
  return c

A,B=map(int,input().split())
print(calculate(A-1)^calculate(B))
h,w = map(int, input().split())
sl = []
for _ in range(h):
    row = list(input())
    sl.append(row)


dp = [ [10000]*h for _ in range(w) ]
dp[0][0] = 0

for wi in range(w):
    for hi in range(h):
        if wi+1 < w:
            if sl[wi][hi] == '.' and sl[wi+1][hi] == '#':
                dp[wi+1][hi] = min( dp[wi+1][hi], dp[wi][hi]+1 )
            else:
                dp[wi+1][hi] = min( dp[wi+1][hi], dp[wi][hi] )

        if hi+1 < h:
            if sl[wi][hi] == '.' and sl[wi][hi+1] == '#':
                dp[wi][hi+1] = min( dp[wi][hi+1], dp[wi][hi]+1 )
            else:
                dp[wi][hi+1] = min( dp[wi][hi+1], dp[wi][hi] )


ans = dp[w-1][h-1]
if sl[0][0] == '#': ans += 1
print(ans)


### FIXED CODE ###

h,w = map(int, input().split())
sl = []
for _ in range(h):
    row = list(input())
    sl.append(row)


dp = [ [10000]*w for _ in range(h) ]
dp[0][0] = 0

for h_i in range(h):
    for w_i in range(w):
        if h_i+1 < h:
            if sl[h_i][w_i] == '.' and sl[h_i+1][w_i] == '#':
                dp[h_i+1][w_i] = min( dp[h_i+1][w_i], dp[h_i][w_i]+1 )
            else:
                dp[h_i+1][w_i] = min( dp[h_i+1][w_i], dp[h_i][w_i] )

        if w_i+1 < w:
            if sl[h_i][w_i] == '.' and sl[h_i][w_i+1] == '#':
                dp[h_i][w_i+1] = min( dp[h_i][w_i+1], dp[h_i][w_i]+1 )
            else:
                dp[h_i][w_i+1] = min( dp[h_i][w_i+1], dp[h_i][w_i] )


ans = dp[h-1][w-1]
if sl[0][0] == '#': ans += 1
print(ans)
N=int(input())
l=list(map(int,input().split()))

if N>=2:
  for i in range(N):
    if l[i]<=l[i+1]:
      continue
    elif l[i]==l[i+1]-1:
      l[i+1]=l[i+1]-1
    else:
      print('No')
        
print('Yes')

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
 
before = 0
result = 'Yes'
for i in range(len(h)):
    if i == 0:
        before = h[i] - 1
    else:
        if before < h[i]:
            before = h[i] - 1
        elif before == h[i]:
            before = h[i]
        else:
            result = 'No'
print(result)
import sys
import fraction
DBG = True
a,b,c =      map(int, input().split())
g = math.gcd(a,b)
for i in range(b):
    if (g*i)%b == c:
        print('YES')
        sys.exit(0)
print('NO')


### FIXED CODE ###

import sys
import fractions
DBG = True
a,b,c =      map(int, input().split())
g = fractions.gcd(a,b)
for i in range(b):
    if (g*i)%b == c:
        print('YES')
        sys.exit(0)
print('NO')
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans = 1
for i in range(1, n):
    if t[i] == t[i - 1]:
        ans = ans * t[i] % mod
    if t[i] == a[i]:
        l = i
        break
for i in range(n - 1)[::-1]:
    if a[i] == a[i + 1]:
        ans = ans * a[i] % mod
    if t[i] == a[i]:
        r = i
        break

if n == 1:
    print(int(t == a))
elif t[l] != max(t) or a[r] != max(a):
    print(0)
else:
    print(ans * pow(t[l], max(r - l - 1, 0), mod) % mod)


### FIXED CODE ###

n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans, l, r = 1, 0, n - 1
for i in range(1, n):
    if t[i] == t[i - 1]:
        ans = ans * t[i] % mod
    if t[i] == a[i]:
        l = i
        break
for i in range(n - 1)[::-1]:
    if a[i] == a[i + 1]:
        ans = ans * a[i] % mod
    if t[i] == a[i]:
        r = i
        break

if t[l] != max(t) or a[r] != max(a) or max(t) != max(a):
    print(0)
else:
    print(ans * pow(t[l], max(r - l - 1, 0), mod) % mod)
a=1
while 1:
    i = int(raw_input())
    if i == 0:
        break
    else:
        print 'Case %d: %d'%(a, i)
        a += 1

### FIXED CODE ###

a=1
while True:
    i=int(input())
    if i==0:
        break
    else:
        print("Case {0:d}: {1:d}".format(a,i))
        a=a+1
INFTY = 100000000
n = int( raw_input() )
graph = {}
for i in range(n):
  In = map( int , raw_input().split('') )
  u = In[0]
  k = In[1]
  graph[u] = {}
  for j in range(k):
    v = In[2+j*2]
    c = In[2+j*2+1]
    graph[u][v] = c
 
da = {}
visited = {}
for i in range(n):
  da[i] = INFTY
  visited[i] = False
s = 0
da[s] = 0
visited[s] = True
 
while True:
  for i in range(n):
    if not visited[i] and i in graph[s] and da[i] > da[s] + graph[s][i]:
      da[i] = da[s] + graph[s][i]
  cost = INFTY
  node = -1
  for i in range(n):
    if not visited[i] and da[i] < cost:
      cost = da[i]
      node = i
  if cost == INFTY: break
  visited[node] = True
  s = node
  
for i in range(n):
  print i,da[i]

### FIXED CODE ###

INFTY = 100000000
n = int( raw_input() )
graph = {}
for i in range(n):
  In = map( int , raw_input().split(' ') )
  u = In[0]
  k = In[1]
  graph[u] = {}
  for j in range(k):
    v = In[2+j*2]
    c = In[2+j*2+1]
    graph[u][v] = c
 
da = {}
visited = {}
for i in range(n):
  da[i] = INFTY
  visited[i] = False
s = 0
da[s] = 0
visited[s] = True
 
while True:
  for i in range(n):
    if not visited[i] and i in graph[s] and da[i] > da[s] + graph[s][i]:
      da[i] = da[s] + graph[s][i]
  cost = INFTY
  node = -1
  for i in range(n):
    if not visited[i] and da[i] < cost:
      cost = da[i]
      node = i
  if cost == INFTY: 
    break
  visited[node] = True
  s = node
  
for i in range(n):
  print i,da[i]
n,*a=map(int,open(0).read().split())
ma=max(a)
ma_index=a.index(ma)
for i in range(n):
    if i==ma_index:
        print(*max(a[:i]+a[i+1:]))
    else:
        print(ma)

### FIXED CODE ###

n,*a=map(int,open(0).read().split())
ma=max(a)
ma_index=a.index(ma)
for i in range(n):
    if i==ma_index:
        print(max(a[:i]+a[i+1:]))
    else:
        print(ma)
n, k = map(int,input().sprit())
a = list(map(int,input().sprit()))
a.sort()
b = 0
for i in range(k):
	b += a[k]
print(b)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
total = 0
for i in range(k):
    total+=p[i]
print(total)
from math import sqrt
n=input()
for i in range(n):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
    A1=2*(x2-x1)
    B1=2*(y2-y1)
    C1=x2**2+y2**2-x1**2-y1**2
    A2=2*(x3-x2)
    B2=2*(y3-y2)
    C2=x3**2+y3**2-x2**2-y2**2
    x=(C1*B2-C2*B1)/(A1*B2-A2*B1)
    y=(A1*C2-A2*C1)/(A1*B2-A2*B1)
    R=sqrt((x1-x)**2+(y1-y)**2)
    print"%.3f %.3f %.3f"%(x,y,R)


### FIXED CODE ###

from math import sqrt
n=input()
for i in range(n):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
    A1=2*(x2-x1)
    B1=2*(y2-y1)
    C1=x2**2+y2**2-x1**2-y1**2
    A2=2*(x3-x2)
    B2=2*(y3-y2)
    C2=x3**2+y3**2-x2**2-y2**2
    x=(C1*B2-C2*B1)/(A1*B2-A2*B1)
    y=(A1*C2-A2*C1)/(A1*B2-A2*B1)
    R=sqrt((x1-x)**2+(y1-y)**2)
    print"%.3f %.3f %.3f"%(x,y,R)
n = int(input())
v = list(map(int, input().split()))

num = set(v)

if len(num) == 1:
    print(n//2)
else:
    value = []
    num = list(num)
    for i in range(len(num)):
        value.append(v.count(num[i]))

    value.sort()

    if len(num) == 3:
        print(value[0])
    elif len(num) == 2:
        print(0)
    else:
        print(sum(value.sort[0:2]))

### FIXED CODE ###

from collections import Counter

n = int(input())
v = list(map(int, input().split()))

e = Counter(v[::2]).most_common()
o = Counter(v[1::2]).most_common()

if len(set(v)) == 1:
    ans = n // 2
elif e[0][0] != o[0][0]:
    ans = n - e[0][1] - o[0][1]
else:
    ans = min(n - e[0][1] - o[1][1],
              n - e[1][1] - o[0][1])
print(ans)
n = int(input())
V = list(map(int,input().split()))

from collections import Counter

v1 = []
v2 = []
for i in range(0,n,2):
  v1.append(V[i])
for i in range(1,n,2):
  v2.append(V[i])
  
c1 = Counter(v1)
c2 = Counter(v2)

if list(c1.keys())[0] == list(c2.keys())[0]:
  a1 = sum(list(c1.values())[1:])+list(c2.values())[0]+sum(list(c2.values()[2:]))
  a2 = sum(list(c2.values())[1:])+list(c1.values())[0]+sum(list(c1.values()[2:]))
           
  ans = min(a1,a2)
  
else:
  ans = sum(list(c1.values())[1:])+sum(list(c2.values())[1:])

print(ans)

### FIXED CODE ###

n = int(input())
V = list(map(int,input().split()))

from collections import Counter

v1 = []
v2 = []
for i in range(0,n-1,2):
  v1.append(V[i])
for i in range(1,n,2):
  v2.append(V[i])
  
c1 = Counter(v1).most_common() + [(0,0)]
c2 = Counter(v2).most_common() + [(0,0)]

if c1[0][0] == c2[0][0]:
  a1 = n -c1[1][1]-c2[0][1]
  a2 = n -c1[0][1]-c2[1][1]
  ans = min(a1,a2)
  
else:
  ans = n-c1[0][1]-c2[0][1]

print(ans)
a = int(input())
s = str(input())
if a >= 3200:
 print("red")
if s < 2800:
 print(s)

### FIXED CODE ###

a = int(input())
s = str(input())
if a >= 3200:
 print(s)
if a < 3200:
 print("red")
X, A, B = map(int, input().split())
if A <= B:
    print("delicious")
if (B-A) <= X:
    pirnt("safe")
if X < (B-A):
    print("dangerous")


### FIXED CODE ###

X, A, B = map(int, input().split())
if B <= A:
    print("delicious")
else:
    if (B-A) <= X:
        print("safe")
    if (B-A) > X:
        print("dangerous")
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	A = list(rli())
	dp = [INF for _ in range(n)]
	dp[0] = 0
	for i in range(1, n):
		for j in range(i-k, i):
			dp[i] = min(dp[i], dp[j] + abs(A[j] - A[i]))
	print(dp[-1])
	stdout.close()

if __name__ == "__main__":
	main()

### FIXED CODE ###

from sys import stdin, stdout
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	H = list(rli())
	dp = [INF for _ in range(n)]
	dp[0] = 0
	for i in range(1, n):
		for j in range(max(0, i-k), i):
			cost = abs(H[j] - H[i])
			dp[i] = min(dp[i], dp[j] + cost)
	print(dp[-1])
	stdout.close()

if __name__ == "__main__":
	main()
#91b
import collections as c

n=int(input())
b_l=sorted([input() for _ in range(n)])
b=c.Counter(b_l)
b=b.most_common()

m=int(input())
r_l=sorted([input() for _ in range(m)])
r=c.Counter(r_l)
r=r.most_common()
ans=0
i=0
while i<=m-1:
    if b[i][0]==r[i][0]:
        temp=b[0][1]-r[0][1]
        i+=1
        if temp>0:
            ans=max(temp,ans)
print(ans)




### FIXED CODE ###

#91b
n=int(input())
s=[input() for _ in range(n)]

m=int(input())
t=[input() for _ in range(m)]
ans=0

st=set(s+t)
for i in st:
    ans = max(s.count(i) - t.count(i) , ans)
print(ans)
import collections
N = int(input())

cost = 0
diff_list = []

past_x, past_y = map(int, input().split())
cost += 1

for n in range(N - 1):
    x, y = map(int, input().split())
    diff_list.append((x - past_x, y - past_y))
    past_x = x
    past_y = y
    cost += 1

counter = collections.Counter(diff_list)

print(cost - max(counter.values()))

### FIXED CODE ###

import collections
import copy
import sys
N = int(input())

cost = 0
diff_list = []
x_y_list = []

if N == 1:
    print(1)
    sys.exit()

for n in range(N):
    x, y = map(int, input().split())
    x_y_list.append((x, y))
    cost += 1

x_y_list_copy = copy.copy(x_y_list)

for n in range(N):
    x_y = x_y_list.pop()
    x = x_y[0]
    y = x_y[1]
    for tmp_x, tmp_y in x_y_list:
        diff_list.append((x - tmp_x, y - tmp_y))

for n in range(N):
    x_y = x_y_list_copy.pop(0)
    x = x_y[0]
    y = x_y[1]
    for tmp_x, tmp_y in x_y_list_copy:
        diff_list.append((x - tmp_x, y - tmp_y))

counter = collections.Counter(diff_list)
print(cost - max(counter.values()))
import logging
 
logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)
 
N, X  = (int(x) for x in input().split())
L = list(int(x) for x in input().split())
 
logging.info(L)
 
length = 0
counter = 1
if X < L[0]:
    print(1)
else:
    for i in L:
        length += i
        if length > X or counter == N:
            break
        counter += 1
       
    print(counter

### FIXED CODE ###

import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

N, X  = (int(x) for x in input().split())
L = list(int(x) for x in input().split())

logging.info(L)

length = 0
counter = 1

for i in L:
    length += i
    if length <= X:
        counter += 1
    
print(counter)
import numpy　as np
N = int(input())
a = int(list(input())

count = [0] * N
for i in range(N):
  while(a[i] % 2== 1):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

### FIXED CODE ###

import numpy as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))
#abc047-b
w,h,n=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
#x,y,a
x_min=0
y_min=0

for i in l:
    if i[-1]==1:
        x_min=max(i[0],x_min)

    elif i[-1]==2:
        w=min(i[0],w)

    elif i[-1]==3:
        y_min=max(i[1],y_min)

    else:
        h=min(i[1],h)
s=
print((w-x_min)*(h-y_min) if (w-x_min)>0 and (h-y_min)>0 else 0)

### FIXED CODE ###

#abc047-b
w,h,n=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
#x,y,a
x_min=0
y_min=0

for i in l:
    if i[-1]==1:
        x_min=max(i[0],x_min)

    elif i[-1]==2:
        w=min(i[0],w)

    elif i[-1]==3:
        y_min=max(i[1],y_min)

    else:
        h=min(i[1],h)

print((w-x_min)*(h-y_min) if (w-x_min)>0 and (h-y_min)>0 else 0)
import sys
import collections

n = int(input())
xy = []
for _ in range(n):
    xy.append([int(i) for i in input().split()])
xy.sort()

cost_list = []
for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        x_sub = xy[j][0] - xy[i][0]
        y_sub = xy[j][1] - xy[i][1]
        cost_list.append('{},{}'.format(x_sub, y_sub))

cost_dic = collections.Counter(cost_list)
#print(cost_dic)
zero_cost_num = max(cost_dic.values())
#print(zero_cost_num)
ans = n - zero_cost_num

print(ans)


### FIXED CODE ###

import sys
import collections

n = int(input())
xy = []
for _ in range(n):
    xy.append([int(i) for i in input().split()])
xy.sort()

if len(xy) == 1:
    print(1)
    sys.exit()

cost_list = []
for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        x_sub = xy[j][0] - xy[i][0]
        y_sub = xy[j][1] - xy[i][1]
        cost_list.append('{},{}'.format(x_sub, y_sub))

cost_dic = collections.Counter(cost_list)
#print(cost_dic)
zero_cost_num = max(cost_dic.values())
#print(zero_cost_num)
ans = n - zero_cost_num

print(ans)
x=input()
print(x**3)

### FIXED CODE ###

x = int(input())
print(x**3)
n, m = map(int,input().split())
s = list(list(map(int, input().split())) for _ in range(m)) 
p = list(map(int,input().split()))
ans = 0
for i in range(1<<n):
    # 全switch(n)のon/offパターン数
    sw = [False]*m
    # 各電球の点灯リストを作成
    for j in range(M):
        # 各電球について
        cnt = 0
        for k in range(1,len(s[j])):
            if i>>s[j][k]-1&1:
                cnt += 1

        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)

### FIXED CODE ###

n, m = map(int,input().split())
s = list(list(map(int, input().split())) for _ in range(m)) 
p = list(map(int,input().split()))
ans = 0
for i in range(1<<n):
    # 全switch(n)のon/offパターン数
    sw = [False]*m
    # 各電球の点灯リストを作成
    for j in range(m):
        # 各電球について
        cnt = 0
        for k in range(1,len(s[j])):
            if i>>s[j][k]-1&1:
                cnt += 1
        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)
# ABC118A

a, b = map(int, input().split())
if b % a == 0:
    print(a+b)
else:
    print(b-a)


### FIXED CODE ###

# ABC118A

a, b = map(int, input().split())
if b % a == 0:
    print(a+b)
else:
    print(b-a)
from operator import mul
from functools import reduce

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

def com(n, k):
    if n == 0 or k == 0:
        return 1
    return int(reduce(mul, range(n + 1 - k, n + 1)) / reduce(mul, range(1, k + 1)))

idx_list = [-1] * (n + 2)
l = 0
r = 0
for i, a_i in enumerate(a):
    if idx_list[a_i] < 0:
        idx_list[a_i] = i
    else:
        l = idx_list[a_i]
        r = n - i
        break

for k in range(1, n + 2):
    m = k - 1
    dup = 0
    for l_n in range(0, m + 1):
        r_n = m - l_n
        if l_n > l or r_n > r:
            continue
        l_c = com(l, l_n)
        r_c = com(r, r_n)
        dup += l_c * r_c
    ans = (com(n + 1, k) - dup) % (10 ** 9 + 7)
    print(ans)

### FIXED CODE ###

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

b = []
if n % 2 == 0:
    for i in reversed(range(1, n, 2)):
        b.append(str(a[i]))
    for i in range(0, n, 2):
        b.append(str(a[i]))
else:
    for i in reversed(range(0, n + 1, 2)):
        b.append(str(a[i]))
    for i in range(1, n, 2):
        b.append(str(a[i]))

ans = ' '.join(b)
print(ans)
import numpy as np
n, k = map(int, input().split())
p = np.array(list(map(int, input().split())))
p += 1
ans = np.zeros(n-k+1)
for i in range(n-k+1):
    ans += p[i:k+i]
print(max(ans)/2)

### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
p = np.array(list(map(int, input().split())))
p += 1
sum_E = np.cumsum(p)
sum_e = np.append([0], sum_E)
ans = -1
for i in range(n-k+1):
    ans = max(ans, sum_e[i+k] - sum_e[i])
print(ans/2)
a = input()
b = int(a)
c = list(a)
t = int(a[0])
#print(t,a.count("9"))
if t != 9  and a.count("9") == len(a)-1:
    r = t+(len(a)-1)*9
elif a.count("9") != len(a):
    t -= 1
    r = t+(len(a)-1)*9
if b<9:
    r = b
    
print(r)

### FIXED CODE ###

a = input()
b = int(a)
c = list(a)
t = int(a[0])
r = t+(len(a)-1)*9
#print(t,a.count("9"))
if t != 9  and a.count("9") == len(a)-1:
    r = t+(len(a)-1)*9
elif a.count("9") != len(a):
    t -= 1
    r = t+(len(a)-1)*9
if b<9:
    r = b
elif b == 9:
    r = 9
    
print(r)
n = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

ans = 3
hats = [1, 0, 0]

for a in A[1:]:
    count = hats.count(a)
    idx = hats.index(a)
    hats[idx] += 1
    ans *= count
    ans %= mod

print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

ans = 3
hats = [1, 0, 0]

if n == 1:
    if A[0] == 0:
        print(3)
    else:
        print(0)
    exit()


if A[0] != 0:
    print(0)
    exit()
for a in A[1:]:
    count = hats.count(a)
    if count == 0:
        print(0)
        exit()

    idx = hats.index(a)
    hats[idx] += 1
    ans *= count
    ans %= mod

print(ans)