peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, k = map(int, input().split())
d = [0]*k
a = [0]*k

for i in range(k):
    d[i] = int(input()) 
    a[i] = list(map(int, input().split()))

ans = [0]*100

for i in range(k):
    for j in range(d[i]):
        ans[a[i][j]-1] = 1

print(n-sum(ans))
# Judge status: Accepted
S = input()

if S == ('Sunny'):
    print('Cloudy')
elif S == ('Cloudy'):
    print('Rainy')
elif S == ('Rainy'):
    print('Sunny')
else:
    print('入力に誤りがあります。Sunny,Cloudy,Rainyのいずれかを入力してください。')
# Judge status: Accepted
n = int(input())
lis = list(map(int,input().split()))

lis.sort()

ans1 = lis[-1]

lis = lis[:-1]
half = ans1/2

ans2 = 0
length = 10**9+7

for i in lis:
    t = abs(half - i)
    if t < length:
        length = t
        ans2 = i
    

print(ans1, ans2)
# Judge status: Wrong Answer
N = int(input())

if N >= 4:
    if N % 4 == 0:
        print("Yes")
    elif N % 4 == 3:
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Accepted
S = input()
N = int(S[5]) * 10 + int(S[6])
print("Heisei" if N <= 4 else "TBD")
# Judge status: Wrong Answer
import string

s = input()

lall = [chr(i) for i in range(97, 97+26)]
#print(lall)

for x in lall:
    if x not in s:
        print(x)
        break
# Judge status: Accepted
import math

def resolve():

    n = int(input())
    values = list(map(int, input().split(' ')))

    values.sort(reverse=True)

    ans = 0

    for i in range(1, n):

        ans += values[math.floor(i / 2)]

    print(ans)


resolve()
# Judge status: Accepted
import sys
input = sys.stdin.readline

N, H = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

tmp = 0
for a, b in AB:
    tmp = max(tmp, a)

AB.sort(key = lambda x: x[1], reverse = True)

count = 0
for a, b, in AB:
    if b > tmp:
        H -= b
        count += 1
        if H <= 0:
            print (count)
            exit()
    else:
        break

count += (H + tmp - 1) // tmp
print (count)
# Judge status: Accepted
s = input()

ans = True

while len(s) > 0:
    if len(s) == 1:
        print('No')
        exit(0)
    if s[0] == 'h' and s[1] == 'i':
        s = s[2:]
    else:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main():
  n=int(input())
  num = list(map(int,input().split()))
  ave=round(sum(num)/len(num))
  ans=0
  for i in range(0,len(num)):
    ans+=(ave-num[i])*(ave-num[i])
  print(ans)

main()
# Judge status: Accepted
n,k,s = map(int,input().split())

o = 10 ** 9
if s == 10 ** 9:
    o = 1

res = [s] * k + [o] * (n - k)
print(*res)
# Judge status: Accepted
N, A, B, C, D = map(lambda  x: int(x) - 1, input().split())
S = input()
if C < D:
    if "##" in S[A: D + 1]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in S[A: D + 1] or not("..." in S[B - 1: D + 2]):
        print("No")
    else:
        print("Yes")
# Judge status: Accepted
n,x=map(int,input().split())
l=list(map(int,input().split()))
tmp=0
ans=1
for i in range(n):
    tmp+=l[i]
    if tmp<=x:
        ans+=1
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
d = set(map(int, input().split()))

while True:
    str_n = str(n)
    hantei = 1
    for i in range(len(str_n)):
        if int(str_n[i]) in d: hantei = 0
    if hantei == 1: break
    n += 1

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

new=a+a

new=sorted(new, reverse=True)

ans=0

for i in range(1, n):
    ans+=new[i]

print(ans)
# Judge status: Wrong Answer
import math
N,D = map(int,input().split())

A = [list(map(int, input().split()))  for i in range(N)]
count = 0
for i in range(N-1):
    a = math.sqrt((A[i][0]**2+(A[i][1])**2))
    if a <= D:
        count += 1

print(count)
# Judge status: Wrong Answer
num = int(input())
a = num // 100
b = num // 10 - (a * 10)
c = num - (a * 100) - (b * 10)
print(num)
print(a, b, c)
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
  A[i] -= 1

loop_lis = [0]
visited = [0 for _ in range(N)]
visited[0] = 1
loop_time = 0
start_loop = 0
for i in range(K):
  if visited[A[loop_lis[-1]]] != 0:
    loop_time = (i+2)-(visited[A[loop_lis[-1]]])
    start_loop = i+1 - loop_time
    break
  visited[A[loop_lis[-1]]] = i+1
  loop_lis.append(A[loop_lis[-1]])
if len(loop_lis) == K+1:
  print(loop_lis[-1]+1)
else:
  print(loop_lis[start_loop+(K-start_loop)%loop_time]+1)
# Judge status: Accepted
S = input()
if S[0] == "A":
    count = 0
    S2 = S[2:-1]
    for i in S2:
        if i == "C":
            count += 1
    if count == 1:
        S3 = S[1:].replace("C","")
        if S3.islower():
            print("AC")
            exit()
print("WA")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
bon = []
for i in range(n):
  ri = n - i - 1
  if sum(b[ri::ri+1]) % 2 != a[ri]:
    b[ri] = 1
    bon.append(ri+1)
print(len(bon))
print(*bon)
# Judge status: Wrong Answer
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(N)]

cd = [tuple(map(int, input().split())) for i in range(M)]


for a, b in ab:
    ret = 0
    dis = 10**20
    for i, x in enumerate(cd):
        c, d = x
        if dis > (c-a)**2 + (d-b)**2:
            dis = (c-a)**2 + (d-b)**2
            ret = i
    print(ret+1)
# Judge status: Accepted
def gcd(a,b):
    if a < b:
        a,b = b,a
    if b != 0:
        return gcd(b,a%b)
    return a

def solve(n,ts):
    a = ts[0]
    for i in range(n):
        b = ts[i]
        c = gcd(a,b)
        a = a*b//c
    return a

if __name__ == '__main__':
    n = int(input())
    ts = [int(input()) for i in range(n)]
    print(solve(n,ts))
# Judge status: Accepted
W,H,x,y = map(int,input().split())
if x == W/2 and y == H/2:
    ans = 1
else:
    ans = 0
print(W*H/2,ans)
# Judge status: Wrong Answer
x = int(input())
a = 0
for i in range(1,10*10):
    a += i
    if a >= x :
        print(i)
        break
# Judge status: Accepted
#!/usr/bin/env python
import math

n = int(input())
ans = 0 
for i in range(1, n): 
    if n%i == 0:
        ans += n//i-1
    else:
        ans += n//i
print(ans)
# Judge status: Accepted
H,N=map(int,input().split())
A=[]
B=[]
for i in range(N):
   a,b=map(int,input().split())
   A.append(a)
   B.append(b)

DP=[[0]*(H+max(A)) for i in range(N)]
DP.insert(0,[10**8+1]*(H+max(A)))
DP[0][0]=0

for i in range(1,N+1):
   for j in range(1,H+1):
      if j-A[i-1]>0:
         DP[i][j]=min(DP[i-1][j],DP[i][j-A[i-1]]+B[i-1])
      else:
         DP[i][j]=min(DP[i-1][j],B[i-1])

print(DP[N][H])
# Judge status: Wrong Answer
A, B = map(str, input().split())
B = float(B)
A = int(A)
import math
a = A*B

a = math.floor(a)

print(a)
# Judge status: Accepted
s = str(input())
for i in range(len(s)):
  if s[i] == 'A':
    start = i
    break
for i in range(len(s)):
  if s[len(s)-1-i] == 'Z':
    stop = len(s)-i
    break
ans = stop-start
print(ans)
# Judge status: Accepted
N, A, B = map(int, input().split())

diff = B - A
if diff % 2 == 0:
    print(diff // 2)
else:
    print(min(A - 1, N - B) + 1 + ((diff - 1) // 2))
# Judge status: Wrong Answer
n,m,k = map(int,input().split())

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

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


c = [0]
d = 0
for i in range(n):
    d += a[i]
    c.append(d)

e = [0]
f = 0
for i in range(m):
    f += b[i]
    e.append(f)


ans = 0
j = m
for i in range(n):
    if c[i] > k:
        break
    else:
        while c[i] + e[j] > k:
            j -= 1
    ans = max(i + j,ans)

print(ans)
# Judge status: Wrong Answer
all = list(map(int, input().split()))

N = all[0]
Y = all[1]

check = 0
for i in range(N):
    for j in range(N-i):
        total = 10000*i + 5000*j + 1000*(N-(i+j))
        if Y!=total:
            continue
        else:
            yu = i
            hi = j
            no = (N-(i+j))
            check += 1

if check==0:
    yu = -1
    hi = -1
    no = -1

print(str(yu) + " " + str(hi) + " " + str(no))
# Judge status: Accepted
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')

def solve():
    N = int(input())
    X = it()
    a = 0 
    for x in X:
        a = a ^ x
    
    ans = ''
    for x in X:
        ans += str(x ^ a) + ' '
    print(ans)

if __name__ == '__main__':
    solve()
# Judge status: Accepted
# C
#C

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

sc = {i+1:[] for i in range(N)}

for _ in range(M):
  si, ci = map(int, input().split())
  sc[si] += [ci]

sc = {k:list(set(v)) for k,v in sc.items()}

flag = True

if N>1 and 0 in sc[1]:
  flag = False

for v in sc.values():
  if len(v)>1:
    flag = False


ans = -1

if flag:
  cand = [0]*N
  if N>1:
    cand[0] = 1
  for k, v in sc.items():
    if len(v)>0:
      cand[k-1] = v[0]
  ans = "".join([str(c) for c in cand])

print(ans)
# Judge status: Accepted
N, *A = map(int, open(0).read().split())

C = {}
for a in A:
    if a in C.keys():
        C[a] += 1
    else:
        C[a] = 1
B = list(C.items())
B.sort(key=lambda x: x[0])

M = len(B)
ans = 0
for i in range(M):
    count = B[i][1]
    if i-1 >= 0 and B[i-1][0] == B[i][0]-1:
        count += B[i-1][1]
    if i+1 < M and B[i+1][0] == B[i][0]+1:
        count += B[i+1][1]
    ans = max(ans, count)
print(ans)
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(1,n):
  k = n//i
  ans += i*(k*(k+1)//2)

print(ans)
# Judge status: Accepted
S = input()
ans = 0

if S[0]=="0":
  ans += S[0::2].count("1")
  ans += S[1::2].count("0")
  
else:
  ans += S[0::2].count("0")
  ans += S[1::2].count("1")
  
print(ans)
# Judge status: Accepted
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = min(a)+min(b)
for i in range(M):
    x,y,c = map(int,input().split())
    ans = min(ans,a[x-1]+b[y-1]-c)
    
print(ans)
# Judge status: Accepted
x,y=map(int,input().split())
cnt=0
num=x
while(num<=y):
    num*=2
    cnt+=1
print(cnt)
# Judge status: Accepted
def solve(n, a_list):
    if len(set(a_list)) == n:
        return "YES"
    else:
        return "NO"


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    res = solve(n, a_list)
    print(res)


def test():
    assert solve(5, [2, 6, 1, 4, 5]) == "YES"
    assert solve(6, [4, 1, 3, 1, 6, 2]) == "NO"
    assert solve(2, [10000000, 10000000]) == "NO"


if __name__ == "__main__":
    test()
    main()
# Judge status: Wrong Answer
n=int(input())
m=0
t1,t2=map(int,input().split())
for i in range(n-1):
    x,y=map(int,input().split())
    xn=(x-t1)
    yn=(y-t2)
    
    if xn<0:
        xn=xn*(-1)
    
    if yn<0:
        yn=yn*(-1)
    
    l=xn+yn
    
    t1=x
    t2=y
    
    if l>m:
        m=l
    
print(m)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
result = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        result *= A[i]
        if result > 10**18:
            print(-1)
            quit()
    print(result)
# Judge status: Accepted
k, x = map(int, input().split())
s = x - k + 1
e = x + k - 1

list = []
for i in range(s, e +1):
  list.append(i)

print(*list)
# Judge status: Accepted
'''
Created on 2020/08/28

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,M=map(int,pin().split())
  if 2*N>M:
    print(M//2)
  else:
    print(N+((M-2*N)//4))
  return 

main()
# Judge status: Wrong Answer
N=int(input())


if(N%2==0):
    print(N/2)
else:
    print(N//2+1)
# Judge status: Accepted
N, A, B=map(int, input().split())

def fun(x):
  s=list(str(x))
  wa=0
  for p in s:
    wa+=int(p)
  return wa
ans=0
for i in range(1,N+1):
  tmp=fun(i)
  if A<=tmp and tmp<=B:
    ans+=i

print(ans)
# Judge status: Accepted
url = "https://atcoder.jp/contests/abc088/tasks/abc088_b"

def main():
    g = input()
    lis = list(map(int, input().split()))
    lis.sort(reverse=True)
    a = 0
    b = 0
    for i in range(len(lis)):
        if i % 2 == 0:
            a += lis[i]
        else:
            b += lis[i]
    print(a - b)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from math import gcd

n=int(input())
a=list(map(int,input().split()))
if n==2:
  print(max(a))
  exit()
  
a.sort()

pin=a[0]
pin2=a[1]

lst=[]
lst2=[]

for i in a:
  lst.append(gcd(pin,i))
  lst2.append(gcd(pin2,i))
  
lst.sort()
lst2.sort()

print(max(lst[1],lst2[1]))
# Judge status: Accepted
def main():
    length, sum_num, subarray_sum = map(int, input().split())
    answer = [subarray_sum] * sum_num
    if subarray_sum == 10 ** 9:
        answer += [1] * (length - sum_num)
    else:
        answer += [subarray_sum + 1] * (length - sum_num)
    print(" ".join(map(str, answer)))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a>=10:
  print(b)
else:
  print(b+100*(10-b))
# Judge status: Wrong Answer
X,Y,Z=map(int,input().split())
for i in range((X//Y)+1):
	if X<(i*Y+(i+1)*Z):
		print(i-1)
		break
# Judge status: Wrong Answer
S = input()
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
  print("Bad")
else:
  print("Yes")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
K = {}
A.sort()
before = -1
for i in A:
    c = 2
    if before == i:
        K[i] = 1
    while(True):
        if i*c > 2*(10**5):
            break
        K[i*c] = 1
        c += 1
    before = i
t = 0
for i in A:
    if i in K:
        t += 1
print(N-t)
# Judge status: Wrong Answer
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t = input()
d = [0]*3*10**5
for i in range(n):
  if t[i] == 'r':
    d[i] = 2*10**4+p
  if t[i] == 's':
    d[i] = 4*10**4+r
  if t[i] == 'p':
    d[i] = 6*10**4+s
ans = 0
for i in range(n):
  if d[i] == d[k+i]:
    d[k+i] = 0
  ans += d[i]%(10**4)
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))

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

print('\n'.join(map(str, a)))
# Judge status: Wrong Answer
def main():
    s = list(input())
    for i in range(len(s)):
        if i == 0 and s[0] == "?":
            s[0] = "P"
        elif s[i] == "?":
            s[i] = "D"
    print(*s, sep="")


if __name__ == "__main__":
    main()
# Judge status: Accepted
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

diff1 = c21 - c11
diff2 = c31 - c21
if diff1 == (c22-c12) and diff2 == (c32-c22) and diff1 == (c23-c13) and diff2 == (c33-c23):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
# -*- coding: utf-8 -*-

n = list(str(input()))

if n[0:3].count(n[0]) == 3 or n[1:].count(n[1]) == 3:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
# A
N = input()
N_i = int(N)
N_s = list(N)


for i in range(0,17):
  if N_i < 10 ** i:
    break
flag = True
for j in range(0,i-1):
  if N_s[j] != "9":
    flag = False
    break

if flag == True:
  # 最上位を除いたすべての桁が9
   print(int(N_s[0])+9*(len(N_s)-1))
else:
   print(int(N_s[0])+9*(len(N_s)-1)-1)
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))
for i in range(n):
    A[i]-=i+1
A.sort()
c=A[n//2]
ans=0
for a in A:
    ans+=abs(a-c)
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
x=max(a,b,c)
y=min(a,b,c)
z=a+b+c-x-y
if (z-y)%2==0:
  print(x-z+(z-y)//2)
else:
  print(x-z+1+(z-y+1)//2)
# Judge status: Accepted
def main():
    n,k = map(int,input().split())
    s = list(input())
    s[k - 1] = chr(ord(s[k - 1]) + 32)
    t = ''
    for i in s:
        t = t + i
    print(t)
main()
# Judge status: Accepted
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
d = defaultdict(int)
for i in [input() for j in range(n)]:
  d["".join(sorted(i))]+=1

from math import factorial as f

ans = 0
for i in d:
  if d[i]>1:
    ans+=f(d[i])//f(2)//f(d[i]-2)

print(ans)
# Judge status: Wrong Answer
# x2y3 - y2x3 = S
s = int(input())
if s == 10**19:
	print(0, 0, 10**9, 10**9, 0, 10**9)
	exit()
x_2 = 10**9
x_3 = 10**9 - s%(10**9)
y_2 = 1
y_3 = s//(10**9) + 1
print(0, 0, x_2, x_3, y_2, y_3)
# Judge status: Accepted
import math
import calendar
import fractions
import itertools

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

if c < a:
    if d < a:
        print(0)
    elif a <= d <= b:
        print(d - a)
    else:
        print(b - a)
elif a <= c <= b:
    print(min(d - c, b - c))
else:
    print(0)
# Judge status: Accepted
a, x =map(int, input().split())
if (a+x)%2 ==0:
  print(int((a+x)/2))
else:
  print('IMPOSSIBLE')
# Judge status: Wrong Answer
S = input("")
if len(S)<6:
    print("If S is coffee-like, print 'Yes';")
else:
    if ((S[2]) == (S[3])):
        if ((S[4]) == (S[5])):
            if S.islower():
                print ("Yes")
            else:
                print ("No")
    else:
        print("No")
# Judge status: Accepted
import itertools
import math

n = int(input())
X = [[] for _ in range(n)]
Y = [[] for _ in range(n)]

for i in range(n):
    X[i], Y[i] = map(int, input().split())

Dist = [0 for _ in range(math.factorial(n))]
for i, S in enumerate(itertools.permutations(range(n))):
    for j in range(len(S) - 1):
        Dist[i] += ((X[S[j+1]] - X[S[j]])**2 + (Y[S[j+1]] - Y[S[j]])**2)**(1/2)
print(sum(Dist)/len(Dist))
# Judge status: Accepted
a, b = map(int, input().split())
k = (a * a - b * b) / (2 * a - 2 * b)
if k == int(k):
    print(int(k))
else:
    print('IMPOSSIBLE')
# Judge status: Wrong Answer
N = int(input())


def get_max(nums):
    for num in nums:
        if num % 10 != 0:
            return num
    return 0


# accumulateは使わない
scores = sorted([int(input()) for i in range(N)])[::-1]
accum = [scores[0]]
# 降順になったscoresで数字を足し込んでいく（後半になるほど増加分を少なくする）
for i in range(1, N):
    accum.append(accum[i-1] + scores[i])

# 逆順にすることでスキップしたときの減少を抑える
print(get_max(accum[::-1]))
# Judge status: Accepted
A,B = map(int,input().split())
if A > 9 or B > 9:
    print("-1")
else: 
    print(str(A * B))
# Judge status: Accepted
N = int(input())
A = tuple(map(int, input().split()))
MOD = 10**9+7

arr = [0] * 60
for a in A:
    for i in range(60):
        if a>>i & 1:
            arr[59-i] += 1

ans = 0
for i, a in enumerate(arr):
    b = N - a
    ans += (a*b) * (2**(59-i))
    ans %= MOD
print(ans)
# Judge status: Accepted
import sys

a, b = map(int, sys.stdin.readline().split())

def main():
    c = a + b
    return 'IMPOSSIBLE' if c & 1 else c // 2

if __name__ == '__main__':
    ans = main()
    print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
d = {}

for i in range(1,n):
    d[i] = 0

for _ in range(m):
    a, b = map(int, input().split())
    if d[a] < b:
        d[a] = b

if d[d[1]] == n:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Judge status: Accepted
s = input()
a = ""
for i in range(len(s)):
  a += "x"
print(a)
# Judge status: Accepted
N, K = [int(i) for i in input().split()]
cnt = 0
sunuke_dict = {}
for i in range(1, N+1):
    sunuke_dict[i] = 0
    
while cnt < K:
    cnt += 1
    d = int(input())
    sunuke_list = [int(i) for i in input().split()]
    for sunuke in sunuke_list:
        sunuke_dict[sunuke] = 1

result = [key for key, value in sunuke_dict.items() if value == 0]
print(len(result))
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
x,k,d=map(int,input().split())
x+=d*k
m=abs(x)
for i in range(k+1):
  x-=d*2
  if i==k:
    print(m)
  else:
    if abs(x)<m:
      m=abs(x)
    else:
      print(m)
# Judge status: Accepted
N, M = map(int, input().split())
A = [input() for a in range(N)]
B = [input() for b in range(M)]
ans = False
for h in range(N - M + 1):
    for w in range(N - M + 1):
        if ans == True:
            break
        for m in range(M):
            if A[h + m][w:w + M] == B[m]:
                pass
            else:
                ans = False
                break
            ans = True
if ans == True:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N,K = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(N)]

ls.sort(key=lambda x: x[0])
s = 0

for i in range(N):
  s += ls[i][1]
  if s >= K: break
    
print(ls[i][0])
# Judge status: Accepted
N,P = map(int,input().split())
A = list(map(int,input().split()))

odd = 0
for v in A:
    if  v % 2:
        odd += 1 
even = N-odd
if odd != 0:
    print((2**even)*int(2**(odd-1)))
else:
    if P == 0:
        print(2**N)
    else:
        print(0)
# Judge status: Accepted

from collections import defaultdict
from typing import DefaultDict

from collections import defaultdict

N = int(input())
A = [int(i) for i in input().split()]
di_A = defaultdict(int)

for a in A:
    di_A[a] += 1

Q = int(input())
now_sum = sum(A)
ans = []
for _ in range(Q):
    b, c = [int(i) for i in input().split()]
    cnt = di_A[b]
    now_sum += cnt * (c-b) 
    di_A[b] = 0
    di_A[c] += cnt
    ans.append(now_sum)

for a in ans:
    print(a)
# Judge status: Accepted
n,m = map(int,input().split())
lst = [[] for i in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    lst[a-1].append(b-1)
    lst[b-1].append(a-1)

for v in lst:
    print(len(v))
# Judge status: Wrong Answer
n,C,T=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
res=t[0]+T
cnt=1
ans=0
for i in range(n):
  if t[i]<=res and cnt<C:
    cnt+=1
  elif t[i]>res or cnt==C:
    ans+=1
    res=t[i]+T
    cnt=1
print(ans+1)
# Judge status: Accepted
a, b = map(int, input().split())
if a <= 0 <= b:
    print("Zero")
elif b < 0 and (b - a) % 2 == 0:
    print("Negative")
else:
    print("Positive")
# Judge status: Accepted
#D
import math
import numpy as np
n = int(input())
num = np.zeros((10, 10))
for i in range(1, n + 1):
    a = i // pow(10, (int(math.log10(i))))
    b = i % 10
    num[b][a] += 1
ans=0
for i in range(10):
    for j in range(10):
        ans += num[i][j] * num[j][i]
print(int(ans))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

i = 0
while i < n-1:
    x = a[i+1] % a[i]
    a[i+1] = a[i]
    a[i] = x
    if a[i] == 0:
        i += 1
print(a[i])
# Judge status: Wrong Answer
n=int(input())
s=list(input())
sw=[0]
se=[0]
swc=0
sec=0
for i in range(n):
    if s[i]=='W':
        swc+=1
    else:
        sec+=1
    sw.append(swc)
    se.append(sec)
m=n
for i in range(n):
    m=min(m,sw[i]+se[-1]-se[i])
print(m)
# Judge status: Wrong Answer
a, b, n = map(int, input().split())

cand = []

def calc(n):
  return int(a*n/b)-a*int(n/b)

cand.append(calc(0))
cand.append(calc(n))
cand.append(calc(n-1))
cand.append(max(0, calc(b*(n//b) - 1)))
cand.append(max(0, calc(b*(n//b) - 2)))
cand.append(calc(min(n, b-1)))
cand.append(calc(min(n, b-2)))

print(max(cand))
# Judge status: Accepted
n = int(input())
ab = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[1])

t = 0
for a,b in ab:
  t += a
  if t > b:
    print("No")
    exit()
print("Yes")
# Judge status: Accepted
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    x = int(input())
    if x == 1:
        print(0)
    else:
        print(1)
    

    
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

def main():
    scores = [i*400 for i in range(1, 8)]
    scores.reverse()

    scores_d = {}
    input()
    god = []
    for a in map(int,input().split()):
        if a >= 3200:
            god.append(a)
        for i in scores:
            if a >= i:
                scores_d[i] = 1
                break

    counts = sum(scores_d.values())
    print(counts, counts + min(len(god), 8))

main()
# Judge status: Accepted
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
s=s[:-1]
while len(s)>0:
    if s[:len(s)//2]==s[len(s)//2:]:
        print(len(s))
        exit()
    s=s[:-1]