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

Fixed submission:
A,B=input().split()
A=int(A)
B=int(B.replace('.', ''))
print(int(A*B//100))

Buggy submission (verdict: Runtime Error):
input_=Input.split('\n')
A,B=input_[0].split()
A=int(A)
B=int(B.replace('.', ''))
print(A,B)
print(int(A*B//100))

Buggy submission (verdict: Runtime Error):
A,B=input().split()
A_=[A[:-2],A[-2:]]

if A_[0]=='':
    A_[0]='0'
    
A_[0]=int(A_[0])*100
A_[1]=int( A_[1])

A,B=input_[0].split()

B=float(B)
print(int(A_[0]*B + A_[1]*B))
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()

if len(S) <= K:
    print(S)
else:
    print(S[:K]+'...')

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

if len(S) < K:
    print(S)
else:
    print(S[:K]+'...')

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

if len(S) < K:
    print(S)
else:
    print(S[:K]+'...')
Problem p02785 (python)

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

H.sort(reverse=True)

H=H[K:]

H_cumsum=[0]
H_sum_=0
for n in range(len(H)):
    H_sum_=H_sum_+H[n]
    H_cumsum.append(H_sum_)
print(H_sum_)

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

H.soat(reverse=True)

H=H[K:]

H_cumsum=[0]
H_sum_=0
for n in range(len(H)):
    H_sum_=H_sum_+H[n]
    H_cumsum.append(H_sum_)
print(H_sum_)
Problem p02792 (python)

Fixed submission:
N = int(input())

C=[[0]*10 for _ in range(10)]

for n in range(1,N+1):
    n=str(n)
    n_s=int(n[0])
    n_e=int(n[-1])
    
    C[n_s][n_e]+=1
    
ans=0
for c_1 in range(10):
    for c_2 in range(10):
        ans += C[c_1][c_2]*C[c_2][c_1]
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
# N = random.randint(1,2*10**5)

N_ =str(N)
n_o=len(N_)

# ans:条件を満たす組みの個数
ans=0

def get_ans(A):
    ans=0
    A_=str(A)
    a_s=A_[0]
    a_e=A_[-1]
#     print(a_s,a_e)
    
    if int(a_e) == 0:
        return 0

    if a_s == a_e:
        ans+=1

    for b_o in range(2,n_o+1):
        B_temp = []
        if b_o < n_o:
            ans += 10**(b_o-2)

        elif b_o == n_o:
            if int(a_e) > int(N_[0]):
                break
            elif int(a_e) < int(N_[0]):
                ans += 10 ** (b_o-2)
            else:
                ans+=int(N_[1:-1])

        else:
            break
        
    return ans

for a in range(1,N+1):
    ans_=get_ans(a)
    ans+=ans_
print(ans)

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

N_ =str(N)
n_o=len(N_)

# ans:条件を満たす組みの個数
ans=0

def get_ans(A):
    ans=0
    A_=str(A)
    a_s=A_[0]
    a_e=A_[-1]
#     print(a_s,a_e)
    
    if int(a_e) == 0:
        return 0

    if a_s == a_e:
        ans+=1

    for b_o in range(2,n_o+1):
        B_temp = []
        if b_o < n_o:
            ans += 10**(b_o-2)

        elif b_o == n_o:
            if int(a_e) > int(N_[0]):
                break
            elif int(a_e) < int(N_[0]):
                ans += 10**(b_o-2)
            else:      
                for p in product(range(10),repeat=n_o-2):
                    ans_temp=int(a_e+''.join(map(str,p))+a_s)
                    if ans_temp > N:
                        break
                    ans+=1 
                    B_temp.append(ans_temp)
    #                 print(B_temp)

        else:
            break
        
    return ans

for a in range(1,N+1):
#     print('====',a)
    ans_=get_ans(a)
    ans+=ans_
print(ans)
Problem p02820 (python)

Fixed submission:
from collections import Counter

#input
N,K = list(map(int,input().split()))
R,S,P = list(map(int,input().split()))

T = list(input())
T_ =T.copy()

# N=2*10**5
# T=[random.choice(['s', 'r', 'p']) for _ in range(N)]

check=set(['s', 'r', 'p'])

#得点
point={'r':P,'s':R,'p':S}
point

T_point = [0]*N
for n in range(N):
    T_point[n]=point[T[n]]
    
for k in range(K,N):
    check_out = set()
    if T[k] == T[k-K]: # K回前の手と同じ場合
        check_out.add(T[k])
        if k+K < N:
            check_out.add(T[k+K])
            
        check_out=check-check_out
        
        T[k]=list(check_out)[0]
         
ans=0

for t in range(len(T)):
    if T[t] == T_[t]:
        ans += point[T[t]]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

#input
N,K = list(map(int,input().split()))
R,S,P = list(map(int,input().split()))

T = list(input())
T_ =T.copy()

# N=2*10**5
# T=[random.choice(['s', 'r', 'p']) for _ in range(N)]

check=set(['s', 'r', 'p'])

#得点
point={'r':P,'s':R,'p':S}
point

T_point = [0]*N
for n in range(N):
    T_point[n]=point[T[n]]
    
for k in range(K,N):
    check_out = set()
    if T[k] == T[k-K]: # K回前の手と同じ場合
        check_out.add(T[k])
        if k+K <= N:
            check_out.add(T[k+K])
            
        check_out=check-check_out
        
        T[k]=list(check_out)[0]
         
ans=0

for t in range(len(T)):
    if T[t] == T_[t]:
        ans += point[T[t]]
print(ans)
Problem p02862 (python)

Fixed submission:
def mod_fact(N,p):
    mod=1
    for n in range(1,N+1):
        mod = (mod*(n%p))%p
        
    mod = mod%p
    
    return mod

X,Y = list(map(int,input().split()))

Z = X+Y

ans=0

if Z%3 != 0:
    ans=0
    
elif min(X,Y) >= Z//3:
    b=0
    for z in range(Z//3,((Z//3)*2)+1):
        if z == X:
            break
        b+=1
    a = Z//3 - b 
    
    p=(10**9)+7

    Z_= mod_fact(Z//3 , p)
    a_= mod_fact(a , p)
    b_= mod_fact(b , p)

    a_= pow(a_,p-2,p)
    b_= pow(b_,p-2,p)

    ans=(Z_*(a_*b_))%p
    
print(ans)

Buggy submission (verdict: Runtime Error):
def mod_fact(N,p):
    mod=1
    for n in range(1,N+1):
        mod = (mod*(n%p))%p
        
    mod = mod%p
    
    return mod

X,Y = list(map(int,input().split()))

Z = X+Y

if Z%3 != 0:
    ans=0
    
elif min(X,Y) >= Z//3:
    b=0
    for z in range(Z//3,((Z//3)*2)+1):
        if z == X:
            break
        b+=1
    a = Z//3 - b 
    
    p=(10**9)+7

    Z_= mod_fact(Z//3 , p)
    a_= mod_fact(a , p)
    b_= mod_fact(b , p)

    a_= pow(a_,p-2,p)
    b_= pow(b_,p-2,p)

    ans=(Z_*(a_*b_))%p
    
print(ans)
Problem p02954 (python)

Fixed submission:
from collections import Counter
S = input()

check_str = 'LR'
S_=[]
s_temp = ''
for s in range(len(S)):
    s_temp += S[s]
    
    if s < len(S)-1:
        s_= s+1 
        if S[s]=='L' and S[s_] == 'R':
            S_.append(Counter(s_temp))
            s_temp =''
            
    else:
        S_.append(Counter(s_temp))

def get_ans_temp(S_temp):
    S_R = S_temp['R']
    S_L = S_temp['L']
    
    S_R_ans=[0]*S_R
    S_L_ans=[0]*S_L
    
    if (S_R + S_L) % 2 ==0 :#偶数の時
        S_R_ans[-1] = (S_R + S_L) // 2
        S_L_ans[0] = (S_R + S_L) // 2

    elif S_R != S_L :#奇数の時
        if S_R > S_L:
            S_R_ans[-1] = (S_R + S_L) // 2 +1
            S_L_ans[0] = (S_R + S_L) // 2         
        else:
            S_R_ans[-1] = (S_R + S_L) // 2
            S_L_ans[0] = (S_R + S_L) // 2 + 1
            
        max_RL_num = max(S_R,S_L)
        if max_RL_num % 2 == 0:
            _ = S_R_ans[-1]
            S_R_ans[-1]=S_L_ans[0]
            S_L_ans[0]=_

    ans_temp = []
    ans_temp.extend(S_R_ans)
    ans_temp.extend(S_L_ans)
    return ans_temp

ans_list=[]
for S_temp in S_:
    ans_list.extend(get_ans_temp(S_temp))
    
ans=' '.join(map(str,ans_list))

print(ans)

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

check_str = 'LR'
S_=[]
s_temp = ''
for s in range(len(S)):
    s_temp += S[s]
    
    if s < len(S)-1:
        s_= s+1 
        if S[s]=='L' and S[s_] == 'R':
            S_.append(Counter(s_temp))
            s_temp =''
            
    else:
        S_.append(Counter(s_temp))

def get_ans_temp(S_temp):
    S_R = S_temp['R']
    S_L = S_temp['L']
    
    S_R_ans=[0]*S_R
    S_L_ans=[0]*S_L
    
    if (S_R + S_L) % 2 ==0 :#偶数の時
        S_R_ans[-1] = (S_R + S_L) // 2
        S_L_ans[0] = (S_R + S_L) // 2

    elif S_R != S_L :#奇数の時
        if S_R > S_L:
            S_R_ans[-1] = (S_R + S_L) // 2 +1
            S_L_ans[0] = (S_R + S_L) // 2         
        else:
            S_R_ans[-1] = (S_R + S_L) // 2
            S_L_ans[0] = (S_R + S_L) // 2 + 1
            
        max_RL_num = max(S_R,S_L)
        if max_RL_num % 2 == 0:
            _ = S_R_ans[-1]
            S_R_ans[-1]=S_L_ans[0]
            S_L_ans[0]=_

    ans_temp = []
    ans_temp.extend(S_R_ans)
    ans_temp.extend(S_L_ans)
    return ans_temp

ans_list=[]
for S_temp in S_:
    ans_list.extend(get_ans_temp(S_temp))
    
ans=' '.join(map(str,ans_list))

print(ans)
Problem p02990 (python)

Fixed submission:
N,K = list(map(int,input().split()))
# N = random.randint(1,20)
# K = random.randint(1,N)
# print(N,K)

p=(10**9)+7

def get_mod_factalize(A):
    a_mod = 1     
    for a in range(1,A+1):
        a_mod = a * a_mod % p
    return a_mod

def get_mod_comb(A,B):
    a_mod = get_mod_factalize(A)
    b_mod = get_mod_factalize(B)
    a_b_mod = get_mod_factalize(A-B)

    return (a_mod * pow((b_mod*a_b_mod),p-2,p))%p

a = N-K
b = K

for i in range(1,K+1): 
    if i > a+1 :
        ans=0
    else:
        ans=(get_mod_comb(a+1,i) * get_mod_comb(b-1,i-1))%p
    print(ans)

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

p=(10**9)+7

def get_mod_factalize(A):
    a_mod = 1     
    for a in range(1,A+1):
        a_mod = a * a_mod % p
    return a_mod

def get_mod_comb(A,B):
    a_mod = get_mod_factalize(A)
    b_mod = get_mod_factalize(B)
    a_b_mod = get_mod_factalize(A-B)

    return (a_mod * pow((b_mod*a_b_mod),p-2,p))%p

get_mod_comb(A,B)
a = N-K
b = K

for i in range(1,K+1): 
    ans=(get_mod_comb(a+1,i) * get_mod_comb(b-1,i-1))%p
    print(ans)
Problem p03013 (python)

Fixed submission:
N,M=list(map(int,input().split()))
 
S=[]
s=0
for m in range(M):
    e = int(input())
    S.append(list(range(s,e)))
    s = e+1

e = int(N+1)
S.append(list(range(s,e)))
 
fibo=[0,1]
for n in range(2,N+2):
    fibo.append(fibo[n-2]+fibo[n-1])
    
ans=1
for s in S:
    ans=ans*fibo[len(s)]
print(ans%1000000007)

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

S=[]
s=0
for m in range(M):
    e = int(input())
    S.append(list(range(s,e)))
    s = e+1

e = int(N+1)
S.append(list(range(s,e)))

fibo=[0,1]
for n in range(2,N+1):
    fibo.append(fibo[n-2]+fibo[n-1])
    
ans=1
for s in S:
    ans=ans*fibo[len(s)]
print(ans%1000000007)
Problem p03038 (python)

Fixed submission:
from collections import deque

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

BC_dict={}
for m in range(M):
    b,c = list(map(int,input().split()))
    if c in BC_dict.keys():
        BC_dict[c]+=b  
    else:    
        BC_dict[c]=b  
    
C = list(BC_dict.keys())

A.sort()
C.sort(reverse=True)

C=deque(C)

check = C.popleft()

for a_idx,a in enumerate(A):
    if a >= check:
        break
    
    A[a_idx] = check
    BC_dict[check] -= 1
    
    if BC_dict[check] == 0:
        if len(C) == 0:
            break
        else:
            check = C.popleft()
        
print(sum(A))

Buggy submission (verdict: Runtime Error):
from collections import deque

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

BC_dict={}
for m in range(M):
    b,c = list(map(int,input().split()))
    if c in BC_dict.keys():
        BC_dict[c]+=b  
    else:    
        BC_dict[c]=b  
    
C = list(BC_dict.keys())

A.sort()
C.sort(reverse=True)

C=deque(C)

check = C.popleft()

for a_idx,a in enumerate(A):
    if a >= check:
        break
    
    A[a_idx] = check
    BC_dict[check] -= 1
    
    if BC_dict[check] == 0:
        if len(C) == 0:
            break
        else:
            print(C)
            check = C.popleft()
        
print(sum(A))
Problem p03804 (python)

Fixed submission:
import numpy as np
N,M = list(map(int,input().split()))

A=[]
B=[]
for n in range(N):
    A_ = list(input())
    A.append(A_)
    
for m in range(M):
    B_ = list(input())
    B.append(B_)
    
B=np.array(B)

ans='No'
for n1 in range(N-M+1):
    for n2 in range(N-M+1):
        check = np.array(A)[n1:n1+M,n2:n2+M]
        c=np.unique(check == B)
        
        if False not in set(c):
            ans='Yes'
            break
            
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = list(map(int,input().split()))

A=[]
B=[]
for n in range(N):
    A_ = list(input())
    A.append(A_)
    
for m in range(M):
    B_ = list(input())
    B.append(B_)
    
B=np.array(B)

ans='No'
for n1 in range(N-M+1):
    for n2 in range(N-M+1):
        check = np.array(A)[n1:n1+M,n2:n2+M]
        c=np.unique(check == B)
        
        if False not in set(c):
            ans='Yes'
            break
            
print(ans)
Problem p02847 (python)

Fixed submission:
week = ['MON','TUE','WED','THU','FRI','SAT','SUN']
day = input()
ans = week.index('SUN')-week.index(day)
print(ans if ans!=0 else 7)

Buggy submission (verdict: Runtime Error):
week = ['MON','TUE','WED','THU','FRI','SAT','SUN']
day = input()
ans = week.index('SUN')-week,index(day)
print(ans if ans!=0 else 7)

Buggy submission (verdict: Runtime Error):
week = ['SUN','MON','TUE','WED','THU','FRI','SAT' ]
print(week[(week.index(input)+1)%7])
Problem p03774 (python)

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

a = [[0, 0] for i in range(n)]

c = [[0, 0] for i in range(m)]

for i in range(n):
    a[i][0], a[i][1] = map(int, input().split())

for i in range(m):
    c[i][0], c[i][1] = map(int, input().split())

index = 0


for i in range(n):
    for j in range(m):
        if j == 0 :
            k = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) +1

        di = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if di < k:
            index = j + 1
            k = di
    print(index)

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

a = [[0, 0] for i in range(n)]

c = [[0, 0] for i in range(m)]

for i in range(n):
    a[i][0], a[i][1] = map(int, input().split())

for i in range(n):
    c[i][0], c[i][1] = map(int, input().split())

index = 0

for i in range(n):
    for j in range(m):
        if j == 0 :
            k = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) +1

        di = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if di < k:
            index = j + 1
            k = di
    print(index)

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

a = [[0, 0] for i in range(n)]

c = [[0, 0] for i in range(m)]

for i in range(n):
    a[i][0], a[i][1] = map(int, input().split())

for i in range(n):
    c[i][0], c[i][1] = map(int, input().split())

index = 0

for i in range(n):
    k = 1<<20
    for j in range(m):
        di = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if di < k:
            index = j + 1
            k = di
    print(index)
Problem p02552 (python)

Fixed submission:
x = int(input())

if x == 0:
    print(1)
else:
    print(0)

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

if x == 0:
    prine(1)
else:
    print(0)
Problem p02572 (python)

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

a = [0]
for i in range(N):
    a.append(a[i] + A[i])

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

mod = 10 ** 9 + 7
ans = cnt % mod
print(ans)

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

def func(n):
    if n == 1:
        return 0
    else:
        sum = 0
        for i in range(n-1):
            sum += A[i]
        return func(n-1) + sum * A[n-1]

ans = func(N)
mod = 10 ** 9 + 7
print(ans % mod)
Problem p02624 (python)

Fixed submission:
N = int(input())
ans = 0
for i in range(1, N+1):
    j = N // i
    ans += i * j * (j+1) // 2

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(N):
    j = N // i
    ans += i * j * (j+1) / 2

print(ans)

Buggy submission (verdict: Runtime Error):
ans = 0
for i in range(N):
    j = N // i
    ans += i * j * (j+1) / 2

print(ans)
Problem p02729 (python)

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

print(N * (N - 1) // 2 + M * (M - 1) // 2)

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

print(N(N - 1) // 2 + M(M - 1) // 2)
Problem p02547 (python)

Fixed submission:
n = int(input())

a = []
for i in range(n):
    d,e = map(int,input().split())
    a.append([d,e])


b = []
for i in range(n):
    if a[i][0] == a[i][1]:
        b.append(1)
    else:
        b.append(0)

c = 0
for i in range(n-2):
    if b[i] == 1 and b[i+1] == 1 and b[i+2] == 1:
        c = 1
        break

if c == 1:
    print("Yes")
else:
    print("No")

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

a = []
for i in range(n):
    d,e = map(int,input().split())
    a.append([d,e])


b = []
for i in range(n):
    if a[i][0] == a[i][1]:
        b.append(1)
    else:
        b.append(0)

c = 0
for i in range(n):
    if b[i] == 1 and b[i+1] == 1 and b[i+2] == 1:
        c = 1
        break

if c == 1:
    print("Yes")
else:
    print("No")
Problem p02623 (python)

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

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

b = list(map(int,input().split()))


c = [0]
d = 0
for i in range(n):
    d += a[i]
    c.append(d)

e = [0]
f = 0
for i in range(m):
    f += b[i]
    e.append(f)


ans = 0
j = m
for i in range(n+1):
    if c[i] > k:
        break
    else:
        while c[i] + e[j] > k:
            j -= 1
    ans = max(i + j,ans)

print(ans)

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

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

b = list(map(int,input().split()))

c = [0]
d = 0
for i in range(n):
    d += a[i]
    c.append(d)

e = [0]
f = 0
for i in range(m):
    f += b[i]
    e.append(f)


ans = 0
j = q-1
for i in range(n):
    if c[i] > k:
        break
    else:
        while c[i] + e[j] > k:
            j -= 1
    ans = max(i + j,ans)

print(ans)

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

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

b = list(map(int,input().split()))

c = [0]
d = 0
for i in range(n):
    d += a[i]
    c.append(d)

e = [0]
f = 0
for i in range(n):
    f += b[i]
    e.append(f)


ans = 0
j = q-1
for i in range(n):
    if c[i] > k:
        break
    else:
        while c[i] + e[j] > k:
            j -= 1
    ans = max(i + j,ans)

print(ans)

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

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

b = list(map(int,input().split()))

c = [0]
d = 0
for i in range(n):
    d += a[i]
    c.append(d)
    if d > k:
        break

e = [0]
f = 0
for i in range(n):
    f += b[i]
    e.append(f)
    if f > k:
        break

p = len(c)
q = len(e)

ans = 0
j = q-1
for i in range(p):
    if c[i] > k:
        break
    else:
        while c[i] + e[j] > k:
            j -= 1
    ans = max(i + j,ans)

print(ans)
Problem p02820 (python)

Fixed submission:
def f(x):
    if x == "r":
        return "p"
    elif x == "s":
        return "r"
    else:
        return "s"

def g(x):
    if x == "r":
        return r
    elif x == "s":
        return s
    else:
        return p 

n,k = map(int,input().split())

r,s,p = map(int,input().split())

t = str(input())

m = n
a = 0
ss = [' '] * m

if m <= k:
    for i in range(m):
        a += g(f(t[i]))
    print(a)
else:
    for i in range(k):
        a += g(f(t[i]))
        ss[i] = f(t[i])
    for i in range(k,m):
        if t[i-k] != t[i]:
            a += g(f(t[i]))
            ss[i] = f(t[i])
        elif (t[i-k] == t[i]) and (ss[i-k] != f(t[i])):
            a += g(f(t[i]))
            ss[i] = f(t[i])
    print(a)

Buggy submission (verdict: Runtime Error):
def f(x):
    if x == "r":
        return "p"
    elif x == "s":
        return "r"
    else:
        return "s"

def g(x):
    if x == "r":
        return r
    elif x == "s":
        return s
    else:
        return p 

n,k = map(int,input().split())

r,s,p = map(int,input().split())

t = str(input())
ssssppr
m = n
a = 0
ss = [' '] * m

if m <= k:
    for i in range(m):
        a += g(f(t[i]))
    print(a)
else:
    for i in range(k):
        a += g(f(t[i]))
        ss[i] = f(t[i])
    for i in range(k,m):
        if t[i-k] != t[i]:
            a += g(f(t[i]))
            ss[i] = f(t[i])
        elif (t[i-k] == t[i]) and (ss[i-k] != f(t[i])):
            a += g(f(t[i]))
            ss[i] = f(t[i])
    print(a)

Buggy submission (verdict: Runtime Error):
def f(x):
    if x == "r":
        return "p"
    elif x == "s":
        return "r"
    else:
        return "s"

def g(x):
    if x == "r":
        return r
    elif x == "s":
        return s
    else:
        return p 

n,k = map(int,input().split())
 
r,s,p = map(int,input().split())
 
t = str(input())
ssssppr
m = n
a = 0
ss = [' '] ** m
 
if m <= k:
    for i in range(m):
        a += g(f(t[i]))
    print(a)
else:
    for i in range(k):
        a += g(f(t[i]))
        ss[i] = f(t[i])
    for i in range(k,m):
        if t[i-k] != t[i]:
            a += g(f(t[i]))
            ss[i] = f(t[i])
        elif (t[i-k] == t[i]) and (ss[i-k] != f(t[i])):
            a += g(f(t[i]))
            ss[i] = f(t[i])
    print(a)

Buggy submission (verdict: Runtime Error):
def f(x):
    if x == "r":
        return "p"
    elif x == "s":
        return "r"
    else:
        return "s"

def g(x):
    if x == "r":
        return r
    elif x == "s":
        return s
    else:
        return p 
n,k = map(int,input().split())

r,s,p = map(int,input().split())

t = str(input())
ssssppr
m = n
a = 0
ss = [' '] ** m

if m <= k:
    for i in range(m):
        a += g(f(t[i]))
    print(a)
else:
    for i in range(k):
        a += g(f(t[i]))
        ss[i] = f(t[i])
    for i in range(k,m):
        if t[i-k] != t[i]:
            a += g(f(t[i]))
            ss[i] = f(t[i])
        elif (t[i-k] == t[i]) and (ss[i-k] != f(t[i])):
            a += g(f(t[i]))
            ss[i] = f(t[i])
    print(a)
Problem p02835 (python)

Fixed submission:
x,y,z = map(int,input().split())

if x + y + z > 21:
    print('bust')
else:
    print('win')

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

ass = list(map(int,input().split()))

ans = 0
for i in range(60):
    k = 1 << i
    i_1 = sum([k & a for a in ass]) >> i
    ans += i_1 * (n - i_1) << i
    ans = ans % ((10**9) + 7)

print(ans)

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

a = []
xys = [[] for i in range(n)]

for j in range(n):
    a.append(int(input()))
    for i in range(a[j]):
        xys[j].append(list(map(int,input().split())))

ps = []
p = [0 for i in range(n)]
for i in range(n+1):
    for combi in itertools.combinations(range(n),i):
        p = [0 for i in range(n)]
        combi = list(combi)
        for i in combi:
            p[i] = 1
        ps.append(p)

for l in range(2**n):
    for i in range(n):
        if  (ps[l])[i] == 1:
            for j in range(a[i]):
                if ps[l][xys[i][j][0] - 1] != xys[i][j][1]:
                    ps[l] = [0,0,0]

print(max(sum(ps[l]) for l in range(2**n)))
Problem p02847 (python)

Fixed submission:
s = str(input())

if s == 'SUN':
    print(7)
elif s == 'SAT':
    print(1)
elif s == 'FRI':
    print(2)
elif s == 'THU':
    print(3)
elif s == 'WED':
    print(4)
elif s == 'TUE':
    print(5)
else:
    print(6)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

n = int(input())

graph = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    graph[a].append([b,i])

ans = [0]*(N-1)
def col(now,color):
    c = 1
    for (b,j) in graph[now]:
        if c == color:
            c += 1
    ans[j] = c
    col(b,c)
    c += 1

col(0,0)
print(max(ans))
[print(a) for a in ans]
Problem p02881 (python)

Fixed submission:
import math
n = int(input())

a = []
m = math.floor(n**(1/2))
for i in range(1,m + 1):
    if n % i == 0:
        a.append(i + (n/i) - 2)

print(int(min(a)))

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

a = []
m = math.floor(a**(1/2))
for i in range(1,m + 1):
    if n % i == 0:
        a.append(i + (n/i) - 2)

print(int(min(a)))

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

a = []
m = amth.floor(a**(1/2))
for i in range(1,m + 1):
    if n % i == 0:
        a.append(i + (n/i) - 2)

print(int(min(a)))