Buggy python submission (verdict: Runtime Error):
import sys

N = int(input())
C = [0]
for line in sys.stdin:
    c = int(line)
    if c[-1] == c:
        continue
    else:
        C.append(c)

ans = 1
dic = {}
for c in C:
    if c in dic.keys():
        a = dic[c]
        dic[c] += ans
        ans += a
    else:
        dic[c] = ans

print(ans % (10 ** 9 + 7))

Fixed submission:
import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c

ans = 1
dic = {}
for c in C:
    if c in dic.keys():
        a = dic[c]
        dic[c] += ans
        ans += a
    else:
        dic[c] = ans

print(ans % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c
L = len(C)
A = np.array(C)

ans = 1
f = np.ones(L + 1, dtype="int")
for i in range(2, L):
    ans += np.sum(f[A[:i-1] == A[i]])
    f[i + 1] = ans

print(ans)

Fixed submission:
import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c

ans = 1
dic = {}
for c in C:
    if c in dic.keys():
        a = dic[c]
        dic[c] += ans
        ans += a
    else:
        dic[c] = ans

print(ans % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c
L = len(C)
A = np.array(C)

ans = 1
f = np.ones(L + 1, dtype="int")
for i in range(2, L):
    g = f[:i-1]
    ans += np.sum(g[A[:i-1] == A[i]])
    f[i + 1] = ans

print(ans)

Fixed submission:
import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c

ans = 1
dic = {}
for c in C:
    if c in dic.keys():
        a = dic[c]
        dic[c] += ans
        ans += a
    else:
        dic[c] = ans

print(ans % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(input())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c

ans = 1
f = [1] * (N + 1)
for i, c in enumerate(C):
    for j in range(i - 1):
        if C[j] == c:
            ans += f[j]
    f[i + 1] = ans

print(ans)

Fixed submission:
import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c

ans = 1
dic = {}
for c in C:
    if c in dic.keys():
        a = dic[c]
        dic[c] += ans
        ans += a
    else:
        dic[c] = ans

print(ans % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
C = [int(input()) for _ in range(N)]
f = [0] * N

ans = 1
pre = 0
for i, c in enumerate(C):
    if pre == c:
        f[i] = ans
        continue
    else:
        pre = c

    flag = True
    for j in range(i - 1):
        if C[j] == c:
            if flag:
                if j == 0:
                    ans += 1
                else:
                    ans += f[j - 1]
                flag = False
            else:
                continue
        else:
            flag = True
    f[i] = ans

print(ans)

Fixed submission:
import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c

ans = 1
dic = {}
for c in C:
    if c in dic.keys():
        a = dic[c]
        dic[c] += ans
        ans += a
    else:
        dic[c] = ans

print(ans % (10 ** 9 + 7))