Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import heapq as hq
def solve():
    N, M = list(map(int, input().split()))
    plan = []
    for _ in range(N):
        plan.append(list(map(int, input().split())))
    task = {}
    for p in plan:
      if p[0] in task.keys():
        task[p[0]].append(-p[1])
      else:
        task[p[0]] = [-p[1]]
    choices = []
    res = 0
    d = task.keys()
    for day in range(1, M+1):
        if day in d:
            choices.extend(task[day])
            hq.heapify(choices)
        if len(choices) > 0:
            res += - hq.heappop(choices)
    print(res)

if __name__ == "__main__":
    solve()

Fixed submission:
import heapq as hq
def solve():
    N, M = list(map(int, input().split()))
    plan = []
    for _ in range(N):
        plan.append(list(map(int, input().split())))
    task = {}
    for p in plan:
      if p[0] in task.keys():
        task[p[0]].append(-p[1])
      else:
        task[p[0]] = [-p[1]]
    choices = []
    res = 0
    d = task.keys()
    for day in range(1, M+1):
        if day in d:
            for j in task[day]:
                hq.heappush(choices, j)
        if len(choices) > 0:
            res += - hq.heappop(choices)
    print(res)

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import heapq as hq
def solve():
    N, M = list(map(int, input().split()))
    plan = []
    for _ in range(N):
        plan.append(list(map(int, input().split())))
    task = {}
    for p in plan:
      if p[0] in task.keys():
        task[p[0]].append(-p[1])
      else:
        task[p[0]] = [-p[1]]
    choices = []
    res = 0
    d = task.keys()
    for day in range(1, M+1):
        if day in d:
            choices.extend(task[day])
            hq.heapify(choices)
        if len(choices) > 0:
            res += - hq.heappop(choices)
    print(res)

if __name__ == "__main__":
    solve()

Fixed submission:
import heapq as hq
def solve():
    N, M = list(map(int, input().split()))
    plan = []
    for _ in range(N):
        plan.append(list(map(int, input().split())))
    task = {}
    for p in plan:
      if p[0] in task.keys():
        task[p[0]].append(-p[1])
      else:
        task[p[0]] = [-p[1]]
    choices = []
    res = 0
    d = task.keys()
    for day in range(1, M+1):
        if day in d:
            for j in task[day]:
                hq.heappush(choices, j)
        if len(choices) > 0:
            res += - hq.heappop(choices)
    print(res)

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    N, *sl = map(lambda x: int(x), open(0).read().split())
    ans = "Yes"
    for i in range(N-1):
        a = sl[i] - 1
        b = min(sl[i+1:])
        if b < a:
            ans = "No"
            break
    print(ans)  
if __name__ == '__main__':
    solve()


Fixed submission:
def solve():
    N, *sl = map(lambda x: int(x), open(0).read().split())
    ans = "Yes"
    s_max = sl[0]
    for i in range(1, N):
        a = sl[i]
        if s_max > a + 1:
            ans = "No"
            break
        s_max = max(s_max, a)
    print(ans)  
if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    N, *sl = map(lambda x: int(x), open(0).read().split())
    ans = "Yes"
    for i in range(N-1):
        a = sl[i] - 1
        for j in range(i+1, N):
            if sl[j] < a:
                ans = "No"
                break
        else:
            continue
        break
    print(ans)  
if __name__ == '__main__':
    solve()

Fixed submission:
def solve():
    N, *sl = map(lambda x: int(x), open(0).read().split())
    ans = "Yes"
    s_max = sl[0]
    for i in range(1, N):
        a = sl[i]
        if s_max > a + 1:
            ans = "No"
            break
        s_max = max(s_max, a)
    print(ans)  
if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
    #include<iostream>
    #include<vector>
    #include<algorithm>
    #define lli long long
    #define all(i) i.begin(),i.end()
    #define rall(i) i.rbegin(),i.rend()
    #define rep0(i,j) for(int i=0;i<j;i++)
    #define rep1(i,j) for(int i=1;i<=j;i++)
    #define rep0d(i,j) for(int i=j-1;i>=0;i--)
    #define MAX 1000000007
     
    using namespace std;
     
     
     
    int main() {
        lli n, mi = 1e16;
        lli min;
        cin >> n;
        vector<lli> vec(5,0);
        rep0(i,5){
            cin >> vec[i];
        
            if(vec[i]<mi){
                min = i;
                mi = vec[i];
            }
        }
        
        cout << n/vec[min] + 4 + (n%vec[min]==0)?0:1;
    }

Fixed submission:
N = int(input())
a = []
for _ in range(5):
    a.append(int(input()))

bt = min(a)
bt_i = a.index(bt)
t = N // bt + (0 if N % bt == 0 else 1) + 4
print(t)
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

count=0
for sei in reversed(range(1,max((a,b)))):
    if a%sei==0 and b%sei==0:
        count += 1
        if count == k:
            break

print(sei)

Fixed submission:
a, b, k = map(int, input().split())

count=0
for sei in reversed(range(1, max((a,b))+1 )):
    if a%sei==0 and b%sei==0:
        count += 1
        if count == k:
            break

print(sei)
Buggy python submission (verdict: Runtime Error):
N = int(input())
dish = []
 for i in range(N):
     a, b = map(int, input().split())
     dish.append((a+b, (a,b)))

"""while True:
    try:
        a, b = map(int, input().split())
    except EOFError:
        break
    dish.append((a+b, (a,b)))
"""

l = sorted(dish)

t=a = 0
for i, (_, (a_i, b_i)) in enumerate(l):
    if i % 2 == 0:
        #takahashi
        t += a_i
    else:
        a += b_i

print(t-a)


Fixed submission:
n, x, y = [int(i) for i in input().split()]
tmp = x+y-n
if tmp <= 0:
    tmp = 0
print(min(x, y), tmp)
Buggy python submission (verdict: Time Limit Exceeded):
black = "B"
white = "W"
s = ""

def main():
    global s
    s = [c for c in input()]
    ans = one()
    tmp = ans
    while tmp != 0:
        tmp = one()
        ans += tmp
    print(ans) 

def one():
    global s
    ans = 0
    for i in range(len(s) - 1):
        if s[i] == black and s[i+1] == white:
            s[i], s[i+1] = s[i+1], s[i]
            ans += 1
    return ans

main()


Fixed submission:
black = "B"
white = "W"

def move_cost(s):
    a = 0
    count = 0
    for i, c in enumerate(s):
        if c == white:
            a += i
            count += 1
    count -= 1
    return a - count*(count+1)//2


print(move_cost(input()))

Buggy python submission (verdict: Time Limit Exceeded):
black = "B"
white = "W"

def main():
    s = [c for c in input()]
    ans = one(s)
    tmp = ans
    while tmp != 0:
        tmp = one(s)
        ans += tmp
    print(ans) 

def one(s):
    ans = 0
    for i in range(len(s) - 1):
        if s[i] == black and s[i+1] == white:
            s[i], s[i+1] = s[i+1], s[i]
            ans += 1
    return ans

main()


Fixed submission:
black = "B"
white = "W"

def move_cost(s):
    a = 0
    count = 0
    for i, c in enumerate(s):
        if c == white:
            a += i
            count += 1
    count -= 1
    return a - count*(count+1)//2


print(move_cost(input()))
Buggy python submission (verdict: Runtime Error):
a,b =map(input().split())
if a<10:a=10-a
else:a=0
print(b+ (a*100))

Fixed submission:
a,b =map(int, input().split())
if a<10:a=10-a
else:a=0
print(b+ (a*100))
Buggy python submission (verdict: Runtime Error):
s = input()
if s[3] = s[2] and s[4] = s[5]:
  print('Yes', end = '')
else:
  print('No',end = '')

Fixed submission:
s = input()
if s[3] == s[2] and s[4] == s[5]:
  print('Yes', end = '')
else:
  print('No',end = '')

Buggy python submission (verdict: Runtime Error):
s = input()
if s[3] = s[2] and s[4] = s[5]:
  print('Yes')
else:
  print('No')

Fixed submission:
s = input()
if s[3] == s[2] and s[4] == s[5]:
  print('Yes', end = '')
else:
  print('No',end = '')
Buggy python submission (verdict: Runtime Error):
ddd = [input() for i in range(2)]
eee = ddd[0].split()
fff = ddd[1].split()
longest_distance = 0

for i in range(len(fff - 1)):
    distance = fff[i+1] - fff[i]
    if longest_distance < distance:
        longest_distance = distance

shortest_road = eee[0] - longest_distance

print(shortest_road)


Fixed submission:
ddd = [input() for i in range(2)]
eee = ddd[0].split()
fff = ddd[1].split()
longest_distance = int(eee[0]) + int(fff[0]) - int(fff[-1])
for i in range(len(fff) - 1):
    distance = int(fff[i+1]) - int(fff[i])
    if longest_distance < distance:
        longest_distance = distance
shortest_road = int(eee[0]) - longest_distance
print(shortest_road)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
a = list(map(int,input().split()))

table = set(a)

con = {}
dic = {}
ans = []

con = Counter(a)
dic = {}
#for i in table:
#    con[i] = a.count(i)
#    dic[i] = -1

for x in a:
    if dic[x] == None:
        ex = (con[x] - 1) * (con[x] - 2) / 2
        no = (con[x]) * (con[x] - 1) / 2
        dic[x] = (int(no), int(ex))

su = sum([int(x[0]) for x in dic.values()])

for i,x in enumerate(a):
    print(su - (dic[x][0] - dic[x][1]))


Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int,input().split()))

#table = set(a)
con = Counter(a)
dic = {}
#for i in table:
#    con[i] = a.count(i)
#    dic[i] = -1

for x in a:
    if x not in dic:
        ex = (con[x] - 1) * (con[x] - 2) / 2
        no = (con[x]) * (con[x] - 1) / 2
        dic[x] = (int(no), int(ex))

su = sum([int(x[0]) for x in dic.values()])

for i,x in enumerate(a):
    print(su - (dic[x][0] - dic[x][1]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

table = set(a)

con = {}
dic = {}
ans = []
for i in table:
    con[i] = a.count(i)
    dic[i] = -1

for x in a:
    if dic[x] == -1:
        ex = (con[x] - 1) * (con[x] - 2) / 2
        no = (con[x]) * (con[x] - 1) / 2
        dic[x] = (int(no), int(ex))

su = sum([int(x[0]) for x in dic.values()])

for i,x in enumerate(a):
    print(su - (dic[x][0] - dic[x][1]))


Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int,input().split()))

#table = set(a)
con = Counter(a)
dic = {}
#for i in table:
#    con[i] = a.count(i)
#    dic[i] = -1

for x in a:
    if x not in dic:
        ex = (con[x] - 1) * (con[x] - 2) / 2
        no = (con[x]) * (con[x] - 1) / 2
        dic[x] = (int(no), int(ex))

su = sum([int(x[0]) for x in dic.values()])

for i,x in enumerate(a):
    print(su - (dic[x][0] - dic[x][1]))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

def prob_a(args):
    s = args[1]
    chars = list(s)
    tmpc = chars[0]
    for c in chars[1:]:
        if c == tmpc:
            continue
        else:
            print('Yes')
            return 0
    print('No')

if __name__ == '__main__':
    args = sys.argv
    prob_a(args)


Fixed submission:
# -*- coding: utf-8 -*-

import sys

def prob_a(s):
    chars = list(s)
    tmpc = chars[0]
    for c in chars[1:]:
        if c == tmpc:
            continue
        else:
            print('Yes')
            return 0
    print('No')

if __name__ == '__main__':
    s = input()
    prob_a(s)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

def prob_b(n, a, b):
    n, a, b = int(n), int(a), int(b)
    x = int(n / (a + b)) * a
    y = n % (a + b)
    print(x+y)


if __name__ == '__main__':
    args = sys.argv
    n = args[1]
    a = args[2]
    b = args[3]
    prob_b(n,a,b)


Fixed submission:
# -*- coding: utf-8 -*-

import sys


def prob_b(n, a, b):
    x = int(n / (a + b)) * a
    y = min(n % (a + b), a)
    print(x+y)


if __name__ == '__main__':
    #args = sys.argv
    #n = args[1]
    #a = args[2]
    #b = args[3]
    n, a, b = map(int, input().split())
    prob_b(n,a,b)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

def check(a, b, x):
    if int(x * 0.08) != a or int(x * 0.1) != b:
        return -1
    return x

def prob_c(a, b):
    yasu = a * 100 / 8
    yasutaka = (a+0.99) * 100 / 8
    taka = b * 100 / 10
    takataka = (b+0.99) * 100 / 10
    ans = check(a, b, max(yasu, taka))
    print(f'{ans}')

if __name__ == '__main__':
    a, b = map(int, input().split())
    prob_c(a,b)
    


Fixed submission:
# -*- coding: utf-8 -*-

from math import ceil

def check(a, b, x):
    if int(x * 0.08) != a or int(x * 0.1) != b:
        return -1
    return x

def prob_c(a, b):
    yasu = ceil(a * 100 / 8)
    taka = ceil(b * 100 / 10)
    ans = int(check(a, b, max(yasu, taka)))
    print(ans)

if __name__ == '__main__':
    a, b = map(int, input().split())
    prob_c(a,b)
Buggy python submission (verdict: Runtime Error):
#coding: utf-8

base = 700
output = base

s = input()
for i in range(3):
    if s[i] == "○":
        output += 100
    else:

print(output)


Fixed submission:
#coding: utf-8

base = 700
output = base

s = input()
for i in range(3):
    if s[i] == "o":
        output += 100

print(output)
Buggy python submission (verdict: Runtime Error):
n1 = list(map(int, input().split()))
n2 = list(map(int, input().split()))
n3 = list(map(int, input().split()))
arr = []
z=0
for i in range(10):
    arr.append(int(input()))
    if arr[i] == n1[0] or arr[i] == n1[1] or arr[i] == n1[2] or arr[i] == n2[0] or arr[i] == n2[1] or arr[i] == n2[2] or arr[i] == n3[0] or arr[i] == n3[1] or arr[i] == n3[2]:
        z+=1
if z >= 3: print("Yes")
else: print("No")

Fixed submission:
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
#
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
n1 = list(map(int, input().split()))
n2 = list(map(int, input().split()))
n3 = list(map(int, input().split()))
arr = []
z=0
for i in range(10):
    arr.append(int(input()))
    if arr[i] == n1[0] or arr[i] == n1[1] or arr[i] == n1[2] or arr[i] == n2[0] or arr[i] == n2[1] or arr[i] == n2[2] or arr[i] == n3[0] or arr[i] == n3[1] or arr[i] == n3[2]:
        z+=1
if z >= 3: print("Yes")
else: print("No")

Fixed submission:
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
#
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input(""))
M = int(input(""))
if N<100 and N>M and M>0:
    if N == M:
        print("yes")
    else:
        print("No")
else:
    print("error")


Fixed submission:
n,m = map(int, input().split())
print('Yes' if n==m else 'No')

Buggy python submission (verdict: Runtime Error):
N = int(input(""))
M = int(input(""))
if N == M:
    print("yes")
else:
    print("No")


Fixed submission:
n,m = map(int, input().split())
print('Yes' if n==m else 'No')

Buggy python submission (verdict: Runtime Error):
N = int(input("Enter the number: "))
M = int(input("Enter the number "))
if N == M:
    print("yes")
else:
    print("No")
    
    

Fixed submission:
n,m = map(int, input().split())
print('Yes' if n==m else 'No')

Buggy python submission (verdict: Runtime Error):
N = int(input("Enter the number: "))
M = int(input("Enter the number "))
if N == M:
    print("yes")
else:
    print("No")
    

Fixed submission:
n,m = map(int, input().split())
print('Yes' if n==m else 'No')

Buggy python submission (verdict: Runtime Error):
N = int(input("Enter the number: "))
M = int(input("Enter the number "))
if N == M:
    print("yes")
else:
    print("No")
    

Fixed submission:
n,m = map(int, input().split())
print('Yes' if n==m else 'No')
Buggy python submission (verdict: Runtime Error):
import math


A, B = map(int, input().split())
gcd = math.gcd(A, B)

print((A * B) // gcd)

Fixed submission:
import fractions


A, B = map(int, input().split())
gcd = fractions.gcd(A, B)

print((A * B) // gcd)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())
A = list(A)
index = 0
sum = 0
j = 0
prev = 0


for i in range(N):
    index = j
    for a in A[index:]:
        j = j + 1
        if a == (i+1):
           sum = sum + 1
           break
    if prev == sum:
        break
    else:
        prev = sum

if sum == 0:
    print('-1')
else:
    print(N-sum)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

num = 1
ans = 0

for i in A:
    if i == num:
        num += 1
    else:
        ans += 1

if num == 1:
    print('-1')
else:
    print(str(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())
A = list(A)
index = 0
sum = 0
j = 0

for i in range(N):
    index = j
    for a in A[index:]:
        j = j + 1
        if a == (i+1):
           sum = sum + 1
           break

if sum == 0:
    print('-1')
else:
    print(N-sum)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

num = 1
ans = 0

for i in A:
    if i == num:
        num += 1
    else:
        ans += 1

if num == 1:
    print('-1')
else:
    print(str(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

for i in range(1, N+1):
    print(A.index(i)+1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

result = [0] * (N+1)
for i in range(0, N):
    result[A[i]-1] = i+1

for i in range(N):
    print(result[i])
Buggy python submission (verdict: Runtime Error):
M = input()
D = input()

M, D = int(M), int(D)

# print("M:", M, "D:", D)

count = 0
# days = []

for m in range(1, M+1):
    for d in range(1, D+1):
        # print("m: ", m, " d: ", d, " d10: ", d/10, " d1", d%10)
        d1 = d % 10
        d10 = d // 10
        if (d1 * d10) == m and d1 != 1 and d10 != 1:
            # days.append("{}月{}日".format(m, d))
            count += 1

# for day in days:
#     print(day)
print(count)

Fixed submission:
M, D = map(int, input().split())

# print("M:", M, "D:", D)

count = 0
# days = []

for m in range(1, M+1):
    for d in range(1, D+1):
        # print("m: ", m, " d: ", d, " d10: ", d/10, " d1", d%10)
        d1 = d % 10
        d10 = d // 10
        if (d1 * d10) == m and d1 != 1 and d10 != 1:
            # days.append("{}月{}日".format(m, d))
            count += 1

# for day in days:
#     print(day)
print(count)
Buggy python submission (verdict: Runtime Error):
n,m = list(map(int, input().split()))
x = list(map(int, input().split()))

if n >= m:
    print(0)
    exit()
else:
    difference = []
    x.sort()
 
    for i in range(m-1):
        difference.append(x[i+1]-x[i])
 
    difference.sort()
 
    print(sum(difference[:n-1]))


Fixed submission:
t,x = input().split()
print(int(t)/int(x))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
li=[0]
ans=n
for i in s:
    li+=[li[-1]+1] if i=='#' else [li[-1]]
b=li[-1]
for i in range(n+1):
    temp=li[i]+n-i-b+li[i]
    ans=min(ans,temp)
print(ans)n

Fixed submission:
n=int(input())
s=list(input())
li=[0]
ans=n
for i in s:
    li+=[li[-1]+1] if i=='#' else [li[-1]]
b=li[-1]
for i in range(n+1):
    temp=li[i]+n-i-b+li[i]
    ans=min(ans,temp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
s=list(map(int,list(input())))
t=[1 if s[0]==1 else -1]
ans=0
for i in range(1,n):
    if s[i]==s[i-1]:
        t[-1]+=1 if s[i]==1 else -1
    else:
        t+=[1 if s[i]==1 else -1]
for i in range(len(t)):
    temp=0
    l=k*2+1 if t[i]>0 else k*2
    for j in range(l):
        if 0<=i+j<len(t):
            temp+=abs(t[i+j])
    ans=max(ans,temp)
print(ans)

Fixed submission:
n,k=map(int,input().split())
s=list(map(int,list(input())))
t=[0]+[1 if s[0]==1 else -1]
ans=0
for i in range(1,n):
    if s[i]==s[i-1]:
        t[-1]=i+1 if s[i]==1 else -i-1
    else:
        t+=[i+1 if s[i]==1 else -i-1]
for i in range(len(t)-1):
    temp=0
    l=k*2+1 if t[i+1]>0 else k*2
    temp=abs(t[min(len(t)-1,i+l)])-abs(t[i])
    ans=max(ans,temp)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sy=sys.stdin.readline

n=int(sy())
dp=[0]*(n+1)
lis=[0]*(2*10**5+1)
dp[0],dp[1],dp[2]=0,1,1
c1=int(sy())
c2=int(sy())
lis[c1]=1
lis[c2]=2
for i in range(3,n+1):
    c1=c2
    c2=int(sy())
    if c1==c2 or lis[c2]==0:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]+dp[lis[c2]]
    lis[c2]=i
    dp[i]%=1000000007
print(dp[n])

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

n=int(sy())
if n==1:
    print(1)
    quit()
dp=[0]*(n+1)
lis=[0]*(2*10**5+1)
dp[0],dp[1],dp[2]=0,1,1
c1=int(sy())
c2=int(sy())
lis[c1]=1
lis[c2]=2
for i in range(3,n+1):
    c1=c2
    c2=int(sy())
    if c1==c2 or lis[c2]==0:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]+dp[lis[c2]]
    lis[c2]=i
    dp[i]%=1000000007
print(dp[n])

Buggy python submission (verdict: Runtime Error):
import sys
sy=sys.stdin.readline

n=int(sy())
dp=[0]*(n+1)
lis=[0]*(n+1)
dp[0],dp[1],dp[2]=0,1,1
c1=int(sy())
c2=int(sy())
lis[c1]=1
lis[c2]=2
for i in range(3,n+1):
    c1=c2
    c2=int(sy())
    if c1==c2 or lis[c2]==0:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]+dp[lis[c2]]
    lis[c2]=i
    dp[i]%=1000000007
print(dp[n])

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

n=int(sy())
if n==1:
    print(1)
    quit()
dp=[0]*(n+1)
lis=[0]*(2*10**5+1)
dp[0],dp[1],dp[2]=0,1,1
c1=int(sy())
c2=int(sy())
lis[c1]=1
lis[c2]=2
for i in range(3,n+1):
    c1=c2
    c2=int(sy())
    if c1==c2 or lis[c2]==0:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]+dp[lis[c2]]
    lis[c2]=i
    dp[i]%=1000000007
print(dp[n])

Buggy python submission (verdict: Runtime Error):
import sys
sy=sys.stdin.readline

n=int(sy())
dp=[0]*(n+1)
lis=[0]*(n+1)
dp[0],dp[1],dp[2]=0,1,1
c1=int(sy())
c2=int(sy())
lis[c1]=1
lis[c2]=2
for i in range(3,n+1):
    c1=c2
    c2=int(sy())
    if c1==c2 or lis[c2]==0:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]+dp[lis[c2]]
    lis[c2]=i
print(dp[n])

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

n=int(sy())
if n==1:
    print(1)
    quit()
dp=[0]*(n+1)
lis=[0]*(2*10**5+1)
dp[0],dp[1],dp[2]=0,1,1
c1=int(sy())
c2=int(sy())
lis[c1]=1
lis[c2]=2
for i in range(3,n+1):
    c1=c2
    c2=int(sy())
    if c1==c2 or lis[c2]==0:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]+dp[lis[c2]]
    lis[c2]=i
    dp[i]%=1000000007
print(dp[n])

Buggy python submission (verdict: Runtime Error):
import sys
sy=sys.stdin.readline

n=int(sy())
dp=[[] for _ in range(n+1)]
lis=[[] for _ in range(n+1)]
dp[0],dp[1],dp[2]=0,1,1
c1=int(sy())
c2=int(sy())
lis[c1]+=[1]
lis[c2]+=[2]
for i in range(3,n+1):
    c1=c2
    c2=int(sy())
    if c1==c2 or lis[c2]==[]:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]+dp[lis[c2][-1]]
    lis[c2]+=[i]
print(dp[n])

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

n=int(sy())
if n==1:
    print(1)
    quit()
dp=[0]*(n+1)
lis=[0]*(2*10**5+1)
dp[0],dp[1],dp[2]=0,1,1
c1=int(sy())
c2=int(sy())
lis[c1]=1
lis[c2]=2
for i in range(3,n+1):
    c1=c2
    c2=int(sy())
    if c1==c2 or lis[c2]==0:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]+dp[lis[c2]]
    lis[c2]=i
    dp[i]%=1000000007
print(dp[n])