Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x]
  
  dp[N-1-i]%=mod
  table[x]+=d[N-1-i]

print(dp[0])


Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]

  table[x].append(N-1-i)

print(dp[0]%mod)


Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]
    dp[N-1-i]%=mod
  table[x].append(N-1-i)

print(dp[0])


Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]
  dp[N-1-i]%=mod
  table[x].append(N-1-i)

print(dp[0])


Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])

Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1)
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]
  dp[N-1-i]%=mod
  table[x].append(N-1-i)

print(dp[0])


Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input()) for i in range(N)]
C=[C[i] for i in range(N) if i ==0 or C[i-1]!=C[i]]

import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]
  dp[N-1-i]%=mod
  table[x].append(N-1-i)

print(dp[0])


Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input()) for i in range(N)]
C=[C[i] for i in range(N) if i ==0 or C[i-1]!=C[i]]

import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]
  dp[N-1-i]%=mod
  table[x].append(N-1-i)

print(dp[0])

Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
C=[int(input()) for i in range(N)]
C=[C[i] for i in range(N) if i ==0 or C[i-1]!=C[i]]

import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]
    dp[N-1-i]%=mod
  table[x].append(N-1-i)

print(dp[0])

Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
C=[int(input()) for i in range(N)]
C=[C[i] for i in range(N) if i ==0 or C[i-1]!=C[i]]

import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]
  dp[N-1-i]%=mod
  table[x].append(N-1-i)

print(dp[0])

Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
C=[int(input()) for i in range(N)]
C=[C[i] for i in range(N) if i ==0 or C[i-1]!=C[i]]

import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]
  dp[N-1-i]%=mod
  table[x].append(N-1-i)

print(dp[0])

Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])