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

Fixed submission:
import sys
from io import StringIO
import unittest
import fractions
import math


#from numba import jit
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def resolve():
    A, B, C, D = map(int, input().split())
    size = B - A + 1
    C_warikire = B // C - (A - 1) // C
    D_warikire = B // D - (A - 1) // D
    C_and_D_warikire = B // lcm(C, D) - (A - 1) // lcm(C, D)
    print(size - C_warikire - D_warikire + C_and_D_warikire)
resolve()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def resolve():
    A, B, C, D = map(int, input().split())
    size = B - A + 1
    C_warikire = math.ceil(size / C)
    D_warikire = math.ceil(size / D)
    C_and_D_warikire = math.ceil(size / (lcm(C, D)))
    print(size - C_warikire - D_warikire + C_and_D_warikire)
    
resolve()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest
import math


#from numba import jit
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def resolve():
    A, B, C, D = map(int, input().split())
    size = B - A + 1
    C_warikire = math.ceil(size / C)
    D_warikire = math.ceil(size / D)
    C_and_D_warikire = math.ceil(size / (lcm(C, D)))
    print(size - C_warikire - D_warikire + C_and_D_warikire)
resolve()
Problem p02996 (python)

Fixed submission:
import sys
from io import StringIO
import unittest
import numpy as np


def resolve():
    N = int(input())
    L = [list(map(int, input().split())) for i in range(N)]
    L.sort(key=lambda v: v[1])
    A_sum = 0
    for a, b in L:
        A_sum += a
        if (b < A_sum):
            print("No")
            return
    print("Yes")
resolve()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest
import numpy as np


def resolve():
    N = int(input())
    L = [list(map(int, input().split())) for i in range(N)]
    L.sort(key=lambda v: v[1])
    A_sum = 0
    for a, b in L:
        A_sum += a
        if (b < A_sum):
            print("No")
            return
    print("Yes")
resolve()
Problem p03047 (python)

Fixed submission:
import bisect
import numpy as np
import scipy as sp
from sys import stdin

n, k = map(int, input().split())
print(n - k + 1)

Buggy submission (verdict: Runtime Error):
r, g, b, n = map(int, input().split())
count = 0

for i in range(n + 1):
    for j in range(n + 1):
        total = n - r * i - g * j
        if total < 0:
            break
        if total % b == 0:
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import bisect
import numpy as np
import scipy as sp
from sys import stdin

r, g, b, n = map(int, input().split())
count = 0

for i in range(n + 1):
    for j in range(n + 1):
        total = n - r * i - g * j
        if total < 0:
            break
        if total % b == 0:
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import bisect
import numpy as np
import scipy as sp
from sys import stdin

r, g, b, n = map(int, input().split())
count = 0

for i in range(n + 1):
    for j in range(n + 1):
        total = n - r * i - g * j
        if total < 0:
        	break
        if total % b == 0:
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import bisect
import numpy as np
import scipy as sp
from sys import stdin

r, g, b, n = map(int, input().split())
count = 0

for i in range(n + 1):
    for j in range(n + 1):
        total = n - r * i - g * j
        if total < 0:
        	break
        if total % b == 0:
            count += 1

print(count)
Problem p03048 (python)

Fixed submission:


r, g, b, n = map(int, input().split())
count = 0

for i in range(n + 1):
    for j in range(n + 1):
        total = n - r * i - g * j
        if total < 0:
            break
        if total % b == 0:
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import bisect
import numpy as np
import scipy as sp
from sys import stdin

r, g, b, n = map(int, input().split())
count = 0

for i in range(n + 1):
    for j in range(n + 1):
        total = n - r * i - g * j
        if total < 0:
            break
        if total % b == 0:
            count += 1

print(count)
Problem p03160 (python)

Fixed submission:
n = int(input())
h = [None] + list(map(int, input().split()))

dp = [None for _ in range(n+1)]
for k in range(1,n+1):
  if k == 1:
    dp[k] = 0
  elif k == 2:
    dp[k] = abs(h[2] - h[1])
  else:
    dp[k] = min(
      dp[k-1] + abs(h[k] - h[k-1]),
      dp[k-2] + abs(h[k] - h[k-2])
    )
print(dp[k])

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [None] + list(map(int, input().split('')))

dp = [None for _ in range(n+1)]
for k in range(1,n+1):
  if k == 1:
    dp[k] = 0
  elif k == 2:
    dp[k] = abs(h[2] - h[1])
  else:
    dp[k] = min(
      dp[k-1] + abs(h[k] - h[k-1]),
      dp[k-2] + abs(h[k] - h[k-2])
    )
print(dp[k])

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [None] + list(map(int, input().split('')))

dp = [None for _ in range(n+1)]
for k in range(1,n+1):
  if k == 1:
    dp[k] = 0
  elif k ==2:
    dp[k] = abs(h[2] - h[1])
  else:
    dp[k] = min(
      dp[k-1] + abs(h[k] - h[k-1]),
      dp[k-2] + abs(h[k] - h[k-2])
    )
print(dp[k])

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [None] + list(map(int, input().split('')))

dp = [None for _ in range(n+1)]
for k in range(1,n+1):
  if k == 1:
    dp[k] = 0
  elif k ==2:
    dp[k] = abs(h[2] - h[1])
  else:
    dp[k] = min(
      dp[k-1] + abs(h[k] - h[k-1]),
      dp[k-2] + abs(h[k] - h[k-2])
    )
print(dp[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [None] + list(map(int, input().split('')))

dp = [None for _ in range(n+1)]
for i in range(1,n+1):
  if i == 1:
    dp[i] = 0
  elif i ==2:
    dp[i] = abs(h[2] - h[1])
  else:
    dp[i] = min(
      dp[i-1] + abs(h[k] - h[k-1]),
      dp[i-2] + abs(h[k] - h[k-2])
    )
print(dp[i])
Problem p02700 (python)

Fixed submission:
import math
a,b,c,d = map(int,input().split())
x=c/b
y=a/d
x=math.ceil(x)
y=math.ceil(y)
if x<=y:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
 a,b,c,d = map(int,input().split())
while(a>0 or c>0):
  c-=b
  a-=d
if a<=0 and c>0:
  print("No")
elif c<=0 and a>0: 
  print("Yes")
elif a<=0 and c<=0:
  print("Yes")
Problem p02705 (python)

Fixed submission:
i = int(input())
l = 2*i*3.141592
print(l)

Buggy submission (verdict: Runtime Error):
i = int(input())
l = 2*i*math.pi
print(l)
Problem p02791 (python)

Fixed submission:
N=int(input())
P=[int(i) for i in input().split()]
x=P[0]
a=1
if N==1:
    print(a)
else:
    for i in range(1,N):
        if x>P[i]:
            x=P[i]
            a+=1
    print(a)

Buggy submission (verdict: Runtime Error):
N=int(input())
P=[int(i) for i in input().split()]
x=P[0]
a=1
if N==1:
    print(a)
else:
    for i in range(1,N):
        if x>P[i]:
            x=P[i]
            a+=1
        else:
    print(a)
Problem p02717 (python)

Fixed submission:
a = list(map(int,input().strip().split()))
print (a[2],a[0],a[1])

Buggy submission (verdict: Runtime Error):
l=list(map(int(input().strip().split()))
       print(str(l[3]+ " " +l[1]+" "+l[2]))
Problem p02706 (python)

Fixed submission:
N,M=map(int,input().split())
A_i=list(map(int,input().split()))
A=0
for i in range(M):
    A+=A_i[i]
    
if N<A:
    print("-1")

else:
    print(N-A)

Buggy submission (verdict: Runtime Error):
N,M,A_i=(int,input().split())
A=0
for i in range(M):
    A+=A_i
if N<A:
    print("-1")

else:
    print(N-A)

Buggy submission (verdict: Runtime Error):
N,M,A_i=(int(x) for x in input().split())
A=0
for i in range(M):
    A+=A_i
if N<A:
    print("-1")

else:
    print(N-A)
Problem p02708 (python)

Fixed submission:
N,K = map(int,input().split())
cnt = [0]*(N-K+2)

cnt_all = 0
mod = 1000000007

for i in range(K,N+2):
    cnt[i-K] = i*N - i*(i-1) + 1

for i in range(N-K+2):
    cnt_all += cnt[i]

print(cnt_all % mod)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
cnt = [0]*(N-K+2)

cnt_all = 0
mod = 1000000007

for i in range(K,N+2):
    cnt[i] = i*N - i*(i-1) + 1

for i in range(N-K+2):
    cnt_all += cnt[i]

print(cnt_all % mod)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
cnt = [0]*(N-K+2)

cnt_all = 0
mod = 1000000007

for i in range(K,N+2):
    cnt[i] = (i+1)*N - i^2

for i in range(N-K+2):
    cnt_all += cnt[i]

print(cnt_all % mod)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
cnt = [0]*(N-K+2)

cnt_all = 0
mod = 1000000007

for i in range(K,N+2):
    cnt[i] = (i+1)*(N-i)

for i in range(N-K+2):
    cnt_all += cnt[i]

print(cnt_all % mod)
Problem p02687 (python)

Fixed submission:
s = input()
if s == "ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
hs = list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(0))
Problem p02717 (python)

Fixed submission:
x, y, z = map(str,input().split())
print(z + ' ' + x + ' ' + y)

Buggy submission (verdict: Runtime Error):
x , y, z = map(int,input().split())
print(z + ' ' + x + ' ' + y)
Problem p02731 (python)

Fixed submission:
l = int(input())
print(pow(l/3,3))

Buggy submission (verdict: Runtime Error):
l = int(input())
print(pow(1/3,3)
Problem p02789 (python)

Fixed submission:
n, m = map(int, input().split())
 
if n == m:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

if n == m:
  print('Yes'):
else:
  print('No')
Problem p03377 (python)

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

if x >= a and x <= a + b:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
n = int(input())
list = list(map(int, input().split()))
for i in range(len(list)-1):
  copy_list = list.copy()
  copy_list.pop(i)
  copy_list.sort()
  print(copy_list[int(n/2-1)])

Buggy submission (verdict: Runtime Error):
n = int(input())
list = list(map(int, input().split()))
for i in range(len(list)):
  copy_list = list.copy()
  copy_list.pop(i)
  copy_list.sort()
  print(copy_list[int(n/2)-1])
Problem p03076 (python)

Fixed submission:
ipt = [int(input()) for i in range(5)]

minnum = 1000
minidx = 6
for i, con in enumerate(ipt):
    if con % 10 != 0:
        if minnum > con % 10:
            minnum = con % 10
            minidx = i

print(sum([int((con+9)/10)*10 if i != minidx and con%10 != 0 else con for i,con in enumerate(ipt)]))

Buggy submission (verdict: Runtime Error):
ipt = [int(input()) for i in range(5)]

minnum = 1000

for i, con in enumerate(ipt):
    if con % 10 != 0:
        if minnum > con % 10:
            minnum = con % 10
            minidx = i

print(sum([int((con+9)/10)*10 if i != minidx and con%10 != 0 else con for i,con in enumerate(ipt)]))
Problem p03101 (python)

Fixed submission:
H,W = map(int,input().split())
h,w = map(int,input().split())

print((H*W + h*w) - (H*w + W*h))

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
h,w = map(int,input().split())

print((H*W + h*w) - (H*w + Wh))
Problem p03294 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
print(sum(l) - n)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

input()
l = list(map(int, input().split()))
m = reduce(lcm, l, 1) - 1

ans = 0
for i in range(len(l)):
	ans += m % l[i]

print(ans)

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

input()
l = list(map(int, input().split()))
m = np.lcm.reduce(l) - 1

ans = 0
for i in range(len(l)):
	ans += m % l[i]

print(ans)
Problem p03378 (python)

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

c1 = len([i for i in gates if i < X])
can = [c1, M - c1]

print(min(can))

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split(' '))
gates = [int(input()) for i in range(M)]

can = [len([i for i in gates if i > X]), len([i for i in gates if i < X])]

print(min(can))
Problem p03380 (python)

Fixed submission:
from bisect import bisect_left

N = int(input())
data = list(map(int, input().split(' ')))
sorteddata = sorted(data)

def takeClosest(myList, myNumber):
    pos = bisect_left(myList, myNumber)
    if pos == 0:
        return myList[0]
    if pos == len(myList):
        return myList[-1]
    before = myList[pos - 1]
    after = myList[pos]
    if after - myNumber < myNumber - before:
       return after
    else:
       return before

ans = takeClosest(sorteddata, sorteddata[-1] / 2)
print(str(sorteddata[-1]) + ' ' + str(ans))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left

N = int(input())
data = list(map(int, input().split(' ')))
sorteddata = sorted(data)

def takeClosest(myList, myNumber):
    pos = bisect_left(myList, myNumber)
    if pos == 0:
        return myList[0]
    if pos == len(myList):
        return myList[-1]
    before = myList[pos - 1]
    after = myList[pos]
    if after - myNumber < myNumber - before:
       return after
    else:
       return before

ans = takeClosest(sorteddata, sorteddata[-1] / 2)
print(sorteddata[-1] + ' ' + ans)
Problem p02687 (python)

Fixed submission:
s = input()
if s=="ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
s = char(input())
if s=="ABC":
    print("ARC")
else:
    print("ABC")
Problem p02706 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(0,m):
    n-=a[i]
if n<0:
    print(-1)
else:
    print(n)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(0,m+1):
    n-=a[i]
if n<=0:
    print(-1)
else:
    print(n)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(0,m):
    num=int(input())
    a.append(num)
    n-=a[i]
if n<=0:
    print(-1)
else:
    print(n)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(0,m):
    a[i] = input()
    n-=a[i]
if n<=0:
    print(-1)
else:
    print(n)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
for i in range(0,m):
    a[i] = input()
    n-=a[i]
if n<=0:
    print(-1)
else:
    print(n)
Problem p02717 (python)

Fixed submission:
x,y,z=map(int,input().split())
print(z,x,y)

Buggy submission (verdict: Runtime Error):
x,y,z=map(int,input().split())
def sort(a,b):
    tmp=a
    a=b
    b=tmp
sort(x,y)
sort(x,z)
print(f"{z} {x} {y}")

Buggy submission (verdict: Runtime Error):
x,y,z=map(int,input().split())
print(f"{z} {x} {y}")
Problem p02765 (python)

Fixed submission:
N,R = map(int,input().split())
plus=0
if N<10:
	plus=100*(10-N)
print(R+plus)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(0,m):
    num=int(input())
    a.append(num)
    n-=a[i]
if n<=0:
    print(-1)
else:
    print(n)

Buggy submission (verdict: Runtime Error):
n = int(input())
r = int(input())
if n<10 and -1<n:
  	print(r+100*(10-n))
elif n>=10:
    print(r)

Buggy submission (verdict: Runtime Error):
n = int(input())
r = int(input())
if n<10 and -1<n:
  	print(r+100(10-n))
elif n>=10:
    print(r)
Problem p02767 (python)

Fixed submission:
number = int(input())
coordinates = list(map(int, input().split()))
coordinates.sort()
coordinates.reverse()
#print(coordinates)
list = []
for i in range(coordinates[0]+1):
    total=0
    for j in range(number):
        total += (coordinates[j]-i)**2
    list.insert(0, total)
list.sort()
print(list[0])

Buggy submission (verdict: Runtime Error):
number, base = map(int, input().split())
devision = number
list = []
while(devision>=base):
    surplus = devision % base
    devision = int(devision / base)
    #print(devision, surplus)
    list.insert(0,surplus)
    #print(list)
list += [devision]
#print(list)
print(len(list))

Buggy submission (verdict: Runtime Error):
number = input()
coordinates = list(map(int, input().split()))
coordinates.sort()
coordinates.reverse()
#print(coordinates)
list = []
for i in range(coordinates[0]):
    total=0
    for j in range(number):
        total += (coordinates[j]-i)**2
    list.insert(0, total)
list.sort()
print(list[0])
Problem p02772 (python)

Fixed submission:
number = input()
list1 = list(map(int, input().split()))
han = 0
count = 0
for i in range(0, len(list1)):
    if list1[i]%2 == 0:
        count += 1
        if list1[i]%3 == 0 or list1[i]%5 == 0:
            han += 1
if han == count:
    print("APPROVED")
else:
    print("DENIED")

Buggy submission (verdict: Runtime Error):
number = str(input())
list = list(map(int, input().split())
for i in list:
	if i%2==0:
		if i%3==0 or i%5==0:
            print("APPROVED")
        else:
            print("DENIED")
Problem p02778 (python)

Fixed submission:
mozi = str(input())
s = str()
for i in range(len(mozi)):
  s += str("x")
print(s)

Buggy submission (verdict: Runtime Error):
mozi = str(input())
s = str(x)
for i in range(len(mozi)):
  s += "x"
print(s)

Buggy submission (verdict: Runtime Error):
mozi = str(input())
for i in mozi:
  i == chr(x)
  print(i)
Problem p02783 (python)

Fixed submission:
A,B = map(int,input().split())
C=A/B
if(C>int(A/B)):
  D=int(A/B)+1
else:
  D=int(A/B)
print(D)

Buggy submission (verdict: Runtime Error):
A,B map(int,input().split())
print(int(A/B))
Problem p02801 (python)

Fixed submission:
A=ord(input())
print(chr(A+1))

Buggy submission (verdict: Runtime Error):
A=chr(input())
print(chr(B+1))

Buggy submission (verdict: Runtime Error):
A=int(input())
print(chr(B+1))

Buggy submission (verdict: Runtime Error):
A=int(input())
B=chr(A+1)
print("" + B)

Buggy submission (verdict: Runtime Error):
A=int(input())
print("A+1")
Problem p02885 (python)

Fixed submission:
a,b = map(int,input().split())
if a<=b*2:
  print(0)
else:
  print(a-b*2)

Buggy submission (verdict: Runtime Error):
    a,b = map(int,input().split())
     
    if a >= b*2:
        print(a-b*2)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
    a,b = map(int,input().split())
     
    if a >= b*2:
        print(a-b*2)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
    a,b = map(int,input().split())
     
    if a >= b*2:
        print(a-b*2)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = 2*b
if a>c:
  print(a-c)
elif a<c:
  print(0)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = 2*b
if a>c:
  print(a-c)
elif a<c:
  print(0)
Problem p02945 (python)

Fixed submission:
a,b=map(int,input().split())
pl = a+b
di = a-b
mu = a*b
if pl>=di and pl>=mu:
    print(pl)
elif di>=pl and di>=mu:
    print(di)
else:
    print(mu)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
pl = a+b
di = a-b
mu = a*b
if pl>di and pl>mu:
    print(pl)
elif di>pl and di>mu:
    print(di)
else mu>di and mu>pl:
    print(mu)
Problem p02843 (python)

Fixed submission:
n=int(input())
#下２桁を実現させる最小個数を考えよう
l=[0]
for i in range(1,100):
  num=i
  l.append((num-1)//5+1)
w=str(n)
if n<100:
  print(0)
else:
  num=int(w[-2]+w[-1])
  index=l[num]
  if n<index*100+num:
    print(0)
  else:
    print(1)

Buggy submission (verdict: Runtime Error):
n=int(input())
boo=[0 for i in range(10**5+1)]
boo[100]=1
boo[101]=1
boo[102]=1
boo[103]=1
boo[104]=1
boo[105]=1
for i in range(100,n+1):
  if boo[i]==1:
    for j in range(6):
      boo[i+100+j]=1
if boo[n]:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
n=int(input())
boo=[0 for i in range(10**5+1)]
boo[100]=1
boo[101]=1
boo[102]=1
boo[103]=1
boo[104]=1
for i in range(100,n+1):
  if boo[i]==1:
    for j in range(6):
      boo[i+100+j]=1
if boo[n]:
  print(1)
else:
  print(0)
Problem p02850 (python)

Fixed submission:
n=int(input())
l=[]
import sys
sys.setrecursionlimit(20000000)
from collections import defaultdict
d=defaultdict(lambda:defaultdict(int))
l1=[[] for i in range(n+1)]
#d=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  l1[a].append(b)
  l1[b].append(a)
  l.append([a,b])
max1=0
for i in l1:
  if max1<len(i):
    max1=len(i)
def dfs(x,y):#xは頂点yは入ってくる色
  l2=l1[x]
  now=1
  for i in range(len(l2)):
    if d[x][l2[i]]!=0:
      pass
    else:                
      if now==y:
        now+=1
      d[x][l2[i]]=now
      d[l2[i]][x]=now
      dfs(l2[i],now)
      now+=1
print(max1)
dfs(1,0)
for i in range(len(l)):
  print(d[l[i][0]][l[i][1]])

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
from collections import defaultdict
d=defaultdict(lambda:defaultdict(int))
l1=[[] for i in range(n+1)]
#d=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  l1[a].append(b)
  l1[b].append(a)
  l.append([a,b])
max1=0
for i in l1:
  if max1<len(i):
    max1=len(i)
def dfs(x,y):#xは頂点yは入ってくる色
  l2=l1[x]
  now=1
  for i in range(len(l2)):
    if d[x][l2[i]]!=0:
      pass
    else:                
      if now==y:
        now+=1
      d[x][l2[i]]=now
      d[l2[i]][x]=now
      dfs(l2[i],now)
      now+=1
print(max1)
dfs(1,0)
for i in range(len(l)):
  print(d[l[i][0]][l[i][1]])
Problem p02888 (python)

Fixed submission:
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
count=0
for i in range(n-2):
  for j in range(i+1,n-1):
    index=bisect.bisect_left(l,l[i]+l[j])
    count+=index-j-1
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=sorted(list(map(int,input().split())))
import bisect
count=0
for i in range(n-1):
  for j in range(1,n):
    if i==j:
      pass
    else:
      left=bisect.bisect_left(abs(l[i]-l[j]))
      right=bisect.bisect_right(l[i]+l[j])
      count+=right-left
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=sorted(list(map(int,input().split())))
count=0
def nibutan(s,g,num):
  while True:
    low=s
    high=g-1
    mid=(low+high)/2
    num1=l[mid]
    if num<=l[mid] and l[mid-1]<num:
      return mid
    elif l[mid-1]>num:
      low=mid+1
    elif l[mid]<num:
      high=mid-1
    else:
      return mid-1    
for i in range(n-2):
  for j in range(i+1,n-1):
    if l[i]+l[j]<=l[n-1]:
      pass
    else:
Problem p02917 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l1=[0 for i in range(n)]
l1[0]=l[0]
l1[1]=l[0]
for i in range(0,n-2):
  if l[i]>l[i+1]:
    l1[i+1]=l[i+1]
  l1[i+2]=l[i+1]
sum=0
for i in l1:
  sum+=i
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
l1=[0 for i in range(n)]
l1[0]=l[0]
l1[1]=l[1]
for i in range(1,n-2):
  if l[i]>l[i+1]:
    l1[i]=l[i+1]
  l1[i+1]=l[i+1]
sum=0
for i in l1:
  sum+=i
print(sum)
Problem p02918 (python)

Fixed submission:
n,k=map(int,input().split())
l=list(input())
s=l[0]
m=0
c=1
for i in range(1,n):
  if l[i]!=s:
    c+=1
    s=l[i]
if c//2<=k:
  print(n-1)
else:
  for i in range(1,n-1):
    if l[i]=="R":
      if l[i+1]=="R":
        m+=1
    if l[i]=="L":
      if l[i-1]=="L":
        m+=1
  if l[0]=="R" and l[0]==l[1]:
    m+=1
  if l[-1]=="L" and l[-2]==l[-1]:
    m+=1
  print(m+k*2)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(input())
m=0
for i in range(1,n-1):
  if l[i]=="R":
    if l[i+1]=="R":
      m+=1
  if l[i]=="L":
    if l[i-1]=="L":
      m+=1
if l[0]=="R" and l[0]==l[1]:
  m+=1
if l[-1]=="L" and l[-2]==l[-1]:
  m+=1
print(min(m+k*2,n-1))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(input())
s=l[0]
m=0
c=0
for i in range(1,n):
  if l[i]!=s:
    c+=1
    s=l[i]
if (c%2==0 and c//2<=k):
  print(n-1)
if (c%2==1 and c//2<k):
  print(n-1)
else:
  for i in range(1,n-1):
    if l[i]=="R" and l[i-1]=="R":
      m+=1   
    elif l[i]=="R" and l[i-1]=="L":
      pass
    elif l[i]=="L" and l[i-1]=="R":
      pass
    else:
      m+=1
  if l[-1]==l[-2] and l[-2]=="R":
    m+=1
  elif l[-1]==l[-2] and l[-2]=="L":
    m+=1
  print(m+k*2)