Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
v = [[] for _ in range(N)]
for i in range(M) :
    s, t = map(int, input().split())
    v[s-1].append(t-1)

# 削除しないでdp
dp = [0] * N
for i in range(N - 1, -1, -1) :
    if len(v[i]) == 0 :
        continue
   
    s = [dp[j] for j in v[i]]
    dp[i] = 1 + sum(s) / len(v[i])
    
ret = dp[0]

# 削除してdp
for i in range(N) :
    if len(v[i]) <= 1 :
        continue
    
    s = [dp[j] for j in v[i]]
    if len(v[i]) != 1 :
        dp[i] = 1 + (sum(s) - max(s)) / (len(v[i]) - 1)
    
    for j in range(i - 1, -1, -1) :
        if len(v[j]) == 0 :
            continue
        s = [dp[k] for k in v[j]]
        dp[j] = 1 + sum(s) / len(v[j])
    
    ret = min(ret, dp[0])

print(ret)

Fixed submission:
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
v = [[] for _ in range(N)]
for i in range(M) :
    s, t = map(int, input().split())
    v[s-1].append(t-1)

# 削除しないでdp
dp = [0] * N
for i in range(N - 1, -1, -1) :
    if len(v[i]) == 0 :
        continue
    
    for j in v[i] :
        dp[i] += dp[j]
    dp[i] = 1 + dp[i] / len(v[i])
    
ret = dp[0]
# 削除してdp
for i in range(N - 1) :
    if len(v[i]) <= 1 :
        continue
        
    dp[i] = 0
    M = -1
    for j in v[i] :
        dp[i] += dp[j]
        M = max(M, dp[j])
    dp[i] = 1 + (dp[i] - M) / (len(v[i]) - 1)
    
    for j in range(i - 1, -1, -1) :
        if len(v[j]) == 0 :
            continue
            
        dp[j] = 0
        for k in v[j] :
            dp[j] += dp[k]
        dp[j] = 1 + dp[j] / len(v[j])
    
    ret = min(ret, dp[0])

print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
v = [[] for _ in range(N)]
for i in range(M) :
    s, t = map(int, input().split())
    v[s-1].append(t-1)

# 削除しないでdp
dp = [0] * N
for i in range(N - 1, -1, -1) :
    if len(v[i]) == 0 :
        continue
   
    s = [dp[j] for j in v[i]]
    dp[i] = 1 + sum(s) / len(v[i])
    
ret = dp[0]

# 削除してdp
for i in range(N) :
    if len(v[i]) == 0 :
        continue
        
    for j in range(i, -1, -1) :
        if len(v[j]) == 0 :
            continue
            
        s = [dp[k] for k in v[j]]
        if j == i :
            if len(v[j]) != 1 :
                dp[j] = 1 + (sum(s) - max(s)) / (len(v[j]) - 1)
        else :
            dp[j] = 1 + sum(s) / len(v[j])
    ret = min(ret, dp[0])
print(ret)

Fixed submission:
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
v = [[] for _ in range(N)]
for i in range(M) :
    s, t = map(int, input().split())
    v[s-1].append(t-1)

# 削除しないでdp
dp = [0] * N
for i in range(N - 1, -1, -1) :
    if len(v[i]) == 0 :
        continue
    
    for j in v[i] :
        dp[i] += dp[j]
    dp[i] = 1 + dp[i] / len(v[i])
    
ret = dp[0]
# 削除してdp
for i in range(N - 1) :
    if len(v[i]) <= 1 :
        continue
        
    dp[i] = 0
    M = -1
    for j in v[i] :
        dp[i] += dp[j]
        M = max(M, dp[j])
    dp[i] = 1 + (dp[i] - M) / (len(v[i]) - 1)
    
    for j in range(i - 1, -1, -1) :
        if len(v[j]) == 0 :
            continue
            
        dp[j] = 0
        for k in v[j] :
            dp[j] += dp[k]
        dp[j] = 1 + dp[j] / len(v[j])
    
    ret = min(ret, dp[0])

print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
v = [[] for _ in range(N)]
for i in range(M) :
    s, t = map(int, input().split())
    v[s-1].append(t-1)

# 削除しないでdp
dp = [0] * N
for i in range(N - 1, -1, -1) :
    if len(v[i]) == 0 :
        continue
   
    s = [dp[j] for j in v[i]]
    dp[i] = 1 + sum(s) / len(v[i])
    
ret = dp[0]

# 削除してdp
for i in range(N) :
    if len(v[i]) == 1 :
        continue
        
    dp = [0] * N
    for j in range(N - 1, -1, -1) :
        if len(v[j]) == 0 :
            continue
            
        s = [dp[k] for k in v[j]]
        if j == i :
            if len(v[j]) != 1 :
                dp[j] = 1 + (sum(s) - max(s)) / (len(v[j]) - 1)
        else :
            dp[j] = 1 + sum(s) / len(v[j])
        
    ret = min(ret, dp[0])
print(ret)

Fixed submission:
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
v = [[] for _ in range(N)]
for i in range(M) :
    s, t = map(int, input().split())
    v[s-1].append(t-1)

# 削除しないでdp
dp = [0] * N
for i in range(N - 1, -1, -1) :
    if len(v[i]) == 0 :
        continue
    
    for j in v[i] :
        dp[i] += dp[j]
    dp[i] = 1 + dp[i] / len(v[i])
    
ret = dp[0]
# 削除してdp
for i in range(N - 1) :
    if len(v[i]) <= 1 :
        continue
        
    dp[i] = 0
    M = -1
    for j in v[i] :
        dp[i] += dp[j]
        M = max(M, dp[j])
    dp[i] = 1 + (dp[i] - M) / (len(v[i]) - 1)
    
    for j in range(i - 1, -1, -1) :
        if len(v[j]) == 0 :
            continue
            
        dp[j] = 0
        for k in v[j] :
            dp[j] += dp[k]
        dp[j] = 1 + dp[j] / len(v[j])
    
    ret = min(ret, dp[0])

print(ret)