Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03001 (python)

Fixed submission:
W,H,x,y=map(float,input().split())
answer=0
if W/2==x and H/2==y:
  answer=1
print(W*H/2,answer)

Buggy submission (verdict: Runtime Error):
W,H,x,y=map(float,input().split())
answer=0
if W//2==x and H//2==y:
  answer=1
print(W*H//2 answer)
Problem p03067 (python)

Fixed submission:
abc=list(map(int,input().split()))
if max(abc)==abc[0] and min(abc)==abc[1] or max(abc)==abc[1] and min(abc)==abc[0]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
abc=list(map(int,input().split()))
if max(abc)=abc[2]:
  print("Yes")
else:
  print("No")
Problem p03068 (python)

Fixed submission:
n=int(input())
s=list(input())
k=int(input())
for i in range(n):
  if s[i]!=s[k-1]:
    print("*",end="")
  else:
    print(s[i],end="")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
k=int(input())
for i in range(n):
  if s[i]!=s[k]:
    print("*",end="")
  else:
    print(s[i],end="")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
k=int(input())
a=0
a=s[k]
for i in range(n):
  if k[i]!=a:
    print("*",end="")
  else:
    print(k[i],end="")
Problem p03102 (python)

Fixed submission:
n,m,c=map(int,input().split())
b=[0 for i in range(m)]
a=[[0 for i in range(m)]for i in range(n)]
k=[0 for i in range(m)]
count=0
b=list(map(int,input().split()))
a=[list(map(int,input().split()))for i in range(n)]
for i in range(n):
  ans=0
  for j in range(m):
    ans=ans+(a[i][j]*b[j])
  if (ans+c)>0:
    count=count+1
print(count)

Buggy submission (verdict: Runtime Error):
n,m,c=map(int,input().split())
b=[0 for i in range(m)]
a=[[0 for i in range(m)]for i in range(n)]
ans=0
count=0
for i in range(m):
  b[i]=int(input())
for i in range(n):
  for j in range(m):
    a[n][j]=int(input())
for i in range(n):
  for j in range(m):
    ans=ans+a[n][j]*b[j]
  if (ans+c)>0:
    count=count+1
print(count)
Problem p03106 (python)

Fixed submission:
a,b,n=map(int,input().split())
c=[]
i=0
while(1):
  i=i+1
  if a%i==0 and b%i==0:
    c.append(i)
  if a<=i or b<=i:
    break
d=len(c)-n
print(c[d])

Buggy submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
c=[]
i=0
while(1):
  i=i+1
  if a%i==0 and b%i==0:
    c,append(i)
  if a<=i or b<=i:
    break
d=(len(c)-k+1)
print(c[d])

Buggy submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
c=[]
i=0
while(1):
  i=i+1
  if a%i==0 and b%i==0:
    c,append(i)
  if a<=i or b<=i:
    break
print(c[(len(c)-k+1)])
Problem p03109 (python)

Fixed submission:
s=list(map(int,input().split("/")))
if (s[0]==2019 and s[1]<=4) or (s[0]<2019):
  print("Heisei")
else:
  print("TBD")

Buggy submission (verdict: Runtime Error):
s=list(map(int,input().split("/")))
if (s[0]=2019 and s[1]<=4) or (s[0]<2019):
  print("Heisei")
else:
  print("TBD")
Problem p03239 (python)

Fixed submission:
n,t=map(int,input().split())
ct=[list(map(int,input().split())) for i in range(n)]
ans=1001
for i in range(n):
  if ct[i][0]<=ans and ct[i][1]<=t:
    ans=ct[i][0]
if ans<1001:
  print(ans)
else:
  print("TLE")

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
ct=[list(map(int,input().split())) for i in range(n)]
ans=1001
for i in range(n):
  if ct[n][1]<=t and ct[n][0]<=ans:
    ans=ct[n][0]
if ans<1001:
  print(ans)
else:
  print("TLE")

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().spplit())
ct=[list(map(int,input().split())) for i in range(n)]
ans=1001
for i in range(n):
  if ct[n][1]<=t and ct[n][0]<=ans:
    ans=ct[n][0]
if ans<1001:
  print(ans)
else:
  print("TLE")
Problem p03316 (python)

Fixed submission:
n=int(input())
s=n
temp=0
while s:
  temp=temp+s%10
  s=s//10
if n%temp==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=n
temp=0
while s:
  temp=temp+s%10
  s=s//10
if n%s==0:
  print("Yes")
else:
  print("No")
Problem p03493 (python)

Fixed submission:
s=list(input())
ans=0
for i in s:
  if i=="1":
    ans=ans+1
print(ans)

Buggy submission (verdict: Runtime Error):
s=list(int(input()))
ans=0
for i in s:
  if i==1:
    ans=ans+1
print(ans)
Problem p03494 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
while 1:
  for i in range(n):
    if a[i]%2==0:
      a[i]=a[i]//2
    else:
      break
  else:
    ans=ans+1
    continue
  break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=map(int,input().split())
ans=0
while 1:
  for i in range(n):
    if a[i]%2==0:
      a[i]=a[i]//2
    else:
      break
  else:
    ans=ans+1
    continue
  break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=map(int,input().split())
ans=0
while 1:
  for i in range(n):
    if s[i]%2==0:
      s[i]=s[i]//2
    else:
      break
  else:
    ans=ans+1
    continue
  break
print(ans)
Problem p04043 (python)

Fixed submission:
a,b,c=map(int,input().split())
if ((a+b==10 and a==5) and c==7) or ((a+b==12 and c==5) and (a==5 or b==5)):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if ((a+b==10 and a==5) and c==7) or ((a+b=12 and c==5) and (a==5 or b==5)):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if (a+b==10 and a==5 and c==7) or (a+b=12 and c==5 and (a==5 or b==5)):
  print("YES")
else:
  print("NO")
Problem p02861 (python)

Fixed submission:
import numpy as np

def main():
    N = int(input())
    x = []
    for i in range(N):
        x.append(list(map(int, input().split())))
    X = np.array(x)
    j = 0
    for i in range(N-1):
        for k in range(i+1, N):
            j += np.linalg.norm(X[i] - X[k], ord=2)

    print(2*j/N) # 2(N-1)!/N!

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np

def main():
    N = int(input())
    x = []
    for i in range(N):
        x.append(list(map(int, input().split())))
    X = np.array(x)
    j = 0
    for i in range(N-1):
        for k in range(i+1, N):
            j += np.linalg.norm(X[i] - X[k], ord=2)

    print(2*j/N) # 2(N-1)!/N!

if __name__ == "__main__":
    main()
Problem p02888 (python)

Fixed submission:
from bisect import bisect_right
def main():
	N = int(input())
	L = list(map(int, input().split(" ")))
	L.sort()
	k = 0
	for i in reversed(range(2, N)):
		a = L[i]
		for j in reversed(range(1, i)):
			b = L[j]
			index = bisect_right(L, a-b, hi=j)
			k += j - index
	print(k)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
  	N = int(input())
	l = list(map(int, input().split(" ")))
	k = 0
	for i in range(N-2):
    	a = l[i]
    	for j in range(i+1, N-1):
        	b = l[j]
        	k += len([p for p in l[j+1:] if abs(b-a) < p < (a+b)])
	print(k)
main()
Problem p02901 (python)

Fixed submission:
def main():
  Inf = 10**8
  N, M = list(map(int, input().split(" ")))
  keys = []
  for _ in range(M):
      c = list(map(int, input().split(" ")))
      j = list(map(int, input().split(" ")))
      keys.append([c[0], sum([1 << k-1 for k in j])])
  dp = [Inf for _ in range(1 << N)]
  dp[0] = 0
  for i in range(len(dp)):
      for key in keys:
          t = i | key[1]
          dp[t] = min(dp[t], key[0] + dp[i])
  if dp[-1]==Inf:
      print(-1)
  else:
      print(dp[-1])
main()

Buggy submission (verdict: Runtime Error):
from math import inf
N, M = list(map(int, input().split(" ")))
keys = []
for _ in range(M):
	c = list(map(int, input().split(" ")))
	j = list(map(int, input().split(" ")))
	keys.append([c[0], sum([1 << k-1 for k in j])])
dp = [inf for _ in range(1 << N)]
dp[0] = 0
for i in range(len(dp)):
    for key in keys:
        t = i | key[1]
        dp[t] = min(dp[t], key[0] + dp[i])
if dp[-1]==inf:
    print(-1)
else:
    print(dp[-1])
Problem p02922 (python)

Fixed submission:
from math import ceil

s, t = map(int, input().split())
a = t-s
print(1+ceil(a/(s-1)))

Buggy submission (verdict: Runtime Error):
s, t = map(int, input().split())
a = t-s
print(1+int(a/(s-1))
Problem p02924 (python)

Fixed submission:
a = int(input())
print(a*(a-1)//2)

Buggy submission (verdict: Runtime Error):
a = int(input())
print(int(0.5*a*(a+1))
Problem p02927 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 24 21:04:16 2019

@author: Toroi0610
"""

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

M, D = map(int, input().split())
day = [str(d) for d in range(1, D+1)]
cnt = 0
for m in range(1, M+1):
    s = make_divisors(m)
    length = len(s)
    if length == 2:
        continue
    if length%2 == 0:
        for l, r in zip(s[:int(length/2)], s[int(length/2):][::-1]):
            if (l > 10) or (r > 10) or (l==1):
                continue
            else:
                if str(l)+str(r) in day:
                    cnt += 1
                if str(r)+str(l) in day:
                    cnt += 1
    else:
        for l, r in zip(s[:int(length/2)+1], s[int(length/2):][::-1]):
            if (l > 10) or (r > 10) or (l==1):
                continue
            else:
                if str(l)+str(r) in day:
                    cnt += 1
                if l != r:
                    if str(r)+str(l) in day:
                        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
_, K = map(int, input().split())
a = list(map(int, input().split()))
s = [sum([b > c for c in a]) for b in a]
r = [sum([b > c for c in a[i:]]) for i, b in enumerate(a)]
b = (sum(r) + sum(s)*(K-1)/2)*K + sum(r)
print(int(b%(1e9+7)))
Problem p02928 (python)

Fixed submission:
MAX = 10**9 + 7
_, K = map(int, input().split())
a = list(map(int, input().split()))
s = [sum([b > c for c in a]) for b in a]
r = [sum([b > c for c in a[i:]]) for i, b in enumerate(a)]
b = sum(s)*(K-1)*K//2%MAX
print((b+sum(r)*K)%MAX)

Buggy submission (verdict: Runtime Error):
_, K = map(int, input())
a = list(map(int, input().split()))
s = [sum([b > c for c in a]) for b in a]
r = [sum([b > c for c in a[i:]]) for i, b in enumerate(a)]
b = (sum(r) + sum(s)*(K-1)/2)*K + sum(r)
print(int(b%(1e9+7)))

Buggy submission (verdict: Runtime Error):
_, K = map(int, input())
a = list(map(int, input().split()))
s = [sum([b > c for c in a]) for b in a]
l = [sum([l < a[i] for l in a[:i]]) for i in range(1, len(a))]
l.insert(0, 0)
r = [b - c for b, c in zip(s, l)]
a = (sum(r)*(1+K) + sum(l)*(K-1))*K/2
print(int(a%(1e9+7)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
a = list(map(int, input().split()))
s = [sum([b > c for c in a]) for b in a]
l = [sum([l < a[i] for l in a[:i]]) for i in range(1, len(a))]
l.insert(0, 0)
r = [[b - c for b, c in zip(s, l)]]
a = sum(r) * (1+K)*K/2 + sum(l) * (K-1)*K/2
print(int(a)%(1e9+7))

Buggy submission (verdict: Runtime Error):
a = list(map(int, "2 1".split()))
s = [sum([b > c for c in a]) for b in a]
p = [sum([l < a[i] for l in a[:i]]) for i in range(1, len(a))]
print((sum(s)*(1+K)*K/2 - sum(p))%(1e9+7))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split()
a = list(map(int, input().split()))
s = [sum([b > c for c in a])*K for b in a]
p = [sum([l < a[i] for l in a[:i]]) for i in range(1, len(a))]
print(int((sum(s)-sum(p))%(1e9+7)))
Problem p02936 (python)

Fixed submission:
from collections import deque
N, Q = map(int, input().split())
brunch = [[] for _ in range(N)]
value = [0 for _ in range(N)]

for _ in range(N-1):
  a, b = map(int, input().split())
  brunch[a-1].append(b-1)
  brunch[b-1].append(a-1)
  
for _ in range(Q):
  f, val = map(int, input().split())
  value[f-1] += val

d = deque()
d.append((0, -1))
while len(d):
  root, from_root = d.popleft()
  for to in brunch[root]:
    if to == from_root:
      continue
    value[to] += value[root]
    d.append((to, root))
print(' '.join(map(str, value)))

Buggy submission (verdict: Runtime Error):
N, Q = list(map(int, input().split()))
brunch = [[] for _ in range(N)]
value = [0 for _ in range(N)]
for _ in range(N-1):
  a, b = list(map(int, input().split()))
  brunch[a-1].append(b-1)

def flow(fr, v, brunch, v_list):
  v_list[fr] += v
  for to in brunch[fr]:
    v_list = flow(to, v, brunch, v_list)
  return v_list

for _ in range(Q):
  frr, val = list(map(int, input().split()))
  value = flow(frr-1, val, brunch, value)
print(' '.join(map(str, value)))
Problem p02947 (python)

Fixed submission:
def main():
	N = int(input())
	s = {}
	pair = 0
	for _ in range(N):
		b = "".join(sorted([a for a in input()]))
		if b in s.keys():
			pair += s[b]
			s[b] += 1
		else:
			s[b] = 1
	print(pair)
main()

Buggy submission (verdict: Runtime Error):
N = int(input())
s = []
for _ in range(N):
	s.append("".joint(sorted([a for a in input()])))
pair = 0
for i in range(N-1):
	for j in range(i+1, N):
		if s[i] == s[j]:
			pair += 1
print(pair)
Problem p03106 (python)

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 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)
Problem p03139 (python)

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 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)
Problem p02765 (python)

Fixed submission:
a,b =map(int, input().split())
if a<10:a=10-a
else:a=0
print(b+ (a*100))

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

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 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]))
Problem p02755 (python)

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 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)
Problem p03369 (python)

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 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)
Problem p02760 (python)

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 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")

Buggy 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")
Problem p02789 (python)

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

Buggy 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")

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

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

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

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

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 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)
Problem p03063 (python)

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 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
Problem p03096 (python)

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 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])

Buggy 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])

Buggy 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])

Buggy 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])
Problem p03150 (python)

Fixed submission:
s=input()
s=list(s)
a=list('keyence')
for i in range(8):
    if s[:i]==a[:i] and s[i-7:]==a[i-7:]:
        print('YES')
        quit()
print('NO')

Buggy submission (verdict: Runtime Error):
s=input()ß
s=list(s)
a=list('keyence')
for i in range(8):
    if s[:i]==a[:i] and s[i-7:]==a[i-7:]:
        print('YES')
        quit()
print('NO')
Problem p03212 (python)

Fixed submission:
a3={'357','375','537','573','735','753'}
def make_a(a,n):
    new_a=set()
    for i in a:
        for j in range(n+1):
            new_a.add(i[:j]+'3'+i[j:])
            new_a.add(i[:j]+'5'+i[j:])
            new_a.add(i[:j]+'7'+i[j:])
    return new_a
a4=make_a(a3,3)
a5=make_a(a4,4)
a6=make_a(a5,5)
a7=make_a(a6,6)
a8=make_a(a7,7)
a9=make_a(a8,8)
a=list(map(int,a3))+list(map(int,a4))+list(map(int,a5))+list(map(int,a6))+list(map(int,a7))+list(map(int,a8))+list(map(int,a9))
n=int(input())
a.append(n)
a.sort()
ans=a.index(n)
if ans!=len(a)-1:
    if a[ans]==a[ans+1]:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
a3={'357','375','537','573','735','753'}
def make_a(a,n):
    new_a=set()
    for i in a:
        for j in range(n+1):
            new_a.add(i[:j]+'3'+i[j:])
            new_a.add(i[:j]+'5'+i[j:])
            new_a.add(i[:j]+'7'+i[j:])
    return new_a
a4=make_a(a3,3)
a5=make_a(a4,4)
a6=make_a(a5,5)
a7=make_a(a6,6)
a8=make_a(a7,7)
a9=make_a(a8,8)
a=list(map(int,a3))+list(map(int,a4))+list(map(int,a5))+list(map(int,a6))+list(map(int,a7))+list(map(int,a8))+list(map(int,a9))
n=int(input())
a.append(n)
a.sort()
ans=a.index(n)
if a[ans]==a[ans+1]:
    ans+=1
print(ans)