Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(1500)
n=int(input())
arr=list(map(int,input().split()))
vis={}
def count(n):
    if n in vis:
        return vis[n]
    if n<2:
        return 0
    if n==2:
        vis[n]=abs(arr[n-1]-arr[n-2])+count(n-1)
    if n>=3:
        vis[n]=min(abs(arr[n-1]-arr[n-2])+count(n-1),(abs(arr[n-1]-arr[n-3])+count(n-2)))
    return vis[n]
print(count(n))

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
tailA = 0
both = 0
c = 0
for i in range(int(input())):
    t = input()
    if t[0] =='B' and t[-1]=='A':
        both+=1
    elif t[0] == 'B':
        headB+=1
    elif t[-1] == 'A':
        tailA +=1
    c+=t.count('AB')
if both>0:
    c+=both-1
    headB+=1
    tailA+=1
print(c+min(headB,tailA))


### FIXED CODE ###

headB = 0
tailA = 0
both = 0
c = 0
for i in range(int(input())):
    t = input()
    if t[0] =='B' and t[-1]=='A':
        both+=1
    elif t[0] == 'B':
        headB+=1
    elif t[-1] == 'A':
        tailA +=1
    c+=t.count('AB')
if both>0:
    if tailA+headB>0:
        if tailA:
            c+=1
            tailA-=1
        if headB:
            c+=1
            headB-=1
        c+=min(headB,tailA)
        c+=both-1
    else:
        c+=both-1
else:
    c+=min(tailA,headB)
print(c)
n = int(input())
x = [0 for i in range(10**5+1)]
for i in range(n):
    t = int(input())
    x[t]+=1
    if x[t]==2:
        x[t]=0
print(x.count(1))

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
dict = {}
for i in a:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1
ans = 0
for i in dict:
    if dict[i]%2==0:
        continue
    else:
        ans += 1
print(ans)
def main():
    N, K, Q = [int(i) for i in input().split()]
    L = [0] * N
    Submits = [int(input()) for _ in range(Q)]

    for submit in Submits:
        L[submit] =  L[submit] + 1
    
    for chk in L:
        if K - Q + chk > 0:
            print("Yes")
        else:
            print("No")



if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import Counter

def main():
    N, K, Q = [int(i) for i in input().split()]
    Submits = Counter([int(input()) for _ in range(Q)])
    for n in range(1, N + 1):
        try:
            if K - Q + Submits[n] > 0:
                print("Yes")
            else:
                print("No")
        except:
            print("No")


if __name__ == "__main__":
    main()
loop_count = int(input())

ac_count = 0
wa_count = 0
tle_count = 0
re_count = 0

for i in range(loop_count):
    result = input()
    if result == 'AC':
        ac_count += 1
    elif result == 'WA':
        wa_count += 1
    elif result == 'TLE':
        tle_count += 1
    else:
        re_count += 1

print("AC x {0}".format(str(ac_count)))
print("WA x {0}".format(str(wa_count)))
print("TLE x {0}".format(str(tle_count)))
print("RE x {0}".format(str(re_count)))




### FIXED CODE ###

money = int(input())

for i in range(1, 11):
    if money <= i * 1000 :
        print(i * 1000 - money)
        exit()
    else:
        pass
from collections import deque

def solve(s):
    que = deque()
    que.append(s)
    while len(que) > 0:
        top = que.pop()
        if top == '':
            return 'YES'

        if top[:5] == 'dream':
            if top[5:7] == 'er':
                que.append(s[:7])
            que.append(s[:5])
        elif top[:5] == 'erase':
            if top[5] == 'r':
                que.append(top[:6])
            else:
                que.append(top[:5])
    return 'NO'

print(solve(input()))


### FIXED CODE ###

from collections import deque

def solve(s):
    stack = deque()
    stack.append(s)
    while len(stack) > 0:
        top = stack.pop()
        if top == '':
            return 'YES'

        if top[:5] == 'dream':
            if top[5:7] == 'er':
                stack.append(top[7:])
            stack.append(top[5:])
        elif top[:5] == 'erase':
            if len(top) > 5 and top[5] == 'r':
                stack.append(top[6:])
            else:
                stack.append(top[5:])
    return 'NO'

print(solve(input()))
s=list(input())

l=[]
cnt=0

for i in s:
  if i=='A' or i=='C' or i=='G' or i=='T':
    cnt+=1
  else:
    if cnt!=0:
      l.append(cnt)
      cnt=0

print(max(l))

### FIXED CODE ###

s=list(input())

l=[]
cnt=0

for i in s:
  if i=='A' or i=='C' or i=='G' or i=='T':
    cnt+=1
  else:
    if cnt!=0:
      l.append(cnt)
      cnt=0

l.append(cnt)
print(max(l))
N=int(input())

A = set(map(int, input().split()))
print(Len(A))





### FIXED CODE ###

N=int(input())

A = list(map(int, input().split()))
if len(A)==3:
  print(1)
elif (len(A)-len(set(A)))%2==1:
  print(len(set(A))-1)
else:
  print(len(set(A)))
N, K = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
K = K-1
ans = -10**9-1
for i in range(N):
   i += 1
   start = i
   number = 1
   circle = [c[i-1]]
   i = p[i-1]
   while i != start:
      number += 1
      l = len(circle)
      score = circle[l-1] + c[i-1]
      circle.append(score)
      i = p[i-1]
   for j in range(min(l, K+1):
      if circle[l-1] > 0:
         score = circle[j] + ((K - j)//l)*circle[l-1]
      else:
         score = circle[j]
      ans = max(score, ans)      
print(ans)

### FIXED CODE ###

N, K = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
K = K-1
ans = -10**9-1
for h in range(N):
   i = h+1
   start = i
   circle = [c[i-1]]
   i = p[i-1]
   while i != start:
      score = circle[-1] + c[i-1]
      circle.append(score)
      i = p[i-1]
   l=len(circle)
   for j in range(min(l, K+1)):
      if circle[l-1] > 0:
         score = circle[j] + ((K - j)//l)*circle[l-1]
      else:
         score = circle[j]
      ans = max(score, ans)      
print(ans)
from scipy.misc import comb
from collections import defaultdict
from collections import deque
d = defaultdict(lambda: -1)
d_ = defaultdict(lambda: -1)
n = int(input())
a = deque([int(x) for x in input().split()])

for i in a:
  a_ = a.copy()
  b = a_.remove(i)
  if d[str(b)] != -1:
    print(d[str(b)])
    continue
  A = list(set(a_))
  ans = 0
  for j in A:
    c = a_.count(j)
    if d_[str(c)] != -1:
      ans += d_[str(c)]
    else:
      e = comb(c, 2, exact=True)
      ans += e
      d_[str(c)] = e

  d[str(b)] = ans
  print(ans)




### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict
d = defaultdict(int)
for i in a:
  d[i] += 1

total = 0
for i in set(a):
  x = d[i]
  total += x*(x-1)/2

for i in a:
  x = d[i]
  print(int(total-((x*(x-1)/2))+((x-1)*(x-2)/2)))
n=int(input())
a=list(map(int,input().split()))
ans=sum(a)
q=int(input())
dp=[0]*(10**5)
for i in range(1,10**5):
  dp[i]=a.count(i)

for j in range(q):
  b,c=map(int,input().split())
  ans+=(c-b)*dp[b]
  dp[c]=dp[b]+dp[c]
  dp[b]=0
  print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=sum(a)
q=int(input())
dp=[0]*(10**5+1)
for i in a:
  dp[i]+=1

for j in range(q):
  b,c=map(int,input().split())
  ans+=(c-b)*dp[b]
  dp[c]+=dp[b]
  dp[b]=0
  print(ans)
N,M=map(int,input().split())
if M%N==0:
  print(M//N)
else:
  s=M//N
  if s<100000:
    ans=1
    while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)
  else:
    rM=M**(1/2)
    s=N
    ans=1
    while s<=rM:
      if M%s==0:
        ans=M//s
        break
      s+=1
    if N<rM:
      nya-n
      
    print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
if M%N==0:
  print(M//N)
else:
  s=M//N
  if s<100000:
    ans=1
    while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)
  else:
    rM=M**(1/2)
    s=N
    ans=1
    while s<=rM:
      if M%s==0:
        ans=M//s
        break
      s+=1
    else:
      s=N
      while s!=1:
        if M%s==0:
          ans=s
          break
        s-=1
    print(ans)
N=int(input())
P=list(map(int, input().split()))
X=[0]+list(map(int, input().split()))
ko=[[] for _ in range(N+1)]
for i, p in enumerate(P, 2):
  ko[p].append(i)
  
def f(p):
  n=len(ko[p])
  if n==0:
    return X[p], 0
  
  dp=[[float('inf')]*(X[p]+1) for _ in range(n+1)]
  dp[0][0]=0
  for i, c in enumerate(ko[p], 1):
    a, b=f(c)
    for j in range(a, 5001):
      dp[i][j]=min(dp[i][j], dp[i-1][j-a]+b)
    for j in range(b, 5001):
      dp[i][j]=min(dp[i][j], dp[i-1][j-b]+a)
      
  out=min(dp[-1])
  if out==float('inf'):
    print('IMPOSSIBLE')
    exit()
  elif out>X[p]:
    return out, X[p]
  else:
    return X[p], out
  
print('POSSIBLE') if min(f(1))<=X[1] else print('IMPOSSIBLE')

### FIXED CODE ###

N=int(input())
P=list(map(int, input().split()))
X=[0]+list(map(int, input().split()))
ko=[[] for _ in range(N+1)]
for i, p in enumerate(P, 2):
  ko[p].append(i)
  
def f(p):
  n=len(ko[p])
  if n==0:
    return X[p], 0
  
  dp=[[float('inf')]*5001 for _ in range(n+1)]
  dp[0][0]=0
  for i, c in enumerate(ko[p], 1):
    a, b=f(c)
    for j in range(a, 5001):
      dp[i][j]=min(dp[i][j], dp[i-1][j-a]+b)
    for j in range(b, 5001):
      dp[i][j]=min(dp[i][j], dp[i-1][j-b]+a)
      
  out=min(dp[-1][:X[p]+1])
  if out==float('inf'):
    print('IMPOSSIBLE')
    exit()
  elif out>X[p]:
    return out, X[p]
  else:
    return X[p], out
  
print('POSSIBLE') if min(f(1))<=X[1] else print('IMPOSSIBLE')
a = input()
ans = []
count = 0
for i in range(len(a)):
    b = a[i]
    if b == 'A':
        count +=1
    elif b == 'C':
        count+=1
    elif b == 'G':
        count+=1
    elif b == 'T':
        count+=1
    else:
        ans.append(count)
        count = 0
print(max(ans))

### FIXED CODE ###

a = list(input())
ans = 0
count = 0
for i in a:

    if i == 'A':
        count +=1
    elif i == 'C':
        count+=1
    elif i == 'G':
        count+=1
    elif i == 'T':
        count+=1
    else:
        ans = max(ans ,count)
        count = 0

print(max(ans,count))
from collections import deque
H,W=map(int,input().split())
L=[]
l=["#"]*(W+2)
L.append(l)
cnt=0
for i in range(H):
    s=input()
    s="#"+s+"#"
    l=[]
    for j in range(W+2):
        l.append(s[j])
        if s[j]==".":
            cnt+=1
    L.append(l)
l=["#"]*(W+2)
L.append(l)
#print(L)
D=deque([[1,1,1]])
for x in range(1000000):
    if D==[]:
        print("-1")
    elif H==D[0][0] and W==D[0][1]:
        print(cnt-D[0][2])
        exit()
    else:
        if L[D[0][0]+1][D[0][1]]==".":
            D.append([D[0][0]+1,D[0][1],D[0][2]+1])
        if L[D[0][0]][D[0][1]+1]==".":
            D.append([D[0][0],D[0][1]+1,D[0][2]+1])
        if L[D[0][0]-1][D[0][1]]==".":
            D.append([D[0][0]-1,D[0][1],D[0][2]+1])
        if L[D[0][0]][D[0][1]-1]==".":
            D.append([D[0][0],D[0][1]-1,D[0][2]+1])
        L[D[0][0]][D[0][1]]="#"
        D.popleft()
            

### FIXED CODE ###

H,W=map(int,input().split())

A=[]
a=["#"]*(W+2)
A.append(a)
for i in range(H):
    s=input()
    s="#"+s+"#"
    A.append(list(s))
A.append(a)
#幅優先探索
#print(A)
P=[[1,1]]
A[1][1]=1
x=[1,-1,0,0]
y=[0,0,1,-1]
while P!=[]:
    #print(P)
    for j in range(4):
        if A[P[0][0]+x[j]][P[0][1]+y[j]]=="#":
            pass
        elif A[P[0][0]+x[j]][P[0][1]+y[j]]==".":
            A[P[0][0]+x[j]][P[0][1]+y[j]]=A[P[0][0]][P[0][1]]+1
            P.append([P[0][0]+x[j],P[0][1]+y[j]])
        elif A[P[0][0]+x[j]][P[0][1]+y[j]]<=A[P[0][0]][P[0][1]]+1:
            pass
        else:
            A[P[0][0]+x[j]][P[0][1]+y[j]]=A[P[0][0]][P[0][1]]+1
            P.append([P[0][0]+x[j],P[0][1]+y[j]])
    del P[0]
S=0
for i in range(H+2):
    for j in range(W+2):
        if A[i][j]=="#":
            S+=1
if A[H][W]==".":
    print(-1)
else:
    print((H+2)*(W+2)-S-A[H][W])
def solve(string):
    n, s = string.split()
    n = int(n)
    num_e = len(s.count("E"))
    count_e = 0
    count_w = 0
    ans = n
    for _s in s:
        tmp = count_w
        if _s == "E":
            count_e += 1
        else:
            count_w += 1
        tmp += num_e - count_e
        ans = min(ans, tmp)
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


### FIXED CODE ###

def solve(string):
    n, s = string.split()
    n = int(n)
    es = {i for i, _s in enumerate(s) if _s == "E"}
    num_e = len(es)
    num_w = n - num_e
    count_e = 0
    count_w = 0

    ans = n
    for i, _s in enumerate(s):
        tmp = [count_e, count_w]
        if i in es:
            count_e += 1
        else:
            count_w += 1
        tmp += [num_e - count_e, num_w - count_w]
        ans = min(ans, tmp[1] + tmp[2])
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
n, m = map(int, input().split())

listans = [-1] * n
ans = 0

for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        ans = -1
    if listans[int(s)-1] != c:
        if listans[int(s)-1] == "0":
            listans[int(s)-1] = c
        else :
            ans = -1

if ans == 0:
    if n > 1 and listans[0] == "0":
        listans[0] = "1"
    ans = int("".join([str(li) for li in listans]))

print(ans)

### FIXED CODE ###

n = int(input())

ans = n//2 + n%2

print(ans)
ans = 1
for i in range(N):
    if i == 0:
        ans *= K
    else:
        ans *= K-1
print(ans)

### FIXED CODE ###

N, K = map(int,input().split())
ans = 1
for i in range(N):
    if i == 0:
        ans *= K
    else:
        ans *= K-1
print(ans)
import sys
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A, B = map(int, input().split())
x = gcd(A, B)
prime_list = prime_decomposition(x)
s = set(prime_list)
s.add(1)
for y in s:
    if y == x and len(s) != 1:
        s -= {x}
        
print(len(s))


### FIXED CODE ###

import fractions

A, B = map(int, input().split())

GCD = fractions.gcd(A, B)

def pf(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(len(set(pf(GCD))) + 1)
n=int(input())


a=0
for i in　range(0,26):
    for j in range(0,20):
        if 4*i+7*j==n:
            a+=1


if a==0:
    print("N0")
else:
    print("Yes")


### FIXED CODE ###

n=int(input())


a=0
for i in range(0,n):
    for j in range(0,n):
        if 4*i+7*j==n:
            a+=1


if a==0:
    print("No")
else:
    print("Yes")
n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

Min = 0
Max = 0

comb_min = 1
comb_max = 1

a_sort = sorted(a)

def SUM(a):
    count = 0
    comb = 1
    for i, num in enumerate(a_sort):
        if i == k-1:
            count += num
        elif i >= k-1:
            comb = comb * i / (i-k+1)
            count += (comb * num) % (10**9+7)
            count = count % (10**9+7)
    return int(count)

Min = SUM(a_sort)
Max = SUM(a_sort.reverse())

print((Min - Max + (10**9+7)) % (10**9+7))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
 
class Combination():
    # コンストラクタ
    def __init__(self, N:int, P:int):
        self.N = N
        self.P = P
 
        # fact[i] = (i! mod P)
        self.fact = [1, 1]   
        # factinv[i] = ((i!)^(-1) mod P)
        self.factinv = [1, 1]
        # factinv 計算用
        self.inv = [0, 1]    
 
        for i in range(2, N+1):
            self.fact.append((self.fact[-1] * i) % P)
            self.inv.append((-self.inv[P % i] * (P // i)) % P)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % P)
    
    # nCk (mod P)   (ただし、n<=N)
    def getComb(self, n:int, k:int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] * self.factinv[n-k] % self.P
 
def main():
    N,K = map(int,input().split())
    A = sorted([int(i) for i in input().split()])
 
    mod = 10**9+7
 
    COMB = Combination(N,mod)
 
    cmb = [0] * (N-K+1)
    for i in range(N-K+1):
        cmb[i] = COMB.getComb(i+(K-1),K-1)
 
    sum_max = 0
    for i in range(K-1,N):
        sum_max = (sum_max + cmb[i-(K-1)] * A[i]) % mod
 
    sum_min = 0
    for i in range(N-K,-1,-1):
        sum_min = (sum_min + cmb[(N-K)-i] * A[i]) % mod
 
    answer = sum_max - sum_min
    print(answer % mod)
 
if __name__ == "__main__":
    main()
N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

A_itta = [None] * N
# A_cycle = '1'

A_stayed = []
A_stayed.append('1')

i = 0
while True:
    # print('stay', i)

    # 訪問フラグ
    A_itta[i] = 1

    # 訪問リスト
    # A_cycle = A_cycle + str(A[i])
    A_stayed.append(str(A[i]))

    # 次の番号
    i = A[i] - 1

    # print('next', i)

    # 行ったことある
    if A_itta[i]:
        # print('loop at=', i)
        break

# 最初の町からループする場合
if i == 0:
    # cycle = A_cycle[0:-1]
    cycle = A_stayed[0:-1]
    ans = cycle[K % len(cycle)]

else:
    # cycle = A_cycle[i + 1:-1]
    cycle = A_stayed[i+1:-1]
    ans = cycle[(K - (i + 1)) % len(cycle)]

# print(cycle)
print(ans)


### FIXED CODE ###

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

visited = [False for _ in range(N)]
now = 0

cycle = []

while True:
    cycle.append(now)
    visited[now] = True
    now = A[now] - 1

    if visited[now]:
        break

total_len = len(cycle)

cycle_start = 0

for i in range(total_len):
    if cycle[i] == now:
        cycle_start = i
        break

cycle_len = total_len - cycle_start

if K < cycle_start:
    print(cycle[K] + 1)
else:
    print(cycle[cycle_start + (K - cycle_start) % cycle_len] + 1)
n=input()
d={"9":"1","1":"9"}
"".join(d[x] for in n)

### FIXED CODE ###

n=input()
d={"9":"1","1":"9"}
print("".join(d[x] for x in n))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

print(lcm(a, b))

### FIXED CODE ###

import fractions

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

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

print(lcm(a, b))
N,X = [int(i) for i in input().split()]
W = []
W = list(map(int,input().split()))
count = 0
Sum = 0
while Sum <= X:
    Sum += W.pop(0)
    count += 1

print(count)

### FIXED CODE ###

N,X = [int(i) for i in input().split()]
W = []
for j in input().split():
    W.append(j)

count = 1
Sum = 0
while Sum <= X and count < N + 2:
    if count < N + 1:
        Sum += int(W.pop(0))
    count += 1
print(count-1)
N = int(input())

Xmax = -2*10**9
Ymax = -2*10**9
Xmin = 2*10**9
Ymin = 2*10**9


for i in range(N):
    x, y = map(int, input().split())
    if (x + y >= Xmax):
        Xmax = x + y
    if (x + y =< Xmin):
        Xmin = x + y
    if (x - y >= Ymax):
        Ymax = x - y
    if (x - y =< Ymin):
        Ymin = x - y

print(max(Xmax - Xmin, Ymax - Ymin))

### FIXED CODE ###

N = int(input())

Xmax = -2*10**9
Ymax = -2*10**9
Xmin = 2*10**9
Ymin = 2*10**9


for i in range(N):
    x, y = map(int, input().split())
    if (x + y >= Xmax):
        Xmax = x + y
    if (x + y <= Xmin):
        Xmin = x + y
    if (x - y >= Ymax):
        Ymax = x - y
    if (x - y <= Ymin):
        Ymin = x - y

print(max(Xmax - Xmin, Ymax - Ymin))
import sys
N, M = map(int, input().split())
if M & 1:
    print(-1)
    sys.exit()
Edge = [[] for _ in range(N)]
Dim = [0]*N
for _ in range(M):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)
    Dim[a] += 1
    Dim[b] += 1
Ans = []
used = set()
for i in range(N):
    Edge[i].sort(key = lambda x: Dim[x], reverse = True)
    while Dim[i] > 1:
        while (i, Edge[i][-1]) in used:
            Edge[i].pop()
        j1 = Edge[i].pop()
        while (i, Edge[i][-1]) in used:
            Edge[i].pop()
        j2 = Edge[i].pop()
        Ans.append((i+1, j1+1))
        Ans.append((i+1, j2+1))
        Dim[i] -= 2
        Dim[j1] -= 1
        Dim[j2] -= 1
        used.add((i, j1))
        used.add((i, j2))
        used.add((j1, i))
        used.add((j2, i))
assert len(Ans) == M,''

for a in Ans:
    print(*a)  

### FIXED CODE ###

import sys
readline = sys.stdin.readline
write = sys.stdout.write
sys.setrecursionlimit(2*10**6)
class UF():
    def __init__(self, num):
        self.par = [-1]*num
        self.size = [1]*num
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            x = self.par[x]
            return self.find(x)
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            if self.par[rx] < self.par[ry]:
                self.par[ry] = rx
                self.size[rx] += self.size[ry] 
            elif self.par[rx] > self.par[ry]:
                self.par[rx] = ry
                self.size[ry] += self.size[rx]
            else:
                self.par[rx] -= 1
                self.par[ry] = rx
                self.size[rx] += self.size[ry]
            return True
        return False

def getpar(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[0] = -1
    par[p]  -1
    stack = [p]
    visited = set([p])
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            stack.append(vf)
    return par

def topological_sort_tree(E, r):
    Q = [r]
    L = []
    visited = set([r])
    while Q:
        vn = Q.pop()
        L.append(vn)
        for vf in E[vn]:
            if vf not in visited:
                visited.add(vf)
                Q.append(vf)
    return L

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

Edge = []
for _ in range(M):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge.append((a, b))

tr = [[] for _ in range(N)]
ans = []
eo = [0]*N
T = UF(N)
for a, b in Edge:
    if T.union(a, b):
        tr[a].append(b)
        tr[b].append(a)
    else:
        ans.append((a+1, b+1))
        eo[a] ^= 1

L = topological_sort_tree(tr, 0)
P = getpar(tr, 0)
for l in L[1:][::-1]:
    if eo[l]:
        ans.append((l+1, P[l]+1))
    else:
        ans.append((P[l]+1, l+1))
        eo[P[l]] ^= 1
if M % 2 == 0:
    for a, b in ans:
        write('{} {}\n'.format(a, b))
else:
    write('-1\n')
N=int(input())
A=1
for i in range(N):
   A=A*int(input())
print(A if len(A)<=18 else -1)

### FIXED CODE ###

N=int(input())
As=list(map(int,input().split()))
ans=1

if 0 in As:
    print(0)
else:
    for i in range(N):
        ans*=As[i]
        if ans>int(1e18):
            break
    print(ans if ans<=int(1e18) else -1)
N,K=map(int,input().split())

Sanuke=list(range(K))

def calc_double(n):
	return n - 1
def calc_zero(n):
	return n *0

Sanuke=map(calc_zero, Sanuke)
  
for i in range(N):
  di=int(input())
  A=list(map(int,input().split()))
  A=map(calc_double, A)
  for j in A:
    Sanuke[j]+=1

higaisha=0

for i in Sanuke:
  if i ==0:
    higaisha += 1

print(higaisha)

### FIXED CODE ###

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

ans=[0]*n

for i in range(k):
  d=int(input())
  a=[int(k) - 1 for k in input().split()]
  for j in a:
    ans[j]+=1

ansint=0


for i in range(n):
  if ans[i]==0:
    ansint+=1


print(ansint)