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

Fixed submission:
n=int(input())

print(n**3)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
cnt=0
for i,v in enumerate(a):
	cnt += b[v-1]
	if i == 0:continue
	if v-1 == a[i-1]:
		#print(c[v-1])
		cnt += c[v-2]
print(cnt)
Problem p02595 (python)

Fixed submission:
from math import *
n, d = map(int, input().split())
p = 0
for i in range(n):
  x, y = map(int, input().split())
  if sqrt(pow(abs(x),2)+pow(abs(y),2)) <= d :
    p += 1
print(p)

Buggy submission (verdict: Runtime Error):
import math
n, d = map(int, input().split())
p = 0
for i in range(n):
  x, y = map(int, input().split())
  if sqrt(pow(abs(x),2)+pow(abs(y),2)) <= d :
    p += 1
print(p)

Buggy submission (verdict: Runtime Error):
import math
n, d = map(int, input().split())
p = 0
for i in range(n):
  x, y = map(int, input().split())
  if sqrt(pow(x,2)+pow(y,2)) ≤ d :
    p += 1
print(p)
Problem p02594 (python)

Fixed submission:
s = int(input()) 

print("Yes" if s>=30 else "No")

Buggy submission (verdict: Runtime Error):
import math
N, D = map(int, input().split())
l = [list(map(int, input().split())) for l in range(N)]
 
ans=0
for i,a in enumerate(l):
    if math.sqrt(a[0]**2 + a[1]**2)<=D:
        ans+=1
ans
Problem p02595 (python)

Fixed submission:
import math
N, D = map(int, input().split())
l = [list(map(int, input().split())) for l in range(N)]
 
ans=0
for i,a in enumerate(l):
    if math.sqrt(a[0]**2 + a[1]**2)<=D:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
print math
N, D = map(int, input().split())
l = [list(map(int, input().split())) for l in range(N)]

ans=0
x=3
for i,a in enumerate(l):
    if math.sqrt(a[0]**2 + a[1]**2)>D :
        ans+=1
Problem p02699 (python)

Fixed submission:
s,w= map(int,input().split())
if w>=s:
  print('unsafe')
else:
  print('safe')

Buggy submission (verdict: Runtime Error):
s = int(input())
w = int(input())
if w>=s:
  print("unsafe")
else:
  print("safe")
Problem p02701 (python)

Fixed submission:
n = int(input())
obj= []
for i in range (n):
	obj.append(input())
dictOfElems = dict()
for elem in obj:
  if elem in dictOfElems:
    dictOfElems[elem] += 1
  else:
    dictOfElems[elem] = 1
print(len(dictOfElems))

Buggy submission (verdict: Runtime Error):
n = int(input())
obj= []
for i in range (n):
	obj.append(input())
dictOfElems = dict()
for elem in obj:
  if elem in dictOfElems:
    dictOfElems[elem] += 1
  else:
    dictOfElems[elem] = 1
print(len(dict))

Buggy submission (verdict: Runtime Error):
n = int(input())
obj= []
for i in range (n):
	obj.append(input())
dictOfElems = dict()
    # Iterate over each element in list
    for elem in obj:
        # If element exists in dict then increment its value else add it in dict
        if elem in dictOfElems:
            dictOfElems[elem] += 1
        else:
            dictOfElems[elem] = 1
print(len(dict))

Buggy submission (verdict: Runtime Error):
n = int(input())
obj= []
for i in range (n)
	obj.append(input())
dictOfElems = dict()
    # Iterate over each element in list
    for elem in obj:
        # If element exists in dict then increment its value else add it in dict
        if elem in dictOfElems:
            dictOfElems[elem] += 1
        else:
            dictOfElems[elem] = 1
print(len(dict))
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:    A -= 1
else: B -= 1
print(A,B)

Buggy submission (verdict: Runtime Error):
S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:    A -= 1
else: B -= 1
print(A, 😎
Problem p02831 (python)

Fixed submission:
def gcd(a, b):
    return b if a == 0 else gcd(b%a, a)
num = [int(x) for x in input().split(" ")]
print(int(num[0]*num[1]/gcd(num[0], num[1])))

Buggy submission (verdict: Runtime Error):
n,m = int(input()), int(input())
i =1
while true:
  if i%n == 0 and i%m == 0:
    print(i)
    break
  i+= 1
Problem p02711 (python)

Fixed submission:
N = input()
print("Yes" if N.__contains__("7") else "No")

Buggy submission (verdict: Runtime Error):
N = input()
print("Yes" if N.contains("7") else "No")

Buggy submission (verdict: Runtime Error):
N = input()

print("Yes" if N.contains("7") else "No")
Problem p02723 (python)

Fixed submission:
S = input("")
if(S[2].__eq__(S[3]) and S[4].__eq__(S[5])):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
S = input("")
if(S[2].__eq__(S[3]) and S[4].__eq__(S[5])):
    print("Yes")
else:
    print("No")
Problem p02777 (python)

Fixed submission:
S,T = input().split(" ")
A,B = map(int,input().split(" "))
U = input()

if S==U:
  A-=1
else:
  B-=1
  
print("{} {}".format(A,B))

Buggy submission (verdict: Runtime Error):
S,T = map(input().split(" "))
A,B = map(int,input().split(" "))
U = input()

if S==U:
  A-=1
else:
  B-=1
  
print(f"{A} {B}")

Buggy submission (verdict: Runtime Error):
S,T = map(input().split())
A,B = map(int,input().split())
U = input().split()

if S==U:
  A-=1
else:
  B-=1
  
print(f"{A} {B}")

Buggy submission (verdict: Runtime Error):
S,T = map(input().split())
A,B = map(int,input().split())
U = input().split()

if S==U:
  A-=1
else:
  B-=1
  
print(f"{A} {B}")
Problem p02785 (python)

Fixed submission:
N,K = map(int,input().split())
H = list(map(int,input().split()))

H.sort()

for i in range(0,K):
    if H:
      H.pop()

print(sum(H))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
H = list(map(int,input().split()))

H.sort()

for i in range(0,K):
    H.pop()

print(sum(H))
Problem p02790 (python)

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

a1 = "{}".format(b)*a
b1 = "{}".format(a)*b

print("{}".format(b1) if min(a,b)==a else "{}".format(a1))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())

a1 = f"{b}" * a
b1 = f"{a}" * b

print(f"{b1}" if min(a,b)==a else f"{a1}")
Problem p02835 (python)

Fixed submission:
inp = list(map(int , input().split(" ")))
ans = inp[0]+inp[1]+inp[2]
if ans >= 22:
  print("bust")
else:
  print("win")

Buggy submission (verdict: Runtime Error):
inp = map(int,input().split())
ans = inp[0]+inp[1]+inp[2]
if ans >= 22:
  print("bust")
 else:
  print("win")
Problem p02627 (python)

Fixed submission:
S = str(input())
if S.isupper():
  print ("A")
else:
  print ("a")

Buggy submission (verdict: Runtime Error):
S = str(input())
if S .isupper():
  print(A)
else:
  print(a)
Problem p02759 (python)

Fixed submission:
N = int(input())
S = -(-N // 2)
print (S)

Buggy submission (verdict: Runtime Error):
N = input()
S = N / 2
if N % 2 = 0
	print(S)
else
	print(S + 1)

Buggy submission (verdict: Runtime Error):
N=input()
print -(-N//2)
Problem p02597 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
S = input()

num_r = S.count('R')
ans = num_r

for i in range(num_r):
    if S[i] == 'R':
        ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))
import math

N, K = mi()
A = li()

if K == 0:
    print(max(A))
    exit()

left = 0
right = max(A)

def count(num):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / num)
    
    return cnt


while True:
    mid = (left + right) // 2
    tmp = count(mid)
    if tmp == K:
        break
    elif tmp > K:
        if left == mid:
            mid += 1
            break
        left = mid
    else:
        right = mid

if mid == 0:
    print(mid)
    exit()

right = mid
while True:
    tmp = count(mid)
    if tmp == K and tmp != count(mid-1):
        print(mid)
        break
    elif tmp == K:
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
Problem p02695 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M, Q = mi()
abcd = li2(Q)

#N = 10

a = '0' * N
m = str(M-1)
l = [a]
#for length in range(N):
while True:
    i = N-1
    while i >= 0 and a[i] == m:
        i -= 1
    if i == -1:
        break
    a = list(a)
    num = str(int(a[i]) + 1)
    a[i] = num
    if i !=N-1:
        for j in range(i+1, N):
            a[j] = num
    tmp = ''.join(a)
    l.append(tmp)


ans = 0
for num in l:
    cnt = 0
    num = list(map(int, list(num)))
    for i in range(Q):
        if num[abcd[i][1]-1] - num[abcd[i][0]-1] == abcd[i][2]:
            cnt += abcd[i][3]

    ans = max(ans, cnt)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M, Q = mi()
abcd = li2(Q)

'''
a = '0' * N
m = str(M-1)
l = [a]

while True:
    i = N-1
    while i >= 0 and a[i] == m:
        i -= 1
    if i == -1:
        break
    a = list(a)
    num = str(int(a[i]) + 1)
    a[i] = num
    if i != N-1:
        for j in range(i+1, N):
            a[j] = num
    tmp = ''.join(a)
    l.append(tmp)
'''

def dfs(num, length):
    if length == N:
        l.append(num)
        return
    last = int(num[-1])
    for i in range(last, M):
        dfs(num + str(i), length+1)

dfs('0', 1)
ans = 0
for num in l:
    cnt = 0
    num = list(map(int, list(num)))
    for i in range(Q):
        if num[abcd[i][1]-1] - num[abcd[i][0]-1] == abcd[i][2]:
            cnt += abcd[i][3]
    ans = max(ans, cnt)

print(ans)
Problem p02753 (python)

Fixed submission:
N = input()

#A = map(int,input().split())

if N[0]==N[1]==N[2]:
    print('No')
    exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import sys

S = input()

Q = int(input())
flag=0

for i in range(Q):
    r = sys.stdin.readline().strip('\n')
    if r == '1':
        S = S[::-1]
    else:
        ni, f, c = r.split()
        if f=='1':
            S = c + S
        else:
            S+=c

print(S)
Problem p02757 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, mod = mi()
S = list(map(int, list(input())))
ans = 0

if 10 % mod != 0:
    mod_list = [0]
    ten = 1
    for num in S[::-1]:
        yo = (num * ten + mod_list[-1]) % mod
        mod_list.append(yo)
        ten = (ten * 10) % mod

    cnt = [0]*mod
    for yo in mod_list:
        cnt[yo] += 1

    for i in range(mod):
        ans += cnt[i] * (cnt[i]-1) // 2

else:
    for i, num in enumerate(S):
        if num % mod == 0:
            ans += i+1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, mod = mi()
S = list(map(int, list(input())))
ans = 0

if 10 % mod != 0:
    mod_list = [0]
    ten = 1
    for num in S[::-1]:
        yo = (num * ten + mod_list[-1]) % mod
        mod_list.append(yo)
        ten = (ten * 10) % mod

    cnt = [0]*2019
    for yo in mod_list:
        cnt[yo] += 1

    for i in range(2019):
        ans += cnt[i] * (cnt[i]-1) // 2

else:
    for i, num in enumerate(S):
        if num % mod == 0:
            ans += i+1

print(ans)
Problem p02831 (python)

Fixed submission:
import fractions
A,B=map(int, input().split())
f=fractions.gcd(A,B)
f2=A*B//f
print(f2)

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(A * B // math.gcd(A, B))
Problem p02833 (python)

Fixed submission:
N = int(input())
count = 0
k = 5

if N % 2 == 0:
    n = (N // 2 // 5) * 5
    while(n >= k):
        count += n // k
        k *= 5

print(count)

Buggy submission (verdict: Runtime Error):
import sys
A = 10**18
sys.setrecursionlimit(A)

N = int(input())

def f(n):
    '''
    if N % 2 == 1:
        n = (N+1)//2
        if n == 1:
            return 1
        else:
            return (2*n+1) * f(2*(n-1))
        
    else:
        n = N // 2
        if n == 1:
            return 1
        else:
            return 2 * n * f(2*(n-1))
    '''
    if n == 1:
        return 1
    else:
        return n * f(n-2)


count = 0
a = f(N)
print(a)

while(a % 10 ==0):
    a = a // 10
    count += 1

print(count)
Problem p03295 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
Q = li2(M)
#Q = sorted(Q, key=lambda x:x[1])

l = [N]*N
for i in range(M):
    ind = max(0, Q[i][0]-1)
    l[ind] = min(Q[i][1]-1, l[ind])

for i in reversed(range(N-1)):
    l[i] = min(l[i], l[i+1])

cnt = 0
i = 0
#print(l)
while True:
    i = l[i]
    cnt += 1
    if l[i] == N:
        break

print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
 
N, M = mi()
#Q = li2(M)
 
#Q = sorted(Q, key=lambda x:x[0])
 
table = dp2(0, N, N)
 
for i in range(M):
    s, t = mi()
    table[s-1][t-1] = 1
 
for i in reversed(range(N-1)):
    for j in range(i, N):
        table[i][j] = max(table[i+1][j], table[i][j])
 
#print(table)
 
i = j = 0
cnt = 0
while True:
    while j < N and table[i][j] == 0:
        j += 1
    if j >= N:
        break
    cnt += 1
    i = j
 
print(cnt)
Problem p02627 (python)

Fixed submission:
a=input()
if(a.islower()):
    print('a')
else:
    print('A')

Buggy submission (verdict: Runtime Error):
lpha=input()
cap=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
if(alpha in cap):
    print('A')
else:
    print('a')
Problem p02627 (python)

Fixed submission:
a = input()
print('A') if a.isupper() is True else print('a')

Buggy submission (verdict: Runtime Error):
a = input()
print('A') if c.isupper() is True else print('a')

Buggy submission (verdict: Runtime Error):
a = input()
print('A') if c.isupper() is True else print('B')
Problem p02759 (python)

Fixed submission:
N = int(input())

if N % 2 == 0:
    print(N//2)
else:
    print(N//2+1)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N % 2 == 0:
    print(N//2)
else:
    print(N//2+1
Problem p02771 (python)

Fixed submission:
numbers = map(int, input().split())
print("Yes") if len(set(numbers)) == 2 else print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = int(intput())
if(a=b||a=c||b=c):
  return yes
elif(a=b=c):
  return no
else: 
  return no
Problem p02676 (python)

Fixed submission:
k = int(input())
s = input()
i = ""
if len(s) <= k:
    print(s)
else:
    for j in range(k):
        i = i + s[j]
    print(i+"...")

Buggy submission (verdict: Runtime Error):
k = int(input())
s = input()
i = ""
if len(s) <= k:
  print(s)
  else: 
    for j in range(k):
      i = i + s[j]
    print(i + '...')
Problem p02682 (python)

Fixed submission:
a, b, c, k = map(int, input().split())
ans = 0
if k <= a:
    print(k)
else:
    k -= a
    ans += a
    if k <= b:
        print(ans)
    else:
        k -= b
        ans += -1 * k
        print(ans)

Buggy submission (verdict: Runtime Error):
sum = 0
if K>0:
    if A>0:
        if A>K:
            sum = sum + K
        else:
            sum = sum + A
    K = K - A
if K > 0:
    if B>0:
        K = K - B
if K > 0:
    if C>0:
        sum = sum + K * (-1)
print(sum)

Buggy submission (verdict: Runtime Error):
a, b, c, k = map(int,input().split())
sum = 0
if k > 0:
    if a > 0:
        if a > k:
            sum = sum + k
        else:
            sum = sum + a
    k = k - a
if k > 0:
    if b > 0:
        k = k - b
if k > 0:
    if c > 0:
        sum = sum + k (-1)
print(sum)
Problem p02701 (python)

Fixed submission:
n = int(input())
s = set()
for i in range(n):
    s.add(str(input()).lower())
print(len(s))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = set()
for i in range(n):
    s.add(str(input()).lower())
print(len(x))

Buggy submission (verdict: Runtime Error):
i = int(input())
x = set()
for j in range(i):
    x.add(str(input().lower())
print(len(x))
Problem p02836 (python)

Fixed submission:
s = input()
count = 0
first_half, second_half = s[:len(s)//2], s[(len(s)+1)//2:]
if first_half == reversed(second_half):
    print(count)
else:
    for x in range(len(first_half)):
        if first_half[x] != second_half[len(second_half)-x-1]:
            count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
print [S[:g]+S[g+1:]==(S[:g]+S[g+1:])[::-1] for g in range(len(S))].index(1)
Problem p02754 (python)

Fixed submission:
N, A, B = list(map(int, input().split()))

try:
    blue_num = A * (N // (A + B))
    residue = N - ((A + B) * (N // (A + B)))
    if(residue > A):
        blue_num += A
    else:
        blue_num += residue
except ZeroDivisionError:
    blue_num = 0

print(blue_num)

Buggy submission (verdict: Runtime Error):
N, A, B = list(map(int, input().split()))

blue_num = A * (N // (A + B)) + (N % (A + B) % A)
print(blue_num)

Buggy submission (verdict: Runtime Error):
N, A, B = list(map(int, input().split()))

blue_num = A * (N // (A + B)) + (N % (A + B) % A)
print(blue_num)
Problem p02597 (python)

Fixed submission:
n = int(input())
c = list(input())

def solve_fixed(p):
    w_cnt = 0
    r_cnt = 0

    for i in range(p):
        if(c[i] == "W"):
            w_cnt += 1
    
    for j in range(p,n):
        if(c[j] == "R"):
            r_cnt += 1
    
    return (w_cnt,r_cnt)

ans = 10**9
w_cnt,r_cnt = solve_fixed(0)

tmp = max(w_cnt,r_cnt)
ans = min(ans,tmp)
for i in range(n):
    
    if(c[i] == "W"):
        w_cnt += 1
    else:
        r_cnt -= 1

    tmp = max(w_cnt,r_cnt)
    ans = min(ans,tmp)
    

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())


flag = 0
for i in range(n-1): 
    if(s[i] == "R" and s[i+1] == "W"):
        w_left = i
        r_right = i+1
        flag = 1
        break


#print(w_left)
#print(r_right)
if(flag == 1):
    w_len = len([i for i in s[r_right:] if i == "R"])
    r_len = len([i for i in s[:w_left] if i == "W"])
    print(max(w_len,r_len))
else:
    for i in range(n):
        if(s[i] == "W" and s[i+1] == "R"):
            flag = 2
            pnt = i
            if((pnt+1)*2 < n):
                print(pnt+1)
            else:
                print(n-pnt-1)

if(flag == 0):
    print(0)
Problem p02629 (python)

Fixed submission:
import itertools
import bisect



n = int(input())
al = [0 for _ in range(26)]
for i in range(97,123):
    al[i-97] = chr(i)
#print(al)

sm = [0 for _ in range(20)]
for i in range(1,20):
    sm[i] = int(26*(26**i - 1)/25)

#print(sm[4])

xx = bisect.bisect_left(sm, n)
#print(xx)
if(xx > 1):
    rd = n - sm[xx-1]
    ans = []
    tmp = [0 for _ in range(30)]
    for i in range(xx):
        if(xx > 1):
            unt = 26**(xx-i-1)
        if(rd >= unt):
            tmp = [j*unt for j in range(30)]
            num = bisect.bisect_left(tmp,rd)
            ans.append(al[num-1])
            rd -= tmp[num-1]
            #print(rd)
        else:
            ans.append("a")

    print("".join(ans))

else:
    print(al[n-1])

Buggy submission (verdict: Runtime Error):
import itertools
import bisect



n = int(input())

sm = [0 for _ in range(20)]

for i in range(1,20):
    sm[i] = int(26*(26**i - 1)/25)

#print(sm[4])

xx = bisect.bisect_left(sm, n)
#print(xx)

rd = n - sm[xx-1]
#print(rd)


al = [0 for _ in range(26)]

for i in range(97,122):
    al[i-97] = chr(i)
    

#rdの字の個数だけループを回して、文字を特定していく

ans = []
tmp = [0 for _ in range(30)]
for i in range(xx):
    unt = 26**(xx-i-1)
    if(rd >= unt):
        tmp = [j*unt for j in range(30)]
        num = bisect.bisect_left(tmp,rd)
        ans.append(al[num-1])
        rd -= tmp[num-1]
        #print(rd)
    else:
        ans.append("a")

print("".join(ans))

Buggy submission (verdict: Runtime Error):
import itertools
import bisect



n = int(input())

sm = [0 for _ in range(20)]

for i in range(1,20):
    sm[i] = int(26*(26**i - 1)/25)

#print(sm[4])

xx = bisect.bisect_left(sm, n)
#print(xx)

rd = n - sm[xx-1]
#print(rd)


al = [0 for _ in range(26)]

for i in range(97,122):
    al[i-97] = chr(i)
    

#rdの字の個数だけループを回して、文字を特定していく

ans = []
tmp = [0 for _ in range(30)]
for i in range(xx):
    unt = 26**(xx-i-1)
    tmp = [j*unt for j in range(30)]
    num = bisect.bisect_left(tmp,rd)
    ans.append(al[num-1])
    rd -= tmp[num-1]
    #print(rd)

print("".join(ans))