Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
N = len(S)


l = [0] * 2019
index = 0
temp = 0
for i in range(N-1, -1, -1):
    temp += int(S[i]) * 10**index
    l[temp%2019] += 1
    index += 1

ans = l[0]

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

print(ans)

Fixed submission:
S = list(input())
N = len(S)


l = [0] * 2019
l[0] = 1
m = 1
temp = 0
for i in range(N-1, -1, -1):
    temp += int(S[i]) * m
    temp %= 2019
    l[temp] += 1
    m *= 10
    m %= 2019

ans = 0

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

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = 0
l = 0
for c in s:
  if c == 'A' || c == 'C' || c == 'G' || c == 'T':
    l += 1
  else:
    ans = max(ans, l)
    l = 0
ans = max(ans, l)
print(ans)


Fixed submission:
s = input()
ans = 0
l = 0
for c in s:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    l += 1
  else:
    ans = max(ans, l)
    l = 0
ans = max(ans, l)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
print(2 * min(s.count(0), s.count(1)))


Fixed submission:
s = input()
print(2 * min(s.count('0'), s.count('1')))
Buggy python submission (verdict: Runtime Error):
s = int(input())
a = [0 for i in range(1000001)]
a[s] = 1
ai = s
i = 2
while True:
  if ai % 2 == 0:
    ai /= 2
  else:
    ai = 3 * ai + 1
  if a[ai] > 0:
    print(i)
    break
  else:
    a[ai] = 1
    i += 1


Fixed submission:
s = int(input())
a = [0 for i in range(1000001)]
a[s] = 1
ai = s
i = 2
while True:
  if ai % 2 == 0:
    ai //= 2
  else:
    ai = 3 * ai + 1
  if a[ai] > 0:
    print(i)
    break
  else:
    a[ai] = 1
    i += 1

Buggy python submission (verdict: Time Limit Exceeded):
s = int(input())
a = {s}
ai = s
i = 2
while True:
  if ai % 2 == 0:
    ai /= 2
  else:
    ai = 3 * ai + 1
  if ai in a:
    print(i)
    break
  else:
    i += 1


Fixed submission:
s = int(input())
a = [0 for i in range(1000001)]
a[s] = 1
ai = s
i = 2
while True:
  if ai % 2 == 0:
    ai //= 2
  else:
    ai = 3 * ai + 1
  if a[ai] > 0:
    print(i)
    break
  else:
    a[ai] = 1
    i += 1

Buggy python submission (verdict: Time Limit Exceeded):
s = int(input())
a = {s}
ai = s
i = 2
while True:
  if ai % 2 == 0:
    ai /= 2
  else:
    ai = 3 * ai + 1
  if ai in a:
    print(i)
    break
  else:
    i += 1


Fixed submission:
s = int(input())
a = [0 for i in range(1000001)]
a[s] = 1
ai = s
i = 2
while True:
  if ai % 2 == 0:
    ai //= 2
  else:
    ai = 3 * ai + 1
  if a[ai] > 0:
    print(i)
    break
  else:
    a[ai] = 1
    i += 1
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = sorted[int(input()) for i in range(n)]
ans = 1e9
for i in range(n - k + 1):
  ans = min(ans, h[i + k - 1] - h[i])
print(ans)


Fixed submission:
n, k = map(int, input().split())
h = sorted([int(input()) for i in range(n)])
ans = 1e9
for i in range(n - k + 1):
  ans = min(ans, h[i + k - 1] - h[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
x = []
y = []
for i in range(n):
  xi, yi = map(int, input().split())
  x.append(xi)
  y.append(yi)
parity = None
for i in range(n):
  if i == 0:
    parity = (x[i] + y[i]) % 2
  elif (x[i] + y[i]) % 2 != parity:
    print(-1)
    sys.exit()
print(20 - parity)
print(*[1] * (20 - parity))
for i in range(n):
  s = ''
  if x[i] > 0:
    s += 'R' * x[i]
  else:
    s += 'L' * (-x[i])
  if y[i] > 0:
    s += 'U' * y[i]
  else:
    s += 'D' * (-y[i])
  s += (20 - parity - abs(x[i]) - abs(y[i])) // 2 * 'LR'
  print(s)

Fixed submission:
import sys
import itertools
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
c = ['R', 'U', 'L', 'D']
n = int(input())
x = []
y = []
for i in range(n):
  xi, yi = map(int, input().split())
  x.append(xi)
  y.append(yi)
parity = None
for i in range(n):
  if i == 0:
    parity = (x[i] + y[i]) % 2
  elif (x[i] + y[i]) % 2 != parity:
    print(-1)
    sys.exit()
print(40)
d = []
for i in range(20):
  d.append(3**i)
  d.append(3**i)
d[1] += parity
print(*d)
d = [1] * 40
d[1] += parity
for i in range(n):
  for m in range(20):
    for j, k in itertools.product(range(4), range(4)):
      xnew = x[i] - (d[2*m] * dx[j] + d[2*m+1] * dx[k])
      ynew = y[i] - (d[2*m] * dy[j] + d[2*m+1] * dy[k])
      if xnew % 3 == 0 and ynew % 3 == 0:
        x[i] = xnew // 3
        y[i] = ynew // 3
        print(c[j] + c[k], end='')
        break
  print('')
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print(max(a, b, c) * 9 + sum(a, b, c))


Fixed submission:
a, b, c = map(int, input().split())
print(max(a, b, c) * 9 + a + b + c)
Buggy python submission (verdict: Runtime Error):
import itertools
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
s = []
for i, j in itertools.product(range(h), range(w - 1)):
  if a[i][j] % 2 == 1:
    s.append((i + 1, j + 1, i + 1, j + 2))
    a[i][j] -= 1
    a[i][j + 1] += 1
for i in range(h - 1):
  if a[i][j] % 2 == 1:
    s.append((i + 1, j + 1, i + 2, j + 1))
    a[i][j] -= 1
    a[i + 1][j] += 1
print(len(s))
for l in s:
  print(*l)


Fixed submission:
import itertools
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
s = []
for i, j in itertools.product(range(h), range(w - 1)):
  if a[i][j] % 2 == 1:
    s.append((i + 1, j + 1, i + 1, j + 2))
    a[i][j] -= 1
    a[i][j + 1] += 1
for i in range(h - 1):
  if a[i][w - 1] % 2 == 1:
    s.append((i + 1, w, i + 2, w))
    a[i][w - 1] -= 1
    a[i + 1][w - 1] += 1
print(len(s))
for l in s:
  print(*l)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
for i in range(min(len(s), k)):
  if s[i] != '1':
    print(c)
    break
else:
  print(s[k - 1])


Fixed submission:
s = input()
k = int(input())
for i in range(min(len(s), k)):
  if s[i] != '1':
    print(s[i])
    break
else:
  print(s[k - 1])

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
for i in range(k):
  if s[i] != '1':
    print(c)
    break
else:
  print(s[k - 1])


Fixed submission:
s = input()
k = int(input())
for i in range(min(len(s), k)):
  if s[i] != '1':
    print(s[i])
    break
else:
  print(s[k - 1])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, cs = map(int, input().split())
d = [list(map(int, input().split())) for i in range(cs)]
c = [list(map(int, input().split())) for i in range(n)]
for i, j in itertools.product(range(n), repeat=2):
  c[i][j] -= 1
ans = 10**20
for i, j, k in itertools.permutations(range(cs), 3):
  s = 0
  for l, m in itertools.product(range(n), repeat=2):
    if (l + m) % 3 == 0:
      s += d[c[l][m]][i]
    elif (l + m) % 3 == 1:
      s += d[c[l][m]][j]
    else:
      s += d[c[l][m]][k]
  ans = min(ans, s)
print(ans)


Fixed submission:
import itertools
n, cs = map(int, input().split())
d = [list(map(int, input().split())) for i in range(cs)]
c = [list(map(int, input().split())) for i in range(n)]
color_count = [[0] * cs for i in range(3)]
for i, j in itertools.product(range(n), repeat=2):
  color_count[(i + j) % 3][c[i][j] - 1] += 1
ans = 10**20
for t in itertools.permutations(range(cs), 3):
  s = 0
  for l in range(3):
    for m in range(cs):
      s += color_count[l][m] * d[m][t[l]]
  ans = min(ans, s)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, cs = map(int, input().split())
d = [list(map(int, input().split())) for i in range(cs)]
c = [list(map(int, input().split())) for i in range(n)]
for i, j in itertools.product(range(n), repeat=2):
  c[i][j] -= 1
ans = 10**20
for i, j, k in itertools.permutations(range(cs), 3):
  s = 0
  for l, m in itertools.product(range(n), repeat=2):
    if (l + m) % 3 == 0:
      s += d[c[l][m]][i]
    elif (l + m) % 3 == 1:
      s += d[c[l][m]][j]
    else:
      s += d[c[l][m]][k]
  ans = min(ans, s)
print(ans)


Fixed submission:
import itertools
n, cs = map(int, input().split())
d = [list(map(int, input().split())) for i in range(cs)]
c = [list(map(int, input().split())) for i in range(n)]
color_count = [[0] * cs for i in range(3)]
for i, j in itertools.product(range(n), repeat=2):
  color_count[(i + j) % 3][c[i][j] - 1] += 1
ans = 10**20
for t in itertools.permutations(range(cs), 3):
  s = 0
  for l in range(3):
    for m in range(cs):
      s += color_count[l][m] * d[m][t[l]]
  ans = min(ans, s)
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = input()
for i in len(s):
  if (i == a) != (s[i] == '-'):
    print('No')
    break
else:
  print('Yes')


Fixed submission:
a, b = map(int, input().split())
s = input()
for i in range(len(s)):
  if (i == a) != (s[i] == '-'):
    print('No')
    break
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a0, a1, a2 = 0, 0, 0
for i in a:
  if a % 2 == 1:
    a0 += 1
  elif a % 4 == 2:
    a1 = 1
  else:
    a2 += 1
if a0 + a1 <= a2 + 1:
  print('Yes')
else:
  print('No')


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a0, a1, a2 = 0, 0, 0
for i in a:
  if i % 2 == 1:
    a0 += 1
  elif i % 4 == 2:
    a1 = 1
  else:
    a2 += 1
if a0 + a1 <= a2 + 1:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
else:
  print('NO')


Fixed submission:
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
import math
a, b, c = map(int, input().split())
if c % math.gcd(a, b) == 0:
  print('YES')
else:
  print('NO')


Fixed submission:
import fractions
a, b, c = map(int, input().split())
if c % fractions.gcd(a, b) == 0:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
import math
n, x = map(int, input().split())
print(3 * (n - gcd(n, x)))


Fixed submission:
import math
n, x = map(int, input().split())
print(3 * (n - math.gcd(n, x)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int, input().split()))

total = 0 

for i in range(len(s)-1):
  for j in range(i+1, len(s)):
    total += s[i] * s[j]

print(total % (10**9 +7))

Fixed submission:
n = int(input())
s = list(map(int, input().split()))

ans= 0
total = sum(s)

for i in range(len(s)-1):
  total -= s[i]
  ans += total * s[i]

print(ans % (10**9 +7))
Buggy python submission (verdict: Runtime Error):
t = input()

if t >= 30:
  print('Yes')
else:
  print('No')

Fixed submission:
t = int(input())

if t >= 30:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n, d = list(map(int, split().input()))n, d = list(map(int, input().split()))
count = 0
for i in range(n):
  x, y = list(map(int, input().split()))
  p = x **2 + y **2
  if p <= d**2:
    count += 1
    
print(count)

Fixed submission:
n, d = list(map(int, input().split()))
count = 0
for i in range(n):
  x, y = list(map(int, input().split()))
  p = x **2 + y **2
  if p <= d**2:
    count += 1
    
print(count)

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

Fixed submission:
n, d = list(map(int, input().split()))
count = 0
for i in range(n):
  x, y = list(map(int, input().split()))
  p = x **2 + y **2
  if p <= d**2:
    count += 1
    
print(count)
Buggy python submission (verdict: Runtime Error):
rate = imput()

di = rate // 200

print(10 - di)

Fixed submission:
rate = int(input())

print(10 - rate // 200)
Buggy python submission (verdict: Runtime Error):
a = int(input())
print(a + a**2 + a***3)

Fixed submission:
a = int(input())
print(a + a**2 + a**3)
Buggy python submission (verdict: Runtime Error):
n = int(input())

if len(n) % 2 == 1:
  print('No')
else:
  a = n[0 : len(n)//2]
  b = n[len(n)//2 : len(n)]
  if a == b:
    print('Yes')
  else:
    print('No')

Fixed submission:
n = int(input())
print(n**2)
Buggy python submission (verdict: Runtime Error):
n = str(input())
if len(n) % 2 ==1:
  print('No')
else:
  a = n[0 : len(n)/2]
  b = n[len(n)/2 : len(n)]
  if a = b:
    print('Yes')
  else:
    print('No')

Fixed submission:
nn = input()
n = str(input())

if len(n) % 2 == 1:
  print('No')
else:
  a = n[0 : len(n)//2]
  b = n[len(n)//2 : len(n)]
  if a == b:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n = str(input())
if len(n) % 2 ==1:
  print('No')
else:
  a = n[0 : len(n)/2]
  b = n[len(n)/2 : len(n)]
  if a == b:
    print('Yes')
  else:
    print('No')

Fixed submission:
nn = input()
n = str(input())

if len(n) % 2 == 1:
  print('No')
else:
  a = n[0 : len(n)//2]
  b = n[len(n)//2 : len(n)]
  if a == b:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a b = list(map(int, input().split()))
if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')

Fixed submission:
a, b = list(map(int, input().split()))
if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if a==0 or b==0:
        return max([a,b])
    else:
        if a>=b:
            return gcd(a-b,b)
        else:
            return gcd(a,b-a)

def lcm(a,b):
   return int(a*b/gcd(a,b)) 
a=input().split(" ")
print(lcm(int(a[0]),int(a[1])))

Fixed submission:
def gcd(a,b):
    if a==0 or b==0:
        return max([a,b])
    else:
        if a>=b:
            n=int(a/b)
            return gcd(a-n*b,b)
        else:
            n=int(b/a)
            return gcd(a,b-n*a)

def lcm(a,b):
   return int(a*b/gcd(a,b)) 
a=input().split(" ")
print(lcm(int(a[0]),int(a[1])))

Buggy python submission (verdict: Runtime Error):
def lcm(a,b):
    if a==0 or b==0:
        return max([a,b])
    else:
        if a>=b:
            return lcm(a-b,b)
        else:
            return lcm(a,b-a)
a=input().split(" ")
print(lcm(int(a[0]),int(a[1])))

Fixed submission:
def gcd(a,b):
    if a==0 or b==0:
        return max([a,b])
    else:
        if a>=b:
            n=int(a/b)
            return gcd(a-n*b,b)
        else:
            n=int(b/a)
            return gcd(a,b-n*a)

def lcm(a,b):
   return int(a*b/gcd(a,b)) 
a=input().split(" ")
print(lcm(int(a[0]),int(a[1])))

Buggy python submission (verdict: Time Limit Exceeded):
c=input().split(" ")

a=int(c[0])
b=int(c[1])

for i in range(1,a*b+1):
    if i%a==0 and i%b==0:
        print(i)
        break


Fixed submission:
def gcd(a,b):
    if a==0 or b==0:
        return max([a,b])
    else:
        if a>=b:
            n=int(a/b)
            return gcd(a-n*b,b)
        else:
            n=int(b/a)
            return gcd(a,b-n*a)

def lcm(a,b):
   return int(a*b/gcd(a,b)) 
a=input().split(" ")
print(lcm(int(a[0]),int(a[1])))
Buggy python submission (verdict: Runtime Error):
def nn(n):
    if n==0:
        return 1
    else:
        return n*nn(n-1)

n=int(input())
ans=nn(n)%100000007
print(ans)

Fixed submission:
N = int(input())
C = 10**9+7
ans = 1
for i in range(1, N + 1):
    ans *= i
    ans %= C
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

K_list = [0] * N
K_sum = 0

A_sum = 0

for i in range(N):
    A_sum += A[i]

if A_sum <= K:
    print(0)

else:
    left = 0
    right = A[N-1] * F[0]

    while right - left > 1:
        K_sum = 0
        mid = (right + left) // 2
        for i in range(N):
            if A[i] * F[i] > mid:
                K_list[i] = A[i] - mid // F[i]
                K_sum += K_list[i]

        if K_sum > K:
            left = mid
        else:
            right = mid
    print(right)


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

A.sort()
F.sort(reverse=True)

K_list = [0] * N
K_sum = 0

A_sum = 0

for i in range(N):
    A_sum += A[i]

if A_sum <= K:
    print(0)

else:
    left = 0
    right = A[N-1] * F[0]

    while right - left > 1:
        K_sum = 0
        mid = (right + left) // 2
        for i in range(N):
            if A[i] * F[i] > mid:
                K_list[i] = A[i] - mid // F[i]
                K_sum += K_list[i]

        if K_sum > K:
            left = mid
        else:
            right = mid
    print(right)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

success = 0

for x in range (K + 1):
    for y in range (K + 1):
        for z in range (K + 1):
            if x + y + z == S:
                success = success + 1

print(success)


Fixed submission:
K, S = map(int, input().split())

success = 0

for x in range (K + 1):
    for y in range (K + 1):
        if S - x - y >= 0 and S - x - y <= K:
            success = success + 1

print(success)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = [int(i) for i in input().split()]
count = 0

for i in range(a, b + 1):
  if i % x == 0:
    count += 1

print(count)

Fixed submission:
a, b, x = [int(i) for i in input().split()]

if a % x == 0:
  print(b // x - a // x + 1)
else:
  print(b // x - a // x)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = [int(i) for i in input().split()]
count = 0

for i in range(a, b + 1):
  if i % x == 0:
    count += 1

print(count)

Fixed submission:
a, b, x = [int(i) for i in input().split()]

if a % x == 0:
  print(b // x - a // x + 1)
else:
  print(b // x - a // x)
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



N,M=map(int,input().split())
A=[0]*M
B=[0]*M
for i in range(M):
    A[i],B[i]=map(int,input().split())

uf=UnionFind(N+1)
for i in range(M):
    uf.union(A[i],B[i])
    #print(uf.find(1))
#print()
a=[0]*N
#print(uf)
print(len(list(uf.all_group_members().values()))-2)


Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N,M=map(int,input().split())
A=[0]*M
B=[0]*M
for i in range(M):
    A[i],B[i]=map(int,input().split())

uf=UnionFind(N+1)
for i in range(M):
    uf.union(A[i],B[i])
a=[0]*(N+1)
con=0

for i in uf.parents:
    if(i<0):
        con=con+1

print(con-2)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
for i in range(N):
    A[i]=A[i]%(10**9+7)
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        ans=(ans+A[i]*A[j])%(10**9+7)
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
wa=[0]*(N-1)
wa[0]=A[-1]
for i in range(1,N-1):
    wa[i]=wa[i-1]+A[N-i-1]
ans=0
wa.reverse()

for i in range(0,N-1):

    ans=(ans+wa[i]*A[i])%(10**9+7)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        ans=(ans+A[i]*A[j])%(10**9+7)
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
wa=[0]*(N-1)
wa[0]=A[-1]
for i in range(1,N-1):
    wa[i]=wa[i-1]+A[N-i-1]
ans=0
wa.reverse()

for i in range(0,N-1):

    ans=(ans+wa[i]*A[i])%(10**9+7)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

c=list(input())


#c[1]=c[2]
sta=1
ans=0
for i in range(N):
    if(-sta+N<i):
        break
    if(c[i]=='W'):
        for j in range(sta,N):
            if(-j+N<=i):
                break
            if(c[-j]=='R'):
                temp=c[-j]
                c[-j]=c[i]
                c[i]=temp
                sta=j
                ans=ans+1
                break


print(ans)


Fixed submission:
N=int(input())

c=list(input())


#c[1]=c[2]
sta=1
ans=0
for i in range(N):
    if(-sta+N<i):
        break
    if(c[i]=='W'):
        for j in range(sta,N):
            if(-j+N<=i):
                print(ans)
                exit()
                break
            if(c[-j]=='R'):
                temp=c[-j]
                c[-j]=c[i]
                c[i]=temp
                sta=j
                ans=ans+1
                break


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

c=list(input())


#c[1]=c[2]
sta=1
ans=0
for i in range(N):
    if(c[i]=='W'):
        for j in range(sta,N):
            if(-j+N<=i):
                break
            if(c[-j]=='R'):
                temp=c[-j]
                c[-j]=c[i]
                c[i]=temp
                sta=j
                ans=ans+1
                break


print(ans)


Fixed submission:
N=int(input())

c=list(input())


#c[1]=c[2]
sta=1
ans=0
for i in range(N):
    if(-sta+N<i):
        break
    if(c[i]=='W'):
        for j in range(sta,N):
            if(-j+N<=i):
                print(ans)
                exit()
                break
            if(c[-j]=='R'):
                temp=c[-j]
                c[-j]=c[i]
                c[i]=temp
                sta=j
                ans=ans+1
                break


print(ans)