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

Fixed submission:
import numpy as np
import sys
N, M = [int(x) for x in input().split()]
s = []
c = []
for i in range(M):
  a, b = [int(x) for x in input().split()]
  s.append(a)
  c.append(b)
  
ans = np.full(N+1, -1)
for i in range(M):
  if(ans[s[i]]==-1):
    ans[s[i]] = c[i]
  elif(ans[s[i]]!=c[i]):
    print(-1)
    sys.exit()
if(ans[1]==-1)and(N>1):
  ans[1] = 1
ans = np.where(ans==-1, 0, ans)
 
if(ans[1]==0)and(N!=1):
  print(-1)
  sys.exit()
Ans = 0
for i in range(1, N+1):
  Ans += 10**(N-i)*ans[i]
print(int(Ans))

Buggy submission (verdict: Runtime Error):
ans = np.full(N+1, -1)
for i in range(M):
  if(ans[s[i]]==-1):
    ans[s[i]] = c[i]
  elif(ans[s[i]]!=c[i]):
    print(-1)
    sys.exit()

if(ans[1]==0)and(N!=1):
  print(-1)
  sys.exit()
if(ans[1]==-1)and(n!=1):
  ans[1] = 1
ans = np.where(ans==-1, 0, ans)
Ans = 0
for i in range(1, N+1):
  Ans += 10**(N-i)*ans[i]
print(int(Ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
N, M = [int(x) for x in input().split()]
s = []
c = []
for i in range(M):
  a, b = [int(x) for x in input().split()]
  s.append(a)
  c.append(b)

ans = np.full(N+1, -1)
for i in range(M):
  if(ans[s[i]]==-1):
    ans[s[i]] = c[i]
  elif(ans[s[i]]!=c[i]):
    print(-1)
    sys.exit()
if(ans[1]==-1)and(n>1):
  ans[1] = 1
ans = np.where(ans==-1, 0, ans)

if(ans[1]==0)and(N!=1):
  print(-1)
  sys.exit()
Ans = 0
for i in range(1, N+1):
  Ans += 10**(N-i)*ans[i]
print(int(Ans))
Problem p03400 (python)

Fixed submission:
N = int(input())
D, X = [int(x) for x in input().split()]
A = [int(input()) for _ in range(N)]
ans = X
for i in range(N):
  a = 1
  l = 1
  while a <= D:
    ans += 1
    a = l*A[i] + 1
    l += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
D, X = [int(x) for x in input().split()]
A = [int(input()) for _ in range(N)]
ans = X
for i in range(N):
  a = 1
  l = 1
  while a <= D:
    ans += 1
    a = l*A[i] + 1
    l += 1
print(ans)N = int(input())
D, X = [int(x) for x in input().split()]
A = [int(input()) for _ in range(N)]
ans = X
for i in range(N):
  a = 1
  l = 1
  while a <= D:
    ans += 1
    a = l*A[i] + 1
    l += 1
print(ans)
Problem p03624 (python)

Fixed submission:
import sys
S = list(input())
s = list(set(S))
s.sort()
alfa = list('abcdefghijklmnopqrstuvwxyz')
ans = 0
if(len(s)==len(alfa)):
  print('None')
  sys.exit()
else:
  for i in range(len(s)):
    if(s[i]!=alfa[i]):
      print(alfa[i])
      sys.exit()
  print(alfa[len(s)])

Buggy submission (verdict: Runtime Error):
import sys
S = list(input())
s = list(set(S))
s.sort()
alfa = list('abcdefghijklmnopqrstuvwxyg')
ans = 0
if(len(s)==len(alfa)):
  print('None')
  sys.exit()
else:
  for i in range(len(s)):
    if(s[i]!=alfa[i]):
      print(alfa[i])
      sys.exit()
  print(alfa[len(s)+1])

Buggy submission (verdict: Runtime Error):
import sys
S = list(input())
s = list(set(S))
s.sort()
alfa = list('abcdefghijklmnopqrstuvwxyg')
ans = 0
if(len(s)==len(alfa)):
  print('None')
else:
  for i in range(len(s)):
    if(s[i]!=alfa[i]):
      print(alfa[i])
      sys.exit()
  print(a)
Problem p02585 (python)

Fixed submission:
n,k = map(int,input().split())
p = [0] + list(map(int,input().split()))
c = [0] + list(map(int,input().split()))
maxsc = -1E20
for s in range(1,n+1):
  x = s
  sc = [0]
  i = 0
  while i<k:
    x = p[x]
    sc.append(sc[i]+c[x])
    i += 1
    if x == s:
      loop = i
      loopsc = sc[i]
      if loopsc > 0:
        baseup = loopsc * int((k-i)/loop)
        for j in range(loop):
          sc[j+1] += baseup
        for j in range((k-i)%loop):
          sc[j+1] += loopsc
      i=k
  sc[0] = -1e20
  maxsc = max(maxsc, max(sc))
print(maxsc)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = [0] + list(map(int,input().split()))
c = [0] + list(map(int,input().split()))
maxsc = 0
for s in range(1,n+1):
  x = s
  sc = [0]
  i = 0
  while i<k:
    x = p[x]
    sc.append(sc[i]+c[x])
    i += 1
  print(sc)
  maxsc = max(maxsc, max(sc))
print(maxsc)
Problem p02936 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline

N, Q = map(int, input().split())
connections = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    pa, ki = map(int, input().split())
    connections[pa].append(ki)
    connections[ki].append(pa)

scores = [0 for _ in range(N + 1)]
for _ in range(Q):
    tag, p = map(int, input().split())
    scores[tag] += p

i = 1

def dfs(k=1,bef=-1):
    global scores
    global fins
    kids = connections[k]
    if len(kids)==1 and bef==kids[0]:
        return
    for kid in kids:
        # print(f'k:{k} kids:{kids}')
        if bef==kid:
            continue
        scores[kid]+=scores[k]
        dfs(kid,k)


dfs()



print(*scores[1:])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
connections = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    pa, ki = map(int, input().split())
    connections[pa].append(ki)
    connections[ki].append(pa)
scores = [0 for _ in range(N + 1)]
for _ in range(Q):
    tag, p = map(int, input().split())
    scores[tag] += p

i = 1
fins = []

def dfs(k=1):
    global scores
    global fins
    if k in fins:
        return
    fins.append(k)
    kids = connections[k]
    if not kids:
        return
    for kid in kids:
        if kid in fins:
            continue
        scores[kid]+=scores[k]
        dfs(kid)


dfs()



print(*scores[1:])
Problem p03043 (python)

Fixed submission:
import math
N,K=map(int,input().split())

sum=0
for deme in range(1,N+1):
    need_challenge=max(0,math.ceil(math.log2(K)-math.log2(deme)))
    sum+=float((1/N)*((1/2)**need_challenge))
print('{:.13f}'.format(sum))

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

sum=0
for deme in range(1,N+1):
    need_challenge=max(0,math.ceil(math.log2(K)-math.log2(deme)))
    sum+=float((1/N)*((1/2)**need_challenge))
print('{:.13f}'.format(sum))
Problem p03047 (python)

Fixed submission:
N, K = map(int, input().split())
print(N - (K - 1))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input())
print(N - (K - 1))
Problem p03111 (python)

Fixed submission:

# 入力
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

INF = 10 ** 9


def dfs(cursor, a, b, c):  # cursor:カーソル a,b,c:現在の竹の長さ
    if cursor == N:  # cursorが最後まで行ったら終了する。
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    # abs(a - A) + abs(b - B) + abs(c - C) - 30 でなぜ30を減じているのかというと、
    # dfs(0,0,0)
    # dfs(0,0,0,0)で始まる以上、最初に選ばれるa,b,cを決定する際にもコストが10増加してしまうからである。
    # また、全探索を行う中で、a,b,cの初期値が0,0,0である以上、a,b,cのどれかが0のまま終了する場合が存在する。
    # この場合はa,b,cに竹が対応してないと言えるため、解にはならない、そこで三項演算子を利用して
    # その場合についてコストをINFとしている

    # 以下は4**Nで展開される再起処理となる。
    # カーソルの当たっている竹に対して、(A or B or Cに合成する) or (合成しない)の場合に分ける
    no_compound_pattern = dfs(cursor+1, a, b, c)
    compound_a_pattern = dfs(cursor+1, a + L[cursor], b, c)+10
    compound_b_pattern = dfs(cursor+1, a, b + L[cursor], c)+10
    compound_c_pattern = dfs(cursor+1, a, b, c + L[cursor])+10

    # 結果的に以下の値が返るのはそれぞれのパターンのコストが決定されてからなので
    # 以下のコードは最終的なコストの最小値
    return min(no_compound_pattern, compound_a_pattern, compound_b_pattern, compound_c_pattern)


print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
# 入力
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

INF = 10 ** 9


def dfs(cursor, a, b, c):  # cursor:カーソル a,b,c:現在の竹の長さ
    if cursor == N:  # cursorが最後まで行ったら終了する。
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    # abs(a - A) + abs(b - B) + abs(c - C) - 30 でなぜ30を減じているのかというと、
    # dfs(0,0,0)
    # dfs(0,0,0,0)で始まる以上、最初に選ばれるa,b,cを決定する際にもコストが10増加してしまうからである。
    # また、全探索を行う中で、a,b,cの初期値が0,0,0である以上、a,b,cのどれかが0のまま終了する場合が存在する。
    # この場合はa,b,cに竹が対応してないと言えるため、解にはならない、そこで三項演算子を利用して
    # その場合についてコストをINFとしている

    # 以下は4**Nで展開される再起処理となる。
    # カーソルの当たっている竹に対して、(A or B or Cに合成する) or (合成しない)の場合に分ける
    no_compound_pattern = dfs(cursor, a, b, c)
    compound_a_pattern = dfs(cursor, a + L[cursor], b, c)
    compound_b_pattern = dfs(cursor, a, b + L[cursor], c)
    compound_c_pattern = dfs(cursor, a, b, c + L[cursor])

    # 結果的に以下の値が返るのはそれぞれのパターンのコストが決定されてからなので
    # 以下のコードは最終的なコストの最小値
    return min(no_compound_pattern, compound_a_pattern, compound_b_pattern, compound_c_pattern)


print(dfs(0, 0, 0, 0))
Problem p03160 (python)

Fixed submission:
N = int(input())
H = [0] + [int(h) for h in input().split()]
dp = [999999999 for _ in range(N + 1)]
dp[0] = 0
dp[1] = 0
dp[2] = abs(H[2] - H[1])
for i in range(3, N + 1):
    dp[i] = min(dp[i], dp[i - 1] + abs(H[i - 1] - H[i]), dp[i - 2] + abs(H[i - 2] - H[i]))

print(dp[N])

Buggy submission (verdict: Runtime Error):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
import numpy as np
import sys
sys.setrecursionlimit(1000000000)
node_num = int(input())
nodes=input().split()




route_list=np.zeros((node_num,node_num))


mi_count=0
for i in range(node_num-1):
    if i+2<node_num:
        route_list[i][i+1]=abs(int(nodes[i+1])-int(nodes[i])) if abs(int(nodes[i+1])-int(nodes[i])) != 0 else 0.000000001
        route_list[i][i+2]=abs(int(nodes[i+2])-int(nodes[i])) if abs(int(nodes[i+2])-int(nodes[i])) != 0 else 0.000000001
    else:
        route_list[i][i+1]=abs(int(nodes[i+1])-int(nodes[i])) if abs(int(nodes[i+1])-int(nodes[i])) != 0 else 0.000000001


route_list = csr_matrix(route_list)
#print(route_list)
dist_matrix= dijkstra(csgraph=route_list, directed=False, indices=0, return_predecessors=False)

dis=dist_matrix[-1]

print(int(dis))

Buggy submission (verdict: Runtime Error):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
import numpy as np
node_num = int(input())
nodes=input().split()




route_list=np.zeros((node_num,node_num))


mi_count=0
for i in range(node_num-1):
    if i+2<node_num:
        route_list[i][i+1]=abs(int(nodes[i+1])-int(nodes[i])) if abs(int(nodes[i+1])-int(nodes[i])) != 0 else 0.0000001
        route_list[i][i+2]=abs(int(nodes[i+2])-int(nodes[i])) if abs(int(nodes[i+2])-int(nodes[i])) != 0 else 0.0000001
    else:
        route_list[i][i+1]=abs(int(nodes[i+1])-int(nodes[i])) if abs(int(nodes[i+1])-int(nodes[i])) != 0 else 0.0000001


route_list = csr_matrix(route_list)
#print(route_list)
dist_matrix= dijkstra(csgraph=route_list, directed=False, indices=0, return_predecessors=False)

dis=dist_matrix[-1]

print(int(dis))

Buggy submission (verdict: Runtime Error):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

node_num = int(input())
nodes=input().split()



for _ in range(node_num):
    route_list=[ 99999 for _ in range(node_num)]


mi_count=0
for i in range(node_num-1):
    if i+2<node_num:
        route_list[i][i+1]=abs(int(nodes[i+1])-int(nodes[i])) if abs(int(nodes[i+1])-int(nodes[i])) != 0 else 0.0000001
        route_list[i][i+2]=abs(int(nodes[i+2])-int(nodes[i])) if abs(int(nodes[i+2])-int(nodes[i])) != 0 else 0.0000001
    else:
        route_list[i][i+1]=abs(int(nodes[i+1])-int(nodes[i])) if abs(int(nodes[i+1])-int(nodes[i])) != 0 else 0.0000001


route_list = csr_matrix(route_list)
#print(route_list)
dist_matrix= dijkstra(csgraph=route_list, directed=False, indices=0, return_predecessors=False)

dis=dist_matrix[-1]

print(int(dis))
Problem p03240 (python)

Fixed submission:
# 解答ちらっと見た
# 問題のキモは Cx,Cy,Hがそれぞれ100通り、
# 全探索をCx,Cy,Hに対して試みると 入力された情報のcheckを入れて101*101*100*100でTLEする。
# でもよく考えてみると、Cx,CyがわかればHはそのあとで出せるので Cx,Cyに対して全探索をする(101*101*100+100の計算量で済む)


def get_H(Cx, Cy):
    for x, y, h in L:
        if h > 0:
            return abs(x - Cx) + abs(y - Cy) + h


def check_H(Cx, Cy, H):
    for x, y, h in L:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
            return False
    return True


N = int(input())

L = [(list(map(int, input().split()))) for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        H = get_H(Cx, Cy)
        if check_H(Cx, Cy, H):
            print('{} {} {}'.format(Cx, Cy, H))
            exit(0)

Buggy submission (verdict: Runtime Error):
# 解答ちらっと見た
# 問題のキモは Cx,Cy,Hがそれぞれ100通り、
# 全探索をCx,Cy,Hに対して試みると 入力された情報のcheckを入れて101*101*100*100でTLEする。
# でもよく考えてみると、Cx,CyがわかればHはそのあとで出せるので Cx,Cyに対して全探索をする(101*101*100+100の計算量で済む)


def check(x, y, h, cx, cy):
    return h + abs(x - cx) + abs(y - cy)


def checks(x, y, eh, cx, cy, h):
    cah = max(h - abs(x - cx) - abs(y - cy), 0)
    return cah == eh


N = int(input())
H = {}

checkers = [(list(map(int, input().split()))) for _ in range(N)]
for x,y,h in checkers:
    if h>0:
        lockx=x
        locky=y
        lockh=h

for icx in range(101):
    for icy in range(101):
        H = set({})
        for checker in checkers:
            H.add(lockh + abs(lockx - icx) + abs(locky - icy))

        if len(H) == 1:
            # print('{} {} {}'.format(icx, icy, H[0]))
            ok = True
            for c in checkers:
                if not checks(c[0], c[1], c[2], icx, icy, H[0]):
                    # print('failedin {} {} {} {} {} {}'.format(c[0], c[1], c[2], icx, icy, H[0]))
                    ok = False
                    break
            if ok:
                print('{} {} {}'.format(icx, icy, H[0]))
                exit(0)
Problem p03282 (python)

Fixed submission:
S=list(input())
K=int(input())
#print(S)
for i in range(K):
    n=int(S[i])
    if n==1:
        if K-1==i:
            print(1)
            exit(0)
    else:
        print(n)
        exit(0)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
print(1 if N%K != 0 else 0)
Problem p03292 (python)

Fixed submission:
list=input().split()
for i in list:
    i=int(i)
list.sort()
sumcosts=0
costs=0
first=True
mae=0
for i in list:
    i = int(i)
    if(first):
        first=False
        mae=i
    else:
        sumcosts=sumcosts+abs((i-mae))
        mae=i
print(sumcosts)

Buggy submission (verdict: Runtime Error):
class Need(object):
    def __init__(self,arg1,arg2):
        self.island1=int(arg1)
        self.island2=int(arg2)
        self.bridge=[]
        for i in range(arg1,arg2):
            self.bridge.append(i)
    def GETbridge(self):
        return self.bridge
deadbridges=0
islands,needsnum=map(int,input().split())
bridge=[0 for _ in range(islands-1)]
box = []
for i in range(needsnum):
    arg1,arg2=map(int,input().split())
    box.append(Need(arg1,arg2))
#ここから投票をする。
while(len(box)!=1):
    bridge = [0 for _ in range(islands - 1)]
    for need in box:
        list=need.GETbridge()
        for ing in list:
            bridge[ing-1]=bridge[ing-1]+1
    #集計終わり
    maxi=0
    for i in range(len(bridge)):
        if(bridge[i]>bridge[maxi]):
            maxi=i
    #橋を削除
    deadbridges=deadbridges+1
    #要望を削除
    kill=False
    for i in range(len(box)):
        try:
            s=box[i].GETbridge()
        except:
            break
        for k in s:
            if(k==bridge[maxi]):
                kill=True
                break
        if(kill):
            box.pop(i)
            i=i-1
print(deadbridges)

Buggy submission (verdict: Runtime Error):
class Need(object):
    def __init__(self,arg1,arg2):
        self.island1=int(arg1)
        self.island2=int(arg2)
        self.bridge=[]
        for i in range(arg1,arg2):
            self.bridge.append(i)
    def GETbridge(self):
        return self.bridge
deadbridges=0
islands,needsnum=map(int,input().split())
bridge=[0 for _ in range(islands-1)]
box = []
for i in range(needsnum):
    arg1,arg2=map(int,input().split())
    box.append(Need(arg1,arg2))
#ここから投票をする。
while(len(box)!=1):
    bridge = [0 for _ in range(islands - 1)]
    for need in box:
        list=need.GETbridge()
        for ing in list:
            bridge[ing-1]=bridge[ing-1]+1
    #集計終わり
    maxi=0
    for i in range(len(bridge)):
        if(bridge[i]>bridge[maxi]):
            maxi=i
    #橋を削除
    deadbridges=deadbridges+1
    #要望を削除
    kill=False
    for i in range(len(box)):
        try:
            s=box[i].GETbridge()
        except:
            break
        for k in s:
            if(k==bridge[maxi]):
                kill=True
                break
        if(kill):
            box.pop(i)
            i=i-1
print(deadbridges)
Problem p03328 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**6)

def sig(x):
    return 1 if x==1 else sig(x-1)+x


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

upper=int(sig(b-a))
print(upper-b)

Buggy submission (verdict: Runtime Error):
def sig(x):
    return 1 if x==1 else sig(x-1)+x


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

upper=int(sig(b-a))
print(upper-b)

Buggy submission (verdict: Runtime Error):
def sig(x):
    return 1 if x==1 else sig(x-1)+x


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

upper=int(sig(b-a))
print(upper-b)

Buggy submission (verdict: Runtime Error):
def sigx(x):
    if(x==1):
        return 1
    else:
        return sigx(x-1)+x

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

upper=int(sigx(b-a))
print(upper-b)

Buggy submission (verdict: Runtime Error):
def sigx(x):
    if(x==0):
        return 0
    else:
        return sigx(x-1)+x

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

upper=int(sigx(b-a))
print(upper-b)

Buggy submission (verdict: Runtime Error):
def sigx(x):
    if(x==0):
        return 0
    else:
        return sigx(x-1)+x

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

upper=sigx(b-a)
print(upper-b)
Problem p03351 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
direct_distance=abs(c-a)
AtB=abs(b-a)
BtC=abs(c-b)

if direct_distance<=d or (AtB <= d and BtC <= d):
    print('Yes')
else:
    print('No')

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

if X<4:
    print('1')
    exit(0)

n=2
p=2
max=0
b_flag=True
while True:
    n+=1
    #print(n)
    while b_flag:
        if n**p>X:
            b_flag=False
        elif max<n**p:
            max=n**p
        p+=1

    p = 2
    b_flag=True
    if n**p>X:
        break
print(max)

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

if X<4:
    print('1')
    exit(0)

n=2
p=2
max=0
b_flag=True
while True:

    #print(n)
    while b_flag:
        if n**p>X:
            b_flag=False
        elif max<n**p:
            max=n**p
        p+=1
    n+=1
    p = 2
    b_flag=True
    if n**p>X:
        break
print(max)

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

if X<4:
    print('1')
    exit(0)

n=2
p=2
max=0
b_flag=True
while True:

    #print(n)
    while b_flag:
        if n**p>X:
            b_flag=False
        elif max<n**p:
            max=n**p
        p+=1
    n+=1
    p = 2
    b_flag=True
    if n**p>X:
        break
print(max)
Problem p03370 (python)

Fixed submission:
N,X=map(int,input().split())
M=[int(input()) for _ in range(N)]
print(len(M)+(X-sum(M))//min(M))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

@lru_cache(maxsize=100000)
def dp(rest,score):
    ansbox=[]
    scorebox=[]
    for i in m_list:
        if (rest-i)>0:
            ansbox.append(dp(rest-i,score+1))
            scorebox.append(dp(rest-i, score+1)[1])
    if ansbox:
        max_index=scorebox.index(max(scorebox))
        return ansbox[max_index][0],ansbox[max_index][1]
    else:

        return rest,score
    pass

N,X=map(int,input().split())
m_list=[]
newX=X
sum=0
for i in range(N):
    inp=int(input())
    m_list.append(inp)
    newX-=inp

score=dp(newX,N)

print(score[1])
Problem p03377 (python)

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

need_neko_in_b=X-A

print('YES' if B >= need_neko_in_b and not A>X else 'NO')

Buggy submission (verdict: Runtime Error):
#include <iostream>
using namespace std;
int main(){
    int A,B,X;
    cin >> A >> B >> X;
    if( (B-X)>0 && (X-A)>=(B-X) )
    {
        cout<<"YES"<<endl;

    }
    else
    {
        cout<<"NO"<<endl;
    }

    return 0;
}
Problem p03425 (python)

Fixed submission:
import itertools
N=int(input())
S=[input() for _ in range(N)]
M=0
A=0
R=0
C=0
H=0
alives=0
march=['M','A','R','C','H']
for i in S:
    if i.startswith('M'):
        M+=1
    elif i.startswith('A'):
        A+=1
    elif i.startswith('R'):
        R+=1
    elif i.startswith('C'):
        C+=1
    elif i.startswith('H'):
        H+=1

if M==0:
    march.pop(march.index('M'))
if A==0:
    march.pop(march.index('A'))
if R==0:
    march.pop(march.index('R'))
if C==0:
    march.pop(march.index('C'))
if H==0:
    march.pop(march.index('H'))

if len(march)<3:
    print(0)
    exit(0)

seq=list(itertools.combinations(march,3))

ans=0
for i in seq:
    temp=1
    for ch in i:
        if ch=='M':
            temp*=M
        if ch=='A':
            temp*=A
        if ch=='R':
            temp*=R
        if ch=='C':
            temp*=C
        if ch=='H':
            temp*=H
    ans+=temp

print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
import itertools
N=int(input())
S=[input() for _ in range(N)]
M=0
A=0
R=0
C=0
H=0
alives=0
march=['M','A','R','C','H']
for i in S:
    if i.startswith('M'):
        M+=1
    elif i.startswith('A'):
        A+=1
    elif i.startswith('R'):
        R+=1
    elif i.startswith('C'):
        C+=1
    elif i.startswith('H'):
        H+=1

if M==0:
    march.pop(march.index('M'))
if A==0:
    march.pop(march.index('A'))
if R==0:
    march.pop(march.index('R'))
if C==0:
    march.pop(march.index('C'))
if H==0:
    march.pop(march.index('H'))

if len(march)<3:
    print(0)

seq=list(itertools.combinations(march,3))

ans=0
for i in seq:
    temp=1
    for ch in i:
        if ch=='M':
            temp*=M
        if ch=='A':
            temp*=A
        if ch=='R':
            temp*=R
        if ch=='C':
            temp*=C
        if ch=='H':
            temp*=H
    ans+=temp

print(ans)
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
print('Odd' if a*b%2==1 else 'Even')

Buggy submission (verdict: Runtime Error):
import numpy
a,b=map(int,input().split())
print('Odd' if a*b%2==1 else 'Even')
Problem p03624 (python)

Fixed submission:
alphabets = [i for i in range(ord('a'), ord('z') + 1)]
lists = [ord(i) for i in input()]
lists=list(set(lists))
lists.sort()
for i in range(len(alphabets)):
    if i+1>=len(lists) and i!=25:
        if alphabets[i] == lists[i]:
            print(chr(alphabets[i+1]))
            exit(0)
    if alphabets[i]!=lists[i]:
        print(chr(alphabets[i]))
        exit(0)


print('None')

Buggy submission (verdict: Runtime Error):
alphabets = [i for i in range(ord('a'), ord('z') + 1)]
lists = [ord(i) for i in input()]
lists=list(set(lists))
lists.sort()
for i in range(len(alphabets)):
    if i+1>=len(lists):
        if alphabets[i] == lists[i]:
            print(chr(alphabets[i+1]))
            exit(0)
    if alphabets[i]!=lists[i]:
        print(chr(alphabets[i]))
        exit(0)


print('None')

Buggy submission (verdict: Runtime Error):
alphabets = [i for i in range(ord('a'), ord('z') + 1)]
lists = [ord(i) for i in input()]
lists=list(set(lists))
lists.sort()
for i in range(len(alphabets)):
    if alphabets[i]!=lists[i]:
        print(chr(alphabets[i]))
        exit(0)

print('None')
Problem p03698 (python)

Fixed submission:
S = [i for i in input()]
print('yes' if len(S) == len(set(S)) else 'no')

Buggy submission (verdict: Runtime Error):
S=[for i in input()]
print('yes' if len(S)==len(set(S)) else 'no')
Problem p03759 (python)

Fixed submission:
a, b, c = map(int, input().split())
print('YES' if (b - a) == (c - b) else 'NO')

Buggy submission (verdict: Runtime Error):
print('YES' if (lambda poles=input().split(): True if (int(poles[1])-input(poles[0]))==(int(poles[2])-input(poles[1])) else False)() else 'NO')