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

Fixed submission:
from sys import stdin
lis =[]
#k = int(stdin.readline().rstrip())
lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
count = 0
x = 0
y = 0
z = 0
for x in range(k+1):
    y = 0
    for y in range(k+1):
        z = 0
        z = s - x - y
        if z <= k and z >= 0:
                count +=1



print(count)

Buggy submission (verdict: Runtime Error):
from sys import stdin

k = int(stdin.readline().rstrip())
s = int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

for x in range(s+1):
    y = 0
    for y in range(s+1):
        z = 0
        z = s - x - y
        if s <= 3*k:
            break;
        if x <= k and y <= k and z<= k and 0 <= z:
            count +=1
            print(x,y,z)

print(count,flush=True)

Buggy submission (verdict: Runtime Error):
from sys import stdin

k = int(stdin.readline().rstrip())
s = int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

for x in range(s+1):
    y = 0
    for y in range(s+1):
        z = 0
        z = s - x - y
        if x <= k and y <= k and z<= k and 0 <= z:
            count +=1
            #print(x,y,z)

print(count,flush=True)

Buggy submission (verdict: Runtime Error):
from sys import stdin

k = int(stdin.readline().rstrip())
s = int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

for x in range(s+1):
    y = 0
    for y in range(s+1):
        z = 0
        z = s - x - y
        if x <= k and y <= k and z<= k and 0 <= z:
            count +=1
            print(x,y,z)

print(count,flush=True)

Buggy submission (verdict: Runtime Error):
from sys import stdin

k = int(stdin.readline().rstrip())
s = int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

for x in range(s+1):
    y = 0
    for y in range(s+1):
        z = 0
        if x + y + z <= k:
            z = s - x - y
            count +=1
            #print(x,y,z)

print(count,flush=True)
Problem p02580 (python)

Fixed submission:
import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)

Buggy submission (verdict: Runtime Error):
# 初期入力
import sys
from collections import defaultdict
import numpy as np
input = sys.stdin.readline  #文字列では使わない
H,W,M = map(int, input().split())
bomb =np.zeros((H,W),np.int64)
posision =defaultdict(int)

for i in range(M):
    h,w = map(int, input().split())
    bomb[h-1,:] +=1
    bomb[:,w-1] +=1
    bomb[h-1,w-1] -=1
    posision[(h-1,w-1)] =1

#index =np.unravel_index(np.argmax(bomb), bomb.shape)
bom_max =np.max(bomb)
print(int(bom_max))

Buggy submission (verdict: Runtime Error):
# 初期入力
import sys
from collections import defaultdict
import numpy as np
input = sys.stdin.readline  #文字列では使わない
H,W,M = map(int, input().split())
bomb =np.zeros((H,W))
posision =defaultdict(int)

for i in range(M):
    h,w = map(int, input().split())
    bomb[h-1,:] +=1
    bomb[:,w-1] +=1
    bomb[h-1,w-1] -=1
    posision[(h-1,w-1)] =1

#index =np.unravel_index(np.argmax(bomb), bomb.shape)
bom_max =np.max(bomb)
print(int(bom_max))

Buggy submission (verdict: Runtime Error):
# 初期入力
import sys
from collections import defaultdict
import numpy as np
input = sys.stdin.readline  #文字列では使わない
H,W,M = map(int, input().split())
bomb =np.zeros(H+1,W+1)
posision =defaultdict(int)

for i in range(M):
    h,w = map(int, input().split())
    bomb[h,:] +=1
    bomb[:,w] +=1
    posision[(h,w)] =1

index =np.unravel_index(np.argmax(bomb), bomb.shape)
bom_max =np.max(bomb)
ans =0
if posision[index] ==1:
    ans =bom_max -1
else:
    ans =bom_max
print(ans)
Problem p02629 (python)

Fixed submission:
#######関数部分##############
#url http://iatlex.com/python/base_change
def Base_10_to_n(X, n):
    if (int((X-1)/n)):
        return Base_10_to_n(int((X-1)/n), n)+" "+str((X-1)%n)
    return str(X%n)
############################

# 初期入力
import sys
input = sys.stdin.readline
N = int(input())

#26進数に変換
x26 = Base_10_to_n(N, 26) 
x26_list =list(x26.split())
#x26_list.remove(" ")
int_str =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

#26進数⇒文字
ans =""
if len(x26_list) ==1:
    ans +=int_str[int(x26_list[0])-1]
else:
    ans +=int_str[int(x26_list[0])-1]

    for i in range(1,len(x26_list)):
        a =x26_list[i]
        x =int_str[int(a)]
        ans +=x

print(ans)

Buggy submission (verdict: Runtime Error):
#######関数部分##############
#url http://iatlex.com/python/base_change
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+" "+str(X%n)
    return str(X%n)
############################

# 初期入力
import sys
input = sys.stdin.readline
N = int(input())

#26進数に変換
x26 = Base_10_to_n(N-1, 26) 
x26_list =x26.split()
int_str =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

#26進数⇒文字
if x26_list[0] =="1":
    del x26_list[0]
ans =""
for i in range(len(x26_list)-1):
    a =x26_list[i]
    x =int_str[int(a)-1]
    ans +=x
ans +=int_str[int(x26_list[-1])]
ans_list =list(ans)

print(ans)
Problem p02659 (python)

Fixed submission:
# 初期入力
from decimal import Decimal
import sys
input = sys.stdin.readline
A,B = (str(x) for x in input().split())
a =Decimal(A)
b =Decimal(B)
ans =int(a *b)
print(ans)

Buggy submission (verdict: Runtime Error):
# 初期入力
import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A_np =np.array(A,dtype=np.int64)
ans =np.prod(A_np)
if 0 in A:
    print(0)
elif 0 < ans <=10**18:
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
# 初期入力
from decimal import Decimal
import sys
input = sys.stdin.readline
A,B = (str(x) for x in input().split())
a =Decimal(A)
b =Decimal(B)
ans =int(A *B)
print(ans)
Problem p02689 (python)

Fixed submission:
# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(x) for x in input().split())
H = [-1]+list(map(int, input().split()))

#observ_H =[i for i in range(1,N+1)]
observ_H ={}
connection ={i:set() for i in range(1,N+1)}

#つながり
for i in range(1,M+1):
    a,b = (int(x) for x in input().split())
    connection[a].add(b)
    connection[b].add(a)
    
#展望台の高さ、辞書
for i in range(1,N+1):
    observ_H[i] = H[i]
#observ_H.sort(key=lambda x:x[1],reverse=True)
observ_good ={}
hantei=1
for num,connect in connection.items():
    hantei =1
    for saki in connect:
        if observ_H[num] > observ_H[saki]:
            hantei *=1
        else:
            hantei=0
    if hantei==1:
        observ_good[num] ="good"
print(len(observ_good))

Buggy submission (verdict: Runtime Error):
# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(x) for x in input().split())
H = [-1]+list(map(int, input().split()))

#observ_H =[i for i in range(1,N+1)]
observ_H ={}
connction ={i:set() for i in range(1,N+1)}

#つながり
for i in range(1,M+1):
    a,b = (int(x) for x in input().split())
    connction[a].add(b)
    connction[b].add(a)
    
#展望台の高さ、辞書
for i in range(1,N+1):
    observ_H[i] = H[i]
#observ_H.sort(key=lambda x:x[1],reverse=True)
observ_good ={i:"bad"}
hantei="bad"
for num,connect in connction.items():
    hantei ="bad"
    for saki in connect:
        if observ_H[num] > observ_H[saki]:
            hantei ="good"
    if hantei=="good":
        observ_good[num] ="good"
print(len(i))
Problem p02726 (python)

Fixed submission:
N, X, Y = map(int, input().split())
D = [None] + [0] * (N - 1) #最低距離が1からNまでの個数を表示するリストを作る(YZT さんのコメント)

#各最低距離の個数カウント
for i in range(1, N):                           # i 出発
    for j in range(i + 1, N + 1):               # j 到着
        d = min(abs(j - i),                     # 近道をしない
                abs(X - i) + 1 + abs(j - Y),    # 「+1」は近道の距離、X < Y　
                abs(Y - i) + 1 + abs(j - X))    # 「+1」は近道の距離、Y < X　
        D[d] += 1                               # 距離ｄごとにカウント
        # print(abs(j-i),abs(X-i)+1 , abs(j-Y) , abs(Y - i) + 1,abs(j - X)," ",d,D," ",i,j)
    
for d in D[1:]: #最低距離は１だから距離０は使わないが、添え字＝距離とすることでわかりやすい
    print(d)

Buggy submission (verdict: Runtime Error):
#６回目、2020-0612
#2重ループ + numpy
#場合分けを近道と通常のみ（絶対値を使う）
import numpy as np 
#初期入力
N, x, y = map(int, input().split())
dist =np.zeros((N,N),dtype=np.int64)

#iからjの距離
for i in range(1,N):
    j =np.arange(i+1,N+1)
    normal =j -i
    short  =abs(x-i) +1 +abs(j-y)
    dist[i-1,i:] =np.minimum(normal,short)
    #print(d)
#距離別の数
a,ans =np.unique(dist,return_counts=True)      
ans =np.delete(ans,0) #距離０を削除
count_zero =N-1-len(ans) 
ans =np.append(ans,np.zeros(count_zero))#存在しない遠い距離は０

#出力
for i in ans:
    print(int(i))

Buggy submission (verdict: Runtime Error):
#６回目、2020-0612
#2重ループ + numpy
#場合分けを近道と通常のみ（絶対値を使う）
import numpy as np 
#初期入力
N, x, y = map(int, input().split())
dist =np.zeros((N,N),dtype=int)

#iからjの距離
for i in range(1,N):
    j =np.arange(i+1,N+1)
    normal =j -i
    short  =abs(x-i) +1 +abs(j-y)
    dist[i-1,i:] =np.minimum(normal,short)
    #print(d)
#距離別の数
a,ans =np.unique(dist,return_counts=True)      
ans =np.delete(ans,0) #距離０を削除
count_zero =N-1-len(ans) 
ans =np.append(ans,np.zeros(count_zero))#存在しない遠い距離は０

#出力
for i in ans:
    print(int(i))
Problem p02753 (python)

Fixed submission:
# 初期入力
S = input()

# 3つとも同じ会社だったらバスはない
s_list =[i for i in S]
if s_list[0] == s_list[1] and s_list[1] ==s_list[2]:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
A,B =map(int,input().split())
 
# 元の価格ｘ,8%  y、１０％
x = A/0.08
x_1 =(A+1)/0.08
y = B/0.1
y_1 = (B+1)/0.1

x_2 = {i for i in range(int(x),int(x_1) +1) }
y_2 = {i for i in range(int(y),int(y_1) +1) }
moto_nedan = x_2 & y_2
if len(moto_nedan) == 0:
    print("-1")
else:
    print(min(moto_nedan))
print(x_2)
print(y_2)
print(38*0.08)

Buggy submission (verdict: Runtime Error):
# 初期入力
N,A,B = (int(x) for x in input().split(" "))

# 赤と青を並べる
retu = ""
for j in range(10100):
    for i in range(A):
        retu += "b"
    for i in range(B):
        retu += "r"

b_num = retu[:N].count("b")
print(b_num)
Problem p02759 (python)

Fixed submission:
N = int(input())
import math
maisu = math.ceil(N/2)
print(maisu)

Buggy submission (verdict: Runtime Error):

from collections import defaultdict
N,M = (int(x) for x in input().split())
keta_num_str = [ (input().split()) for i in range(M) ]

#各桁をキー、数字を値の辞書にする
suuji = ""
num_str_dic = defaultdict(set)
kotae_dic ={ str(i):"0" for i in range(1,N + 1) } #　各桁に初期値”０”を入力
for i in keta_num_str:   
    num_str_dic[i[0]].add(i[1])


for i,v in num_str_dic.items():
    if 1 < len(v) : # 一つの桁に複数の値がある時はエラー
        kotae_dic ={}
        break

    else:
        kotae_dic[i] = list(v)

# 表示
import math
if kotae_dic == {}: # 一つの桁に複数の値の時        
    print(-1)
else:
    kotae_dic_sorted = sorted(kotae_dic.items(),key=lambda x:int(x[0]))
    kotae_str = "".join( [i[1][0] for i in kotae_dic_sorted ] ) # 辞書の値を連結
    kotae_int =int(kotae_str)
    if kotae_int == 0 and 1< N: # "00"などはエラー、"0"はOK
        print(-1)
    elif kotae_int == 0 and N == 1:
        print("0")
    elif 10**(N-1) > kotae_int or kotae_int >= 10** N: # 桁があってない＝一番左の桁が”０”はエラー
        print(-1)
    else:
        print(kotae_int)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N,M = (int(x) for x in input().split())
keta_num_str = [ (input().split()) for i in range(M) ]

#各桁をキー、数字を値の辞書にする
suuji = ""
num_str_dic = defaultdict(set)
kotae_dic ={ str(i):"0" for i in range(1,N + 1) } #　各桁に初期値”０”を入力
for i in keta_num_str:   
    num_str_dic[i[0]].add(i[1])


for i,v in num_str_dic.items():
    if 1 < len(v) : # 一つの桁に複数の値がある時はエラー
        kotae_dic ={}
        break

    else:
        kotae_dic[i] = list(v)

# 表示
if kotae_dic == {}: # 一つの桁に複数の値の時        
    print(-1)
else:
    kotae_dic_sorted = sorted(kotae_dic.items(),key=lambda x:int(x[0]))
    kotae_str = "".join( [i[1][0] for i in kotae_dic_sorted ] ) # 辞書の値を連結
    kotae_int =int(kotae_str)
    if kotae_int == 0: # "00"などはエラー
        print(-1)
    else:
        print(kotae_int)
Problem p02771 (python)

Fixed submission:
# 初期入力
a,b,c = (int(x) for x in input().split(" "))

#
if a == b == c:
    print("No")
elif a == b or b ==c or a == c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# 初期入力
N = int(input())
word = [ input() for i in range(N) ]

# 単語をキーに数を数えて辞書
from collections import Counter
kazu_word = Counter(word)

#一番多い単語を抜き出す
kazu_word_a = max(kazu_word.values()) #　内包表記の中で毎回MAXを計算するより出したほうが１回で済む
kazu_word_max =[i for i,v in kazu_word.items() if v == kazu_word_a ]
kazu_word_max_sorted = sorted(kazu_word_max)
"""
print(kazu_word)
print(kazu_word_max)
"""
#print(*kazu_word_max_sorted,sep="\n")
print("\n".join(kazu_word_max_sorted)) #sortedをやめて sortにした
Problem p02773 (python)

Fixed submission:
# 初期入力
N = int(input())
word = [ input() for i in range(N) ]

# 単語をキーに数を数えて辞書
from collections import Counter
kazu_word = Counter(word)

#一番多い単語を抜き出す
kazu_word_a = max(kazu_word.values()) #　内包表記の中で毎回MAXを計算するより出したほうが１回で済む
kazu_word_max =[i for i,v in kazu_word.items() if v == kazu_word_a ]
kazu_word_max_sorted = sorted(kazu_word_max)
"""
print(kazu_word)
print(kazu_word_max)
"""
print(*kazu_word_max_sorted,sep="\n")

Buggy submission (verdict: Runtime Error):
# 初期入力
N = int(input())
word = [ input() for i in range(N) ]

# 単語をキーに数を数えて辞書
from collections import Counter
kazu_word = Counter(word)

#一番多い単語を抜き出す
kazu_word_a = max(kazu_word.values()) #　内包表記の中で毎回MAXを計算するより出したほうが１回で済む
kazu_word_max =[i for i,v in kazu_word.items() if v == kazu_word_a )]
# kazu_word_max_sorted = sorted(kazu_word_max)
"""
print(kazu_word)
print(kazu_word_max)
"""
#print(*kazu_word_max_sorted,sep="\n")
print("\n".join(kazu_word_max.sort())) #sortedをやめて sortにした
Problem p02785 (python)

Fixed submission:
# 初期入力
N,K = (int(x) for x in input().split(" "))
H = list(map(int, input().split()))
tuujou_attack = 1

# N種類のモンスター、K回の必殺技、モンスターは　H　の体力
# 体力の多いモンスターから必殺技で倒す。必殺技が使えなくなったら通常攻撃
nokori_kaisu = 0
H_sorted = sorted(H)
if N <= K:
    nokori_kaisu = 0
else:
    nokori_hissatuwaza = N -K
    del H_sorted[nokori_hissatuwaza:]
    nokori_kaisu = sum( H_sorted ) # 体力少ないほうから　N-K　まで、通常攻撃「１」

print(nokori_kaisu)

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

import math
def d(N): #桁を求める
    return int(math.log10(N)) +1

#2分探索法
N_min =0
N_max =10**9
while 1<(N_max - N_min):
    N=(N_max + N_min)//2
    if A*N +B*d(N) >X:
        N_max = N
    else:
        N_min =N
if A * N_max + B * d(N_max) <X:
    print(N_max)
else:
    print(N_min)
Problem p02820 (python)

Fixed submission:
# 初期入力
N,K = (int(x) for x in input().split(" "))
R,S,P = (int(x) for x in input().split(" "))
ten_janken_dic ={"R":R,"S":S,"P":P} #じゃんけんの役ごとの点を辞書
ten_janken_sort =sorted(ten_janken_dic.items(),key=lambda x: x[1])
T =input()

#合計点と高橋君が出す手を同時進行
sum_janken = 0 # 合計点
takahasi = [] # 高橋君が出す手,K回前の手も出せる＝すべて勝つとした場合
for i in T:
    if i =="r":
        sum_janken += P #6
        takahasi.append("P")
    elif i == "s":
        sum_janken += R #8
        takahasi.append("R")

    elif i == "p":
        sum_janken += S #7
        takahasi.append("S")
takahasi_mae =[]
from copy import deepcopy
takahasi_mae = deepcopy(takahasi)

# K回前の手は出せない        
for i,v in enumerate(takahasi[K:]):
    if v ==takahasi[(i+K)-K]:
        sum_janken -= ten_janken_dic[v]
        x = ["R","S","P"]
        if takahasi[(i+K)-K] in x:
            x.remove( takahasi[(i+K)-K] ) #K回前の手を消す
        if i+K+K < len(takahasi):    
            if takahasi[i+K+K] in x:
                x.remove( takahasi[i+K+K] ) #K回後の手を消す
        if len(x) ==1:
            takahasi[i+K] =x[0]
        elif x[0]==ten_janken_sort[2][0] or x[1] ==ten_janken_sort[2][0] : #高い点を選ぶ
            takahasi[i+K] =ten_janken_sort[2][0]
        else:
            takahasi[i+K] =ten_janken_sort[1][0] #2番目に高い点のキー（点順でソートしてある）
print(sum_janken)

Buggy submission (verdict: Runtime Error):
# 初期入力
N,K = (int(x) for x in input().split(" "))
R,S,P = (int(x) for x in input().split(" "))
ten_janken_dic ={"R":R,"S":S,"P":P} #じゃんけんの役ごとの点を辞書
ten_janken_sort =sorted(ten_janken_dic.items(),key=lambda x: x[1])
T =input()

#合計点と高橋君が出す手を同時進行
sum_janken = 0 # 合計点
takahasi = [] # 高橋君が出す手,K回前の手も出せる＝すべて勝つとした場合
for i in T:
    if i =="r":
        sum_janken += P #6
        takahasi.append("P")
    elif i == "s":
        sum_janken += R #8
        takahasi.append("R")

    elif i == "p":
        sum_janken += S #7
        takahasi.append("S")
takahasi_mae =[]
from copy import deepcopy
takahasi_mae = deepcopy(takahasi)

# K回前の手は出せない        
for i,v in enumerate(takahasi[K:]):
    if v ==takahasi[(i+K)-K]:
        sum_janken -= ten_janken_dic[v]
        x = ["R","S","P"]
        if takahasi[(i+K)-K] in x:
            x.remove( takahasi[(i+K)-K] ) #K回前の手を消す
        if i+K+K <=len(takahasi):    
            if takahasi[i+K+K] in x:
                x.remove( takahasi[i+K+K] ) #K回後の手を消す
        if len(x) ==1:
            takahasi[i+K] =x[0]
        elif x[0]==ten_janken_sort[2][0] or x[1] ==ten_janken_sort[2][0] : #高い点を選ぶ
            takahasi[i+K] =ten_janken_sort[2][0]
        else:
            takahasi[i+K] =ten_janken_sort[1][0] #2番目に高い点のキー（点順でソートしてある）
print(sum_janken)
Problem p02832 (python)

Fixed submission:
#初期入力
import sys
N = int(input())
A=[int(i) for i in input().split()]
#


if 1 not in A:
    print(-1)
    exit
else:
    i=1 #探す数字
    brick_remain =set() #「1」は入っていること上記で確かめた
    for a in A:
        if a ==i:
            brick_remain.add(a)
            i +=1
    brick_destroy = N - len(brick_remain)       
    print(brick_destroy)

Buggy submission (verdict: Runtime Error):
     if i_index >= N-1:
            break
        #print(brick_destroy)
        #print(i,end=" ")
        A_now = A[i_index :] #見つけた字の右側のみ見る

brick_destroy = N - len(brick_remain)
if brick_remain==[]:
    print(-1)
else:
    print(brick_destroy)
Problem p02859 (python)

Fixed submission:
# 初期入力
r = int(input())
#mennseki_r =3.14*r*r
#mennseki_1 =3.14*1*1

#kotae =int(mennseki_r / mennseki_1)
kotae=r*r
print(kotae)

Buggy submission (verdict: Runtime Error):
# 初期入力
r = int(input())
#mennseki_r =3.14*r*r
#mennseki_1 =3.14*1*1

#kotae =int(mennseki_r / mennseki_1)
print(kotae=r*r)
Problem p02862 (python)

Fixed submission:
def cmb(n, r, p): # 組み合わせの総数 109+7 で割ったあまりを求める Satoooh Blog 2020/02/27 4分 
    N = 10 ** 6  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用
    
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p



# 初期入力
X,Y = (int(x) for x in input().split())

# X+Y が3の倍数、かつY=2XとY=X/2の間にある必要あり
kotae =0
if (X+Y) %3 !=0 or X*2< Y or Y*2 <X :
    a =b =0
else: #a(1,2) + b(2,1)=(X,Y)  の連立法手式を解く　X,Yは入力値
    b=(2*X -Y)//3
    a=X-2*b

    # (1,2)と(2,1)の数がわかったので、その組み合わせ
    if b<a:
        a,b = b,a
    #kotae = kumiawase_num(a+b,a) 
    mod =10**9 +7
    kotae = cmb(a+b,a,mod ) 
    
print(kotae)

Buggy submission (verdict: Runtime Error):
from math import factorial
def kumiawase_num(n, r): # 組み合わせ n「C」r
    if  n<r or n==0:
        return 0
    return factorial(n) // (factorial(n - r) * factorial(r))

# 初期入力
X,Y = (int(x) for x in input().split())

#NUMPYで連立方程式を解く
from numpy.linalg import solve
left = [[2,1],
        [1,2]]
right = [X,Y]
x,y =solve(left, right)
if x == int(x) and y ==int(y):
    a,b =int(x),int(y)
    if b<a:
        a,b=b,a
else:
    a=b=0
# (1,2)と(2,1)の数がわかったので、その組み合わせ
kotae = kumiawase_num(a+b,a) 
syou,amari =divmod(kotae,10**9 +7)
print(amari)
Problem p02912 (python)

Fixed submission:
# 初期入力
N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))
A =list(map(lambda x:x*(-1),A))     #最大値を取り出すため―１を掛ける
import heapq  # heapqライブラリのimport
heapq.heapify(A)  #         リストを優先度付きキューへ
m=0
for i in range(M):
    a=heapq.heappop(A)  #       最大値の取り出し
    a //=-2             # 負の値を2で割り切り捨てると、絶対値が大きくなる。
    heapq.heappush(A, -a) #正の値で2で割り、戻すとき負にする
    #print(A)

A_sum =sum(A)
A_sum *=(-1)
print(A_sum)

Buggy submission (verdict: Runtime Error):
import numpy as np

# 初期入力
N,M = (int(x) for x in input().split())
A = np.array( list(map(int, input().split())) )

#
a_waribiki = np.zeros((N,M+1),dtype=np.int64)
a_waribiki[:,0] =A # 割引しない場合を代入

# 各商品を１からM回割引券使った場合の金額
for i in range(1,M+1): 
    a_waribiki[:,i] =a_waribiki[:,i-1] //2

# 各商品に何枚割引券使うか
from itertools import combinations
n_waribiki = [i for i in range(M+N-1)]
x_list_2 =[]
if N-1 ==0:
    x_list_2.append([M])
else:
    for t in combinations(n_waribiki, N-1):
        t_list = list(t)
        t_list.append(M+N-1)
        x_list=[]
        for i in range(1,len(t_list)):
            x= t_list[i] -t_list[i-1]-1
            x_list.append(x)
        x_list.append(t[0])
        x_list_2.append(x_list)
        #print(t_list)
        #print(t,end=" ")

#[割引券を何枚使うか」を利用し、金額計算
x_np = np.array(x_list_2)
kotae = []
for i in x_np:
    a_sum =0
    for j,v in enumerate(i):
        a_sum += a_waribiki[j,v]
    kotae.append(a_sum)
print(min(kotae))

Buggy submission (verdict: Runtime Error):
import numpy as np

# 初期入力
N,M = (int(x) for x in input().split())
A = np.array( list(map(int, input().split())) )

#
a_waribiki = np.zeros((N,M+1),dtype=np.int64)
a_waribiki[:,0] =A # 割引しない場合を代入

# 各商品を１からM回割引券使った場合の金額
for i in range(1,M+1): 
    a_waribiki[:,i] =a_waribiki[:,i-1] //2

# 各商品に何枚割引券使うか
from itertools import combinations
n_waribiki = [i for i in range(M+N-1)]
x_list_2 =[]
for t in combinations(n_waribiki, N-1):
    t_list = list(t)
    t_list.append(M+N-1)
    x_list=[]
    for i in range(1,len(t_list)):
        x= t_list[i] -t_list[i-1]-1
        x_list.append(x)
    x_list.append(t[0])
    x_list_2.append(x_list)
    #print(t_list)
    #print(t,end=" ")

#[割引券を何枚使うか」を利用し、金額計算
x_np = np.array(x_list_2)
kotae = []
for i in x_np:
    a_sum =0
    for j,v in enumerate(i):
        a_sum += a_waribiki[j,v]
    kotae.append(a_sum)
print(min(kotae))
Problem p02984 (python)

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

mt_rain =[0]*N
mt_all =sum(A)
dam_even = sum(A[1::2]) #偶数番目のダムの増えた水
mt_rain[0] = mt_all - 2*dam_even #1番目の山の降水量

#2番目の山以降
for i in range(1,N):
    mt_rain[i] =2*A[i-1] -mt_rain[i-1]
print(*mt_rain)

Buggy submission (verdict: Runtime Error):
# 初期入力
import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
A = [[int(i)] for i in input().split()]
A_np =np.array(A)

#numpyで連立方程式を解く
mat_1 =np.zeros((N,N),dtype=int)
for i in range(N):
    mat_1[i,i]=1
    mat_1[i,(i+1)%N]=1 #余りをとらないと、i=N-1の時エラーになる
x =np.linalg.solve(mat_1,A_np)*2

#表示
for i in x:
    print(int(i[0]),end=" ")
Problem p03107 (python)

Fixed submission:
#計算でもとまるのか・・・
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
#*S, = input() 
S =input().strip()
c1 =S.count("1")
c0 =S.count("0")
print(min(c0,c1)*2)

Buggy submission (verdict: Runtime Error):
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
#S =input().strip()
*S, = input() 
count =0
flag =1
while len(S) >=2 and flag==1:
    flag =0
    l =len(S)
    for i in range(l -1):
        if S[i:i+2] ==["1","0"] or S[i:i+2] ==["0","1"]:
            #print(S[i:i+2])
            del S[i:i+2]
            print(S,end=" ")
            count +=2
            flag =1
            #break
    #print()
print(count)