Problem p02987 (python)

Fixed submission:
# @author 

import sys

class AFiftyFifty:
    def solve(self):
        s = list(input().strip())
        s.sort()
        print("Yes" if (s[0] == s[1] and s[2] == s[3] and s[0] != s[2]) else "No")


solver = AFiftyFifty()
input = sys.stdin.readline

solver.solve()

Buggy submission (verdict: Runtime Error):
# @author 

import sys

class DBlueAndRedBalls:
    def solve(self):
        MOD = 10 ** 9 + 7
        MAX_N = 2001
        C = [[0] * MAX_N for _ in range(MAX_N)]
        for i in range(MAX_N):
            C[0][i] = 1
        for i in range(1, MAX_N):
            C[i][i] = 1
            for j in range(i + 1, MAX_N):
                C[i][j] = (C[i][j - 1] + C[i - 1][j - 1]) % MOD

        n, k = [int(_) for _ in input().split()]
        ans = [0] * (k + 1)
        if n == k:
            for i in range(1, k + 1):
                ans[i] = 1
        else:
            ans[1] = n - k + 1
            for i in range(2, min(n - k + 1, k) + 1):
                ans[i] = (C[i - 1][k - 1] * C[i - 1 - 1][n - k - 1] +
                          2 * (sum(C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(1, n - k - i + 1 + 1))) +
                          sum((ext - 1) * C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(2, n - k - i + 1 + 1))) % MOD

        for x in ans[1:]:
            print(x)

solver = DBlueAndRedBalls()
input = sys.stdin.readline

solver.solve()

Buggy submission (verdict: Runtime Error):
# @author 

import sys

class DBlueAndRedBalls:
    def solve(self):
        MOD = 10 ** 9 + 7
        MAX_N = 2001
        C = [[0] * MAX_N for _ in range(MAX_N)]
        for i in range(MAX_N):
            C[0][i] = 1
        for i in range(1, MAX_N):
            C[i][i] = 1
            for j in range(i + 1, MAX_N):
                C[i][j] = (C[i][j - 1] + C[i - 1][j - 1]) % MOD

        n, k = [int(_) for _ in input().split()]
        ans = [0] * (k + 1)
        if n == k:
            for i in range(k):
                ans[i] = 1
        else:
            ans[1] = n - k + 1
            for i in range(2, min(n - k + 1, k) + 1):
                ans[i] = (C[i - 1][k - 1] * C[i - 1 - 1][n - k - 1] +
                          2 * (sum(C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(1, n - k - i + 1 + 1))) +
                          sum((ext - 1) * C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(2, n - k - i + 1 + 1))) % MOD

        for x in ans[1:]:
            print(x)

solver = DBlueAndRedBalls()
input = sys.stdin.readline

solver.solve()

Buggy submission (verdict: Runtime Error):
# @author 

import sys

class DBlueAndRedBalls:
    def solve(self):
        MOD = 10 ** 9 + 7
        MAX_N = 2001
        C = [[0] * MAX_N for _ in range(MAX_N)]
        for i in range(MAX_N):
            C[0][i] = 1
        for i in range(1, MAX_N):
            C[i][i] = 1
            for j in range(i + 1, MAX_N):
                C[i][j] = (C[i][j - 1] + C[i - 1][j - 1]) % MOD

        n, k = [int(_) for _ in input().split()]
        ans = [0] * (k + 1)
        if n == k:
            for i in range(k):
                ans[i] = 1
        ans[1] = n - k + 1
        for i in range(2, min(n - k + 1, k) + 1):
            ans[i] = (C[i - 1][k - 1] * C[i - 1 - 1][n - k - 1] +
                      2 * (sum(C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(1, n - k - i + 1 + 1))) +
                      sum((ext - 1) * C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(2, n - k - i + 1 + 1))) % MOD

        for x in ans[1:]:
            print(x)

solver = DBlueAndRedBalls()
input = sys.stdin.readline

solver.solve()