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

Fixed submission:
C = input()
letters = "abcdefghijklmnopqrstuvwxyz"
list_letters = list(letters)
print(list_letters[letters.find(C)+1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

l = [list(input().split()) for _ in range(M)]

answers = {}
wrongs = {}

for a in l:
    if a[1] == "AC":
        answers[a[0]] = a[1]
    elif a[1] == "WA":
        if not a[0] in wrongs:
            wrongs[a[0]] = 1
        elif a[0] in wrongs:
            wrongs[a[0]] = wrongs[a[0]] + 1

# 集計
wc = 0
for k, v in wrongs.items():
    if k in answers.keys():
        wc += 1
result = [len(answers.keys()), wc]

print(result[0], result[1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

l = [list(input().split()) for _ in range(M)]

answers = {}
wrongs = {}

for a in l:
    if a[1] == "AC":
        answers[a[0]] = a[1]
    elif a[1] == "WA":
        if not a[0] in answers:
            if a[0] in wrongs:
                wrongs[a[0]] = wrongs[a[0]] + 1
            else:
                wrongs[a[0]] = 1


# 集計
result = [len(answers.keys()), sum(wrongs.values())]

print(result[0], result[1])

Buggy submission (verdict: Runtime Error):
N, K, M = map(int, input().split())
tests = map(int, input().split())

total = sum(tests)

for i in range(K):
    if (total + i) / N >= M:
        print(i)
        exit(0)
print(-1)
Problem p02811 (python)

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

if X <= N * 500:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())

if X > N * 500:
  return Yes
return No
Problem p02817 (python)

Fixed submission:
s, t = input().split()

print("".join([t,s]))

Buggy submission (verdict: Runtime Error):
s, t = input.split()

print("".join([t,s]))
Problem p02885 (python)

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

if int(a) - int(b) * 2 > 0:
    print(int(a) - int(b) * 2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a, b = input().split()

if int(a) - int(b) * 2 > 0:
	print(int(a) - int(b) * 2)
else
	print(0)
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())

pen= [0] * (n+1)
result=[False] * (n+1)
cnt = 0
pen_sum = 0
for i in range(m):
    p1, s1 = input().split()
    p1 = int(p1)
    if s1 == "AC" and not result[p1]:
        result[p1] = True
        cnt += 1
        pen_sum += pen[p1]
    if s1 == "WA" and not result[p1]:
        pen[p1] += 1

print("{} {}".format(cnt, pen_sum))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
p = []
s = []
pen= [0] * (n+1)
result=[False] * (n+1)
cnt = 0
for i in range(m):
    p1, s1 = input().split()
    p1 = int(p1)
    p.append(p1)
    s.append(s1)

    if s1 == "AC" and not result[p1]:
        result[p1] = True
        cnt += 1
    if s1 == "WA" and not result[p1]:
        pen[p1] += 1
print(f"{cnt} {sum(pen)}")
Problem p03511 (python)

Fixed submission:
l = int(input())
a = input()
b = input()

if len(a) > len(b):
    k = b
    b = a
    a = k

mina = None
maxa = None
"""
f = [None] * (l + 1)

f[0] = ''
#print(f)
for i in range(l):
    tmpa = None
    tmpb = None
    if i + 1 >= len(a) and f[i + 1 - len(a)] is not None:
        tmpa = a + f[i + 1 - len(a)]
    if i + 1 >= len(b) and f[i + 1 - len(b)] is not None:
        tmpb = b + f[i + 1 - len(b)]
    if tmpa is None and tmpb is None:
        continue
    if tmpa is None and tmpb is not None:
        f[i+1] = tmpb
        continue
    if tmpb is None and tmpa is not None:
        f[i+1] = tmpa
        continue
    if tmpa < tmpb:
        f[i+1] = tmpa
    else:
        f[i+1] = tmpb
print(f[l])

def less(a, b):
    if a < b:
        if not b.startswith(a):
            return True
        else:
            c = b
            while c.startswith(a):
                c = c[len(a):]
            if a < c:
                return True
            else:
                return False

"""
for i in range(l+ 1) :
    if i * len(a) > l:
        break
    if (l - i * len(a)) % len(b) == 0:
        if mina is None:
            mina = i
            maxb = (l - i * len(a)) // len(b)
        maxa = i
        minb = (l - i * len(a)) // len(b)


ans1 = a * maxa + b * minb
ans2 = b * maxb + a * mina

if ans1 < ans2:
    print(ans1)
else:
    print(ans2)

Buggy submission (verdict: Runtime Error):
l = int(input())
a = input()
b = input()

if len(a) > len(b):
    k = b
    b = a
    a = k

mina = None
maxa = None

f = [None] * (l + 1)

f[0] = ''
#print(f)
for i in range(l):
    tmpa = None
    tmpb = None
    if i + 1 >= len(a) and f[i + 1 - len(a)] is not None:
        tmpa = a + f[i + 1 - len(a)]
    if i + 1 >= len(b) and f[i + 1 - len(b)] is not None:
        tmpb = b + f[i + 1 - len(b)]
    if tmpa is None and tmpb is None:
        continue
    if tmpa is None and tmpb is not None:
        f[i+1] = tmpb
        continue
    if tmpb is None and tmpa is not None:
        f[i+1] = tmpa
        continue
    if tmpa < tmpb:
        f[i+1] = tmpa
    else:
        f[i+1] = tmpb
print(f[l])
Problem p03239 (python)

Fixed submission:
a=[]
b=1001
n,t=map(int,input().split(" "))
for _ in range(n):
    a.append(tuple(map(int,input().split(" "))))
for i in range(n):
    if t>=a[i][1]:
        if b>a[i][0]:
            b=a[i][0]
if b !=1001:
    print(b)
else:
    print("TLE")

Buggy submission (verdict: Runtime Error):
a=[]
b=1000
n,t=map(int,input().split(" "))
for _ in range(n):
    a.append(tuple(map(int,input().split(" "))))
for i in range(n):
    if t>=a[i][1]:
        if b>a[i][0]:
            b=a[i][0]
if b !=1000:
    print(b)
if b==1000
    print("TLE")

Buggy submission (verdict: Runtime Error):
a=[]
b=1000
n,t=map(int,input().split(" "))
for _ in range(n+1):
    a.append(tuple(map(int,input().split(" "))))
for i in range(n+1):
    if t>=a[i][1]:
        if b>a[i][0]:
            b=a[i][0]
if b !=1000:
    print(b)
else:
    print("TLE")
Problem p03998 (python)

Fixed submission:
a,b,c,=list(input()),list(input()),list(input())
d=a[0]
e=0
a.remove(d)
while True:
    if eval(d)==[]:
        break
    e=eval(d)[0]
    eval(d).remove(e)
    d=e
print(str.upper(d))

Buggy submission (verdict: Runtime Error):
a,b,c,=list(input()),list(input()),list(input())
d=a[0]
e=0
a.remove(d)
while True:
    if eval(d)==[]:
        break
    e=eval(d)[0]
    eval(d).remove(e)
    d=e
print(str.upper(e))
Problem p02909 (python)

Fixed submission:
a = input()
if a=='Sunny':
  print('Cloudy')
elif a=='Cloudy':
  print('Rainy')
elif a=='Rainy':
  print('Sunny')

Buggy submission (verdict: Runtime Error):
a = input()
if a='Sunny':
  print('Cloudy')

Buggy submission (verdict: Runtime Error):
a = input()
if a='Sunny':
  print('Cloudy')
elif a='Cloudy':
  print('Rainy')
elif a='Rainy':
  print('Sunny')

Buggy submission (verdict: Runtime Error):
a = input()
if a = "Sunny":
  print("Cloudy")
elif a = "Cloudy":
  print("Rainy")
else:
  print("Sunny")
Problem p02921 (python)

Fixed submission:
s = input()
t = input()
c=0
if s[0]==t[0]:
  c = c + 1

if s[1]==t[1]:
  c = c + 1

if s[2]==t[2]:
  c = c + 1
  
print(c)

Buggy submission (verdict: Runtime Error):
s = int()
t = int()
c=0
if s[0]==t[0]:
  c = c + 1

if s[1]==t[1]:
  c = c + 1

if s[2]==t[2]:
  c = c + 1
  
print(c)

Buggy submission (verdict: Runtime Error):
s = int()
t = int()
c=0
if s[0]==t[0]:
  c = c + 1

if s[1]==t[1]:
  c = c + 1

if s[2]==t[2]:
  c = c + 1
print(c)

Buggy submission (verdict: Runtime Error):
s=map(str, input().split())
t=map(str, input().split())
c = 0
for i in range(3):
  if s[i]==t[i]:
    c = c + 1
print(c)

Buggy submission (verdict: Runtime Error):
s=map(str, input().split())
t=map(str, input().split())
c = 0
for i in range(3):
  if s[i] == t[i]:
    c = c + 1
print(c)

Buggy submission (verdict: Runtime Error):
s=map(str, input().split())
t=map(str,i nput().split())
c = 0
for i in range(3):
  if s[i] == t[i]:
    c = c + 1
print(c)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
int c = 0
for i in range(2):
  if (s[i] = t[i]):
    c = c + 1
print(c)
Problem p03071 (python)

Fixed submission:
a = sorted(list(map(int, input().split())))
if a[1]-a[0] >= 1:
  print(a[1]*2-1)
else:
  print(a[1]*2)

Buggy submission (verdict: Runtime Error):
a = sorted(list(map(int, input().split())))
if a[1]-a[0] >= 1:
  print(a[2]*2-1)
else:
  print(a[2]*2)

Buggy submission (verdict: Runtime Error):
a = sorted(list(map(int, input().split())))
if a[2]-a[1]>=1:
  print(a[2]*2-1)

Buggy submission (verdict: Runtime Error):
a = sorted(list(map(int, input().split())))
if a[2]-a[1]>=1:
  print(a[2]*2-1)
elif a[2]-a[1]=0:
  print(a[2]*2)
Problem p03101 (python)

Fixed submission:
hh,ww = map(int, input().split())
h, w = map(int, input().split())
s = hh*ww - h*ww - hh*w + h*w
print(s)

Buggy submission (verdict: Runtime Error):
hh, ww = map(int, input(),split())
h, w = map(int, input(),split())
s = hh*ww - h*ww - hh*w + hh*ww
print(s)

Buggy submission (verdict: Runtime Error):
hh, ww = map(int, input(),split())
h, w = map(int, input(),split())

print(hh*ww - h - w + 1)
Problem p03238 (python)

Fixed submission:
n = int(input())

if n == 1:
  print('Hello World')
  exit()
elif n == 2:
  a = int(input())
  b = int(input())
  print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(input())

if n == 1:
  print('Hello World')
  exit()
else if n == 2:
  a = int(input())
  b = int(input())
  print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(input())

if n == 1:
  print('Hello World')
else if n == 2:
  a = int(input())
  b = int(input())
  print(a+b)
Problem p03264 (python)

Fixed submission:
k = int(input())

if k%2 ==0 :
  s = k*k
  s1 = s//4
  print(s1)
else:
  s = k//2
  s1 = s*(s+1)
  print(s1)

Buggy submission (verdict: Runtime Error):
k = input()

if k%2==0:
  s = k*k//4
  print(s)
else:
  s = k//2
  s1 = s*(s+1)
  print(s1)

Buggy submission (verdict: Runtime Error):
k = input()

if k%2==0:
  print(k*k//4)
else:
  print(k//2 * (k//2 + 1))
Problem p03351 (python)

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

if abs(c-a)<=d:
  print('Yes')
  exit()

if abs(b-a)<=d:
  if abs(c-b)<=d:
    print('Yes')
    exit()

print('No')

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int, input().split())

if abs(c-a)<=d:
  print('Yes')
  exit()

if abs(b-a)<=d:
  if abs(c-b)<=d:
  print('Yes')
  exit()

print('No')
Problem p03407 (python)

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

if (a+b) >= c:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, imput().split())

if (a+b) >= c:
  print('Yes')
else:
  print('No')
Problem p03415 (python)

Fixed submission:
a = input()
b = input()
c = input()

print(a[0]+b[1]+c[2])

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()

print(a[1]+b[2]+c[3])
Problem p03469 (python)

Fixed submission:
s = input()
ss = s.replace('2017', '2018')
print(ss)

Buggy submission (verdict: Runtime Error):
s = input()
s[3] = 8
print(s)
Problem p03563 (python)

Fixed submission:
r = int(input())
g = int(input())
print(2*g - r)

Buggy submission (verdict: Runtime Error):
r,g = map(int, input().split())

Buggy submission (verdict: Runtime Error):
r,g = map(int, input().split())

s = g * 2 - r
print(s)

Buggy submission (verdict: Runtime Error):
r,g = map(int, input().split())

print(g*2-r)
Problem p03636 (python)

Fixed submission:
s = input()
n = len(s)
print(s[0]+str(n-2)+s[n-1])

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
print(s[0]+(n-2)+s[n-1])
Problem p03737 (python)

Fixed submission:
s1,s2,s3 = map(str,input().split())
bs1 = s1.upper()
bs2 = s2.upper()
bs3 = s3.upper()
print(bs1[0]+bs2[0]+bs3[0])

Buggy submission (verdict: Runtime Error):
s1,s2,s3 = map(str,input())
bs1 = s1.upper()
bs2 = s2.upper()
bs3 = s3.upper()
print(bs1[0]+bs2[0]+bs3[0])
Problem p03813 (python)

Fixed submission:
x = int(input())

if x < 1200:
  print('ABC')
else:
  print('ARC')

Buggy submission (verdict: Runtime Error):
x = map(int, input().split())

if x < 1200:
  print('ABC')
else:
  print('ARC')
Problem p03962 (python)

Fixed submission:
a,b,c = map(int, input().split())
if a==b==c:
  print(1)
  exit()
if a==b:
  print(2)
elif a==c:
  print(2)
elif b==c:
  print(2)
else:
  print(3)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
if a==b==c:
  print(1)
elif a==b/=c:
  print(2)
elif a==c/=b:
  print(2)
elif c==b/=a:
  print(2)
else:
  print(3)
Problem p02882 (python)

Fixed submission:
import math
a, b, x = map(int, input().split())
if x >= a*a*b/2:
  print(math.degrees(math.atan(2*b/a-2*x/a/a/a)))
else:
  print(math.degrees(math.atan(a * b * b / 2 / x)))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
print(math.degrees(math.atan(2*b/a-2*x/a/a/a if x >= a*a*b/2 else a*b*b/2/x)
Problem p02888 (python)

Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j]) - j - 1
 
print(c)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split())).sort
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j], j+1)
 
print(c)
Problem p02975 (python)

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))

c = collections.Counter(a)
k = list(c.keys())
v = list(c.values())

if n % 3 == 0:
  if len(v) == 3:
    if v[0] == v[1] == v[2] and k[0] ^ k[1] == k[2]:
      print("Yes")
    else:
      print("No")
  elif len(v) == 2:
    if (k[0] == 0 and v[0] * 2 == v[1]) or (k[1] == 0 and v[1] * 2 == v[0]):
      print("Yes")
    else:
      print("No")
  elif len(v) == 1:
    if k[0] == 0:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
elif len(v) == 1:
  if k[0] == 0:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(int, input().split()))

c = collections.Counter(a)
v = list(c.values())
k = list(c.keys())

if n % 3 == 0 and v[0] == v[1] == v[2] and k[0] ^ k[1] == k[2]:
  print("Yes")
else:
  print("No")
Problem p03050 (python)

Fixed submission:
import math
 
n = int(input())
s = 0
if n > 2:
  for p in range(1, int(math.sqrt(n)) + 1):
    t = (n - p) / p
    if t.is_integer():
      if (n // int(t)) == (n % int(t)):
        s += int(t)
  print(s)

else:
  print(0)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
s = 0

for p in range(1, int(math.sqrt(n)) + 1):
  t = (n - p) / p
  if t.is_integer():
    if (n // int(t)) == (n % int(t)):
      s += int(t)

print(s)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
s = 0

for p in range(1, int(math.sqrt(n)) + 1):
  t = (n - p) / p
  if t.is_integer():
    if (n // int(t)) == (n % int(t)):
      s += int(t)

print(s)
Problem p03145 (python)

Fixed submission:
b, c, _ = map(int, input().split())
print(int(b * c / 2))

Buggy submission (verdict: Runtime Error):
b, c, _ = map(int, raw_input().split())
print(b * c / 2)
Problem p02787 (python)

Fixed submission:
H, N = map(int, input().split())
G = [0 for i in range(N)]
for i in range(N):
    A, B = map(int, input().split())
    koritu = A / B
    G[i] = (koritu, A, B)
G.sort(reverse = True)
#print(G)
dp = [[0 for i in range(H+1)] for j in range(N)]
k, a, b = G[0]
for i in range(1, H + 1):
    dp[0][i] = ((i - 1) // a + 1) * b
for j in range(1, N):
    k, a, b = G[j]
    for i in range(1, H+1):
        if i >= a:
            dp[j][i] = min(dp[j-1][i], dp[j][i-a] + b)
        else:
            dp[j][i] = min(dp[j-1][i],b)
print(dp[N-1][H])

Buggy submission (verdict: Runtime Error):
H, N = map(int, input().split())
G = [0 for i in range(N)]
for i in range(N):
    A, B = map(int, input().split())
    koritu = A / B
    G[i] = (koritu, A, B)
G.sort(reverse = True)
#print(G)
dp = [[0 for i in range(H+1)] for j in range(N)]
for i in range(1, H + 1):
    dp[0][i] = ((i - 1) // a + 1) * b
for j in range(1, N):
    k, a, b = G[j]
    for i in range(1, H+1):
        if i >= a:
            dp[j][i] = min(dp[j-1][i], dp[j][i-a] + b)
        else:
            dp[j][i] = min(dp[j-1][i],b)
print(dp[N-1][H])
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
WAC = [0 for i in range(N)]
TF = [0 for i in range(N)]
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if S == 'AC':
        TF[p] = 1
    if TF[p] == 0 and S == 'WA':
        WAC[p] += 1
count = 0
for i in range(N):
    count += TF[i] * WAC[i]
print(sum(TF), count)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
WAC = [0 for i in range(M)]
TF = {}
for i in range(M):
    p, S = input().split()
    p = int(p)
    if p in TF.keys():
        if S == 'AC':
            TF[p] = True
    else:
        if S == 'AC':
            TF[p] = True
        else:
            TF[p] = False
    if  TF[p] == False and S == 'WA':
        WAC[p-1] += 1
count = 0
for k in TF:
    if TF[k]:
        count += 1
print(count, sum(WAC))
Problem p02814 (python)

Fixed submission:

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return(y)

def lcm(x, y):
    ans = (x * y) // gcd(x, y)
    return(ans)
l = 1
cnt = [0 for i in range(len(A))]
for i in range(len(A)):
    a = A[i]
    l = lcm(l, a)
    count = 0
    while True:
        if a % 2 == 0:
            a //= 2
            count += 1
        else:
            cnt[i] = count
            break
count = cnt[0]
flag = True
for i in range(len(A)):
    if cnt[i] != count:
        flag = False
        break
if flag:
    l = l // 2
    ans = M // l
    print((ans+1)//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
from math import gcd

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
AA = [a//2 for a in A]
K = [1 for i in range(len(AA))]
'''
def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return(y)
'''
def lcm(x, y):
    ans = (x * y) // gcd(x, y)
    return(ans)
l = 1
g = AA[0]

for i in range(len(AA)):
    g = gcd(g, AA[i])
    l = lcm(l, AA[i])
AAA = [a // g for a in AA]
C = [a % 2 for a in AAA]

if C == K:
    ans = M // l
    print((ans+1)//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
AA = [a//2 for a in A]
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
l = 1
for i in range(len(AA)):
    l = lcm(l, AA[i])
amari = l % 2
if amari == 1:
    ans = M // l
    print((ans+1)//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
AA = [a//2 for a in A]
#print(AA)

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l = 1
for i in range(len(AA)):
    l = lcm(l, AA[i])
amari = l % 2
if amari == 1:
    ans = M // l
    print((ans+1)//2)
else:
    print(0)
Problem p03006 (python)

Fixed submission:
import collections
N = int(input())
x = [0 for i in range(N)]
for i in range(N):
    x[i] = list(map(int, input().split()))
x.sort(key=lambda x: (x[0],x[1]))
salist = []
if N >= 2:
    for i in range(1,N):
        for k in range(1,N):
            if i >= k:
                lb, mb = x[i-k]
                l, m = x[i]
                salist.append((l-lb,m-mb))
    #print(salist)
    c = collections.Counter(salist)
    print( N - c.most_common()[0][1])
else:
    print(1)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
x = [0 for i in range(N)]
for i in range(N):
    x[i] = list(map(int, input().split()))
x.sort(key=lambda x: (x[0],x[1]))
salist = []
for i in range(1,N):
    lb, mb = x[i-1]
    l, m = x[i]
    salist.append((l-lb,m-mb))
#print(salist)
c = collections.Counter(salist)
print( N - c.most_common()[0][1])
Problem p03087 (python)

Fixed submission:
import bisect
N, Q = map(int, input().split())
S = input()
numlist = []
for i in range(N-1):
    if S[i:i+2] == 'AC':
        numlist.append(i)

l = [0 for i in range(Q)]
r = [0 for i in range(Q)]
for i in range(Q):
    ll, rr = map(int, input().split())
    l[i], r[i] = ll-1, rr-1

for i in range(Q):
    hajime = bisect.bisect_left(numlist, l[i])
    owari = bisect.bisect_right(numlist,r[i]-1)
    print(owari - hajime)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
numlist = []
for i in range(N-1):
    if S[i:i+2] == 'AC':
        numlist.append(i)

l = [0 for i in range(Q)]
r = [0 for i in range(Q)]
for i in range(Q):
    ll, rr = map(int, input().split())
    l[i], r[i] = ll-1, rr-1

for i in range(Q):
    hajime = bisect.bisect_left(numlist, l[i])
    owari = bisect.bisect_right(numlist,r[i]-1)
    print(owari - hajime)
Problem p03096 (python)

Fixed submission:
N = int(input())
C = [0 for i in range(N)]

for i in range(N):
    C[i] = int(input())

sosu = 10 ** 9 + 7

dp = [1 for i in range(N)]
alpha = {}
alpha[C[0]] = [0]
mae = C[0]
for i in range(1,N):
    dp[i] = dp[i-1]
    if C[i] != mae:
        if C[i] in alpha.keys():
            length = len(alpha[C[i]])
            lastnum = alpha[C[i]][length - 1]
            dp[i] += dp[lastnum]
            alpha[C[i]].append(i)
        else:
            alpha[C[i]] = [i]
    mae = C[i]
    dp[i] = dp[i] % sosu
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
C = [0 for i in range(N)]
alpha = {}
for i in range(N):
    C[i] = int(input())
    if C[i] in alpha.keys():
        alpha[C[i]].append(i)
    else:
        alpha[C[i]] = [i]
sosu = 10 ** 9 + 7

dp = [1 for i in range(N)]
mae = C[1]
for i in range(2,N):
    dp[i] = dp[i-1]
    if C[i] != mae:
        numlist = alpha[C[i]]
        for j in numlist:
            if j < i and j>=1:
                dp[i] += dp[j-1]
            elif j == 0:
                dp[i] += 1
            else:
                break
    mae = C[i]
    dp[i] = dp[i] % sosu
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
 = [0 for i in range(N)]
alpha = {}
for i in range(N):
    C[i] = int(input())
    if C[i] in alpha.keys():
        alpha[C[i]].append(i)
    else:
        alpha[C[i]] = [i]
sosu = 10 ** 9 + 7

dp = [1 for i in range(N)]
mae = C[1]
for i in range(2,N):
    dp[i] = dp[i-1]
    if C[i] != mae:
        numlist = alpha[C[i]]
        for j in numlist:
            if j < i and j>=1:
                dp[i] += dp[j-1]
            elif j == 0:
                dp[i] += 1
            else:
                break
    mae = C[i]
    dp[i] = dp[i] % sosu
print(dp[N-1])