Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np 
N = int(input())
A = list(map(int, input().split()))
A =np.array(A,dtype=int)
id =np.arange(1,N+1)

count =0
for i in range(1,N+1):
    x2_big = id[i+1:] -A[i+1:] #各人のidと身長の差
    x1 = i +A[i-1] #iの身長とidの和
    count += np.count_nonzero(x1 ==x2_big)     
    
    """x2_small = id[:i] +A[:i] #各人のidと身長の差
    x1 = i -A[i-1] #iの身長とidの和
    count += np.count_nonzero(x1 ==x2_small)     
    """
print(count)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
l =[]
r =[]
for id,h in enumerate(A,start=1):
    r.append(id -h)
    l.append(id +h)

r_cou =Counter(r)
l_cou =Counter(l)
ans =[]
for i in l_cou.keys():
    ans.append(l_cou[i] *r_cou.get(i,0))

print(sum(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np 
N = int(input())
A = list(map(int, input().split()))
A =np.array(A,dtype=int)
id =np.arange(1,N+1)

count =0
for i in range(1,N+1):
    x2_big = id[i+1:] -A[i+1:] #各人のidと身長の差
    x1 = i +A[i-1] #iの身長とidの和
    count += np.count_nonzero(x1 ==x2_big)     
    
    x2_small = id[:i] +A[:i] #各人のidと身長の差
    x1 = i -A[i-1] #iの身長とidの和
    count += np.count_nonzero(x1 ==x2_small)     
print(count//2)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
l =[]
r =[]
for id,h in enumerate(A,start=1):
    r.append(id -h)
    l.append(id +h)

r_cou =Counter(r)
l_cou =Counter(l)
ans =[]
for i in l_cou.keys():
    ans.append(l_cou[i] *r_cou.get(i,0))

print(sum(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np 
N = int(input())
A = list(map(int, input().split()))
A =np.array(A,dtype=int)
id =np.arange(1,N+1)

count =0
for i in range(1,N+1):
    x1 = A +A[i-1]
    x2 = abs(id -i)
    count += np.count_nonzero(x1 -x2 ==0)     
print(count//2)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
l =[]
r =[]
for id,h in enumerate(A,start=1):
    r.append(id -h)
    l.append(id +h)

r_cou =Counter(r)
l_cou =Counter(l)
ans =[]
for i in l_cou.keys():
    ans.append(l_cou[i] *r_cou.get(i,0))

print(sum(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations_with_replacement
import numpy as np 
N,M,Q = (int(x) for x in input().split())
abcd =np.zeros((Q,4),dtype=int)
for i in range(Q):
    abcd[i] = list(map(int, input().split()))
abcd[:,0] -=1 #添え字にするから、-1
abcd[:,1] -=1 #添え字にするから、-1

#リストAを要素数N,最大値Mで全列挙
ans =[]
#for i in range(1,N+1):
for a in combinations_with_replacement (range(1,M+1),N):
    co_np =[]
    for q in range(Q):
        A =list(a)
        #print(A,end=" ")
        if A[abcd[q,1] ] -A[abcd[q,0]] ==abcd[q,2]:
            co_np.append(abcd[q,3])
    ans.append(sum(co_np))
print(max(ans))

Fixed submission:
#数列Aの取りうるものをcombinations_with_replacementで作って、全探索
#データ入力
from itertools import combinations_with_replacement
N,M,Q = (int(x) for x in input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

#
all_A =[i for i in range(1,M+1)] #数列Aの取りうる値
A =[0]*N
ans =[]
for A in combinations_with_replacement(all_A,N):
    count =0
    for i in range(Q):
        ai,bi,ci,di =abcd[i]
        if A[bi-1] -A[ai-1] ==ci:
            count += di
    ans.append(count)
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
# 初期入力
K =int(input())

# 最小約数(mathは3.5以降) 
from functools import reduce
import math #(2020-0405  fractions→math)
def lcm_base(x, y):
    return  math.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm_list(numbers):
    return reduce(lcm_base, numbers)

#

saisyou_koyakusu =[]
"""
for i in range(1,K+1):
    for j in range(1,K+1):
        for l in range(1,K+1):
            saisyou_koyakusu.append(lcm(i,j,l))

"""            #print(i,j,l)

from itertools import product
# ["a", "b", "c"] の並べ替えをすべて列挙する
a= [i for i in range(1,K+1)]
for t in product(a,repeat=3):
    #print(t)
    saisyou_koyakusu.append(lcm_list(list(t)))
    
print(sum(saisyou_koyakusu))

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

# 最大公約数(mathは3.5以降) 
from functools import reduce
import math #(2020-0405  fractions→math)
def lcm_base(x, y):
    return  math.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm_list(numbers):
    return reduce(lcm_base, numbers)
def lcm_fukusu(*numbers):
    return reduce(lcm_base, numbers)


saisyou_koyakusu =[]

for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            if i ==j and j==k:
                saisyou_koyakusu.append(lcm_fukusu(i,j,k))
            elif i==j or j==k:
                saisyou_koyakusu.append( (lcm_fukusu(i,j,k))*3 )
            else:
                saisyou_koyakusu.append( (lcm_fukusu(i,j,k)) *6)

            #print(i,j,k)   
print(sum(saisyou_koyakusu))
Buggy python submission (verdict: Runtime Error):
# 初期入力
N,K = (int(x) for x in input().split(" "))

#
zeroika = N//K
N1 =abs(N-K*zeroika) #N1がマイナスになって初めてABS、そこまではKの倍数単調に減る
    N =N1
    N1 =abs(N-K)
    #print(N1,end=" ")
print(N)

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

#
zeroika = 0
if K <N:
    zeroika = N//K
else:
    zeroika = 1
N1 =abs(N-K*zeroika) #N1がマイナスになって初めてABS、そこまではKの倍数単調に減る
while N1<N:
    N =N1
    N1 =abs(N-K)
    #print(N1,end=" ")
print(N)
Buggy python submission (verdict: Runtime Error):
from collections import deque 
#from copy import copy
#初期入力
X,Y,A,B,C = (int(x) for x in input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))


# ソート⇒無色と比較
p.sort()
q.sort()
r.sort()

p_dq =deque(p[A-X:])
q_dq =deque(q[B-Y:])
ans_sum =sum(p[A-X:]) + sum(q[B-Y:])
p_change =p_dq.popleft()
q_change =q_dq.popleft()
count_p =0
count_q =0
for i in r:
    if p_change < q_change:
        if i > p_change and count_p < X:
            count_p +=1
            ans_sum = ans_sum -p_change +i
            p_change =p_dq.popleft()

    elif p_change > q_change and count_q < Y:
        if i > q_change:
            count_q +=1
            ans_sum = ans_sum -q_change +i
            q_change =q_dq.popleft()
print(ans_sum)

Fixed submission:
#heapq p,qの最小値側にrの最大値入れていく。
import heapq 

#初期入力
X,Y,A,B,C = (int(x) for x in input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))


# ソート⇒無色と比較
p.sort()
q.sort()
r.sort(reverse=True)

ans_sum =sum(p[-X:]) + sum(q[-Y:])
p_hq = p[-X:]
q_hq = q[-Y:]
heapq.heapify(p_hq)
heapq.heapify(q_hq)
p_change =heapq.heappop(p_hq)
q_change =heapq.heappop(q_hq)
count_p =0
count_q =0
for i in r: #rは大きい順
    if p_change <= q_change and p_change < i:
        if  count_p < X:
            heapq.heappush(p_hq,i)
            count_p +=1
            ans_sum = ans_sum -p_change +i
            p_change =heapq.heappop(p_hq)
    elif p_change > q_change and q_change < i:
        if  count_q < Y:
            heapq.heappush(q_hq,i)
            count_q +=1
            ans_sum = ans_sum -q_change +i
            q_change =heapq.heappop(q_hq)
print(ans_sum)
Buggy python 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)


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 python 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)

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 python submission (verdict: Time Limit Exceeded):
# 初期入力
N,A,B = (int(x) for x in input().split(" "))

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

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

Fixed submission:
# 初期入力
N,A,B = map(int, input().split(" "))

# 青A個と赤Bを並べると、A+Bの組み合わせが何個あるか
kanz = N//(A+B) *A

# 余りを考える
saigo = min(N%(A+B),A)
print(kanz + saigo)
Buggy python 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) if i<=100)}
y_2 = {i for i in range(int(y),int(y_1) if i<=100)}
moto_nedan = x_2 & y_2
if len(moto_nedan) == 0:
    print("-1")
else:
    print(min(moto_nedan))

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

x_2 = {i for i in range(int(x),int(x_1) ) }
y_2 = {i for i in range(int(y),int(y_1) ) }
moto_nedan = x_2 & y_2
if len(moto_nedan) == 0:
    print("-1")
else:
    print(min(moto_nedan))
Buggy python 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)

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

Buggy python 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)

Fixed submission:
N = int(input())
import math
maisu = math.ceil(N/2)
print(maisu)
Buggy python 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にした

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 python 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)

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 python submission (verdict: Time Limit Exceeded):
# 初期入力
N = int(input())
P = list(map(int, input().split()))

#　右から１つ目と２つ目だけ比較し分岐
count =1 # 一つ目（添え字０）は必ずOK
for i in range(1,N):
    if P[i-1] < P[i]: # 増えていたら×
        #print(P[i],P[:i+1])
        continue
    elif P[i] ==min(P[:i+1]): # 減っていてかつMinならOK
        #print(P[i],P[:i+1])
        count +=1
print(count)

Fixed submission:
# 初期入力
N = int(input())
P = list(map(int, input().split()))

#　右から１つ目と２つ目だけ比較し分岐
count =1 # 一つ目（添え字０）は必ずOK
P_min = P[0]
for i in range(1,N):
    if P[i-1] < P[i]: # 増えていたら×
        #print(P[i],P[:i+1])
        continue
    elif P[i] <= P_min: # 今までのPで最小値ならOK
        #print(P[i],P[:i+1])
        count +=1
        P_min = P[i]
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
# 初期入力
N = int(input())
P = list(map(int, input().split()))

# 
count =0
for i in range(N):
    if P[i] ==min(P[:i+1]):
        #print(P[i],P[:i+1])
        count +=1
print(count)

Fixed submission:
# 初期入力
N = int(input())
P = list(map(int, input().split()))

#　右から１つ目と２つ目だけ比較し分岐
count =1 # 一つ目（添え字０）は必ずOK
P_min = P[0]
for i in range(1,N):
    if P[i-1] < P[i]: # 増えていたら×
        #print(P[i],P[:i+1])
        continue
    elif P[i] <= P_min: # 今までのPで最小値ならOK
        #print(P[i],P[:i+1])
        count +=1
        P_min = P[i]
print(count)
Buggy python submission (verdict: Runtime Error):
# 初期入力
N,M = (int(x) for x in input().split(" "))
S = []

#　問題種類をキー、ac,waを値の辞書
mondai_acwa ={i:list() for i in range(1,N+1) }
q_id =0
result =""
for i in range(M):
    q_id_str,result = (x for x in input().split())
    mondai_acwa[int(q_id_str)].append(result)

# ACのindexを検索（各問題）
count_wa=0
ac_index =[]
ac_sum=0
for i,v_wa in mondai_acwa.items():
    if 0 < len(v_wa):
        ac_i =v_wa.index("AC")
        ac_index.append(ac_i)
        ac_sum +=1
print(ac_sum,sum(ac_index))

Fixed submission:
# 初期入力
N,M = (int(x) for x in input().split(" "))
S = []

#　問題種類をキー、ac,waを値の辞書
mondai_acwa ={i:list() for i in range(1,N+1) }
q_id =0
result =""
for i in range(M):
    q_id_str,result = (x for x in input().split())
    mondai_acwa[int(q_id_str)].append(result)

# ACが初めてでた時のindex＝その問題のWAの数（各問題）
ac_sum=0
wa_sum=0

for i,v_wa in mondai_acwa.items():
    if 0 < len(v_wa):
        if "AC" in v_wa: #ACがないときはWAも数えない
            ac_i =v_wa.index("AC") 
            ac_sum +=1
            wa_sum += ac_i
print(ac_sum,wa_sum)
Buggy python submission (verdict: Runtime Error):
#素因数分解にsympy を使ってみる（素数の列挙）
import sympy
import math
def soinsu_bunkai(m,sosu_list):
    pf={}
    for i in sosu_list:
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:
        pf[m]=1
    return pf

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

#ai<10**9 だから
ai_root =int(math.sqrt(10**9)) +1
sosu_list = list(sympy.primerange(2, ai_root))


y ={}
for i in A:
    x_dic =soinsu_bunkai(i,sosu_list) 
    for k,v in x_dic.items():
        if k not in y:
            y[k] = v
            if y[k] < v:
                y[k] = v
#半＿最小公倍数
han_saisyo_kobaisu =1
for i,v in y.items():
    han_saisyo_kobaisu *= i*v
han_saisyo_kobaisu //=2

#半公倍数の数( Mの中に半最小公倍数の数→偶数を削除のためさらに2で割る)
han_kobaisu_num =( M // han_saisyo_kobaisu +1 )//2
print(han_kobaisu_num)

Fixed submission:

# 最小公倍数(mathは3.5以降) fractions
from functools import reduce
import fractions #(2020-0405  fractions→math)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))
lcm         =lcm_list(A)
han_lcm     =lcm//2
han_lcm_num =M//han_lcm
han_lcm_num =(han_lcm_num +1)//2 #偶数を除く

#半公倍数がA自身の中にある時は✖
if han_lcm in A:
    han_lcm_num =0
#半公倍数がaiで割り切れるときは✖
for a in A:
    if han_lcm % a ==0:
        han_lcm_num =0
print(han_lcm_num)
Buggy python 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)

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 python submission (verdict: Runtime Error):
# 初期入力
N = int(input())
A = list(map(int, input().split()))


x = [  A[i]^A[j] for i in range(N-1) for j in range(i+1,N) ]
kotae =sum(x) % (10**9 +7)
print(kotae)

Fixed submission:
from itertools import product
#初期入力
N = int(input())
testimony ={j:[-1 for i in range(N)] for j in range(1,N+1)}
A=[]
for i in range(1,N+1):
    a = int(input())
    A.append(a)
    for j in range(a):
        x,y = list(map(int, input().split()))
        testimony[i][x-1] =y

#各人が正直か不親切かを仮定する。仮定(Assumption)が矛盾するか、判定を全探索

assumption_correct =[]
for assumption in product([1,0], repeat=N):
    count_2=0
    for i in range(N):      #証言する人        
        if assumption[i] ==1:
            count =0 
            for j in range(N):  #証言受けた人 
                         
                if testimony[i+1][j] ==assumption[j]:
                    count +=1
            if count == A[i]:
                count_2 +=1
    if count_2 ==sum(assumption):
        assumption_correct.append(sum(assumption))
print(max(assumption_correct))
Buggy python submission (verdict: Time Limit Exceeded):
# 初期入力
N = int(input())
A = list(map(int, input().split()))


x = [ A[i]^A[j] for i in range(N-1) for j in range(i+1,N) ]
kotae =sum(x) % (10**9 +7)
print(kotae)

Fixed submission:
import numpy as np
mod=10**9+7
N=int(input())
A=np.array(list(map(int, input().split())))
ans=0
for i in range(60):
  b=np.count_nonzero(A>>i&1)
  ans+=(2**i)*b*(N-b)
  ans%=mod
  
print(ans)
Buggy python 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)

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 python submission (verdict: Time Limit Exceeded):
# 初期入力
N=int(input())
S = [list(map(int, input().split())) for i in range(N)]

#町のいく順番　順列
from itertools import permutations
import math
from statistics import mean
junban=[]
for t in permutations(range(N)):
    if t[::-1] not in junban:
        junban.append(t)
#junban =[ t for t in permutations(range(N)) ]
#junban =junban_2[:len(junban_2)//2] # 逆順は考えなくていい
j_len =len(junban) # 順番の要素数
x =[] #距離
x_sum =[]

def kyori(a,b): 
    return math.sqrt(pow( S[a][0]-S[b][0],2) + pow( S[a][1] - S[b][1],2) )

# 各点の距離　　組み合わせ
from itertools import combinations
kumiawase = [t for t in combinations(range(N), 2)]
kyori_all ={i:kyori(i[0],i[1]) for i in kumiawase}

#
for i in junban:
    for ji,jv in enumerate(i[:-1]):
        if i[ji]<i[ji+1]:
            x.append(kyori_all[ i[ji],i[ji+1] ] )
        if i[ji+1]<i[ji]:
            x.append(kyori_all[ i[ji+1],i[ji] ] )

    y =sum(x)    
    x_sum.append(y)
    x.clear()
kotae =mean(x_sum) 

print(kotae)

Fixed submission:
# 初期入力
N=int(input())
S = [list(map(int, input().split())) for i in range(N)]

#町のいく順番　順列
from itertools import permutations
import math
from statistics import mean
junban =[ t for t in permutations(range(N)) ]
#junban =junban_2[:len(junban_2)//2] # 逆順は考えなくていい
j_len =len(junban) # 順番の要素数
x =[] #距離
x_sum =[]
def kyori(a,b): 
    return math.sqrt(pow( S[a][0]-S[b][0],2) + pow( S[a][1] - S[b][1],2) )

# 各点の距離　　組み合わせ
from itertools import combinations
kumiawase = [t for t in combinations(range(N), 2)]
kyori_all ={i:kyori(i[0],i[1]) for i in kumiawase}

#
for i in junban:
    for ji,jv in enumerate(i[:-1]):
        if i[ji]<i[ji+1]:
            x.append(kyori_all[ i[ji],i[ji+1] ] )
        if i[ji+1]<i[ji]:
            x.append(kyori_all[ i[ji+1],i[ji] ] )

    y =sum(x)    
    x_sum.append(y)
    x.clear()
kotae =mean(x_sum) 

print(kotae)