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

Fixed submission:
import itertools
def main():
    N = int(input())
    P = list(map(int, input().split()))
    S = list(map(int, input().split()))
    count = 1
    if P == S:
        print(0)
    else:
        for i in itertools.permutations(list(range(1,N + 1))):
            if P == list(i):
                a = count
            elif S == list(i):
                b = count
            count += 1
        print(abs(a - b))
main()

Buggy submission (verdict: Runtime Error):
import itertools
def main():
    N = int(input())
    P = list(map(int, input().split()))
    S = list(map(int, input().split()))
    count = 1
    for i in itertools.permutations(list(range(1,N + 1))):
        if P == list(i):
            a = count
        elif S == list(i):
            b = count
        count += 1
    print(abs(a - b))
main()
Problem p02817 (python)

Fixed submission:
def main():
    S,T = map(str,input().split())
    print(T+S)
 
if __name__ == '__main__':
    main()

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

print(T+S)
Problem p02830 (python)

Fixed submission:
n = int(input())
s,t = input().split()
for i in range(n):
  print(s[i]+t[i],end='')

Buggy submission (verdict: Runtime Error):
n = int(input())
s,t = map(input().split())
for i in range(n):
  print(s[i]+t[i],end='')
Problem p02953 (python)

Fixed submission:
N = int(input())
b_list = list(map(int,input().split()))
s = True
if (b_list[0] > 1):
  b_list[0] -= 1
for i in range(1,len(b_list)):
  if (b_list[i-1] < b_list[i]):
    b_list[i] -= 1
for i in range(len(b_list)-1):
  if (b_list[i] > b_list[i+1]):
    s = False
if (s):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
b_list = list(map(int,input().split()))
s = True
if (b_list[0] > 1):
  b_list -= 1
for i in range(1,len(b_list)):
  if (b_list[i-1] < b_list[i]):
    b_list[i] -= 1
for i in range(len(b_list)-1):
  if (b_list[i] > b_list[i+1]):
    s = False
if (s):
  print('Yes')
else:
  print('No')
Problem p03160 (python)

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

dp_table = [0 for i in range(n)]
dp_table[1] = abs(a[0] - a[1])
for i in range(2,len(a)):
    dp_table[i] = min(dp_table[i-2]+abs(a[i-2]-a[i]),dp_table[i-1]+abs(a[i-1]-a[i]))
print(dp_table[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
inf = 1e14
dp_table = [inf for i in range(n)]
dp_table[0] = 0
dp_table[1] = abs(a[0] - a[1])
for i in range(2,len(a)):
    dp_table[i] = min(dp_table[i-2]+abs(a[i-2]-a[i]),dp_table[i-1]+abs(a[i-1]-a[i]))
    print(dp_table)
print(dp_table[-1])
Problem p02848 (python)

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

out = ""
for i in S:
    tmp = (ord(i) + N) % 91
    if tmp < 65:
        tmp = tmp + 65
    out = out + chr(tmp)

print(out)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N = int(readline())
S = [int(x) - ord("A") for x in read().rstrip]
N = int(readline())

S = [(x + N) % 26 for x in S]

anser = "".join(chr(x + ord("A")) for x in S)

print(anser)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N = int(readline())
S = [int(x) - ord("A") for x in read().rstrip]
N = int(readline())

S = [(x + N) % 26 for x in S]

anser = "".join([chr(x + ord("A")) for x in S])

print(anser)
Problem p02778 (python)

Fixed submission:
s=input()
num=len(s)
print("x"*(num))

Buggy submission (verdict: Runtime Error):
s=input()
num=len(s)å
print("x"*(num))
Problem p02791 (python)

Fixed submission:
n=int(input())
l=list(map(int, input().split()))
# n=5
# l=[4,2,5,1,3]
count=0

import heapq

tmp=l[0]
for i in range(1,len(l)+1):
    if tmp>=l[i-1]:
        count+=1
        tmp=l[i-1]
    
    
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=map(int, input().split())
# n=5
# l=[4,2,5,1,3]
count=0
for i in range(1,len(l)+1):
#     print(l[:i])
#     print(l[i-1])
    if min(l[:i])==l[i-1]:
        count+=1
    
    
    
print(count)
Problem p02802 (python)

Fixed submission:
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
from collections import defaultdict
n,m=map(int, input().split())
ac=set()
ac_cnt=0
wa_cnt=0
d_ac=defaultdict(int)
d_wa=defaultdict(int)
for i in range(m):
    p,s=nm()
    if s=='AC':
        if int(p) in ac:
            continue
        ac.add(int(p))
        ac_cnt+=1
    elif s=='WA':
        if int(p) in ac:
            continue
        d_wa[p]+=1
 
for a in ac:
    wa_cnt+=d_wa[str(a)]
 
print(ac_cnt,wa_cnt)

Buggy submission (verdict: Runtime Error):
ABC151 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
from collections import defaultdict
n,m=map(int, input().split())
ac=set()
ac_cnt=0
wa_cnt=0
d_ac=defaultdict(int)
d_wa=defaultdict(int)
for i in range(m):
    p,s=nm()
    if s=='AC':
        if int(p) in ac:
            continue
        ac.add(int(p))
        ac_cnt+=1
    elif s=='WA':
        if int(p) in ac:
            continue
        d_wa[p]+=1
 
for a in ac:
    wa_cnt+=d_wa[str(a)]
 
print(ac_cnt,wa_cnt)
Problem p02806 (python)

Fixed submission:
N=int(input())
s=[]
t=[]
for i in range(N):
    s_tmp,t_tmp=map(str,input().split())
    s.append(s_tmp)
    t.append(int(t_tmp))
X=input() 

# N=3
# s=["dwango","sixth","prelims"]
# t=[ 2, 5,25]
# X="prelims"

print(sum(t[s.index(X)+1:]))

Buggy submission (verdict: Runtime Error):
N=int(input())
s=[]
t=[]
for i range(N):
    s_tmp,t_tmp=map(str,input().split())
    s.append(s_tmp)
    t.append(int(t_tmp))
X=input() 

# N=3
# s=["dwango","sixth","prelims"]
# t=[ 2, 5,25]
# X="prelims"

print(sum(t[s.index(X)+1:]))
Problem p02823 (python)

Fixed submission:
N, A, B = map(int, input().split())
 
if (B - A) % 2 == 0:
    print((B-A) // 2)
else:
    print(min(A - 1, N - B) + 1 + (B-A) // 2)

Buggy submission (verdict: Runtime Error):
n,m,v,p = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
def binary_search(left, right):
    if right - left <= 1:
        return left
    middle = (left + right) // 2
    if check(middle):
        return binary_search(middle, right)
    else:
        return binary_search(left, middle)
 
def check(target):
    used_vote = (p + n - target - 1) * m
    sum_vote = 0
    for i in range(target-1, p-2, -1):
        if a[target] + m < a[i]:
            return False
        sum_vote += (a[target] + m) - a[i]
    if sum_vote >= (m * v - used_vote): 
        return True
    else:
        return False
print(binary_search(0,n) + 1)
Problem p02953 (python)

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




for i in range(len(s)-2,-1,-1):    
    if s[i]>s[i+1]:
        s[i]=s[i]-1


        
if s==sorted(s):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
 int(input())
l = list(map(int, input().split()))
 
l[0] -= 0
 
ans = 'Yes'
for i in range(1,N):
    if l[i-1] < l[i]:
        l[i] -= 1
    elif l[i-1] == l[i]:
        pass
    else:
        ans = 'No'
        break
print(ans)
Problem p03043 (python)

Fixed submission:
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    if i>=k:
        ans+=1/n
    else:
        cnt=1/n
        while i<k:
            cnt*=(1/2)
            i=2*i
        ans+=cnt
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ans=0
for i in range(1,N+1):
  if i>=k:
    ans+=1/n
  else:
    cnt=1/n
    while i<k:
      cnt*=(1/2)
      i=2*i
    ans+=cnt
print(ans)
Problem p03311 (python)

Fixed submission:
n=int(input())
al=list(map(int,input().split()))
t=[]
for i in range(n):
    t.append(al[i]-(i+1))
t=sorted(t)
if n%2==0:
    v=(t[n//2-1]+t[n//2])//2
else:
    v=t[n//2]
ans=0
for i in t:
    ans+=abs(i-v)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
A=[int(i) for i in input().split()]
A=[A[i]-i for i in range(N)]
#print(A)
b=np.median(A)
K=[abs(A[i]-b) for i in range(N)]
print(int(sum(K)))
Problem p03497 (python)

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

import sys
import collections
c = collections.Counter(t)
c=sorted(list(c.values()))
ans=0
delete_count=len(c)-k
if delete_count<=0:
    print(0)
    sys.exit()
else:
    for i in range(delete_count):
        if len(c)>k:
            ans+=c[i]
            
print(ans)
sys.exit()

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

import sys
import collections
c = collections.Counter(t)
c=sorted(list(c.values()))
ans=0
delete_count=len(c)-k
if delete_count<=0:
    print(0)
    sys.exit()
else:
    for i in range(delete_count):
        if len(c)>k:
            ans+=c[i]
            
print(ans)
sys.exit()

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

import sys
import collections
c = collections.Counter(t)
c=sorted(list(c.values()))
ans=0
delete_count=len(c)-k
if delete_count<=0:
    print(0)
else:
    for i in range(delete_count):
        if len(c)>k:
            ans+=c[i]
            
print(ans)
sys.exit()
Problem p03635 (python)

Fixed submission:
a,b=map(int,input().split())
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
a,b=str(int,input().split())
print((a-1)*(b-1))
Problem p03636 (python)

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

Buggy submission (verdict: Runtime Error):
word=str(iinput)
print(woed[0]+str(len(word)-2)+word[-1])
Problem p03733 (python)

Fixed submission:
N,T=map(int,input().split())
t= list(map(int,input().split()))
ans=0
t_diff=[t[i+1]-t[i] for i in range(N-1)]
for i in t_diff:
    if i>T:
        ans+=T
    else:
        ans+=i
# 差分で足し合わせたので最後は計算に入ってない、最後は必ず被らないのでTを加える
print(ans+T)

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

t=[0,3,5,7,100,110,200,300,311]
ans=0
t_diff=[t[i+1]-t[i] for i in range(N-1)]
print(t_diff)
for i in t_diff:
    if i>T:
        ans+=T
    else:
        ans+=i
# 差分で足し合わせたので最後は計算に入ってない、最後は必ず被らないのでTを加える
print(ans+T)
Problem p03738 (python)

Fixed submission:
a=int(input())
b=int(input())
if a>b:
    print("GREATER")
if a<b:
    print("LESS")
if a==b:
    print("EQUAL")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a>b:
    print("GREATER")
if a<b:
    print("LESS")
if a==b:
    print("EQUAL")
Problem p03778 (python)

Fixed submission:
w,a,b=map(int, input().split())
if a<=b:
    print(max(0,(b-a-w)))
if b<a:
    print(max(0,(a-b-w)))

Buggy submission (verdict: Runtime Error):
w,a,b=map(int, input().split())
print(min(abs(a+w-b)),abs(a-b-w))
Problem p03861 (python)

Fixed submission:
a,b,x=map(int, input().split())
if (a%x==0):
    print((b//x-a//x)+1)
else:
    print((b//x-a//x))

Buggy submission (verdict: Runtime Error):
a,b,x=map(int, input().split())
count_n=0
for i in range(a,b+1):
	if i%2==0:
    count_n+=1
print(count_n)
Problem p03945 (python)

Fixed submission:
word=input()
# word="WBWBWBWBWB"
ans=0
for i in range(len(word)-1):
    if word[i]!=word[i+1]:
        ans+=1
        
print(ans)

Buggy submission (verdict: Runtime Error):
word=inpput()
# word="WBWBWBWBWB"
ans=0
for i in range(len(word)-1):
    if word[i]!=word[i+1]:
        ans+=1
        
print(ans)

Buggy submission (verdict: Runtime Error):
word=inpput()
# word="WBWBWBWBWB"
ans=0
for i in range(len(word)-1):
    if word[i]!=word[i+1]:
        ans+=1
        
print(ans)
Problem p03947 (python)

Fixed submission:
s=input()
cnt=0
for i in range(1,len(s)):
  if s[i]!=s[i-1]:
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
s=input()
cnt=0
for i range(1,len(s)):
  if s[i]!=s[i-1]:
    cnt+=1
print(cnt)
Problem p03963 (python)

Fixed submission:
a,b=map(int,input().split())
n=b*(b-1)**(a-1)
print(n)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().spllt())
n=b+(a-1)*(b-1)
print(n)
Problem p04011 (python)

Fixed submission:
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(min(n,k)*x+max(n-k,0)*y)

Buggy submission (verdict: Runtime Error):
n,k,x,y=map(int, input().split("¥n"))
tmp=0
if n>=k:
    print(x*k+y*(n-k))
else:
    print(x*n)

Buggy submission (verdict: Runtime Error):
n,k,x,y=map(int, input().split())
tmp=0
if n>=k:
    print(x*k+y*(n-k))
else:
    print(x*n)

Buggy submission (verdict: Runtime Error):
n,k,x,y=map(int, input().split())
tmp=0
if n>=k:
    print(x*k+y*(n-k))
else:
    print(x*n)

Buggy submission (verdict: Runtime Error):
n,k,x,y=map(int, input().split())
sum_n=x*k+y*(n-k)
print(sum_n)
Problem p04029 (python)

Fixed submission:
n=int(input())
sum_n=0
for i in range(n+1):
  sum_n+=i
print(sum_n)

Buggy submission (verdict: Runtime Error):
n=int(input())
sun_m=0
for i in range(n+1):
  sum_m+=i
print(sum_n)

Buggy submission (verdict: Runtime Error):
n=map(int,input())
sun_m=0
for i in range(n+1):
  sum_n+=i
print(sum_n)

Buggy submission (verdict: Runtime Error):
n=map(int,input())
sun_n=0
for i in range(n+1):
  sun_n+=i
 print(sun_n)
Problem p04043 (python)

Fixed submission:
a,b,c=map(int, input().split())
if sorted(list((a,b,c)))==[5,5,7]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if sorted(list[a,b,c])==[5,5,7]:
  print("YES")
else:
  print("NO")
Problem p04044 (python)

Fixed submission:
n, l = map(int, input().split())
s = []
for i in range(n):
    s.append(input())
print(''.join(sorted(s)))

Buggy submission (verdict: Runtime Error):
n,l=map(int,input())
s=[]
for i in range(n):
	s.append(input())
print("",join(sorted(s)))

Buggy submission (verdict: Runtime Error):
n,l=map(int,input())
s=[]
for i in range(n):
	s.append(i)
print("",join(sorted(s)))
Problem p02811 (python)

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

if K * 500 >= X:
  print("Yes")
else: print("No")

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

if K * 500 >= X:
  print("Yes")
else print("No")
Problem p02853 (python)

Fixed submission:
a, b = input().split(" ")
x = int(a)
y = int(b)

amt = 0
if x == 1:
    amt += 300000
elif x == 2:
    amt += 200000
elif x == 3:
    amt += 100000

if y == 1:
    amt += 300000
elif y == 2:
    amt += 200000
elif y == 3:
    amt += 100000

if x == 1 and y == 1:
    amt += 400000

print (amt)

Buggy submission (verdict: Runtime Error):
# At Coder 1
def calculate_reward_earning_per_competition(rank):
    # Get input for ranking of both competition
        switcher = { 
            1: 300000, 
            2: 200000 , 
            3: 100000, 
        }
    # 4th ranking and below will recieve nothing 
        return switcher.get(rank, 0)
        
# Execution

# Getting ranking of Coding Contest and Robot Manuever
x = int(input("Enter your Coding Contest Ranking : "))
y = int(input("Enter your Robot Manuever Ranking: 100")) 
if x > 205 or x < 1 or y > 205 or y < 1:
    print("Nothing")
else:
    # Overall Winning Prize
    total_winning_prize = calculate_reward_earning_per_competition(x) + calculate_reward_earning_per_competition(y)
    if total_winning_prize == 600000:
        print(total_winning_prize + 400000)
    else:
        print(total_winning_prize)

Buggy submission (verdict: Runtime Error):
# At Coder 1
def calculate_reward_earning_per_competition(rank):
  # Get input for ranking of both competition
    switcher = { 
        1: 300000, 
        2: 200000 , 
        3: 100000, 
    }
   # 4th ranking and below will recieve nothing 
    return switcher.get(rank, 0)

# Execution
# Getting ranking of Coding Contest and Robot Manuever
x = int(input("Enter your Coding Contest Ranking: "))
y = int(input("Enter your Robot Manuever Ranking")) 
# Overall Winning Prize
total_winning_prize = calculate_reward_earning_per_competition(x) + calculate_reward_earning_per_competition(y)
if total_winning_prize == 600000:
  print(total_winning_prize + 400000)
else:
  print(total_winning_prize)

Buggy submission (verdict: Runtime Error):
# At Coder 1
def calculate_reward_earning_per_competition(rank):
  # Get input for ranking of both competition
    switcher = { 
        1: 300000, 
        2: 200000 , 
        3: 100000, 
    }
   # 4th ranking and below will recieve nothing 
    return switcher.get(rank, 0)

# Execution
# Getting ranking of Coding Contest and Robot Manuever
x = int(input("Enter your Coding Contest Ranking: "))
y = int(input("Enter your Robot Manuever Ranking")) 
# Overall Winning Prize
total_winning_prize = calculate_reward_earning_per_competition(x) + calculate_reward_earning_per_competition(y)
if total_winning_prize == 600000:
  print(total_winning_prize + 400000)
else:
  print(total_winning_prize)
Problem p02898 (python)

Fixed submission:
n=input().split()
N=int(n[0])
K=int(n[1])
h=list(map(int,input().split()))
sum=0
for i in range(N):
    if h[i]>=K:
        sum=sum+1
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
sum=0
for i in range(n):
  h=int(input())
  if h>=k:
    sum=sum+1
print(sum)
Problem p02900 (python)

Fixed submission:
import fractions
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n=list(map(int, input().split()))
a=fractions.gcd(n[0], n[1])
c = collections.Counter(prime_factorize(a))
b=list(c.keys())
d=len(b)+1
print(d)

Buggy submission (verdict: Runtime Error):
import math
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n=list(map(int, input().split()))
a=math.gcd(n[0], n[1])
c = collections.Counter(prime_factorize(a))
b=list(c.keys())
d=len(b)
print(d+1)
Problem p02909 (python)

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

Buggy submission (verdict: Runtime Error):
s=input()
if s=='Sunny':
    print('Cloudy')
else if s=='Cloudy':
    print('Rainy')
else:
    print('Sunny')
Problem p03369 (python)

Fixed submission:
S = input()
count = 0
for i in range(3):
	if S[i] == 'o':
		count += 1

print(700 + 100*count)

Buggy submission (verdict: Runtime Error):
N, C = list(map(int, input().split()))
len_cal_list = [list(map(int, input().split())) for i in range(N)]

total_cal = 0
f_r = [0]
for l, c in len_cal_list:
    total_cal += c
    f_r.append(total_cal - l)

total_cal = 0
f_l = [0]
for l, c in len_cal_list[::-1]:
    total_cal += c
    f_l.append(total_cal - (C - l))


max_cal = 0
for i in range(N):
	tmp_cal_r = f_r[i] + max(max(f_l[:N-i+1]) - len_cal_list[i-1][0], 0)
	tmp_cal_l = f_l[i] + max(max(f_r[:N-i+1]) - (C - len_cal_list[-i][0]), 0)
	if max_cal <= max(tmp_cal_r, tmp_cal_l):
		max_cal = max(tmp_cal_r, tmp_cal_l)

print(max_cal)
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 = list(int, input().split())
if (A+B) >=C:
	print("Yes")
else:
	print("No")
Problem p03423 (python)

Fixed submission:
n = int(input())
out = int(n / 3)
print(out)

Buggy submission (verdict: Runtime Error):
H,W,D = list(map(int, input().split()))
X = [[0,0] for i in range(H*W+1)]

for i in range(1, H+1):
	A = list(map(int, input().split()))
	for idx, a in enumerate(A):
		X[a] = [i, idx+1]

Q = int(input())
L = []
R = []
S = [0]*(H*W+1)

for i in range(Q):
	l,r = list(map(int, input().split()))
	L.append(l)
	R.append(r)

for i in range(D+1, H*W+1):
	S[i] = S[i-D] + abs(X[i][0]-X[i-D][0])+abs(X[i][1]-X[i-D][1])

for i in range(Q):
	print(S[R[i]] - S[L[i]])

Buggy submission (verdict: Runtime Error):
N = int(input())
num = [0,0,0,0,0]
answer = 0
for i in range(N):
	a = input()
	if a[0]=='M':
		num[0] += 1
	if a[0]=='A':
		num[1] += 1
	if a[0]=='R':
		num[2] += 1
	if a[0]=='C':
		num[3] += 1
	if a[0]=='H':
		num[4] += 1

for i in range(3):
  for j in range(i+1, 4):
	for k in range(j+1, 5):
		answer += num[i]*num[j]*num[k]

print(answer)
Problem p03425 (python)

Fixed submission:
N = int(input())
num = [0,0,0,0,0]
for i in range(N):
	a = input()
	if a[0]=='M':
		num[0] += 1
	if a[0]=='A':
		num[1] += 1
	if a[0]=='R':
		num[2] += 1
	if a[0]=='C':
		num[3] += 1
	if a[0]=='H':
		num[4] += 1


num_1 = num[0]*num[1]*num[2]
num_2 = num[0]*num[1]*num[3]
num_3 = num[0]*num[1]*num[4]
num_4 = num[1]*num[2]*num[3]
num_5 = num[1]*num[2]*num[4]
num_6 = num[2]*num[3]*num[4]
num_7 = num[0]*num[2]*num[3]
num_8 = num[0]*num[2]*num[4]
num_9 = num[0]*num[3]*num[4]
num_10 = num[1]*num[3]*num[4]

answer = num_1 + num_2 + num_3 + num_4 + num_5 + num_6 + num_7 + num_8 + num_9 + num_10

print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
num = [0,0,0,0,0]
for i in range(N):
  a = input()
  if a[0]=='M':
    num[0] += 1
  if a[0]=='A':
    num[1] += 1
  if a[0]=='R':
	num[2] += 1
  if a[0]=='C':
	num[3] += 1
  if a[0]=='H':
	num[4] += 1


num_1 = num[0]*num[1]*num[2]
num_2 = num[0]*num[1]*num[3]
num_3 = num[0]*num[1]*num[4]
num_4 = num[1]*num[2]*num[3]
num_5 = num[1]*num[2]*num[4]
num_6 = num[2]*num[3]*num[4]
num_7 = num[0]*num[2]*num[3]
num_8 = num[0]*num[2]*num[4]
num_9 = num[0]*num[3]*num[4]
num_10 = num[1]*num[3]*num[4]

answer = num_1 + num_2 + num_3 + num_4 + num_5 + num_6 + num_7 + num_8 + num_9 + num_10

print(answer)
Problem p03288 (python)

Fixed submission:
R = int(input())
if R < 1200:
  print('ABC')
elif R < 2800:
  print('ARC')
else:
  print('AGC')

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]
sum_list = [(i+1)*100*pac[0] for i, pac in enumerate(pc)]
max_list = [(i+1)*100*pac[0]+pac[1] for i, pac in enumerate(pc)]
stoc = 0
shiyouzumi = []
ichian = 0
nian = 0
while 1:
    kouho1 = []
    kouho2 = []
    for i in range(D):
        if i in shiyouzumi:
            continue
        if G <= sum_list[i]:
            kouho1.append(i)
        if G <= max_list[i]:
            kouho2.append(i)
    if kouho1 != []:
        saikou = kouho1[-1]
        for i in range(pc[saikou][0]+1):
            if i*(saikou+1)*100 >= G :
                ichian = stoc+i
                break
    if kouho2 != []:
        mini = 1000
        for i in kouho2:
            if mini > pc[i][0]:
                mini = pc[i][0]
        nian = stoc+mini
    chiisai = min(ichian, nian)
    if chiisai != 0:
        print(chiisai)
        exit()
    kouritsu = 0
    kouritsu_i = -1
    for i, s in enumerate(max_list):
        if i in shiyouzumi:
            continue
        if s/pc[i][0] > kouritsu:
            kouritsu_i = i
            kouritsu = s/pc[i][0]
    stoc += pc[kouritsu_i][0]
    G -= max_list[kouritsu_i]
    shiyouzumi.append(kouritsu_i)
Problem p03351 (python)

Fixed submission:
a,b,c,d = map(int, input().split())
if abs(a-c)<=d:
  print('Yes')
  exit()
if abs(b-a)<=d and abs(c-b)<=d:
  print('Yes')
  exit()
print('No')

Buggy submission (verdict: Runtime Error):
s = input()
z = int(input())
list = [chr(i) for i in range(97,97+26)]
d = []
for j in list:
  indexes = [i for i,x in enumerate(s) if x==j]
  if len(indexes)==0:
    continue
  for k in indexes:
    for l in range(len(s)-k):
      d.append(s[k:l+k+1])
      if len(s[k:l+k+1])==z:
        break
print(sorted(set(d))[z-1])