TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
n,k=map(int,input().split())
s=input()
t=list()
ans=0
count=1
for i in range(n-1):
	if s[i]==s[i+1]:
		count+=1
	else:
		if count >= 2:
			ans += count-1
		t.append(1)
		count=1
if count >= 2:
	ans += count-1
t.append(1)
if len(t) <= 2*k+1:
	ans += len(t)
else:
	ans += 2*k+1
print(ans)

n,k=map(int,input().split())
s=input()
t=list()
ans=0
count=1
for i in range(n-1):
	if s[i]==s[i+1]:
		count+=1
	else:
		if count >= 2:
			ans += count-1
		t.append(1)
		count=1
if count >= 2:
	ans += count-1
t.append(1)
if len(t) < 2*k+1:
	ans += len(t) - 1
else:
	ans += 2*k
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N, K = map(int, input().split())
S = input()

res = 0
pre = None
add = {2: 0}
add[1] = 0 if S[0] == S[-1] else 1
for s in S:
    if pre is None:
        pass
    elif pre == s:
        res += 1
    elif pre == "R":
        add[2] += 1
    pre = s
if add[1] + add[2] >= K:
    print(N - 1)
elif add[2] > K:
    res += 2 * K
    print(res)
else:
    res += 2 * add[2]
    K -= add[2]
    if K > 0:
        res += add[1]
    print(res)





N, K = map(int, input().split())
S = input()

res = 0
pre = None
add = {2: 0}
add[1] = 0 if S[0] == S[-1] else 1
for s in S:
    if pre is None:
        pass
    elif pre == s:
        res += 1
    elif pre == "R":
        add[2] += 1
    pre = s

if add[1] + add[2] >= K:
    print(N - 1)
if add[2] > K:
    res += 2 * K
    print(res)
else:
    res += 2 * add[2]
    K -= add[2]
    if K > 0:
        res += add[1]
    print(res)





N, K = map(int, input().split())
S = input()

res = 0
pre = None
add = {2: 0}
add[1] = 0 if S[0] == S[-1] else 1
for s in S:
    if pre is None:
        pass
    elif pre == s:
        res += 1
    elif pre == "R":
        add[2] += 1

    pre = s

if add[2] > K:
    res += 2 * K
    print(res)
else:
    res += 2 * add[2]
    K -= add[2]
    if add[1] == 1 and S[-1] == "L":
        res -= 2
    if K > 0:
        res += add[1]
    print(res)





Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N,K=map(int, input().split())
S=input()
comp=[]
tmp=""

for i in range(N):
  if tmp=="":
    tmp=S[i]
    cnt=1
  else:
    if S[i]==tmp:
      cnt +=1
      
  if S[i]!=tmp:
    comp.append([tmp,cnt])
    tmp=S[i]
    cnt=1
  if i==N-1:
    comp.append([tmp,cnt])
    
print(comp)    
for _ in range(K):
  if len(comp)<=3:
    print(N-1)
    exit()
  else:
    c= [comp[j][1]+comp[j+2][1] for j in range(len(comp)-2)]
    print(c)
    maxi=max(c)
    idx = c.index(maxi)
    s= comp[idx][1]
    t = comp[idx+2][1]
    if idx>=1:
      comp[idx-1][1] += t
    if idx+3<len(comp):
      comp[idx+3][1] += s
    if comp[idx+1][0]=="R":
      comp[idx+1][0]="L"
    else:
      comp[idx+1][0]="R"
    comp = comp[:idx] + [comp[idx+1]]+comp[idx+3:]
      
  print(comp)

ans=0  
for a in comp:
  ans += a[1]-1
print(ans)

N,K=map(int, input().split())
S=input()
comp=[]
tmp=""

for i in range(N):
  if tmp=="":
    tmp=S[i]
    cnt=1
  else:
    if S[i]==tmp:
      cnt +=1
      
  if S[i]!=tmp:
    comp.append([tmp,cnt])
    tmp=S[i]
    cnt=1
  if i==N-1:
    comp.append([tmp,cnt])
  
ans=0  
for run in comp:
  ans += run[1]-1
ans += K*2
ans = min(ans,N-1)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
n, k = map(int, input().split())
s = list(input())
s_num = []
point = 1
prev = s[0]
ans = 0
for i in range(n - 1):
    if prev != s[i + 1]:
        prev = s[i + 1]
        s_num.append(point)
        ans += point - 1
        point = 1        
    else:
        point += 1
s_num.append(point)
ans += point - 1
kkk = max(len(s_num) - 2, 0)
ans = ans + min(kkk, k) * 2
if kkk < k:
    ans += k - kkk
ans = max(n, ans)
print(ans)

n, k = map(int, input().split())
s = list(input())
s_num = []
point = 1
prev = s[0]
ans = 0
for i in range(n - 1):
    if prev != s[i + 1]:
        prev = s[i + 1]
        s_num.append(point)
        ans += point - 1
        point = 1        
    else:
        point += 1
s_num.append(point)
ans += point - 1
kkk = max(len(s_num) - 2, 0)
ans = ans + min(kkk, k) * 2
if kkk < k:
    ans += k - kkk
ans = min(n - 1, ans)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
,k=map(int,input().split())
s=input()

if n==1:
  print(0)
  exit()

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

l_cnt=[]
for i in range(n):
  if s[i]=='R':
    if i==0:
      if s[i+1]=='L':
        l_cnt.append(1)
    if i==n-1:
      if s[i-1]=='L':
        l_cnt.append(1)
    else:
      t_l_cnt=s[i-1:i+2].count('L')
      l_cnt.append(t_l_cnt)

r_cnt=[]
for i in range(n):
  if s[i]=='L':
    if i==0:
      if s[i+1]=='R':
        r_cnt.append(1)
    if i==n-1:
      if s[i-1]=='R':
        r_cnt.append(1)
    else:
      t_r_cnt=s[i-1:i+2].count('R')
      r_cnt.append(t_r_cnt)

ans=l_cnt+r_cnt
ans.sort(reverse=True)
ans=sum(ans[:k])

print(happy+ans)

from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,k=nii()
s=input()

happy=0
unhappy=0
for i in range(1,n):
  if s[i-1]==s[i]:
    happy+=1
  else:
    unhappy+=1

for i in range(k):
  if unhappy==1:
    happy+=1
    break
  happy+=2
  unhappy-=2

print(min(happy,n-1))

Verdicts: Runtime Error

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
(str_len,cng_cnt) = input().split(" ")
str_input = list(input())


print(str_len)
print(cng_cnt)
cng_cnt= int(cng_cnt)
#print(asd)
tmp1=""
cnt=0
cnt2=0
for st in str_input:
    if(tmp1 == st ):
      cnt = cnt+1
    else:
      cnt2= cnt2 + 1
      
    tmp1=st

if (cng_cnt < cnt2 ):
	c_up = cng_cnt * 2 
else:
	c_up= (cnt2 * 2) + (cng_cnt - cnt2)
ans =cnt + c_up

print(ans)

(str_len,cng_cnt) = input().split(" ")
str_input = list(input())


cng_cnt= int(cng_cnt)
tmp1=""
cnt=0
cnt2=0
for st in str_input:
    if(tmp1 == st ):
      cnt = cnt+1
    else:
      cnt2= cnt2 + 1
      
    tmp1=st

if (cng_cnt > cnt2 ):
	c_up = cng_cnt * 2 
else:
	c_up= (cnt2 * 2) + (cng_cnt - cnt2)
ans =cnt + c_up

print(ans)

(str_len,cng_cnt) = input().split(" ")
str_input = list(input())

str_len= int(str_len)
cng_cnt= int(cng_cnt)
tmp1=""
cnt=0
cnt2=0
for st in str_input:
    if(tmp1 == st ):
      cnt = cnt+1
    else:
      cnt2= cnt2 + 1
      
    tmp1=st

if (cng_cnt < cnt2-1 ):
	c_up = cng_cnt * 2 
else:
	c_up= (cnt2 * 2) + (cng_cnt - cnt2)
ans =cnt + c_up

if(ans >= str_len):
  ans =str_len-1

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
n, k = map(int, input().split())
s = int(input())

cnt = 0
for i in range(n):
    if s[i] != s[i+1]:
        cnt += 1
ans = min(count+2*k, n-1)


n, k = map(int, input().split())
s = int(input())

cnt = 0
for i in range(n-1):
    if s[i] != s[i+1]:
        cnt += 1
ans = min(count+2*k, n-1)
print(ans)

n, k = map(int, input().split())
s = int(input())

cnt = 0
for i in range(n):
    if s[i] != s[i+1]:
        cnt += 1
ans = min(count+2*k, n-1)
print(ans)

n, k = map(int, input().split())
s = input()

cnt = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
ans = min(cnt+2*k, n-1)
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):


N, K = map(int, input().split())
S = input()

score = 0
for i in range(N):
    score += 1 if S[i-1] == S[i] else 0
ans = min(score+2*K, N-1)
print (ans)




N, K = map(int, input().split())
S = input()

score = 0
for i in range(N-1):
    if S[i] == S[i+1]: score += 1 
ans = min(score+2*K, N-1)
print (ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
n,k=map(int,input().split())
msg=input()



left=(msg[0]!="R")
right=(msg[-1]!="L")
msg2=msg[1:-1]
cntrl=msg.count("RL")


first=n-cntrl*2-left-right
print("f",first)
ans=first+2*min(k,msg2.count("RL"))
if ans==n:
  ans=n-1
print(ans)
               


n,k=map(int,input().split())
msg=input()



left=(msg[0]!="R")
right=(msg[-1]!="L")
msg2=msg[1:-1]
cntrl=msg.count("RL")


first=n-cntrl*2-left-right
print("f",first)
ans=first+2*min(k,msg2(count("RL")))
if ans==n:
  ans=n-1
print(ans)
               

n,k=map(int,input().split())
msg=input()



left=(msg[0]!="R")
right=(msg[-1]!="L")
msg2=msg[1:-1]
cntrl=msg.count("RL")


first=n-cntrl*2-left-right
print("f",first)

print(min(first+2*min(cntrl,k),n-1))

n,k=map(int,input().split())
hoge=list(input())
hap=0
for i,j in zip(hoge[0:],hoge[1:]):
  if i==j:hap+=1
print(min(hap+2*k,n-1))

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
def count(s):
	c=0
	
	for i in range(len(s)-1):
		if s[i+1] == s[i]:
			c += 1
	return c
	
n, k = map(int, input().split())
s = input()
a = [str(c) for c in s]
cmax = n-1
p = count(a)
print(type(p))
while 1:
  if p == cmax:
    break
  elif p == cmax +1:
    p -=1
    break
  elif k > 0:
    p += 2
    k -= 1
  else:
    break
		
print(p)



def count(s):
	c=0
	
	for i in range(len(s)-1):
		if s[i+1] == s[i]:
			c += 1
	return c
	
n, k = map(int, input().split())
s = input()
a = [str(c) for c in s]
cmax = n-1
p = count(a)
while 1:
  if p == cmax:
    break
  elif p == cmax +1:
    p -=1
    break
  elif k > 0:
    p += 2
    k -= 1
  else:
    break
		
print(p)




Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N, K = map(int, input().split())
S = list(input())

p = 0
while K > 0 and p < len(S):
	now = S[p]
	p += 1
	if p >= len(S):
		break
	while now == S[p]:
		p += 1
		if p >= len(S):
			break

	q = p + 1
	if q >= len(S):
		"""
		if S[p] == "R":
			S[p] = "L"
		else:
			S[p] = "R"
		"""
		break
	while S[p] == S[q]:
		q += 1
		if q >= len(S):
			break
	while p < q:
		if S[p] == "R":
			S[p] = "L"
		else:
			S[p] = "R"
		p += 1
		if p >= len(S):
			break
	K -= 1

ret = 0;
print(len(S))
for x in range(len(S)-1):
	print(x)
	if S[x] == S[x + 1]:
		ret += 1
print(ret)


N, K = map(int, input().split())
S = list(input())
 
p = 0
while K > 0 and p < len(S):
	now = S[p]
	p += 1
	if p >= len(S):
		break
	while now == S[p]:
		p += 1
		if p >= len(S):
			break
			
	if p >= len(S):
		break
	q = p + 1
	if q >= len(S):
		if S[p] == "R":
			S[p] = "L"
		else:
			S[p] = "R"
		break
	while S[p] == S[q]:
		q += 1
		if q >= len(S):
			break
	while p < q:
		if S[p] == "R":
			S[p] = "L"
		else:
			S[p] = "R"
		p += 1
		if p >= len(S):
			break
	K -= 1
 
ret = 0;
for x in range(len(S)-1):
	if S[x] == S[x + 1]:
		ret += 1
print(ret)



Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N, K = map(int,input().split())
S = list(input())

def eval(N,S):
    total=0
    for i in range(1,N):
        if S[i]==S[i-1]:total+=1
    return total

for k in range(K):
    j=[]
    for i in range(1, N):
        if S[i-1]!=S[i]:
            j.append(i)
            if len(j)==2:break
    if len(j)==1:j.append(N)
    if S[j[0]]=='R':
        S[j[0]:j[1]]=['L']*(j[1]-j[0])
    else:S[j[0]:j[1]]=['R']*(j[1]-j[0])
    print(S)  
print(eval(N,S))
  


import sys

input = sys.stdin.readline

N, K = map(int,input().split())
S = list(input())

def eval(N,S):
    total=0
    for i in range(1,N):
        if S[i]==S[i-1]:total+=1
    return total

start_num=1
  
for k in range(K):
    if S==['R']*N or S==['L']*N:break
    j=[]
    start_num=j[1]+1
    for i in range(start_num, N):
        if S[i-1]!=S[i]:
            j.append(i)
            if len(j)==2:break
    if len(j)==1:j.append(N)
    if S[j[0]]=='R':
        S[j[0]:j[1]]=['L']*(j[1]-j[0])
    else:S[j[0]:j[1]]=['R']*(j[1]-j[0])
print(eval(N,S))
  


import sys
from collections import deque

input = sys.stdin.readline

N, K = map(int,input().split())
S = list(input())

sq = deque(S)
lst=[]
j=0

for i in range(K):
    j=0
    if not sq:break
    sq_1st = sq.popleft()
    sq_2nd = sq_1st
    lst.append(sq_1st)

    while sq:
        sq_3rd = sq.popleft()
        if sq_2nd!=sq_3rd:
            j+=1
            sq_2nd=sq_3rd
            if j==2:
                sq.appendleft(sq_3rd)
                break
        lst.append(sq_1st)

lst+=list(sq)             

def eval(N,S):
    total=0
    for i in range(1,N):
        if S[i]==S[i-1]:total+=1
    return total
  
print(eval(N,lst))
  


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
n,k = map(int,input().split())
s = list(input())
c = 0
a = 0
for i in range(n-1):
	if s[i] == s[i+1]:
		c += 1
i = 0
if s[-1] == 'R':
	s.append('L')
else:
	s.append('R')
print(s)
while a < k and len(s) >= 2:
	if s[0] != s[1] and s[-1] != s[-2] and s[0] == s[-1]:
		c += 2
		a += 1
	s = s[1:]

	i += 1
print(c)

n,k = map(int,input().split())
s = list(input())
c = 0
a = 0

for i in range(n-1):
	if s[i] == s[i+1]:
		c += 1
	if a < k:
		if s[i] == 'R' and s[i+1] == 'L':
			c += 2
			a += 1
if a < k and a + 2 <= k:
	if s[0] == 'L':
		c += 1
	if s[-1] == 'R':
		c += 1
if a < k and a + 1 >= k:
	if s[0] == 'L' or s[-1] == 'R':
		c += 1
print(min(c,n-1))

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
import re
n, k = [int(i) for i in input().split()]
s = input()
cnt = sum([1 for i in range(n-1) if s[i+1] == s[i]])
print(cnt)
flg = s[-1] == "R"
s += "L"
red_ls = re.findall(r"RL", s)
if len(red_ls) > k:
    print(cnt + k * 2)
else:
    if flg:
        print(cnt + (len(red_ls) - 1) * 2 + 1)
    else:
        print(cnt + len(red_ls) * 2)

import re
n, k = [int(i) for i in input().split()]
s = input()
cnt = sum([1 for i in range(n-1) if s[i+1] == s[i]])
flg = (s[-1] == "R") + (s[0] == "R")
s += "L"
red_ls = re.findall(r"RL", s)
if len(red_ls) > k:
    print(cnt + k * 2)
else:
    if flg > 0:
        print(cnt + (len(red_ls) - flg) * 2 + flg)
    else:
        print(cnt + len(red_ls) * 2)

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N,K=map(int,input().split())
S=input()

ch_list=[]
for i in range(1,N):
  if S[i-1]!=S[i]:
    ch_list.append(i)
print(ch_list)
len_ch=len(ch_list)

if len_ch>=2*K:
  print(N-1-len_ch+2*K)
elif len_ch==2*K-1:
  print(N-1-len_ch+2*K-1)
else:
  print(N-1)

N,K=map(int,input().split())
S=input()

ch_list=[]
for i in range(1,N):
  if S[i-1]!=S[i]:
    ch_list.append(i)
#print(ch_list)
len_ch=len(ch_list)

if len_ch>2*K:
  print(N-1-len_ch+2*K)
else:
  print(N-1)

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N, K = map(int, input().split())
S = input()

d = 0
for i in range(N-1):
	if(S[i]!=S[i-1]):
		d += 1
d = max(0, d - 2 * K)
print(N - 1 - d)

N, K = map(int, input().split())
S = input()

d = 0
for i in range(N-1):
	if(S[i] != S[i+1]):
		d += 1
d = max(0, d - 2 * K)
print(N - 1 - d)

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
n,k=map(int,input().split())
S=input()
c=0
d=0
for i in range(n):
    if S[i]==S[i+1]:
        c+=1
    if S[i]!=S[i+1]:
        d+=1
print(c+2*k-1 if d<=k and S[0]==S[-1] else c+2*k)

n,k=map(int,input().split())
S=input()+'X'
if n==1:
  print(0)
  exit()
if n==2:
  print(1)
  exit()
A=[0]
l=0
r=0
for i in range(n):
  if S[i]=='L':
    l+=1
    if S[i+1]!='L':
      A.append(l)
      l=0
  if S[i]=='R':
    r-=1
    if S[i+1]!='R':
      A.append(r)
      r=0
A=sorted(A)
z=A.index(0)
L=sum(A[z+1:])-len(A[z+1:])-sum(A[:min(z,k)])+min(len(A)-z-1,k)
R=sum(A[:z])+len(A[:z])-sum(A[-min(len(A)-z,k):])-min(z,k)
if len(A[z+1:])==min(len(A)-z-1,k):
  L-=1
if len(A[:z])==min(z,k):
  R+=1
print(L,R)
print(max(L,-R))

n,k=map(int,input().split())
S=input()+'X'
if n==1:
  print(0)
  exit()
if n==2:
  print(1)
  exit()
A=[0]
l=0
r=0
for i in range(n):
  if S[i]=='L':
    l+=1
    if S[i+1]!='L':
      A.append(l)
      l=0
  if S[i]=='R':
    r-=1
    if S[i+1]!='R':
      A.append(r)
      r=0
A=sorted(A)
z=A.index(0)
L=sum(A[z+1:])-len(A[z+1:])-sum(A[:min(z,k)])+min(len(A)-z-1,k)
R=sum(A[:z])+len(A[:z])-sum(A[-min(z,k):])-min(z,k)
if len(A[z+1:])==min(len(A)-z-1,k):
  L-=1
if len(A[:z])==min(z,k):
  R+=1
print(L,R)
print(max(L,-R))

n,k=map(int,input().split())
S=input()
c=0
d=0
for i in range(n-1):
    if S[i]==S[i+1]:
        c+=1
    if S[i]!=S[i+1]:
        d+=1
d=(d+1)//2
print(c+2*d-1 if (d<=k and S[0]!=S[-1]) else c+2*min(d,k))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
s = input()
print(n)
print(k)

def count_happy(s):
    count = 0
    for i in range(1,len(s)-1):
        if s[i]==s[i-1]:
            count += 1
    return count

# print(count_happy(s))
ans = count_happy(s) + 2*k
ans_final = min(n-1,ans)
print(ans_final)

import sys
input = sys.stdin.readline
n,k = map(int,input().split())
s = input()
# print(n)
# print(k)

def count_happy(s):
    count = 0
    for i in range(1,len(s)-1):
        if s[i]==s[i-1]:
            count += 1
    return count

# print(count_happy(s))
ans = count_happy(s) + 2*k
ans_final = min(n-1,ans)
print(ans_final)

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
from fractions import gcd


a, b, c, d = map(int, input().split())
lcm = int(c * d / gcd(c, d))
A = a - 1
l_cd = A - A // c - A // d + A // lcm
r_cd = b - b // c - b // d + b // lcm
print(r_cd - l_cd)


n, k = map(int, input().split())
s = input()
t = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        t += 1
print(min([n - 1, h + 2 * k]))


n, k = map(int, input().split())
s = input()
t = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        t += 1
print(min([n - 1, t + 2 * k]))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
tmp=1
for i in range(1,N):
    if S[i-1]==S[i]:
        tmp+=1
    else:
        A.append(tmp)
        tmp=1
A.append(tmp)
 
ans=sum(A)-len(A)+(K)*2
 
if ans<N-1:
    print(ans)
else: print(N-1)

N, K=map(int, input().split())
S=input()
A=[]
tmp=1
for i in range(1,N):
    if S[i-1]==S[i]:
        tmp+=1
    else:
        A.append(tmp)
        tmp=1
A.append(tmp)
 
ans=sum(A)-len(A)+(K)*2
 
if ans<N-1:
    print(ans)
else: print(N-1)

Verdicts: Runtime Error

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N ,K =map(int,input().split())
S ="R" +input() +"L"
coun = 0
foo = 0
for i in range(N+1):
    if S[i:i+2] =="RL":
        coun += 1
    if i==0 or i==N:
        foo  +=1
if K >= coun:
    print(N)
elif coun -K <= foo:
    print(N-foo)
else:
    print(N-2*(coun-K) +foo)

N ,K =map(int,input().split())
S ="R" +input() +"L"
coun = 0
foo = 0
for i in range(N+1):
    if S[i:i+2] =="RL":
        coun += 1
        if i==0 or i==N:
            foo  +=1
if K >= coun:
    print(N-1)
elif coun -K <= foo:
    print(N-(coun-K))
else:
    print(N-2*(coun-K) +foo)

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N, K = map(int, input().split())
S = input()
 
num = S.count('RL')
 
ans = N-max(1,(num-K)*2)
print(ans)

N, K = map(int, input().split())
Ss = input()
 
num = Ss.count('RL')*2
if list(Ss)[-1]=='L':
  if list(Ss)[0]=='L':
    num += 1
  num += 1

ans = N - max(1, num-2*K)
print(ans)

N, K = map(int, input().split())
Ss = input()
 
num = Ss.count('RL')*2
if list(Ss)[-1]=='L':
  num += 1
if list(Ss)[0]=='L':
  num += 1
ans = N - max(1, num-2*K)
print(ans)

N, K = map(int, input().split())
Ss = input()
 
num = Ss.count('RL')*2
if list(Ss)[-1]=='R':
  num += 1
if list(Ss)[0]=='L':
  num += 1
ans = N - max(1, num-2*K)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N,K = map(int,input().split())
S = input()

h = 0
for i in range(len(S)-1):
  if s[i] == S[i+1]:
    h += 1
h += 2*K
print(min(N-1, h))


N,K = map(int,input().split())
S = input()

h = 0
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    h += 1
h += 2*K
print(min(N-1, h))


Verdicts: Runtime Error

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
n, k = map(int, input().split())
s = input()
count = 0
s = 'X' + s + 'X'
for i in range(1, n+1):
    print(f's[i]: {s[i]} s[i-1]: {s[i-1]} s[i+1]:{s[i+1]}')
    if (s[i] == s[i-1] and s[i] == 'L') or \
        (s[i] == s[i+1] and s[i] == 'R'):
        count += 1
if count == n-2:
    print(count + 1)
else:
    print(count + 2*k)

n, k = map(int, input().split())
s = input()
count = 0
s = 'X' + s + 'X'
for i in range(1, n+1):
    #print(f's[i]: {s[i]} s[i-1]: {s[i-1]} s[i+1]:{s[i+1]}')
    if (s[i] == s[i-1] and s[i] == 'L') or \
        (s[i] == s[i+1] and s[i] == 'R'):
        count += 1
print(min(n-1, count + 2*k))

Verdicts: Runtime Error

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N, K = map(int, input().split())
S = input()


LR = 0

for j in range(N-1):
    if S[j] == "L" and S[j+1]== "R":
        LR += 1
'''
if LR > K:
    ans = N - (LR-K)*2
else:
    ans = N-1
'''
ans = min(N-1, N - (LR-K)*2)

print(ans)


N, K = map(int, input().split())
S = input()


LR = 0

for j in range(N-1):
    if S[j] == "L" and S[j+1]== "R":
        LR += 1

if LR > K:
    ans = N - (LR-K)*2
else:
    ans = N-1


print(ans)


N, K = map(int, input().split())
S = input()


LR = 0
f = 0
for j in range(N-1):
    if S[j] == "L" and S[j+1]== "R":
        if j == 0 or j == N-2:
            f += 1
        else:
            LR += 1

if LR > K:
    ans = N - (LR-K)*2
elif f > K-LR:
    ans = N -(f+LR-K)*2
else:
    ans = N-1

print(ans)


N, K = map(int, input().split())
S = input()




ans = 0
pre = S[0]
for i in range(N-1):
    if pre == S[i+1]:
        ans += 1
    pre = S[i+1]

ans = min([N-1, ans+2*K])

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N,K=list(map(int,input().split()))
S=list(input())
sum=-1
for i in range(N-1):
    if S[i]==S[i+1]:
        sum+=1
sum+=2*K
if sum>=N:
    sum=N-1
print(sum)

N,K=list(map(int,input().split()))
S=list(input())
sum=0
for i in range(N-1):
    if S[i]==S[i+1]:
        sum+=1
sum+=2*K
if sum>=N:
    sum=N-1
print(sum)

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing in a queue from west to east.  Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.  A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.  You can perform the following operation any number of times between 0 and K (inclusive):  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.  What is the maximum possible number of happy people you can have?

Submission attempts (in order):
N, K = map(int, input().split())
S = list(input())

hikkuri = 0

for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        hikkuri += 1

shiawase = len(S) - hikkuri - 1

for i in range(K):
    if hikkuri >= 2:
        shiawase += 2
        hikkuri -= 2
    elif hikkuri == 1:
        shiawase += 1
        break

print(shiawase)N, K = map(int, input().split())
S = list(input())

hikkuri = 0

for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        hikkuri += 1

shiawase = len(S) - hikkuri - 1

for i in range(K):
    if hikkuri >= 2:
        shiawase += 2
        hikkuri -= 2
    elif hikkuri == 1:
        shiawase += 1
        break

print(shiawase)

N, K = map(int, input().split())
S = list(input())

hikkuri = 0

for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        hikkuri += 1

shiawase = len(S) - hikkuri - 1

for i in range(K):
    if hikkuri >= 2:
        shiawase += 2
        hikkuri -= 2
    elif hikkuri == 1:
        shiawase += 1
        break

print(shiawase)

Verdicts: Runtime Error

Accepted