Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from collections import Counter
INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = [[] for _ in range(N)]
        self.revE = [[] for _ in range(N)]

    def add_edge(self, s, t, w=1):
        self.E[s].append((t, w))
        self.revE[t].append((s, w))


def solve(N: int, M: int, s: "List[int]", t: "List[int]"):
    c = Counter(s)
    g = Graph(N)
    for ss, tt in zip(s, t):
        g.add_edge(ss, tt)

    DP = [0]*N
    for i in range(N-2, -1, -1):
        DP[i] = sum(DP[t] for t, w in g.E[i])/c[i] + 1

    gm = DP[0]
    for i in range(N-2):
        if len(g.E[i]) == 1:
            continue
        dp = DP[:]
        for j in range(i, -1, -1):
            a = tuple(dp[t] for t, w in g.E[j])
            b = sum(a)
            if i == j:
                dp[j] = (b-max(a))/(c[j]-1)
            else:
                dp[j] = b/c[j]
            dp[j] += 1
        gm = min(dp[0], gm)
        # print(dp)
    print(gm)


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    t = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))-1
        t[i] = int(next(tokens))-1
    solve(N, M, s, t)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from collections import Counter
INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = [[] for _ in range(N)]

    def add_edge(self, s, t, w=1):
        self.E[s].append(t)


def solve(N: int, M: int, s: "List[int]", t: "List[int]"):
    c = Counter(s)
    g = Graph(N)
    for ss, tt in zip(s, t):
        g.add_edge(ss, tt)

    DP = [0]*N
    for i in range(N-2, -1, -1):
        DP[i] = sum(DP[t] for t in g.E[i])/c[i] + 1

    gm = DP[0]
    for i in range(N-2):
        if len(g.E[i]) == 1:
            continue
        dp = DP[:]
        for j in range(i, -1, -1):
            tot, m = 0, 0
            for t in g.E[j]:
                tot += dp[t]
                m = max(dp[t], m)
            if i == j:
                dp[j] = (tot-m)/(c[j]-1)
            else:
                dp[j] = tot/c[j]
            dp[j] += 1
        gm = min(dp[0], gm)
        # print(dp)
    print(gm)


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    t = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))-1
        t[i] = int(next(tokens))-1
    solve(N, M, s, t)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from collections import Counter
INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = [[] for _ in range(N)]
        self.revE = [[] for _ in range(N)]

    def add_edge(self, s, t, w=1):
        self.E[s].append((t, w))
        self.revE[t].append((s, w))


def solve(N: int, M: int, s: "List[int]", t: "List[int]"):
    c = Counter(s)
    g = Graph(N)
    for ss, tt in zip(s, t):
        g.add_edge(ss, tt, 1/c[ss])

    DP = [0]*N
    for i in range(N-2, -1, -1):
        DP[i] = sum(DP[t] for t, w in g.E[i])/c[i] + 1
    # print(DP)

    gm = DP[0]
    for i in range(N-1):
        if len(g.E[i]) == 1:
            continue
        m = 0
        mj = -1
        for j, _ in g.E[i]:
            if m < DP[j]:
                m = DP[j]
                mj = j
        # print(i, mj)

        dp = [0]*N
        for j in range(N-2, -1, -1):
            if i == j:
                dp[j] = (sum(dp[t] for t, w in g.E[j])-m)/(c[j]-1) + 1
            else:
                dp[j] = sum(dp[t] for t, w in g.E[j])/c[j] + 1
        gm = min(dp[0], gm)
        # print(dp)
    print(gm)


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    t = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))-1
        t[i] = int(next(tokens))-1
    solve(N, M, s, t)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from collections import Counter
INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = [[] for _ in range(N)]

    def add_edge(self, s, t, w=1):
        self.E[s].append(t)


def solve(N: int, M: int, s: "List[int]", t: "List[int]"):
    c = Counter(s)
    g = Graph(N)
    for ss, tt in zip(s, t):
        g.add_edge(ss, tt)

    DP = [0]*N
    for i in range(N-2, -1, -1):
        DP[i] = sum(DP[t] for t in g.E[i])/c[i] + 1

    gm = DP[0]
    for i in range(N-2):
        if len(g.E[i]) == 1:
            continue
        dp = DP[:]
        for j in range(i, -1, -1):
            tot, m = 0, 0
            for t in g.E[j]:
                tot += dp[t]
                m = max(dp[t], m)
            if i == j:
                dp[j] = (tot-m)/(c[j]-1)
            else:
                dp[j] = tot/c[j]
            dp[j] += 1
        gm = min(dp[0], gm)
        # print(dp)
    print(gm)


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    t = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))-1
        t[i] = int(next(tokens))-1
    solve(N, M, s, t)


if __name__ == '__main__':
    main()