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

Fixed submission:
nk = input()
nk = nk.split()
n = int(nk[0])
k = int(nk[1])
trees = []
for i in range(n):
  trees.append(int(input()))
trees.sort()
minimum = 1000000000
i = 0
while i<=n-k:
  if trees[i+k-1]-trees[i]<minimum:
    minimum = trees[i+k-1]-trees[i]
  i+=1
print(minimum)

Buggy submission (verdict: Runtime Error):
nk = input()
nk = nk.split()
n = int(n[0])
k = int(n[1])
trees = []
for i in range(n):
  trees.append(int(input()))
trees.sort()
minimum = 1000000000
i = 0
while i<=n-k:
  if trees[i+k-1]-trees[i]<minimum:
    minimum = trees[i+k-1]-trees[i]
  i+=1
print(minimum)
Problem p03209 (python)

Fixed submission:
def stack(layer, length):
  if layer==1:
    return "BPPPB"[:length].count("P")
  else:
    if length==(lengths[layer-1]+1)/2:
      return ps[layer-2]+1
    elif length<(lengths[layer-1]+1)/2:
      return stack(layer-1, length-1)
    else:
      return ps[layer-2]+1+stack(layer-1, length-lengths[layer-2]-2)
    
inp = input().split()
layer = int(inp[0])
length = int(inp[1])
lengths = [5]
ps = [3]
for i in range(49):
  lengths.append(lengths[i]*2+3)
  ps.append(ps[i]*2+1)
print(stack(layer, length))

Buggy submission (verdict: Runtime Error):
inp = input().split()
layer = int(inp[0])
length = int(inp[1])
lengths = [5]
ps = [3]
for i in range(49):
  lengths.append(lengths[i]*2+3)
  ps.append(ps[i]*2+1)
print(stack(layer, length))

def stack(layer, length):
  if layer==1:
    return "BPPPB"[:length].count("P")
  else:
    if length==(lengths[layers-1]+1)/2:
      return ps[layers-1]+1
    elif length==(lengths[layers-1]+1)/2:
      return stack(layers-1, length-1)
    else:
      return ps[layers-1]+1+stack(layers-1, length-(lengths[layers-2]+2)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long int n, x, i;
  string result;
  cin >> n >> x;
  vector<string> burgers[51];
  burgers[0] = "P";
  burgers[1] = "BPPPB";
  burgers[2] = "BBPPPBPBPPPBB";
  i = 3;
  while (i<=50) {
    burgers[i] = "B" + burgers[i-1] + "P" + burgers[i-1] + "B";
    i+=1;
  }
  result = burgers[n][:x-1];
  cout << result;
  return 0;
}

/*
nx = input()
nx = nx.split()
n = int(nx[0])
x = int(nx[1])
burgers = [None] * 51
burgers[0] = "P"
burgers[1] = "BPPPB"
burgers[2] = "BBPPPBPBPPPBB"
i = 3
while i<=50:
  burgers[i] = "B" + burgers[i-1] + "P" + burgers[i-1] + "B"
  i+=1
result = burgers[n][:x-1]
print(result.count("P"))
*/
Problem p03776 (python)

Fixed submission:
import math

nab = [int(x) for x in input().split()]
n = nab[0]
a = nab[1]
b = nab[2]
counts = []
nums = [int(x) for x in input().split()]
means = []
nums.sort(reverse = True)
for i in range(a, b+1):
  means.append(sum(nums[:i])/i)
  counts.append(int(math.factorial(nums.count(nums[i-1]))/(math.factorial(nums[:i].count(nums[i-1]))*math.factorial(nums.count(nums[i-1])-nums[:i].count(nums[i-1])))))

maxim = max(means)
print(maxim)
k = 0
count = 0
while k<len(means):
  if means[k]==maxim:
    count+=counts[k]
  k+=1
print(count)

#print(means.count(max(means)))

'''
def C(n, k):
  return C(n-1, k-1) + C(n-1, k)
  
for n in range(MAX_N):
  for k in range(MAX_K):
    C[n][k] = C[n-1][k-1] + C[n-1][k]
'''

Buggy submission (verdict: Runtime Error):
import math

nab = [int(x) for x in input().split()]
n = nab[0]
a = nab[1]
b = nab[2]
counts = []
nums = [int(x) for x in input().split()]
means = []
nums.sort(reverse = True)
for i in range(a, b+1):
  #means.append(sum(nums[:i])/i)
    
  
  j = i
  while j<n:
    if nums[j-1]==nums[j]:
      j+=1
    else:
      break
  
  for k in range(int(math.factorial(j)/(math.factorial(i)*math.factorial(j-i)))):
    means.append(sum(nums[:i])/i)
  #counts.append(math.comb(j, i))
  print(math.factorial(j)/(math.factorial(i)*math.factorial(j-i)))
  print(math.factorial(4)/(math.factorial(2)*math.factorial(2)))
  print(math.factorial(4))
  print(j, i)
print(max(means))
#print(counts[
print(means.count(max(means)))

'''
def C(n, k):
  return C(n-1, k-1) + C(n-1, k)
  
for n in range(MAX_N):
  for k in range(MAX_K):
    C[n][k] = C[n-1][k-1] + C[n-1][k]
Problem p02623 (python)

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

a,b = [0],[0]

for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
  b.append(b[i]+B[i])
  
ans = 0
j = M

for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans,i+j)

print(ans)

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

ans = 0

def dfs_A(n,m,t,c):
  global ans
  x = t+A_list[n]
  if x > K:
    if c > ans:
      ans = c
  elif x == K:
    if c+1 > ans:
      ans = c+1
  else:
    if n+1 <= N-1 and m <= M-1:
      dfs_A(n+1,m,x,c+1)
    if n <= N and m+1 <= M-1:
      dfs_B(n+1,m,x,c+1)

def dfs_B(n,m,t,c):
  global ans
  x = t+B_list[m]
  if x > K:
    if c > ans:
      ans =c
  elif x == K:
    if c+1 > ans:
      ans = c+1
  else:
    if n+1 <= N-1 and m <= M-1:
      dfs_A(n,m+1,x,c+1)
    if n <= N and m+1 <= M-1:
      dfs_B(n,m+1,x,c+1)

dfs_A(0,0,0,0)
dfs_B(0,0,0,0)
print(ans)
Problem p02711 (python)

Fixed submission:
N = list((input()))
ans = "No"
 
for i in N:
  if i == "7":
    ans = "Yes"
         
print(ans)

Buggy submission (verdict: Runtime Error):
N = list(int(input()))
answer = "No"
 
for i in range(N):
  if N[i] == 7:
    answer = "Yes"
 
print(answer)

Buggy submission (verdict: Runtime Error):
N = list(int(input()))
answer = "No"

for i in N:
  if i == 7:
    answer = "Yes"

print(answer)
Problem p02596 (python)

Fixed submission:
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()

Buggy submission (verdict: Runtime Error):
k=int(input())
if k%2==0 k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()
Problem p02693 (python)

Fixed submission:
k=int(input())
a,b=map(int,input().split())
x=b%k
y=b-x
if b-a>k:
    print('OK')
elif y>a:
    print('OK')
elif a%k==0:
    print('OK')
else:
    print('NG')

Buggy submission (verdict: Runtime Error):
k=int(input())
a,b=map(int,input.split())
if b-a>k:
    print('OK')
else:
    print('NG')
Problem p02753 (python)

Fixed submission:
s=input()
if s =='AAA' or s=='BBB':
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
w='z'*a+'x'*b
f=''
for i in range(1000):
    f+=w
    d=f[:n]
print(d.count('z'))
Problem p02754 (python)

Fixed submission:
n,a,b=map(int,input().split())
x=n//(a+b)
y=n%(a+b)
if y<a:
    print(x*a+y)
else:
    print(x*a+a)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
w='z'*a+'x'*b
f=''
for i in range(1000):
    f+=w
    d=f[:n]
print(d.count('z'))
Problem p02771 (python)

Fixed submission:
a=list(map(int,input().split()))
a.sort()
if a[0]==a[1]!=a[2] or a[0]!=a[1]==a[2]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=input()
a=list(map(int,input().split()))
for i in a:
    if i%2==0:
        if i%3==0 or i%5==0:
            pass
        else:
            print('DENIED')
            exit(0)
print('APPROVED')
Problem p03135 (python)

Fixed submission:
t,x=map(int,input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
t,x=(int,input().split())
print(t/x)
Problem p03272 (python)

Fixed submission:
n,i=map(int,input().split())
print(n-i+1)

Buggy submission (verdict: Runtime Error):
n,i=map(int,input(),split())
print(n-i+1)
Problem p03315 (python)

Fixed submission:
s=input()
count=0
for i in s:
    if i=='+':
        count+=1
    else:
        count-=1
print(count)

Buggy submission (verdict: Runtime Error):
s=input()
count=0
for i in s:
    if i='+':
        count+=1
    else:
        count-=1
print(count)

Buggy submission (verdict: Runtime Error):
s=input()
count=0
for i in s:
    if i='+':
        count+=1
    else:
        count-=1
Problem p02623 (python)

Fixed submission:
#(0)環境
from itertools import accumulate
import bisect
n, m, k = map(int,input().split())
#[0]足すことで上から０冊読んだという要素として加えると実装が楽に(一冊も読めんかった)
#accumulate:累積和などが求められる
a = [0] + list(accumulate(map(int,input().split())))
b = [0] + list(accumulate(map(int,input().split())))
ans =[0]

for i in range(n + 1):
    c = bisect.bisect_right(b, k - a[i]) - 1
    #k-s<0のときはインデックスがー１なので除外しなあかん
    if c != -1:
        ans.append(c + i)
print(max(ans))

Buggy submission (verdict: Runtime Error):
from collections import deque
ans = 0
n, m, k = map(int,input().split())
a = deque(list(map(int,input().split())))
b = deque(list(map(int,input().split())))
result = 0

while True:
    if ans > k:
        print(result-1)
        break
    if a[0] + b[0] == 2 * (10 ** 9 + 1):
        print(result)
        break
    if len(a) == 0 or len(b) == 0:
        a.append(10 ** 9 + 1)
        b.append(10 ** 9 + 1)
    if a[0] > b[0]:
        ans += b.popleft()
        result += 1
    else:
        ans += a.popleft()
        result += 1



#<D>
#import math
##def search_divisor_nu

Buggy submission (verdict: Runtime Error):
ans = []
n, m, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

i = 0
j = 0
while True:
    
    if a[i] < b[j]:
        ans += [a[i]]
        i += 1
    else:
        ans += [b[j]]
        j += 1

    if sum(ans) > k:
        print(len(ans) - 1)
        break
Problem p02699 (python)

Fixed submission:
S,W=map(int,input().split())
if S > W:
    print("safe")
else:
    print("unsafe")

Buggy submission (verdict: Runtime Error):
S,W=int(input())
if S < W:
    print("safe")
else:
    print("unsafe")
Problem p02729 (python)

Fixed submission:
import math
def comb(x,y):
    return math.factorial(x)//(math.factorial(x-y)*math.factorial(y))
n,m = map(int,input().split())

ans1=0
ans2=0
if n > 1:
    ans1=comb(n,2)
if m > 1:
    ans2=comb(m,2)
print(ans1+ans2)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n,m = map(int,input().split())
ans1=0
ans2=0
if n > 1:
    ans1=comb(n,2,exact=True)
if m > 1:
    ans2=comb(m,2,exact=True)
print(ans1+ans2)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n,m = map(int,input().split())
ans1=0
ans2=0
if n > 1:
    ans1=comb(n,2,exact=True)
if m > 1:
    ans2=comb(m,2,exact=True)
print(ans1+ans2)
Problem p02832 (python)

Fixed submission:
n = int(input())
a = [int(s) - 1 for s in input().split()]

result = 0
for i in range(n):
    if a[i] != (i - result):
        result += 1
if result == n:
    print(-1)
else:
    print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
c=a[n-1]
a.sort()
a=list(set(a))
#fuct = [i for i in range(1,n+1)]
b=[0]
i = 0
ans = 0
while True:
    if a[0] != 1:
        print(-1)
        break
    if b[i]+1 == a[i]:
        b.append(a[i])
        if a[i] == c:
            print(n - len(b) + 1)
            
            break
    elif b[i] == a[i]:
        ans += 0
    i += 1
Problem p02912 (python)

Fixed submission:
#<D>wa
#(Point)
#優先度付きキューを使いこなす！
#最大値を1/2するのをＭ回繰り返せばいいけどリストやと最大値の選定にO(N),
#それをＭ回やからO(MN)でＴＬＥ
#heapqやったらO(MlogN)なのでおｋ
import heapq
N, M = map(int,input().split())
#最大値取り出すためにリストの要素をすべてマイナスに
A = list(map(lambda x:-int(x),input().split()))
heapq.heapify(A) #Ａを優先度付きキューに

for i in range(M):
    value_min = heapq.heappop(A)
    heapq.heappush(A, (-1) * (-value_min//2)) #負数の剰余演算避けるために
    #一時的に０以上の整数にしている
    #*(-1)してやらんと挿入した後の次の最大値を探す作業ができなくなる
    #heapqは最小値しかみつけれんから
    #print(A)
print(-sum(A))

Buggy submission (verdict: Runtime Error):
#<D>wa
#(Point)
#優先度付きキューを使いこなす！
#最大値を1/2するのをＭ回繰り返せばいいけどリストやと最大値の選定にO(N),
#それをＭ回やからO(MN)でＴＬＥ
#heapqやったらO(MlogN)なのでおｋ
import heapq
N, M = map(int,input().split())
#最大値取り出すためにリストの要素をすべてマイナスに
A = list(map(lambda x:-int(x),input().split()))
heapq.heapify(A) #Ａを優先度付きキューに

for i in range(M):
    value_min = heapq.heappop(A)
    heapq.heappush(A, (-1) * (-value_min//2)) #負数の剰余演算避けるために
    #一時的に０以上の整数にしている
    #*(-1)してやらんと挿入した後の次の最大値を探す作業ができなくなる
    #heapqは最小値しかみつけれんから
    print(A)
print(-sum(A))
Problem p02629 (python)

Fixed submission:
N = int(input())

S = "abcdefghijklmnopqrstuvwxyz"

ans = ""
while N > 0:
    N -= 1
    ans += S[N%26]
    N //= 26

print(ans[::-1])

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

S = "abcdefghijklmnopqrstu"

s = ""
while N // 26 > 0:
    s += S[N%26-1]
    N //= 26
s += S[N-1]

print(s[::-1])
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())

if W >= S:
    print("unsafe")
else:
    print("safe")

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

ans = 0
for i in range(len(S)-3):
    for j in range(i+3, len(S)):
        if int(S[i:j+1]) % 2019 == 0:
            ans += 1
print(ans)
Problem p02725 (python)

Fixed submission:
K, N = map(int, input().split())
A = [int(i) for i in input().split()]

A_dist = [0 for i in range(N)]
for i in range(N):
    if i == 0:
        A_dist[0] = A[0] + (K - A[-1])
    else:
        A_dist[i] = A[i] - A[i-1]

print(K - max(A_dist))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = [int(i) for i in input().split()]

max_dist = A_dist[0] = A[0] + (K - A[-1])
for i in range(1, N):
    if A[i] - A[i-1] > min_dist:
        max_dist = A[i] - A[i-1]

print(K - max_dist)
Problem p02819 (python)

Fixed submission:
X = int(input())

def check(num):
    max_div = int(num**0.5)
    for div in range(2, max_div+1):
        if num % div == 0:
            return False
    else:
        return True

num = X
while True:
    if check(num):
        print(num)
        break
    
    num += 1

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

def check(num):
    max_div = int(num**0.5)
    for div in range(2, max_div+1):
        if num % div == 0:
            return False
    else:
        return True

num = X
while True:
    if check(num):
    print(num)
    break
    
    num += 1
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])

mod = 1000000007

dp = [0] * (N + 2)
dp[N] = 1  # GOAL

for i in range(N-1, -1, -1):
  if i not in A:
    dp[i] = dp[i+1] + dp[i+2]

print(dp[0] % mod)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
A = set(A)

mod = 1000000007

dp = [0] * (N + 1)

if len(dp) <= 2:
  return 1

dp[-1] = 1
dp[-2] = 1 if N - 1 not in A else 0

for i in range(N-2, -1, -1):
  if i not in A:
    dp[i] = dp[i+1] + dp[i+2]

print(dp[0] % mod)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
A = set(A)

dp = [0] * N

ans = None

if N == 1:
  ans = 1

if N == 2:
  ans = 2 if 1 not in A else 1

if ans:
  print(ans)
  
dp[-1] = 1 if N-1 not in A else 0
dp[-2] = dp[-1] + 1 if N-2 not in A else dp[-1]

for i in range(N-3, -1, -1):
  if i not in A:
    dp[i] = dp[i+1] + dp[i+2]

print(dp[0] % (10 ** 9 + 7))
Problem p03041 (python)

Fixed submission:
N, K = input().split()
K = int(K)
S = list(input())

S[K-1] = S[K-1].lower()
 
print(''.join(S))

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

S[K-1] = S[K-1].lower()

print(S)
Problem p02688 (python)

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

d = []
a = []
res = [0] * n

for i in range(k):
    d_tmp = int(input())
    a_tmp = list(map(int, input().split()))
    d.append(d_tmp)
    a.append(a_tmp)

for aa in a:
    for aaa in aa:
        res[aaa - 1] += 1

count = 0

for i in range(n):
    if res[i] == 0:
        count += 1

print(count)

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

d = []
a = []
res = [0] * n

for i in range(k):
    d_tmp = int(input())
    a_tmp = map(int, input().split())
    d.append(d_tmp)
    a.append(a_tmp)

for aa in a:
    for aaa in aa:
        res[aaa - 1] += 1

count = 0

for i in range(k):
    if res[i] == 0:
        count += 1

print(count)
Problem p02879 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    
    if A > 9 or B > 9:
        print(-1)
    else:
        print(A * B)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    
   	if A > 9 or B > 9:
      print(-1)
    else:
      print(A * B)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, L)

if __name__ == '__main__':
    main()
Problem p02984 (python)

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

x = 0
for i,a in enumerate(A):
    if i%2==0:
        x += a
    else:
        x -= a
ans = [str(x)]
for i in range(1,N):
    x = 2*A[i-1] - x
    ans.append(str(x))

print(' '.join(ans))

Buggy submission (verdict: Runtime Error):

L, R = map(int, input().split())
# 2019 = 3*673
p = 673
if R-L>=p:
    print(0)
else:
    ans = 2019
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans = min((i*j)%2019, ans)
    print(ans)
Problem p02792 (python)

Fixed submission:
n = int(input())
f_dict = {}
s_dict = {}
cnt_all = 0
for i in range(n):
  moji = str(i+1)
  if not moji[0]+moji[-1] in f_dict:
    f_dict[moji[0]+moji[-1]] = 1
  else:
    f_dict[moji[0]+moji[-1]] += 1 
  if not moji[-1]+moji[0] in s_dict:
    s_dict[moji[-1]+moji[0]] = 1
  else:
    s_dict[moji[-1]+moji[0]] += 1
for mykey in f_dict.keys():
  if mykey in s_dict:
      cnt_all += f_dict[mykey] * s_dict[mykey]
print(cnt_all)

Buggy submission (verdict: Runtime Error):
n = int(input())
f_dict = {}
s_dict = {}
cnt_all = 0
for i in range(n):
  moji = str(i+1)
  if f_dict[[moji[0]+moji[-1]] == "":
    f_dict[moji[0]+moji[-1]] = 0
  else:
    f_dict[[moji[0]+moji[-1]]+= 1 
  if s_dict[[moji[-1]+moji[0]] == "":
    f_dict[[moji[-1]+moji[0]] = 0
  else:
    f_dict[[moji[-1]+moji[0]] += 1
for mykey in f_dict.keys():
  cnt_all += f_dict[mykey] * s_dict[mykey]
print(cnt_all)

Buggy submission (verdict: Runtime Error):
n = int(input())
f_dict = {}
s_dict = {}
cnt_all = 0
for i in range(n):
  moji = str(i+1)
  if f_dict[[moji[0], moji[-1]] == "":
    f_dict[moji[0], moji[-1]] = 0
  else:
    f_dict[[moji[0], moji[-1]]+= 1 
  if s_dict[[moji[-1], moji[0]] == "":
    f_dict[[moji[-1], moji[0]] = 0
  else:
    f_dict[[moji[-1], moji[0]] += 1
for mykey in f_dict.keys():
  cnt_all += f_dict[mykey] * s_dict[mykey]
print(cnt_all)

Buggy submission (verdict: Runtime Error):
n = int(input())
f_dict = {}
s_dict = {}
cnt_all = 0
for i in range(n):
  moji = str(i+1)
  if f_dict[moji[0], moji[-1]] == "":
    f_dict[moji[0], moji[-1]] = 0
  else:
  	f_dict[moji[0], moji[-1]] += 1 
  if s_dict[moji[-1], moji[0]] == "":
    f_dict[moji[-1], moji[0]] = 0
  else:
  	f_dict[moji[-1], moji[0]] += 1
for mykey in f_dict.keys():
  cnt_all += f_dict[mykey] * s_dict[mykey]
print(cnt_all)
Problem p02820 (python)

Fixed submission:
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())
syo = n//k 
total = 0
for i in range(k):
  te = ''
  score = 0
  for j in range(i, n, k):
    if score == 0 or t[j] != te:
      if t[j] == 'r':
        score = p
        total += p
        te = 'r'
      elif t[j] == 's':
        score = r
        total += r
        te = 's'
      else:
        score = s
        total += s
        te = 'p'
    else:
      score = 0
      
  
print(total)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())
syo = n//k 
total = 0
for i in range(k):
  for j in range(i, n, k):
    if j == i or score == 0 or t[j] ?= te:
      if t[j] = 'r'
      	score = p
      	total += p
        te = 'p'
      elif t[j] = 's'
      	score = r
      	total += r
        te = 'r'
      else:
        score = s
        total += s
        te = 's'
    else:
      score = 0
      
  
print(total)
Problem p03295 (python)

Fixed submission:
n, m = map(int, input().split())
ab_lis =[]
for i in range(m):
    a,b = map(int, input().split())
    ab_lis.append([b,a])
ab_lis.sort()
count = 0
x = 0
for lis in ab_lis:
    b = lis[0]
    a = lis[1]
    if a <= x:
        continue
    x = b-1
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab_lis =[]
for i in range(m):
    a,b = map(int, input().split())
    ab_lis.append([b,a])
ab_lis.sort()
count = 0
bridge = [1]*(n-1)
for lis in ab_lis:
    b = lis[0]
    a = lis[1]
    if sum(bridge[a:b])/len(bridge[a:b]) == 1 and b >= 2:
        bridge[b-2] = 0
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab_lis =[]
for i in range(m):
    a,b = map(int, input().split())
    ab_lis.append([b,a])
ab_lis.sort()
count = 0
bridge = [1]*(n-1)
for lis in ab_lis:
    b = lis[0]
    a = lis[1]
    if sum(bridge[a:b])/len(bridge[a:b]) == 1:
        bridge[b-2] = 0
        count += 1
print(count)