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

Fixed submission:
def quick_sort(plices):
    if len(plices) == 1:
        return plices


    cri = plices[0]
    left = []
    right = []

    for i in range(1, len(plices)):
        if plices[i] < cri:
            left.append(plices[i])

        else:
            right.append(plices[i])

    left.append(cri)

    return quick_sort(left) + quick_sort(right)

def cal_sum(sorted_plices, K):
    min_sum = 0
    for i in range(K):
        min_sum += sorted_plices[i]

    return min_sum


if __name__ == "__main__":

    N, K = map(lambda x:int(x), input().split())
    plices = [int(i) for i in input().split()]

    # sorted_plices = quick_sort(plices)
    sorted_plices = sorted(plices)
    # print(sorted_plices)
    min_sum = cal_sum(sorted_plices, K)

    print(min_sum)

Buggy submission (verdict: Runtime Error):
def quick_sort(plices):
    if len(plices) <= 1:
        return plices

    cri = plices[0]
    left = []
    right = []

    for i in range(1, len(plices)):
        if plices[i] < cri:
            left.append(plices[i])

        else:
            right.append(plices[i])

    left.append(cri)

    return quick_sort(left) + quick_sort(right)

def cal_sum(sorted_plices, K):
    min_sum = 0
    for i in range(K):
        min_sum += sorted_plices[i]

    return min_sum


if __name__ == "__main__":

    N, K = map(lambda x:int(x), input().split())
    plices = [int(i) for i in input().split()]

    sorted_plices = quick_sort(plices)

    # print(sorted_plices)
    min_sum = cal_sum(sorted_plices, K)

    print(min_sum)

Buggy submission (verdict: Runtime Error):

def quick_sort(plices):
    if len(plices) == 1:
        return plices


    cri = plices[0]
    left = []
    right = []

    for i in range(1, len(plices)):
        if plices[i] < cri:
            left.append(plices[i])

        else:
            right.append(plices[i])

    left.append(cri)

    return quick_sort(left) + quick_sort(right)

def cal_sum(sorted_plices, K):
    min_sum = 0
    for i in range(K):
        min_sum += sorted_plices[i]

    return min_sum


if __name__ == "__main__":

    N, K = map(lambda x:int(x), input().split())
    plices = [int(i) for i in input().split()]

    sorted_plices = quick_sort(plices)
    min_sum = cal_sum(sorted_plices, K)

    print(min_sum)
Problem p02628 (python)

Fixed submission:
N, K = map(int,input().split())
List_1 = sorted(list(map(int, input().split())))
ans = sum(List_1[:K])
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
LIst_1 = sorted(list(map(int, input().split())), reverse=True)
K = K+1
ans = sum(List_1[:K])
Problem p02811 (python)

Fixed submission:
k,x=map(int,input().split())
if k*500>=x:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x=input('')
k=input('')
if k*500>=x:
    print ("Yes")
else:
    print ("No")
Problem p02817 (python)

Fixed submission:
b, c = map(str, input().split())

print(c+b)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
print("{}{}".format(t,s))

Buggy submission (verdict: Runtime Error):
s=str(input())
t=str(input())

print("{}{}".format(t,s))
Problem p03352 (python)

Fixed submission:

x=int(input())
a=[]
ans=0

for i in range(1,32):
            for j in range(2,10):
                        ans=i**j
                        if ans<=x:
                                    a.append(ans)   
                                    #i+=1
                        else:
                                    break
                        
            #print(a)
print(max(a))
"""
while ans<x:
"""

Buggy submission (verdict: Runtime Error):

x=int(input())
a=[]
ans=0

for i in range(1,32):
            for j in range(2,10):
                        ans=i**j
                        if ans<x:
                                    a.append(ans)   
                                    i+=1
                        else:
                                    break
                        
            #print(a)
print(max(a))
"""
while ans<x:
"""
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())

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

"""
for i in range(a,b+1):
            #print("i",i)
            if i<a+k:
                        print(i)
            elif b-k<i:
                        print(i)
"""

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
"""
if b-a+1<=2*k:
            for i in range(a,b+1):
                        print(i)
else:
            for i in range(a,a+k):
                        print(i)
            for i in range(b-k+1,b+1):
                        print(i)

"""
for i in range(a,b+1):
            #print("i",i)
            if i<a+k:
                        print(i)
            elif b-k<i:
                        print(i)
"""
Problem p03415 (python)

Fixed submission:
s=list(input())
t=list(input())
v=list(input())
print(s[0]+t[1]+v[2])

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
cnt=0
for l in range(a,b+1):
            l_i=list(str())
            if l_i[0]==l_i[-1] and l_i[1]=l_i[-2]:
                        cnt+=1
print(cnt)
Problem p03416 (python)

Fixed submission:
a,b=map(int,input().split())
cnt=0
for l in range(a,b+1):
            l_i=list(str(l))
            if l_i[0]==l_i[-1] and l_i[1]==l_i[-2]:
                        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
cnt=0
for l in range(a,b+1):
            l_i=list(str())
            if l_i[0]==l_i[-1] and l_i[1]=l_i[-2]:
                        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
cnt=0
for l in range(a,b+1):
            l_i=list(str())
            if l_i[0]==l_i[-1] and l_i[1]=l_i[-2]:
                        cnt+=1
print(cnt)
Problem p03433 (python)

Fixed submission:

n=int(input())
a=int(input())
if n%500<=a:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=input()
a=input()
if n%500 <=a:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=input()
a=input()
if n%500 <=a:
    print('Yes')
else:
    print('No')
Problem p03556 (python)

Fixed submission:
n = int(input())
m = 1
for i in range(1, n):
    if i ** 2 > n:
        break
    m = i ** 2
print(m)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=0
l=[]
for a in range(1,n+1):
            for i in range(1,n):
                        if a==i**2:
                                    #print(a,i)
                                    l.append(a)
                               
print(max(l))
Problem p03624 (python)

Fixed submission:
alp=['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']
s=list(input())
s_ = list(set(s))
#print(s)
#print(s_)
s.sort()
s_.sort()
#print(s)
#print(s_)
        
l=[]
cnt=0
for i in range(len(alp)):
            if s.count(alp[i]):
                        pass
            else:
                        l.append(alp[i])
                        cnt+=1
#print(l)
if cnt==0:
            print('None')
else:
            print(min(l))
exit()

Buggy submission (verdict: Runtime Error):
alp=['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']
s=list(input())
s_ = list(set(s))
#print(s)
#print(s_)
s.sort()
s_.sort()
#print(s)
#print(s_)
        
l=[]
cnt=0
for i in range(len(alp)):
            if s.count(alp[i]):a
                        pass
            else:
                        l.append(alp[i])
                        cnt+=1
#print(l)
if cnt==0:
            print('None')
else:
            print(min(l))
exit()
Problem p03760 (python)

Fixed submission:
o=list(input())
m=list(input())

ans=[]
for i in range(len(o)-1):
            ans.append(o[i])
            ans.append(m[i])
ans.append(o[-1])
if len(o)==len(m):
            ans.append(m[-1])
print("".join(ans))

Buggy submission (verdict: Runtime Error):
o=list(input())
m=list(input())
ans=' '
for i in range(len(o)):
            
                        ans +=o[i]
                        ans +=m[i]
                        
print(ans)
Problem p02675 (python)

Fixed submission:

def main():
    N = input()
    N_l = list(N)
    m = int(N_l[-1])
    if m == 0 or m == 1 or m==6 or m==8:
        print("pon")
    elif m == 2 or m== 4 or m == 5 or m == 7 or m==9:
        print("hon")
    elif m == 3:
        print("bon")
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    N = input()
    N_l = list(N)
    m = int(N_l[-1])
    if m == 0 or m == 1 or m==6 or m==8:
        print("pon")
    elif m == 2 or m== 4 or m == 5 or m == 7 or m==9:
        print("hon")
    elif m == 3:
        print("bon")
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    N = input()
    N_l = list(N)
    m = int(N_l[-1])
    if m == 0 or m == 1 or m==6 or m==8:
        print("pon")
    elif m == 2 or m== 4 or m == 5 or m == 7 or m==9:
        print("hon")
    elif m == 3:
        print("bon")
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    N = input()
    N_l = list(N)
    m = int(N_l[-1])
    if m == 0 or m == 1 or m==6 or m==8:
        print("pon")
    elif m == 2 or m== 4 or m == 5 or m == 7 or m==9:
        print("hon")
    else:
        print("bon")
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    N = input()
    N_l = list(N)
    m = int(N_l[-1])
    if m == 0 or m == 1 or m==6 or m==8:
        print("pon")
    elif m == 2 or m== 4 or m == 5 or m == 7 or m==9:
        print("hon")
    else:
        print("bon")
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    N = input()
    N_l = list(N)
    m = int(N_l[-1])
    if m == 0 or m == 1 or m==6 or m==8:
        print("pon")
    elif m == 2 or m== 4 or m == 5 or m == 7 or m==9:
        print("hon")
    else:
        print("bon")
if __name__ == "__main__":
    main()
Problem p02678 (python)

Fixed submission:
from collections import deque

def main():
    n,m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1].append(b)
        graph[b-1].append(a)
    
    q = deque([1])
    prev=[1]
    siru = [0] * n
    siru[0] = 1
    while q:
    
        now = q.popleft()
        
        next = graph[now-1]
    
        
        for n in next:
            if not siru[n-1]: 
                q.append(n)
                siru[n-1] = now
    
    
    print("Yes")
    print("\n".join(map(str, siru[1:])))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque


n,m = map(int, input().split())
graph = [[] for _ in range(n)]
for i in range(1,m+1):
    a,b = map(int, input().split())
    graph[a-1].append(b)
    graph[b-1].append(a)

q = deque([1])
prev=[1]
siru = [0] * (n-1)
while q:

    now = q.popleft()
    
    next = graph[now-1]

    
    for n in next:
        if not n in prev: 
            q.append(n)
            prev.append(n)
            siru[n-2] = now
    if not 0 in siru:
        break



print("Yes")
print("\n".join(map(str, signposts[2:])))
Problem p02681 (python)

Fixed submission:
prev = input()
prev_l = list(prev)

now = input()
now_l = list(now)
n = len(now_l)

if now_l[:n-1] == prev_l:
    print("Yes")
else:
    print("No")

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

C = list()
A = list()
for i in range(N):
	temp = list(map(int,input().split()))
	C.append(temp[0])
	A.append(temp[1:])	


MAX = 100000000000	

def func(cost,a,i):
	if min(a) >= X:
		return cost
	elif i == N:
		return MAX
	total_A = [x+y for (x,y) in zip(a,A[i])]
    
	return min(func(cost + C[i],total_A,i+1),func(cost,a,i+1))
	
ans = func(0,[0]*M,0)

if ans == MAX:
	print(-1)
else:
	print(ans)

Buggy submission (verdict: Runtime Error):
n,m,r = map(int, input().split())
dn = [[0] * m for _ in range(n)]

for i in range(n):
  dn[i][:] = map(int, input().split())

  dn = np.array(dn)
  cost = []
  sh = 0
  inf = 10e8
  cost = inf
  k = np.zeros(m+1)

  def secom(j,k,cost):
    if j == n:

      if np.all(k>=r):
        print(k)
        cost = min(cost,k[0])
        return cost
      else:
        return cost

      cost1 = secom(j+1,k,cost)
      k += dn[j]
      cost2 = secom(j+1,k,cost)
      k -= dn[j]

      return min(cost1,cost2)


    cost = secom(0,k,cost)
    if cost == inf:
      print(-1)
      else:
        print(int(cost))
Problem p02683 (python)

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

C = list()
A = list()
for i in range(N):
	temp = list(map(int,input().split()))
	C.append(temp[0])
	A.append(temp[1:])	


MAX = 100000000000	

def func(cost,a,i):
	if min(a) >= X:
		return cost
	elif i == N:
		return MAX
	total_A = [x+y for (x,y) in zip(a,A[i])]
    
	return min(func(cost + C[i],total_A,i+1),func(cost,a,i+1))
	
ans = func(0,[0]*M,0)

if ans == MAX:
	print(-1)
else:
	print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    n,m,r = map(int, input().split())
    dn = [[0] * m for _ in range(n)]
    
    for i in range(n):
        dn[i][:] = map(int, input().split())

    dn = np.array(dn)
    cost = []
    sh = 0
    inf = 10e8
    cost = inf
    k = np.zeros(m+1)
    
    def secom(j,k,cost):
        if j == n:
            
            if np.all(k>=r):
                print(k)
                cost = min(cost,k[0])
                return cost
            else:
                return cost
        
        cost1 = secom(j+1,k,cost)
        k += dn[j]
        cost2 = secom(j+1,k,cost)
        k -= dn[j]
        
        return min(cost1,cost2)
    
    
    cost = secom(0,k,cost)
    if cost == inf:
        print(-1)
    else:
        print(int(cost))
        
        

if __name__ == "__main__":
    main()
Problem p02848 (python)

Fixed submission:
n=int(input())
s=list(input())
a=[chr(i) for i in range(65,65+26)]

for i in range(len(s)):
  for j in range(len(a)):
    if s[i]==a[j]:
      if j+n<26:
        s[i]=a[j+n]
      else:
        s[i]=a[j+n-26]
      break

print(''.join(s))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
a=[chr(i) for i in range(65,65+26)]

for i in range(n):
  for j in range(26):
    if s[i]==a[j]:
      s[i]=a[(j+n)%26]
print(''.join(s))
Problem p02924 (python)

Fixed submission:
n=int(input())
ans=n*(n-1)//2
print(int(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
print(sum(list(range(n))))
Problem p02995 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
cwari=b//c-(a-1)//c
dwari=b//d-(a-1)//d
import fractions
l=int(c*d/fractions.gcd(c,d))
cdwari=b//l-(a-1)//l
ans=(b-a)+1-cwari-dwari+cdwari
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
cwari=b//c-(a-1)//c
dwari=b//d-(a-1)//d
import math
cd=math.gcd(c,d)
cdwari=b//cd-(a-1)//cd
ans=(b-a)+1-cwari-dwari+cdwari
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
cwari=b//c-(a-1)//c
dwari=b//d-(a-1)//d
import math
cd=math.gcd(c,d)
cdwari=b//cd-(a-1)//cd
print(cwari)

ans=(b-a)+1-cwari-dwari+cdwari
print(ans)
Problem p03001 (python)

Fixed submission:
w,h,x,y=map(int,input().split())
huku=0
if w/2==x and h/2==y:
  huku=1
print(w*h/2,huku)

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
huku=0
if w/x==2 and h/y==2:
  huku=1
print(w*h/2,huku)
Problem p02675 (python)

Fixed submission:
N = list(input())
hon = [2,4,5,7,9]
pon = [0,1,6,8]
if int(N[-1]) in hon:
    print("hon")
elif int(N[-1]) in pon:
    print("pon")
else:
    print("bon")

Buggy submission (verdict: Runtime Error):
N = list(input())
hon = [2,4,5,7,9]
pon = [0,1,6,8]
if int(N[2]) in hon:
    print("hon")
elif int(N[2]) in pon:
    print("pon")
else:
    print("bon")

Buggy submission (verdict: Runtime Error):
N = list(input())
hon = [2,4,5,7,9]
pon = [0,1,6,8]
if int(N[2]) in hon:
    print("hon")
elif int(N[2]) in pon:
    print("pon")
else:
    print("bon")
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
vis = [0]*N
p = 1
Town = []

while vis[p-1] == 0:
    Town.append(p)
    vis[p-1] = 1
    p = A[p-1]

l = Town.index(p)

if K < len(Town):
    print(Town[K])
else:
    print(Town[l + (K-l)%(len(Town[l:]))])

Buggy submission (verdict: Runtime Error):
Town = []
N, K = map(int, input().split())
A = list(map(int, input().split()))
vis = [0]*N
p = 1
while vis[p-1]==0:
    Town.append(p)
    vis[p-1] = 1
    p = A[p-1]

l = Town.index[p]

if K < len(Town):
    print(Town[K])
else:
    print(Town[l + (K-l)%(len(Town[l:]))])

Buggy submission (verdict: Runtime Error):
# ABC167D
Town = []
C = 0
N, K = map(int, input().split())
A = list(map(int, input().split()))
def dfs(a, i, town, c):
    if i-1 in town:
        L = len(town) - len(town[:town.index(i-1)])
        c += (K-c) - ((K-c)%L)
        town = []
    else:
        town.append(i-1)
        c += 1
    if c >= K:
        return print(i)
    nx = a[i-1]
    dfs(a, nx, town, c)

dfs(A, 1, Town, C)

Buggy submission (verdict: Runtime Error):
Town = []
C = 0
N, K = map(int, input().split())
A = list(map(int, input().split()))
def dfs(a, i, town, c):
    if i-1 in town:
        L = len(town) - len(town[:town.index(i-1)])
        c += (K - c) - (K%L)
        town = []
        town.append(i-1)
    else:
        town.append(i-1)
        c += 1
    if c == K:
        return print(a[i-1])
    nx = a[i-1]
    dfs(a, nx, town, c)

dfs(A, 1, Town, C)
Problem p02947 (python)

Fixed submission:
from collections import Counter

N = int(input())
s = Counter()
for i in range(N):
    s[''.join(sorted(input()))] += 1
ans = 0
for kw, count in s.most_common():
    for i in range(1, int(count)):
        ans += i
    if int(count) < 2:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
ns = []
ans = 0
for i in range(len(s)):
    if ns.count(s[i]) == 0:
        aas = s.count(s[i])
        if aas > 0:
            ns.append(s[i])
        abs = cmb(aas,2)
        ans += int(abs)
print(ans)

Buggy submission (verdict: Runtime Error):
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
ns = []
ans = 0
for i in range(len(s)):
    if ns.count(s[i]) == 0:
        aas = s.count(s[i])
        if aas > 0:
            ns.append(s[i])
        abs = cmb(aas,2)
        ans += int(abs)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import factorial
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
ns = []
ans = 0
for i in range(len(s)):
    if ns.count(s[i]) == 0:
        aas = s.count(s[i])
        if aas > 0:
            ns.append(s[i])
        abs = int(factorial(aas) / factorial(2) / factorial(aas - 2 ))
        ans += abs
print(ans)
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]
for i in range(1, n+1):
    d.append(d[i-1] + l[i-1])
    if d[i] > x :
        print(len(d) - 1)
        exit()
print(len(d))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]
for i in range(1, n+2):
    d.append(d[i-1] + l[i-1])
    if d[i] > x :
        print(len(d)-1)
        exit()
Problem p03494 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
while True:
    i = 0
    while i <= n -1:
        if a[i]%2:
            print(ans)
            exit()
        else:
            a[i] = a[i]//2
        i += 1
    ans += 1

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input()))
ans = 0
for i in range(n):
    if a[i]%2:
        a[i] = a[i]//2
    else:
        print(ans)
        exit()
    ans += 1
Problem p02641 (python)

Fixed submission:
# coding: utf-8
# Your code here!

import numpy as np

x,n = map(int,input().split())

p = list(map(int,input().split()))

m = np.array(list(range(-200,400)))
m = (m-x)**2
for i in (np.argsort(m)-200):
    if p.count(i) == 0:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

num = int(input())

qm = 1000000000000001

alf = [chr(i) for i in range(97, 97+26)]
#print(alf)

ans = []
f = False

for i in reversed(range(12)):
    if (num-num//26)//26**i >= 1:
        f = True

    if f:
        ans.append(alf[(num-i)//26**i-1])
        num = num % 26**i
print("".join(ans))
Problem p02936 (python)

Fixed submission:
# coding: utf-8
# Your code here!
from collections import Counter

n,q = map(int,input().split())

d = {}

for i in range(n-1):
    _a,_b = map(int,input().split())
    d[_b] = _a

ans = [0]*n

for i in range(q):
    _p,_x = map(int,input().split())
    ans[_p-1]+=_x


for i in range(1,n):
    ans[i] += ans[d.get(i+1)-1]

#print(ans)
print(" ".join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
from collections import Counter

n,q = map(int,input().split())

a,b = [],[]

for i in range(n-1):
    _a,_b = map(int,input().split())
    a.append(_a)
    b.append(_b)

p,x = [],[]

for i in range(q):
    _p,_x = map(int,input().split())
    p.append(_p)
    x.append(_x)

class ki:
    def __init__ (self,n):
        self.name = n
        self.num = 0
        self.node = []
    
    def add(self,n,ne):
        if self.name == n:
            self.node.append(ki(ne))
            return 0
        else:
            for i in self.node:
                i.add(n,ne)
            return 0
            
    def add_num(self,n,num,f):
        if self.name == n or f:
            self.num += num
            f = True
        else:
            f = False
            
        for i in self.node:
            i.add_num(n,num,f)
    
    def out(self):
        d = {self.name:self.num}
        for i in self.node:
            d = dict(Counter(d) + Counter(i.out()))
        return(d)

Ki = ki(1)

for i,j in zip(a,b):
    Ki.add(i,j)
for i,j in zip(p,x):
    Ki.add_num(i,j,False)

d = Ki.out()
print(" ".join([str(d[i+1]) for i in range(n)]))
Problem p02995 (python)

Fixed submission:
# coding: utf-8
# Your code here!

from fractions import gcd

a, b, c, d = map(int,input().split())
a = a-1
dc = b//c
dc -= a//c

dd = b//d
dd -= a//d

lcm = c*d//gcd(c,d)
dcd = b//lcm
dcd -= a//lcm

ans = b-a-dc-dd+dcd

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

import math
a, b, c, d = map(int,input().split())
a = a-1
dc = b//c
dc -= a//c

dd = b//d
dd -= a//d

lcm = c*d//math.gcd(c,d)
dcd = b//lcm
dcd -= a//lcm

ans = b-a-dc-dd+dcd

print(ans)
Problem p03071 (python)

Fixed submission:
# coding: utf-8
# Your code here!

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

ans = 0

if a>b:
    ans+=a
    a-=1

else:
    ans+=b
    b-=1


if a>b:
    ans+=a

else:
    ans+=b

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n,k = map(int,input().split())

s = input()

now = s[0]
tmp = 0

h = []
if s[0]=="0":
    h.append(0)

for i in s:
    if i != now:
        now = i
        h.append(tmp)
        tmp=0
    tmp+=1
h.append(tmp)

ans = 0

for i in range(0,max(len(h),len(h)-k),2):
    ans = max(ans,sum(h[i:i+k*2+1]))

print(ans)