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

import itertools
import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

N = int(sys.stdin.readline())
A = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

A = np.array(A)


def solve():
    # 消していいやつ
    useless = np.zeros((N, N), dtype=bool)

    # 1 つ経由するのだけ考えれば OK
    for st, en in itertools.combinations(range(N), r=2):
        for via in range(N):
            if via in [st, en]:
                continue
            if A[st, via] + A[via, en] < A[st, en]:
                return -1
            if A[st, via] + A[via, en] == A[st, en]:
                useless[st, en] = True
                useless[en, st] = True

    return A[~useless].sum() // 2


print(solve())


### FIXED CODE ###

import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

N = int(sys.stdin.readline())
A = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

A = np.array(A, dtype=float)

useless = np.zeros((N, N), dtype=bool)
impossible = np.zeros((N, N), dtype=bool)
for via in range(N):
    # R[i][j]: i -> via -> j の距離
    R = sum(np.meshgrid(A[via], A[via]))
    R[via] = np.inf
    R[:, via] = np.inf
    useless |= R == A
    impossible |= R < A
if impossible.sum():
    print(-1)
else:
    print(int(A[~useless].sum() // 2))
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
ans=1
for i in range (n):
  ans=ans*l[i]
  
if ans>10**18:
  print(-1)
else:
  print(ans)


### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
ans = 1

if 0 in l:
  print(0)
  exit()

for i in range(n):
  ans*=l[i]
  if ans > 10**18:
      print(-1)
      exit()

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

n = int(input())
a = list(map(int,input().split()))
for i in range(1,n+1):
  print(a.index(i)+1, end=" ")

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
roster=[]
for i in range(n):
  roster.append(i+1)
k=dict(zip(a,roster)) 
k=sorted(k.items())
for i in range(len(k)):
  print(k[i][1],end=" ")
### BUGGY CODE ###

N = int(input())

S_list = []
S_count = []
ans = set()

for _ in range(N):
    S = input()
    if (S in S_list):
        S_count[S_list.index(S)] += 1
    else:
        S_list.append(S)
        S_count.append(0)

M = max(S_count)

for i, s in enumerate(S_count):
    if s == M:
        ans.add(S_list[i])

ans = sorted(ans)

for a in ans:
    print(a)




### FIXED CODE ###

N = int(input())

S_list = {}
ans = set()

for _ in range(N):
    S = input()
    try:
        S_list[S] += 1
    except KeyError:
        S_list[S] = 0

M = max(S_list.values())
S_list = sorted(S_list.items(), key = lambda x: x[0])

for s, v in S_list:
    if v == M:
        print(s)
### BUGGY CODE ###

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

# Sに登場する文字1, 0を左から順にまとめる
array = []
count = 1
for i in range(N+1):
    if i == 0:
        continue
    if i == N:
        # 終了処理
        array.append([S[i-1], count])
        count = 1
        continue
    if S[i-1] == S[i]:
        # カウンターを回す
        count += 1
        continue
    if not S[i-1] == S[i]:
        # ブロック作成
        array.append([S[i-1], count])
        count = 1

maxhito = 0
hito = 0
maxcount = 0

for l in range(len(array)):
    if array[l][0] == 0:
        maxcount += 1

K = min(K, maxcount)

if array[0][0] == 0:
    start = 0
else:
    start = 1

for i in range(start, len(array) - K + 1, 2):
    if i == 0:
        hito = 0
    else:
        hito = array[i-1][1]

    for j in range(i, min(len(array), i+2*K), 1):
        hito += array[j][1]

    if hito > maxhito:
        maxhito = hito

print(maxhito)

### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    S = input()

    countlist = [0]
    if S[0] == "0":
        countlist.append(0)
    last_char = S[0]
    for s in S:
        if s == last_char:
            countlist[-1] += 1
        else:
            countlist.append(1)
            last_char = s

    if S[-1] == "0":
        countlist.append(0)

    l, r = 0, K * 2 + 1
    maxhito = last_count = sum(countlist[l:r])
    while True:
        l, r = l + 2, r + 2
        if len(countlist) < r:
            break
        count = last_count - (countlist[l - 1] + countlist[l - 2]) + (countlist[r - 1] + countlist[r - 2])
        maxhito = max(maxhito, count)
        last_count = count
    print(maxhito)


main()
### BUGGY CODE ###

def main():
    from bisect import bisect_right as br
    import numpy as np
    n = int(input())
    a = np.array(list(map(int, input().split())))
    b = np.array(list(map(int, input().split())))
    a = np.sort(a)
    b = np.sort(b[::-1])
    m = n % 2
    xor = 0
    for i in b:
        xor ^= i
    b = pow(2, 28) - b
    ans = 0
    for loop in range(28, -1, -1):
        j = pow(2, loop)
        k = (xor & j) // j
        temp = br(b, j-1)
        b[temp:n] -= j
        b = np.sort(b)
        temp = br(a, j-1)
        k += sum((a & j) // j)
        a[temp:n] -= j
        x = (k+br(b, 0))*m % 2
        a = np.sort(a)
        l = 0
        for i in a:
            while l < n:
                if i >= b[l]:
                    l += 1
                else:
                    break
            x += l % 2
        ans += (x % 2)*j
    print(ans)


main()

### FIXED CODE ###

def main():
    from bisect import bisect_right as br
    n = int(input())
    a = sorted(list(map(int, input().split())))
    b = sorted(list(map(int, input().split())), reverse=True)
    m = n % 2
    xor = 0
    for i in b:
        xor ^= i
    for i in range(n):
        b[i] = 2**28 - b[i]
    ans = 0
    for loop in range(28, -1, -1):
        j = pow(2, loop)
        k = (xor & j) // j
        temp = br(b, j-1)
        for i in range(temp, n):
            b[i] -= j
        b.sort()
        temp = br(a, j-1)
        for i in a[:temp]:
            k += (i & j) // j
        for i in range(temp, n):
            k += (a[i] & j) // j
            a[i] -= j
        x = (k+br(b, 0))*m % 2
        a.sort()
        l = 0
        for i in a:
            while l < n:
                if i >= b[l]:
                    l += 1
                else:
                    break
            x += l % 2
        ans += (x % 2)*j
    print(ans)


main()
### BUGGY CODE ###

n=int(input())
p=list(map(int,input().split()))
l=n
ans=0
for i in range(1,n+1):
    if p.index(i)<l:
        ans+=1
        l=p.index(i)
print(ans)


### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
m=float('INF')
ans=0

for i in range(n):
    if p[i]<=m:
        ans+=1
        m=p[i]
print(ans)
### BUGGY CODE ###

def main():
    N = int(input())
    a = []
    b = []
    for _ in range(N):
        ai, bi = map(int, input().split())
        a.append(ai)
        b.append(bi)
    ans = 0
    s = 1
    while True:
        if sum(a) == 0:
            print(ans)
            exit()
        ma = a.pop()
        ans += ma * s
        b.pop()
        t = a
        a = b
        b = t
        s *= -1


main()


### FIXED CODE ###

def main():
    N = int(input())
    ab = [[int(i) for i in input().split()] for _ in range(N)]
    ab = sorted(ab, key=lambda x: x[0] + x[1], reverse=True)
    ans = 0
    for i in range(N):
        if i % 2 == 0:
            ans += ab[i][0]
        else:
            ans -= ab[i][1]
    print(ans)


main()
### BUGGY CODE ###

from sys import stdin

N = stdin.readline().rstrip().split()
N = int(N[0])

int_list = list(map(int, stdin.readline().rstrip().split()))

cnt_list = [int_list.count(i) for i in range(1, N+1)]
ret_list = []

# これはO(N)でいける

tmp_ans = 0
for i in range(N):
    if cnt_list[i] < 2:
        continue
    else:
        tmp_ans += cnt_list[i]*(cnt_list[i]-1) // 2

for i in range(N):
    if cnt_list[i] < 1:
        tmp_ret = 0
    else:
        tmp_ret = tmp_ans - cnt_list[i]*(cnt_list[i]-1) // 2 + (cnt_list[i]-1)*(cnt_list[i]-2) // 2
    ret_list.append(tmp_ret)

for i in int_list:
    print(ret_list[i-1])

### FIXED CODE ###

from sys import stdin

N = stdin.readline().rstrip().split()
N = int(N[0])

int_list = list(map(int, stdin.readline().rstrip().split()))
cnt_list = [0] * N

for i in int_list:
    cnt_list[i-1] += 1

ret_list = [0] * N

# これはO(N)でいける

tmp_ans = 0
for i in range(N):
    if cnt_list[i] > 1:
        tmp_ans += cnt_list[i]*(cnt_list[i]-1) // 2


for i in range(N):
    if cnt_list[i] < 1:
        tmp_ret = 0
    else:
        tmp_ret = tmp_ans - cnt_list[i]*(cnt_list[i]-1) // 2 + (cnt_list[i]-1)*(cnt_list[i]-2) // 2
    ret_list[i] = tmp_ret

for i in int_list:
    print(ret_list[i-1])
### BUGGY CODE ###

import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

R, C, K = MI()
item = [[0] * (C + 1) for i in range(R + 1)]

for i in range(K):
    r_, c_, v_, = MI()
    item[r_ - 1][c_ - 1] = v_

dp = [[[0 for _ in range(4)] for _ in range(C + 2)] for _ in range(R + 2)]

for i in range(R + 1):
    for j in range(C + 1):
        for k in range(4):
            v = item[i][j]

            if k == 3:
                dp[i + 1][j][0] = max(dp[i][j][k], dp[i + 1][j][0])
                continue
            dp[i + 1][j][0] = max(dp[i][j][k], dp[i][j][k] + v, dp[i + 1][j][0])
            dp[i][j + 1][k] = max(dp[i][j][k], dp[i][j + 1][k])
            dp[i][j + 1][k + 1] = max(dp[i][j][k] + v, dp[i][j + 1][k + 1])

ans = max(dp[R][C][0], dp[R][C][1], dp[R][C][2], dp[R][C][3])
print(ans)



### FIXED CODE ###

import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    R, C, K = NMI()
    item = [[0] * (C + 1) for i in range(R + 1)]

    for i in range(K):
        r_, c_, v_, = NMI()
        item[r_ - 1][c_ - 1] = v_

    dp = [[[0 for _ in range(C + 2)] for _ in range(R + 2)] for _ in range(4)]

    for i in range(R + 1):
        for j in range(C + 1):
            for k in range(4):
                a = dp[k][i][j]
                v = item[i][j]

                if k == 3:
                    dp[0][i + 1][j] = max(a, dp[0][i + 1][j])
                    continue
                dp[0][i + 1][j] = max(a, a + v, dp[0][i + 1][j])
                dp[k][i][j + 1] = max(a, dp[k][i][j + 1])
                dp[k + 1][i][j + 1] = max(a + v, dp[k + 1][i][j + 1])

    print(max(dp[0][R][C], dp[1][R][C], dp[2][R][C], dp[3][R][C]))

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import time

#  入力
N = int(input())
A = [int(x) for x in input().split()]

# 初期化
dp = [[0] * (N+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(0,N):

    a = max(A)
    id = A.index(a)
    
    for x in range(0,i+1):
        y = i - x

        d = dp[x][y]
        tmp = d + a * (id - x)
        if dp[x+1][y] < tmp:
        	dp[x+1][y] = tmp
        tmp = d + a * (((N-1)-y) - id)            
        if dp[x][y+1] < tmp:
        	dp[x][y+1] = tmp
        
    A[id] = 0

ans = 0
for i in range(N+1):
    ans = max(ans, dp[i][N-i])
print(ans)

### FIXED CODE ###

#  入力
N = int(input())
A = [int(x) for x in input().split()]

# 初期化
dp = [[0] * (N+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(0,N):

    # 最も嬉しさの高い子供から場所を選択していく
    a = max(A)
    id = A.index(a)
    
    for x in range(0,i+1):
        y = i - x

        d = dp[x][y]
        tmp = d + a * (id - x)
        if dp[x+1][y] < tmp:
        	dp[x+1][y] = tmp
        tmp = d + a * (((N-1)-y) - id)            
        if dp[x][y+1] < tmp:
        	dp[x][y+1] = tmp
        
    A[id] = 0

ans = 0
for i in range(N+1):
    ans = max(ans, dp[i][N-i])
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
for i in range(1, N+1):
    print(A.count(i))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for i in A:
    ans[i-1] += 1
for j in ans:
    print(j)
### BUGGY CODE ###

from bisect import bisect
mod = 10**9+7
N,K = map(int,input().split())

c = []
for i in range(1,int(N**0.5)+1):
    c.append(i)
    c.append(int(N/i))
c = list(set(c))
c.sort()

k = []
for i in c:
    if int(N/i) != int(N/(i+1)):
        k.append(i)

dp = [[0]*len(k) for _ in range(K)]
for i in range(len(k)):
    dp[0][i]=k[i]

inv = [0]*(len(k)-1)
for i in range(len(k)-1):
    inv[i] = pow(k[i+1]-k[i],mod-2,mod)

index = [0]*len(k)
for i in range(len(k)):
    m = int(N/(k[i]+1))
    index[i] = bisect(k,m)

for i in range(K-1):
    dp[i+1][0] = dp[i][-1]
    for j in range(len(k)-1):
        m = int(N/(k[j]+1))
        l = index[j]
        S = dp[i][l-1]+(dp[i][l]-dp[i][l-1])*(m-k[l-1])*inv[l-1]
        dp[i+1][j+1] = dp[i+1][j]+(k[j+1]-k[j])*S
        dp[i+1][j+1] %= mod

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

### FIXED CODE ###

from bisect import bisect
mod = 10**9+7
N,K = map(int,input().split())

c = []
for i in range(1,int(N**0.5)+1):
    c.append(i)
    c.append(int(N/i))
c = list(set(c))
c.sort()

k = []
for i in c:
    if int(N/i) != int(N/(i+1)):
        k.append(i)

dp = [[0]*len(k) for _ in range(K)]
for i in range(len(k)):
    dp[0][i]=k[i]

inv = [0]*(len(k)-1)
for i in range(len(k)-1):
    inv[i] = pow(k[i+1]-k[i],mod-2,mod)

index = [0]*len(k)
for i in range(len(k)):
    m = int(N/(k[i]+1))
    index[i] = bisect(k,m)

for i in range(K-1):
    dp[i+1][0] = dp[i][-1]
    for j in range(len(k)-1):
        m = int(N/(k[j]+1))
        l = index[j]
        S = dp[i][l-1]+(dp[i][l]-dp[i][l-1])*(m-k[l-1])*inv[l-1]
        dp[i+1][j+1] = dp[i+1][j]+(k[j+1]-k[j])*S
        dp[i+1][j+1] %= mod

print(dp[-1][-1])
### BUGGY CODE ###

s = input()
q = int(input())

cnt = 0
for i in range(q):
    query = input().split()
    if query[0] == '1':
        cnt += 1
    else:
        if cnt % 2 == 0:
            if query[1] == '1':
                s = query[2] + s
            else:
                s = s + query[2]
        else:
            if query[1] == '1':
                s = s + query[2]
            else:
                s = query[2] + s
if cnt % 2 == 0:
    print(s)
else:
    print(s[::-1])


### FIXED CODE ###

s = input()
q = int(input())

t = ''
for i in range(q):
    query = input().split()
    if query[0] == '1':
        s,t = t,s
    else:
        if query[1] == '1':
            t += query[2] 
        else:
            s += query[2]

print(t[::-1] + s)
### BUGGY CODE ###

n = int(input())
l = list(map(int,input().split()))
ans = [0]*n

for i in range(n):
  ans[i] = l.index(i+1) + 1
print(*ans)

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
ans = [0] * n

for i in range(n):
  ans[l[i]-1] = i + 1
print(*ans)
### BUGGY CODE ###

def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df[a].add(b)
        Df[b].add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db[c].add(d)
        Db[d].add(c)

    Q = []
    ANS = {}
    C = [False] * (n + 1)
    for i in range(1, n + 1):
        if C[i]:
            continue

        C[i] = True
        Cin = [False] * (n + 1)
        Cin[i] = True
        FF = set()
        FF.add(i)
        Q.append(i)
        while len(Q) != 0:
            for f in Df[Q.pop(0)]:
                if not Cin[f]:
                    Q.append(f)
                    FF.add(f)
                    C[f] = True
                    Cin[f] = True

        for ni in range(1, n + 1):
            if Cin[ni]:
                ANS[ni] = (Cin.count(True) - len(Df[ni]) - len(FF & Db[ni] - Df[ni]) - 1)

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque

def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df.get(a).add(b)
        Df.get(b).add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db.get(c).add(d)
        Db.get(d).add(c)

    Q = deque()
    C = set()
    ANS = {}
    for i in range(1, n + 1):
        if i in C:
            continue

        C.add(i)
        Cin = set()
        Cin.add(i)
        Q.appendleft(i)
        while len(Q) != 0:
            for f in Df.get(Q.pop()) - Cin:
                Q.appendleft(f)
                C.add(f)
                Cin.add(f)

        for k in Cin:
            ANS[k] = len(Cin) - len(Df[k]) - len(Cin & Db[k] - Df[k]) - 1

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for _ in range(m):
    b, c = map(int, input().split())
    bc.append([b, c])
    
a = sorted(a)
bc = sorted(bc, key=lambda x: x[1])

que = []
for b, c in bc:
    que += [c]*b


c = que.pop()
ans = 0
i = 0
while True:
    if a[i] < c:
        ans += c
        if que:
            c = que.pop()
            i += 1
        else:
            i += 1
            break
    else:
        break
print(ans + sum(a[i:]))

### FIXED CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]

a.sort()
bc.sort(reverse=True, key=lambda x: x[1])
j = 0
for i in range(m):
    while j < len(a) and bc[i][0] > 0:
        if a[j] < bc[i][1]:
            a[j] = bc[i][1]
            bc[i][0] -= 1
        j += 1
print(sum(a))
### BUGGY CODE ###

H,W = map(int,input().split())
S = [0]*H
for i in range(H):
    S[i] = list(input())

Hor = [0]*H
y = 0
while y != H:
    Hor[y] = []
    i = 0
    while True:
        if i == W:
            break
        if S[y][i] == ".":
            n = 0
            while i < W and S[y][i] == '.':
                i += 1
                n += 1
            Hor[y] += [n] * n
        else:
            Hor[y] += [0]
            i += 1
    y += 1

Ver = [0]*W
x = 0
while x != W:
    Ver[x] = []
    i = 0
    while True:
        if i == H:
            break
        if S[i][x] == ".":
            n = 0
            while i < H and S[i][x] == '.':
                i += 1
                n += 1
            Ver[x] += [n] * n
        else:
            Ver[x] += [0]
            i += 1
    x += 1

ans = 1
x = 0
while x != W:
    y = 0
    while y != H:
        h = Hor[y][x]
        if h:
            v = Ver[x][y]
            ans = max(ans,h+v-1)
        y += 1
    x += 1

print(ans)

### FIXED CODE ###

H,W = map(int,input().split())
S = [0]*H
for i in range(H):
    S[i] = list(input())

def aaa(s):
    i = 0
    l = len(s)
    o = []
    while True:
        if i == l:
            break
        if s[i] == ".":
            n = 0
            while i < l and s[i] == '.':
                i += 1
                n += 1
            o += [n] * n
        else:
            o += [0]
            i += 1
    return o

Hor = [0]*H
y = 0
while y != H:
    Hor[y] = aaa(S[y])
    y += 1

Ver = [0]*W
x = 0
while x != W:
    _ = 0
    s = [0] * H
    while _ != H:
        s[_] = S[_][x]
        _ += 1
    Ver[x] = aaa(s)
    x += 1

ans = 1
x = 0
while x != W:
    y = 0
    while y != H:
        h = Hor[y][x]
        if h:
            v = Ver[x][y]
            ans = max(ans,h+v-1)
        y += 1
    x += 1

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

q = int(input())
like2017 = []

def is_prime(x):
    if x==2:
        return True
    elif x%2==0:
        return False

    for i in range(3, x, 2):
        if x!=i and x%i==0:
            return False
    return True

for i in range(1, 10001, 2):
    if i>2 and is_prime(i) and is_prime(int((i+1)/2)):
        like2017.append(1)
    else:
        like2017.append(0)

for i in range(q):
    l, r = map(int, input().split())
    print(sum(like2017[:int((r+1)/2)])-sum(like2017[:int((l-1)/2)]))


### FIXED CODE ###

import numpy as np
n=123456
q = int(input())
 
is_prime = np.ones(n+1,dtype=int)
is_prime[0]=0
is_prime[1]=0
 
for i in range(2,n+1):
    if(is_prime[i]==1):
        j=i+i
        while j <= n:
            is_prime[j] = 0
            j += i
 
cnt = [is_prime[x]*is_prime[(x+1)//2] for x in range(0,n+1)]
 
for i in range(1,n+1):
    cnt[i]+=cnt[i-1]
 
for i in range(q):
    l,r = map(int, input().split())
    print(cnt[r]-cnt[l-1])
### BUGGY CODE ###

import numpy as np

n, m = map(int, input().split())
adj = np.zeros((n, n), dtype=np.bool)
for _ in range(m):
  s, t = map(int, input().split())
  adj[s-1, t-1] = True

dp = np.zeros(n, dtype=np.float)
for i in range(n - 2, -1, -1):
  dp[i] = dp[adj[i]].mean() + 1.
  
ans = dp[0]

for i in np.where(adj.sum(axis=1) > 1)[0]:
  dp_i = dp.copy()
  dp_i[i] = (dp_i[adj[i]].sum() - dp_i[adj[i]].max()) / (adj[i].sum() - 1) + 1
  for j in range(i - 1, -1, -1):
    dp_i[j] = dp_i[adj[j]].mean() + 1
  ans = np.minimum(ans, dp_i[0])
    
print(ans)

### FIXED CODE ###

import numpy as np

n, m = map(int, input().split())
adj = np.zeros((n, n), dtype=np.bool)
for _ in range(m):
  s, t = map(int, input().split())
  adj[s-1, t-1] = True
deg = adj.sum(axis=1)

ev = np.zeros(n, dtype=np.float)
for i in range(n - 2, -1, -1):
  ev[i] = ev[adj[i]].mean() + 1.

prob = np.zeros(n, dtype=np.float)
prob[0] = 1.
for i in range(n - 1):
  prob[adj[i]] += prob[i] / deg[i]

decrease = 0.
for i in np.where(deg > 1)[0]:
  now = ev[adj[i]].mean()
  cut = (ev[adj[i]].sum() - ev[adj[i]].max()) / (deg[i] - 1)
  decrease = np.maximum(decrease, (now - cut) * prob[i])
    
print(ev[0] - decrease)
### BUGGY CODE ###

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

counter = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                counter += 1
            elif x + y + z > s:
                break

print(counter)

### FIXED CODE ###

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

counter = 0
for x in range(k+1):
    for y in range(k+1):
            if (s- (x + y) <= k) and (s - (x+ y) >= 0):
                counter += 1


print(counter)
### BUGGY CODE ###

n,m = map(int, input().split())
s = []
g = []
for _ in range(m):
  a,b = map(int, input().split())
  if a == 1: s.append(b)
  elif b == n: g.append(a)

ok = False
for v in s:
  if v in g: 
    ok = True
    break
print("POSSIBLE" if ok else "IMPOSSIBLE")

### FIXED CODE ###

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab.sort()
AB = sorted(ab, reverse=True, key=lambda x:x[1])
s = [0] * n
ans = "IMPOSSIBLE"
for a,b in ab:
    if a == 1: s[b-1] = 1
    else: break
for A, B in AB:
    if B == n:
        if s[A-1] == 1:
            ans = "POSSIBLE"
    else: break
print(ans)
### BUGGY CODE ###

N = map(int, input().split())
A = list(map(int, input().split()))
ans = 1
for a in A:
  ans *= a
if (ans > 10 ** 18):
  ans = -1
print(ans)

### FIXED CODE ###

def calc():
  N = map(int, input().split())
  A = list(map(int, input().split()))
  for a in A:
    if a == 0:
      return 0
  ans = 1
  for a in A:
    ans *= a
    if (ans > 10 ** 18):
      return -1
  return ans

print(calc())
### BUGGY CODE ###

ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
iix = lambda x:list(int(input()) for _ in range(x))
mix = lambda x:list(li() for _ in range(x))
##########
def main(n,k,q,a):
    point = [k]*n
    for ans in a:
        point = answer(ans-1, point)
    for i in range(len(point)):
        print(judge(point[i]))
    
def answer(n,point):
    for i in range(len(point)):
        if i != n : point[i] -= 1
    return point

def judge(p):
    return "Yes" if p > 0 else "No"

n,k,q = mi()
a = iix(q)
main(n,k,q,a)

### FIXED CODE ###

from collections import Counter as counter

ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
iix = lambda x:list(int(input()) for _ in range(x))
mix = lambda x:list(li() for _ in range(x))
##########
def main(n,k,q,a):
    c = counter(a)
    for i in range(1,n+1):
        print("Yes" if k-q+c[i] > 0 else "No")

n,k,q = mi()
a = iix(q)
main(n,k,q,a)