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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]
count = [0]*((10**5)+100)
for i in range(len(A)):
  count[A[i]] += 1
sumA = sum(A)
for q in range(Q):
  count[BC[q][1]] += count[BC[q][0]]
  sumA += (BC[q][1] - BC[q][0])*count[BC[q][0]]
  print(sumA)
  count[BC[q][0]] = 0

Buggy submission (verdict: Runtime Error):
import bisect
N = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = list()
sum_a = 0
output = 0
cnt = 0
for i in range(q):
  bc.append(list(map(int,input().split())))
a.sort()
for i in range(q):
  flag = False
  nn = a.index(bc[i][0])
  for j in range(nn-1, len(a)):
    if a[j] == bc[i][0]:
      a[j] = bc[i][1]
      flag = True
    else:
      if flag == True:
        break
  print(sum(a))
  a.sort()
Problem p02658 (python)

Fixed submission:
import sys
N = int(input())
A = list(map(int,input().split()))
A.sort()
mul = A[0]
for i in range(1,N):
  mul *= A[i]
  if mul > 10**18:
    print(-1)
    sys.exit()
print(mul)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
#output = np.prod(A)
AA=1
for i in range(N+1):
  #print(A[i])
  AA = AA * A[i]
a = pow(10,18)
print(AA if abs(AA) <= a else -1)
Problem p02664 (python)

Fixed submission:
T = input()
print(T.replace('?', 'D'))

Buggy submission (verdict: Runtime Error):
S_split = input().split('?')
n = len(S_split) - 1
s = ''
output = ''
large = 0
count = 0
for i in range(2**n):
    s = S_split[0]
    for j in range(n):
        if ((i >> j) & 1) == 1:
          if s[-1] == 'P':
            break
          s = s + 'P' + S_split[j+1]
        else:
          s = s + 'D' + S_split[j+1]
    count = s.count('D') + s.count('PD')
    if  count >= large:
      large = count
      output = s
print(output)
Problem p02817 (python)

Fixed submission:
S,T=input().split()
print(T+S)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int,input().split())
  for _ in range(K):
    if A >= 1:
      A -= 1
    elif B >= 1:
      B -= 1
    else:
      break
print(A,B)
Problem p02818 (python)

Fixed submission:
a,b,c = map(int, input().split())
if a<=c:
    if b<=c-a:
        print('0 0')
    else:
        print('0 {}'.format(a+b-c))
else:
    print('{} {}'.format(a-c,b))

Buggy submission (verdict: Runtime Error):
A, B, K = map(int,input().split())
if  A+B >= K
  print(0,0)
else:
  for _ in range(K):
    if A != 0:
      A = A - 1
    elif B != 0:
      B = B - 1
    else:
      break
  print(A,B)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int,input().split())
  for _ in range(K):
    if A >= 1:
      A -= 1
    elif B >= 1:
      B -= 1
    else:
      break
print(A,B)
Problem p02861 (python)

Fixed submission:
import itertools
import math
N = int(input())
xy = []
for count in range(N):
    xy.append(input().split())
    itertools.permutations(xy)
XY = []
sum = 0
ave = 0
count = 0
for XY in itertools.permutations(xy):
    for i in range(N-1):
        leng = math.sqrt(((int(XY[i+1][0]) - int(XY[i][0])) ** 2) +
                         ((int(XY[i + 1][1]) - int(XY[i][1])) ** 2))
        sum += leng

ave = sum / math.factorial(N)
print(ave)

Buggy submission (verdict: Runtime Error):

N = int(input())
xy = []
for count in range(N):
    xy.append(input().split())
    itertools.permutations(xy)
XY = []
sum = 0
ave = 0
count = 0
for XY in itertools.permutations(xy):
    for i in range(N-1):
        leng = math.sqrt(((int(XY[i+1][0]) - int(XY[i][0])) ** 2) +
                         ((int(XY[i + 1][1]) - int(XY[i][1])) ** 2))
        sum += leng

ave = sum / math.factorial(N)
print(ave)
Problem p02909 (python)

Fixed submission:
S = input()
weather = ['Sunny', 'Cloudy','Rainy']
if S == weather[0]:
  print(weather[1])
elif S == weather[1]:
  print(weather[2])
else:
  print(weather[0])

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(M):
  max_item = A.index(max(A))
  A[max_item] //= 2
print(sum(A))
Problem p03160 (python)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
cost = [10**9]*N
cost[0] = 0
cost[1] = abs(h[1]-h[0])
for i in range(2, N):
  cost[i] = min((abs(h[i-1] - h[i]) + cost[i-1]),cost[i])
  cost[i] = min((abs(h[i-2] - h[i]) + cost[i-2]), cost[i])
print(cost[-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
cost = [1000000]*N
cost[0] = 0
cost[1] = abs(h([1]-h[0])
for i in range(2, N):
  cost[i] = min((abs(h[i-1] - h[i]) + cost[i-1]),cost[i])
  cost[i] = min((abs(h[i-2] - h[i]) + cost[i-2]), cost[i])
print(cost[-1])

Buggy submission (verdict: Runtime Error):
6
30 10 60 10 60 50
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A+B)

Buggy submission (verdict: Runtime Error):
print(int(input()) + int(input()) if int(input()) == 2 else "Hello World
")

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 1:
  print('Hello World')
elif:
  A,B = int(input())
  print(A+B)
Problem p03239 (python)

Fixed submission:
N,T = map(int,input().split())
c = 0
for _ in range(N):
  _c, _t = map(int,input().split())
  if _t <= T:
    if c == 0:
      c = _c
    elif c != 0 and _c <= c:
      c = _c
print(c if c != 0 else "TLE")

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
ct = list()
for _ in range(N):
  s, t = map(int,i)nput().split
  if t <= T:
    ct.append(s, t)
#ct = [input().split() for _ in range(N)]
Problem p02615 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
c = a[-1]
if n%2 == 0:
  n1 = n//2-1
  for i in range(n1):
    a1 = a[n-2-i]
    c += a1*2
else:
  n2 = n//2
  a3 = a[n-n2-1]
  c += a3
  for i in range(n2-1):
    a2 = a[n-2-i]
    c += a2*2
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map,(int,input().split()))
a.sort()
c = int(a[-1])
if n%2 == 0:
  n1 = n//2-1
  for i in range(n1):
    a1 = int(a[n-2-i])
    c += a1*2
else:
  n2 = n//2
  a3 = int(a[n-n2-1])
  c += a3
  for i in range(n2-1):
    a2 = int(a[n-2-i])
    c += a2*2
print(c)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans = 1
for i in range(n):
  ans *= a[i]
  if 10**18 < int(ans):
    print(-1)
  else:
  	print(ans)
Problem p02675 (python)

Fixed submission:
l = input()
s = [int(i) for i in l]
l1 = len(l)
l2 = l[int(l1) - 1]
if int(l2) == 3:
  print("bon")
elif int(l2) == 0:
  print("pon")
elif int(l2) == 1:
  print("pon")
elif int(l2) == 6:
  print("pon")
elif int(l2) == 8:
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
from math import cos, radians, sqrt
 
a,b,h,m = map(int, input().split())
h1 = h * 30
m1 = m * 5.5
r = abs(h1 - m1)
a1 = a ** 2
b1 = b ** 2
ab = a * b
if 180 <= int(r):
  r1 = 360 - int(r)
else:
  r1 = r
cos = cos(radians(r1))
d = int(a1) + int(b1) - 2 * int(ab) * float(cos)
ans = d ** (1/2)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
 
a,b,h,m = map(int, input().split())
h1 = int(h) * 30
m1 = int(m) * 5.5
r = abs(float(h1) - float(m1))
a1 = int(a) ** 2
b1 = int(b) ** 2
ab = int(a) * int(b)
if 180 <= int(r):
  r1 = int(r) -180
else:
  r1 = r
cos = math.cos(math.radians(int(r1)))
d = int(a1) + int(b1) - 2 * int(ab) * float(cos)
ans = d ** (1/2)
print(ans)
Problem p02677 (python)

Fixed submission:
import math
 
a,b,h,m = map(int, input().split())
h1 = h * 30
m1 = m * 5.5
r = abs(h1 - m1)
a1 = a ** 2
b1 = b ** 2
ab = a * b
if r == 0:
  print(abs(a-b))
elif r == 180:
  print(a + b)
elif 180 < r:
  r1 = 360 - r
  cos = math.cos(math.radians(r1))
  d = a1 + b1 - 2 * ab * cos
  ans = d ** (1/2)
  print(ans)
else:
  cos = math.cos(math.radians(r))
  d = a1 + b1 - 2 * ab * cos
  ans = d ** (1/2)
  print(ans)

Buggy submission (verdict: Runtime Error):
import math
 
a,b,h,m = map(int, input().split())
h1 = h * 30
m1 = m * 5.5
r = abs(h1 - m1)
a1 = a ** 2
b1 = b ** 2
ab = a * b
if r == 0:
  print(abs(a-b))
elif r == 180:
  print(a + b)
elif 180 < r:
  	r1 = r -180
    cos = math.cos(math.radians(r1))
 	d = a1 + b1 - 2 * ab * cos
  	ans = d ** (1/2)
  	print(ans)
else:
  cos = math.cos(math.radians(r))
  d = a1 + b1 - 2 * ab * cos
  ans = d ** (1/2)
  print(ans)
Problem p02687 (python)

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

Buggy submission (verdict: Runtime Error):
list = ['ABC','ARC']
if s == 'ABC':
	print(list[1])
else:
  print(list[0])
Problem p02922 (python)

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

i = a
c = 1
while int(i) < int(b):
  i += int(a) - 1
  c += 1
if int(b) == 1:
  print(0)
else:
  print(c)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().spit())
i = a
c = 1
while i < b:
  i += a - 1
  c += 1
if b == 1:
  print(0)
else:
  print(c)
Problem p03447 (python)

Fixed submission:
s = [int(input()) for i in range(3)]
n = s[0]
a = s[1]
b = s[2]
c = n-a
d = int(c/b)
print(c-b*d)

Buggy submission (verdict: Runtime Error):
s = [int(input()) for i in range(3)]
n = s[0]
a = n[1]
b = n[2]
c = n-a
d = int(c/b)
print(c-b*d)
Problem p02582 (python)

Fixed submission:


L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS':
	print(1)
elif L[0] =='RSS':
	print(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)

Buggy submission (verdict: Runtime Error):


L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS':
	prinrt(1)
elif L[0] =='RSS':
	print(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)

Buggy submission (verdict: Runtime Error):


L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS' or L[0] == 'RSS':
	prinrt(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)

Buggy submission (verdict: Runtime Error):


L = []
 
for i in range(3):
	L.append(input())
 
    
c=0
ans=0
 
for i in range(3):
	if L[i] == 'R':
     		 if c != 0:
        			ans = 1
	else:
      		ans += 1

	if L[i] == 'S':
      		c += 1
      
print(ans)

Buggy submission (verdict: Runtime Error):
L = []

for i in range(3):
	L.append(input())

    
c=0
ans=0

for i in range(3):
	if L[i] == 'R':
      if c !=0:
        ans = 1
      else:
      	ans += 1
    if L[i] == 'S':
      c += 1
      
print(ans)
Problem p02584 (python)

Fixed submission:

A = input().split()
X = float(A[0])
K = int(A[1])
D = int(A[2])

if abs(X) - K * D > 0:
	print(int(abs(X) - K*D))
else:
	K2 = abs(X)//D
	if (K - K2) % 2 == 0:
		print(int(abs(abs(X) - D * K2)))
	else:
		print(int(abs(abs(abs(X) - D * K2) - D)))

Buggy submission (verdict: Runtime Error):

L = input()
L2 = L.split()

X = float(L2[0]) #float
K = int(L2[1])
D = int(L2[2])

A = [0]*(K+1)
A[0] = X

for i in range(1,K+1):
	if A[i-1]>0:
		A[i] = A[i-1] - D
	else:
		A[i] = A[i-1] +D

if A[K] > 0:
	print(int(A[K]))
else:
	print(int(-1 *A[K]))
Problem p02588 (python)

Fixed submission:
from math import gcd
from collections import Counter
import sys

N = int(input())
K = 10**9
L = 10**18
A = [0] * N
C = Counter()
ans = 0

for i in range(N):
	A[i] = round(K * float(input()))
	C[gcd(A[i],L)] += 1 
	
for k1,v1 in C.items():
	for k2 ,v2 in C.items():
		if k1 == k2:
			if k1*k2 % L == 0:
				ans += v1*(v1-1)/2
		elif k1 < k2:
			if k1*k2 % L == 0:
				ans += v1 * v2

print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import gcd
from collections import Counter
import sys

N = int(input())
K = 10**9
L = 10**18
A = [0] * N
C = Counter()
ans = 0

for i in range(N):
	A[i] = round(K * float(input()))
	C[gcd(A[i],L)] += 1 #辞書型だから[]内のkeyに対応するvalueの値を+1している。ここでは10^9-nの値をCに加えていっている。
	
for k1,v1 in C.items():
	for k2 ,v2 in C.items():
		if k1 == k2:
			if k1*k2 % L == 0:
				ans += v1*(v1-1)/2
		elif k1 < k2:
			if k1*k2 % L == 0:
				ans += v1 * v2

int(print(ans))
Problem p02647 (python)

Fixed submission:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,50)):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))

Buggy submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,2*(math.log2(N))+1)):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))

Buggy submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,2*(math.log2(N)+1))):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))
Problem p02660 (python)

Fixed submission:
import math
import sys
N = int(input())
temp = N
arr = []
if N == 1:
  print('0')
  sys.exit()
for i in range(2,int(-(-N**0.5//1))+1):
	if temp % i==0:
		cnt = 0
		while temp%i==0:
			cnt+=1
			temp//=i
		arr.append([i,cnt])
if temp!=1:
	arr.append([temp,1])
if arr == []:
	arr.append([n,1])
sum = 0
for i in range(len(arr)):
  p = arr[i][1]
  q = 1
  while p > 0:
    p -= q
    if p >= 0:
      sum += 1
      q += 1
print(sum)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
temp = N
arr = []
for i in range(2,int(-(-N**0.5//1))+1):
	if temp % i==0:
		cnt = 0
		while temp%i==0:
			cnt+=1
			temp//=i
		arr.append([i,cnt])
if temp!=1:
	arr.append([temp,1])
if arr == []:
	arr.append([n,1])
sum = 0
for i in range(len(arr)):
  p = arr[i][1]
  q = 1
  while p > 0:
    p -= q
    if p >= 0:
      sum += 1
      q += 1
print(sum)
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
N = len(T)
T2 = T[0:N-1]
if S == T2:
	print('Yes')
else:
	print('No')

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

for i in range(N):
	lines.append(list(map(int,input().split())))
pricemin = 1500000
for i in range(2**N):
	price = 0
	count = 0
	A = [0]*M
	for j in range(N):
		if ((i >> j) & 1):
			for k in range(M):
				A[k] += lines[j][k+1]
			price += lines[j][0]
	for j in range(M):
		if A[j] >= X:
			count += 1
	if count == M and pricemin > price:
		pricemin = price
if pricemin == 1500000:
	print('-1')
else:
	print(pricemin)

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

for i in range(N):
	lines.append(list(map(int,input().split())))
pricemin = 1000000
for i in range(2**N):
	price = 0
	count = 0
	A = [0]*M
	for j in range(N):
		if ((i >> j) & 1):
			for k in range(M):
				A[k] += lines[j][k+1]
			price += lines[j][0]
	for j in range(M):
		if A[j] >= X:
			count += 1
	if count == M and pricemin > price:
		pricemin = price
if pricemin == 1000000:
	print('-1')
else:
	print(pricemin)

Buggy submission (verdict: Runtime Error):
A, B, C, K = list(map(int,input().split()))
count = 0
s = 0
if A > K:
	print(K)
elif A+B > K:
	print(A)
else:
	print(2*A + B - K)

Buggy submission (verdict: Runtime Error):
A, B, C, K = list(map(int,input().split()))
count = 0
s = 0
while K > 0:
	if count < A:
		s += 1
	elif count >= A+B:
		s -= 1
	K -= 1
	count += 1
print(s)
Problem p02684 (python)

Fixed submission:
import sys
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
p = 1
B = [-1]*N
B[0] = 0
count = 1
while K >= count:
	p = A[p-1]
	if B[p-1] != -1:
		break
	B[p-1] = count
	count += 1
if K < count:
	print(p)
	sys.exit()
K -= count
K = K % (count-B[p-1])
for i in range(K):
	p = A[p-1]
print(p)

Buggy submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
p = 1
B = [-1]*N
B[0] = 0
count = 1
while K < count :
	p = A[p-1]
	if B[p-1] != -1:
		break
	B[p-1] = count
	count += 1
if K < count:
	print(p)
	return
K -= count
K = K % (count-B[p-1])
for i in range(K):
	p = A[p-1]
print(p)
Problem p02582 (python)

Fixed submission:
S = input()

if S == "SSS":
    cnt = 0
elif S == "RRR":
    cnt = 3
elif "RR" in S:
    cnt = 2
else:
    cnt = 1
    
print(cnt)

Buggy submission (verdict: Runtime Error):
S=input()
print(max(i for i in range(4)if S.index("R"*i)))
Problem p02675 (python)

Fixed submission:

str = input()
h = list(str)#文字列をリストに

if(h[-1]=='2' or h[-1]=='4' or h[-1]=='5' or h[-1]=='7' or h[-1]=='9'):
    print('hon')
elif(h[-1]=='0' or h[-1]=='1' or h[-1]=='6' or h[-1]=='8'):
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
n = int(input())
nlis = list(map(int, input().split())) # list()でリスト化、それを変数に代入。

if nlis[-1] == 2 or nlis[-1] == 4 or nlis[-1] == 5 or nlis[-1] == 7 or nlis[-1] == 9:
    print('hon')
elif nlis[-1] == 0 or nlis[-1] == 1 or nlis[-1] == 6 or nlis[-1] == 8:
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
#一行で入力された数値をリストに

if(h[-1]==2 or h[-1]==4 or h[-1]==5 or h[-1]==7 or h[-1]==9):
    print('hon')
elif(h[-1]==0 or h[-1]==1 or h[-1]==6 or h[-1]==8):
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
#一行で入力された数値をリストに

if(h[-1]==2 or h[-1]==4 or h[-1]==5 or h[-1]==7 or h[-1]==9):
    print("hon")
elif(h[-1]==0 or h[-1]==1 or h[-1]==6 or h[-1]==8):
    print("pon")
else:
    print("bon")

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
#一行で入力された数値をリストに

if(h[-1]==2 or h[-1]==4 or h[-1]==5 or h[-1]==7 or h[-1]==9):
    print("hon")
elif(h[-1]==0 or h[-1]==1 or h[-1]==6 or h[-1]==8):
    print("pon")
else:
    print("bon")
Problem p02918 (python)

Fixed submission:
n, k = (int(x) for x in input().split())
s = input()
happy = 0

if(s[0] == 'R' and s[1] == 'R'):
    happy = happy + 1
if(s[n-1] == 'L' and s[n-2] == 'L'):
    happy = happy + 1

for i in range(1,n-1):
    if(s[i] == 'R' and s[i+1] == 'R'):
        happy = happy + 1
    if(s[i] == 'L' and s[i-1] == 'L'):
        happy = happy + 1

happy = happy + 2*k
print(min(happy, n-1))

Buggy submission (verdict: Runtime Error):
n, k = (int(x) for x in input().split())
s = input()
happy = 0

if(s[0] == 'R' and s[1] == 'R'):
    happy = happy + 1
if(s[-1] == 'L' and s[-2] == 'L'):
    happy = happy + 1

for i in range(1,n-1):
    if(s[i] == 'R' and s[i+1] == 'R'):
        happy = happy + 1
    if(s[i] == 'L' and s[i-1] == 'L'):
        happy = happy + 1

happy = happy + 2*k
print(min(happy, n-1))

Buggy submission (verdict: Runtime Error):
n, k = (int(x) for x in input().split())
s = input()
happy = 0

if(s[0] == 'R' and s[1] == 'R'):
    happy = happy + 1
if(s[-1] == 'L' and s[-2] == 'L'):
    happy = happy + 1

for i in range(1,n-1):
    if(s[i] == 'R' and s[i+1] == 'R'):
        happy = happy + 1
    if(s[i] == 'L' and s[i-1] == 'L'):
        happy = happy + 1

happy = happy + 2*k
print(min(happy, n-1))
Problem p02945 (python)

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

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())
print(max([a+b,a-b,a*b]))
Problem p02947 (python)

Fixed submission:
import math
n = int(input())
lst = list()
num = 0
flag = 1
for i in range(n):

    s = input()
    s = list(s)
    s.sort()
    lst.append(s)

lst.sort()

for i in range(n-1):
    if (lst[i] == lst[i+1]):
        flag = flag + 1
    else:
        if (flag > 1):
            num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
        flag = 1
if (flag > 1):
    num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
print(num)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
lst = list()
num = 0
flag = 1
for i in range(n):

    s = input()
    s = list(s)
    s.sort()
    lst.append(s)

lst.sort()

for i in range(n-1):
    if (lst[i] == lst[i+1]):
        flag = flag + 1
    else:
        num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
        flag = 1
if (flag > 1):
    num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
print(num)
Problem p02957 (python)

Fixed submission:
a,b = input().split()
a=int(a)
b=int(b)
if (a+b)%2 != 0:
    print('IMPOSSIBLE')
else:
    print(int((a+b)/2))

Buggy submission (verdict: Runtime Error):
n = int(input())
n
a = list(map(int, input().split(' ')))#モンスター
b = list(map(int, input().split(' ')))#勇者
b.append(0)
beat = 0

for i in range(n):
    mada = b[i]-a[i]
    beat += min(b[i],a[i])
    if mada > 0:
        b[i+1] += mada
beat += min(a[-1],b[-1])

print(beat)
Problem p02645 (python)

Fixed submission:
import random
S = input()

A = random.randint(0, len(S) - 3)

print(S[A] + S[A + 1] + S[A + 2])

Buggy submission (verdict: Runtime Error):
import random
S = input()

A = random.randint(0, len(S) - 2)

print(S[A] + S[A + 1] + S[A + 2])
Problem p02719 (python)

Fixed submission:
import math

if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,K = int(s[0]), int(s[1])
    if(N>=K):
        #cand1 = int(abs(N - int(K*math.ceil(N/float(K)))))
        #cand2 = int(abs(N - int(K*math.floor(N/float(K)))))
        cand1 = int(N%K)
        cand2 = int(K-(N%K))
        print(min(cand1, cand2))
    else:
        print(min(int(abs(N-K)),N))

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,K = int(s[0]), int(s[1])
    cand1 = abs(N - K*math.ceil(N/float(K)))
    cand2 = abs(N - K*math.floor(N/float(K)))
    print(min(cand1, cand2))
Problem p03000 (python)

Fixed submission:
import numpy as np
N,X = map(int,input().split())
arr = list(map(int,input().split()))
sumarr = np.cumsum(arr)
print(len(sumarr[sumarr<=X])+1)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
arr = list(map(int,input().split()))
sumarr = np.cumsum(arr)
print(len(sumarr[sumarr<=X])+1)
Problem p03037 (python)

Fixed submission:
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N = int(s[0])
    M = int(s[1])
    L = []
    R = []
    for i in range(M):
        s = input().rstrip().split(' ')
        L.append(int(s[0]))
        R.append(int(s[1]))

    res = list(range(1,N+1))
    res_min = 1
    res_max = N

    for i in range(M):
        res_min = max(res_min,L[i])
        res_max = min(R[i],res_max)

    print(max(res_max-res_min+1,0))

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N = int(s[0])
    M = int(s[1])
    L = []
    R = []
    for i in range(M):
        s = input().rstrip().split(' ')
        L.append(int(s[0]))
        R.append(int(s[1]))

    res = list(range(1,N+1))

    for i in range(M):
        res = list(range(max(res[0],L[i]), min(R[i],res[-1])+1))

    print(len(res))
Problem p02576 (python)

Fixed submission:
N,X,T  = map(int, input().split())
a = N // X
if N % X ==0:
  print(a*T)
else:
	print((a+1)*T)

Buggy submission (verdict: Runtime Error):
N,X,T  = map(int, input().split())
a = N // X
if N % X ==0:
  pritn(a*T)
else:
	print((a+1)*T)