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

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
maxj=max(j_Aj)
i_Ai = [0] * (maxj+1)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=maxj:
        i_Ai[j + a[j - 1]] += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]
i_Ai = [0] * (max(j_Aj)+1)

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=max(j_Aj):
        i_Ai[j + a[j - 1]] += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]
i_Ai = [0] * (max(a)+n+1)

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    i_Ai[j + a[j - 1]] += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]
i_Ai = [0] * (10 ** 9 + 2 * 10 ** 5)

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    i_Ai[j + a[j - 1]] += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]


j_Aj=[0]
i_Ai=[0]*(10**9+2*10**5)

for j,aj in enumerate(a):
    j_Aj.append(j+1-aj)
ans=0
for j,j_aj in enumerate(j_Aj):
    if j==0:
        continue
    if j_aj>=2:
        ans+=i_Ai[j_aj]
    i_Ai[j+a[j-1]]+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]


j_Aj=[0]
i_Ai=[0]*(10**9+2*10**5)

for j,aj in enumerate(a):
    j_Aj.append(j+1-aj)
ans=0
for j,j_aj in enumerate(j_Aj):
    if j==0:
        continue
    if j_aj>=2:
        ans+=i_Ai[j_aj]
    i_Ai[j+a[j-1]]+=1
print(ans)
Problem p02720 (python)

Fixed submission:
k = int(input())

import queue

que = queue.Queue()

for i in range(1, 10):
    que.put(i)

for i in range(1, k + 1):
    ans = que.get()
    keta1 = ans % 10
    if keta1 == 0:
        append_list = [ans * 10, ans * 10 + 1]
    elif keta1 == 9:
        append_list = [ans * 10 + 8, ans * 10 + 9]
    else:
        append_list = [ans * 10 + keta1 - 1, ans * 10 + keta1, ans * 10 + keta1 + 1]
    for ite in append_list:
        que.put(ite)
print(ans)

Buggy submission (verdict: Runtime Error):
que = queue.Queue()

for i in range(1, 10):
    que.put(i)

for i in range(1, k + 1):
    ans = que.get()
    keta1 = ans % 10
    if keta1 == 0:
        append_list = [ans * 10, ans * 10 + 1]
    elif keta1 == 9:
        append_list = [ans * 10 + 8, ans * 10 + 9]
    else:
        append_list = [ans * 10 + keta1 - 1, ans * 10 + keta1, ans * 10 + keta1 + 1]
    for item in append_list:
        que.put(item)
print(ans)

Buggy submission (verdict: Runtime Error):
que = queue.Queue()

for i in range(1, 10):
    que.put(i)

for i in range(1, k + 1):
    ans = que.get()
    keta1 = ans % 10
    if keta1 == 0:
        append_list = [ans * 10, ans * 10 + 1]
    elif keta1 == 9:
        append_list = [ans * 10 + 8, ans * 10 + 9]
    else:
        append_list = [ans * 10 + keta1 - 1, ans * 10 + keta1, ans * 10 + keta1 + 1]
    for item in append_list:
        que.put(item)
print(ans)
Problem p02727 (python)

Fixed submission:
x,y,a,b,c=[int(i) for i in input().split()]

red_list=[int(i) for i in input().split()]
green_list=[int(i) for i in input().split()]
non_col_list=[int(i) for i in input().split()]

red_list.sort()
green_list.sort()
non_col_list.sort()

eat_red=[]
eat_green=[]
for i in range(x):
    eat_red.append(red_list.pop())
for i in range(y):
    eat_green.append(green_list.pop())


ans_list=eat_green+eat_red+non_col_list
ans_list.sort()
ans=0
for i in range(x+y):
    ans+=ans_list.pop()

print(ans)

Buggy submission (verdict: Runtime Error):
x,y,a,b,c=[int(i) for i in input().split()]

red_list=[int(i) for i in input().split()]
green_list=[int(i) for i in input().split()]
non_col_list=[int(i) for i in input().split()]

red_list.sort()
green_list.sort()
non_col_list.sort()

eat_red=[]
eat_green=[]
for i in range(x):
    eat_red.append(red_list.pop())
for i in range(y):
    eat_green.append(green_list.pop())


# eat_redにX個の赤いリンゴの美味しさ(降順)
# eat_greenにY個の緑のリンゴの美味しさ(降順)
# non_col_listにC個の無色のリンゴの美味しさ(昇順)


ans=0

def irekae(eat_list,non_col_list):
    if non_col_list==[]:
        return False
    global ans
    taishou=eat_list.pop()
    non_col=non_col_list.pop()
    if taishou<non_col:
        ans+=non_col
        return True
    else:
        eat_list.append(taishou)
        return False

while True:
    if eat_red[-1]<eat_green[-1]:
        if not irekae(eat_red,non_col_list):
            break

    else:
        if not irekae(eat_green,non_col_list):
            break

print(ans+sum(eat_green)+sum(eat_red))
Problem p02732 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

ball_count = [0] * (n + 1)

for i in a:
    ball_count[i] += 1
def nCr(i):
    if i<=1:
        return 0
    else:
        return i*(i-1)//2

def get_total(ball_count):
    ans = 0
    for i in ball_count:
        ans += nCr(i)
    return ans


total = get_total(ball_count)
for i in range(1, n + 1):
    num = ball_count[a[i - 1]]
    ans = total - nCr(num) + nCr(num-1)
    print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]

ball_count=[0]*(n+1)
count_count=[0]*(n+1)

for i in a:
    ball_count[i]+=1
for i in ball_count:
    count_count[i]+=1

def get_total(count_count):
    ans=0
    for i in range(2,n+1):
        ans+=(i*(i-1)//2)*count_count[i]
    return ans
total=get_total(count_count)
for i in range(1,n+1):
    num=ball_count[a[i-1]]
    if num==2:
        ans=total-(num*(num-1)//2)
    elif num>2:
        ans = total - (num * (num - 1) // 2)+((num-1) * (num - 2) // 2)
    print(ans)
Problem p02783 (python)

Fixed submission:
import math
h,a=[int(i) for i in input().split()]

print(math.ceil(h / a))

Buggy submission (verdict: Runtime Error):
h,n=[int(i) for i in input().split()]

waza=[None]

class Waza:
    def __init__(self,attack,power):
        self.attack=attack
        self.power=power

maxA=0
for i in range(n):
    a,b=[int(i) for i in input().split()]
    maxA=max(maxA,a)
    waza.append(Waza(a,b))


dp=[[10**9 for i in range(h+maxA)] for j in range(n+1)]

for i in range(n+1):
    for j in range(h+maxA):
        if j==0:
            dp[i][j]=0
        elif i==0:
            pass
        elif j-waza[i].attack>=0:
            dp[i][j]=min(dp[i-1][j],dp[i][j-waza[i].attack]+waza[i].power)

print(min(dp[-1][h:]))
Problem p02787 (python)

Fixed submission:
h, n = [int(i) for i in input().split()]

magics = [None]


class Magic:
    def __init__(self, attack, cost):
        self.attack = attack
        self.cost = cost


maxA = 0
for i in range(n):
    attack, cost = [int(i) for i in input().split()]
    maxA = max(maxA, attack)
    magics.append(Magic(attack, cost))

dp = [[10 ** 9 for i in range(h + maxA)] for j in range(n + 1)]

for i in range(n + 1):
    for j in range(h + maxA):
        if j == 0:
            dp[i][j] = 0
        elif i == 0:
            continue
        elif j - magics[i].attack >= 0:
            dp[i][j] = min(dp[i - 1][j], dp[i][j - magics[i].attack] + magics[i].cost)
        else:
            dp[i][j] = dp[i - 1][j]

print(min(dp[-1][h:]))

Buggy submission (verdict: Runtime Error):
h, n = [int(i) for i in input().split()]

magics = [None]


class Magic:
    def __init__(self, attack, cost):
        self.attack = attack
        self.cost = cost


maxA = 0
for i in range(n):
    attack, cost = [int(i) for i in input().split()]
    maxA = max(maxA, attack)
    magics.append(Magic(attack, cost))

dp = [[10 ** 9 for i in range(h + 1)] for j in range(n + 1)]

for i in range(n + 1):
    for j in range(h + 1):
        if j == 0:
            dp[i][j] = 0
        elif i == 0:
            continue
        elif j - magics[i].attack >= 0:
            dp[i][j] = min(dp[i - 1][j], dp[i][j - magics[i].attack] + magics[i].cost)

print(min(dp[-1][-1]))
Problem p02802 (python)

Fixed submission:
n,m=[int(i) for i in input().split()]
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC":
        if ac[p]==0:
            ac[p]=1
    else:
        if ac[p]==0:
            wa[p]+=1
    
for i in range(n):
    wa[i]=wa[i]*ac[i]
print(sum(ac),sum(wa))

Buggy submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC":
        if check[p]==0:
            check[p]=1
    else:
        if check[p]==0:
            wa[p]+=1
    
for i in range(n):
    wa[i]=wa[i]*ac[i]
print(sum(ac),sum(wa))

Buggy submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC":
        if check[p]==0:
            check[p]=1
    else:
        if check[p]==0:
            wa[p]+=1
    
for i in range(n):
    wa[i]=wa[i]*ac[i]
print(sum(check),wa)
Problem p02945 (python)

Fixed submission:
a,b=[int(i) for i in input().split()]
print(max(a+b,a-b,a*b))

Buggy submission (verdict: Runtime Error):
n=int(input())
wordlist=[input() for i in range(n)]
sortlist=[]
for i in range(n):
    a=list(wordlist[i])
    a.sort()
    a="".join(a)
    sortlist.append(a)
    
def kaijyo(n):
    ans=1
    for i in range(2,n+1):
        ans*=i
    return ans

count=0
sortlist.sort()


while sortlist:
    a=sortlist.pop()
    times=sortlist.count(a)+1
    for i in range(times-1):
        sortlist.pop()
    count+=kaijyo(times)*kaijyo(times-2)/2
    
print(int(count/2) )
Problem p02947 (python)

Fixed submission:
n=int(input())

#単語が全て入ったリストを作るO(n)
wordlist=[input() for i in range(n)]

#wordlistを一つ一つソートさせたものをsortlistとして作るO（n）
sortlist=[]
for i in range(n):
    a=list(wordlist[i])
    a.sort()
    sortlist.append(a)
    
count=0

#ソートリストをソートするO(nlogn)
sortlist.sort()

checkword=""
check=0

for i in range(n): #O(n)
    a=sortlist.pop()
    if checkword==a:
            check+=1
            count+=check
    else:
        check=0
        checkword=a
    
print(int(count) )

Buggy submission (verdict: Runtime Error):
n=int(input())
wordlist=[input() for i in range(n)]
sortlist=[]
for i in range(n):
    a=list(wordlist[i])
    a.sort()
    a="".join(a)
    sortlist.append(a)
    
def kaijyo(n):
    ans=1
    for i in range(1,n+1):
        ans*=i
    return ans

count=0
sortlist.sort()


while sortlist:
    a=sortlist.pop()
    times=sortlist.count(a)+1
    for i in range(times-1):
        sortlist.pop()
    count+=kaijyo(times)*kaijyo(times-2)/2
    
print(int(count) )

Buggy submission (verdict: Runtime Error):
n=int(input())
wordlist=[input() for i in range(n)]
sortlist=[]
for i in range(n):
    a=list(wordlist[i])
    a.sort()
    a="".join(a)
    sortlist.append(a)
    
def kaijyo(n):
    ans=1
    for i in range(2,n+1):
        ans*=i
    return ans

count=0
sortlist.sort()


while sortlist:
    a=sortlist.pop()
    times=sortlist.count(a)+1
    for i in range(times-1):
        sortlist.pop()
    count+=kaijyo(times)*kaijyo(times-2)/2
    
print(int(count/2) )

Buggy submission (verdict: Runtime Error):
n=int(input())
wordlist=[input() for i in range(n)]
sortlist=[]
for i in range(n):
    a=list(wordlist[i])
    a.sort()
    a="".join(a)
    sortlist.append(a)
    
def kaijyo(n):
    ans=1
    for i in range(2,n+1):
        ans*=i
    return ans

count=0
sortlist.sort()


while sortlist:
    a=sortlist.pop()
    times=sortlist.count(a)+1
    for i in range(times-1):
        sortlist.pop()
    count+=kaijyo(times)*kaijyo(times-2)/2
    
print(count/2)

Buggy submission (verdict: Runtime Error):
n=int(input())
wordlist=[input() for i in range(n)]
sortlist=[]
for i in range(n):
    a=list(wordlist[i])
    a.sort()
    a="".join(a)
    sortlist.append(a)
    
def kaijyo(n):
    ans=1
    for i in range(1,n+1):
        ans*=i
    return ans

count=0
sortlist.sort()


while sortlist:
    a=sortlist.pop()
    times=sortlist.count(a)+1
    for i in range(times-1):
        sortlist.pop()
    count+=int(kaijyo(times)*kaijyo(times-2)/2)
    
print(count)
Problem p02995 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)

from fractions import gcd
def lcm(a,b):
    return int(a*b/gcd(a,b))


def div(n,divn):
    #1からnまでの中で、divnで割り切れる数の数を示す
    return n//divn

def divor(n,div1,div2):
    #1からnまでの中で、div1,div2のどちらかで割り切れる数の数を示す
    return div(n,div1)+div(n,div2)-div(n,lcm(div1,div2))
def nondivor(n,div1,div2):
    #１からnまでの中で、div1,div2のどちらでも割り切れない数の数を示す
    return n-divor(n,div1,div2)


a,b,c,d=[int(i) for i in input().split()]


print(nondivor(b,c,d)-nondivor(a-1,c,d))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000)
import math
def lcm(a,b):
    return a*b//math.gcd(a,b)


def div(n,divn):
    #1からnまでの中で、divnで割り切れる数の数を示す
    return n//divn

def divor(n,div1,div2):
    #1からnまでの中で、div1,div2のどちらかで割り切れる数の数を示す
    return div(n,div1)+div(n,div2)-div(n,lcm(div1,div2))
def nondivor(n,div1,div2):
    #１からnまでの中で、div1,div2のどちらでも割り切れない数の数を示す
    return n-divor(n,div1,div2)


a,b,c,d=[int(i) for i in input().split()]


print(nondivor(b,c,d)-nondivor(a-1,c,d))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000)
import math
def lcm(a,b):
    return a*b//math.gcd(a,b)


def div(n,divn):
    #1からnまでの中で、divnで割り切れる数の数を示す
    return n//divn

def divor(n,div1,div2):
    #1からnまでの中で、div1,div2のどちらかで割り切れる数の数を示す
    return div(n,div1)+div(n,div2)-div(n,lcm(div1,div2))
def nondivor(n,div1,div2):
    #１からnまでの中で、div1,div2のどちらでも割り切れない数の数を示す
    return n-divor(n,div1,div2)


a,b,c,d=[int(i) for i in input().split()]


print(nondivor(b,c,d)-nondivor(a-1,c,d))

Buggy submission (verdict: Runtime Error):
import math
def lcm(a,b):
    return a*b//math.gcd(a,b)


def div(n,divn):
    #1からnまでの中で、divnで割り切れる数の数を示す
    return n//divn

def divor(n,div1,div2):
    #1からnまでの中で、div1,div2のどちらかで割り切れる数の数を示す
    return div(n,div1)+div(n,div2)-div(n,lcm(div1,div2))
def nondivor(n,div1,div2):
    #１からnまでの中で、div1,div2のどちらでも割り切れない数の数を示す
    return n-divor(n,div1,div2)


a,b,c,d=[int(i) for i in input().split()]


print(nondivor(b,c,d)-nondivor(a-1,c,d))

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10000000)

import math
def lcm(a,b):
    return int(a*b/math.gcd(a,b))


def div(n,divn):
    #1からnまでの中で、divnで割り切れる数の数を示す
    return n//divn

def divor(n,div1,div2):
    #1からnまでの中で、div1,div2のどちらかで割り切れる数の数を示す
    return div(n,div1)+div(n,div2)-div(n,lcm(div1,div2))
def nondivor(n,div1,div2):
    #１からnまでの中で、div1,div2のどちらでも割り切れない数の数を示す
    return n-divor(n,div1,div2)


a,b,c,d=[int(i) for i in input().split()]


print(nondivor(b,c,d)-nondivor(a-1,c,d))

Buggy submission (verdict: Runtime Error):
import math
def lcm(a,b):
    return int(a*b/math.gcd(a,b))


def div(n,divn):
    #1からnまでの中で、divnで割り切れる数の数を示す
    return n//divn

def divor(n,div1,div2):
    #1からnまでの中で、div1,div2のどちらかで割り切れる数の数を示す
    return div(n,div1)+div(n,div2)-div(n,lcm(div1,div2))
def nondivor(n,div1,div2):
    #１からnまでの中で、div1,div2のどちらでも割り切れない数の数を示す
    return n-divor(n,div1,div2)


a,b,c,d=[int(i) for i in input().split()]


print(nondivor(b,c,d)-nondivor(a-1,c,d))
Problem p03029 (python)

Fixed submission:
apple,appiece=[int(i) for i in input().split()]
appiece+=3*apple
print(appiece//2)

Buggy submission (verdict: Runtime Error):
from collections import deque
a=deque()
b=a.copy()
Problem p03031 (python)

Fixed submission:
#電球クラス
class Light:
    def __init__(self,name,switchs,whattype):
        self.name=name
        self.switchs=switchs
        self.whattype=whattype
    def reset(self):
        sumnum=0
        for switch in self.switchs:
            sumnum+=switch.onoff
        if sumnum%2==self.whattype:
            self.state="on"
        else:
            self.state="off"
            
#スイッチクラス            
class Switch:
    def __init__(self,name):
        self.name=name
        self.onoff=0
    def click(self,onoff):
        self.onoff=onoff
        
    
#整理用データ
n,m=[int(i) for i in input().split()]
allist=[]
for i in range(m+1):
    allist.append([int(j) for j in input().split()])
      

#全スイッチのリスト
switchlist=[]
for i in range(n):
    switchlist.append(Switch(i))


#全電球のリスト
lightlist=[]
for i in range(m):
    swlist=[]
    swnum=allist[i][1:]
    for j in swnum:
        swlist.append(switchlist[j-1])
    whattype=allist[-1][i]
    lightlist.append(Light(i,swlist,whattype))
    
#全部の付け方について
count=0
clicklist=[0 for i in range(n)]    
for i in range(2**n):
    onoffcheck=0
    j=0
    while i:
        clicklist[j]=i%2
        i=i//2
        j+=1
    for k in range(n):
        switchlist[k].click(clicklist[k])
    for light in lightlist:
        light.reset()
        if light.state=="off":
            onoffcheck+=1
    if onoffcheck==0:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
#電球クラス
class Light:
    def __init__(self,name,switchs,whattype):
        self.name=name
        self.switchs=switchs
        self.whattype=whattype
    def reset(self):
        sumnum=0
        for switch in self.switchs:
            sumnum+=switch.onoff
        if sumnum%2==0:
            self.state="off"
        else:
            self.state="on"
            
#スイッチクラス            
class Switch:
    def __init__(self,name):
        self.name=name
        self.onoff=0
    def click(self,onoff):
        self.onoff=onoff
        
    
#整理用データ
n,m=[int(i) for i in input().split()]
allist=[]
for i in range(m+1):
    allist.append([int(j) for j in input().split()])
      

#全スイッチのリスト
switchlist=[]
for i in range(n):
    switchlist.append(Switch(i))


#全電球のリスト
lightlist=[]
for i in range(m):
    swlist=[]
    swnum=allist[i][1:]
    for j in swnum:
        swlist.append(switchlist[j-1])
    whattype=allist[-1][i]
    lightlist.append(Light(i,swlist,whattype))
    
#全部の付け方について
count=0
clicklist=[0 for i in range(n)]    
for i in range(2**n):
    onoffcheck=0
    j=0
    while i:
        clicklist[j]=i%2
        i=i//2
        j+=1
    for k in range(n):
        switchlist[k].click(clicklist[k])
    for light in lightlist:
        light.reset()
        if light.state=="off":
            onoffcheck+=1
    for i in lightlist:
#         print(i.state)
    if onoffcheck==0:
        count+=1
print(count)
Problem p03044 (python)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)


n=int(input())

#ノードクラスの定義
class Node:
    def __init__(self,name):
        self.name=name
        self.near=[]
        self.length=[]
    def coloring(self,color):
        self.color=color


#ノードリストの作成
nodelist=[]
for i in range(n):
    nodelist.append(Node(i))
   
    
#辺の作成
for i in range(n-1):
    u,v,w=[int(i) for i in input().split()]
    w=w%2
    nodelist[u-1].near.append(nodelist[v-1])
    nodelist[u-1].length.append(w)
    nodelist[v-1].near.append(nodelist[u-1])
    nodelist[v-1].length.append(w)
    
#行ったかカラーでチェックリスト
color=[None for i in range(n)]
color[0]=0



def paint(node):
    nodecolor=node.color
    for j in range(len(node.near)):
        nearnode=node.near[j]
        if color[nearnode.name]!=None:
            continue
        if node.length[j]==0:
            nearnode.coloring(nodecolor)
        else:
            nearnode.coloring((nodecolor+1)%2)
        color[nearnode.name]=0
        paint(nearnode)

nodelist[0].coloring(0)
paint(nodelist[0])


for i in nodelist:
    print(i.color)

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

#ノードクラスの定義
class Node:
    def __init__(self,name):
        self.name=name
        self.near=[]
        self.length=[]
    def coloring(self,color):
        self.color=color


#ノードリストの作成
nodelist=[]
for i in range(n):
    nodelist.append(Node(i))
   
    
#辺の作成
for i in range(n-1):
    u,v,w=[int(i) for i in input().split()]
    w=w%2
    nodelist[u-1].near.append(nodelist[v-1])
    nodelist[u-1].length.append(w)
    nodelist[v-1].near.append(nodelist[u-1])
    nodelist[v-1].length.append(w)
    
#行ったかカラーでチェックリスト
color=[None for i in range(n)]
color[0]=0



def paint(node):
    nodecolor=node.color
    for j in range(len(node.near)):
        nearnode=node.near[j]
        if color[nearnode.name]!=None:
            continue
        if node.length[j]==0:
            nearnode.coloring(nodecolor)
        else:
            nearnode.coloring((nodecolor+1)%2)
        color[nearnode.name]=0
        paint(nearnode)

nodelist[0].coloring(0)
paint(nodelist[0])


for i in nodelist:
    print(i.color)
Problem p03262 (python)

Fixed submission:
import functools
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def gcd(nums):
    if len(nums)==1:
        return nums[0]
    return functools.reduce(euclid, nums)



n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.append(k)
a.sort()

sa=[]

for i in range(1,n+1):
    sa.append(a[i]-a[i-1])



print(gcd(sa))

Buggy submission (verdict: Runtime Error):
import functools
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def gcd(nums):
    return functools.reduce(euclid, nums)



n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

a.sort()

sa=[]

for i in range(1,n):
    sa.append(a[i]-a[i-1])



print(gcd(sa))
Problem p03385 (python)

Fixed submission:
moji=list(input())
moji.sort()
a="".join(moji)

if a=="abc":
    print("Yes")
else:
    print("No")

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

if moji.sort()=="abc":
    print("Yes")
else:
    print("No")
Problem p03386 (python)

Fixed submission:
a,b,k=[int(i) for i in input().split()]

if b-a+1>=2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=[int(i) for i in input().split()]
c=list(range(a,b+1))

head=c[:k]
# tail=c[::-1][:k]
# d=head+tail
# e=list(set(d))
# e.sort()
# for i in e:
#     print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=[int(i) for i in input().split()]
c=list(range(a,b+1))

head=c[:k]
tail=c[::-1][:k]
d=head+tail
# e=list(set(d))
# e.sort()
# for i in e:
#     print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=[int(i) for i in input().split()]
c=list(range(a,b+1))

head=c[:k]
tail=c[::-1][:k]
d=head+tail
e=list(set(d))
e.sort()
for i in e:
    print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=[int(i) for i in input().split()]
c=list(range(a,b+1))

d=c[:k]+c[::-1][:k]
e=list(set(d))
e.sort()
for i in e:
    print(i)
Problem p03425 (python)

Fixed submission:
n=int(input())

march=[0]*5

march_dic={"M":0,"A":1,"R":2,"C":3,"H":4}

for i in range(n):
    name=input()
    if name[0] in "MARCH":
        march[march_dic[name[0]]]+=1

def count_type(march):
    ans=[]
    for i in march:
        if i!=0:
            ans.append(i)
    ans.sort()
    return len(ans),ans

type_num,each_num=count_type(march)
if type_num<3:
    print(0)
else:
    ans=0
    for i in range(type_num-2):
        for j in range(i+1,type_num-1):
            for k in range(j+1,type_num):
                ans+=each_num[i]*each_num[j]*each_num[k]

    print(ans)

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

march=[0]*5

march_dic={"M":0,"A":1,"R":2,"C":3,"H":4}

for i in range(n):
    name=input()
    if name[0] in "MARCH":
        march[march_dic[name[0]]]+=1

def count_type(march):
    ans=[]
    for i in march:
        if i!=0:
            ans.append(i)
    ans.sort()
    return n-march.count(0),ans

type_num,each_num=count_type(march)
if type_num<3:
    print(0)
else:
    ans=0
    for i in range(type_num-2):
        for j in range(i+1,type_num-1):
            for k in range(j+1,type_num):
                ans+=each_num[i]*each_num[j]*each_num[k]

    print(ans)