Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
n = int(raw_input())
li = map(int, raw_input().split())
li.sort(reverse=False)

count = 0

for i in xrange(n):
    for j in xrange(i+1,n):
        for k in xrange(j+1,n):
            if li[i] < li[j] + li[k] and li[j] < li[i] + li[k] and li[k] < li[i] + li[j]:
                count +=1
            else:
                break
print count

Fixed submission:
# coding: utf-8
n = int(raw_input())
L = map(int, raw_input().split())

#昇順にソート
L.sort()

ans = 0



for a in xrange(n-2):
	c = a + 2
	for b in xrange(a+1,n-1):
		while c < n and L[a] + L[b] > L[c]:
			c += 1
		if c > b:
			ans += (c-b-1)
print ans

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
n = int(raw_input())
li = map(int, raw_input().split())

count = 0

for i in xrange(n):
    for j in xrange(i+1,n):
        for k in xrange(j+1,n):
            if li[i] < li[j] + li[k] and li[j] < li[i] + li[k] and li[k] < li[i] + li[j]:
                count +=1
print count


Fixed submission:
# coding: utf-8
n = int(raw_input())
L = map(int, raw_input().split())

#昇順にソート
L.sort()

ans = 0



for a in xrange(n-2):
	c = a + 2
	for b in xrange(a+1,n-1):
		while c < n and L[a] + L[b] > L[c]:
			c += 1
		if c > b:
			ans += (c-b-1)
print ans
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from __future__ import print_function

n = int(raw_input())
li = map(int, raw_input().split())


for i in xrange(1,n+1):
    print(str(li.index(i) + 1) + " ", end="")


Fixed submission:
# coding: utf-8
n = int(raw_input())
li = map(int, raw_input().split())

listb = []
listb = sorted(range(len(li)), key=lambda k: li[k])

s = str(map(lambda x: x+1, listb))

print s.replace("[","").replace("]","").replace(",","")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from __future__ import print_function

n = int(raw_input())
li = map(int, raw_input().split())

for i in xrange(1,n+1):
    li[i-1] = li.index(i) +1
    
print(*li, sep=' ')


Fixed submission:
# coding: utf-8
n = int(raw_input())
li = map(int, raw_input().split())

listb = []
listb = sorted(range(len(li)), key=lambda k: li[k])

s = str(map(lambda x: x+1, listb))

print s.replace("[","").replace("]","").replace(",","")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(raw_input())
li = map(int, raw_input().split())

s = ""

for i in xrange(1,n+1):
    s += str(li.index(i) +1) + " "

print s

Fixed submission:
# coding: utf-8
n = int(raw_input())
li = map(int, raw_input().split())

listb = []
listb = sorted(range(len(li)), key=lambda k: li[k])

s = str(map(lambda x: x+1, listb))

print s.replace("[","").replace("]","").replace(",","")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def is_integer(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

a,b = map(int, raw_input().split())
sub = b - a

if a >= b:
	print 1
else:
	count = 1
	while True:
		count +=1
		if sub <= a-1:			
			break
		else:
			sub = sub - (a-1)
print count

Fixed submission:
# -*- coding: utf-8 -*-
a,b = map(int, raw_input().split())
tmp = a

if b == 1:
	print 0
elif a >= b:
	print 1
else:
	count = 1
	while True:
		count +=1
		tmp += (a - 1)
		if tmp >= b:
			print count
			break

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def is_integer(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

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

if a >= b:
	print 1
else:
	sub = b - a
if sub < a-1:
	print 2
else:
	div = sub/float(a-1)
  	print 1 + int(div)


Fixed submission:
# -*- coding: utf-8 -*-
a,b = map(int, raw_input().split())
tmp = a

if b == 1:
	print 0
elif a >= b:
	print 1
else:
	count = 1
	while True:
		count +=1
		tmp += (a - 1)
		if tmp >= b:
			print count
			break
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(raw_input())
li = map(int, raw_input().split())

ans = 0
tmp = 0

for i in xrange(N-1):
    if li[i] < li[i+1]
        tmp +=1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)

Fixed submission:
n = int(raw_input())
a = map(int, raw_input().split())
 
ans = 0
temp = 0
for i in xrange(n-1):
    if a[i] >= a[i+1]:
        temp = temp + 1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(raw_input())
li = map(int, raw_input().split())

move_max = 0
inext = -1

for i in xrange(N-1):
    if i <= inext:
        continue
    move = 0
    tmp = li[i]
    
    for j in xrange(i+1,N):
        if tmp >= li[j]:
            tmp = li[j]
            move += 1
    	else:
            inext = move
            break
    if move > move_max:
        move_max = move

print move_max


Fixed submission:
n = int(raw_input())
a = map(int, raw_input().split())
 
ans = 0
temp = 0
for i in xrange(n-1):
    if a[i] >= a[i+1]:
        temp = temp + 1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(raw_input())
li = map(int, raw_input().split())

move_max = 0
inext = 0

for i in xrange(N-1):
    move = 0
    if i < inext:
        continue
    tmp = li[i]
    
    for j in xrange(i+1,N):
        if tmp >= li[j]:
            tmp = li[j]
            move += 1
    	else:
            inext = move
            break
    if move > move_max:
        move_max = move

print move_max


Fixed submission:
n = int(raw_input())
a = map(int, raw_input().split())
 
ans = 0
temp = 0
for i in xrange(n-1):
    if a[i] >= a[i+1]:
        temp = temp + 1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(raw_input())
li = map(int, raw_input().split())

move_max = 0
tmp = 0

for i in xrange(N-1):
	move = 0
	tmp = li[i]
	for j in xrange(i+1,N):
		if tmp >= li[j]:
			tmp = li[j]
			move += 1
		else:
			break
	if move > move_max:
		move_max = move

print move_max

Fixed submission:
n = int(raw_input())
a = map(int, raw_input().split())
 
ans = 0
temp = 0
for i in xrange(n-1):
    if a[i] >= a[i+1]:
        temp = temp + 1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(raw_input())
li = map(int, raw_input().split())

move_max = 0
tmp = 0

for i in xrange(N):
	move = 0
	tmp = li[i]
	for j in xrange(i+1,N):
		if tmp >= li[j]:
			tmp = li[j]
			move += 1
		else:
			break
	if move > move_max:
		move_max = move

print move_max

Fixed submission:
n = int(raw_input())
a = map(int, raw_input().split())
 
ans = 0
temp = 0
for i in xrange(n-1):
    if a[i] >= a[i+1]:
        temp = temp + 1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(raw_input())
# スペース区切りの整数の入力
a, b = map(int, raw_input().split())

mylist = [a+b,a-b,a*b]
print max(mylist)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a, b = map(int, raw_input().split())

mylist = [a+b,a-b,a*b]
print max(mylist)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
x, k = map(int, raw_input().split())

for i in range(x-(k-1),x+k):
    print (str(i) + " " ,end="")

Fixed submission:
# -*- coding: utf-8 -*-
from __future__ import print_function
 
k, x = map(int, raw_input().split())
 
for i in range(x-(k-1),x+k):
    print (str(i) + " " ,end="")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import collections

N = int(raw_input())
li = list(map(int, input().split()))

for i in range(N):
    sl.append("".join(sorted(li[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))

Fixed submission:
# -*- coding: utf-8 -*-
N = int(raw_input())
cnt = 0
dic = {}

for _ in xrange(N):
	rs = ''.join(sorted(raw_input()))
	
	if rs in dic:
		cnt += dic[rs]
		dic[rs] += 1
	else:
		dic[rs] = 1
print cnt

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(raw_input())
li = list(map(int, input().split()))

for i in range(N):
    sl.append("".join(sorted(li[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))

Fixed submission:
# -*- coding: utf-8 -*-
N = int(raw_input())
cnt = 0
dic = {}

for _ in xrange(N):
	rs = ''.join(sorted(raw_input()))
	
	if rs in dic:
		cnt += dic[rs]
		dic[rs] += 1
	else:
		dic[rs] = 1
print cnt

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(raw_input())
li = list(map(int, input().split()))

for i in range(n):
    sl.append("".join(sorted(li[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))

Fixed submission:
# -*- coding: utf-8 -*-
N = int(raw_input())
cnt = 0
dic = {}

for _ in xrange(N):
	rs = ''.join(sorted(raw_input()))
	
	if rs in dic:
		cnt += dic[rs]
		dic[rs] += 1
	else:
		dic[rs] = 1
print cnt

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(raw_input())
li = list(map(int, input().split()))

for i in range(n):
    sl.append("".join(sorted(list[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))

Fixed submission:
# -*- coding: utf-8 -*-
N = int(raw_input())
cnt = 0
dic = {}

for _ in xrange(N):
	rs = ''.join(sorted(raw_input()))
	
	if rs in dic:
		cnt += dic[rs]
		dic[rs] += 1
	else:
		dic[rs] = 1
print cnt

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(raw_input())
li = list(map(int, input().split()))

for i in range(N):
    sl.append("".join(sorted(list[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))

Fixed submission:
# -*- coding: utf-8 -*-
N = int(raw_input())
cnt = 0
dic = {}

for _ in xrange(N):
	rs = ''.join(sorted(raw_input()))
	
	if rs in dic:
		cnt += dic[rs]
		dic[rs] += 1
	else:
		dic[rs] = 1
print cnt
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, raw_input().split())

# box1 の許容容量
tmp = a - b
rest = c - tmp

print rest

Fixed submission:
# -*- coding: utf-8 -*-
a,b,c = map(int, raw_input().split())

# box1 の許容容量
tmp = a - b
rest = c - tmp

if rest >= 0:
    print rest
else:
    print 0
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())

#正解者順リスト
al = [int(input()) for i in range(q)]

#このリストのindex+1が参加者ナンバーです
#みんなの持ち点
nl = []
for m in range(n):
    nl.append(k)

for r in range(q):
    for x in range(n):
        nl[x] = nl[x]-1
#とりあえず全員、全正解数＊-1点する作業

for y in al:
    nl[y-1] = nl[y-1]+1

for z in nl:
    if z > 0:
        print('Yes')
    else:
        print('No')


Fixed submission:
n, k, q = map(int, input().split())

#正解者順リスト
al = [int(input()) for i in range(q)]

#このリストのindex+1が参加者ナンバーです
#みんなの持ち点
nl = []
for m in range(n):
    nl.append(k-q)

for y in al:
    nl[y-1] = nl[y-1]+1

for z in nl:
    if z > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()

if a < 3200:
  print('red')
 else:
  print(s)

Fixed submission:
a = int(input())
s = input()
 
if a < 3200:
  print('red')
else:
  print(s)
Buggy python submission (verdict: Runtime Error):
r = map(int, input())
print(3 * r * r)

Fixed submission:
r = input()
r = int(r)
print(3 * r * r)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

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

if a >= 13:
    print(b)
elif a >= 6:
    print(int(b/2))
else:
    print(0)


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

if a >= 13:
    print(b)
elif a >= 6:
    print(int(b/2))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
r, d, x = map(int, input().split())

for i in range(10):
    x = r*x-d
    print(xi)


Fixed submission:
r, d, x = map(int, input().split())

for i in range(10):
    x = r*x-d
    print(x)
Buggy python submission (verdict: Runtime Error):
n = int(input())
total = 0

for i in range(n):
  x_temp, u_temp = map(int, input())
  if u_temp = 'BTC':
    x_temp *= 380000.0
  total += x_temp
  
print(total)

Fixed submission:
n = int(input())
total = 0

for i in range(n):
  x_temp, u_temp = input().split()
  x_temp = float(x_temp)
  if u_temp == 'BTC':
    x_temp *= 380000.0
  total += x_temp
  
print(total)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a <= 8 and b <= 8:
  print('Yay!')
else:
  prit(':(')

Fixed submission:
a, b = map(int, input().split())
if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

if a+b <= c:
  print('Yes')
else:
  priny('No')

Fixed submission:
a, b, c = map(int, input().split())
 
if a+b >= c:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
x, a, b = map(int, input().split())
ax = abs(a-x)
bx = abs(b-x)
if ax > bx:
  print(B)
else:
  print(A)

Fixed submission:
x, a, b = map(int, input().split())
ax = abs(a-x)
bx = abs(b-x)
if ax > bx:
  print('B')
else:
  print('A')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = a + b

if a%3 == 0 or b%3 == 0 or s%3 == 0:
  print('Possible')
else:
  print('Impossible)

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

if a%3 == 0 or b%3 == 0 or s%3 == 0:
  print('Possible')
else:
  print('Impossible')
Buggy python submission (verdict: Runtime Error):
r, g, b = input()
rgb = int(r+g+b)
if rgb % 4 == 0:
  print('YES')
else:
  print('NO')

Fixed submission:
r, g, b = input().split()
rgb = int(r+g+b)
if rgb % 4 == 0:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
a, op, b = input().split()
a = int(a)
b = int(b)
if op = '+':
  print(a + b)
else:
  print(a - b)

Fixed submission:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == '+':
  print(a + b)
else:
  print(a - b)
Buggy python submission (verdict: Runtime Error):
import sys

n = int(input())
s = str(input())

if n == 1:
    if s[0] == s[1]:
        print(2)
    else:
        print(1)
    sys.exit()

count = 0
i = 0
while i < n - 1:
    if s[i] == s[i + 1]:
        count = count + 1
    i = i + 1

ans = n - count
print(ans)

Fixed submission:
n = int(input())
s = str(input())
count = 0

for i in range(n - 1):
    if s[i] == s[i + 1]:
        count = count + 1

print(n - count)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

I = 0
J = 0
now = 0
mod = 2019

for i in range(R-L):
    if(L+i % 2019 == 0):
        mod = 0
        break
    for j in range(R-L-i):
        if (L + i + j + 1 % 2019 == 0):
            mod = 0
            break
        I = L + i
        J = L + i + j + 1
        now = (I * J) % 2019
        if(now < mod):
            mod = now
        if(mod == 0):
            break


print(mod)





Fixed submission:
L, R = map(int, input().split())

I = 0
J = 0
now = 0
mod = 2019

end = 0

for i in range(R-L):
    if(L+i % 2019 == 0 or end == 1):
        mod = 0
        break
    for j in range(R-L-i):
        if (L + i + j + 1 % 2019 == 0):
            mod = 0
            break
        I = L + i
        J = L + i + j + 1
        now = (I * J) % 2019
        if(now < mod):
            mod = now
        if(mod == 0):
            end += 1
            break

print(mod)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

I = 0
J = 0
now = 0
mod = 2019
for i in range(R-L):
    for j in range(R-L-i):
        I = L + i
        J = L + i + j + 1
        now = (I * J) % 2019
        if(now < mod):
            mod = now

print(mod)



Fixed submission:
L, R = map(int, input().split())

I = 0
J = 0
now = 0
mod = 2019

end = 0

for i in range(R-L):
    if(L+i % 2019 == 0 or end == 1):
        mod = 0
        break
    for j in range(R-L-i):
        if (L + i + j + 1 % 2019 == 0):
            mod = 0
            break
        I = L + i
        J = L + i + j + 1
        now = (I * J) % 2019
        if(now < mod):
            mod = now
        if(mod == 0):
            end += 1
            break

print(mod)
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int, input().split())

# n_c = 0
# n_d = 0
# n_cd = 0
# for i in range(A,B+1):
#     if(i % C == 0):
#         n_c = i // C
#     n_d = i // D
#     n_cd = i//(C*D)

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

n_c = B//C - A//C
n_d = B//D - A//D
CD = lcm(C,D)
n_cd = B//(CD) - A//(CD)

if(A%C == 0):
    n_c += 1
if(A%D==0):
    n_d += 1
if(A%CD==0):
    n_cd += 1


if (max(C,D)%min(C,D) == 0):
    ans = (B-A+1) - max(n_c, n_d)
else:
    ans = (B-A + 1) - (n_c + n_d - n_cd)

# print(n_c)
# print(n_d)
# print(n_cd)

print(ans)




Fixed submission:
import fractions
A,B,C,D = map(int, input().split())

# n_c = 0
# n_d = 0
# n_cd = 0
# for i in range(A,B+1):
#     if(i % C == 0):
#         n_c = i // C
#     n_d = i // D
#     n_cd = i//(C*D)

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

n_c = B//C - A//C
n_d = B//D - A//D
CD = lcm(C,D)
n_cd = B//(CD) - A//(CD)

if(A%C == 0):
    n_c += 1
if(A%D==0):
    n_d += 1
if(A%CD==0):
    n_cd += 1


if (max(C,D)%min(C,D) == 0):
    ans = (B-A+1) - max(n_c, n_d)
else:
    ans = (B-A + 1) - (n_c + n_d - n_cd)

# print(n_c)
# print(n_d)
# print(n_cd)

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int, input().split())

n_c = 0
n_d = 0
n_cd = 0
# for i in range(A,B+1):
#     if(i % C == 0):
#         n_c = i // C
#     n_d = i // D
#     n_cd = i//(C*D)

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

n_c = B//C - A//C
n_d = B//D - A//D
CD = lcm(C,D)
n_cd = B//(CD) - A//(CD)

if(A%C == 0):
    n_c += 1
if(A%D==0):
    n_d += 1
if(A%CD==0):
    n_cd += 1


if (max(C,D)%min(C,D) == 0):
    ans = (B-A+1) - max(n_c, n_d)
else:
    ans = (B-A + 1) - (n_c + n_d - n_cd)

# print(n_c)
# print(n_d)
# print(n_cd)

print(ans)




Fixed submission:
import fractions
A,B,C,D = map(int, input().split())

# n_c = 0
# n_d = 0
# n_cd = 0
# for i in range(A,B+1):
#     if(i % C == 0):
#         n_c = i // C
#     n_d = i // D
#     n_cd = i//(C*D)

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

n_c = B//C - A//C
n_d = B//D - A//D
CD = lcm(C,D)
n_cd = B//(CD) - A//(CD)

if(A%C == 0):
    n_c += 1
if(A%D==0):
    n_d += 1
if(A%CD==0):
    n_cd += 1


if (max(C,D)%min(C,D) == 0):
    ans = (B-A+1) - max(n_c, n_d)
else:
    ans = (B-A + 1) - (n_c + n_d - n_cd)

# print(n_c)
# print(n_d)
# print(n_cd)

print(ans)
Buggy python submission (verdict: Runtime Error):
P,Q,R = int(input().split())
# P = input().split()

# print(P)
# print(Q)
# print(R)

min = min(P+Q, P+R, Q+R)

print(min)


Fixed submission:
P,Q,R = input().split()
# P = input().split()

# print(P)
# print(Q)
# print(R)

min = min(int(P)+int(Q), int(P)+int(R), int(Q)+int(R))

print(min)
Buggy python submission (verdict: Time Limit Exceeded):
slime_number = int(input())
slime_colors = list(input())

concatable = True

while concatable:
  if slime_number == 1:
     break
  i = 0
  while i < slime_number - 1:
    concatable = False
    if slime_colors[i] == slime_colors[i + 1]:
      slime_colors = slime_colors[:i] + slime_colors[i+1:]
      concatable = True
      slime_number -= 1
    else:
      i += 1
      
print(slime_number)

Fixed submission:
slime_number = int(input())
slime_colors = list(input())

last_slime = 'ほげ'
result = 0

for i in range(slime_number):
  if last_slime != slime_colors[i]:
    last_slime = slime_colors[i]
    result += 1

print(max(result, 1))
Buggy python submission (verdict: Runtime Error):
import math

if __name__ == '__main__':
    n, k = map(int, input().split())
    heights = list(map(int, input().split()))
    heights.sort()
    # n人、k CM必要
    index = 0
    while heights[index] < k:
        index += 1
        if n == 1:
            break
    print(n - index)


Fixed submission:
if __name__ == '__main__':
    n, k = map(int, input().split())
    heights = list(map(int, input().split()))
    heights.sort()
    # n人、k CM必要
    index = 0
    while len(heights) > index and heights[index] < k:
        index += 1
        if n == 1:
            break
    print(n - index)
Buggy python submission (verdict: Runtime Error):
## 幸福度が変わるかどうかは操作Kによって変更されたl, r番目の人間だけなので、
## 左右l,r番目の人間が幸福であるかどうかを見てゆく
## for(n)回のループでまず「既に 1 + x, 任意の r が幸福であるかどうか」を確認して、
## 幸福度2, 1の順でそのl,rをK回覚える
n, k = map(int, input().split())
humans = list(input())
k_count = 0
last_r = n ## 最後に操作したr(番目)
dev_null = 0

for x in range(n - 1):
  if x == last_r:
    break ## すべての可能性を確認した
  if x == 0:
    continue
  l = r = "n"
  if k_count == k:
    break ## 既にK回試行したのでbreak
  if humans[x] == "L" and humans[x - 1] == "L":
    continue
  elif humans[x] == "R" and humans[x - 1] == "R" and humans[x + 1] == "R":
    continue
  else:
    ## 不幸なので、lを確定
    l = x + 1 ## 不幸な人
    if l == last_r - 1:
      break ## 前に操作したrとlが等しい
    ## rを探す(x + 1からlast_rまで)
    for y in reversed(range(l, last_r)): ## l, l+1, last_r - 1
      if y == n - 1 and humans[x] == "R":
        ## 不幸なので、rを確定
        r = y
        last_r = r
        k_count += 1
        break
      elif humans[y] == "L" and humans[y - 1] == "L":
        dev_null += 1 ## 既に同じ方向を向いてる
      elif humans[y] == "R" and humans[y + 1] == "R":
        dev_null += 1 ## 既に同じ方向を向いてる
      else:
        ## 不幸なので、rを確定
        r = y
        last_r = r
        k_count += 1
        break
    if l != "n" and r != "n":
      ## ともに値があるなら操作Kを実行
      for z in range(l, r + 1):
        if humans[z - 1] == "L":
          humans[z - 1] = "R"
        else:
          humans[z - 1] = "L"

## ポイントを計算
happy_point = 0
for x in range(n):
  if x == 0 and humans[x] == "L":
    ## do nothing
    dev_null += 1
  elif x == n - 1 and humans[x] == "R":
    ## do nothing
    dev_null += 1
  else:
    if humans[x] == "L" and humans[x - 1] == "L":
      happy_point += 1
    elif humans[x] == "R" and humans[x + 1] == "R":
      happy_point += 1
print(happy_point)

Fixed submission:
## 幸福度が変わるかどうかは操作Kによって変更されたl, r番目の人間だけなので、
## 左右l,r番目の人間が幸福であるかどうかを見てゆく
## for(n)回のループでまず「既に 1 + x, 任意の r が幸福であるかどうか」を確認して、
## 幸福度2, 1の順でそのl,rをK回覚える
n, k = map(int, input().split())
humans = list(input())
k_count = 0
last_r = n ## 最後に操作したr(番目)
dev_null = 0

## ポイントを計算
happy_point = 0
for x in range(n - 1):
  if humans[x] == humans[x+1]:
    happy_point += 1
print(min(n-1,happy_point+2*k))
Buggy python submission (verdict: Runtime Error):
    forecasts = list(input())
    actuals = list(input())
    ex_count = 0
    for x in range(3):
        if forecasts[x] == actuals[x]:
            ex_count = ex_count + 1
    print("{}".format(ex_count))

Fixed submission:
forecasts = list(input())
actuals = list(input())
ex_count = 0
for x in range(3):
    if forecasts[x] == actuals[x]:
        ex_count = ex_count + 1
print("{}".format(ex_count))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
tap_count = 1
a_count = 0
while tap_count <= b:
  tap_count = tap_count + a - 1
  a_count = a_count + 1
print("{}".format(a_count))

Fixed submission:
a, b = map(int, input().split())
tap_count = 1
a_count = 0
while tap_count < b:
  tap_count = tap_count + a - 1
  a_count = a_count + 1
print("{}".format(a_count))
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
result = 0
for x in range(num):
  result = result + x
print(result)

Fixed submission:
num = int(input())
result = num * (num - 1) // 2
##  初項0, 公差1, 項数numの等差数列の和= num(2a + (num - 1)d)/2
print(int(result))
Buggy python submission (verdict: Runtime Error):
import collections

s=input()
t=input()

if all([c in s for c in t])!=True:
	print(-1)
	exit()

i=0
ss=s
while t!="":
    if i>len(s)-1:
        ss=ss+s
    if t[0]==ss[i]:
        t=t[1:]

    i+=1
print(i)

Fixed submission:
S = input()
T = input()

if all([c in S for c in T])!=True:
	print(-1)
	exit()

str_repeat_num = 0
now_idx = 0
for t in T:
    if t in S[now_idx:]:
        now_idx += S[now_idx:].index(t) + 1
    else:
        str_repeat_num += 1
        now_idx = S[:now_idx].index(t) + 1
print(len(S) * str_repeat_num + now_idx)